Deals with program updates/upgrades. More...
#include <autoupdater.h>
Public Slots | |
void | confirmDownloadAndInstall () |
Signals | |
void | downloadAndInstallConfirmationRequested () |
Information on update packages has been received and install confirmation is requested. More... | |
void | finished () |
AutoUpdater has finished its job. More... | |
void | overallProgress (int current, int total, const QString &msg) |
void | packageDownloadProgress (qint64 bytesReceived, qint64 bytesTotal) |
void | statusMessage (const QString &message) |
Public Member Functions | |
AutoUpdater (QObject *pParent=nullptr) | |
void | abort () |
const UpdateChannel & | channel () const |
setChannel() . More... | |
const QStringList & | downloadedPackagesFilenames () const |
Filenames for packages which are ready to install. More... | |
ErrorCode | errorCode () const |
QString | errorString () const |
bool | isRunning () const |
QNetworkReply::NetworkError | lastNetworkError () const |
The network error that caused the updater to fail. More... | |
const QList< UpdatePackage > & | newUpdatePackages () const |
List of new update packages to install. More... | |
void | setChannel (const UpdateChannel &updateChannel) |
Update channel name. More... | |
void | setIgnoreRevisions (const QMap< QString, QList< QString > > &packagesRevisions) |
Revisions set in this map will not be treated as updates even if they differ from the currently installed one. More... | |
void | setRequireDownloadAndInstallConfirmation (bool b) |
Controls if the download&installation process is automated. More... | |
void | start () |
Static Public Member Functions | |
static QString | errorCodeToString (ErrorCode code) |
static QString | updaterScriptPath () |
Path to updater script XML file. More... | |
static QString | updateStorageDirPath () |
Static Public Attributes | |
static const QString | MAIN_PROGRAM_PACKAGE_NAME |
Package name for the main program. More... | |
static const QString | PLUGIN_PREFIX |
Prefix for all plugins packages names. More... | |
static const QString | QT_PACKAGE_NAME = "qt" |
static const QString | UPDATER_INFO_URL_BASE = "https://doomseeker.drdteam.org/updates/" |
Base URL to the directory where "update-info*" JSON files are contained. More... | |
static const QString | WADSEEKER_PACKAGE_NAME = "wadseeker" |
Deals with program updates/upgrades.
AutoUpdater is a non-reusable state machine. This means that if start() was called once then subsequent calls to start() are an error even if the machine has completed its previous job. If updater needs to be launched multiple times then the old object needs to be disposed of and a new object needs to be created.
The current implementation is coupled with Doomseeker architecture. The updater will extract information on plugins and Doomseeker version and compare it to the version information included in the updater info file.
If versions for selected channels do not match then the actual installation package is downloaded and stored in a space that is persistent between OS reboots. A configuration setting is marked to install the update on next program start.
When AutoUpdater finishes its job it emits the finished() signal. errorCode() must be called to check if operation was successful or if the updater stopped on an error. lastNetworkError() may give more insight if updater stopped on a remote error.
Definition at line 61 of file autoupdater.h.
Enumerator | |
---|---|
EC_Aborted |
Update was aborted by the user or by the program. |
EC_NullUpdateChannel |
No valid UpdateChannel was specified. |
EC_UpdaterInfoDownloadProblem |
Network error when downloading updater info file. |
EC_UpdaterInfoCannotParse |
Updater info file can't be parsed. |
EC_UpdaterInfoMissingMainProgramNode |
File was parseable but there was no main program information inside. |
EC_MissingRevisionInfo |
One of packages has no revision info. |
EC_MissingDownloadUrl |
One of packages has no download URL. |
EC_InvalidDownloadUrl |
QUrl.isValid() for package download URL returned false or QUrl.isRelative() returned true.. |
EC_PackageDownloadProblem |
Failed to download update package. |
EC_StorageDirCreateFailure |
Failed to create directory for updates storage. |
EC_PackageCantBeSaved |
Package file can't be stored on the local filesystem. |
EC_ScriptCantBeSaved |
Update script can't be merged and stored on the local filesystem. |
Definition at line 66 of file autoupdater.h.
const UpdateChannel & AutoUpdater::channel | ( | ) | const |
Definition at line 139 of file autoupdater.cpp.
|
signal |
Information on update packages has been received and install confirmation is requested.
const QStringList & AutoUpdater::downloadedPackagesFilenames | ( | ) | const |
Filenames for packages which are ready to install.
These are names only. These files should reside in a known location, pointed to by DataPaths::localDataLocationPath() in the DataPaths::UPDATE_PACKAGES_DIR_NAME subdir. This ensures that if portable mode is copied to a different directory, it will still know where to get downloaded packages.
Script files are not listed here because their names are the same as for packages but with ".xml" appended.
Contents of the list are only valid if updater finishes with EC_Ok status. Before that, or if updater finishes with error status, the contents of the list are undefined.
Definition at line 151 of file autoupdater.cpp.
|
signal |
AutoUpdater has finished its job.
This signal is emitted if either job completed normally or ended due to an error.
QNetworkReply::NetworkError AutoUpdater::lastNetworkError | ( | ) | const |
The network error that caused the updater to fail.
This returns a valid value only if errorCode() is not equal to EC_Ok and if the failure was in fact caused by the network error.
Definition at line 245 of file autoupdater.cpp.
const QList< UpdatePackage > & AutoUpdater::newUpdatePackages | ( | ) | const |
List of new update packages to install.
When downloadAndInstallConfirmationRequested() signal is emitted this accessor can be used to obtain the list of updates that will be installed if user confirms the install.
Definition at line 259 of file autoupdater.cpp.
void AutoUpdater::setChannel | ( | const UpdateChannel & | updateChannel | ) |
Update channel name.
Definition at line 395 of file autoupdater.cpp.
void AutoUpdater::setIgnoreRevisions | ( | const QMap< QString, QList< QString > > & | packagesRevisions | ) |
Revisions set in this map will not be treated as updates even if they differ from the currently installed one.
However, if update for at least one unignored package is detected, then the entire list is treated as if it wasn't set.
packagesRevisions | Key - package name. Value - list of revisions. |
Definition at line 400 of file autoupdater.cpp.
void AutoUpdater::setRequireDownloadAndInstallConfirmation | ( | bool | b | ) |
Controls if the download&installation process is automated.
If set to true then downloadAndInstallConfirmationRequested() signal will be emitted and the updater will suspend until confirmDownloadAndInstall() slot is called. If false then download&installation will proceed automatically as soon as new packages are detected.
Default: false.
Definition at line 405 of file autoupdater.cpp.
|
static |
Path to updater script XML file.
This consists of a constant filename which the updater XML script is always saved under.
Definition at line 539 of file autoupdater.cpp.
|
static |
Package name for the main program.
Other packages are plugins.
Definition at line 131 of file autoupdater.h.
|
static |
Prefix for all plugins packages names.
Definition at line 125 of file autoupdater.h.
|
static |
Base URL to the directory where "update-info*" JSON files are contained.
Definition at line 138 of file autoupdater.h.