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

00001 /*
00002  * Funambol is a mobile platform developed by Funambol, Inc. 
00003  * Copyright (C) 2003 - 2007 Funambol, Inc.
00004  * 
00005  * This program is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Affero General Public License version 3 as published by
00007  * the Free Software Foundation with the addition of the following permission 
00008  * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
00009  * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE 
00010  * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00015  * details.
00016  * 
00017  * You should have received a copy of the GNU Affero General Public License 
00018  * along with this program; if not, see http://www.gnu.org/licenses or write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00020  * MA 02110-1301 USA.
00021  * 
00022  * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite 
00023  * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
00024  * 
00025  * The interactive user interfaces in modified source and object code versions
00026  * of this program must display Appropriate Legal Notices, as required under
00027  * Section 5 of the GNU Affero General Public License version 3.
00028  * 
00029  * In accordance with Section 7(b) of the GNU Affero General Public License
00030  * version 3, these Appropriate Legal Notices must retain the display of the
00031  * "Powered by Funambol" logo. If the display of the logo is not reasonably 
00032  * feasible for technical reasons, the Appropriate Legal Notices must display
00033  * the words "Powered by Funambol".
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;         // This is the list of all items path in Outlook
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     // Internal utility methods:
00133     // -------------------------
00134     // Get the starting Outlook folder for this source.
00135     ClientFolder* getStartFolder();
00136 
00137     // Get all items inside 'folder' and push them (only keys) into 'listItems' list.
00138     void pushAllSubfolderItemsToList(ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00139     void pushAllItemsToList         (ClientFolder* folder, itemKeyList& listItems, itemKeyList& listItemsPaths);
00140 
00141     // Fill internal itemKeyLists of NEW/MOD/DEL item keys from last successfull sync.
00142     int manageModificationsFromLastSync();
00143 
00144     // Add forced modified items (passed list) to the modItems list.
00145     int addForcedItemsToModList(itemKeyList& forcedItems);
00146 
00147     // Create/parse XML string with old item's keys.
00148     std::wstring createOldItems();
00149     void parseOldItems(std::wstring& data, itemKeyList& listItems, itemKeyList& listFolders);
00150 
00151     // Reset and close the data file (where current items ID are stored).
00152     int resetDataFile(const std::wstring& itemType);
00153     int closeDataFile(const std::wstring& itemType);
00154 
00155     // Returns true if path passed is allowed to sync items inside it.
00156     bool folderPathAllowed(const std::wstring& p);
00157 
00158     // Verifies if birthday/anniversary were created by Outlook (only for contacts save).
00159     void checkBirthdayAnniversary(ClientItem* cItem);
00160     int  deleteAppointment(ClientItem* cItem, const std::wstring& propertyName);
00161 
00162     // Common actions to do when an error occurs inside SyncSource.
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     // --------- Methods to get syncItems from Client --------------
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     // --------- Methods to set syncItems into Client --------------
00212     int addItem   (SyncItem& item);
00213     int updateItem(SyncItem& item);
00214     int deleteItem(SyncItem& item);
00215 
00216 };
00217 
00220 #endif

Generated on Mon Feb 4 09:50:49 2008 for Funambol Outlook Plug-in Library by  doxygen 1.5.2