QSimpleUpdater: Updater Class Reference

| QSimpleUpdater A simple auto-updater system for Qt applications

- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Slots | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
Updater Class Reference

Downloads and interprests the update definition file. More...

`#include <Updater.h>`

Inheritance diagram for Updater:

## Public Slots
void | checkForUpdates ()
void | setUrl (const QString &url)
void | setModuleName (const QString &name)
void | setNotifyOnUpdate (const bool &notify)
void | setNotifyOnFinish (const bool &notify)
void | setModuleVersion (const QString &version)
void | setDownloaderEnabled (const bool &enabled)
void | setPlatformKey (const QString &platformKey)
void | setUseCustomInstallProcedures (const bool &custom)

## Signals
void | checkingFinished (const QString &url)
void | downloadFinished (const QString &url, const QString &filepath)

## Public Member Functions
QString | url () const
QString | changelog () const
QString | moduleName () const
QString | downloadUrl () const
QString | platformKey () const
QString | moduleVersion () const
QString | latestVersion () const
bool | notifyOnUpdate () const
bool | notifyOnFinish () const
bool | updateAvailable () const
bool | downloaderEnabled () const
bool | useCustomInstallProcedures () const

## Private Slots
void | onReply (QNetworkReply *reply)
void | setUpdateAvailable (const bool &available)

## Private Member Functions
bool | compare (const QString &x, const QString &y)

## Private Attributes
QString | m_url
bool | m_notifyOnUpdate
bool | m_notifyOnFinish
bool | m_updateAvailable
bool | m_downloaderEnabled
QString | m_openUrl
QString | m_platform
QString | m_changelog
QString | m_moduleName
QString | m_downloadUrl
QString | m_moduleVersion
QString | m_latestVersion
Downloader * | m_downloader
QNetworkAccessManager * | m_manager

## Detailed Description

Downloads and interprests the update definition file.

## Member Function Documentation

QString Updater::changelog | ( |  | ) | const

Returns the changelog defined by the update definitions file.

Warning
  You should call `checkForUpdates()` before using this function

Referenced by QSimpleUpdater::getChangelog().

void Updater::checkForUpdates | ( |  | ) |
| slot

Downloads and interpets the update definitions file referenced by the `url()` function.

References url().

Referenced by QSimpleUpdater::checkForUpdates().

bool Updater::compare | ( | const QString & | x,
|  | const QString & | y
| ) |  |
| private

Compares the two version strings (x and y).

- If x is greater than , this function returns `true`.
- If y is greater than , this function returns `false`.
- If both versions are the same, this function returns `false`.

Referenced by onReply().

bool Updater::downloaderEnabled | ( |  | ) | const

Returns `true` if the integrated downloader is enabled.

Note
  If set to `true`, the `Updater` will open the downloader dialog if the user agrees to download the update.

Referenced by QSimpleUpdater::getDownloaderEnabled(), and setUpdateAvailable().

QString Updater::downloadUrl | ( |  | ) | const

Returns the download URL defined by the update definitions file.

Warning
  You should call `checkForUpdates()` before using this function

Referenced by QSimpleUpdater::getDownloadUrl(), and setUpdateAvailable().

QString Updater::latestVersion | ( |  | ) | const

Returns the latest version defined by the update definitions file.

Warning
  You should call `checkForUpdates()` before using this function

Referenced by QSimpleUpdater::getLatestVersion(), onReply(), and setUpdateAvailable().

QString Updater::moduleName | ( |  | ) | const

Returns the name of the module (if defined)

Referenced by QSimpleUpdater::getModuleName(), and setUpdateAvailable().

QString Updater::moduleVersion | ( |  | ) | const

Returns the "local" version of the installed module

Referenced by QSimpleUpdater::getModuleVersion(), and onReply().

bool Updater::notifyOnFinish | ( |  | ) | const

Returns `true` if the updater should notify the user when it finishes checking for updates.

Note
  If set to `true`, the `Updater` will notify the user even when there are no updates available (by congratulating him/her about being smart)

Referenced by QSimpleUpdater::getNotifyOnFinish(), and setUpdateAvailable().

bool Updater::notifyOnUpdate | ( |  | ) | const

Returns `true` if the updater should notify the user when an update is available.

