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
00061 int status() const { return fActionStatus; } ;
00062 virtual QString statusString() const;
00063
00064 protected:
00078 virtual bool exec() = 0;
00079
00080 public slots:
00085 void execConduit();
00086
00087 signals:
00088 void syncDone(SyncAction *);
00089 void logMessage(const QString &);
00090 void logError(const QString &);
00091 void logProgress(const QString &,int);
00092
00102 protected slots:
00103 void delayedDoneSlot();
00104
00105 protected:
00106 bool delayDone();
00107
00108 public:
00109 void addSyncLogEntry(const QString &e,bool log=true)
00110 { if (deviceLink()) { deviceLink()->addSyncLogEntry(e,log); } } ;
00111 void addLogMessage( const QString &msg ) { emit logMessage( msg ); }
00112 void addLogError( const QString &msg ) { emit logError( msg ); }
00113 void addLogProgress( const QString &msg, int prog ) { emit logProgress( msg, prog ); }
00114 protected:
00116 KPilotLink *fHandle;
00117 int fActionStatus;
00118
00120 inline KPilotLink *deviceLink() const { return fHandle; }
00121
00126 int pilotSocket() const { return deviceLink() ? deviceLink()->pilotSocket() : -1 ; } ;
00127
00132 int openConduit() { return deviceLink() ? deviceLink()->openConduit() : -1; } ;
00133 public:
00144 class SyncMode
00145 {
00146 public:
00148 enum Mode {
00149 eHotSync=1,
00150 eFullSync=2,
00151 eCopyPCToHH=3,
00152 eCopyHHToPC=4,
00153 eBackup=5,
00154 eRestore=6
00155 } ;
00156
00163 SyncMode(Mode m, bool test=false, bool local=false);
00164
00170 SyncMode(const QStringList &l);
00171
00175 Mode mode() const { return fMode; };
00176
00182 bool setMode(int);
00186 bool setMode(Mode m);
00187
00190 bool setOptions(bool test, bool local) { fTest=test; fLocal=local; return true; } ;
00191
00195 bool operator ==(const Mode &m) const { return mode() == m; } ;
00196 bool operator ==(const SyncMode &m) const
00197 {
00198 return ( mode() == m.mode() ) &&
00199 ( isTest() == m.isTest() ) &&
00200 ( isLocal() == m.isLocal() );
00201 } ;
00202
00206 bool isTest() const { return fTest; };
00207
00211 bool isLocal() const { return fLocal; };
00212
00213
00214 bool isFullSync() const
00215 {
00216 return ( fMode==eFullSync ) ||
00217 ( fMode==eCopyPCToHH) ||
00218 ( fMode==eCopyHHToPC) ;
00219 } ;
00220 bool isFirstSync() const
00221 {
00222 return ( fMode==eCopyHHToPC ) || ( fMode==eCopyPCToHH ) ;
00223 };
00224
00226 bool isSync() const
00227 {
00228 return ( fMode==eFullSync ) ||
00229 ( fMode == eHotSync );
00230 } ;
00231
00233 bool isCopy() const
00234 {
00235 return ( fMode==eBackup ) ||
00236 ( fMode==eRestore ) ||
00237 ( fMode==eCopyPCToHH ) ||
00238 ( fMode==eCopyHHToPC );
00239 } ;
00240
00244 static QString name(Mode);
00249 QString name() const;
00250
00256 QStringList list() const;
00257
00258 private:
00259 Mode fMode;
00260 bool fTest;
00261 bool fLocal;
00262 };
00263
00264
00265 enum ConflictResolution
00266 {
00267 eUseGlobalSetting=-1,
00268 eAskUser=0,
00269 eDoNothing,
00270 eHHOverrides,
00271 ePCOverrides,
00272 ePreviousSyncOverrides,
00273 eDuplicate,
00274 eDelete,
00275 eCROffset=-1
00276 };
00277
00283 enum BackupFrequency
00284 {
00285 eEveryHotSync=0,
00286 eOnRequestOnly
00287 };
00288
00289 protected:
00301 void startTickle(unsigned count=0);
00302 void stopTickle();
00303 signals:
00304 void timeout();
00305
00306
00307
00308
00309 protected:
00310 QWidget *fParent;
00311
00324 int questionYesNo(const QString &question ,
00325 const QString &caption = QString::null,
00326 const QString &key = QString::null,
00327 unsigned timeout = 20,
00328 const QString &yes = QString::null,
00329 const QString &no = QString::null );
00330 int questionYesNoCancel(const QString &question ,
00331 const QString &caption = QString::null,
00332 const QString &key = QString::null,
00333 unsigned timeout = 20,
00334 const QString &yes = QString::null,
00335 const QString &no = QString::null ) ;
00336 };
00337
00338
00339 #endif
|