#include <WindowsSyncSource.h>
Inheritance diagram for WindowsSyncSource:
Public Member Functions | |
WindowsSyncSource (const WCHAR *name, WindowsSyncSourceConfig *wsc) | |
Constructor: creates a WindowsSyncSource with the specified name and config. | |
const WindowsSyncSourceConfig & | getConfig () const |
Used to access configuration of SS. | |
WindowsSyncSourceConfig & | getConfig () |
read-write access to win configuration | |
int | beginSync () |
This is the first method called. | |
int | endSync () |
This is the last method called. | |
void | setItemStatus (const WCHAR *key, int status) |
called by the sync engine with the status returned by the server for a certain item that the client sent to the server | |
void | assign (WindowsSyncSource &s) |
ArrayElement * | clone () |
ArrayElement implementation. | |
SyncItem * | getFirstItem () |
It's called in case of full-sync or refresh-from-client sync. | |
SyncItem * | getNextItem () |
It's called in case of full-sync or refresh-from-client sync. | |
SyncItem * | getFirstNewItem () |
It's called in case of two-way sync. | |
SyncItem * | getNextNewItem () |
It's called in case of two-way sync. | |
SyncItem * | getFirstUpdatedItem () |
It's called in case of two-way sync. | |
SyncItem * | getNextUpdatedItem () |
It's called in case of two-way sync. | |
SyncItem * | getFirstDeletedItem () |
It's called in case of two-way sync. | |
SyncItem * | getNextDeletedItem () |
It's called in case of two-way sync. | |
SyncItem * | getFirstItemKey () |
It's called in case of refresh-from-server sync. | |
SyncItem * | getNextItemKey () |
This method should never been called: getFirstItemKey() returns NULL. | |
int | addItem (SyncItem &item) |
Adds the item from the server to the client. | |
int | updateItem (SyncItem &item) |
Update the item from the server to the client. | |
int | deleteItem (SyncItem &item) |
Delete the SyncItem (empty, only key) from server to client. | |
Protected Member Functions | |
ClientFolder * | getStartFolder () |
Get the starting Outlook folder for this source. | |
void | pushAllSubfolderItemsToList (ClientFolder *folder, itemKeyList &listItems, itemKeyList &listItemsPaths) |
Get all items inside 'folder' and also all items from every subfolder (call to this method recursively). | |
void | pushAllItemsToList (ClientFolder *folder, itemKeyList &listItems, itemKeyList &listItemsPaths) |
Get all items inside 'folder' and push them (only keys) into 'listItems' list. | |
int | manageModificationsFromLastSync () |
Creates the NEW/MOD/DEL items lists from last successfull sync. | |
int | addForcedItemsToModList (itemKeyList &forcedItems) |
Scan the passed list of 'forced modified items' and add each element to the 'modItems' list. | |
std::wstring | createOldItems () |
Format the list of all current items into a string, as an XML. | |
void | parseOldItems (std::wstring &data, itemKeyList &listItems, itemKeyList &listFolders) |
Parse the list of all current items into a string, from an XML. | |
int | resetDataFile (const std::wstring &itemType) |
Reset the specified data file: destroy any content and add a "<itemType>" tag at the beginning of file. | |
int | closeDataFile (const std::wstring &itemType) |
Close the specified data file: append a "</itemType>" tag at the end of the file. | |
bool | folderPathAllowed (const std::wstring &p) |
Returns true if path passed is allowed to sync items inside it. | |
void | checkBirthdayAnniversary (ClientItem *cItem) |
Verifies if birthday/anniversary were created by Outlook (only for contacts save). | |
int | deleteAppointment (ClientItem *cItem, const std::wstring &propertyName) |
Deletes an appointement event (birthday or anniversary) automatically created by Outlook while saving item 'cItem'. | |
void | manageSourceError (const int errorCode, const char *errorMsg) |
Common actions to do when an error occurs inside SyncSource. | |
void | extractFolder (const std::wstring dataString, const std::wstring dataType, std::wstring &path) |
Extract 'Folder' path searching inside string 'dataString' (SIF or vCard/vCal). | |
Protected Attributes | |
WindowsSyncSourceConfig & | winConfig |
Configuration object for the source. | |
itemKeyList | allItems |
Lists of item keys. | |
itemKeyList | newItems |
itemKeyList | modItems |
itemKeyList | delItems |
itemKeyList | allItemsPaths |
itemKeyIterator | iAll |
Iterators of lists. | |
itemKeyIterator | iNew |
itemKeyIterator | iMod |
itemKeyIterator | iDel |
itemKeyIterator | iAllPaths |
unsigned int | numErrors |
Counter of number of errors occurred. | |
std::wstring | defaultFolderPath |
Default folder path in Outlook. | |
Private Attributes | |
ClientApplication * | outlook |
Pointer to the sole instance of ClientApplication (singleton). |
Implements all methods to get/add syncItems on Client, plus there are some internal methods to handle operations on the SyncSource.
All syncItems are managed inside this class, the only difference is the member 'name'.
WindowsSyncSource::WindowsSyncSource | ( | const WCHAR * | name, | |
WindowsSyncSourceConfig * | wsc | |||
) |
Constructor: creates a WindowsSyncSource with the specified name and config.
name | the name of the SyncSource | |
wsc | to init by reference the 'winConfig' member (for client-specific props) 'config' member is initialized from wsc->getCommonConfig() to get the original common properties used by API. |
ClientFolder * WindowsSyncSource::getStartFolder | ( | ) | [protected] |
Get the starting Outlook folder for this source.
Starting folder is retrieved from path (stored in config), if path not set the default folder for this source will be returned.
void WindowsSyncSource::pushAllSubfolderItemsToList | ( | ClientFolder * | folder, | |
itemKeyList & | listItems, | |||
itemKeyList & | listItemsPaths | |||
) | [protected] |
Get all items inside 'folder' and also all items from every subfolder (call to this method recursively).
All items are pushed into 'listItems' list.
folder | the ClientFolder pointer to search items | |
listItems | the list<wstring> where pushing items | |
listItemsPaths | the list<wstring> where pushing items paths (optimization, used at the end of sync) |
void WindowsSyncSource::pushAllItemsToList | ( | ClientFolder * | folder, | |
itemKeyList & | listItems, | |||
itemKeyList & | listItemsPaths | |||
) | [protected] |
Get all items inside 'folder' and push them (only keys) into 'listItems' list.
Sends messages to update statusbar on each item read. Also normalize appointment exceptions: mod exceptions need to be converted to new appointments (see doc on Recurrence Exceptions) and added to the 'listItems'.
folder | the ClientFolder pointer to search items | |
listItems | the list<wstring> where pushing items ID | |
listItemsPaths | the list<wstring> where pushing items paths (optimization, used at the end of sync) |
int WindowsSyncSource::manageModificationsFromLastSync | ( | ) | [protected] |
Creates the NEW/MOD/DEL items lists from last successfull sync.
int WindowsSyncSource::addForcedItemsToModList | ( | itemKeyList & | forcedItems | ) | [protected] |
Scan the passed list of 'forced modified items' and add each element to the 'modItems' list.
Elements are added ONLY if not yet found in one of the lists (NEW/MOD/DEL) - to avoid duplicates.
forcedItems | list of forced items to scan |
wstring WindowsSyncSource::createOldItems | ( | ) | [protected] |
Format the list of all current items into a string, as an XML.
<contact> <LastSyncTime>1168862109</LastSyncTime> <ID>00013505600G4BGG494D009680</ID> <Folder>\Personal Folder</Folder> <ID>00033505600G4BGG494D006620</ID> <Folder>\Personal Folder</Folder> ... </contact>
'ID' is the item's ID in Outlook. 'Folder' is the item's folder path in Outlook.
void WindowsSyncSource::parseOldItems | ( | std::wstring & | data, | |
itemKeyList & | listItems, | |||
itemKeyList & | listFolders | |||
) | [protected] |
Parse the list of all current items into a string, from an XML.
<contact> <LastSyncTime>1168862109</LastSyncTime> <ID>00013505600G4BGG494D009680</ID> <Folder>\Personal Folder</Folder> <ID>00033505600G4BGG494D006620</ID> <Folder>\Personal Folder</Folder> ... </contact>
and push all items' keys into 'listItems' list. Also push all items' folder paths into 'listFolder' list. Each key of listItems corresponds to the folder element of the same index. It supports old format of db files (before v.6.0.9), like this:
<contact> <LastSyncTime>1168862109</LastSyncTime> 00013505600G4BGG494D009680 00033505600G4BGG494D006620 ... </contact>
data | the input string to parse | |
listItems | [IN-OUT] list of item keys, filled here | |
listFolders | [IN-OUT] list of folder paths, filled here |
int WindowsSyncSource::resetDataFile | ( | const std::wstring & | itemType | ) | [protected] |
Reset the specified data file: destroy any content and add a "<itemType>" tag at the beginning of file.
The file path is "<APP_DATA>\Funambol\Outlook Plugin\<itemType>.db"
itemType | the itemType |
int WindowsSyncSource::closeDataFile | ( | const std::wstring & | itemType | ) | [protected] |
Close the specified data file: append a "</itemType>" tag at the end of the file.
The file path is "<APP_DATA>\Funambol\Outlook Plugin\<itemType>.db"
itemType | the itemType |
void WindowsSyncSource::checkBirthdayAnniversary | ( | ClientItem * | cItem | ) | [protected] |
Verifies if birthday/anniversary were created by Outlook (only for contacts save).
If created, they are immediately deleted.
int WindowsSyncSource::deleteAppointment | ( | ClientItem * | cItem, | |
const std::wstring & | propertyName | |||
) | [protected] |
Deletes an appointement event (birthday or anniversary) automatically created by Outlook while saving item 'cItem'.
The item to delete is searched inside default Outlook folder, where:
cItem | : the ClientContact that was saved | |
propertyName | : "Anniversary" or "Birthday" |
void WindowsSyncSource::manageSourceError | ( | const int | errorCode, | |
const char * | errorMsg | |||
) | [protected] |
Common actions to do when an error occurs inside SyncSource.
Updates the internal report. Doesn't set the Source state, as generally we want to continue the sync. (source state is set only after too many errors on this source)
void WindowsSyncSource::extractFolder | ( | const std::wstring | dataString, | |
const std::wstring | dataType, | |||
std::wstring & | path | |||
) | [protected] |
Extract 'Folder' path searching inside string 'dataString' (SIF or vCard/vCal).
Path retrieved is written into 'path' variable (empty string if 'Folder' not found).
dataString | the input string to search 'Folder' info | |
dataType | the mime data type (SIF/vCard) | |
path | [OUTPUT] the folder path exctracted |
int WindowsSyncSource::beginSync | ( | ) | [virtual] |
This is the first method called.
It executes all operations to be done before synchronizing this source:
Reimplemented from SyncSource.
int WindowsSyncSource::endSync | ( | ) | [virtual] |
This is the last method called.
It executes all operations to be done after this source has been synchronized:
Reimplemented from SyncSource.
void WindowsSyncSource::setItemStatus | ( | const WCHAR * | key, | |
int | status | |||
) | [virtual] |
called by the sync engine with the status returned by the server for a certain item that the client sent to the server
key | the local key of the item | |
status | the SyncML status returned by the server |
Implements SyncSource.
SyncItem * WindowsSyncSource::getFirstItem | ( | ) | [virtual] |
It's called in case of full-sync or refresh-from-client sync.
Implements SyncSource.
SyncItem * WindowsSyncSource::getNextItem | ( | ) | [virtual] |
It's called in case of full-sync or refresh-from-client sync.
Implements SyncSource.
SyncItem * WindowsSyncSource::getFirstNewItem | ( | ) | [virtual] |
It's called in case of two-way sync.
Creates the lists of newItems, modItems and delItems, comparing differences between allItems list and the list of all items from the last sync (stored in cache files).
Implements SyncSource.
SyncItem * WindowsSyncSource::getNextNewItem | ( | ) | [virtual] |
It's called in case of two-way sync.
Implements SyncSource.
SyncItem * WindowsSyncSource::getFirstUpdatedItem | ( | ) | [virtual] |
It's called in case of two-way sync.
Implements SyncSource.
SyncItem * WindowsSyncSource::getNextUpdatedItem | ( | ) | [virtual] |
It's called in case of two-way sync.
Implements SyncSource.
SyncItem * WindowsSyncSource::getFirstDeletedItem | ( | ) | [virtual] |
It's called in case of two-way sync.
Implements SyncSource.
SyncItem * WindowsSyncSource::getNextDeletedItem | ( | ) | [virtual] |
It's called in case of two-way sync.
Implements SyncSource.
SyncItem * WindowsSyncSource::getFirstItemKey | ( | ) | [virtual] |
It's called in case of refresh-from-server sync.
All items are removed inside Outlook.
Implements SyncSource.
int WindowsSyncSource::addItem | ( | SyncItem & | item | ) | [virtual] |
Adds the item from the server to the client.
Sets the SyncItem key (the GUID of item).
Implements SyncSource.
int WindowsSyncSource::updateItem | ( | SyncItem & | item | ) | [virtual] |
Update the item from the server to the client.
Checks if destination folder is the same of the item's folder.
Implements SyncSource.
int WindowsSyncSource::deleteItem | ( | SyncItem & | item | ) | [virtual] |
Delete the SyncItem (empty, only key) from server to client.
Implements SyncSource.
WindowsSyncSourceConfig& WindowsSyncSource::winConfig [protected] |
Configuration object for the source.
It's a reference to WindowsSyncSourceConfig object owned by OutlookConfig. It's automatically initialized in the constructor.