ksync

ksyncer.h

00001 /*
00002     This file is part of ksync.
00003 
00004     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 #ifndef KSYNCER_H
00022 #define KSYNCER_H
00023 
00024 #include <qstring.h>
00025 #include <qptrlist.h>
00026 #include <kdepimmacros.h>
00027 
00028 class KSimpleConfig;
00029 
00030 class KSyncUi;
00031 class KSyncee;
00032 
00044 class KDE_EXPORT KSyncEntry
00045 {
00046   public:
00047     KSyncEntry();
00048     virtual ~KSyncEntry();
00049   
00054     virtual QString name() = 0;
00061     virtual QString id() = 0;
00073     virtual QString timestamp() = 0;
00079     virtual bool equals(KSyncEntry *) = 0;
00080 
00084     void setSyncee(KSyncee *);
00088     KSyncee *syncee();
00089     
00090   private:
00091     KSyncee *mSyncee;
00092 };
00093 
00109 class KDE_EXPORT KSyncee
00110 {
00111   public:
00112     KSyncee();
00113     virtual ~KSyncee();
00114     
00120     virtual KSyncEntry *firstEntry() = 0;
00126     virtual KSyncEntry *nextEntry() = 0;
00127     
00131     virtual KSyncEntry *findEntry(const QString &id);
00132     
00137     virtual void addEntry(KSyncEntry *) = 0;
00142     virtual void removeEntry(KSyncEntry *) = 0;
00143 
00148     void replaceEntry(KSyncEntry *oldEntry,KSyncEntry *newEntry);
00149 
00153     void setFilename(const QString &);
00157     QString filename();
00158     
00163     QString statusLogName();
00164     
00170     bool load();
00176     bool save();
00177 
00185     virtual bool read() = 0;
00193     virtual bool write() = 0;
00194 
00198     void writeLog();
00199 
00205     bool hasChanged(KSyncEntry *);
00206     
00207   private:
00208     QString mFilename;
00209     KSimpleConfig *mStatusLog;
00210 };
00211 
00232 class KDE_EXPORT KSyncer
00233 {
00234   public:
00241     KSyncer(KSyncUi *ui=0);
00242     virtual ~KSyncer();
00243     
00247     void addSyncee(KSyncee *);
00248     
00256     void sync();
00265     void syncAllToTarget(KSyncee *target,bool writeback=false);
00274     void syncToTarget(KSyncee *syncee, KSyncee *target, bool override=false);
00275     
00276   private:
00277     QPtrList<KSyncee> mSyncees;
00278     KSyncUi *mUi;
00279 };
00280 
00281 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys