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., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 #ifndef KSYNCER_H 00022 #define KSYNCER_H 00023 00024 #include <qstring.h> 00025 #include <qptrlist.h> 00026 00027 class KSimpleConfig; 00028 00029 class KSyncUi; 00030 class KSyncee; 00031 00043 class KSyncEntry 00044 { 00045 public: 00046 KSyncEntry(); 00047 virtual ~KSyncEntry(); 00048 00053 virtual QString name() = 0; 00060 virtual QString id() = 0; 00072 virtual QString timestamp() = 0; 00078 virtual bool equals(KSyncEntry *) = 0; 00079 00083 void setSyncee(KSyncee *); 00087 KSyncee *syncee(); 00088 00089 private: 00090 KSyncee *mSyncee; 00091 }; 00092 00108 class KSyncee 00109 { 00110 public: 00111 KSyncee(); 00112 virtual ~KSyncee(); 00113 00119 virtual KSyncEntry *firstEntry() = 0; 00125 virtual KSyncEntry *nextEntry() = 0; 00126 00130 virtual KSyncEntry *findEntry(const QString &id); 00131 00136 virtual void addEntry(KSyncEntry *) = 0; 00141 virtual void removeEntry(KSyncEntry *) = 0; 00142 00147 void replaceEntry(KSyncEntry *oldEntry,KSyncEntry *newEntry); 00148 00152 void setFilename(const QString &); 00156 QString filename(); 00157 00162 QString statusLogName(); 00163 00169 bool load(); 00175 bool save(); 00176 00184 virtual bool read() = 0; 00192 virtual bool write() = 0; 00193 00197 void writeLog(); 00198 00204 bool hasChanged(KSyncEntry *); 00205 00206 private: 00207 QString mFilename; 00208 KSimpleConfig *mStatusLog; 00209 }; 00210 00231 class KSyncer 00232 { 00233 public: 00240 KSyncer(KSyncUi *ui=0); 00241 virtual ~KSyncer(); 00242 00246 void addSyncee(KSyncee *); 00247 00255 void sync(); 00264 void syncAllToTarget(KSyncee *target,bool writeback=false); 00273 void syncToTarget(KSyncee *syncee, KSyncee *target, bool override=false); 00274 00275 private: 00276 QPtrList<KSyncee> mSyncees; 00277 KSyncUi *mUi; 00278 }; 00279 00280 #endif