Referenced by QSimpleUpdater::getNotifyOnUpdate(), and setUpdateAvailable().

void Updater::onReply | ( | QNetworkReply * | reply | ) |
| privateslot

Called when the download of the update definitions file is finished.

References compare(), latestVersion(), moduleVersion(), platformKey(), setUpdateAvailable(), and url().

QString Updater::platformKey | ( |  | ) | const

Returns the platform key (be it system-set or user-set). If you do not define a platform key, the system will assign the following platform key:

- On iOS: `ios`
- On Mac OSX: `osx`
- On Android: `android`
- On GNU/Linux: `linux`
- On Microsoft Windows: `windows`

Referenced by QSimpleUpdater::getPlatformKey(), onReply(), and setPlatformKey().

void Updater::setDownloaderEnabled | ( | const bool & | enabled | ) |
| slot

If the enabled parameter is set to `true`, the `Updater` will open the integrated downloader if the user agrees to install the update (if any)

Referenced by QSimpleUpdater::setDownloaderEnabled().

void Updater::setModuleName | ( | const QString & | name | ) |
| slot

Changes the module name.

Note
  The module name is used on the user prompts. If the module name is empty, then the prompts will show the name of the application.

Referenced by QSimpleUpdater::setModuleName().

void Updater::setModuleVersion | ( | const QString & | version | ) |
| slot

Changes the module version

Note
  The module version is used to compare the local and remote versions. If the version parameter is empty, then the `Updater` will use the application version (referenced by `qApp`)

Referenced by QSimpleUpdater::setModuleVersion().

void Updater::setNotifyOnFinish | ( | const bool & | notify | ) |
| slot

If notify is set to `true`, then the `Updater` will notify the user when it has finished interpreting the update definitions file.

Referenced by QSimpleUpdater::setNotifyOnFinish().

void Updater::setNotifyOnUpdate | ( | const bool & | notify | ) |
| slot

If notify is set to `true`, then the `Updater` will notify the user when an update is available.

Referenced by QSimpleUpdater::setNotifyOnUpdate().

void Updater::setPlatformKey | ( | const QString & | platformKey | ) |
| slot

Changes the platform key. If the platform key is empty, then the system will use the following keys:

- On iOS: `ios`
- On Mac OSX: `osx`
- On Android: `android`
- On GNU/Linux: `linux`
- On Microsoft Windows: `windows`

References platformKey().

Referenced by QSimpleUpdater::setPlatformKey().

void Updater::setUpdateAvailable | ( | const bool & | available | ) |
| privateslot

Prompts the user based on the value of the available parameter and the settings of this instance of the `Updater` class.

References downloaderEnabled(), downloadUrl(), latestVersion(), moduleName(), notifyOnFinish(), notifyOnUpdate(), Downloader::startDownload(), and updateAvailable().

Referenced by onReply().

void Updater::setUrl | ( | const QString & | url | ) |
| slot

Changes the `url` in which the `Updater` can find the update definitions file.

References url().

Referenced by QSimpleUpdater::getUpdater().

void Updater::setUseCustomInstallProcedures | ( | const bool & | custom | ) |
| slot

If the custom parameter is set to `true`, the `Updater` will not try to open the downloaded file. Use the signals fired by the `QSimpleUpdater` to install the update from the downloaded file by yourself.

References Downloader::setUseCustomInstallProcedures().

Referenced by QSimpleUpdater::setUseCustomInstallProcedures().

bool Updater::updateAvailable | ( |  | ) | const

Returns `true` if there is an update available.

Warning
  You should call `checkForUpdates()` before using this function

Referenced by QSimpleUpdater::getUpdateAvailable(), and setUpdateAvailable().

QString Updater::url | ( |  | ) | const

Returns the URL of the update definitions file

Referenced by checkForUpdates(), onReply(), and setUrl().

bool Updater::useCustomInstallProcedures | ( |  | ) | const

Returns `true` if the updater shall not intervene when the download has finished (you can use the `QSimpleUpdater` signals to know when the download is completed).

References Downloader::useCustomInstallProcedures().

Referenced by QSimpleUpdater::usesCustomInstallProcedures().

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

- Updater.h
- Updater.cpp