Utility functions
[Client DLL]

Collaboration diagram for Utility functions:

Defines

#define SYNCSOURCE_CALENDAR   1
 Codes used by UI ("0" is the initialization).
#define SYNCSOURCE_CONTACTS   2
#define SYNCSOURCE_NOTES   3
#define SYNCSOURCE_TASKS   4
#define SYNCSOURCE_PICTURES   5
#define TYPE_SKIPPED_ACTION   0
 Used as mapping for the updates choice for the OpenMessageBox for the UI.
#define TYPE_NOW_LATER_SKIP_OPTIONAL   1
#define TYPE_NOW_LATER_RECCOMENDED   2
#define TYPE_NOW_LATER_MANDATORY   3
#define TYPE_NOW_EXIT_MANDATORY   4

Functions

int TimedMessageBox (HWND hwndOwner, LPCTSTR pszMessage, LPCTSTR pszTitle, UINT flags, DWORD dwTimeout)
 TimedMessageBox.
int safeMessageBox (const char *message, const char *title=NULL, unsigned int flags=0)
 Function used to display a message-box with a message for the user.
int wsafeMessageBox (const WCHAR *wmessage, const WCHAR *wtitle=NULL, unsigned int flags=0)
 Function used to display a message-box with a message for the user.
 _declspec (dllexport) void printLog(const char *msg
bool isSIF (const std::wstring &dataType)
 Returns true if dataType is one of accepted SIF formats.
bool isSIF (const std::string &dataType)
 Returns true if dataType is one of accepted SIF formats.
bool isAcceptedDataType (const std::wstring &dataType)
 Returns true if dataType is one of accepted formats by Outlook plugin.
bool isAcceptedDataType (const std::string &dataType)
 Returns true if dataType is one of accepted formats by Outlook plugin.
char * syncModeName (SyncMode code)
 Returns the syncmode name given its code.
bool isFullSyncMode (SyncMode mode)
 Returns true if the passed sync mode is a 'full sync mode' (slow sync, refresh from client, refresh from server).
void toWindows (char *str)
 Convert the path in Windows format, changing the slashes in back-slashes.
WCHAR * readAppDataPath ()
 Returns the path of current user's application data folder.
WCHAR * readDataPath (const WCHAR *itemType)
 Returns the path of file where data files for current user are stored.
int makeDataDirs ()
 Create directories for data files under 'application data' dir.
int getWindowsUser (std::wstring &userName)
 Gets the Windows current user (the one now active).
int getWindowsUserEx (std::wstring &userName)
 Gets the Windows current user (the one now active) in the extended format "Machine\User".
StringBuffer getDefaultPicturesPath ()
 Returns the default path to store pictures (shell folder 'pictures' for this user).
std::wstring readFromFile (const std::wstring &filePath)
 Reads a file from filesystem and write its content into a string.
int writeToFile (const std::wstring &content, const std::wstring &filePath, const WCHAR *mode=L"w")
 Write the passed string 'content' into a file on filesystem (wstring version).
int writeToFile (const std::string &content, const std::string &filePath, const char *mode="w")
 Write the passed string 'content' into a file on filesystem (string version).
std::string getSyncMutexName ()
 Returns the syncMutex unique name: "fol-syncInProgress-xxxxxxx".
char * readSystemErrorMsg (DWORD errorCode=0)
 Utility function to retrieve the correspondant message for a generic System error.
std::wstring getSafeItemName (ClientItem *cItem)
 Returns a smart name of the item passed, used for log/debug or in case of errors.
void printReport (SyncReport *sr, SyncSource **sources)
 Prints a smart synchronization report table into LOG file.
char * friendlyName (const char *sourceName)
 Returns a friendly name for the passed syncsource name.
int getBuildNumberFromVersion (const char *swv)
 Returns an integer value rapresenting the build number read from the string version passed (e.g.
long variantTimeToTimeStamp (const double vTime)
 Variant time (double format) -> Timestamp (long format).
int syncSourceNameToIndex (const StringBuffer &sourceName)
StringBuffer syncSourceIndexToName (const int sourceID)
bool isSourceVisibleA (const char *sourceName)
 Used to quicky check if a specific source is visible or not.
bool isSourceVisible (const WCHAR *sourceName)
 Used to quicky check if a specific source is visible or not (WCHAR version).
int countSourceVisible ()
 Used to check the total number of sources visible.
bool isSourceEnabled (const char *sourceName)
 Used to quicky check if a specific source is enabled or not, checking the configuration.
static bool isErrorStatus (int status)
 Is the given status code an error status code? Error codes are the ones outside the range 200-299.
 _declspec (dllexport) WindowsSyncSourceConfig *OutlookConfig
 Return a pointer to the internal WindowsSyncSourceConfig object from its name (must NOT be freed by caller).

Variables

const char * level = LOG_INFO)

Define Documentation

#define TYPE_SKIPPED_ACTION   0

Used as mapping for the updates choice for the OpenMessageBox for the UI.

With this code type we map the action and the message for the user for the update


Function Documentation

_declspec ( dllexport   ) 

Return a pointer to the internal WindowsSyncSourceConfig object from its name (must NOT be freed by caller).

This method replaces 'getSyncSourceConfig()' of DMTClientConfig.

Parameters:
name : the source name
Returns:
the correspondent WindowsSyncSourceConfig pointer

int countSourceVisible (  ) 

Used to check the total number of sources visible.

It checks the sourcesVisible array.

Referenced by CFullSync::adjustCheckboxes().

int getBuildNumberFromVersion ( const char *  swv  ) 

Returns an integer value rapresenting the build number read from the string version passed (e.g.

"6.1.12" -> 60112).

Referenced by OutlookConfig::decryptPrivateData(), and OutlookConfig::upgradeConfig().

std::wstring getSafeItemName ( ClientItem cItem  ) 

std::string getSyncMutexName (  ) 

Returns the syncMutex unique name: "fol-syncInProgress-xxxxxxx".

"xxxxxxx" is the BeginSync timestamp, stored in win registry (HKCU). We don't use OutlookConfig object because the mutex name can be asked BEFORE the initialization of client (so config not yet available). So here we directly access to the win registry.

References SYNC_MUTEX_NAME.

Referenced by checkSyncInProgress(), and startSync().

int getWindowsUser ( wstring &  userName  ) 

Gets the Windows current user (the one now active).

Parameters:
[OUT] the Windows current user
Returns:
0 if no errors

References readSystemErrorMsg().

Referenced by getScheduledTaskName(), and upgradePlugin().

int getWindowsUserEx ( wstring &  userName  ) 

Gets the Windows current user (the one now active) in the extended format "Machine\User".

Parameters:
[OUT] the Windows current user
Returns:
0 if no errors

References readSystemErrorMsg().

Referenced by setScheduleTask().

bool isAcceptedDataType ( const string &  dataType  ) 

Returns true if dataType is one of accepted formats by Outlook plugin.

(string version)

bool isAcceptedDataType ( const wstring &  dataType  ) 

Returns true if dataType is one of accepted formats by Outlook plugin.

(wstring version)

Referenced by WindowsSyncSource::addItem(), and WindowsSyncSource::updateItem().

static bool isErrorStatus ( int  status  )  [inline, static]

Is the given status code an error status code? Error codes are the ones outside the range 200-299.

Parameters:
status the status code to check

Referenced by WindowsSyncSource::createOldItems().

bool isSIF ( const string &  dataType  ) 

Returns true if dataType is one of accepted SIF formats.

(string version)

bool isSIF ( const wstring &  dataType  ) 

Returns true if dataType is one of accepted SIF formats.

(wstring version)

Referenced by WindowsSyncSource::addItem(), convertToSyncItem(), WindowsSyncSource::extractFolder(), fillClientItem(), and WindowsSyncSource::updateItem().

bool isSourceEnabled ( const char *  sourceName  ) 

Used to quicky check if a specific source is enabled or not, checking the configuration.

If a source is disabled, it's greyed out in UI.

References OutlookConfig::getInstance(), OutlookConfig::getSyncSourceConfig(), and WindowsSyncSourceConfig::isEnabled().

Referenced by CFullSync::OnBnClickedRefreshS2C().

bool isSourceVisible ( const WCHAR *  sourceName  ) 

Used to quicky check if a specific source is visible or not (WCHAR version).

It checks the sourcesVisible array.

References isSourceVisibleA().

Referenced by getMainWindowSize(), and CSyncForm::refreshSource().

bool isSourceVisibleA ( const char *  sourceName  ) 

Used to quicky check if a specific source is visible or not.

It checks the sourcesVisible array.

Referenced by isSourceVisible().

int makeDataDirs (  ) 

Create directories for data files under 'application data' dir.

Returns:
0 if no errors

Referenced by WindowsSyncSource::endSync(), initLog(), and upgradePlugin().

void printReport ( SyncReport sr,
SyncSource **  sources 
)

WCHAR* readAppDataPath (  ) 

Returns the path of current user's application data folder.

For example: "C:\Documents And Settings\Settimio\Application Data" The string returned is allocated new, so MUST be freed by caller. Returns NULL in case of errors (set lastErrorMessage).

Returns:
path of current user's tmp folder under 'application data'

Referenced by ClientContact::ClientContact(), OutlookConfig::createDefaultConfig(), OutlookConfig::read(), and readDataPath().

WCHAR* readDataPath ( const WCHAR *  itemType  ) 

Returns the path of file where data files for current user are stored.

It is located under 'application data' folder. For example: "C:\Documents And Settings\Settimio\Application Data\Funambol\Outlook Client" The string returned is allocated new, so MUST be freed by caller. Returns NULL in case of errors (set lastErrorMessage).

Returns:
path of current user's tmp folder under 'application data'

References readAppDataPath().

Referenced by WindowsSyncSource::closeDataFile(), WindowsSyncSource::endSync(), WindowsSyncSource::manageModificationsFromLastSync(), WindowsSyncSource::resetDataFile(), and setRecurrenceExceptions().

std::wstring readFromFile ( const wstring &  filePath  ) 

Reads a file from filesystem and write its content into a string.

Parameters:
filePath : the path of file to read
Returns:
the wstring with content read (empty if file not found)
Note:
reads chars from file and use 'toWideChar' function to convert data into WCHAR, because we MUST use UTF-8 charset.

Referenced by WindowsSyncSource::manageModificationsFromLastSync().

char* readSystemErrorMsg ( DWORD  errorCode  ) 

Utility function to retrieve the correspondant message for a generic System error.

Pointer returned is allocated new, must be freed by caller.

Parameters:
errorCode : the code of error (obtained by 'getLastError()')
Returns:
the (new allocated) error message

Referenced by checkSyncInProgress(), deleteScheduleTask(), endSync(), exitSyncThread(), getScheduleTask(), getWindowsUser(), getWindowsUserEx(), hardTerminateSync(), setScheduleTask(), OutlookConfig::setUniqueDevID(), startSync(), and upgradePlugin().

int safeMessageBox ( const char *  message,
const char *  title,
unsigned int  flags 
)

Function used to display a message-box with a message for the user.

The message-box is displayed only if this is NOT a scheduled sync (otherwise the message will be redirected to LOG file)

Parameters:
message : the message to display
title : [OPTIONAL] the title of the message box (default = MSGBOX_ERROR_TITLE)
flags : [OPTIONAL] flags for the message-box (default = MB_OK | MB_ICONEXCLAMATION)
Returns:
the value returned from MessageBox call

References OutlookConfig::getInstance(), and OutlookConfig::getScheduledSync().

Referenced by OutlookConfig::addWindowsSyncSourceConfig(), OutlookConfig::createDefaultConfig(), initializeClient(), initLog(), manageClientException(), ClientApplication::pickFolder(), and OutlookConfig::read().

int TimedMessageBox ( HWND  hwndOwner,
LPCTSTR  pszMessage,
LPCTSTR  pszTitle,
UINT  flags,
DWORD  dwTimeout 
)

TimedMessageBox.

The same as the standard MessageBox, except that TimedMessageBox also accepts a timeout. If the user does not respond within the specified timeout, the value 0 is returned instead of one of the ID* values.

Referenced by WindowsSyncClient::continueAfterPrepareSync().

void toWindows ( char *  str  ) 

Convert the path in Windows format, changing the slashes in back-slashes.

Parameters:
str - [IN-OUT] the string to convert

long variantTimeToTimeStamp ( const double  vTime  ) 

Variant time (double format) -> Timestamp (long format).

NOTE: the internal call 'mktime()' adjusts time to UTC... this is OK because timestamps always refer to UTC time.

Parameters:
vTime : input time in variant format (milliseconds from Jan 1 1900)
Returns:
output time as timestamp (seconds from Jan 1 1970)

Referenced by WindowsSyncSource::manageModificationsFromLastSync().

int writeToFile ( const string &  content,
const string &  filePath,
const char *  mode 
)

Write the passed string 'content' into a file on filesystem (string version).

If file not found, it is created.

Parameters:
content : the string to write
filePath : path of file to write
mode : [OPTIONAL] mode of writing (default = "w" = writing, content destroyed)
Returns:
0 if no errors

int writeToFile ( const wstring &  content,
const wstring &  filePath,
const WCHAR *  mode 
)

Write the passed string 'content' into a file on filesystem (wstring version).

If file not found, it is created.

Parameters:
content : the string to write
filePath : path of file to write
mode : [OPTIONAL] mode of writing (default = "w" = writing, content destroyed)
Returns:
0 if no errors
Note:
writes chars to file and use 'toMultibyte' function to convert data from WCHAR, because we MUST use UTF-8 charset.

Referenced by WindowsSyncSource::closeDataFile(), WindowsSyncSource::endSync(), initLog(), WindowsSyncSource::resetDataFile(), and setRecurrenceExceptions().

int wsafeMessageBox ( const WCHAR *  wmessage,
const WCHAR *  wtitle,
unsigned int  flags 
)

Function used to display a message-box with a message for the user.

(WCHAR version) The message-box is displayed only if this is NOT a scheduled sync (otherwise the message will be redirected to LOG file)

Parameters:
message : the message to display
title : [OPTIONAL] the title of the message box (default = MSGBOX_ERROR_TITLE)
flags : [OPTIONAL] flags for the message-box (default = MB_OK | MB_ICONEXCLAMATION)
Returns:
the value returned from MessageBox call

References OutlookConfig::getInstance(), and OutlookConfig::getScheduledSync().

Referenced by manageSyncErrorMsg(), and CSyncForm::refreshSource().


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