src/include/common/spds/SyncSource.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol
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 as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 #ifndef INCL_SYNC_SOURCE
00020 #define INCL_SYNC_SOURCE
00021 
00025 #include "base/fscapi.h"
00026 #include "base/ErrorHandler.h"
00027 #include "base/util/ArrayElement.h"
00028 #include "filter/SourceFilter.h"
00029 #include "spds/constants.h"
00030 #include "spds/SyncItem.h"
00031 #include "spds/SyncStatus.h"
00032 #include "spds/SyncSourceConfig.h"
00033 #include "spds/SyncSourceReport.h"
00034 
00040 class SyncSource : public ArrayElement {
00041 
00042 private:
00043     SyncMode      syncMode;
00044     unsigned long lastSync;
00045     unsigned long nextSync;
00046     WCHAR*      name;
00047 
00048     char next[DIM_ANCHOR];
00049     char last[DIM_ANCHOR];
00050 
00051     //ErrorHandler* errorHandler;
00052 
00053     SourceFilter* filter;
00054 
00055 protected:
00056     SyncSourceConfig& config;
00057     SyncSourceReport* report;
00058 
00062     void assign(SyncSource& s);
00063     
00064 public:
00065 
00079     SyncSource(const WCHAR* name, SyncSourceConfig* sc) EXTRA_SECTION_01;
00080 
00081     // Destructor
00082     virtual ~SyncSource() EXTRA_SECTION_01;
00083 
00091     const WCHAR *getName() EXTRA_SECTION_01;
00092 
00093     /**********************************************************
00094      * Most of the configurable properties are read
00095      * by the client library from the config (in
00096      * SyncClient::setDMConfig()) and then copied into the
00097      * sync source.
00098      *
00099      * These properties are stored in a local copy which will not be
00100      * written back into the permanent config, with a few exceptions:
00101      * properties related to mananging sync sessions like lastAnchor
00102      * are written back into the config by the library afer a
00103      * successful synchronization.
00104      *
00105      * A client developer is not required to modify these calls,
00106      * but he can use and/or update the properties before the
00107      * synchronization starts.
00108      *********************************************************/
00109 
00111     const SyncSourceConfig& getConfig() const EXTRA_SECTION_01 {
00112         return config;
00113     }
00115     SyncSourceConfig& getConfig() EXTRA_SECTION_01 {
00116         return config;
00117     }
00118 
00119 
00123     SyncSourceReport* getReport() EXTRA_SECTION_01;
00124 
00131     void setReport(SyncSourceReport* sr) EXTRA_SECTION_01;
00132 
00140     SyncMode getPreferredSyncMode() EXTRA_SECTION_01;
00141     void setPreferredSyncMode(SyncMode syncMode) EXTRA_SECTION_01;
00142 
00150     SyncMode getSyncMode() EXTRA_SECTION_01;
00151     void setSyncMode(SyncMode syncMode) EXTRA_SECTION_01;
00152 
00157     unsigned long getLastSync() EXTRA_SECTION_01;
00158     void setLastSync(unsigned long timestamp) EXTRA_SECTION_01;
00159 
00164     unsigned long getNextSync() EXTRA_SECTION_01;
00165     void setNextSync(unsigned long timestamp) EXTRA_SECTION_01;
00166 
00170     void setLastAnchor(const char*  last) EXTRA_SECTION_01;
00171     const char*  getLastAnchor() EXTRA_SECTION_01;
00172 
00176     const char*  getNextAnchor() EXTRA_SECTION_01;
00177     void setNextAnchor(const char*  next) EXTRA_SECTION_01;
00178     
00182     SourceFilter* getFilter();
00183 
00190     void setFilter(SourceFilter* f);
00191 
00192     /******************************************************
00193      * The following methods are virtual because a
00194      * derived SyncSource is expected to override or
00195      * implement them. Only the pure virtual methods
00196      * really have to be implemented, the others have
00197      * reasonable defaults.
00198      *****************************************************/
00199     
00215     virtual int beginSync() EXTRA_SECTION_01;
00216     
00230     virtual int endSync() EXTRA_SECTION_01;
00231 
00239     virtual void setItemStatus(const WCHAR* key, int status) = 0 EXTRA_SECTION_01;
00240 
00246     virtual SyncItem* getFirstItemKey() = 0 EXTRA_SECTION_01;
00247 
00253     virtual SyncItem* getNextItemKey() = 0 EXTRA_SECTION_01;
00254 
00260     virtual SyncItem* getFirstItem() = 0 EXTRA_SECTION_01;
00261 
00267     virtual SyncItem* getNextItem() = 0 EXTRA_SECTION_01;
00268 
00273     virtual SyncItem* getFirstNewItem() = 0 EXTRA_SECTION_01;
00274 
00279     virtual SyncItem* getNextNewItem() = 0 EXTRA_SECTION_01;
00280 
00285     virtual SyncItem* getFirstUpdatedItem() = 0 EXTRA_SECTION_01;
00286 
00291     virtual SyncItem* getNextUpdatedItem() = 0 EXTRA_SECTION_01;
00292 
00297     virtual SyncItem* getFirstDeletedItem() = 0 EXTRA_SECTION_01;
00298 
00303     virtual SyncItem* getNextDeletedItem() = 0 EXTRA_SECTION_01;
00304 
00315     virtual int addItem(SyncItem& item) = 0 EXTRA_SECTION_01;
00316 
00324     virtual int updateItem(SyncItem& item) = 0 EXTRA_SECTION_01;
00325 
00333     virtual int deleteItem(SyncItem& item) = 0 EXTRA_SECTION_01;
00334 
00338     virtual ArrayElement* clone() EXTRA_SECTION_01 = 0;
00339 };
00340 
00343 #endif

Generated on Fri Apr 27 12:29:18 2007 for Funambol C++ Client Library by  doxygen 1.5.2