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
00081 #define MAX_SOURCE_ERRORS 500
00082 #define TIMESTAMP_DELAY 2
00083 #define DONT_SEND_FILTERED_DEL_ITEMS 1
00097 class WindowsSyncSource : public SyncSource {
00098
00099 private:
00100
00102 ClientApplication* outlook;
00103
00104 int filterDirection;
00105
00106
00107 protected:
00108
00111 WindowsSyncSourceConfig& winConfig;
00112
00113
00115 itemKeyList allItems;
00116 itemKeyList newItems;
00117 itemKeyList modItems;
00118 itemKeyList delItems;
00119 itemKeyList allItemsPaths;
00120 itemKeyList filteredItems;
00122
00123 itemKeyIterator iAll;
00124 itemKeyIterator iNew;
00125 itemKeyIterator iMod;
00126 itemKeyIterator iDel;
00127 itemKeyIterator iAllPaths;
00128 itemKeyIterator iFiltered;
00129
00130
00132 unsigned int numErrors;
00133
00135 std::wstring defaultFolderPath;
00136
00137
00138
00139
00140
00141 ClientFolder* getStartFolder();
00142
00143
00144 void pushAllSubfolderItemsToList(ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00145 void pushAllItemsToList (ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00146
00147
00148 int manageModificationsFromLastSync();
00149
00150
00151 int addForcedItemsToModList(itemKeyList& forcedItems);
00152
00153
00154 std::wstring createOldItems();
00155 void parseOldItems(std::wstring& data, itemKeyList& listItems, itemKeyList& listFolders);
00156
00157
00158 int resetDataFile(const std::wstring& itemType);
00159 int closeDataFile(const std::wstring& itemType);
00160
00161
00162 bool folderPathAllowed(const std::wstring& p);
00163
00164
00165 void checkBirthdayAnniversary(ClientItem* cItem);
00166 int deleteAppointment(ClientItem* cItem, const std::wstring& propertyName);
00167
00168
00169 void manageSourceError(const int errorCode, const char* errorMsg);
00170
00172 void manageSourceErrorF(const int errorCode, const char *msgFormat, ...);
00173
00174 void extractFolder(const std::wstring dataString, const std::wstring dataType, std::wstring& path);
00175
00188 bool filterClientItem(ClientItem* item, DateFilter::FilterDirection direction, const char* command = NULL);
00189
00194 void updateFilters();
00195
00196
00197 public:
00198
00207 WindowsSyncSource::WindowsSyncSource(const WCHAR* name, WindowsSyncSourceConfig* wsc);
00208
00209 virtual ~WindowsSyncSource();
00210
00211
00213 const WindowsSyncSourceConfig& getConfig() const;
00214 WindowsSyncSourceConfig& getConfig();
00215
00216 int beginSync();
00217 int endSync();
00218
00219 void WindowsSyncSource::setItemStatus(const WCHAR* key, int status);
00220 void assign(WindowsSyncSource& s);
00221
00222
00228 int removeAllItems();
00229
00230
00231 SyncItem* getFirstItem();
00232 SyncItem* getNextItem ();
00233
00234 SyncItem* getFirstNewItem();
00235 SyncItem* getNextNewItem ();
00236 SyncItem* getFirstUpdatedItem();
00237 SyncItem* getNextUpdatedItem ();
00238
00239 SyncItem* getFirstDeletedItem();
00240 SyncItem* getNextDeletedItem ();
00241
00242
00243
00244 int addItem (SyncItem& item);
00245 int updateItem(SyncItem& item);
00246 int deleteItem(SyncItem& item);
00247
00248
00250 DateFilter& getDateFilter() { return getConfig().getDateFilter(); }
00251
00252 };
00253
00256 #endif