kitchensync

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,2004 Holger Hans Peter Freyther <freyther@kde.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., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, 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 #include <kdepimmacros.h>
00034 
00035 class KSimpleConfig;
00036 
00037 namespace KSync {
00038 
00039 class Merger;
00071 class KDE_EXPORT Syncee
00072 {
00073   public:
00077     Syncee( Merger* merger );
00078     virtual ~Syncee();
00079 
00085     // TODO: It might be better if the Syncee would transparently operate on the
00086     // underlying data without requiring the reset() call.
00087     virtual void reset() {}
00088 
00094     virtual SyncEntry *firstEntry() = 0;
00095 
00101     virtual SyncEntry *nextEntry() = 0;
00102 
00108     QString type() const;
00109     
00114     virtual SyncEntry *findEntry( const QString &id );
00115 
00123     virtual void addEntry( SyncEntry * ) = 0;
00124 
00129     virtual void removeEntry( SyncEntry * ) = 0;
00130 
00136     void replaceEntry( SyncEntry *oldEntry, SyncEntry *newEntry );
00137 
00143     void setIdentifier( const QString &identifier );
00144 
00150     QString identifier()const;
00151 
00159     virtual bool isValid();
00160 
00165     virtual int modificationState( SyncEntry * entry) const;
00166 
00167 
00175     //{
00176 
00181     virtual SyncEntry::PtrList added();
00186     virtual SyncEntry::PtrList modified();
00191     virtual SyncEntry::PtrList removed();
00192 
00193     //}
00198 // Syncees are owned by the Konnectors, we won't allow to steal them by cloning.
00199 //    virtual Syncee *clone() = 0;
00200 
00211     void insertId( const QString &type,
00212                    const QString &konnectorId,
00213                    const QString &kdeId );
00214 
00215 
00221     virtual QString generateNewId() const;
00226     Kontainer::ValueList ids( const QString &type ) const;
00227 
00231     QMap<QString,Kontainer::ValueList> ids() const;
00232 
00241     Merger* merger()const;
00242 
00247     void setMerger( Merger *merger = 0 );
00248    
00253     void setTitle( const QString &src );
00254 
00258     QString title() const;
00259 
00260 
00261    
00268     virtual bool trustIdsOnFirstSync() const;
00269 
00270     virtual bool writeBackup( const QString &filename ) = 0;
00271     
00272     virtual bool restoreBackup( const QString &filename ) = 0;
00273 
00274  protected:
00279     void setType(const QString& type);
00280 
00281     SyncEntry::PtrList find(int state);
00282 
00283   private:
00284     QMap<QString,Kontainer::ValueList> mMaps;      
00285     QString mIdentifier;
00286     Merger* mMerger;
00287     QString mTitle;   
00288     QString mType;
00289     class SynceePrivate;
00290     SynceePrivate *d;
00291 };
00292 
00293 }
00294 
00295 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys