summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwm.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index bd07c80..cd56399 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1,1097 +1,1112 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include <klocale.h> 20#include <klocale.h>
21#include <klistview.h> 21#include <klistview.h>
22#include <ktoolbar.h> 22#include <ktoolbar.h>
23#include <kfiledialog.h> 23#include <kfiledialog.h>
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include <kmessagebox.h> 25#include <kmessagebox.h>
26 26
27#ifndef PWM_EMBEDDED 27#ifndef PWM_EMBEDDED
28#include <kmenubar.h> 28#include <kmenubar.h>
29#include <kstatusbar.h> 29#include <kstatusbar.h>
30#include <dcopclient.h> 30#include <dcopclient.h>
31#include "configwndimpl.h" 31#include "configwndimpl.h"
32#include "configuration.h" 32#include "configuration.h"
33#else 33#else
34#include <qmenubar.h> 34#include <qmenubar.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <pwmprefs.h> 36#include <pwmprefs.h>
37#include <kpimglobalprefs.h> 37#include <kpimglobalprefs.h>
38#include <kcmconfigs/kcmpwmconfig.h> 38#include <kcmconfigs/kcmpwmconfig.h>
39#include <kcmconfigs/kcmkdepimconfig.h> 39#include <kcmconfigs/kcmkdepimconfig.h>
40#include <kcmultidialog.h> 40#include <kcmultidialog.h>
41#endif 41#endif
42 42
43#include <qpixmap.h> 43#include <qpixmap.h>
44#include <qcheckbox.h> 44#include <qcheckbox.h>
45#include <qspinbox.h> 45#include <qspinbox.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qfileinfo.h> 47#include <qfileinfo.h>
48#include <qclipboard.h> 48#include <qclipboard.h>
49 49
50 50
51#include <stdio.h> 51#include <stdio.h>
52 52
53#include "pwm.h" 53#include "pwm.h"
54#include "pwminit.h" 54#include "pwminit.h"
55#include "pwmprint.h" 55#include "pwmprint.h"
56#include "addentrywndimpl.h" 56#include "addentrywndimpl.h"
57#include "globalstuff.h" 57#include "globalstuff.h"
58#include "findwndimpl.h" 58#include "findwndimpl.h"
59 59
60#ifdef CONFIG_KWALLETIF 60#ifdef CONFIG_KWALLETIF
61# include "kwalletif.h" 61# include "kwalletif.h"
62# include "kwalletemu.h" 62# include "kwalletemu.h"
63#endif 63#endif
64#ifdef CONFIG_KEYCARD 64#ifdef CONFIG_KEYCARD
65# include "pwmkeycard.h" 65# include "pwmkeycard.h"
66#endif 66#endif
67 67
68 68
69 #define DEFAULT_SIZE (QSize(700, 400)) 69 #define DEFAULT_SIZE (QSize(700, 400))
70 70
71// Button IDs for "file" popup menu 71// Button IDs for "file" popup menu
72enum { 72enum {
73 BUTTON_POPUP_FILE_NEW = 0, 73 BUTTON_POPUP_FILE_NEW = 0,
74 BUTTON_POPUP_FILE_OPEN, 74 BUTTON_POPUP_FILE_OPEN,
75 BUTTON_POPUP_FILE_CLOSE, 75 BUTTON_POPUP_FILE_CLOSE,
76 BUTTON_POPUP_FILE_SAVE, 76 BUTTON_POPUP_FILE_SAVE,
77 BUTTON_POPUP_FILE_SAVEAS, 77 BUTTON_POPUP_FILE_SAVEAS,
78 BUTTON_POPUP_FILE_EXPORT, 78 BUTTON_POPUP_FILE_EXPORT,
79 BUTTON_POPUP_FILE_IMPORT, 79 BUTTON_POPUP_FILE_IMPORT,
80 BUTTON_POPUP_FILE_PRINT, 80 BUTTON_POPUP_FILE_PRINT,
81 BUTTON_POPUP_FILE_QUIT 81 BUTTON_POPUP_FILE_QUIT
82}; 82};
83// Button IDs for "manage" popup menu 83// Button IDs for "manage" popup menu
84enum { 84enum {
85 BUTTON_POPUP_MANAGE_ADD = 0, 85 BUTTON_POPUP_MANAGE_ADD = 0,
86 BUTTON_POPUP_MANAGE_EDIT, 86 BUTTON_POPUP_MANAGE_EDIT,
87 BUTTON_POPUP_MANAGE_DEL, 87 BUTTON_POPUP_MANAGE_DEL,
88 BUTTON_POPUP_MANAGE_CHANGEMP 88 BUTTON_POPUP_MANAGE_CHANGEMP
89}; 89};
90// Button IDs for chipcard popup menu 90// Button IDs for chipcard popup menu
91enum { 91enum {
92#ifdef CONFIG_KEYCARD 92#ifdef CONFIG_KEYCARD
93 BUTTON_POPUP_CHIPCARD_GENNEW = 0, 93 BUTTON_POPUP_CHIPCARD_GENNEW = 0,
94 BUTTON_POPUP_CHIPCARD_DEL, 94 BUTTON_POPUP_CHIPCARD_DEL,
95 BUTTON_POPUP_CHIPCARD_READID, 95 BUTTON_POPUP_CHIPCARD_READID,
96 BUTTON_POPUP_CHIPCARD_SAVEBACKUP, 96 BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
97 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP 97 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
98#else // CONFIG_KEYCARD 98#else // CONFIG_KEYCARD
99 BUTTON_POPUP_CHIPCARD_NO = 0 99 BUTTON_POPUP_CHIPCARD_NO = 0
100#endif // CONFIG_KEYCARD 100#endif // CONFIG_KEYCARD
101}; 101};
102// Button IDs for "view" popup menu 102// Button IDs for "view" popup menu
103enum { 103enum {
104 BUTTON_POPUP_VIEW_FIND = 0, 104 BUTTON_POPUP_VIEW_FIND = 0,
105 BUTTON_POPUP_VIEW_LOCK, 105 BUTTON_POPUP_VIEW_LOCK,
106 BUTTON_POPUP_VIEW_DEEPLOCK, 106 BUTTON_POPUP_VIEW_DEEPLOCK,
107 BUTTON_POPUP_VIEW_UNLOCK 107 BUTTON_POPUP_VIEW_UNLOCK
108}; 108};
109// Button IDs for "options" popup menu 109// Button IDs for "options" popup menu
110enum { 110enum {
111 BUTTON_POPUP_OPTIONS_CONFIG = 0 111 BUTTON_POPUP_OPTIONS_CONFIG = 0
112}; 112};
113// Button IDs for "export" popup menu (in "file" popup menu) 113// Button IDs for "export" popup menu (in "file" popup menu)
114enum { 114enum {
115 BUTTON_POPUP_EXPORT_TEXT = 0, 115 BUTTON_POPUP_EXPORT_TEXT = 0,
116 BUTTON_POPUP_EXPORT_GPASMAN 116 BUTTON_POPUP_EXPORT_GPASMAN
117#ifdef CONFIG_KWALLETIF 117#ifdef CONFIG_KWALLETIF
118 ,BUTTON_POPUP_EXPORT_KWALLET 118 ,BUTTON_POPUP_EXPORT_KWALLET
119#endif 119#endif
120}; 120};
121// Button IDs for "import" popup menu (in "file" popup menu) 121// Button IDs for "import" popup menu (in "file" popup menu)
122enum { 122enum {
123 BUTTON_POPUP_IMPORT_TEXT = 0, 123 BUTTON_POPUP_IMPORT_TEXT = 0,
124 BUTTON_POPUP_IMPORT_GPASMAN 124 BUTTON_POPUP_IMPORT_GPASMAN
125#ifdef CONFIG_KWALLETIF 125#ifdef CONFIG_KWALLETIF
126 ,BUTTON_POPUP_IMPORT_KWALLET 126 ,BUTTON_POPUP_IMPORT_KWALLET
127#endif 127#endif
128}; 128};
129 129
130#ifdef PWM_EMBEDDED 130#ifdef PWM_EMBEDDED
131// Button IDs for "help" popup menu 131// Button IDs for "help" popup menu
132enum { 132enum {
133 BUTTON_POPUP_HELP_LICENSE = 0, 133 BUTTON_POPUP_HELP_LICENSE = 0,
134 BUTTON_POPUP_HELP_FAQ, 134 BUTTON_POPUP_HELP_FAQ,
135 BUTTON_POPUP_HELP_ABOUT 135 BUTTON_POPUP_HELP_ABOUT
136}; 136};
137#endif 137#endif
138 138
139// Button IDs for toolbar 139// Button IDs for toolbar
140enum { 140enum {
141 BUTTON_TOOL_NEW = 0, 141 BUTTON_TOOL_NEW = 0,
142 BUTTON_TOOL_OPEN, 142 BUTTON_TOOL_OPEN,
143 BUTTON_TOOL_SAVE, 143 BUTTON_TOOL_SAVE,
144 BUTTON_TOOL_SAVEAS, 144 BUTTON_TOOL_SAVEAS,
145 BUTTON_TOOL_PRINT, 145 BUTTON_TOOL_PRINT,
146 BUTTON_TOOL_ADD, 146 BUTTON_TOOL_ADD,
147 BUTTON_TOOL_EDIT, 147 BUTTON_TOOL_EDIT,
148 BUTTON_TOOL_DEL, 148 BUTTON_TOOL_DEL,
149 BUTTON_TOOL_FIND, 149 BUTTON_TOOL_FIND,
150 BUTTON_TOOL_LOCK, 150 BUTTON_TOOL_LOCK,
151 BUTTON_TOOL_DEEPLOCK, 151 BUTTON_TOOL_DEEPLOCK,
152 BUTTON_TOOL_UNLOCK 152 BUTTON_TOOL_UNLOCK
153}; 153};
154 154
155 155
156PwM::PwM(PwMInit *_init, PwMDoc *doc, 156PwM::PwM(PwMInit *_init, PwMDoc *doc,
157 bool virginity, 157 bool virginity,
158 QWidget *parent, const char *name) 158 QWidget *parent, const char *name)
159 : KMainWindow(parent, name) 159 : KMainWindow(parent, name)
160 , forceQuit (false) 160 , forceQuit (false)
161 , forceMinimizeToTray (false) 161 , forceMinimizeToTray (false)
162{ 162{
163 init = _init; 163 init = _init;
164 connect(doc, SIGNAL(docClosed(PwMDoc *)), 164 connect(doc, SIGNAL(docClosed(PwMDoc *)),
165 this, SLOT(docClosed(PwMDoc *))); 165 this, SLOT(docClosed(PwMDoc *)));
166 initMenubar(); 166 initMenubar();
167 initToolbar(); 167 initToolbar();
168 initMetrics(); 168 initMetrics();
169 setVirgin(virginity); 169 setVirgin(virginity);
170 setFocusPolicy(QWidget::WheelFocus); 170 setFocusPolicy(QWidget::WheelFocus);
171#ifndef PWM_EMBEDDED 171#ifndef PWM_EMBEDDED
172 statusBar()->show(); 172 statusBar()->show();
173#endif 173#endif
174 view = makeNewListView(doc); 174 view = makeNewListView(doc);
175 setCentralWidget(view); 175 setCentralWidget(view);
176 updateCaption(); 176 updateCaption();
177 showStatMsg(i18n("Ready.")); 177 showStatMsg(i18n("Ready."));
178} 178}
179 179
180PwM::~PwM() 180PwM::~PwM()
181{ 181{
182 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), 182 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
183 this, SLOT(docClosed(PwMDoc *))); 183 this, SLOT(docClosed(PwMDoc *)));
184 conf()->confWndMainWndSize(size()); 184 conf()->confWndMainWndSize(size());
185 emit closed(this); 185 emit closed(this);
186 delete view; 186 delete view;
187} 187}
188 188
189void PwM::initMenubar() 189void PwM::initMenubar()
190{ 190{
191 KIconLoader* picons; 191 KIconLoader* picons;
192#ifndef PWM_EMBEDDED 192#ifndef PWM_EMBEDDED
193 KIconLoader icons; 193 KIconLoader icons;
194 picons = &icons; 194 picons = &icons;
195#else 195#else
196 picons = KGlobal::iconLoader(); 196 picons = KGlobal::iconLoader();
197#endif 197#endif
198 filePopup = new KPopupMenu(this); 198 filePopup = new KPopupMenu(this);
199 importPopup = new KPopupMenu(filePopup); 199 importPopup = new KPopupMenu(filePopup);
200 exportPopup = new KPopupMenu(filePopup); 200 exportPopup = new KPopupMenu(filePopup);
201 managePopup = new KPopupMenu(this); 201 managePopup = new KPopupMenu(this);
202#ifdef CONFIG_KEYCARD 202#ifdef CONFIG_KEYCARD
203 chipcardPopup = new KPopupMenu(this); 203 chipcardPopup = new KPopupMenu(this);
204#endif // CONFIG_KEYCARD 204#endif // CONFIG_KEYCARD
205 viewPopup = new KPopupMenu(this); 205 viewPopup = new KPopupMenu(this);
206 optionsPopup = new KPopupMenu(this); 206 optionsPopup = new KPopupMenu(this);
207 207#ifdef PWM_EMBEDDED
208 syncPopup = new KPopupMenu(this);
209#endif
208// "file" popup menu 210// "file" popup menu
209 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 211 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
210 i18n("&New"), this, 212 i18n("&New"), this,
211 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); 213 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW);
212 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), 214 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)),
213 i18n("&Open"), this, 215 i18n("&Open"), this,
214 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); 216 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN);
215 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), 217 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)),
216 i18n("&Close"), this, 218 i18n("&Close"), this,
217 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); 219 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE);
218 filePopup->insertSeparator(); 220 filePopup->insertSeparator();
219 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), 221 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)),
220 i18n("&Save"), this, 222 i18n("&Save"), this,
221 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); 223 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
222 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), 224 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)),
223 i18n("Save &as..."), 225 i18n("Save &as..."),
224 this, SLOT(saveAs_slot()), 0, 226 this, SLOT(saveAs_slot()), 0,
225 BUTTON_POPUP_FILE_SAVEAS); 227 BUTTON_POPUP_FILE_SAVEAS);
226 filePopup->insertSeparator(); 228 filePopup->insertSeparator();
227 // "file/export" popup menu 229 // "file/export" popup menu
228 exportPopup->insertItem(i18n("&Text-file..."), this, 230 exportPopup->insertItem(i18n("&Text-file..."), this,
229 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); 231 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
230 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 232 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
231 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); 233 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
232#ifdef CONFIG_KWALLETIF 234#ifdef CONFIG_KWALLETIF
233 exportPopup->insertItem(i18n("&KWallet..."), this, 235 exportPopup->insertItem(i18n("&KWallet..."), this,
234 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); 236 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
235#endif 237#endif
236 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), 238 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
237 i18n("E&xport"), exportPopup, 239 i18n("E&xport"), exportPopup,
238 BUTTON_POPUP_FILE_EXPORT); 240 BUTTON_POPUP_FILE_EXPORT);
239 // "file/import" popup menu 241 // "file/import" popup menu
240 importPopup->insertItem(i18n("&Text-file..."), this, 242 importPopup->insertItem(i18n("&Text-file..."), this,
241 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 243 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
242 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 244 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
243 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 245 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
244#ifdef CONFIG_KWALLETIF 246#ifdef CONFIG_KWALLETIF
245 importPopup->insertItem(i18n("&KWallet..."), this, 247 importPopup->insertItem(i18n("&KWallet..."), this,
246 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 248 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
247#endif 249#endif
248 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), 250 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
249 i18n("I&mport"), importPopup, 251 i18n("I&mport"), importPopup,
250 BUTTON_POPUP_FILE_IMPORT); 252 BUTTON_POPUP_FILE_IMPORT);
251 filePopup->insertSeparator(); 253 filePopup->insertSeparator();
252 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), 254 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)),
253 i18n("&Print..."), this, 255 i18n("&Print..."), this,
254 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 256 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
255 filePopup->insertSeparator(); 257 filePopup->insertSeparator();
256 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), 258 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)),
257 i18n("&Quit"), this, 259 i18n("&Quit"), this,
258 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 260 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
259 menuBar()->insertItem(i18n("&File"), filePopup); 261 menuBar()->insertItem(i18n("&File"), filePopup);
260// "manage" popup menu 262// "manage" popup menu
261 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), 263 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
262 i18n("&Add password"), this, 264 i18n("&Add password"), this,
263 SLOT(addPwd_slot()), 0, 265 SLOT(addPwd_slot()), 0,
264 BUTTON_POPUP_MANAGE_ADD); 266 BUTTON_POPUP_MANAGE_ADD);
265 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), 267 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
266 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 268 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
267 BUTTON_POPUP_MANAGE_EDIT); 269 BUTTON_POPUP_MANAGE_EDIT);
268 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 270 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
269 i18n("&Delete"), this, SLOT(deletePwd_slot()), 271 i18n("&Delete"), this, SLOT(deletePwd_slot()),
270 0, BUTTON_POPUP_MANAGE_DEL); 272 0, BUTTON_POPUP_MANAGE_DEL);
271 managePopup->insertSeparator(); 273 managePopup->insertSeparator();
272 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), 274 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
273 i18n("Change &Master Password"), this, 275 i18n("Change &Master Password"), this,
274 SLOT(changeMasterPwd_slot()), 0, 276 SLOT(changeMasterPwd_slot()), 0,
275 BUTTON_POPUP_MANAGE_CHANGEMP); 277 BUTTON_POPUP_MANAGE_CHANGEMP);
276 menuBar()->insertItem(i18n("&Manage"), managePopup); 278 menuBar()->insertItem(i18n("&Manage"), managePopup);
277// "chipcard" popup menu 279// "chipcard" popup menu
278#ifdef CONFIG_KEYCARD 280#ifdef CONFIG_KEYCARD
279 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 281 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
280 i18n("&Generate new key-card"), this, 282 i18n("&Generate new key-card"), this,
281 SLOT(genNewCard_slot()), 0, 283 SLOT(genNewCard_slot()), 0,
282 BUTTON_POPUP_CHIPCARD_GENNEW); 284 BUTTON_POPUP_CHIPCARD_GENNEW);
283 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 285 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
284 i18n("&Erase key-card"), this, 286 i18n("&Erase key-card"), this,
285 SLOT(eraseCard_slot()), 0, 287 SLOT(eraseCard_slot()), 0,
286 BUTTON_POPUP_CHIPCARD_DEL); 288 BUTTON_POPUP_CHIPCARD_DEL);
287 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), 289 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
288 i18n("Read card-&ID"), this, 290 i18n("Read card-&ID"), this,
289 SLOT(readCardId_slot()), 0, 291 SLOT(readCardId_slot()), 0,
290 BUTTON_POPUP_CHIPCARD_READID); 292 BUTTON_POPUP_CHIPCARD_READID);
291 chipcardPopup->insertSeparator(); 293 chipcardPopup->insertSeparator();
292 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), 294 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
293 i18n("&Make card backup-image"), this, 295 i18n("&Make card backup-image"), this,
294 SLOT(makeCardBackup_slot()), 0, 296 SLOT(makeCardBackup_slot()), 0,
295 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 297 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
296 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), 298 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
297 i18n("&Replay card backup-image"), this, 299 i18n("&Replay card backup-image"), this,
298 SLOT(replayCardBackup_slot()), 0, 300 SLOT(replayCardBackup_slot()), 0,
299 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 301 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
300 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 302 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
301#endif // CONFIG_KEYCARD 303#endif // CONFIG_KEYCARD
302// "view" popup menu 304// "view" popup menu
303 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), 305 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
304 i18n("&Find"), this, 306 i18n("&Find"), this,
305 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 307 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
306 viewPopup->insertSeparator(); 308 viewPopup->insertSeparator();
307 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), 309 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
308 i18n("&Lock all entries"), this, 310 i18n("&Lock all entries"), this,
309 SLOT(lockWnd_slot()), 0, 311 SLOT(lockWnd_slot()), 0,
310 BUTTON_POPUP_VIEW_LOCK); 312 BUTTON_POPUP_VIEW_LOCK);
311 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), 313 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
312 i18n("&Deep-lock all entries"), this, 314 i18n("&Deep-lock all entries"), this,
313 SLOT(deepLockWnd_slot()), 0, 315 SLOT(deepLockWnd_slot()), 0,
314 BUTTON_POPUP_VIEW_DEEPLOCK); 316 BUTTON_POPUP_VIEW_DEEPLOCK);
315 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), 317 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
316 i18n("&Unlock all entries"), this, 318 i18n("&Unlock all entries"), this,
317 SLOT(unlockWnd_slot()), 0, 319 SLOT(unlockWnd_slot()), 0,
318 BUTTON_POPUP_VIEW_UNLOCK); 320 BUTTON_POPUP_VIEW_UNLOCK);
319 menuBar()->insertItem(i18n("&View"), viewPopup); 321 menuBar()->insertItem(i18n("&View"), viewPopup);
320// "options" popup menu 322// "options" popup menu
321 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 323 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
322 i18n("&Configure..."), this, 324 i18n("&Configure..."), this,
323 SLOT(config_slot()), 325 SLOT(config_slot()),
324 BUTTON_POPUP_OPTIONS_CONFIG); 326 BUTTON_POPUP_OPTIONS_CONFIG);
325 menuBar()->insertItem(i18n("&Options"), optionsPopup); 327 menuBar()->insertItem(i18n("&Options"), optionsPopup);
326// "help" popup menu 328// "help" popup menu
327#ifndef PWM_EMBEDDED 329#ifndef PWM_EMBEDDED
328 helpPopup = helpMenu(QString::null, false); 330 helpPopup = helpMenu(QString::null, false);
329#else 331#else
332 Popup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
333 i18n("&Configure..."), this,
334 SLOT(config_slot()),
335 BUTTON_POPUP_OPTIONS_CONFIG);
336 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
337 fillSyncMenu();
338
339 menuBar()->insertItem(i18n("&Syncronize"), syncPopup);
340
341
342
343
344
330 helpPopup = new KPopupMenu(this); 345 helpPopup = new KPopupMenu(this);
331 346
332 347
333 helpPopup->insertItem(i18n("&License"), this, 348 helpPopup->insertItem(i18n("&License"), this,
334 SLOT(showLicense_slot()), 0, 349 SLOT(showLicense_slot()), 0,
335 BUTTON_POPUP_HELP_LICENSE); 350 BUTTON_POPUP_HELP_LICENSE);
336 351
337 helpPopup->insertItem(i18n("&Faq"), this, 352 helpPopup->insertItem(i18n("&Faq"), this,
338 SLOT(faq_slot()), 0, 353 SLOT(faq_slot()), 0,
339 BUTTON_POPUP_HELP_FAQ); 354 BUTTON_POPUP_HELP_FAQ);
340 355
341 helpPopup->insertItem(i18n("&About PwManager"), this, 356 helpPopup->insertItem(i18n("&About PwManager"), this,
342 SLOT(createAboutData_slot()), 0, 357 SLOT(createAboutData_slot()), 0,
343 BUTTON_POPUP_HELP_ABOUT); 358 BUTTON_POPUP_HELP_ABOUT);
344 359
345#endif 360#endif
346 menuBar()->insertItem(i18n("&Help"), helpPopup); 361 menuBar()->insertItem(i18n("&Help"), helpPopup);
347 362
348} 363}
349 364
350void PwM::initToolbar() 365void PwM::initToolbar()
351{ 366{
352 KIconLoader* picons; 367 KIconLoader* picons;
353#ifndef PWM_EMBEDDED 368#ifndef PWM_EMBEDDED
354 KIconLoader icons; 369 KIconLoader icons;
355 picons = &icons; 370 picons = &icons;
356#else 371#else
357 picons = KGlobal::iconLoader(); 372 picons = KGlobal::iconLoader();
358#endif 373#endif
359 374
360#ifdef PWM_EMBEDDED 375#ifdef PWM_EMBEDDED
361 if ( QApplication::desktop()->width() > 320 ) 376 if ( QApplication::desktop()->width() > 320 )
362#endif 377#endif
363 { 378 {
364 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), 379 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
365 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 380 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
366 SLOT(new_slot()), true, i18n("New")); 381 SLOT(new_slot()), true, i18n("New"));
367 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), 382 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
368 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 383 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
369 SLOT(open_slot()), true, i18n("Open")); 384 SLOT(open_slot()), true, i18n("Open"));
370 toolBar()->insertSeparator(); 385 toolBar()->insertSeparator();
371 } 386 }
372 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), 387 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
373 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 388 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
374 SLOT(save_slot()), true, i18n("Save")); 389 SLOT(save_slot()), true, i18n("Save"));
375 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), 390 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
376 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 391 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
377 SLOT(saveAs_slot()), true, i18n("Save as")); 392 SLOT(saveAs_slot()), true, i18n("Save as"));
378 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), 393 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
379 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 394 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
380 SLOT(print_slot()), true, i18n("Print...")); 395 SLOT(print_slot()), true, i18n("Print..."));
381 toolBar()->insertSeparator(); 396 toolBar()->insertSeparator();
382 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), 397 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
383 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, 398 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
384 SLOT(addPwd_slot()), true, 399 SLOT(addPwd_slot()), true,
385 i18n("Add password")); 400 i18n("Add password"));
386 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), 401 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
387 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 402 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
388 SLOT(editPwd_slot()), true, 403 SLOT(editPwd_slot()), true,
389 i18n("Edit password")); 404 i18n("Edit password"));
390 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), 405 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
391 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 406 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
392 SLOT(deletePwd_slot()), true, 407 SLOT(deletePwd_slot()), true,
393 i18n("Delete password")); 408 i18n("Delete password"));
394 toolBar()->insertSeparator(); 409 toolBar()->insertSeparator();
395 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), 410 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
396 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, 411 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
397 SLOT(find_slot()), true, i18n("Find entry")); 412 SLOT(find_slot()), true, i18n("Find entry"));
398 toolBar()->insertSeparator(); 413 toolBar()->insertSeparator();
399 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), 414 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
400 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 415 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
401 SLOT(lockWnd_slot()), true, 416 SLOT(lockWnd_slot()), true,
402 i18n("Lock all entries")); 417 i18n("Lock all entries"));
403 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), 418 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
404 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 419 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
405 SLOT(deepLockWnd_slot()), true, 420 SLOT(deepLockWnd_slot()), true,
406 i18n("Deep-Lock all entries")); 421 i18n("Deep-Lock all entries"));
407 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), 422 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
408 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 423 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
409 SLOT(unlockWnd_slot()), true, 424 SLOT(unlockWnd_slot()), true,
410 i18n("Unlock all entries")); 425 i18n("Unlock all entries"));
411} 426}
412 427
413void PwM::initMetrics() 428void PwM::initMetrics()
414{ 429{
415 QSize s = conf()->confWndMainWndSize(); 430 QSize s = conf()->confWndMainWndSize();
416 if (s.isValid()) 431 if (s.isValid())
417 resize(s); 432 resize(s);
418 else 433 else
419 resize(DEFAULT_SIZE); 434 resize(DEFAULT_SIZE);
420} 435}
421 436
422void PwM::updateCaption() 437void PwM::updateCaption()
423{ 438{
424 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); 439 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER);
425} 440}
426 441
427void PwM::hideEvent(QHideEvent *) 442void PwM::hideEvent(QHideEvent *)
428{ 443{
429 if (isMinimized()) { 444 if (isMinimized()) {
430 if (init->tray()) { 445 if (init->tray()) {
431 forceMinimizeToTray = true; 446 forceMinimizeToTray = true;
432 close(); 447 close();
433 } 448 }
434 int mmlock = conf()->confGlobMinimizeLock(); 449 int mmlock = conf()->confGlobMinimizeLock();
435 switch (mmlock) { 450 switch (mmlock) {
436 case 0: // don't lock anything 451 case 0: // don't lock anything
437 break; 452 break;
438 case 1: {// normal lock 453 case 1: {// normal lock
439 curDoc()->lockAll(true); 454 curDoc()->lockAll(true);
440 break; 455 break;
441 } case 2: {// deep-lock 456 } case 2: {// deep-lock
442 curDoc()->deepLock(); 457 curDoc()->deepLock();
443 break; 458 break;
444 } default: 459 } default:
445 WARN(); 460 WARN();
446 } 461 }
447 } 462 }
448} 463}
449 464
450void PwM::setVirgin(bool v) 465void PwM::setVirgin(bool v)
451{ 466{
452 if (virgin == v) 467 if (virgin == v)
453 return; 468 return;
454 virgin = v; 469 virgin = v;
455 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); 470 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
456 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); 471 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
457 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); 472 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
458 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); 473 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
459 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); 474 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
460 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); 475 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
461 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); 476 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
462 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); 477 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
463 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); 478 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
464 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); 479 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
465 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); 480 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
466 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); 481 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
467 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 482 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
468 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 483 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
469 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 484 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
470 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 485 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
471 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 486 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
472 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 487 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
473 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 488 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
474 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 489 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
475} 490}
476 491
477void PwM::new_slot() 492void PwM::new_slot()
478{ 493{
479 init->createMainWnd(); 494 init->createMainWnd();
480} 495}
481 496
482//US ENH 497//US ENH
483void PwM::open_slot() 498void PwM::open_slot()
484{ 499{
485 open_slot(""); 500 open_slot("");
486} 501}
487 502
488void PwM::open_slot(QString fn) 503void PwM::open_slot(QString fn)
489{ 504{
490 openDoc(fn); 505 openDoc(fn);
491} 506}
492 507
493PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 508PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
494{ 509{
495 if (!isVirgin()) { 510 if (!isVirgin()) {
496 // open the document in a new window. 511 // open the document in a new window.
497 PwM *newInstance = init->createMainWnd(); 512 PwM *newInstance = init->createMainWnd();
498 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 513 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
499 if (!newDoc) { 514 if (!newDoc) {
500 newInstance->setForceQuit(true); 515 newInstance->setForceQuit(true);
501 delete_and_null(newInstance); 516 delete_and_null(newInstance);
502 } 517 }
503 return newDoc; 518 return newDoc;
504 } 519 }
505 520
506 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 521 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
507 return 0; 522 return 0;
508 showStatMsg(i18n("Successfully opened file.")); 523 showStatMsg(i18n("Successfully opened file."));
509 updateCaption(); 524 updateCaption();
510 setVirgin(false); 525 setVirgin(false);
511 return curDoc(); 526 return curDoc();
512} 527}
513 528
514PwMView * PwM::makeNewListView(PwMDoc *doc) 529PwMView * PwM::makeNewListView(PwMDoc *doc)
515{ 530{
516 PwMView *ret = new PwMView(this, this, doc); 531 PwMView *ret = new PwMView(this, this, doc);
517 ret->setFont(conf()->confGlobEntryFont()); 532 ret->setFont(conf()->confGlobEntryFont());
518 ret->show(); 533 ret->show();
519 return ret; 534 return ret;
520} 535}
521 536
522void PwM::close_slot() 537void PwM::close_slot()
523{ 538{
524 close(); 539 close();
525} 540}
526 541
527void PwM::quitButton_slot() 542void PwM::quitButton_slot()
528{ 543{
529 init->shutdownApp(0); 544 init->shutdownApp(0);
530} 545}
531 546
532void PwM::save_slot() 547void PwM::save_slot()
533{ 548{
534 save(); 549 save();
535} 550}
536 551
537bool PwM::save() 552bool PwM::save()
538{ 553{
539 if (!curDoc()->saveDocUi(curDoc())) 554 if (!curDoc()->saveDocUi(curDoc()))
540 return false; 555 return false;
541 showStatMsg(i18n("Successfully saved data.")); 556 showStatMsg(i18n("Successfully saved data."));
542 updateCaption(); 557 updateCaption();
543 return true; 558 return true;
544} 559}
545 560
546void PwM::saveAs_slot() 561void PwM::saveAs_slot()
547{ 562{
548 saveAs(); 563 saveAs();
549} 564}
550 565
551bool PwM::saveAs() 566bool PwM::saveAs()
552{ 567{
553 if (!curDoc()->saveAsDocUi(curDoc())) 568 if (!curDoc()->saveAsDocUi(curDoc()))
554 return false; 569 return false;
555 showStatMsg(i18n("Successfully saved data.")); 570 showStatMsg(i18n("Successfully saved data."));
556 updateCaption(); 571 updateCaption();
557 return true; 572 return true;
558} 573}
559 574
560//US ENH : changed code to run with older MOC 575//US ENH : changed code to run with older MOC
561void PwM::addPwd_slot() 576void PwM::addPwd_slot()
562{ 577{
563 addPwd_slot(0, 0); 578 addPwd_slot(0, 0);
564} 579}
565 580
566void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) 581void PwM::addPwd_slot(QString *pw, PwMDoc *_doc)
567{ 582{
568 PwMDoc *doc; 583 PwMDoc *doc;
569 if (_doc) { 584 if (_doc) {
570 doc = _doc; 585 doc = _doc;
571 } else { 586 } else {
572 doc = curDoc(); 587 doc = curDoc();
573 } 588 }
574 PWM_ASSERT(doc); 589 PWM_ASSERT(doc);
575 doc->timer()->getLock(DocTimer::id_autoLockTimer); 590 doc->timer()->getLock(DocTimer::id_autoLockTimer);
576#ifndef PWM_EMBEDDED 591#ifndef PWM_EMBEDDED
577 AddEntryWndImpl w; 592 AddEntryWndImpl w;
578#else 593#else
579 AddEntryWndImpl w(this, "addentrywndimpl"); 594 AddEntryWndImpl w(this, "addentrywndimpl");
580#endif 595#endif
581 596
582 vector<string> catList; 597 vector<string> catList;
583 doc->getCategoryList(&catList); 598 doc->getCategoryList(&catList);
584 unsigned i, size = catList.size(); 599 unsigned i, size = catList.size();
585 for (i = 0; i < size; ++i) { 600 for (i = 0; i < size; ++i) {
586 w.addCategory(catList[i].c_str()); 601 w.addCategory(catList[i].c_str());
587 } 602 }
588 w.setCurrCategory(view->getCurrentCategory()); 603 w.setCurrCategory(view->getCurrentCategory());
589 if (pw) 604 if (pw)
590 w.pwLineEdit->setText(*pw); 605 w.pwLineEdit->setText(*pw);
591 606
592 tryAgain: 607 tryAgain:
593 if (w.exec() == 1) 608 if (w.exec() == 1)
594 { 609 {
595 PwMDataItem d; 610 PwMDataItem d;
596 d.desc = w.getDescription().latin1(); 611 d.desc = w.getDescription().latin1();
597 d.name = w.getUsername().latin1(); 612 d.name = w.getUsername().latin1();
598 d.pw = w.getPassword().latin1(); 613 d.pw = w.getPassword().latin1();
599 d.comment = w.getComment().latin1(); 614 d.comment = w.getComment().latin1();
600 d.url = w.getUrl().latin1(); 615 d.url = w.getUrl().latin1();
601 d.launcher = w.getLauncher().latin1(); 616 d.launcher = w.getLauncher().latin1();
602 PwMerror ret = doc->addEntry(w.getCategory(), &d); 617 PwMerror ret = doc->addEntry(w.getCategory(), &d);
603 if (ret == e_entryExists) { 618 if (ret == e_entryExists) {
604 KMessageBox::error(this, 619 KMessageBox::error(this,
605 i18n 620 i18n
606 ("An entry with this \"Description\", " 621 ("An entry with this \"Description\", "
607 "does already exist.\n" 622 "does already exist.\n"
608 "Please select another description."), 623 "Please select another description."),
609 i18n("entry already exists.")); 624 i18n("entry already exists."));
610 goto tryAgain; 625 goto tryAgain;
611 } else if (ret == e_maxAllowedEntr) { 626 } else if (ret == e_maxAllowedEntr) {
612 KMessageBox::error(this, i18n("The maximum possible number of entries " 627 KMessageBox::error(this, i18n("The maximum possible number of entries "
613 "has been reached. You can't add more entries."), 628 "has been reached. You can't add more entries."),
614 i18n("maximum number of entries")); 629 i18n("maximum number of entries"));
615 doc->timer()->putLock(DocTimer::id_autoLockTimer); 630 doc->timer()->putLock(DocTimer::id_autoLockTimer);
616 return; 631 return;
617 } 632 }
618 } 633 }
619 setVirgin(false); 634 setVirgin(false);
620 doc->timer()->putLock(DocTimer::id_autoLockTimer); 635 doc->timer()->putLock(DocTimer::id_autoLockTimer);
621} 636}
622 637
623//US ENH : changed code to run with older MOC 638//US ENH : changed code to run with older MOC
624void PwM::editPwd_slot() 639void PwM::editPwd_slot()
625{ 640{
626 editPwd_slot(0,0,0); 641 editPwd_slot(0,0,0);
627} 642}
628 643
629void PwM::editPwd_slot(const QString *category) 644void PwM::editPwd_slot(const QString *category)
630{ 645{
631 editPwd_slot(category, 0, 0); 646 editPwd_slot(category, 0, 0);
632} 647}
633 648
634void PwM::editPwd_slot(const QString *category, const int *index, 649void PwM::editPwd_slot(const QString *category, const int *index,
635 PwMDoc *_doc) 650 PwMDoc *_doc)
636{ 651{
637 PwMDoc *doc; 652 PwMDoc *doc;
638 if (_doc) { 653 if (_doc) {
639 doc = _doc; 654 doc = _doc;
640 } else { 655 } else {
641 doc = curDoc(); 656 doc = curDoc();
642 } 657 }
643 PWM_ASSERT(doc); 658 PWM_ASSERT(doc);
644 if (doc->isDocEmpty()) 659 if (doc->isDocEmpty())
645 return; 660 return;
646 if (doc->isDeepLocked()) 661 if (doc->isDeepLocked())
647 return; 662 return;
648 doc->timer()->getLock(DocTimer::id_autoLockTimer); 663 doc->timer()->getLock(DocTimer::id_autoLockTimer);
649 unsigned int curEntryIndex; 664 unsigned int curEntryIndex;
650 if (index) { 665 if (index) {
651 curEntryIndex = *index; 666 curEntryIndex = *index;
652 } else { 667 } else {
653 if (!(view->getCurEntryIndex(&curEntryIndex))) { 668 if (!(view->getCurEntryIndex(&curEntryIndex))) {
654 printDebug("couldn't get index. Maybe we have a binary entry here."); 669 printDebug("couldn't get index. Maybe we have a binary entry here.");
655 doc->timer()->putLock(DocTimer::id_autoLockTimer); 670 doc->timer()->putLock(DocTimer::id_autoLockTimer);
656 return; 671 return;
657 } 672 }
658 } 673 }
659 QString curCategory; 674 QString curCategory;
660 if (category) { 675 if (category) {
661 curCategory = *category; 676 curCategory = *category;
662 } else { 677 } else {
663 curCategory = view->getCurrentCategory(); 678 curCategory = view->getCurrentCategory();
664 } 679 }
665 PwMDataItem currItem; 680 PwMDataItem currItem;
666 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 681 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
667 doc->timer()->putLock(DocTimer::id_autoLockTimer); 682 doc->timer()->putLock(DocTimer::id_autoLockTimer);
668 return; 683 return;
669 } 684 }
670 BUG_ON(currItem.binary); 685 BUG_ON(currItem.binary);
671 686
672 AddEntryWndImpl w; 687 AddEntryWndImpl w;
673 vector<string> catList; 688 vector<string> catList;
674 doc->getCategoryList(&catList); 689 doc->getCategoryList(&catList);
675 unsigned i, size = catList.size(); 690 unsigned i, size = catList.size();
676 for (i = 0; i < size; ++i) { 691 for (i = 0; i < size; ++i) {
677 w.addCategory(catList[i].c_str()); 692 w.addCategory(catList[i].c_str());
678 } 693 }
679 w.setCurrCategory(curCategory); 694 w.setCurrCategory(curCategory);
680 w.setDescription(currItem.desc.c_str()); 695 w.setDescription(currItem.desc.c_str());
681 w.setUsername(currItem.name.c_str()); 696 w.setUsername(currItem.name.c_str());
682 w.setPassword(currItem.pw.c_str()); 697 w.setPassword(currItem.pw.c_str());
683 w.setUrl(currItem.url.c_str()); 698 w.setUrl(currItem.url.c_str());
684 w.setLauncher(currItem.launcher.c_str()); 699 w.setLauncher(currItem.launcher.c_str());
685 w.setComment(currItem.comment.c_str()); 700 w.setComment(currItem.comment.c_str());
686 if (w.exec() == 1) { 701 if (w.exec() == 1) {
687 currItem.desc = w.getDescription().latin1(); 702 currItem.desc = w.getDescription().latin1();
688 currItem.name = w.getUsername().latin1(); 703 currItem.name = w.getUsername().latin1();
689 currItem.pw = w.getPassword().latin1(); 704 currItem.pw = w.getPassword().latin1();
690 currItem.comment = w.getComment().latin1(); 705 currItem.comment = w.getComment().latin1();
691 currItem.url = w.getUrl().latin1(); 706 currItem.url = w.getUrl().latin1();
692 currItem.launcher = w.getLauncher().latin1(); 707 currItem.launcher = w.getLauncher().latin1();
693 if (!doc->editEntry(curCategory, w.getCategory(), 708 if (!doc->editEntry(curCategory, w.getCategory(),
694 curEntryIndex, &currItem)) { 709 curEntryIndex, &currItem)) {
695 KMessageBox::error(this, 710 KMessageBox::error(this,
696 i18n("Couldn't edit the entry.\n" 711 i18n("Couldn't edit the entry.\n"
697 "Maybe you changed the category and " 712 "Maybe you changed the category and "
698 "this entry is already present in the new " 713 "this entry is already present in the new "
699 "category?"), 714 "category?"),
700 i18n("couldn't edit entry.")); 715 i18n("couldn't edit entry."));
701 doc->timer()->putLock(DocTimer::id_autoLockTimer); 716 doc->timer()->putLock(DocTimer::id_autoLockTimer);
702 return; 717 return;
703 } 718 }
704 } 719 }
705 doc->timer()->putLock(DocTimer::id_autoLockTimer); 720 doc->timer()->putLock(DocTimer::id_autoLockTimer);
706} 721}
707 722
708void PwM::deletePwd_slot() 723void PwM::deletePwd_slot()
709{ 724{
710 PWM_ASSERT(curDoc()); 725 PWM_ASSERT(curDoc());
711 if (curDoc()->isDocEmpty()) 726 if (curDoc()->isDocEmpty())
712 return; 727 return;
713 if (curDoc()->isDeepLocked()) 728 if (curDoc()->isDeepLocked())
714 return; 729 return;
715 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 730 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
716 unsigned int curEntryIndex = 0; 731 unsigned int curEntryIndex = 0;
717 if (!(view->getCurEntryIndex(&curEntryIndex))) { 732 if (!(view->getCurEntryIndex(&curEntryIndex))) {
718 printDebug("couldn't get index"); 733 printDebug("couldn't get index");
719 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 734 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
720 return; 735 return;
721 } 736 }
722 737
723 PwMDataItem currItem; 738 PwMDataItem currItem;
724 QString curCategory = view->getCurrentCategory(); 739 QString curCategory = view->getCurrentCategory();
725 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 740 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
726 printDebug("couldn't get entry"); 741 printDebug("couldn't get entry");
727 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 742 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
728 return; 743 return;
729 } 744 }
730 if (KMessageBox:: 745 if (KMessageBox::
731 questionYesNo(this, 746 questionYesNo(this,
732 i18n 747 i18n
733 ("Do you really want to delete\nthe selected entry") + 748 ("Do you really want to delete\nthe selected entry") +
734 " \n\"" + QString(currItem.desc.c_str()) 749 " \n\"" + QString(currItem.desc.c_str())
735 + "\" ?", i18n("delete?")) 750 + "\" ?", i18n("delete?"))
736 == KMessageBox::Yes) { 751 == KMessageBox::Yes) {
737 752
738 curDoc()->delEntry(curCategory, curEntryIndex); 753 curDoc()->delEntry(curCategory, curEntryIndex);
739 } 754 }
740 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 755 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
741} 756}
742 757
743void PwM::changeMasterPwd_slot() 758void PwM::changeMasterPwd_slot()
744{ 759{
745 PWM_ASSERT(curDoc()); 760 PWM_ASSERT(curDoc());
746 curDoc()->changeCurrentPw(); 761 curDoc()->changeCurrentPw();
747} 762}
748 763
749void PwM::lockWnd_slot() 764void PwM::lockWnd_slot()
750{ 765{
751 PWM_ASSERT(curDoc()); 766 PWM_ASSERT(curDoc());
752 curDoc()->lockAll(true); 767 curDoc()->lockAll(true);
753} 768}
754 769
755void PwM::deepLockWnd_slot() 770void PwM::deepLockWnd_slot()
756{ 771{
757 PWM_ASSERT(curDoc()); 772 PWM_ASSERT(curDoc());
758 curDoc()->deepLock(); 773 curDoc()->deepLock();
759} 774}
760 775
761void PwM::unlockWnd_slot() 776void PwM::unlockWnd_slot()
762{ 777{
763 PWM_ASSERT(curDoc()); 778 PWM_ASSERT(curDoc());
764 curDoc()->lockAll(false); 779 curDoc()->lockAll(false);
765} 780}
766 781
767void PwM::config_slot() 782void PwM::config_slot()
768{ 783{
769 int oldStyle = conf()->confWndMainViewStyle(); 784 int oldStyle = conf()->confWndMainViewStyle();
770#ifdef PWM_EMBEDDED 785#ifdef PWM_EMBEDDED
771 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); 786 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true );
772 787
773 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); 788 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" );
774 ConfigureDialog->addModule(pwmcfg ); 789 ConfigureDialog->addModule(pwmcfg );
775 790
776 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 791 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
777 ConfigureDialog->addModule(kdelibcfg ); 792 ConfigureDialog->addModule(kdelibcfg );
778 793
779#ifndef DESKTOP_VERSION 794#ifndef DESKTOP_VERSION
780 ConfigureDialog->showMaximized(); 795 ConfigureDialog->showMaximized();
781#endif 796#endif
782 if ( ConfigureDialog->exec() ) 797 if ( ConfigureDialog->exec() )
783 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 798 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
784 delete ConfigureDialog; 799 delete ConfigureDialog;
785 800
786#else //PWM_EMBEDDED 801#else //PWM_EMBEDDED
787 // display the configuration window (modal mode) 802 // display the configuration window (modal mode)
788 if (!conf()->showConfWnd(this)) 803 if (!conf()->showConfWnd(this))
789 return; 804 return;
790#endif 805#endif
791 806
792 int newStyle = conf()->confWndMainViewStyle(); 807 int newStyle = conf()->confWndMainViewStyle();
793 // reinitialize tray 808 // reinitialize tray
794 init->initTray(); 809 init->initTray();
795 // reinitialize KWallet emulation 810 // reinitialize KWallet emulation
796 init->initKWalletEmu(); 811 init->initKWalletEmu();
797 812
798 PwMDocList *_dl = PwMDoc::getOpenDocList(); 813 PwMDocList *_dl = PwMDoc::getOpenDocList();
799 const vector<PwMDocList::listItem> *dl = _dl->getList(); 814 const vector<PwMDocList::listItem> *dl = _dl->getList();
800 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 815 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
801 end = dl->end(); 816 end = dl->end();
802 PwMDoc *doc; 817 PwMDoc *doc;
803 while (i != end) { 818 while (i != end) {
804 doc = (*i).doc; 819 doc = (*i).doc;
805 // unlock-without-mpw timeout 820 // unlock-without-mpw timeout
806 doc->timer()->start(DocTimer::id_mpwTimer); 821 doc->timer()->start(DocTimer::id_mpwTimer);
807 // auto-lock timeout 822 // auto-lock timeout
808 doc->timer()->start(DocTimer::id_autoLockTimer); 823 doc->timer()->start(DocTimer::id_autoLockTimer);
809 ++i; 824 ++i;
810 } 825 }
811 826
812 const QValueList<PwM *> *ml = init->mainWndList(); 827 const QValueList<PwM *> *ml = init->mainWndList();
813#ifndef PWM_EMBEDDED 828#ifndef PWM_EMBEDDED
814 QValueList<PwM *>::const_iterator i2 = ml->begin(), 829 QValueList<PwM *>::const_iterator i2 = ml->begin(),
815 end2 = ml->end(); 830 end2 = ml->end();
816#else 831#else
817 QValueList<PwM *>::ConstIterator i2 = ml->begin(), 832 QValueList<PwM *>::ConstIterator i2 = ml->begin(),
818 end2 = ml->end(); 833 end2 = ml->end();
819#endif 834#endif
820 PwM *pwm; 835 PwM *pwm;
821 while (i2 != end2) { 836 while (i2 != end2) {
822 pwm = *i2; 837 pwm = *i2;
823 // reinitialize the window style. 838 // reinitialize the window style.
824 if (oldStyle != newStyle) 839 if (oldStyle != newStyle)
825 pwm->curView()->initStyle(newStyle); 840 pwm->curView()->initStyle(newStyle);
826 // set the new font 841 // set the new font
827 pwm->curView()->setFont(conf()->confGlobEntryFont()); 842 pwm->curView()->setFont(conf()->confGlobEntryFont());
828 ++i2; 843 ++i2;
829 } 844 }
830} 845}
831 846
832void PwM::activateMpButton(bool activate) 847void PwM::activateMpButton(bool activate)
833{ 848{
834 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); 849 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
835} 850}
836 851
837void PwM::closeEvent(QCloseEvent *e) 852void PwM::closeEvent(QCloseEvent *e)
838{ 853{
839 e->accept(); 854 e->accept();
840} 855}
841 856
842void PwM::docClosed(PwMDoc *doc) 857void PwM::docClosed(PwMDoc *doc)
843{ 858{
844 PARAM_UNUSED(doc); 859 PARAM_UNUSED(doc);
845 PWM_ASSERT(doc == curDoc()); 860 PWM_ASSERT(doc == curDoc());
846 close(); 861 close();
847} 862}
848 863
849void PwM::find_slot() 864void PwM::find_slot()
850{ 865{
851 PWM_ASSERT(curDoc()); 866 PWM_ASSERT(curDoc());
852 if (curDoc()->isDocEmpty()) 867 if (curDoc()->isDocEmpty())
853 return; 868 return;
854 if (curDoc()->isDeepLocked()) 869 if (curDoc()->isDeepLocked())
855 return; 870 return;
856 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 871 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
857 FindWndImpl findWnd(view); 872 FindWndImpl findWnd(view);
858 findWnd.exec(); 873 findWnd.exec();
859 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 874 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
860} 875}
861 876
862void PwM::exportToText() 877void PwM::exportToText()
863{ 878{
864 PWM_ASSERT(curDoc()); 879 PWM_ASSERT(curDoc());
865 if (curDoc()->isDocEmpty()) { 880 if (curDoc()->isDocEmpty()) {
866 KMessageBox::information(this, 881 KMessageBox::information(this,
867 i18n 882 i18n
868 ("Sorry, there's nothing to export.\n" 883 ("Sorry, there's nothing to export.\n"
869 "Please first add some passwords."), 884 "Please first add some passwords."),
870 i18n("nothing to do")); 885 i18n("nothing to do"));
871 return; 886 return;
872 } 887 }
873 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 888 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
874 QString fn(KFileDialog::getSaveFileName(QString::null, 889 QString fn(KFileDialog::getSaveFileName(QString::null,
875 i18n("*|plain-text file"), 890 i18n("*|plain-text file"),
876 this)); 891 this));
877 if (fn == "") { 892 if (fn == "") {
878 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 893 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
879 return; 894 return;
880 } 895 }
881 896
882 PwMerror ret = curDoc()->exportToText(&fn); 897 PwMerror ret = curDoc()->exportToText(&fn);
883 if (ret != e_success) { 898 if (ret != e_success) {
884 KMessageBox::error(this, 899 KMessageBox::error(this,
885 i18n("Error: Couldn't write to file.\n" 900 i18n("Error: Couldn't write to file.\n"
886 "Please check if you have permission to write " 901 "Please check if you have permission to write "
887 "to the file in that directory."), 902 "to the file in that directory."),
888 i18n("error while writing")); 903 i18n("error while writing"));
889 } else 904 } else
890 showStatMsg(i18n("Successfully exported data.")); 905 showStatMsg(i18n("Successfully exported data."));
891 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 906 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
892} 907}
893 908
894bool PwM::importFromText() 909bool PwM::importFromText()
895{ 910{
896 if (!isVirgin()) { 911 if (!isVirgin()) {
897 if (KMessageBox::questionYesNo(this, 912 if (KMessageBox::questionYesNo(this,
898 i18n("Do you want to import the data " 913 i18n("Do you want to import the data "
899 "into the current document? (If you " 914 "into the current document? (If you "
900 "select \"no\", a new document will be " 915 "select \"no\", a new document will be "
901 "opened.)"), 916 "opened.)"),
902 i18n("import into this document?")) 917 i18n("import into this document?"))
903 == KMessageBox::No) { 918 == KMessageBox::No) {
904 // import the data to a new window. 919 // import the data to a new window.
905 PwM *newInstance = init->createMainWnd(); 920 PwM *newInstance = init->createMainWnd();
906 bool ok = newInstance->importFromText(); 921 bool ok = newInstance->importFromText();
907 if (!ok) { 922 if (!ok) {
908 newInstance->setForceQuit(true); 923 newInstance->setForceQuit(true);
909 delete_and_null(newInstance); 924 delete_and_null(newInstance);
910 } 925 }
911 return ok; 926 return ok;
912 } 927 }
913 } 928 }
914 929
915 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 930 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
916 PwMerror ret; 931 PwMerror ret;
917 QString path(KFileDialog::getOpenFileName(QString::null, 932 QString path(KFileDialog::getOpenFileName(QString::null,
918 i18n("*|PWM-exported text file"), 933 i18n("*|PWM-exported text file"),
919 this)); 934 this));
920 if (path == "") 935 if (path == "")
921 goto cancelImport; 936 goto cancelImport;
922 937
923 ret = curDoc()->importFromText(&path, 0); 938 ret = curDoc()->importFromText(&path, 0);
924 if (ret == e_fileFormat) { 939 if (ret == e_fileFormat) {
925 KMessageBox::error(this, 940 KMessageBox::error(this,
926 i18n("Could not read file-format.\n" 941 i18n("Could not read file-format.\n"
927 "This seems to be _not_ a valid file " 942 "This seems to be _not_ a valid file "
928 "exported by PwM."), 943 "exported by PwM."),
929 i18n("invalid file-format")); 944 i18n("invalid file-format"));
930 goto cancelImport; 945 goto cancelImport;
931 } else if (ret == e_invalidArg) { 946 } else if (ret == e_invalidArg) {
932 BUG(); 947 BUG();
933 goto cancelImport; 948 goto cancelImport;
934 } else if (ret != e_success) { 949 } else if (ret != e_success) {
935 KMessageBox::error(this, 950 KMessageBox::error(this,
936 i18n("Could not import file!\n" 951 i18n("Could not import file!\n"
937 "Do you have permission to read this file? " 952 "Do you have permission to read this file? "
938 "Do you have enough free memory?"), 953 "Do you have enough free memory?"),
939 i18n("import failed")); 954 i18n("import failed"));
940 goto cancelImport; 955 goto cancelImport;
941 } 956 }
942 setVirgin(false); 957 setVirgin(false);
943 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 958 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
944 return true; 959 return true;
945 960
946cancelImport: 961cancelImport:
947 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 962 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
948 return false; 963 return false;
949} 964}
950 965
951void PwM::exportToGpasman() 966void PwM::exportToGpasman()
952{ 967{
953 PWM_ASSERT(curDoc()); 968 PWM_ASSERT(curDoc());
954 if (curDoc()->isDocEmpty()) { 969 if (curDoc()->isDocEmpty()) {
955 KMessageBox::information(this, 970 KMessageBox::information(this,
956 i18n 971 i18n
957 ("Sorry, there's nothing to export.\n" 972 ("Sorry, there's nothing to export.\n"
958 "Please first add some passwords."), 973 "Please first add some passwords."),
959 i18n("nothing to do")); 974 i18n("nothing to do"));
960 return; 975 return;
961 } 976 }
962 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 977 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
963 QString fn(KFileDialog::getSaveFileName(QString::null, 978 QString fn(KFileDialog::getSaveFileName(QString::null,
964 i18n("*|Gpasman or Kpasman file"), 979 i18n("*|Gpasman or Kpasman file"),
965 this)); 980 this));
966 if (fn == "") { 981 if (fn == "") {
967 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 982 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
968 return; 983 return;
969 } 984 }
970 985
971 PwMerror ret = curDoc()->exportToGpasman(&fn); 986 PwMerror ret = curDoc()->exportToGpasman(&fn);
972 if (ret != e_success) { 987 if (ret != e_success) {
973 if (ret == e_noPw) { 988 if (ret == e_noPw) {
974 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 989 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
975 return; 990 return;
976 } 991 }
977 KMessageBox::error(this, 992 KMessageBox::error(this,
978 i18n("Error: Couldn't write to file.\n" 993 i18n("Error: Couldn't write to file.\n"
979 "Please check if you have permission to write " 994 "Please check if you have permission to write "
980 "to the file in that directory."), 995 "to the file in that directory."),
981 i18n("error while writing")); 996 i18n("error while writing"));
982 } else 997 } else
983 showStatMsg(i18n("Successfully exported data.")); 998 showStatMsg(i18n("Successfully exported data."));
984 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 999 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
985} 1000}
986 1001
987void PwM::exportToKWallet() 1002void PwM::exportToKWallet()
988{ 1003{
989#ifdef CONFIG_KWALLETIF 1004#ifdef CONFIG_KWALLETIF
990 if (!checkAndAskForKWalletEmu()) 1005 if (!checkAndAskForKWalletEmu())
991 return; 1006 return;
992 PWM_ASSERT(curDoc()); 1007 PWM_ASSERT(curDoc());
993 if (curDoc()->isDocEmpty()) { 1008 if (curDoc()->isDocEmpty()) {
994 KMessageBox::information(this, 1009 KMessageBox::information(this,
995 i18n 1010 i18n
996 ("Sorry, there's nothing to export.\n" 1011 ("Sorry, there's nothing to export.\n"
997 "Please first add some passwords."), 1012 "Please first add some passwords."),
998 i18n("nothing to do")); 1013 i18n("nothing to do"));
999 init->initKWalletEmu(); 1014 init->initKWalletEmu();
1000 return; 1015 return;
1001 } 1016 }
1002 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1017 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1003 KWalletIf walletIf(this); 1018 KWalletIf walletIf(this);
1004 if (walletIf.kwalletExport(curDoc())) { 1019 if (walletIf.kwalletExport(curDoc())) {
1005 KMessageBox::information(this, 1020 KMessageBox::information(this,
1006 i18n("Successfully exported the data of the current " 1021 i18n("Successfully exported the data of the current "
1007 "document to KWallet."), 1022 "document to KWallet."),
1008 i18n("Successfully exported data.")); 1023 i18n("Successfully exported data."));
1009 showStatMsg(i18n("Successfully exported data.")); 1024 showStatMsg(i18n("Successfully exported data."));
1010 } 1025 }
1011 init->initKWalletEmu(); 1026 init->initKWalletEmu();
1012 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1027 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1013#endif // CONFIG_KWALLETIF 1028#endif // CONFIG_KWALLETIF
1014} 1029}
1015 1030
1016bool PwM::importFromGpasman() 1031bool PwM::importFromGpasman()
1017{ 1032{
1018 if (!isVirgin()) { 1033 if (!isVirgin()) {
1019 if (KMessageBox::questionYesNo(this, 1034 if (KMessageBox::questionYesNo(this,
1020 i18n("Do you want to import the data " 1035 i18n("Do you want to import the data "
1021 "into the current document? (If you " 1036 "into the current document? (If you "
1022 "select \"no\", a new document will be " 1037 "select \"no\", a new document will be "
1023 "opened.)"), 1038 "opened.)"),
1024 i18n("import into this document?")) 1039 i18n("import into this document?"))
1025 == KMessageBox::No) { 1040 == KMessageBox::No) {
1026 // import the data to a new window. 1041 // import the data to a new window.
1027 PwM *newInstance = init->createMainWnd(); 1042 PwM *newInstance = init->createMainWnd();
1028 bool ok = newInstance->importFromGpasman(); 1043 bool ok = newInstance->importFromGpasman();
1029 if (!ok) { 1044 if (!ok) {
1030 newInstance->setForceQuit(true); 1045 newInstance->setForceQuit(true);
1031 delete_and_null(newInstance); 1046 delete_and_null(newInstance);
1032 } 1047 }
1033 return ok; 1048 return ok;
1034 } 1049 }
1035 } 1050 }
1036 1051
1037 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1052 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1038 PwMerror ret; 1053 PwMerror ret;
1039 QString path(KFileDialog::getOpenFileName(QString::null, 1054 QString path(KFileDialog::getOpenFileName(QString::null,
1040 i18n("*|Gpasman or Kpasman file"), this)); 1055 i18n("*|Gpasman or Kpasman file"), this));
1041 if (path == "") 1056 if (path == "")
1042 goto cancelImport; 1057 goto cancelImport;
1043 ret = curDoc()->importFromGpasman(&path); 1058 ret = curDoc()->importFromGpasman(&path);
1044 if (ret == e_wrongPw) { 1059 if (ret == e_wrongPw) {
1045 if (KMessageBox::questionYesNo(this, 1060 if (KMessageBox::questionYesNo(this,
1046 i18n 1061 i18n
1047 ("This is probably the wrong master-password" 1062 ("This is probably the wrong master-password"
1048 "you have typed in.\n" 1063 "you have typed in.\n"
1049 "There is no real way to determine the " 1064 "There is no real way to determine the "
1050 "correctness of the password in the Gpasman " 1065 "correctness of the password in the Gpasman "
1051 "file-format. But I think this " 1066 "file-format. But I think this "
1052 "password ist wrong.\n" 1067 "password ist wrong.\n"
1053 "Do you want to continue nevertheless?"), 1068 "Do you want to continue nevertheless?"),
1054 i18n("password error")) 1069 i18n("password error"))
1055 == KMessageBox::No) { 1070 == KMessageBox::No) {
1056 goto cancelImport; 1071 goto cancelImport;
1057 } 1072 }
1058 } else if (ret != e_success) { 1073 } else if (ret != e_success) {
1059 KMessageBox::error(this, 1074 KMessageBox::error(this,
1060 i18n("Could not import file!\n" 1075 i18n("Could not import file!\n"
1061 "Do you have permission to read this file?"), 1076 "Do you have permission to read this file?"),
1062 i18n("import failed")); 1077 i18n("import failed"));
1063 goto cancelImport; 1078 goto cancelImport;
1064 } 1079 }
1065 setVirgin(false); 1080 setVirgin(false);
1066 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1081 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1067 return true; 1082 return true;
1068 1083
1069cancelImport: 1084cancelImport:
1070 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1085 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1071 return false; 1086 return false;
1072} 1087}
1073 1088
1074#ifdef CONFIG_KWALLETIF 1089#ifdef CONFIG_KWALLETIF
1075bool PwM::checkAndAskForKWalletEmu() 1090bool PwM::checkAndAskForKWalletEmu()
1076{ 1091{
1077 if (init->kwalletEmu()) { 1092 if (init->kwalletEmu()) {
1078 /* KWallet emulation is enabled. We can't import/export 1093 /* KWallet emulation is enabled. We can't import/export
1079 * data from/to it, while emulation is active. 1094 * data from/to it, while emulation is active.
1080 */ 1095 */
1081 if (KMessageBox::questionYesNo(this, 1096 if (KMessageBox::questionYesNo(this,
1082 i18n("KWallet emulation is enabled.\n" 1097 i18n("KWallet emulation is enabled.\n"
1083 "You can't import or export data from/to " 1098 "You can't import or export data from/to "
1084 "the original KWallet, while the emulation " 1099 "the original KWallet, while the emulation "
1085 "is active.\n" 1100 "is active.\n"
1086 "Do you want to tempoarly disable the KWallet emulation?"), 1101 "Do you want to tempoarly disable the KWallet emulation?"),
1087 i18n("Tempoarly disable KWallet emulation?")) 1102 i18n("Tempoarly disable KWallet emulation?"))
1088 == KMessageBox::Yes) { 1103 == KMessageBox::Yes) {
1089 init->initKWalletEmu(true); 1104 init->initKWalletEmu(true);
1090 PWM_ASSERT(!init->kwalletEmu()); 1105 PWM_ASSERT(!init->kwalletEmu());
1091 return true; 1106 return true;
1092 } 1107 }
1093 return false; 1108 return false;
1094 } 1109 }
1095 return true; 1110 return true;
1096} 1111}
1097#endif // CONFIG_KWALLETIF 1112#endif // CONFIG_KWALLETIF