Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
software_update.h
Go to the documentation of this file.
1
10#ifndef SOFTWARE_UPDATE_H
11#define SOFTWARE_UPDATE_H
12
13#include <QObject>
14#include <QUrl>
15#include <QMutex>
16#include <QTimer>
17#include <QVersionNumber>
18
19class QNetworkAccessManager;
20class QNetworkReply;
21
23public:
24 void accept();
25 void reject(const QString& reason = {});
26
27 bool isAccepted() const;
28 QString reason() const;
29
30private:
31 bool accepted_ = false;
32 bool rejected_ = false;
33 QString reason_;
34};
35
37 QString title;
38 QVersionNumber version;
39 QVersionNumber shortVersion;
40 QUrl downloadUrl;
41 QUrl releaseNotesUrl;
42 QString os; // "windows", "macos", or empty (= all)
43 qint64 length = 0;
44 QString edSignature;
45};
46
58class SoftwareUpdate : public QObject
59{
60 Q_OBJECT
61public:
62 SoftwareUpdate(const SoftwareUpdate&) = delete;
63 SoftwareUpdate& operator=(const SoftwareUpdate&) = delete;
64
65 static SoftwareUpdate* instance();
66
77 void init(bool runWithoutSilentCheck = false);
78
82 void cleanup();
83
94 static void performUIUpdate();
95
99 static QString info();
100
108 static bool plattformSupported();
109
110 /**** Utility functions if the automatic update check needs to be manipulated through the UI ****/
111
112 void startAutoCheck(int intervalSeconds = 0);
113 void stopAutoCheck();
114 bool isAutoCheckEnabled() const;
115
116signals:
118 void updateAvailable(QString newVersion, QString releaseNotes);
120 void updateCheckFailed(const QString& errorString);
132
133private:
134 static SoftwareUpdate* instance_;
135 static QMutex mutex_;
136 static QMutex updateMutex_;
137
138 QTimer* updateCheckTimer_;
139 QNetworkAccessManager* networkAccessManager_;
140
141 QUrl updateUrl() const;
142 QList<AppcastItem> parseAppcast(const QByteArray &data) const;
143
144#if defined(_WIN32)
145 static int __cdecl softwareUpdateCanShutdownCallback();
146 static void __cdecl shutdownRequestCallback();
147 static void __cdecl softwareUpdateEngaged();
148#elif defined(__APPLE__)
149 static void onPostponeRelaunch(void (*proceed)(void *ctx), void *ctx);
150#endif /* if */
151
152private slots:
153 void onNetworkReplyFinished(QNetworkReply* reply);
154 void checkForUpdates();
155
156protected:
157 explicit SoftwareUpdate(QObject *parent = nullptr);
159};
160
161#endif /* SOFTWARE_UPDATE_H */
Definition software_update.h:22
The SoftwareUpdate class provides an interface for checking for software updates and engaging the upd...
Definition software_update.h:59
static void performUIUpdate()
Definition software_update.cpp:265
void updateCheckFailed(const QString &errorString)
void updateAvailable(QString newVersion, QString releaseNotes)
static bool plattformSupported()
Definition software_update.cpp:219
void appShutdownRequested(ShutdownEvent *shutdownEvent)
void init(bool runWithoutSilentCheck=false)
Definition software_update.cpp:125
static QString info()
Definition software_update.cpp:204
void updateEngaged()
void cleanup()
Definition software_update.cpp:281
Definition software_update.h:36