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
|
#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 kde-pim@kde.org
*/
#include <plugin.h>
class docSyncInfo;
typedef QValueList<docSyncInfo> syncInfoList;
typedef enum eSyncDirectionEnum {
eSyncNone,
// eSyncAll,
eSyncPDAToPC,
eSyncPCToPDA,
eSyncDelete,
eSyncConflict
};
typedef enum eTextStatus {
eStatNone=0,
eStatNew=1,
eStatChanged=2,
eStatBookmarksChanged=4,
eStatDeleted=8,
eStatDoesntExist=16
};
QString dirToString(eSyncDirectionEnum dir);
class DOCConduit:public ConduitAction {
Q_OBJECT
public:
eSyncDirectionEnum eSyncDirection;
public:
DOCConduit(KPilotLink * o,
const char *n = 0L, const QStringList & a = QStringList());
virtual ~ DOCConduit();
bool encode(QStringList fileName, PilotDatabase * db);
bool decode(PilotDatabase * db, QString 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(QString 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 QString &dbname);
QString constructPDBFileName(QString name);
QString constructTXTFileName(QString name);
eSyncDirectionEnum eConflictResolution;
int fTXTBookmarks, fPDBBookmarks;
QStringList fDBListSynced;
QStringList fDBNames;
syncInfoList fSyncInfoList;
syncInfoList::Iterator fSyncInfoListIterator;
long int dbnr;
QStringList docnames;
QStringList::Iterator dociterator;
};
class docSyncInfo
{
public:
docSyncInfo(QString hhDB=QString(), QString txtfn=QString(), QString pdbfn=QString(), eSyncDirectionEnum dir=eSyncNone)
{
handheldDB=hhDB;
txtfilename=txtfn;
pdbfilename=pdbfn;
direction=dir;
fPCStatus=eStatNone;
fPalmStatus=eStatNone;
};
~docSyncInfo(){};
QString handheldDB, txtfilename, pdbfilename;
DBInfo dbinfo;
eSyncDirectionEnum direction;
eTextStatus fPCStatus, fPalmStatus;
};
#endif
|