00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef INCL_WINDOWS_SYNC_SOURCE
00037 #define INCL_WINDOWS_SYNC_SOURCE
00038
00043 #include "base/fscapi.h"
00044 #include "spds/constants.h"
00045 #include "spds/SyncItem.h"
00046 #include "spds/SyncMap.h"
00047 #include "spds/SyncStatus.h"
00048 #include "spds/SyncSource.h"
00049 #include"WindowsSyncSourceConfig.h"
00050 #include "outlook/ClientApplication.h"
00051
00052 #include <string>
00053 #include <list>
00054
00055
00056 typedef std::list<std::wstring> itemKeyList;
00057 typedef itemKeyList::iterator itemKeyIterator;
00058
00060
00061
00062
00063
00064
00065 #define ERR_CODE_FOLDER_PATH 1
00066 #define ERR_CODE_DELETE_NOT_FOUND 2
00067 #define ERR_CODE_OLD_ITEMS_PATH 100
00068 #define ERR_CODE_UPDATE_NOT_FOUND 101
00069 #define ERR_CODE_FOLDER_OPEN 102
00070 #define ERR_CODE_ITEM_CREATE 104
00071 #define ERR_CODE_ITEM_FILL 105
00072 #define ERR_CODE_ITEM_SAVE 106
00073 #define ERR_CODE_DELETE 107
00074 #define ERR_CODE_ITEM_BAD_TYPE 108
00075 #define ERR_CODE_ITEM_GET 109
00076 #define ERR_CODE_NO_ROOT_FOLDER 110
00077 #define ERR_CODE_OPEN_OUTLOOK 111
00078 #define ERR_CODE_READ_ALL_ITEMS 112
00079
00080 #define MAX_SOURCE_ERRORS 10
00082 #define TIMESTAMP_DELAY 2
00095 class WindowsSyncSource : public SyncSource {
00096
00097 private:
00098
00100 ClientApplication* outlook;
00101
00102
00103 protected:
00104
00107 WindowsSyncSourceConfig& winConfig;
00108
00109
00111 itemKeyList allItems;
00112 itemKeyList newItems;
00113 itemKeyList modItems;
00114 itemKeyList delItems;
00115 itemKeyList allItemsPaths;
00116
00118 itemKeyIterator iAll;
00119 itemKeyIterator iNew;
00120 itemKeyIterator iMod;
00121 itemKeyIterator iDel;
00122 itemKeyIterator iAllPaths;
00123
00124
00126 unsigned int numErrors;
00127
00129 std::wstring defaultFolderPath;
00130
00131
00132
00133
00134
00135 ClientFolder* getStartFolder();
00136
00137
00138 void pushAllSubfolderItemsToList(ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00139 void pushAllItemsToList (ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00140
00141
00142 int manageModificationsFromLastSync();
00143
00144
00145 int addForcedItemsToModList(itemKeyList& forcedItems);
00146
00147
00148 std::wstring createOldItems();
00149 void parseOldItems(std::wstring& data, itemKeyList& listItems, itemKeyList& listFolders);
00150
00151
00152 int resetDataFile(const std::wstring& itemType);
00153 int closeDataFile(const std::wstring& itemType);
00154
00155
00156 bool folderPathAllowed(const std::wstring& p);
00157
00158
00159 void checkBirthdayAnniversary(ClientItem* cItem);
00160 int deleteAppointment(ClientItem* cItem, const std::wstring& propertyName);
00161
00162
00163 void manageSourceError(const int errorCode, const char* errorMsg);
00164
00165 void extractFolder(const std::wstring dataString, const std::wstring dataType, std::wstring& path);
00166
00167
00168 public:
00169
00178 WindowsSyncSource::WindowsSyncSource(const WCHAR* name, WindowsSyncSourceConfig* wsc);
00179
00180 ~WindowsSyncSource();
00181
00182
00184 const WindowsSyncSourceConfig& getConfig() const;
00185 WindowsSyncSourceConfig& getConfig();
00186
00187 int beginSync();
00188 int endSync();
00189
00190 void WindowsSyncSource::setItemStatus(const WCHAR* key, int status);
00191 void assign(WindowsSyncSource& s);
00192 ArrayElement* clone();
00193
00194
00195
00196 SyncItem* getFirstItem();
00197 SyncItem* getNextItem ();
00198
00199 SyncItem* getFirstNewItem();
00200 SyncItem* getNextNewItem ();
00201 SyncItem* getFirstUpdatedItem();
00202 SyncItem* getNextUpdatedItem ();
00203
00204 SyncItem* getFirstDeletedItem();
00205 SyncItem* getNextDeletedItem ();
00206
00207 SyncItem* getFirstItemKey();
00208 SyncItem* getNextItemKey();
00209
00210
00211
00212 int addItem (SyncItem& item);
00213 int updateItem(SyncItem& item);
00214 int deleteItem(SyncItem& item);
00215
00216 };
00217
00220 #endif