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 
45 class QSU_DECL Updater : public QObject {
46  Q_OBJECT
47 
48  signals:
49  void checkingFinished (const QString& url);
50  void downloadFinished (const QString& url, const QString& filepath);
51 
52  public:
53  Updater();
54  ~Updater();
55 
56  QString url() const;
57  QString changelog() const;
58  QString moduleName() const;
59  QString downloadUrl() const;
60  QString platformKey() const;
61  QString moduleVersion() const;
62  QString latestVersion() const;
63 
64  bool notifyOnUpdate() const;
65  bool notifyOnFinish() const;
66  bool updateAvailable() const;
67  bool downloaderEnabled() const;
68  bool useCustomInstallProcedures() const;
69 
70  public slots:
71  void checkForUpdates();
72  void setUrl (const QString& url);
73  void setModuleName (const QString& name);
74  void setNotifyOnUpdate (const bool& notify);
75  void setNotifyOnFinish (const bool& notify);
76  void setModuleVersion (const QString& version);
77  void setDownloaderEnabled (const bool& enabled);
78  void setPlatformKey (const QString& platformKey);
79  void setUseCustomInstallProcedures (const bool& custom);
80 
81  private slots:
82  void onReply (QNetworkReply* reply);
83  void setUpdateAvailable (const bool& available);
84 
85  private:
86  bool compare (const QString& x, const QString& y);
87 
88  private:
89  QString m_url;
90 
91  bool m_notifyOnUpdate;
92  bool m_notifyOnFinish;
93  bool m_updateAvailable;
94  bool m_downloaderEnabled;
95 
96  QString m_openUrl;
97  QString m_platform;
98  QString m_changelog;
99  QString m_moduleName;
100  QString m_downloadUrl;
101  QString m_moduleVersion;
102  QString m_latestVersion;
103 
104  Downloader* m_downloader;
105  QNetworkAccessManager* m_manager;
106 };
107 
108 #endif
Downloads and interprests the update definition file.
Definition: Updater.h:45
Implements an integrated file downloader with a nice UI.
Definition: Downloader.h:46