MythTV  master
mythrssmanager.h
Go to the documentation of this file.
1 #ifndef MYTHRSSMANAGER_H
2 #define MYTHRSSMANAGER_H
3 
4 #include <vector>
5 
6 #include <QObject>
7 #include <QMetaType>
8 #include <QMutex>
9 #include <QTimer>
10 #include <QDateTime>
11 #include <QByteArray>
12 #include <QVariant>
13 #include <QNetworkReply>
14 
15 #include "rssparse.h"
16 
17 
18 class RSSSite;
19 class MPUBLIC RSSSite : public QObject
20 {
21  Q_OBJECT
22 
23  public:
24 
25  class List : public std::vector<RSSSite*>
26  {
27  public:
28  void clear(void)
29  {
30  while (size())
31  {
32  RSSSite *tmp = back();
33  pop_back();
34  tmp->deleteLater();
35  }
36  }
37  };
38 
39  RSSSite(const QString& title,
40  const QString& sortTitle,
41  const QString& image,
42  const ArticleType& type,
43  const QString& description,
44  const QString& url,
45  const QString& author,
46  const bool& download,
47  const QDateTime& updated);
48 
49  ~RSSSite() = default;
50 
51  typedef QList<RSSSite *> rssList;
52 
53  const QString& GetTitle() const { return m_title; }
54  const QString& GetSortTitle() const { return m_sortTitle; }
55  const QString& GetImage() const { return m_image; }
56  const ArticleType& GetType() const { return m_type; }
57  const QString& GetDescription() const { return m_description; }
58  const QString& GetURL() const { return m_url; }
59  const QString& GetAuthor() const { return m_author; }
60  const bool& GetDownload() const { return m_download; }
61  const QDateTime& GetUpdated() const { return m_updated; }
62 
63  unsigned int timeSinceLastUpdate(void) const; // in minutes
64 
65  void insertRSSArticle(ResultItem *item);
66  void clearRSSArticles(void);
67 
68  ResultItem::resultList GetVideoList(void) const;
69 
70  void retrieve(void);
71  void stop(void);
72  void process(void);
73 
74  private:
75 
76  QUrl redirectUrl(const QUrl& possibleRedirectUrl,
77  const QUrl& oldRedirectUrl) const;
78 
79  QString m_title;
80  QString m_sortTitle;
81  QString m_image;
83  QString m_description;
84  QString m_url;
85  QUrl m_urlReq;
86  QString m_author;
87  bool m_download;
88  QDateTime m_updated;
89 
90  mutable QMutex m_lock {QMutex::Recursive};
91  QByteArray m_data;
92  QString m_imageURL;
93  bool m_podcast {false};
94 
96 
97  QNetworkReply *m_reply {nullptr};
98  QNetworkAccessManager *m_manager {nullptr};
99 
100  private slots:
101  void slotCheckRedirect(QNetworkReply* reply);
102 
103  signals:
104 
105  void finished(RSSSite *item);
106 
107 };
108 
109 class MPUBLIC RSSManager : public QObject
110 {
111  Q_OBJECT
112 
113  public:
114  RSSManager();
115  ~RSSManager();
116  void startTimer();
117  void stopTimer();
118 
119  signals:
120  void finished();
121 
122  public slots:
123  void doUpdate();
124 
125  private slots:
126  void slotRefreshRSS(void);
127  void slotRSSRetrieved(RSSSite*);
128 
129  private:
130  void processAndInsertRSS(RSSSite *site);
131 
132  QTimer *m_timer {nullptr};
134  uint m_updateFreq {6 * 3600 * 1000};
136 };
137 
139 
140 #endif
void clear(void)
unsigned int slots[4]
Definition: element.c:38
#define MPUBLIC
Definition: mythexp.h:10
bool clearRSSArticles(const QString &feedtitle, ArticleType type)
Definition: netutils.cpp:718
const QDateTime & GetUpdated() const
QString m_title
QList< RSSSite * > rssList
unsigned int uint
Definition: compat.h:140
QByteArray m_data
Q_DECLARE_METATYPE(GrabberScript *)
static guint32 * tmp
Definition: goom_core.c:35
QString m_url
QString m_sortTitle
const QString & GetSortTitle() const
const ArticleType & GetType() const
const QString & GetImage() const
QString m_description
QString m_author
RSSSite::rssList m_inprogress
const QString & GetURL() const
const QString & GetTitle() const
ResultItem::resultList m_articleList
QDateTime m_updated
const QString & GetAuthor() const
const QString & GetDescription() const
QString m_imageURL
QString m_image
bool m_download
QUrl m_urlReq
static guint32 * back
Definition: goom_core.c:34
QList< ResultItem * > resultList
Definition: rssparse.h:114
ArticleType m_type
enum ArticleTypes ArticleType
const bool & GetDownload() const
RSSSite::rssList m_sites