NDEVR
API Documentation
UpdateCheckerabstract

Provides logic for checking a source, typically online, for an update to the software. More...

Inheritance diagram for UpdateChecker:
[legend]
Collaboration diagram for UpdateChecker:
[legend]

Public Types

enum  UpdateStatus {
  e_need_to_check , e_no_new_updates , e_update_available_to_download , e_update_available_to_install ,
  e_could_not_connect , e_unsupported
}
 The possible states of the update check/download lifecycle. More...

Public Member Functions

 UpdateChecker ()
 Constructs an UpdateChecker with default settings.
 UpdateChecker (StringView update_version)
 Constructs an UpdateChecker with a known current version.
void appStartupCheck ()
 Performs an update check at application startup if enough time has elapsed.
const Buffer< ApplicationResource::ReleaseType > & availableReleaseTypes () const
 Returns the list of available release types for this application.
void checkForUpdateCompletedSignal (UpdateStatus update)
 Signal emitted when an update check completes.
virtual void createUpdateFile (const String &installer_url, File output_location)
 Creates an update file from the given installer URL.
uint08 currentDownloadSize () const
 Returns the number of bytes downloaded so far.
virtual String defaultURLPathName () const
 Returns the default URL path segment used for update requests.
fltp08 downloadPercent () const
 Returns the download progress as a percentage.
virtual INIFactory getINI ()
 Returns an INI factory configured for update settings.
Time lastUpdateCheckTime () const
 Returns the time of the last update check.
void percentChangedSignal ()
 Signal emitted when download progress changes.
virtual void processUpdateString (const String &s)
 Parses an update response string to extract version and URL information.
ApplicationResource::ReleaseType recommendedReleaseType () const
 Returns the recommended release type based on user preference and availability.
void releaseTypesChangedSignal ()
 Signal emitted when the available release types change.
virtual void requestCheckForUpdate (const StringView &current_version=StringView())=0
 Initiates an asynchronous check for available updates.
virtual bool requestInstallUpdate (bool wait_for_completion=false)
 Requests installation of the downloaded update.
virtual bool requstDownloadUpdate ()
 Requests download of the available update.
void setMaxNoUpdateTime (const TimeSpan &max_no_update_check_time)
 Sets the maximum time between automatic update checks.
void setReleaseTypes (const Buffer< ApplicationResource::ReleaseType > &types)
 Sets the available release types for the update checker.
void setUpdateStatus (UpdateStatus status)
 Sets the current update status and emits statusChangedSignal.
void showUpdateDialogIfNeeded ()
 Shows a dialog prompting the user to update if one is available.
void statusChangedSignal ()
 Signal emitted when the update status changes.
uint08 totalDownloadSize () const
 Returns the total size of the update download.
void updateDownloadCompletedSignal (const File &location)
 Signal emitted when an update download completes.
File updateFile () const
 Returns the local file path of the downloaded update.
virtual String updateName () const
 Returns the file name of the available update.
virtual bool updateRequiresApplicationClose () const
 Returns whether the update requires closing the application first.
UpdateStatus updateStatus () const
 Returns the current update status.
virtual bool updateSupported () const
 Returns whether software updates are supported on this platform.
virtual String updateURLDownload () const
 Returns the direct download URL for the update.
virtual String updateURLPage () const =0
 Returns the URL of the update information page.
virtual String updateVersion () const
 Returns the version string of the available update.

Static Public Attributes

static ApplicationOption< ApplicationResource::ReleaseTyperelease_check_type
 The user's preferred release type for update checks.

Protected Member Functions

void checkForUpdateCompleteSlot ()
 Slot invoked when the update check network request completes.
virtual void onCheckForUpdateComplete ()
 Virtual callback invoked when an update check completes.
void onUpdateDownloadCompleteSlot ()
 Slot invoked when the update file download completes.

Protected Attributes

String m_current_version
 The current application version string.
File m_download_location
 The local file path for downloaded updates.
QPointer< ItemDownloaderm_downloader
 The downloader managing the update file transfer.
Time m_last_application_update_check
 The time of the last update check.
TimeSpan m_max_no_update_time
 The maximum allowed time between automatic update checks.
Buffer< ApplicationResource::ReleaseTypem_release_types
 The available release types.
String m_update_file_name
 The file name of the available update.
String m_update_url
 The download URL for the available update.
String m_update_version
 The version string of the available update.

Detailed Description

Provides logic for checking a source, typically online, for an update to the software.


Definition at line 49 of file UpdateChecker.h.

Member Enumeration Documentation

◆ UpdateStatus

The possible states of the update check/download lifecycle.

Enumerator
e_need_to_check 

An update check has not yet been performed.

e_no_new_updates 

The software is up to date.

e_update_available_to_download 

A new version is available for download.

e_update_available_to_install 

A downloaded update is ready to install.

e_could_not_connect 

Failed to connect to the update server.

e_unsupported 

Updates are not supported on this platform.

Definition at line 54 of file UpdateChecker.h.

Constructor & Destructor Documentation

◆ UpdateChecker()

UpdateChecker::UpdateChecker ( StringView update_version)

Constructs an UpdateChecker with a known current version.

Parameters
[in]update_versionThe current application version string.

Member Function Documentation

◆ availableReleaseTypes()

const Buffer< ApplicationResource::ReleaseType > & UpdateChecker::availableReleaseTypes ( ) const

Returns the list of available release types for this application.

Returns
A reference to the buffer of available ReleaseType values.

◆ checkForUpdateCompletedSignal()

