summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/configuration.h
blob: 900114765ec91cdc630992c584694b5c2a5f746f (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/***************************************************************************
 *                                                                         *
 *   copyright (C) 2004 by Michael Buesch                                  *
 *   email: mbuesch@freenet.de                                             *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License version 2        *
 *   as published by the Free Software Foundation.                         *
 *                                                                         *
 ***************************************************************************/

/***************************************************************************
 * copyright (C) 2004 by Ulf Schenk
 * This file is originaly based on version 1.0.1 of pwmanager
 * and was modified to run on embedded devices that run microkde
 *
 * $Id$
 **************************************************************************/  

#ifndef __CONFIGURATION_H
#define __CONFIGURATION_H

#define CONF_DEFAULT_PWTIMEOUT		10	/* 10 sec */
#define CONF_DEFAULT_LOCKTIMEOUT	0	/* 0 == disable */
#define CONF_DEFAULT_TRAY		true
#define CONF_DEFAULT_UNLOCKONOPEN	false
#define CONF_DEFAULT_MAINVIEWSTYLE	0
#define CONF_DEFAULT_COMPRESSION	0x01	/* gzip */
#define CONF_DEFAULT_AUTOMINIMIZE	false
#define CONF_DEFAULT_BROWSERCOMMAND	""
#define CONF_DEFAULT_XTERMCOMMAND	"konsole -e"
#define CONF_DEFAULT_FILEPERMISSIONS	0600
#define CONF_DEFAULT_MAKEFILEBACKUP	false
#define CONF_DEFAULT_AUTOSTART_DEEPL	true
#define CONF_DEFAULT_AUTODEEPLOCK	true
#define CONF_DEFAULT_KWALLETEMU		true
#define CONF_DEFAULT_MINIMIZELOCK	2	/* deep-lock */
#define CONF_DEFAULT_NEWENTRLOCKSTAT	true	/* locked */
#define CONF_DEFAULT_WNDCLOSE		true	/* don't minimize to tray */

/** This is just because I'm too lazy to always
  * type this loooong statement, when accessing
  * configuration parameters.
  */
#define conf()	Configuration::obj()

#include <kstandarddirs.h>

#ifndef PWM_EMBEDDED
#include <kdeversion.h>
#else
#define KDE_VERSION 310
#define KDE_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c))
#endif

// Set this to 1 to debug the 3.1 compatibility interface
#if 0
# warning configuration.h KDE_VERSION debugging enabled!
# undef KDE_VERSION
# define KDE_VERSION	KDE_MAKE_VERSION(3, 1, 0)
#endif

#if !defined(KDE_VERSION) || !defined(KDE_MAKE_VERSION)
# error "KDE_VERSION or KDE_MAKE_VERSION not defined"
#endif
#if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)

#ifndef PWM_EMBEDDED
//MOC_SKIP_BEGIN
#endif 

#include <qstring.h>
#include <qsize.h>
#include <qfont.h>
#include <qwidget.h>
#include <qvbox.h>
#include <qhbox.h>
#include <qlineedit.h>

#include <kconfigskeleton.h>

#include "pwmexception.h"

class QLabel;
class QGroupBox;
class QPushButton;
class QResizeEvent;

/** New global configuration file interface
  * using KDE-3.2 KConfigSkeleton model.
  */
class Configuration
{
public:
	Configuration();
	~Configuration();

	static Configuration * obj()
		{
			PWM_ASSERT(_obj);
			return _obj;
		}
	static void init()
		{
			PWM_ASSERT(!_obj);
			_obj = new Configuration;
		}
	static void cleanup()
			{ delete_ifnot_null(_obj); }


	/** Read the configuration from the file.
	  * Normally this function has not to be called manually.
	  */
	void readConfig()
			{ skel->readConfig(); }
	/** Write the configuration to the file.
	  * Normally this function has not to be called manually.
	  */
	void writeConfig()
			{ skel->writeConfig(); }
	/** reset the whole configuration to its defaults */
	void resetConfig()
			{ skel->setDefaults(); }
	/** show the configuration window */
	bool showConfWnd(QWidget *parent);

public:
	/* functions for reading the configuration settings */
	/* GLOBAL */
	QString confGlobAutoStart()
			{ return cGlobAutoStart; }
	QString confGlobBrowserCommand()
			{ return cGlobBrowserCommand; }
	QString confGlobXtermCommand()
			{ return cGlobXtermCommand; }
	QFont confGlobEntryFont()
			{ return cGlobEntryFont; }
	int confGlobPwTimeout()
			{ return cGlobPwTimeout; }
	int confGlobLockTimeout()
			{ return cGlobLockTimeout; }
	int confGlobCompression()
			{ return cGlobCompression; }
	int confGlobFilePermissions()
			{ return cGlobFilePermissions; }
	int confGlobMinimizeLock()
			{ return cGlobMinimizeLock; }
	bool confGlobUnlockOnOpen()
			{ return cGlobUnlockOnOpen; }
	bool confGlobTray()
			{ return cGlobTray; }
	bool confGlobMakeFileBackup()
			{ return cGlobMakeFileBackup; }
	bool confGlobAutostartDeepLocked()
			{ return cGlobAutostartDeepLocked; }
	bool confGlobAutoDeepLock()
			{ return cGlobAutoDeepLock; }
	bool confGlobKwalletEmu()
			{ return cGlobKwalletEmu; }
	bool confGlobNewEntrLockStat()
			{ return cGlobNewEntrLockStat; }
	/* WND */
	QSize confWndMainWndSize()
			{ return cWndMainWndSize; }
	int confWndMainViewStyle()
			{ return cWndMainViewStyle; }
	bool confWndAutoMinimizeOnStart()
			{ return cWndAutoMinimizeOnStart; }
	bool confWndClose()
			{ return cWndClose; }

public:
	/* functions for writing the configuration settings */
	/* GLOBAL */
	void confGlobAutoStart(const QString &e)
			{ cGlobAutoStart = e; }
	void confGlobBrowserCommand(const QString &e)
			{ cGlobBrowserCommand = e; }
	void confGlobXtermCommand(const QString &e)
			{ cGlobXtermCommand = e; }
	void confGlobEntryFont(const QFont &e)
			{ cGlobEntryFont = e; }
	void confGlobPwTimeout(int e)
			{ cGlobPwTimeout = e; }
	void confGlobLockTimeout(int e)
			{ cGlobLockTimeout = e; }
	void confGlobCompression(int e)
			{ cGlobCompression = e; }
	void confGlobFilePermissions(int e)
			{ cGlobFilePermissions = e; }
	void confGlobMinimizeLock(int e)
			{ cGlobMinimizeLock = e; }
	void confGlobUnlockOnOpen(bool e)
			{ cGlobUnlockOnOpen = e; }
	void confGlobTray(bool e)
			{ cGlobTray = e; }
	void confGlobMakeFileBackup(bool e)
			{ cGlobMakeFileBackup = e; }
	void confGlobAutostartDeepLocked(bool e)
			{ cGlobAutostartDeepLocked = e; }
	void confGlobAutoDeepLock(bool e)
			{ cGlobAutoDeepLock = e; }
	void confGlobKwalletEmu(bool e)
			{ cGlobKwalletEmu = e; }
	void confGlobNewEntrLockStat(bool e)
			{ cGlobNewEntrLockStat = e; }
	/* WND */
	void confWndMainWndSize(const QSize &e)
			{ cWndMainWndSize = e; }
	void confWndMainViewStyle(int e)
			{ cWndMainViewStyle = e; }
	void confWndAutoMinimizeOnStart(bool e)
			{ cWndAutoMinimizeOnStart = e; }
	void confWndClose(bool e)
			{ cWndClose = e; }

protected:
	/** initialize the skeleton */
	void initSkel();

protected:
	/** static instance of this class returned by obj() */
	static Configuration *_obj;
	/** main configuration access skeleton */
	KConfigSkeleton *skel;

protected:
	/* configuration variables. All prefixed with 'c'. */
	/* GLOBAL */
	QString cGlobAutoStart;
	QString cGlobBrowserCommand;
	QString cGlobXtermCommand;
	QFont cGlobEntryFont;
	int cGlobPwTimeout;
	int cGlobLockTimeout;
	int cGlobCompression;
	int cGlobFilePermissions;
	int cGlobMinimizeLock;
	bool cGlobUnlockOnOpen;
	bool cGlobTray;
	bool cGlobMakeFileBackup;
	bool cGlobAutostartDeepLocked;
	bool cGlobAutoDeepLock;
	bool cGlobKwalletEmu;
	bool cGlobNewEntrLockStat;
	/* WND */
	QSize cWndMainWndSize;
	int cWndMainViewStyle;
	bool cWndAutoMinimizeOnStart;
	bool cWndClose;
};

/* Big fat note: Internal stuff follows.
 * ============  Don't use the following classes outside of
 *		 the Configuration code, because it's unavailable
 *		 when compiled under KDE-3.1
 */

/** class for input of octal numbers (for example file permissions) */
class OctLineEdit : public QLineEdit
{
	Q_OBJECT
	Q_OVERRIDE( QString text READ text WRITE setText )

public:
	OctLineEdit(QWidget *parent, const char *name = 0);
	~OctLineEdit();

	void setText(const QString &t);
	QString text() const;

protected:
	void keyPressEvent(QKeyEvent *e);
};

/** global configuration page */
class ConfPageGlobal : public QWidget
{
public:
	ConfPageGlobal(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
};

/** configuration page for look&feel */
class ConfPageLookNFeel : public QWidget
{
public:
	ConfPageLookNFeel(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
};

/** file configuration page */
class ConfPageFile : public QWidget
{
public:
	ConfPageFile(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
};

/** timeouts configuration page */
class ConfPageTimeouts : public QWidget
{
public:
	ConfPageTimeouts(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
};

/** configuration page for external apps */
class ConfPageExtApps : public QWidget
{
public:
	ConfPageExtApps(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
};

/** autostart configuration page */
class ConfPageAutostart : public QWidget
{
	Q_OBJECT
public:
	ConfPageAutostart(QWidget *parent = 0, const char *name = 0, WFlags f = 0);

protected slots:
	void browseButton_slot();

protected:
	QLineEdit *kcfg_autoStart;
};


#ifndef PWM_EMBEDDED
//MOC_SKIP_END
#endif 


#else // KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
  /* XXX: This is the code for KDE-3.1 compatibility. */
# include "configuration_31compat.h"
#endif // KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
#endif // CONFIGURATION_H