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
26public:
30 void accept();
31
37 void reject(const QString &reason = {});
38
43 bool isAccepted() const;
44
50 QString reason() const;
51
52private:
53 bool accepted_ = false;
54 bool rejected_ = false;
55 QString reason_;
56};
57
62 QString title;
63 QVersionNumber version;
64 QVersionNumber shortVersion;
69 QString os;
70 qint64 length = 0;
71 QString edSignature;
72};
73
85class SoftwareUpdate : public QObject
86{
87 Q_OBJECT
88public:
90 SoftwareUpdate(const SoftwareUpdate &) = delete;
91
94
99 static SoftwareUpdate *instance();
100
111 void init(bool runWithoutSilentCheck = false);
112
116 void cleanup();
117
128 static void performUIUpdate();
129
133 static QString info();
134
142 static bool plattformSupported();
143
144/**** Utility functions for manipulating the automatic update check through the UI ****/
145
152void startAutoCheck(int intervalSeconds = 0);
153
157void stopAutoCheck();
158
163bool isAutoCheckEnabled() const;
164
165signals:
171 void updateAvailable(QString newVersion, QString releaseNotes);
172
177 void updateCheckFailed(const QString &errorString);
178
190
196
197private:
198 static SoftwareUpdate *instance_;
199 static QMutex mutex_;
200 static QMutex updateMutex_;
202 QTimer *updateCheckTimer_;
203 QNetworkAccessManager *networkAccessManager_;
209 QUrl updateUrl() const;
210
216 QList<AppcastItem> parseAppcast(const QByteArray &data) const;
217
218
219#if defined(_WIN32)
224 static int __cdecl softwareUpdateCanShutdownCallback();
225
229 static void __cdecl shutdownRequestCallback();
230
234 static void __cdecl softwareUpdateEngaged();
235
236#elif defined(__APPLE__)
243 static void onPostponeRelaunch(void (*proceed)(void *ctx), void *ctx);
244#endif /* if */
245
246private slots:
251 void onNetworkReplyFinished(QNetworkReply *reply);
252
258 void checkForUpdates();
259
260
261protected:
266 explicit SoftwareUpdate(QObject *parent = nullptr);
267
270};
271
272#endif /* SOFTWARE_UPDATE_H */
An event object passed to shutdown listeners to allow vetoing.
Definition software_update.h:25
QString reason() const
Return the reason provided to the most recent reject() call.
Definition software_update.cpp:90
void accept()
Signal that this listener consents to the shutdown.
Definition software_update.cpp:74
bool isAccepted() const
Return whether the shutdown has been accepted.
Definition software_update.cpp:86
void reject(const QString &reason={})
Veto the shutdown with an optional explanatory message.
Definition software_update.cpp:80
The SoftwareUpdate class provides an interface for checking for software updates and engaging the upd...
Definition software_update.h:86
void stopAutoCheck()
Stop the periodic automatic update check.
Definition software_update.cpp:315
static void performUIUpdate()
Definition software_update.cpp:265
void updateCheckFailed(const QString &errorString)
Emitted when the update check fails.
void updateAvailable(QString newVersion, QString releaseNotes)
Emitted when a new software update is available.
static bool plattformSupported()
Definition software_update.cpp:219
SoftwareUpdate & operator=(const SoftwareUpdate &)=delete
Deleted copy-assignment operator — SoftwareUpdate is a singleton.
void appShutdownRequested(ShutdownEvent *shutdownEvent)
Emitted when the application requests a shutdown to perform an update.
static SoftwareUpdate * instance()
Return the singleton SoftwareUpdate instance.
Definition software_update.cpp:115
void init(bool runWithoutSilentCheck=false)
Definition software_update.cpp:125
~SoftwareUpdate()
Destroy the SoftwareUpdate singleton and release all resources.
Definition software_update.cpp:110
void startAutoCheck(int intervalSeconds=0)
Start the periodic automatic update check.
Definition software_update.cpp:289
static QString info()
Definition software_update.cpp:204
void updateEngaged()
Emitted when the update process is engaged.
void cleanup()
Definition software_update.cpp:281
bool isAutoCheckEnabled() const
Return whether the periodic automatic update check is enabled.
Definition software_update.cpp:324
SoftwareUpdate(const SoftwareUpdate &)=delete
Deleted copy constructor — SoftwareUpdate is a singleton.
A single entry from a Sparkle-compatible appcast feed.
Definition software_update.h:61
QUrl releaseNotesUrl
Definition software_update.h:66
QVersionNumber shortVersion
Definition software_update.h:64
qint64 length
Definition software_update.h:70
QVersionNumber version
Definition software_update.h:63
QString title
Definition software_update.h:62
QString edSignature
Definition software_update.h:71
QString os
Definition software_update.h:69
QUrl downloadUrl
Definition software_update.h:65