kitchensync

syncentry.h

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2002 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., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 #ifndef KSYNC_SYNCENTRY_H
00023 #define KSYNC_SYNCENTRY_H
00024 
00025 #include <qstring.h>
00026 #include <qptrlist.h>
00027 #include <kdepimmacros.h>
00028 
00029 namespace KPIM {
00030 class DiffAlgo;
00031 }
00032 
00033 namespace KSync {
00034 class Merger;
00035 class Syncee;
00036 
00049 class KDE_EXPORT SyncEntry
00050 {
00051   public:
00052     typedef QPtrList<SyncEntry> PtrList;
00053 
00054     enum Equalness { Different = -1, Equal = 0, EqualButModifiedThis = 1,
00055                      EqualButModifiedOther = 2, EqualButModifiedBoth = 3 };
00056 
00057     enum Status { Undefined = -1, Added = 0, Modified=1, Removed = 2 };
00058 
00063     SyncEntry( Syncee *parent );
00064     SyncEntry( const SyncEntry & );
00065     virtual ~SyncEntry();
00066 
00070     QString type() const;
00071 
00076     virtual QString name() = 0;
00077 
00084     virtual QString id() = 0;
00085 
00086 
00091     virtual void setId( const QString& id );
00092 
00104     virtual QString timestamp() = 0;
00105 
00111     virtual bool equals( SyncEntry * ) = 0;
00112 
00121     virtual int match( SyncEntry *entry );
00122 
00131     virtual int compareTo( SyncEntry *entry );
00132 
00137     virtual int state() const;
00138 
00139     // TODO ### discuss for during sync added or such
00140     void setSyncState(int);
00141     int syncState()const;
00142 
00146     virtual bool wasAdded() const;
00147 
00152     virtual bool wasModified() const;
00153 
00157     virtual bool wasRemoved() const;
00158 
00162     virtual void setState( int state = Undefined );
00163 
00164 
00172     virtual SyncEntry *clone() = 0;
00173 
00177     void setSyncee( Syncee * );
00178 
00182     Syncee *syncee()const;
00183 
00187     void setDontSync( bool );
00188 
00189     bool dontSync() const;
00190 
00191     bool mergeWith(SyncEntry *other);
00192 
00197     virtual KPIM::DiffAlgo* diffAlgo( SyncEntry*, SyncEntry* );
00198 
00199  protected:
00200     void setType(const QString&);
00201 
00202  protected:
00203     Merger* merger()const;
00204 
00205   private:
00206     int mState;
00207     int mSyncState;
00208     Syncee *mSyncee;
00209     bool mDontSync : 1;
00210     QString mType;
00211 
00212     class SyncEntryPrivate;
00213     SyncEntryPrivate *d;
00214 };
00215 
00216 }
00217 
00218 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys