D:/develop/v65/clients/outlook/install/output/export/funambol/clients/outlook/mainclientDll/src/include/WindowsSyncSource.h

00001  /*
00002  * Copyright (C) 2006-2007 Funambol, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 2 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00016  * 02111-1307  USA
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;         // This is the list of all items path in Outlook
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     // Internal utility methods:
00116     // -------------------------
00117     // Get the starting Outlook folder for this source.
00118     ClientFolder* getStartFolder();
00119 
00120     // Get all items inside 'folder' and push them (only keys) into 'listItems' list.
00121     void pushAllSubfolderItemsToList(ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00122     void pushAllItemsToList         (ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00123 
00124     // Fill internal itemKeyLists of NEW/MOD/DEL item keys from last successfull sync.
00125     int manageModificationsFromLastSync();
00126 
00127     // Add forced modified items (passed list) to the modItems list.
00128     int addForcedItemsToModList(itemKeyList& forcedItems);
00129 
00130     // Create/parse XML string with old item's keys.
00131     std::wstring createOldItems();
00132     void parseOldItems(std::wstring& data, itemKeyList& listItems, itemKeyList& listFolders);
00133 
00134     // Reset and close the data file (where current items ID are stored).
00135     int resetDataFile(const std::wstring& itemType);
00136     int closeDataFile(const std::wstring& itemType);
00137 
00138     // Returns true if path passed is allowed to sync items inside it.
00139     bool folderPathAllowed(const std::wstring& p);
00140 
00141     // Verifies if birthday/anniversary were created by Outlook (only for contacts save).
00142     void checkBirthdayAnniversary(ClientItem* cItem);
00143     int  deleteAppointment(ClientItem* cItem, const std::wstring& propertyName);
00144 
00145     // Common actions to do when an error occurs inside SyncSource.
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     // --------- Methods to get syncItems from Client --------------
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     // --------- Methods to set syncItems into Client --------------
00195     int addItem   (SyncItem& item);
00196     int updateItem(SyncItem& item);
00197     int deleteItem(SyncItem& item);
00198 
00199 };
00200 
00203 #endif

Generated on Fri Nov 9 12:21:26 2007 for Funambol Outlook Plug-in Library by  doxygen 1.5.2