OutlookConfig Class Reference
[Configuration]

Represents the configuration of Outlook client. More...

#include <OutlookConfig.h>

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

List of all members.

Public Member Functions

 ~OutlookConfig ()
 Destructor.
bool read ()
 Read the configuration from Windows registry into this object.
bool save ()
bool save (SyncReport *report)
 Save the configuration from this object into Windows registry.
void readSourcesTimestamps ()
 Read all sources timestamps from win registry.
 _declspec (dllexport) WindowsSyncSourceConfig *getSyncSourceConfig(const char *name)
 Replace getSyncSourceConfig() of DMT (return specific winSourceConfig).
WindowsSyncSourceConfiggetSyncSourceConfig (unsigned int i)
 Return a pointer to the internal WindowsSyncSourceConfig object from its index in winSourceConfigs array (must NOT be freed by caller).
BOOL setSyncSourceConfig (WindowsSyncSourceConfig &wsc)
 Set the passed WindowsSyncSourceConfig object into the correspondent object inside 'winSourceConfigs' array.
BOOL addSyncSourceConfig (WindowsSyncSourceConfig &wsc)
 Adds the passed WindowsSyncSourceConfig.
void setWorkingDir (const char *v)
void setLogDir (const char *v)
void setFullSync (const bool v)
void setScheduledSync (const bool v)
 Save the value to win registry (HKCU), because it can be required from a different instance of plugin.
void setAbortSync (const bool v)
const bool getScheduledSync () const
 Retrieve from win registry (HKCU).
const bool getAbortSync () const
 _declspec (dllexport) const char *getWorkingDir() const
 _declspec (dllexport) const char *getLogDir() const
 _declspec (dllexport) const bool getFullSync() const
const TimeZoneInformationgetCurrentTimezone () const
 Returns a pointer to the currentTimezone internal structure.
void createDefaultConfig ()
 Creates a default configuration.
bool checkToUpgrade ()
 Checks if the config is to upgrade.
void upgradeConfig ()
 Update config with values from HKLM (set by installer).
bool isUpgraded ()
 true if config has been upgraded from a previous version
int getOldSwv ()
 Returns the old installed swv (for upgrades). '0' if not an upgrade.
char * readCurrentSwv ()
 Returns the current software version, read it from HKLM registry.
int setUniqueDevID ()
 Creates and set a unique 'devID' property for current configuration.
bool checkPortalBuild ()
 Check if it's a normal/portal build (from HKLM keys).
void saveBeginSync ()
 Save only "beginSync" property to win registry.
void saveSyncModes ()
 Save only "sync" properties of each source, to win registry.
 _declspec (dllexport) void readSyncModes()
 Reads only "sync" properties of each source, to win registry.

Static Public Member Functions

static OutlookConfiggetInstance ()
 Method to get the sole instance of OutlookConfig.
static bool isInstantiated ()
 Returns true if static instance is not NULL.

Protected Member Functions

 OutlookConfig ()
 Constructor.

Private Member Functions

void readWinSourceConfig (unsigned int i)
 Read client-specific SyncSource properties from Win registry.
void saveWinSourceConfig (unsigned int i)
 Save WindowsSyncSourceConfig properties in DMTree for the desired Source.
char * readPropertyValue (const char *context, const char *propertyName, HKEY rootKey)
int decryptPrivateData ()
 Decrypt private data (Username/Password/Proxy username/Proxy password).
void encryptPrivateData ()
 Encrypt private data (Username/Password/Proxy username/Proxy password).
int readCurrentTimezone ()
 Populate 'currentTimezone' structure, reading values from TIME_ZONE_INFORMATION and also directly from Windows Registry.

Private Attributes

char * workingDir
char * logDir
bool fullSync
bool abortSync
bool upgraded
int oldSwv
TimeZoneInformation currentTimezone
 The structure with current timezone informations.
WindowsSyncSourceConfigwinSourceConfigs
 Array of specific SSConfig.
unsigned int winSourceConfigsCount
 Counter for winSourceConfigs array.

Static Private Attributes

static OutlookConfigpinstance = NULL
 pointer to OutlookConfig instance


Detailed Description

Represents the configuration of Outlook client.

This class is derivated from DMTClientConfig, which is derivate from SyncMangerConfig.


Member Function Documentation

BOOL OutlookConfig::addSyncSourceConfig ( WindowsSyncSourceConfig wsc  ) 

Adds the passed WindowsSyncSourceConfig.

It is added at the end of the 'winSourceConfig' array. This method replaces the 'SyncManagerConfigaddSyncSourceConfig()'.

