ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Updater.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <QUrl>
11 #include <QObject>
12 #include <QNetworkReply>
13 #include <QNetworkAccessManager>
14 
16 
17 class Downloader;
18 
22 class QSU_DECL Updater : public QObject
23 {
24  Q_OBJECT
25 
26 signals:
27  void checkingFinished(const QString &url);
28  void downloadFinished(const QString &url, const QString &filepath);
29  void appcastDownloaded(const QString &url, const QByteArray &data);
30 
31 public:
32  Updater();
33  ~Updater();
34 
35  QString url() const;
36  QString openUrl() const;
37  QString changelog() const;
38  QString moduleName() const;
39  QString downloadUrl() const;
40  QString platformKey() const;
41  QString moduleVersion() const;
42  QString latestVersion() const;
43  QString userAgentString() const;
44  bool mandatoryUpdate() const;
45 
46  bool customAppcast() const;
47  bool notifyOnUpdate() const;
48  bool notifyOnFinish() const;
49  bool updateAvailable() const;
50  bool downloaderEnabled() const;
51  bool useCustomInstallProcedures() const;
52 
53 public slots:
54  void checkForUpdates();
55  void setUrl(const QString &url);
56  void setModuleName(const QString &name);
57  void setNotifyOnUpdate(const bool notify);
58  void setNotifyOnFinish(const bool notify);
59  void setUserAgentString(const QString &agent);
60  void setModuleVersion(const QString &version);
61  void setDownloaderEnabled(const bool enabled);
62  void setPlatformKey(const QString &platformKey);
63  void setUseCustomAppcast(const bool customAppcast);
64  void setUseCustomInstallProcedures(const bool custom);
65  void setMandatoryUpdate(const bool mandatory_update);
66 
67 private slots:
68  void onReply(QNetworkReply *reply);
69  void setUpdateAvailable(const bool available);
70 
71 private:
72  bool compare(const QString &x, const QString &y);
73 
74 private:
75  QString m_url;
76  QString m_userAgentString;
77 
78  bool m_customAppcast;
79  bool m_notifyOnUpdate;
80  bool m_notifyOnFinish;
81  bool m_updateAvailable;
82  bool m_downloaderEnabled;
83  bool m_mandatoryUpdate;
84 
85  QString m_openUrl;
86  QString m_platform;
87  QString m_changelog;
88  QString m_moduleName;
89  QString m_downloadUrl;
90  QString m_moduleVersion;
91  QString m_latestVersion;
92 
93  Downloader *m_downloader;
94  QNetworkAccessManager *m_manager;
95 };
Compare compare
std::string version
std::string name
#define slots
#define signals
#define QSU_DECL
Implements an integrated file downloader with a nice UI.
Definition: Downloader.h:26
Downloads and interprests the update definition file.
Definition: Updater.h:23
void downloadFinished(const QString &url, const QString &filepath)
void checkingFinished(const QString &url)
void appcastDownloaded(const QString &url, const QByteArray &data)