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/AbstractSyncSourceConfig.h"
00050 #include "spds/SyncSourceReport.h"
00051 #include "base/globalsdef.h"
00052 
00053 BEGIN_NAMESPACE
00054 
00060 class SyncSource {
00061 
00062 private:
00063     SyncMode      syncMode;
00064     unsigned long lastSync;
00065     unsigned long nextSync;
00066     WCHAR*      name;
00067 
00068     char next[DIM_ANCHOR];
00069     char last[DIM_ANCHOR];
00070 
00071     SourceFilter* filter;
00072 
00073 protected:
00074     AbstractSyncSourceConfig* config;
00075     SyncSourceReport* report;
00076 
00080     void assign(SyncSource& s);
00081 
00082 public:
00083 
00100     SyncSource(const WCHAR* name, AbstractSyncSourceConfig* sc);
00101 
00102     // Destructor
00103     virtual ~SyncSource();
00104 
00112     const WCHAR *getName();
00113 
00114     /**********************************************************
00115      * Most of the configurable properties are read
00116      * by the client library from the config (in
00117      * SyncClient::setDMConfig()) and then copied into the
00118      * sync source.
00119      *
00120      * These properties are stored in a local copy which will not be
00121      * written back into the permanent config, with a few exceptions:
00122      * properties related to mananging sync sessions like lastAnchor
00123      * are written back into the config by the library afer a
00124      * successful synchronization.
00125      *
00126      * A client developer is not required to modify these calls,
00127      * but he can use and/or update the properties before the
00128      * synchronization starts.
00129      *********************************************************/
00130 
00135     void setConfig(AbstractSyncSourceConfig* sc);
00136 
00138     const AbstractSyncSourceConfig& getConfig() const;
00140     AbstractSyncSourceConfig& getConfig();
00141 
00142     
00143 
00147     SyncSourceReport* getReport();
00148 
00155     void setReport(SyncSourceReport* sr);
00156 
00164     SyncMode getPreferredSyncMode();
00165     void setPreferredSyncMode(SyncMode syncMode);
00166 
00174     SyncMode getSyncMode();
00175     void setSyncMode(SyncMode syncMode);
00176 
00181     unsigned long getLastSync();
00182     void setLastSync(unsigned long timestamp);
00183 
00188     unsigned long getNextSync();
00189     void setNextSync(unsigned long timestamp);
00190 
00194     void setLastAnchor(const char*  last);
00195     const char*  getLastAnchor();
00196 
00200     const char*  getNextAnchor();
00201     void setNextAnchor(const char*  next);
00202 
00206     SourceFilter* getFilter();
00207 
00214     void setFilter(SourceFilter* f);
00215 
00216     /******************************************************
00217      * The following methods are virtual because a
00218      * derived SyncSource is expected to override or
00219      * implement them. Only the pure virtual methods
00220      * really have to be implemented, the others have
00221      * reasonable defaults.
00222      *****************************************************/
00223 
00239     virtual int beginSync();
00240 
00254     virtual int endSync();
00255 
00265     virtual void setItemStatus(const WCHAR* /* key */, int /* status */) {}
00266 
00277     virtual void setItemStatus(const WCHAR* key, int status,
00278                                const char* /* command */) {
00279         setItemStatus(key, status);
00280     }
00281     
00287     virtual void serverStatusPackageEnded();    
00288     
00295     virtual void clientStatusPackageEnded(); 
00296     
00305     virtual int removeAllItems() = 0;
00306 
00312     virtual SyncItem* getFirstItemKey() = 0;
00313 
00319     virtual SyncItem* getNextItemKey() = 0;
00320 
00326     virtual SyncItem* getFirstItem() = 0;
00327 
00333     virtual SyncItem* getNextItem() = 0;
00334 
00339     virtual SyncItem* getFirstNewItem() = 0;
00340 
00345     virtual SyncItem* getNextNewItem() = 0;
00346 
00351     virtual SyncItem* getFirstUpdatedItem() = 0;
00352 
00357     virtual SyncItem* getNextUpdatedItem() = 0;
00358 
00363     virtual SyncItem* getFirstDeletedItem() = 0;
00364 
00369     virtual SyncItem* getNextDeletedItem() = 0;
00370 
00381     virtual int addItem(SyncItem& item) = 0;
00382 
00390     virtual int updateItem(SyncItem& item) = 0;
00391 
00399     virtual int deleteItem(SyncItem& item) = 0;
00400  
00401                
00402     
00403 };
00404 
00405 
00406 END_NAMESPACE
00407 
00410 #endif

Generated on Tue Jun 10 17:20:21 2008 for Funambol C++ Client Library by  doxygen 1.5.2