Parameters:
wsc : the WindowsSyncSourceConfig passed by reference
Returns:
TRUE if no errors

References winSourceConfigs, and winSourceConfigsCount.

Referenced by setSyncSourceConfig().

bool OutlookConfig::checkToUpgrade (  ) 

Checks if the config is to upgrade.

Checks whether the config has to be upgraded to a new version.

It checks the difference between: swv from HKLM: this is set by installer, current version swv from HKCU: previous version of this config

Returns:
'true' if the config needs to be upgraded. 'false' if no upgrade is necessary.

References SyncManagerConfig::getClientConfig(), and readCurrentSwv().

Referenced by initializeClient().

void OutlookConfig::createDefaultConfig (  ) 

int OutlookConfig::decryptPrivateData (  )  [private]

Decrypt private data (Username/Password/Proxy username/Proxy password).

Data is stored encrypted (B64(DES(data)) since version 6.0.9. Data must be in clear text into the config, as config is used by API.

Returns:
0 if data decrypted. 1 if no decryption was necessary (data not encrypted before v.6.0.9).

References checkPortalBuild(), getBuildNumberFromVersion(), and SyncManagerConfig::getClientConfig().

Referenced by read(), and save().

void OutlookConfig::encryptPrivateData (  )  [private]

Encrypt private data (Username/Password/Proxy username/Proxy password).

Data is stored encrypted (B64(DES(data)) since version 6.0.9. Note: Data must be in clear text into the config, as config is used by API, so this method should be called only during save() operation.

Referenced by save().

int OutlookConfig::getOldSwv (  ) 

Returns the old installed swv (for upgrades). '0' if not an upgrade.

Returns the old installed swv (for upgrades).

'0' if not an upgrade.

Referenced by initializeClient().

WindowsSyncSourceConfig * OutlookConfig::getSyncSourceConfig ( unsigned int  i  ) 

Return a pointer to the internal WindowsSyncSourceConfig object from its index in winSourceConfigs array (must NOT be freed by caller).

This method replaces 'getSyncSourceConfig()' of DMTClientConfig.

NOTE: please use the "getSyncSourceConfig(const char* name)" method, to ensure the correct WindowsSyncSourceConfig* is used!

Parameters:
i : the index of source in winSourceConfigs array
Returns:
the correspondent WindowsSyncSourceConfig pointer

References winSourceConfigs.

Referenced by createDefaultConfig(), startSync(), and upgradeConfig().

bool OutlookConfig::isUpgraded (  ) 

true if config has been upgraded from a previous version

Returns true if config has been upgraded from a previous version.

bool OutlookConfig::read (  )  [virtual]

Read the configuration from Windows registry into this object.

This method overrides 'DMTClientConfigread()'. 'DMTClientConfigread()' is first called to read all common properties, then specific SyncSource properties are retrieved.

A separate 'winSourceConfigs' array is used to store all specific SS config, common props are linked to original 'sourceConfigs' array (no copy!).

Returns:
TRUE if no errors

Reimplemented from DMTClientConfig.

References APPLICATION_URI, DMTClientConfig::close(), decryptPrivateData(), SyncManagerConfig::getClientConfig(), SyncManagerConfig::getSwv(), DMTClientConfig::open(), readAppDataPath(), readCurrentTimezone(), readWinSourceConfig(), safeMessageBox(), WindowsSyncSourceConfig::setCommonConfig(), winSourceConfigs, and winSourceConfigsCount.

Referenced by initializeClient().

char * OutlookConfig::readCurrentSwv (  ) 

Returns the current software version, read it from HKLM registry.

This value is set and updated ONLY by installer. Returns a new allocated buffer, must be deleted by the caller.

References APPLICATION_URI.

Referenced by checkToUpgrade(), and upgradeConfig().

int OutlookConfig::readCurrentTimezone (  )  [private]

Populate 'currentTimezone' structure, reading values from TIME_ZONE_INFORMATION and also directly from Windows Registry.

Note:
some mandatory informations cannot be retrieved from Win32 API calls, so we have to get them from HKLM keys.
Returns:
0 if no errors

References TimeZone::bias, currentTimezone, TimeZone::daylightBias, TimeZone::daylightDate, TimeZone::daylightName, TimeZone::displayName, TimeZone::index, TimeZone::isDaylight, TimeZone::keyName, TimeZone::standardBias, TimeZone::standardDate, and TimeZone::standardName.

Referenced by read().

void OutlookConfig::readSourcesTimestamps (  ) 

Read all sources timestamps from win registry.

Reads all sources timestamps from win registry and set all values into configuration.

References DMTClientConfig::close(), DMTClientConfig::open(), and DMTClientConfig::readSourceVars().

Referenced by startSync().

void OutlookConfig::readWinSourceConfig ( unsigned int  i  )  [private]

Read client-specific SyncSource properties from Win registry.

Parameters:
i : the index of node (and syncsource) under 'sourcesNode' node

References DMTClientConfig::open(), PROPERTY_FILTER_DATE_LOWER, PROPERTY_USE_SUBFOLDERS, DateFilter::setDirection(), and winSourceConfigs.

Referenced by read().

bool OutlookConfig::save ( SyncReport report  ) 

Save the configuration from this object into Windows registry.

If SyncReport pointer is passed not NULL, each SyncSource configuration will be saved ONLY if that source was successfully synced. This method overrides 'DMTClientConfigsave()'.

A separate 'winSourceConfigs' array is used to store all SS config, so a specific method 'saveWinSourceConfig()' is used to save sources config into the windows registry.

Returns:
TRUE if no errors

References SyncSourceReport::checkState(), DMTClientConfig::close(), decryptPrivateData(), encryptPrivateData(), SyncReport::getSyncSourceReport(), DMTClientConfig::open(), and saveWinSourceConfig().

void OutlookConfig::saveWinSourceConfig ( unsigned int  i  )  [private]

Save WindowsSyncSourceConfig properties in DMTree for the desired Source.

Source properties are placed in specific node under sources node. Notes: if the node for the current source is not found, it is created! if we are under a restore sync (slow/refresh), 'sync' property will be skipped (keep previous value from registry)

Parameters:
i : the index of SyncSource node

References DateFilter::getDirection(), DMTClientConfig::open(), PROPERTY_FILTER_DATE_LOWER, PROPERTY_USE_SUBFOLDERS, and winSourceConfigs.

Referenced by save().

BOOL OutlookConfig::setSyncSourceConfig ( WindowsSyncSourceConfig wsc  ) 

Set the passed WindowsSyncSourceConfig object into the correspondent object inside 'winSourceConfigs' array.

The values are copied into the object that matches the same name of the passed one. This method replaces the 'SyncManagerConfigsetSyncSourceConfig()'. Note: If a WindowsSyncSourceConfig with the same name is not found, the passed object is added at the end of the 'winSourceConfig' array.

Parameters:
wsc : the WindowsSyncSourceConfig passed by reference
Returns:
TRUE if no errors

References addSyncSourceConfig(), WindowsSyncSourceConfig::getName(), winSourceConfigs, and winSourceConfigsCount.

Referenced by createDefaultConfig().

int OutlookConfig::setUniqueDevID (  ) 

Creates and set a unique 'devID' property for current configuration.

The devID depends on: 1: the local machine name 2: the Windows current user name 3: the current Outlook profile name (now disabled)

If one of these parameters has changed, the devID generated is different. The devID property is then set into current configuration, in the format "fol-%1:%2:%3" where 1 2 3 are the parameters already described. Parameters are also encoded in base64.

Returns:
0 if no errors occurred

References SyncManagerConfig::getClientConfig(), and readSystemErrorMsg().

Referenced by createDefaultConfig().

void OutlookConfig::upgradeConfig (  ) 

Update config with values from HKLM (set by installer).

---- Update config with values from HKLM (set by installer) ---- This is useful when the client has just been upgraded to a new version, only some properties (like 'swv' and 'userAgent') must be corrected.

References getBuildNumberFromVersion(), SyncManagerConfig::getClientConfig(), SyncManagerConfig::getSwv(), getSyncSourceConfig(), WindowsSyncSourceConfig::getType(), readCurrentSwv(), DateFilter::setDirection(), WindowsSyncSourceConfig::setEncoding(), WindowsSyncSourceConfig::setSupportedTypes(), WindowsSyncSourceConfig::setType(), DateFilter::setUpperDate(), and WindowsSyncSourceConfig::setVersion().

Referenced by createDefaultConfig(), and initializeClient().


Member Data Documentation

unsigned int OutlookConfig::winSourceConfigsCount [private]

Counter for winSourceConfigs array.

(internal use, should be equal to 'sourceConfigsCount' member)

Referenced by addSyncSourceConfig(), OutlookConfig(), read(), and setSyncSourceConfig().


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

Generated on Tue Jun 30 12:52:37 2009 for Funambol Outlook Plug-in Library by  doxygen 1.5.7.1