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/util/ArrayElement.h"
00044 #include "filter/SourceFilter.h"
00045 #include "spds/constants.h"
00046 #include "spds/SyncItem.h"
00047 #include "spds/SyncStatus.h"
00048 #include "spds/AbstractSyncSourceConfig.h"
00049 #include "spds/SyncSourceReport.h"
00050 #include "base/globalsdef.h"
00051 
00052 BEGIN_NAMESPACE
00053 
00059 class SyncSource {
00060 
00061 private:
00062     SyncMode      syncMode;
00063     unsigned long lastSync;
00064     unsigned long nextSync;
00065     WCHAR*      name;
00066 
00067     char next[DIM_ANCHOR];
00068     char last[DIM_ANCHOR];
00069 
00070     SourceFilter* filter;
00071 
00072 protected:
00073     AbstractSyncSourceConfig* config;
00074     SyncSourceReport* report;
00075 
00079     void assign(SyncSource& s);
00080 
00081 public:
00082 
00099     SyncSource(const WCHAR* name, AbstractSyncSourceConfig* sc);
00100 
00101     // Destructor
00102     virtual ~SyncSource();
00103 
00111     const WCHAR *getName();
00112 
00113     /**********************************************************
00114      * Most of the configurable properties are read
00115      * by the client library from the config (in
00116      * SyncClient::setDMConfig()) and then copied into the
00117      * sync source.
00118      *
00119      * These properties are stored in a local copy which will not be
00120      * written back into the permanent config, with a few exceptions:
00121      * properties related to mananging sync sessions like lastAnchor
00122      * are written back into the config by the library afer a
00123      * successful synchronization.
00124      *
00125      * A client developer is not required to modify these calls,
00126      * but he can use and/or update the properties before the
00127      * synchronization starts.
00128      *********************************************************/
00129 
00134     void setConfig(AbstractSyncSourceConfig* sc);
00135 
00137     const AbstractSyncSourceConfig& getConfig() const;
00139     AbstractSyncSourceConfig& getConfig();
00140 
00141     
00142 
00146     SyncSourceReport* getReport();
00147 
00154     void setReport(SyncSourceReport* sr);
00155 
00163     SyncMode getPreferredSyncMode();
00164     void setPreferredSyncMode(SyncMode syncMode);
00165 
00173     SyncMode getSyncMode();
00174     void setSyncMode(SyncMode syncMode);
00175 
00180     unsigned long getLastSync();
00181     void setLastSync(unsigned long timestamp);
00182 
00187     unsigned long getNextSync();
00188     void setNextSync(unsigned long timestamp);
00189 
00193     void setLastAnchor(const char*  last);
00194     const char*  getLastAnchor();
00195 
00199     const char*  getNextAnchor();
00200     void setNextAnchor(const char*  next);
00201 
00205     SourceFilter* getFilter();
00206 
00213     void setFilter(SourceFilter* f);
00214 
00215     /******************************************************
00216      * The following methods are virtual because a
00217      * derived SyncSource is expected to override or
00218      * implement them. Only the pure virtual methods
00219      * really have to be implemented, the others have
00220      * reasonable defaults.
00221      *****************************************************/
00222 
00238     virtual int beginSync();
00239 
00253     virtual int endSync();
00254 
00264     virtual void setItemStatus(const WCHAR* /* key */, int /* status */) {}
00265 
00276     virtual void setItemStatus(const WCHAR* key, int status,
00277                                const char* /* command */) {
00278         setItemStatus(key, status);
00279     }
00280     
00286     virtual void serverStatusPackageEnded();    
00287     
00294     virtual void clientStatusPackageEnded(); 
00295     
00304     virtual int removeAllItems() = 0;
00305 
00311     virtual SyncItem* getFirstItem() = 0;
00312 
00318     virtual SyncItem* getNextItem() = 0;
00319 
00324     virtual SyncItem* getFirstNewItem() = 0;
00325 
00330     virtual SyncItem* getNextNewItem() = 0;
00331 
00336     virtual SyncItem* getFirstUpdatedItem() = 0;
00337 
00342     virtual SyncItem* getNextUpdatedItem() = 0;
00343 
00348     virtual SyncItem* getFirstDeletedItem() = 0;
00349 
00354     virtual SyncItem* getNextDeletedItem() = 0;
00355 
00366     virtual int addItem(SyncItem& item) = 0;
00367 
00375     virtual int updateItem(SyncItem& item) = 0;
00376 
00384     virtual int deleteItem(SyncItem& item) = 0;
00385  
00386                
00387     
00388 };
00389 
00390 
00391 END_NAMESPACE
00392 
00395 #endif

Generated on Wed Jan 14 17:15:36 2009 for Funambol C++ Client Library by  doxygen 1.5.2