00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef INCL_WINDOWS_SYNC_SOURCE
00020 #define INCL_WINDOWS_SYNC_SOURCE
00021
00026 #include "base/fscapi.h"
00027 #include "spds/constants.h"
00028 #include "spds/SyncItem.h"
00029 #include "spds/SyncMap.h"
00030 #include "spds/SyncStatus.h"
00031 #include "spds/SyncSource.h"
00032 #include"WindowsSyncSourceConfig.h"
00033 #include "outlook/ClientApplication.h"
00034
00035 #include <string>
00036 #include <list>
00037
00038
00039 typedef std::list<std::wstring> itemKeyList;
00040 typedef itemKeyList::iterator itemKeyIterator;
00041
00043
00044
00045
00046
00047
00048 #define ERR_CODE_FOLDER_PATH 1
00049 #define ERR_CODE_DELETE_NOT_FOUND 2
00050 #define ERR_CODE_OLD_ITEMS_PATH 100
00051 #define ERR_CODE_UPDATE_NOT_FOUND 101
00052 #define ERR_CODE_FOLDER_OPEN 102
00053 #define ERR_CODE_ITEM_CREATE 104
00054 #define ERR_CODE_ITEM_FILL 105
00055 #define ERR_CODE_ITEM_SAVE 106
00056 #define ERR_CODE_DELETE 107
00057 #define ERR_CODE_ITEM_BAD_TYPE 108
00058 #define ERR_CODE_ITEM_GET 109
00059 #define ERR_CODE_NO_ROOT_FOLDER 110
00060 #define ERR_CODE_OPEN_OUTLOOK 111
00061 #define ERR_CODE_READ_ALL_ITEMS 112
00062
00063 #define MAX_SOURCE_ERRORS 10
00065 #define TIMESTAMP_DELAY 2
00078 class WindowsSyncSource : public SyncSource {
00079
00080 private:
00081
00083 ClientApplication* outlook;
00084
00085
00086 protected:
00087
00090 WindowsSyncSourceConfig& winConfig;
00091
00092
00094 itemKeyList allItems;
00095 itemKeyList newItems;
00096 itemKeyList modItems;
00097 itemKeyList delItems;
00098 itemKeyList allItemsPaths;
00099
00101 itemKeyIterator iAll;
00102 itemKeyIterator iNew;
00103 itemKeyIterator iMod;
00104 itemKeyIterator iDel;
00105 itemKeyIterator iAllPaths;
00106
00107
00109 unsigned int numErrors;
00110
00112 std::wstring defaultFolderPath;
00113
00114
00115
00116
00117
00118 ClientFolder* getStartFolder();
00119
00120
00121 void pushAllSubfolderItemsToList(ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00122 void pushAllItemsToList (ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00123
00124
00125 int manageModificationsFromLastSync();
00126
00127
00128 int addForcedItemsToModList(itemKeyList& forcedItems);
00129
00130
00131 std::wstring createOldItems();
00132 void parseOldItems(std::wstring& data, itemKeyList& listItems, itemKeyList& listFolders);
00133
00134
00135 int resetDataFile(const std::wstring& itemType);
00136 int closeDataFile(const std::wstring& itemType);
00137
00138
00139 bool folderPathAllowed(const std::wstring& p);
00140
00141
00142 void checkBirthdayAnniversary(ClientItem* cItem);
00143 int deleteAppointment(ClientItem* cItem, const std::wstring& propertyName);
00144
00145
00146 void manageSourceError(const int errorCode, const char* errorMsg);
00147
00148 void extractFolder(const std::wstring dataString, const std::wstring dataType, std::wstring& path);
00149
00150
00151 public:
00152
00161 WindowsSyncSource::WindowsSyncSource(const WCHAR* name, WindowsSyncSourceConfig* wsc);
00162
00163 ~WindowsSyncSource();
00164
00165
00167 const WindowsSyncSourceConfig& getConfig() const;
00168 WindowsSyncSourceConfig& getConfig();
00169
00170 int beginSync();
00171 int endSync();
00172
00173 void WindowsSyncSource::setItemStatus(const WCHAR* key, int status);
00174 void assign(WindowsSyncSource& s);
00175 ArrayElement* clone();
00176
00177
00178
00179 SyncItem* getFirstItem();
00180 SyncItem* getNextItem ();
00181
00182 SyncItem* getFirstNewItem();
00183 SyncItem* getNextNewItem ();
00184 SyncItem* getFirstUpdatedItem();
00185 SyncItem* getNextUpdatedItem ();
00186
00187 SyncItem* getFirstDeletedItem();
00188 SyncItem* getNextDeletedItem ();
00189
00190 SyncItem* getFirstItemKey();
00191 SyncItem* getNextItemKey();
00192
00193
00194
00195 int addItem (SyncItem& item);
00196 int updateItem(SyncItem& item);
00197 int deleteItem(SyncItem& item);
00198
00199 };
00200
00203 #endif