kpilot/lib
syncAction.h00001 #ifndef _KPILOT_SYNCACTION_H
00002 #define _KPILOT_SYNCACTION_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <time.h>
00032
00033 #include <pi-dlp.h>
00034
00035
00036 #include <qobject.h>
00037 #include <qstring.h>
00038 #include <qstringlist.h>
00039
00040 #include "kpilotlink.h"
00041
00042 class QTimer;
00043 class QSocketNotifier;
00044 class KPilotUser;
00045 class SyncAction;
00046
00047 class KDE_EXPORT SyncAction : public QObject
00048 {
00049 Q_OBJECT
00050
00051 public:
00052 SyncAction(KPilotLink *p,
00053 const char *name=0L);
00054 SyncAction(KPilotLink *p,
00055 QWidget *visibleparent,
00056 const char *name=0L);
00057 ~SyncAction();
00058
00059 typedef enum { Error=-1 } Status;
00060
00065 int status() const
00066 {
00067 return fActionStatus;
00068 }
00070 virtual QString statusString() const;
00071
00072 protected:
00086 virtual bool exec() = 0;
00087
00088 public slots:
00093 void execConduit();
00094
00095 signals:
00096 void syncDone(SyncAction *);
00097 void logMessage(const QString &);
00098 void logError(const QString &);
00099 void logProgress(const QString &,int);
00100
00101 protected slots:
00106 void delayedDoneSlot();
00107
00108 protected:
00118 bool delayDone();
00119
00120 public:
00128 void addSyncLogEntry(const QString &e,bool log=true)
00129 {
00130 if (deviceLink())
00131 {
00132 deviceLink()->addSyncLogEntry(e,log);
00133 }
00134 }
00138 void addLogMessage( const QString &msg )
00139 {
00140 emit logMessage( msg );
00141 }
00143 void addLogError( const QString &msg )
00144 {
00145 emit logError( msg );
00146 }
00148 void addLogProgress( const QString &msg, int prog )
00149 {
00150 emit logProgress( msg, prog );
00151 }
00152 protected:
00154 KPilotLink *fHandle;
00155 int fActionStatus;
00156
00158 inline KPilotLink *deviceLink() const
00159 {
00160 return fHandle;
00161 }
00162
00167 int pilotSocket() const
00168 {
00169 return deviceLink() ? deviceLink()->pilotSocket() : -1 ;
00170 }
00171
00176 int openConduit()
00177 {
00178 return deviceLink() ? deviceLink()->openConduit() : -1;
00179 }
00180 public:
00191 class SyncMode
00192 {
00193 public:
00195 enum Mode {
00196 eHotSync=1,
00197 eFullSync=2,
00198 eCopyPCToHH=3,
00199 eCopyHHToPC=4,
00200 eBackup=5,
00201 eRestore=6
00202 } ;
00203
00210 SyncMode(Mode m, bool test=false, bool local=false);
00211
00217 SyncMode(const QStringList &l);
00218
00222 Mode mode() const
00223 {
00224 return fMode;
00225 }
00226
00232 bool setMode(int);
00233
00237 bool setMode(Mode m);
00238
00241 bool setOptions(bool test, bool local)
00242 {
00243 fTest=test;
00244 fLocal=local;
00245 return true;
00246 }
00247
00251 bool operator ==(const Mode &m) const
00252 {
00253 return mode() == m;
00254 }
00258 bool operator ==(const SyncMode &m) const
00259 {
00260 return ( mode() == m.mode() ) &&
00261 ( isTest() == m.isTest() ) &&
00262 ( isLocal() == m.isLocal() );
00263 } ;
00264
00268 bool isTest() const
00269 {
00270 return fTest;
00271 }
00272
00276 bool isLocal() const
00277 {
00278 return fLocal;
00279 }
00280
00281 bool isFullSync() const
00282 {
00283 return ( fMode==eFullSync ) ||
00284 ( fMode==eCopyPCToHH) ||
00285 ( fMode==eCopyHHToPC) ;
00286 } ;
00287 bool isFirstSync() const
00288 {
00289 return ( fMode==eCopyHHToPC ) || ( fMode==eCopyPCToHH ) ;
00290 };
00291
00293 bool isSync() const
00294 {
00295 return ( fMode==eFullSync ) ||
00296 ( fMode == eHotSync );
00297 } ;
00298
00300 bool isCopy() const
00301 {
00302 return ( fMode==eBackup ) ||
00303 ( fMode==eRestore ) ||
00304 ( fMode==eCopyPCToHH ) ||
00305 ( fMode==eCopyHHToPC );
00306 } ;
00307
00311 static QString name(Mode);
00312
00317 QString name() const;
00318
00324 QStringList list() const;
00325
00326 private:
00327 Mode fMode;
00328 bool fTest;
00329 bool fLocal;
00330 };
00331
00332
00333 enum ConflictResolution
00334 {
00335 eUseGlobalSetting=-1,
00336 eAskUser=0,
00337 eDoNothing,
00338 eHHOverrides,
00339 ePCOverrides,
00340 ePreviousSyncOverrides,
00341 eDuplicate,
00342 eDelete,
00343 eCROffset=-1
00344 };
00345
00351 enum BackupFrequency
00352 {
00353 eEveryHotSync=0,
00354 eOnRequestOnly
00355 };
00356
00357 protected:
00369 void startTickle(unsigned count=0);
00370 void stopTickle();
00371 signals:
00372 void timeout();
00373
00374
00375
00376
00377 protected:
00378 QWidget *fParent;
00379
00392 int questionYesNo(const QString &question ,
00393 const QString &caption = QString::null,
00394 const QString &key = QString::null,
00395 unsigned timeout = 20,
00396 const QString &yes = QString::null,
00397 const QString &no = QString::null );
00398 int questionYesNoCancel(const QString &question ,
00399 const QString &caption = QString::null,
00400 const QString &key = QString::null,
00401 unsigned timeout = 20,
00402 const QString &yes = QString::null,
00403 const QString &no = QString::null ) ;
00404 };
00405
00406
00407 #endif
|