void UpdateChecker::checkForUpdateCompletedSignal ( UpdateStatus update)

Signal emitted when an update check completes.

Parameters
[in]updateThe resulting UpdateStatus.

◆ createUpdateFile()

virtual void UpdateChecker::createUpdateFile ( const String & installer_url,
File output_location )
virtual

Creates an update file from the given installer URL.

Parameters
[in]installer_urlThe URL of the installer to download.
[in]output_locationThe file path to write the downloaded installer to.

◆ currentDownloadSize()

uint08 UpdateChecker::currentDownloadSize ( ) const

Returns the number of bytes downloaded so far.

Returns
The current download size in bytes.

◆ defaultURLPathName()

virtual String UpdateChecker::defaultURLPathName ( ) const
virtual

Returns the default URL path segment used for update requests.

Returns
The default URL path name string.

◆ downloadPercent()

fltp08 UpdateChecker::downloadPercent ( ) const

Returns the download progress as a percentage.

Returns
The download percentage from 0.0 to 100.0.

◆ getINI()

virtual INIFactory UpdateChecker::getINI ( )
virtual

Returns an INI factory configured for update settings.

Returns
The INIFactory for reading/writing update configuration.

◆ lastUpdateCheckTime()

Time UpdateChecker::lastUpdateCheckTime ( ) const

Returns the time of the last update check.

Returns
The Time of the most recent check.

◆ onCheckForUpdateComplete()

virtual void UpdateChecker::onCheckForUpdateComplete ( )
inlineprotectedvirtual

Virtual callback invoked when an update check completes.

Override for custom handling.

Reimplemented in NDEVRUpdateChecker.

Definition at line 169 of file UpdateChecker.h.

◆ processUpdateString()

virtual void UpdateChecker::processUpdateString ( const String & s)
virtual

Parses an update response string to extract version and URL information.

Parameters
[in]sThe raw update response string to parse.

◆ recommendedReleaseType()

ApplicationResource::ReleaseType UpdateChecker::recommendedReleaseType ( ) const

Returns the recommended release type based on user preference and availability.

Returns
The recommended ReleaseType.

◆ requestCheckForUpdate()

virtual void UpdateChecker::requestCheckForUpdate ( const StringView & current_version = StringView())
pure virtual

Initiates an asynchronous check for available updates.

Parameters
[in]current_versionThe current version to compare against. Uses stored version if empty.

Implemented in NDEVRUpdateChecker.

◆ requestInstallUpdate()

virtual bool UpdateChecker::requestInstallUpdate ( bool wait_for_completion = false)
virtual

Requests installation of the downloaded update.

Parameters
[in]wait_for_completionWhether to block until installation finishes.
Returns
True if the install was successfully started.

◆ requstDownloadUpdate()

virtual bool UpdateChecker::requstDownloadUpdate ( )
virtual

Requests download of the available update.

Returns
True if the download was successfully started.

◆ setMaxNoUpdateTime()

void UpdateChecker::setMaxNoUpdateTime ( const TimeSpan & max_no_update_check_time)

Sets the maximum time between automatic update checks.

Parameters
[in]max_no_update_check_timeThe maximum TimeSpan between checks.

◆ setReleaseTypes()

void UpdateChecker::setReleaseTypes ( const Buffer< ApplicationResource::ReleaseType > & types)

Sets the available release types for the update checker.

Parameters
[in]typesThe buffer of ReleaseType values to make available.

◆ setUpdateStatus()

void UpdateChecker::setUpdateStatus ( UpdateStatus status)

Sets the current update status and emits statusChangedSignal.

Parameters
[in]statusThe new UpdateStatus to set.

◆ totalDownloadSize()

uint08 UpdateChecker::totalDownloadSize ( ) const

Returns the total size of the update download.

Returns
The total download size in bytes.

◆ updateDownloadCompletedSignal()

void UpdateChecker::updateDownloadCompletedSignal ( const File & location)

Signal emitted when an update download completes.

Parameters
[in]locationThe file path of the downloaded update.

◆ updateFile()

File UpdateChecker::updateFile ( ) const

Returns the local file path of the downloaded update.

Returns
The update File location.

◆ updateName()

virtual String UpdateChecker::updateName ( ) const
inlinevirtual

Returns the file name of the available update.

Returns
The update file name.

Definition at line 84 of file UpdateChecker.h.

References m_update_file_name.

◆ updateRequiresApplicationClose()

virtual bool UpdateChecker::updateRequiresApplicationClose ( ) const
virtual

Returns whether the update requires closing the application first.

Returns
True if the application must close before updating.

◆ updateStatus()

UpdateStatus UpdateChecker::updateStatus ( ) const

Returns the current update status.

Returns
The current UpdateStatus value.

◆ updateSupported()

virtual bool UpdateChecker::updateSupported ( ) const
virtual

Returns whether software updates are supported on this platform.

Returns
True if updates are supported.

◆ updateURLDownload()

virtual String UpdateChecker::updateURLDownload ( ) const
inlinevirtual

Returns the direct download URL for the update.

Returns
The download URL string.

Definition at line 93 of file UpdateChecker.h.

References m_update_url.

◆ updateURLPage()

virtual String UpdateChecker::updateURLPage ( ) const
pure virtual

Returns the URL of the update information page.

Returns
The update page URL.

Implemented in NDEVRUpdateChecker.

◆ updateVersion()

virtual String UpdateChecker::updateVersion ( ) const
inlinevirtual

Returns the version string of the available update.

Returns
The update version string.

Definition at line 87 of file UpdateChecker.h.

References m_update_version.


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