1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
#ifndef _doc_CONDUIT_H
#define _doc_CONDUIT_H
/* doc-conduit.h KPilot
**
** Copyright (C) 2002-2003 by Reinhold Kainhofer
**
*/
/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/
/*
** Bug reports and questions can be sent to [email protected]
*/
#include <plugin.h>
class docSyncInfo;
typedef TQValueList<docSyncInfo> syncInfoList;
typedef enum eSyncDirectionEnum {
eSyncNone,
// eSyncAll,
eSyncPDAToPC,
eSyncPCToPDA,
eSyncDelete,
eSyncConflict
};
typedef enum eTexStatus {
eStatNone=0,
eStatNew=1,
eStatChanged=2,
eStatBookmarksChanged=4,
eStatDeleted=8,
eStatDoesntExist=16
};
TQString dirToString(eSyncDirectionEnum dir);
class DOCConduit:public ConduitAction {
Q_OBJECT
public:
eSyncDirectionEnum eSyncDirection;
public:
DOCConduit(KPilotLink * o,
const char *n = 0L, const TQStringList & a = TQStringList());
virtual ~ DOCConduit();
bool encode(TQStringList fileName, PilotDatabase * db);
bool decode(PilotDatabase * db, TQString fileName);
virtual bool exec();
protected:
virtual bool isCorrectDBTypeCreator(DBInfo dbinfo);
virtual const unsigned long dbtype();
virtual const unsigned long dbcreator();
public slots:
/** syncNextDB walks through all PalmDoc databases on the handheld and decides if they are supposed to be synced to the PC.
* syncNextDB and syncNextDOC fist build the list of all PalmDoc texts, and then the method syncDatabases does the actual sync. */
void syncNextDB();
void syncNextTXT();
void checkPDBFiles();
void checkDeletedDocs();
void resolve();
void syncDatabases();
void cleanup();
private:
/**
* Read the global KPilot config file for settings
* particular to the docConduit conduit.
*/
void readConfig();
/**
* Check if the database needs to be synced at all.
*/
bool needsSync(docSyncInfo &sinfo);
/**
* If necessary, copy the database from the palm to a local dir.
* Also initialize the docDBInfo that will be passed to the docconverter
*/
PilotDatabase *preSyncAction(docSyncInfo &sinfo) const;
bool doSync(docSyncInfo &sinfo);
/**
* Clean up after the sync. The bool parameter res tells
* the function if the conversion was successful or not
*/
bool postSyncAction(PilotDatabase * dbinfo, docSyncInfo &sinfo, bool res = true);
bool pcTextChanged(TQString txtfn);
bool hhTextChanged(PilotDatabase*docdb);
/** Opens the database with name dbname. For a local sync, this will be a
* PilotLocalDatabase, otherwise it will be a database on the serial device
* (i.e. an object of class PilotSerialDatabase) */
PilotDatabase *openDOCDatabase(const TQString &dbname);
TQString constructPDBFileName(TQString name);
TQString constructTXTFileName(TQString name);
eSyncDirectionEnum eConflictResolution;
int fTXTBookmarks, fPDBBookmarks;
TQStringList fDBListSynced;
TQStringList fDBNames;
syncInfoList fSyncInfoList;
syncInfoList::Iterator fSyncInfoListIterator;
long int dbnr;
TQStringList docnames;
TQStringList::Iterator dociterator;
};
class docSyncInfo
{
public:
docSyncInfo(TQString hhDB=TQString(), TQString txtfn=TQString(), TQString pdbfn=TQString(), eSyncDirectionEnum dir=eSyncNone)
{
handheldDB=hhDB;
txtfilename=txtfn;
pdbfilename=pdbfn;
direction=dir;
fPCStatus=eStatNone;
fPalmStatus=eStatNone;
};
~docSyncInfo(){};
TQString handheldDB, txtfilename, pdbfilename;
DBInfo dbinfo;
eSyncDirectionEnum direction;
eTexStatus fPCStatus, fPalmStatus;
};
#endif
|