DBLSQD Qt SDK
feed.h
1 #ifndef DBLSQD_FEED_H
2 #define DBLSQD_FEED_H
3 
4 #include <QtCore>
5 #include <QtNetwork>
6 #include "dblsqd/release.h"
7 
8 namespace dblsqd {
9 
10 class Feed : public QObject
11 {
12  Q_OBJECT
13 
14 public:
15  Feed(QString baseUrl = "", QString channel = "release", QString os = QString(), QString arch = QString(), QString type = QString());
16 
17  void setUrl(QUrl url);
18  void setUrl(QString baseUrl, QString channel = "release", QString os = QString(), QString arch = QString(), QString type = QString());
19  QUrl getUrl();
20 
21  //Async API
22  void load();
23  void downloadRelease(Release release);
24 
25  //Sync API
26  QList<Release> getUpdates(Release currentRelease = Release(QCoreApplication::applicationVersion()));
27  QList<Release> getReleases();
28  QTemporaryFile* getDownloadFile();
29  bool isReady();
30 
31 signals:
32  void ready();
33  void loadError(QString message);
34  void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
35  void downloadFinished();
36  void downloadError(QString message);
37 
38 private:
39  QUrl url;
40 
41  QList<Release> releases;
42 
43  void makeDownloadRequest(QUrl url);
44 
45  QNetworkAccessManager nam;
46  QNetworkReply* feedReply;
47  Release release;
48  QNetworkReply* downloadReply;
49  QTemporaryFile* downloadFile;
50  uint redirects;
51  bool _ready;
52 
53 private slots:
54  void handleFeedFinished();
55  void handleDownloadProgress(qint64, qint64);
56  void handleDownloadReadyRead();
57  void handleDownloadFinished();
58 };
59 
60 } // namespace dblsqd
61 
62 #endif // DBLSQD_FEED_H
Feed(QString baseUrl="", QString channel="release", QString os=QString(), QString arch=QString(), QString type=QString())
Constructs a new Feed object.
Definition: feed.cpp:25
void ready()
Definition: moc_feed.cpp:195
QTemporaryFile * getDownloadFile()
Returns the pointer to a QTemporaryFile for a downloaded file.
Definition: feed.cpp:127
bool isReady()
Returns true if Feed information has been retrieved successfully.
Definition: feed.cpp:137
void downloadError(QString message)
Definition: moc_feed.cpp:221
The Feed class provides methods for accessing DBLSQD Feeds and downloading Releases.
Definition: feed.h:10
void downloadFinished()
Definition: moc_feed.cpp:215
void loadError(QString message)
Definition: moc_feed.cpp:201
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
Definition: moc_feed.cpp:208
QList< Release > getUpdates(Release currentRelease=Release(QCoreApplication::applicationVersion()))
Returns a list of all Releases in the Feed that are newer than the given Release. ...
Definition: feed.cpp:113
Definition: feed.cpp:3
QUrl getUrl()
Returns the Feed URL.
Definition: feed.cpp:91
This class is used to represent information about a single Release from a Feed.
Definition: release.h:10
void setUrl(QUrl url)
Sets the Feed URL.
Definition: feed.cpp:41
void downloadRelease(Release release)
Starts the download of a given Release.
Definition: feed.cpp:164
QList< Release > getReleases()
Returns a list of all Releases in the Feed.
Definition: feed.cpp:102
void load()
Retrieves and parses data from the Feed.
Definition: feed.cpp:150