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

virtual ~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.
const ArrayList & getSourcesVisible ()
 Returns the ArrayList of sources visible.
 _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 addWindowsSyncSourceConfig (const std::wstring &sourceName)
 Adds a new WindowsSyncSourceConfig to the array.
bool safeAddSourceVisible (const char *sourceName)
 Adds the passed source name to the sourcesVisible array, safely: the source is not added if already exists in the array.
bool removeSourceVisible (const char *sourceName)
 Removes the passed source name from the sourcesVisible array.
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)
void setFunambolSwv (const StringBuffer &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 StringBuffer & getFunambolSwv ()
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.
int getOldFunambolSwv ()
char * readCurrentSwv ()
 Returns the current software version, read it from HKLM registry.
StringBuffer readFunambolSwv (HKEY rootKey)
 Returns the funambol product software version, read it from HKLM or HKCU 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 saveFunambolSwv ()
 Save the Funambol sw version to config ("_root_/syncML/devDetail/funambol_swv" key).
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.
BOOL readUpdaterConfig (bool refresh)
 Load data from the update tree all the configuration parameters.
void storeUpdaterConfig ()
 Save data into the registry.
UpdaterConfig & getUpdaterConfig ()

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.
BOOL setSyncSourceConfig (WindowsSyncSourceConfig &wsc)
 Set the passed WindowsSyncSourceConfig object into the correspondent object inside 'winSourceConfigs' array.
BOOL addSyncSourceConfig (WindowsSyncSourceConfig &wsc)
 Adds the passed WindowsSyncSourceConfig.

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.
void readSourcesVisible (HKEY rootKey=HKEY_CURRENT_USER)
 Reads the 'sourceOrder' registry key and populates the sourcesVisible array.
void saveSourcesVisible ()
 Reads the sourcesVisible array and saves the 'sourceOrder' registry key.
void savePropertyValue (const StringBuffer &context, const StringBuffer &name, const StringBuffer &value)
 Used to save a generic property into config (win registry, under HKCU node).

Private Attributes

char * workingDir
char * logDir
bool fullSync
bool abortSync
bool upgraded
int oldSwv
StringBuffer funambolSwv
int oldFunambolSwv
TimeZoneInformation currentTimezone
 The structure with current timezone informations.
WindowsSyncSourceConfigwinSourceConfigs
 Array of specific SSConfig.
unsigned int winSourceConfigsCount
 Counter for winSourceConfigs array.
ArrayList sourcesVisible
 The list of sources visible in the Client's UI.
UpdaterConfig updaterConfig
 The parameters related to the update procedure.

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  )  [protected]

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::addWindowsSyncSourceConfig ( const std::wstring &  sourceName  ) 

Adds a new WindowsSyncSourceConfig to the array.

The config for the new source is generated by DefaultConfigFactory. For this operation we have to delete and ricreate the winSourceConfigs array, it's managed inside this method so it's hidden from outside. TODO: rework the procedure to add a source (use ArrayList?)

Parameters:
sourceName the source name to add
Returns:
true if no errors

References getSyncSourceConfig(), DefaultWinConfigFactory::getWinSyncSourceConfig(), readWinSourceConfig(), safeMessageBox(), WindowsSyncSourceConfig::setCommonConfig(), setSyncSourceConfig(), and winSourceConfigs.

Referenced by upgradeConfig().

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(), and getBuildNumberFromVersion().

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 addWindowsSyncSourceConfig(), createDefaultConfig(), isSourceEnabled(), 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 decryptPrivateData(), SyncManagerConfig::getClientConfig(), SyncManagerConfig::getSwv(), DMTClientConfig::open(), readAppDataPath(), readCurrentTimezone(), readFunambolSwv(), readSourcesVisible(), 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.

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().

StringBuffer OutlookConfig::readFunambolSwv ( HKEY  rootKey  ) 

Returns the funambol product software version, read it from HKLM or HKCU registry.

For Funambol builds, this value is = swv.

References SyncManagerConfig::getSwv().

Referenced by read(), and upgradeConfig().

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::open(), and DMTClientConfig::readSourceVars().

Referenced by startSync().

void OutlookConfig::readSourcesVisible ( HKEY  rootKey = HKEY_CURRENT_USER  )  [private]

Reads the 'sourceOrder' registry key and populates the sourcesVisible array.

The 'sourceOrder' value is a comma separated string of source names.

Parameters:
rootKey [OPTIONAL] the rootkey, default is HKEY_CURRENT_USER
Note:
contacts,calendar,tasks,notes cannot be hidden for now

References safeAddSourceVisible(), and sourcesVisible.

Referenced by createDefaultConfig(), and read().

BOOL OutlookConfig::readUpdaterConfig ( bool  refresh  ) 

Load data from the update tree all the configuration parameters.

It populates also the currentVersion of the UpdateConfig class. At the moment "refresh" is not used

References updaterConfig.

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 addWindowsSyncSourceConfig(), and read().

bool OutlookConfig::removeSourceVisible ( const char *  sourceName  ) 

Removes the passed source name from the sourcesVisible array.

Returns:
true if the source was found and removed, false if not found

References sourcesVisible.

Referenced by startSync().

bool OutlookConfig::safeAddSourceVisible ( const char *  sourceName  ) 

Adds the passed source name to the sourcesVisible array, safely: the source is not added if already exists in the array.

Returns:
true if the element is added, false if not found

References sourcesVisible.

Referenced by readSourcesVisible(), and startSync().

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(), decryptPrivateData(), encryptPrivateData(), SyncReport::getSyncSourceReport(), SyncManagerConfig::getSyncURL(), DMTClientConfig::open(), saveFunambolSwv(), saveSourcesVisible(), saveWinSourceConfig(), and UpdateManager::setURLCheck().

void OutlookConfig::savePropertyValue ( const StringBuffer &  context,
const StringBuffer &  name,
const StringBuffer &  value 
) [private]

Used to save a generic property into config (win registry, under HKCU node).

Parameters:
context the full context (i.e. "Software/Funambol/OutlookClient/spds/syncml/DevDetail")
name the property name
value the property value to set

Referenced by saveBeginSync(), saveFunambolSwv(), and saveSourcesVisible().

void OutlookConfig::saveSourcesVisible (  )  [private]

Reads the sourcesVisible array and saves the 'sourceOrder' registry key.

The 'sourceOrder' value is a comma separated string of source names.

References savePropertyValue(), and sourcesVisible.

Referenced by save().

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(), WindowsSyncSourceConfig::getName(), DMTClientConfig::open(), PROPERTY_FILTER_DATE_LOWER, PROPERTY_USE_SUBFOLDERS, and winSourceConfigs.

Referenced by save().

BOOL OutlookConfig::setSyncSourceConfig ( WindowsSyncSourceConfig wsc  )  [protected]

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 addWindowsSyncSourceConfig(), and 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 (  ) 


Member Data Documentation

ArrayList OutlookConfig::sourcesVisible [private]

The list of sources visible in the Client's UI.

Sources not listed here are hidden to the user. NOTE: "contact, calendar, task, note" cannot be hidden *** TODO ***

Referenced by getSourcesVisible(), readSourcesVisible(), removeSourceVisible(), safeAddSourceVisible(), and saveSourcesVisible().

unsigned int OutlookConfig::winSourceConfigsCount [private]

Counter for winSourceConfigs array.

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

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


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

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