src/include/common/spds/SyncSource.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_SYNC_SOURCE
00037 #define INCL_SYNC_SOURCE
00038 
00042 #include "base/fscapi.h"
00043 #include "base/ErrorHandler.h"
00044 #include "base/util/ArrayElement.h"
00045 #include "filter/SourceFilter.h"
00046 #include "spds/constants.h"
00047 #include "spds/SyncItem.h"
00048 #include "spds/SyncStatus.h"
00049 #include "spds/SyncSourceConfig.h"
00050 #include "spds/SyncSourceReport.h"
00051 
00057 class SyncSource : public ArrayElement {
00058 
00059 private:
00060     SyncMode      syncMode;
00061     unsigned long lastSync;
00062     unsigned long nextSync;
00063     WCHAR*      name;
00064 
00065     char next[DIM_ANCHOR];
00066     char last[DIM_ANCHOR];
00067 
00068     //ErrorHandler* errorHandler;
00069 
00070     SourceFilter* filter;
00071 
00072 protected:
00073     SyncSourceConfig& config;
00074     SyncSourceReport* report;
00075 
00079     void assign(SyncSource& s);
00080 
00081 public:
00082 
00096     SyncSource(const WCHAR* name, SyncSourceConfig* sc);
00097 
00098     // Destructor
00099     virtual ~SyncSource();
00100 
00108     const WCHAR *getName();
00109 
00110     /**********************************************************
00111      * Most of the configurable properties are read
00112      * by the client library from the config (in
00113      * SyncClient::setDMConfig()) and then copied into the
00114      * sync source.
00115      *
00116      * These properties are stored in a local copy which will not be
00117      * written back into the permanent config, with a few exceptions:
00118      * properties related to mananging sync sessions like lastAnchor
00119      * are written back into the config by the library afer a
00120      * successful synchronization.
00121      *
00122      * A client developer is not required to modify these calls,
00123      * but he can use and/or update the properties before the
00124      * synchronization starts.
00125      *********************************************************/
00126 
00128     const SyncSourceConfig& getConfig() const {
00129         return config;
00130     }
00132     SyncSourceConfig& getConfig() {
00133         return config;
00134     }
00135 
00136 
00140     SyncSourceReport* getReport();
00141 
00148     void setReport(SyncSourceReport* sr);
00149 
00157     SyncMode getPreferredSyncMode();
00158     void setPreferredSyncMode(SyncMode syncMode);
00159 
00167     SyncMode getSyncMode();
00168     void setSyncMode(SyncMode syncMode);
00169 
00174     unsigned long getLastSync();
00175     void setLastSync(unsigned long timestamp);
00176 
00181     unsigned long getNextSync();
00182     void setNextSync(unsigned long timestamp);
00183 
00187     void setLastAnchor(const char*  last);
00188     const char*  getLastAnchor();
00189 
00193     const char*  getNextAnchor();
00194     void setNextAnchor(const char*  next);
00195 
00199     SourceFilter* getFilter();
00200 
00207     void setFilter(SourceFilter* f);
00208 
00209     /******************************************************
00210      * The following methods are virtual because a
00211      * derived SyncSource is expected to override or
00212      * implement them. Only the pure virtual methods
00213      * really have to be implemented, the others have
00214      * reasonable defaults.
00215      *****************************************************/
00216 
00232     virtual int beginSync();
00233 
00247     virtual int endSync();
00248 
00256     virtual void setItemStatus(const WCHAR* key, int status) = 0;
00257 
00263     virtual SyncItem* getFirstItemKey() = 0;
00264 
00270     virtual SyncItem* getNextItemKey() = 0;
00271 
00277     virtual SyncItem* getFirstItem() = 0;
00278 
00284     virtual SyncItem* getNextItem() = 0;
00285 
00290     virtual SyncItem* getFirstNewItem() = 0;
00291 
00296     virtual SyncItem* getNextNewItem() = 0;
00297 
00302     virtual SyncItem* getFirstUpdatedItem() = 0;
00303 
00308     virtual SyncItem* getNextUpdatedItem() = 0;
00309 
00314     virtual SyncItem* getFirstDeletedItem() = 0;
00315 
00320     virtual SyncItem* getNextDeletedItem() = 0;
00321 
00332     virtual int addItem(SyncItem& item) = 0;
00333 
00341     virtual int updateItem(SyncItem& item) = 0;
00342 
00350     virtual int deleteItem(SyncItem& item) = 0;
00351 
00355     virtual ArrayElement* clone() = 0;
00356 };
00357 
00360 #endif

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