summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/pwm.h
blob: 2d1b854380ae23d4f9530169e2170451a7c863dc (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
/***************************************************************************
 *                                                                         *
 *   copyright (C) 2003, 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 __PWM_H
#define __PWM_H


#include <kpopupmenu.h>
#include <klistview.h>
#include <kmainwindow.h>

#ifndef PWM_EMBEDDED
#include <kwin.h>
#include <kapp.h>
#include <kdeversion.h>
#else
#include <ksyncmanager.h>
#endif

#include <kaction.h>

#include <qglobal.h>

#include "pwmview.h"
#include "pwmexception.h"


/** timeout for displaying a message on the status-bar (in seconds) */
#define STATUSBAR_MSG_TIMEOUT	5


class PwMInit;
class KSyncManager;

/** PwM is the base class of the project */
#ifndef PWM_EMBEDDED
//MOC_SKIP_BEGIN
class PwM : public KMainWindow
//MOC_SKIP_END
#else
class PwM : public KMainWindow, public KSyncInterface
#endif
{
	Q_OBJECT
public:
	friend class PwMView;
	/** construtor */
	PwM(PwMInit *_init, PwMDoc *doc,
	    bool virginity = true,
	    QWidget* parent = 0, const char *name = 0);
	/** destructor */
	~PwM();

	/** copy some text to the global clipboard */
	static void copyToClipboard(const QString &s);

	/** returns pointer to the view */
	PwMView * curView()
			{ return view; }
	/** returns pointer to the currently using document. */
	PwMDoc * curDoc()
			{ return curView()->document(); }
	/** open a new doc with the given filename */
	PwMDoc * openDoc(QString filename, bool openDeepLocked = false);
	/** show a message on the global status bar.
	  * The message times out after some seconds.
	  */
	void showStatMsg(const QString &msg);
	/** ask the user where to save the doc (if it has not been saved, yet)
	  * and write the data to disk.
	  */
	bool save();
	/** ask the user where to save the doc
	  * and write the data to disk.
	  */
	bool saveAs();
	/** force quit. Quit this window, always! Don't minimize it */
	bool isForceQuit()
			{ return forceQuit; }
	/** set forceQuit */
	void setForceQuit(bool force)
			{ forceQuit = force; }
	/** force minimize this window */
	bool isForceMinimizeToTray()
			{ return forceMinimizeToTray; }
	/** set forceMinimizeToTray */
	void setForceMinimizeToTray(bool force)
			{ forceMinimizeToTray = force; }

public slots:
	/** file/new triggered */
	void new_slot();
	/** file/open triggered */
//US ENH
	void open_slot();
	void open_slot(QString fn);
	/** file/close triggered */
	void close_slot();
	/** file/quit triggered */
	void quitButton_slot();
	/** file/save triggered */
	void save_slot();
	/** file/saveAs triggered */
	void saveAs_slot();
	/** file/export/text triggered */
	void exportToText();
	/** file/export/gpasman triggered */
	void exportToGpasman();
	/** file/export/kwallet triggered */
	void exportToKWallet();
	/** file/export/csv triggered */
	void exportToCsv();
	/** file/import/text triggered */
	bool importFromText();
	/** file/import/gpasman triggered */
	bool importFromGpasman();
	/** file/import/kwallet triggered */
	bool importKWallet();
	/** file/import/csv triggered */
	bool importCsv();
	/** file/print triggered */
	void print_slot();
	/** manage/add triggered */
	//US ENH : changed code to run with older MOC

	void addPwd_slot();
	void addPwd_slot1(QString *pw, PwMDoc *_doc);
	/** manage/edit triggered */
	//US ENH : changed code to run with older MOC
	void editPwd_slot();
	void editPwd_slot1(const QString *category);
	void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc );

	/** manage/delete triggered */
	void deletePwd_slot();
	/** execute the "Launcher" entry */
	void execLauncher_slot();
	/** open browser with URL entry */
	void goToURL_slot();
	/** manage/changeMasterPwd triggered */
	void changeMasterPwd_slot();
	/** lock current document */
	void lockWnd_slot();
	/** deeplock current document */
	void deepLockWnd_slot();
	/** window/unlock triggered */
	void unlockWnd_slot();
	/** find item */
	void find_slot();
	/** configure clicked */
	void config_slot();
	void config_global_slot();
	/** (de)activate the "change master pw" button in the menu-bar */
	void activateMpButton(bool activate = true);
	/** generate a new chipcard */
	void genNewCard_slot();
	/** completely erase the current card */
	void eraseCard_slot();
	/** returns the ID number of the current card */
	void readCardId_slot();
	/** make backup image of the current card */
	void makeCardBackup_slot();
	/** write backup image to current card */
	void replayCardBackup_slot();

#ifdef PWM_EMBEDDED
	void category_slot();
	void whatsnew_slot();
	void showLicense_slot();
	void faq_slot();
	void createAboutData_slot();
	void syncHowTo_slot();
#endif

protected:
	/** is this window virgin? */
	bool isVirgin()
			{ return virgin; }
	/** add/remove virginity */
	void setVirgin(bool v);
	/** initialize the menubar */
	void initMenubar();
	/** initialize the toolbar */
	void initToolbar();
	/** initialize the window-metrics */
	void initMetrics();
	/** close-event */
	void closeEvent(QCloseEvent *e);
	/** creates a new PwM-ListView and returns it */
	PwMView * makeNewListView(PwMDoc *doc);
	/** Window hide-event */
	void hideEvent(QHideEvent *);
	/** is this window minimized? */
	bool isMinimized()
		{
#ifndef PWM_EMBEDDED
		  #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
			return KWin::windowInfo(winId()).isMinimized();
		  #else // KDE_VERSION
			return KWin::info(winId()).isIconified();
		  #endif // KDE_VERSION
#else
			return false;
#endif
		}
	/** window got the focus */
	void focusInEvent(QFocusEvent *e);
	/** update the caption string */
	void updateCaption();
#ifdef CONFIG_KWALLETIF
	/** check if kwalletemu is enabled and ask the user what to do */
	bool checkAndAskForKWalletEmu();
#endif // CONFIG_KWALLETIF

protected slots:
	/** doc got closed */
	void docClosed(PwMDoc *doc);

signals:
	/** window got closed (by user or someone else) */
	void closed(PwM *wnd);
	/** window got the focus (was brought to foreground) */
	void gotFocus(PwM *wnd);
	/** window lost the focus */
	void lostFocus(PwM *wnd);

protected:
	/** pointer to the view active in this KMainWindow */
	PwMView *view;
	/** pointer to the init class */
	PwMInit *init;
	/** has this window already lost its virginity?
	  * Means is there an open working document
	  */
	bool virgin;
	/** "file" popup-menu */
	KPopupMenu *filePopup;

	/** "manage" popup-menu */
	KPopupMenu *managePopup;
#ifdef CONFIG_KEYCARD
	/** "chipcard" popup-menu */
	KPopupMenu *chipcardPopup;
#endif // CONFIG_KEYCARD
	/** "view" popup-menu */
	KPopupMenu *viewPopup;
	/** "options" popup-menu */
	KPopupMenu *optionsPopup;
	/** "help" popup-menu */
	KPopupMenu *helpPopup;
	/** "export" popup-menu */
	KPopupMenu *exportPopup;
	/** "import" popup-menu */
	KPopupMenu *importPopup;
	/** force quit this window? */
	bool forceQuit;
	/** force minimize this window to the tray */
	bool forceMinimizeToTray;




 private:
#ifdef PWM_EMBEDDED
    //this are the overwritten callbackmethods from the syncinterface
    virtual bool sync(KSyncManager* manager, QString filename, int mode); 
    virtual void removeSyncInfo( QString syncProfile);

    // LR *******************************
    // sync stuff!
    QPopupMenu *syncPopup;
    KSyncManager* syncManager;
#endif








};

#endif