QSimpleUpdater
A simple auto-updater system for Qt applications
Updater.h
1 /*
2  * Copyright (c) 2014-2016 Alex Spataru <alex_spataru@outlook.com>
3  *
4  * This file is part of the QSimpleUpdater library, which is released under
5  * the DBAD license, you can read a copy of it below:
6  *
7  * DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING,
8  * DISTRIBUTION AND MODIFICATION:
9  *
10  * Do whatever you like with the original work, just don't be a dick.
11  * Being a dick includes - but is not limited to - the following instances:
12  *
13  * 1a. Outright copyright infringement - Don't just copy this and change the
14  * name.
15  * 1b. Selling the unmodified original with no work done what-so-ever, that's
16  * REALLY being a dick.
17  * 1c. Modifying the original work to contain hidden harmful content.
18  * That would make you a PROPER dick.
19  *
20  * If you become rich through modifications, related works/services, or
21  * supporting the original work, share the love.
22  * Only a dick would make loads off this work and not buy the original works
23  * creator(s) a pint.
24  *
25  * Code is provided with no warranty. Using somebody else's code and bitching
26  * when it goes wrong makes you a DONKEY dick.
27  * Fix the problem yourself. A non-dick would submit the fix back.
28  */
29 
30 #ifndef _QSIMPLEUPDATER_UPDATER_H
31 #define _QSIMPLEUPDATER_UPDATER_H
32 
33 #include <QUrl>
34 #include <QObject>
35 #include <QNetworkReply>
36 #include <QNetworkAccessManager>
37 
38 #include <QSimpleUpdater.h>
39 
40 class Downloader;
41 
47 class QSU_DECL Updater : public QObject {
48  Q_OBJECT
49 
50  public:
51  Updater();
52  ~Updater();
53 
57  QString url() const;
58 
66  QString platformKey() const;
67 
72  bool notifyOnUpdate() const;
73 
79  bool notifyOnFinish() const;
80 
85  bool updateAvailable() const;
86 
91  bool downloaderEnabled() const;
92 
96  QString changelog() const;
97 
101  QString downloadUrl() const;
102 
106  QString latestVersion() const;
107 
112  QString moduleName() const;
113 
118  QString moduleVersion() const;
119 
127  bool useCustomInstallProcedures() const;
128 
129  public slots:
134  void checkForUpdates();
135 
139  void setUrl (const QString& url);
140 
148  void setNotifyOnUpdate (const bool& notify);
149 
157  void setNotifyOnFinish (const bool& notify);
158 
163  void setModuleName (const QString& name);
164 
170  void setModuleVersion (const QString& version);
171 
178  void setDownloaderEnabled (const bool& enabled);
179 
185  void setPlatformKey (const QString& platformKey);
186 
193  void setUseCustomInstallProcedures (const bool& custom);
194 
195  signals:
199  void checkingFinished (const QString& url);
200 
206  void downloadFinished (const QString& url, const QString& filepath);
207 
208  private slots:
212  void onReply (QNetworkReply* reply);
213 
218  void setUpdateAvailable (const bool& available);
219 
220  private:
226  bool compare (const QString& x, const QString& y);
227 
228  private:
229  QString m_url;
230 
231  bool m_notifyOnUpdate;
232  bool m_notifyOnFinish;
233  bool m_updateAvailable;
234  bool m_downloaderEnabled;
235 
236  QString m_openUrl;
237  QString m_platform;
238  QString m_changelog;
239  QString m_moduleName;
240  QString m_downloadUrl;
241  QString m_moduleVersion;
242  QString m_latestVersion;
243 
244  Downloader* m_downloader;
245  QNetworkAccessManager* m_manager;
246 };
247 
248 #endif
Definition: Updater.h:47
Definition: Downloader.h:29