The main updater. Can check for updates and trigger update installations. More...
#include <updater.h>
Public Types | |
enum | State { State::NoUpdates = 0, State::Checking, State::Canceling, State::NewUpdates, State::Installing, State::Error = -1 } |
The state of the updater. More... | |
enum | InstallModeFlag { InstallModeFlag::Parallel = 0x00, InstallModeFlag::OnExit = 0x01, InstallModeFlag::Force = 0x02, InstallModeFlag::ForceOnExit = (OnExit | Force) } |
Flags to indicate how to run the installer. More... | |
enum | InstallScope { InstallScope::PreferInternal, InstallScope::PreferExternal } |
Defines the different installation scopes. More... | |
Public Slots | |
void | checkForUpdates () |
Starts checking for updates. More... | |
void | abortUpdateCheck (int killDelay=5000) |
Aborts checking for updates. More... | |
void | cancelScheduledUpdate (int taskId) |
Cancels the scheduled update with taskId. More... | |
void | cancelExitRun () |
RESET accessor for runOnExit. | |
Signals | |
void | checkUpdatesDone (QtAutoUpdater::Updater::State result, QPrivateSignal) |
Will be emitted as soon as the updater finished checking for updates. More... | |
void | progressChanged (double progress, const QString &status, QPrivateSignal) |
Will be emitted to report a change in the update check progress. More... | |
void | showInstaller (QtAutoUpdater::UpdateInstaller *installer, QPrivateSignal) |
Will be emitted when a started installation requires an installer to be shown. More... | |
void | installDone (bool success, QPrivateSignal) |
Will be emitted when a started parallel installation has finished. More... | |
void | stateChanged (QtAutoUpdater::Updater::State state, QPrivateSignal) |
NOTIFY accessor for Updater::state. | |
void | runningChanged (bool running, QPrivateSignal) |
NOTIFY accessor for Updater::running. | |
void | updateInfoChanged (QList< QtAutoUpdater::UpdateInfo > updateInfo, QPrivateSignal) |
NOTIFY accessor for Updater::updateInfo. | |
void | runOnExitChanged (bool runOnExit, QPrivateSignal) |
NOTIFY accessor for Updater::runOnExit. | |
Public Member Functions | |
~Updater () override | |
Destroyes the updater and kills the update check (if running) More... | |
Q_INVOKABLE QtAutoUpdater::UpdaterBackend * | backend () const |
Returns the backend used by this updater instance. | |
UpdaterBackend::Features | features () const |
READ accessor for Updater::features. | |
State | state () const |
READ accessor for Updater::state. | |
bool | isRunning () const |
READ accessor for Updater::running. | |
QList< UpdateInfo > | updateInfo () const |
READ accessor for Updater::updateInfo. | |
bool | willRunOnExit () const |
READ accessor for Updater::runOnExit. | |
int | scheduleUpdate (std::chrono::seconds delaySeconds, bool repeated=false) |
Schedules an update after a specific delay, optionally repeated. More... | |
Q_INVOKABLE int | scheduleUpdate (int delaySeconds, bool repeated=false) |
Schedules an update after a specific delay, optionally repeated. More... | |
template<typename TRep , typename TPeriod > | |
int | scheduleUpdate (const std::chrono::duration< TRep, TPeriod > &delaySeconds, bool repeated=false) |
Schedules an update after a specific delay, optionally repeated. More... | |
Q_INVOKABLE int | scheduleUpdate (const QDateTime &when) |
Schedules an update for a specific timepoint. More... | |
template<typename TClock , typename TDur > | |
int | scheduleUpdate (const std::chrono::time_point< TClock, TDur > &when) |
Schedules an update for a specific timepoint. More... | |
Q_INVOKABLE bool | runUpdater (InstallMode mode=InstallModeFlag::Parallel, InstallScope scope=InstallScope::PreferInternal) |
Launches an update installer based on the given mode and scope. More... | |
Public Member Functions inherited from QObject | |
virtual const QMetaObject * | metaObject () const const |
QObject (QObject *parent) | |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
QString | objectName () const const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
bool | signalsBlocked () const const |
bool | blockSignals (bool block) |
QThread * | thread () const const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
void | killTimer (int id) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
const QObjectList & | children () const const |
void | setParent (QObject *parent) |
void | installEventFilter (QObject *filterObj) |
void | removeEventFilter (QObject *obj) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
void | dumpObjectTree () const const |
void | dumpObjectInfo () const const |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const const |
QList< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
bool | inherits (const char *className) const const |
void | deleteLater () |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
T | qobject_cast (QObject *object) |
T | qobject_cast (const QObject *object) |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
Q_CLASSINFO (Name, Value) | |
Q_INTERFACES (...) | |
Q_PROPERTY (...) | |
Q_ENUMS (...) | |
Q_FLAGS (...) | |
Q_ENUM (...) | |
Q_FLAG (...) | |
Q_ENUM_NS (...) | |
Q_FLAG_NS (...) | |
Q_OBJECT Q_OBJECT | |
Q_GADGET Q_GADGET | |
Q_NAMESPACE Q_NAMESPACE | |
Q_SIGNALS Q_SIGNALS | |
Q_SIGNAL Q_SIGNAL | |
Q_SLOTS Q_SLOTS | |
Q_SLOT Q_SLOT | |
Q_EMIT Q_EMIT | |
Q_INVOKABLE Q_INVOKABLE | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Static Public Member Functions | |
static QStringList | supportedUpdaterBackends () |
Returns a list of all currently available backends. | |
static Updater * | create (QObject *parent=nullptr) |
Creates an updater instance using the default configuration. More... | |
static Updater * | create (const QString &configPath, QObject *parent=nullptr) |
Creates an updater instance using the given configuration file. More... | |
static Updater * | create (QSettings *config, QObject *parent=nullptr) |
Creates an updater instance using the given configuration object. More... | |
static Updater * | create (QString key, QVariantMap configuration, QObject *parent=nullptr) |
Creates an updater instance using the given backend and configuration. More... | |
static Updater * | create (UpdaterBackend::IConfigReader *configReader, QObject *parent=nullptr) |
Creates an updater instance using the given configuration reader. More... | |
Static Public Member Functions inherited from QObject | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
Properties | |
QtAutoUpdater::UpdaterBackend::Features | features |
Holds the features of the backend used by the updater. More... | |
QtAutoUpdater::Updater::State | state |
Reports the state the updater is currently in. More... | |
bool | running |
Specifies whether the updater is currently running or not. More... | |
QList< QtAutoUpdater::UpdateInfo > | updateInfo |
Holds extended information about the last update check. More... | |
bool | runOnExit |
Specifies whether an installer will be launched when the application exits. More... | |
Properties inherited from QObject | |
objectName | |
Additional Inherited Members | |
Public Attributes inherited from QObject | |
typedef | QObjectList |
Protected Member Functions inherited from QObject | |
QObject * | sender () const const |
int | senderSignalIndex () const const |
int | receivers (const char *signal) const const |
bool | isSignalConnected (const QMetaMethod &signal) const const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
The main updater. Can check for updates and trigger update installations.
The updater class acts as a user friendly frontend to the UpdaterBackend. It is the primary class of this module and can be used to check for updates and install them, if supported. The actual feature set of the updater depends on the backend used, but all backends support at least checking for updates.
|
strong |
Flags to indicate how to run the installer.
|
strong |
|
strong |
The state of the updater.
|
override |
Destroyes the updater and kills the update check (if running)
|
slot |
Aborts checking for updates.
killDelay | The maximum delay to wait for the process to gracefully finish |
Tries to abort the update check. If no update is currently running (Updater::state != Checking), nothing will happen.
If killDelay
is greater than 0, the updater will try to gracefully terminate the check. After this is done, the updater will wait at most killDelay
milliseconds for the process to finish. If it doesn't, it will be killed hard. It will be killed hard immediately, if the delay is set to 0. A value below 0 indicates, that only the terminate should happen, without a hard kill timeout.
|
slot |
Cancels the scheduled update with taskId.
taskId | The id of the task to be canceled |
Cancels the task with the id taskId
. If there was a task with that ID, you can be shure that it will be canceled. If the task was not until the point you call this function, it will not be triggered anymore.
|
slot |
Starts checking for updates.
Checking for updates means that the backend will perform the check in the background. If already in the running state, nothing happens instead. The updater now enters the Checking state and performs the check. The result will be reported via the checkUpdatesDone() signal (and the state).
|
signal |
Will be emitted as soon as the updater finished checking for updates.
result | The result state the updater reached after checking for updates |
This signal is emitted if the updater was in the Checking state and has finished that task. It will now be in one of the three non-running states NoUpdates, NewUpdates or Error. This is a signal for convenience to only catch those specific state changes, instead of all by using the state property.
Creates an updater instance using the given configuration file.
configPath | The path to the configuration file |
parent | The object to be set as the parent for the created updater |
nullptr
, if unable to create one.The backend is loaded based on the given configuration file, which must be in the QSettings::IniFormat. It must contain the "backend" entry, set to the updater backend to be used. If the file does not exists or backend is invalid, nullptr is returned. Otherwise the created instance, initialized using the given configuration.
qApp
or nullptr
as parent for the updater.
|
static |
Creates an updater instance using the default configuration.
parent | The object to be set as the parent for the created updater |
nullptr
, if unable to create one.This method assumes the configuration for the updater to be create is located at a default location. The location is searched as follows:
If none of these work and no config can be found, nullptr is returned. If it is found, it must contain the "backend" entry, set to the updater backend to be used. The backend will get initialized using the found configuration.
qApp
or nullptr
as parent for the updater.Creates an updater instance using the given configuration object.
config | The configuration object |
parent | The object to be set as the parent for the created updater |
nullptr
, if unable to create one.The backend is loaded based on the given configuration. It must contain the "backend" entry, set to the updater backend to be used. If the backend is missing or invalid, nullptr is returned. Otherwise the created instance, initialized using the given configuration.
qApp
or nullptr
as parent for the updater.
|
static |
Creates an updater instance using the given backend and configuration.
key | The key of the backend to be loaded |
configuration | The configuration to be passed to the backend to configure it |
parent | The object to be set as the parent for the created updater |
nullptr
, if unable to create one.The backend is loaded based on the given key. If no backend was found for the key, nullptr is returned. Otherwise the created instance. The configuration is used to initialize the backend.
qApp
or nullptr
as parent for the updater.
|
static |
Creates an updater instance using the given configuration reader.
configReader | The configuration reader object |
parent | The object to be set as the parent for the created updater |
nullptr
, if unable to create one.The backend is loaded based on the given configuration. It must contain the "backend" entry, set to the updater backend to be used. If the backend is missing or invalid, nullptr is returned. Otherwise the created instance, initialized using the given configuration.
qApp
or nullptr
as parent for the updater.
|
signal |
Will be emitted when a started parallel installation has finished.
success | Reports whether the update installer did succeed or not |
This signal is emitted if runUpdater() launched a parallel installation (either a performed or a triggered installation) and that installation finished. If the installation was successfully completed, success will be true, otherwise false.
|
signal |
Will be emitted to report a change in the update check progress.
progress | A percentage value representing the check progress |
status | A localized status string to explaing the current state of the check process |
This signal provides the current state of the update check process. percent can either range from 0.0 to 1.0 to present an actual percentage, or be -1.0 to represent an indeterminate progress. Status can be empty to be unchanged/unset. Not all update backends support reporting detailes status. Check the features property for the UpdaterBackend::Feature::CheckProgress flag to verify this.
QtAutoUpdater::Updater::runUpdater | ( | InstallMode | mode = InstallModeFlag::Parallel , |
InstallScope | scope = InstallScope::PreferInternal |
||
) |
Launches an update installer based on the given mode and scope.
mode | The preferred mode to start the updater in |
scope | The preferred scope to use for the updater |
true
, if the update installer was started, false if notThis method launches the installer, based on the given mode, scope and the features that the backend supports. It will either launch the internal installer ("perform"), by emitting showInstaller(), launch a parallel external install process immediately ("trigger") and track it's exection, or mark an external installer to be executed as soon as the application quits ("onExit"). The following table shows which parameters and flags trigger which mode. The flags are evaluated in the order seen in the table, so if multiple flags are set, those who are displayed here first are the onces that decide what happens
Mode | Scope | Flags | Result |
---|---|---|---|
Parallel | PreferInternal | PerformInstall | perform |
ParallelTrigger | trigger | ||
TriggerInstall | onExit | ||
PreferExternal | ParallelTrigger | trigger | |
PerformInstall | perform | ||
TriggerInstall | onExit | ||
Parallel | Force | PreferInternal | PerformInstall | perform |
ParallelTrigger | trigger | ||
TriggerInstall | - | ||
PreferExternal | ParallelTrigger | trigger | |
PerformInstall | perform | ||
TriggerInstall | - | ||
OnExit | PreferInternal | TriggerInstall | onExit |
ParallelTrigger | onExit | ||
PerformInstall | perform | ||
PreferExternal | Same as PreferInternal | ||
OnExit | Force | PreferInternal | TriggerInstall | onExit |
ParallelTrigger | onExit | ||
PerformInstall | - | ||
PreferExternal | Same as PreferInternal |
For some force configurations, - is specified. This means no updater can be run and false is returned instead. If you want to find out whether an installation as been launched immediatly (Parallel) or delayed (OnExit), query the runOnExit property.
QtAutoUpdater::Updater::scheduleUpdate | ( | const QDateTime & | when | ) |
Schedules an update for a specific timepoint.
when | The timepoint where the update should be started |
Schedules an update to be run at when
. If when
is in the past, nothing will happen and 0 will be returned. The update will be started once that time is reached (assuming that this updater instance is still alive at that timepoint).
int QtAutoUpdater::Updater::scheduleUpdate | ( | const std::chrono::duration< TRep, TPeriod > & | delaySeconds, |
bool | repeated = false |
||
) |
Schedules an update after a specific delay, optionally repeated.
delaySeconds | The time (in seconds) to wait until the update is started |
repeated | Specifies, whether the updater should be started every delaySeconds or only once |
Schedules an update to be run after delaySeconds
seconds. If repeated
is true
, the updater will not just be run once, but every delaySeconds
seconds (indefinitly, until this instance is destroyed or the task canceled).
int QtAutoUpdater::Updater::scheduleUpdate | ( | const std::chrono::time_point< TClock, TDur > & | when | ) |
Schedules an update for a specific timepoint.
when | The timepoint where the update should be started |
Schedules an update to be run at when
. If when
is in the past, nothing will happen and 0 will be returned. The update will be started once that time is reached (assuming that this updater instance is still alive at that timepoint).
Q_INVOKABLE int QtAutoUpdater::Updater::scheduleUpdate | ( | int | delaySeconds, |
bool | repeated = false |
||
) |
Schedules an update after a specific delay, optionally repeated.
delaySeconds | The time (in seconds) to wait until the update is started |
repeated | Specifies, whether the updater should be started every delaySeconds or only once |
Schedules an update to be run after delaySeconds
seconds. If repeated
is true
, the updater will not just be run once, but every delaySeconds
seconds (indefinitly, until this instance is destroyed or the task canceled).
QtAutoUpdater::Updater::scheduleUpdate | ( | std::chrono::seconds | delaySeconds, |
bool | repeated = false |
||
) |
Schedules an update after a specific delay, optionally repeated.
delaySeconds | The time (in seconds) to wait until the update is started |
repeated | Specifies, whether the updater should be started every delaySeconds or only once |
Schedules an update to be run after delaySeconds
seconds. If repeated
is true
, the updater will not just be run once, but every delaySeconds
seconds (indefinitly, until this instance is destroyed or the task canceled).
|
signal |
Will be emitted when a started installation requires an installer to be shown.
installer | The installer to be shown |
This signal is emitted if runUpdater() decides to perform an internal update installation. It will create an installer from the backend and pass it back via this signal. The installer should be used by some kind of UI to guide the user through the installation process.
|
read |
Holds the features of the backend used by the updater.
Default: UpdaterBackend::CheckUpdates
These features depend on what the backend implementation supports and thus differ based on the update mechanism used for your application. The features dictate what can be done with the backend. All backends can check for updates, but installing is only supported on some in one way or another.
Accessors | |
---|---|
READ | features() |
CONSTANT |
|
read |
Specifies whether the updater is currently running or not.
Default: false
Convenience property that simplifies the state property into a boolean property that reports whether the updater is doing something or not. States are mapped as follows:
State | Running |
---|---|
NoUpdates | false |
Checking | true |
Canceling | true |
NewUpdates | false |
Installing | true |
Error | false |
Checking for updates and installing is only possible when the updater is not running
Accessors | |
---|---|
READ | isRunning() |
NOTIFY | runningChanged() |
|
read |
Specifies whether an installer will be launched when the application exits.
Default: false
Specifies if an installer will be launched automatically, as soon as the application exists. This property is read only, but will be set when runUpdater() leads to an installer beeing queued to be run on exit.
To reset this property use the cancelExitRun() method. If an exit run was scheduled, this will disable it. To reenable it, call runUpdater() again
Accessors | |
---|---|
READ | willRunOnExit() |
RESET | cancelExitRun() |
NOTIFY | runOnExitChanged() |
|
read |
Reports the state the updater is currently in.
Default: Updater::State::NoUpdates
The state represents what the updater is currently doing. Certain operations are only possible in certain states. For example, you can only install updates if the updater is in the NewUpdates state.
Accessors | |
---|---|
READ | state() |
NOTIFY | stateChanged() |
|
read |
Holds extended information about the last update check.
Default: <empty list>
This property is always empty, unless the state is Updater::State::NewUpdates. In that case, it will hold the update information of those available updates. Whenever the updater leaves this state, this property will be cleared as well.
Accessors | |
---|---|
READ | updateInfo() |
NOTIFY | updateInfoChanged() |