summaryrefslogtreecommitdiffstats
path: root/kpilot/kpilot/hotSync.h
blob: f100e639d0086d832c428821e73c529fa2521c40 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#ifndef _KPILOT_HOTSYNC_H
#define _KPILOT_HOTSYNC_H
/* hotSync.h                            KPilot
**
** Copyright (C) 2001 by Dan Pilone
** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
** Copyright (C) 2006 Adriaan de Groot <groot@kde.org>
**
** This file defines SyncActions, which are used to perform some specific
** task during a HotSync. Conduits are not included here, nor are
** sync actions requiring user interaction. Those can be found in the
** conduits subdirectory or interactiveSync.h.
*/

/*
** 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
*/


class TQTimer;

#include "syncAction.h"

class CheckUser : public SyncAction
{
public:
	CheckUser(KPilotLink *p,TQWidget *w=0L);
	virtual ~CheckUser();

protected:
	virtual bool exec();
} ;


class BackupAction : public SyncAction
{
Q_OBJECT

public:
	/** Constructor. Back up all the databases on
	*   the link to a directory on the local disk.
	*   If @p full is @c true, then a full backup,
	*   including applications, is done. Otherwise,
	*   only user data is backed-up.
	*
	* @see setDirectory()
	*/
	BackupAction(KPilotLink *, bool full);

	enum Status { Init,
		Error,
		FastBackup,
		FullBackup,
		BackupIncomplete,
		BackupEnded,
		BackupComplete
		} ;
	virtual TQString statusString() const;

	/** By default, a path based on the user name (either
	*   on the handheld or set in KPilot) is used to
	*   determine the backup directory name ( generally
	*   $KDEHOME/share/apps/kpilot/DBBackup/_user_name_ ).
	*   Use setDirectory() to change that and use a given
	*   @p path as target for the backup. Use an empty
	*   @p path to restore the default behavior of using
	*   the username.
	*/
	void setDirectory( const TQString &path );

	// Reimplemented to support threaded backup.
	virtual bool event( TQEvent *e );

protected:
	virtual bool exec();

private:
	/** Finish the backup and clean up resources. */
	void endBackup();

	/** Copy the database indicated by @p info to the local
	*   disk; returns @c false on failure.
	*/
	bool startBackupThread(DBInfo *info);

private slots:
	/** Implementation detail: databases get backed-up
	*   one at a time because the backup function in
	*   pilot-link isn't threaded.
	*/
	void backupOneDB();

private:
	class Private;
	Private *fP;
	class Thread;
	Thread *fBackupThread;
} ;

class FileInstallAction : public SyncAction
{
Q_OBJECT
public:
	FileInstallAction(KPilotLink *,
		const TQString &fileDir);
	virtual ~FileInstallAction();

	virtual TQString statusString() const;

protected:
	virtual bool exec();

protected slots:
	void installNextFile();

private:
	int fDBIndex;
	TQTimer *fTimer;
	TQString fDir;
	TQStringList fList;

	// TODO: not const because it calls logError(), which is
	// non-const (but might be - can signals be const, anyway?)
	bool resourceOK(const TQString &, const TQString &) /* const */ ;
} ;

class RestoreAction : public SyncAction
{
Q_OBJECT
public:
	RestoreAction(KPilotLink *,TQWidget *w=0L);

	typedef enum { InstallingFiles, GettingFileInfo,Done } Status;
	virtual TQString statusString() const;

	/** By default, a path based on the user name (either
	*   on the handheld or set in KPilot) is used to
	*   determine the restory directory name ( generally
	*   $KDEHOME/share/apps/kpilot/DBBackup/_user_name_ ).
	*   Use setDirectory() to change that and use a given
	*   @p path as target for the source. Use an empty
	*   @p path to restore the default behavior of using
	*   the username.
	*/
	void setDirectory( const TQString &path );

protected:
	virtual bool exec();

protected slots:
	void installNextFile();

private:
	class Private;
	Private *fP;
} ;

#endif