kitchensync Library API Documentation

syncee.h

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2002,2004 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020     Boston, MA 02111-1307, USA.
00021 */
00022 #ifndef KSYNC_SYNCEE_H
00023 #define KSYNC_SYNCEE_H
00024 
00025 #include <qbitarray.h>
00026 #include <qobject.h>
00027 #include <qmap.h>
00028 #include <qstring.h>
00029 #include <qptrlist.h>
00030 
00031 #include "kontainer.h"
00032 #include "syncentry.h"
00033 
00034 class KSimpleConfig;
00035 
00036 namespace KSync {
00037 
00068 class Syncee
00069 {
00070   public:
00071     enum SyncMode { MetaLess=0, MetaMode=2 };
00072 
00073     Syncee( uint supportSize = 0 );
00074     virtual ~Syncee();
00075 
00081     // TODO: It might be better if the Syncee would transparently operate on the
00082     // underlying data without requiring the reset() call.
00083     virtual void reset() {}
00084 
00090     virtual SyncEntry *firstEntry() = 0;
00091 
00097     virtual SyncEntry *nextEntry() = 0;
00098 
00102     // Do we really need this function?
00103     virtual QString type() const { return QString::null; }
00108     virtual SyncEntry *findEntry( const QString &id );
00109 
00114     virtual void addEntry( SyncEntry * ) = 0;
00119     virtual void removeEntry( SyncEntry * ) = 0;
00120 
00125     void replaceEntry( SyncEntry *oldEntry, SyncEntry *newEntry );
00126 
00132     void setIdentifier( const QString &identifier );
00133 
00139     QString identifier() { return mIdentifier; }
00140 
00148     virtual bool isValid();
00149 
00154     QString statusLogName();
00155 
00161     bool loadLog();
00167     bool saveLog();
00168 
00174     bool hasChanged(SyncEntry *);
00175 
00180     virtual int modificationState( SyncEntry * entry) const;
00181 
00186     virtual int syncMode() const;
00187 
00191     virtual void setSyncMode( int mode = MetaLess );
00192 
00196     virtual void setFirstSync( bool firstSync = true );
00197 
00201     virtual bool firstSync() const;
00202 
00211     // Do we really need these functions here?
00215     virtual SyncEntry::PtrList added() { return SyncEntry::PtrList(); }
00219     virtual SyncEntry::PtrList modified() { return SyncEntry::PtrList(); };
00223     virtual SyncEntry::PtrList removed() { return SyncEntry::PtrList(); }
00224 
00229 // Syncees are owned by the Konnectors, we won't allow to steal them by cloning.
00230 //    virtual Syncee *clone() = 0;
00231 
00242     void insertId( const QString &type,
00243                    const QString &konnectorId,
00244                    const QString &kdeId );
00245 
00246 
00252     virtual QString newId() const;
00257     Kontainer::ValueList ids( const QString &type ) const;
00258 
00262     QMap<QString,Kontainer::ValueList> ids() const;
00263 
00267     virtual void setSupports( const QBitArray& );
00268 
00272     virtual QBitArray bitArray() const;
00273 
00274     // FIXME: Rename setSource to setLabel or setTitle
00279     void setSource( const QString &src );
00280 
00284     QString source() const;
00285 
00286 
00290     inline bool isSupported( uint Attribute ) const;
00291 
00292 
00293     // a bit hacky
00300     virtual bool trustIdsOnFirstSync() const;
00301 
00302     virtual bool writeBackup( const QString &filename ) = 0;
00303     
00304     virtual bool restoreBackup( const QString &filename ) = 0;
00305 
00306   private:
00307     QMap<QString,Kontainer::ValueList> mMaps;
00308     int mSyncMode;
00309     bool mFirstSync : 1;
00310     QString mIdentifier;
00311     KSimpleConfig *mStatusLog;
00312     QBitArray mSupport;
00313     QString mName;
00314     class SynceePrivate;
00315     SynceePrivate *d;
00316 };
00317 
00318 }
00319 
00320 #endif
KDE Logo
This file is part of the documentation for kitchensync Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jan 31 15:53:46 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003