00001
#ifndef _doc_CONDUIT_H
00002
#define _doc_CONDUIT_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 <plugin.h>
00032
00033
class docSyncInfo;
00034
typedef QValueList<docSyncInfo> syncInfoList;
00035
00036
typedef enum eSyncDirectionEnum {
00037 eSyncNone,
00038
00039 eSyncPDAToPC,
00040 eSyncPCToPDA,
00041 eSyncDelete,
00042 eSyncConflict
00043 };
00044
typedef enum eTextStatus {
00045 eStatNone=0,
00046 eStatNew=1,
00047 eStatChanged=2,
00048 eStatBookmarksChanged=4,
00049 eStatDeleted=8,
00050 eStatDoesntExist=16
00051 };
00052
00053
00054 QString dirToString(eSyncDirectionEnum dir);
00055
00056
class DOCConduit:
public ConduitAction {
00057 Q_OBJECT
00058
public:
00059 eSyncDirectionEnum eSyncDirection;
00060
00061
public:
00062 DOCConduit(KPilotDeviceLink * o,
00063
const char *n = 0L,
const QStringList & a = QStringList());
00064
virtual ~ DOCConduit();
00065
00066
bool encode(QStringList fileName,
PilotDatabase * db);
00067
bool decode(
PilotDatabase * db, QString fileName);
00068
virtual bool exec();
00069
protected:
00070
virtual bool isCorrectDBTypeCreator(DBInfo dbinfo);
00071
virtual const unsigned long dbtype();
00072
virtual const unsigned long dbcreator();
00073
00074
public slots:
00077
void syncNextDB();
00078
void syncNextTXT();
00079
void checkPDBFiles();
00080
void checkDeletedDocs();
00081
void resolve();
00082
void syncDatabases();
00083
void cleanup();
00084
00085
private:
00090
void readConfig();
00091
00095
bool needsSync(docSyncInfo &sinfo);
00100
PilotDatabase *preSyncAction(docSyncInfo &sinfo)
const;
00101
00102
bool doSync(docSyncInfo &sinfo);
00107
bool postSyncAction(
PilotDatabase * dbinfo, docSyncInfo &sinfo,
bool res =
true);
00108
00109
bool pcTextChanged(QString txtfn);
00110
bool hhTextChanged(
PilotDatabase*docdb);
00111
00115
PilotDatabase*openDOCDatabase(QString dbname);
00116
00117 QString constructPDBFileName(QString name);
00118 QString constructTXTFileName(QString name);
00119
00120
00121 QString fTXTDir, fPDBDir;
00122
bool fKeepPDBLocally;
00123 eSyncDirectionEnum eConflictResolution;
00124
int fTXTBookmarks, fPDBBookmarks;
00125
bool fCompress, fIgnoreBmkChangesOnly, fLocalSync, fAlwaysUseResolution;
00126 QStringList fDBListSynced;
00127 QStringList fDBNames;
00128 syncInfoList fSyncInfoList;
00129 syncInfoList::Iterator fSyncInfoListIterator;
00130
long int dbnr;
00131
00132 QStringList docnames;
00133 QStringList::Iterator dociterator;
00134 };
00135
00136
class docSyncInfo
00137 {
00138
public:
00139 docSyncInfo(QString hhDB=QString(), QString txtfn=QString(), QString pdbfn=QString(), eSyncDirectionEnum dir=eSyncNone)
00140 {
00141 handheldDB=hhDB;
00142 txtfilename=txtfn;
00143 pdbfilename=pdbfn;
00144 direction=dir;
00145 fPCStatus=eStatNone;
00146 fPalmStatus=eStatNone;
00147 };
00148 ~docSyncInfo(){};
00149 QString handheldDB, txtfilename, pdbfilename;
00150 DBInfo dbinfo;
00151 eSyncDirectionEnum direction;
00152 eTextStatus fPCStatus, fPalmStatus;
00153 };
00154
00155
00156
#endif