Updater Class Reference

This class is responsible to handle the update procedure of the client. More...

#include <Updater.h>

List of all members.

Public Member Functions

 Updater (const StringBuffer &component, const StringBuffer &version, UpdaterConfig &c)
 Construct an update with the given component name, version and configuration.
bool start ()
 Start the update check progress.
void forceUpdate ()
 This method forces the process of installing a new version.
bool isNewVersionAvailable ()
 Returns true if a new version is known to be available for upgrade.
bool newVersionAvailable (bool onlyMandatoryExpired=false)
 This method handles a new version.
void setUI (UpdaterUI *ui)
 Set the ui for calling bck when user actions are required.
bool checkIsToUpdate ()
 check the update on the server.
bool isMandatoryUpdateActivationDateExceeded ()
 Check if the stored info are Mandatory update and the activation date has been exceeded.

Private Member Functions

int32_t requestUpdate ()
 It checks if it is needed to check via url or locally only.
int32_t parseMessage (StringBuffer message)
 Used to ask the server.
StringBuffer long2string (uint32_t v)
 utility to convert an unsigned long into a string
uint32_t string2long (const StringBuffer &v)
 utility to convert a string into an unsigned long
void getListedString (ArrayList &allString, const StringBuffer &s, const StringBuffer &separator)
 Get all the strings in the server message.
int32_t buildVersionID (const StringBuffer &version)
 Build a numerical representation of a software version string.

Private Attributes

StringBuffer component
 Name of the component to check for updates.
StringBuffer version
 Current version of the component for which we check updates.
time_t currentTime
 Current time (this is not continuos, but updated when needed).
time_t nextCheckTime
 The time on which the next check (with the server) will be performed.
time_t nextRemindTime
 The time on which the next reminder to the user shall be presented.
UpdaterConfig & config
 Updater configuration.
UpdaterUI * ui
 UI abstraction to interact with the user.


Detailed Description

This class is responsible to handle the update procedure of the client.

It contains all the action that has to be done in order to handle the udpate.


Member Function Documentation

int32_t Updater::buildVersionID ( const StringBuffer &  version  )  [private]

Build a numerical representation of a software version string.

This representation is suitable for comparison (>,<,==). Versions must be triplets for this method to work properly.

bool Updater::checkIsToUpdate (  ) 

check the update on the server.

If it is necessary set a value to 1 return false if there is no action to do return true if there is something to download

Referenced by UpdateManager::checkIsToUpdate().

void Updater::forceUpdate (  ) 

This method forces the process of installing a new version.

It does not check if a new version is really available, but it calls the UI with the last update URL (which may be invalid). It is responsability of the caller to make sure it makes sense to invoke this method.

bool Updater::isMandatoryUpdateActivationDateExceeded (  ) 

Check if the stored info are Mandatory update and the activation date has been exceeded.

It checks between the activation date stored in the settings and the current date in the system plus the updateType that must be mandatory...

Returns:
true if it is a mandatory and the activation date exceeded, false otherwise

bool Updater::isNewVersionAvailable (  ) 

Returns true if a new version is known to be available for upgrade.

This method does not query the upgrade server, but it uses the information available.

Referenced by UpdateManager::isNewVersionAvailable().

bool Updater::newVersionAvailable ( bool  onlyMandatoryExpired = false  ) 

This method handles a new version.

It takes care of asking the user what he intends to do and take the proper actions. The onlyMandatoryExpired is usually false because the method is in the flow of the udpate. Putting the onlyMandatoryExpired to true, means that the check with the stored info is done only if the updateType is mandatory and the expiration date is done. It is useful for some check that can be done before starting the sync.

Parameters:
onlyMandatoryExpired - false to check everything during the whole process true continue to check only if the mandatory udpate is expired
Returns:
true if the user has selected something. False if no action was performed by the user.

Referenced by UpdateManager::checkForMandatoryUpdateBeforeStarting(), and UpdateManager::manualCheckForUpdates().

int32_t Updater::parseMessage ( StringBuffer  message  )  [private]

Used to ask the server.

Parse the message from the server and populate the UpdateConfig

int32_t Updater::requestUpdate (  )  [private]

It checks if it is needed to check via url or locally only.

If locally only, there is no other stuff to do. Otherwise the data are overwritten in the Updateconfig and then persisted

void Updater::setUI ( UpdaterUI *  ui  ) 

Set the ui for calling bck when user actions are required.

If this value is not set, the update changes the config but does not need any user interaction.

Referenced by UpdateManager::checkForMandatoryUpdateBeforeStarting(), UpdateManager::checkForUpdates(), and UpdateManager::manualCheckForUpdates().

bool Updater::start (  ) 

Start the update check progress.

This may result in connecting to the update server, check if a new version is available. If this is not required, we can still notify the user of a new version which was previously postponed (later option). The method returns true iff the check discovers a new version.

Referenced by UpdateManager::checkForUpdates().


Member Data Documentation

UpdaterConfig& Updater::config [private]

Updater configuration.

Note: it's owned externally!


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

Generated on Tue Apr 6 13:00:43 2010 for Funambol Outlook Plug-in Library by  doxygen 1.5.7.1