AutoUpdater Class Reference

Deals with program updates/upgrades. More...

#include <autoupdater.h>

+ Inheritance diagram for AutoUpdater:

Public Types

enum  ErrorCode {
  EC_Ok = 0, EC_Aborted, EC_NullUpdateChannel, EC_UpdaterInfoDownloadProblem,
  EC_UpdaterInfoCannotParse, EC_UpdaterInfoMissingMainProgramNode, EC_MissingRevisionInfo, EC_MissingDownloadUrl,
  EC_InvalidDownloadUrl, EC_PackageDownloadProblem, EC_StorageDirCreateFailure, EC_PackageCantBeSaved,
  EC_ScriptCantBeSaved
}
 

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=NULL)
 
void abort ()
 
const UpdateChannelchannel () 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< unsigned long long > > &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 UPDATER_INFO_URL_BASE = "http://doomseeker.drdteam.org/updates/"
 Base URL to the directory where "update-info*" JSON files are contained. More...
 

Detailed Description

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.

Member Enumeration Documentation

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.

Member Function Documentation

const UpdateChannel & AutoUpdater::channel ( ) const

setChannel() .

Definition at line 137 of file autoupdater.cpp.

void AutoUpdater::downloadAndInstallConfirmationRequested ( )
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 149 of file autoupdater.cpp.

void AutoUpdater::finished ( )
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 243 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 257 of file autoupdater.cpp.

void AutoUpdater::setChannel ( const UpdateChannel updateChannel)

Update channel name.

Definition at line 393 of file autoupdater.cpp.

void AutoUpdater::setIgnoreRevisions ( const QMap< QString, QList< unsigned long long > > &  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.

Parameters
packagesRevisionsKey - package name. Value - list of revision numbers.

Definition at line 398 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 403 of file autoupdater.cpp.

QString AutoUpdater::updaterScriptPath ( )
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 537 of file autoupdater.cpp.

Member Data Documentation

const QString AutoUpdater::MAIN_PROGRAM_PACKAGE_NAME
static

Package name for the main program.

Other packages are plugins.

Definition at line 131 of file autoupdater.h.

const QString AutoUpdater::PLUGIN_PREFIX
static

Prefix for all plugins packages names.

Definition at line 125 of file autoupdater.h.

const QString AutoUpdater::UPDATER_INFO_URL_BASE = "http://doomseeker.drdteam.org/updates/"
static

Base URL to the directory where "update-info*" JSON files are contained.

Definition at line 136 of file autoupdater.h.


The documentation for this class was generated from the following files: