summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwm.cpp167
-rw-r--r--pwmanager/pwmanager/pwm.h6
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp17
3 files changed, 152 insertions, 38 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 0e57650..e5579f8 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1,1192 +1,1283 @@
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#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qmessagebox.h>
33#endif 34#endif
34 35
35#include <qpixmap.h> 36#include <qpixmap.h>
36#include <qcheckbox.h> 37#include <qcheckbox.h>
37#include <qspinbox.h> 38#include <qspinbox.h>
38#include <qlineedit.h> 39#include <qlineedit.h>
39#include <qfileinfo.h> 40#include <qfileinfo.h>
40#include <qclipboard.h> 41#include <qclipboard.h>
41 42
42 43
43#include <stdio.h> 44#include <stdio.h>
44 45
45#include "pwm.h" 46#include "pwm.h"
46#include "pwminit.h" 47#include "pwminit.h"
47#include "configwndimpl.h" 48#include "configwndimpl.h"
48#include "pwmprint.h" 49#include "pwmprint.h"
49#include "addentrywndimpl.h" 50#include "addentrywndimpl.h"
50#include "globalstuff.h" 51#include "globalstuff.h"
51#include "findwndimpl.h" 52#include "findwndimpl.h"
52#include "configuration.h" 53#include "configuration.h"
53 54
54#ifdef CONFIG_KWALLETIF 55#ifdef CONFIG_KWALLETIF
55# include "kwalletif.h" 56# include "kwalletif.h"
56# include "kwalletemu.h" 57# include "kwalletemu.h"
57#endif 58#endif
58#ifdef CONFIG_KEYCARD 59#ifdef CONFIG_KEYCARD
59# include "pwmkeycard.h" 60# include "pwmkeycard.h"
60#endif 61#endif
61 62
62 63
63 #define DEFAULT_SIZE (QSize(700, 400)) 64 #define DEFAULT_SIZE (QSize(700, 400))
64 65
65// Button IDs for "file" popup menu 66// Button IDs for "file" popup menu
66enum { 67enum {
67 BUTTON_POPUP_FILE_NEW = 0, 68 BUTTON_POPUP_FILE_NEW = 0,
68 BUTTON_POPUP_FILE_OPEN, 69 BUTTON_POPUP_FILE_OPEN,
69 BUTTON_POPUP_FILE_CLOSE, 70 BUTTON_POPUP_FILE_CLOSE,
70 BUTTON_POPUP_FILE_SAVE, 71 BUTTON_POPUP_FILE_SAVE,
71 BUTTON_POPUP_FILE_SAVEAS, 72 BUTTON_POPUP_FILE_SAVEAS,
72 BUTTON_POPUP_FILE_EXPORT, 73 BUTTON_POPUP_FILE_EXPORT,
73 BUTTON_POPUP_FILE_IMPORT, 74 BUTTON_POPUP_FILE_IMPORT,
74 BUTTON_POPUP_FILE_PRINT, 75 BUTTON_POPUP_FILE_PRINT,
75 BUTTON_POPUP_FILE_QUIT 76 BUTTON_POPUP_FILE_QUIT
76}; 77};
77// Button IDs for "manage" popup menu 78// Button IDs for "manage" popup menu
78enum { 79enum {
79 BUTTON_POPUP_MANAGE_ADD = 0, 80 BUTTON_POPUP_MANAGE_ADD = 0,
80 BUTTON_POPUP_MANAGE_EDIT, 81 BUTTON_POPUP_MANAGE_EDIT,
81 BUTTON_POPUP_MANAGE_DEL, 82 BUTTON_POPUP_MANAGE_DEL,
82 BUTTON_POPUP_MANAGE_CHANGEMP 83 BUTTON_POPUP_MANAGE_CHANGEMP
83}; 84};
84// Button IDs for chipcard popup menu 85// Button IDs for chipcard popup menu
85enum { 86enum {
86#ifdef CONFIG_KEYCARD 87#ifdef CONFIG_KEYCARD
87 BUTTON_POPUP_CHIPCARD_GENNEW = 0, 88 BUTTON_POPUP_CHIPCARD_GENNEW = 0,
88 BUTTON_POPUP_CHIPCARD_DEL, 89 BUTTON_POPUP_CHIPCARD_DEL,
89 BUTTON_POPUP_CHIPCARD_READID, 90 BUTTON_POPUP_CHIPCARD_READID,
90 BUTTON_POPUP_CHIPCARD_SAVEBACKUP, 91 BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
91 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP 92 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
92#else // CONFIG_KEYCARD 93#else // CONFIG_KEYCARD
93 BUTTON_POPUP_CHIPCARD_NO = 0 94 BUTTON_POPUP_CHIPCARD_NO = 0
94#endif // CONFIG_KEYCARD 95#endif // CONFIG_KEYCARD
95}; 96};
96// Button IDs for "view" popup menu 97// Button IDs for "view" popup menu
97enum { 98enum {
98 BUTTON_POPUP_VIEW_FIND = 0, 99 BUTTON_POPUP_VIEW_FIND = 0,
99 BUTTON_POPUP_VIEW_LOCK, 100 BUTTON_POPUP_VIEW_LOCK,
100 BUTTON_POPUP_VIEW_DEEPLOCK, 101 BUTTON_POPUP_VIEW_DEEPLOCK,
101 BUTTON_POPUP_VIEW_UNLOCK 102 BUTTON_POPUP_VIEW_UNLOCK
102}; 103};
103// Button IDs for "options" popup menu 104// Button IDs for "options" popup menu
104enum { 105enum {
105 BUTTON_POPUP_OPTIONS_CONFIG = 0 106 BUTTON_POPUP_OPTIONS_CONFIG = 0
106}; 107};
107// Button IDs for "export" popup menu (in "file" popup menu) 108// Button IDs for "export" popup menu (in "file" popup menu)
108enum { 109enum {
109 BUTTON_POPUP_EXPORT_TEXT = 0, 110 BUTTON_POPUP_EXPORT_TEXT = 0,
110 BUTTON_POPUP_EXPORT_GPASMAN 111 BUTTON_POPUP_EXPORT_GPASMAN
111#ifdef CONFIG_KWALLETIF 112#ifdef CONFIG_KWALLETIF
112 ,BUTTON_POPUP_EXPORT_KWALLET 113 ,BUTTON_POPUP_EXPORT_KWALLET
113#endif 114#endif
114}; 115};
115// Button IDs for "import" popup menu (in "file" popup menu) 116// Button IDs for "import" popup menu (in "file" popup menu)
116enum { 117enum {
117 BUTTON_POPUP_IMPORT_TEXT = 0, 118 BUTTON_POPUP_IMPORT_TEXT = 0,
118 BUTTON_POPUP_IMPORT_GPASMAN 119 BUTTON_POPUP_IMPORT_GPASMAN
119#ifdef CONFIG_KWALLETIF 120#ifdef CONFIG_KWALLETIF
120 ,BUTTON_POPUP_IMPORT_KWALLET 121 ,BUTTON_POPUP_IMPORT_KWALLET
121#endif 122#endif
122}; 123};
124
125#ifdef PWM_EMBEDDED
126// Button IDs for "help" popup menu
127enum {
128 BUTTON_POPUP_HELP_LICENSE = 0,
129 BUTTON_POPUP_HELP_FAQ,
130 BUTTON_POPUP_HELP_ABOUT
131};
132#endif
133
123// Button IDs for toolbar 134// Button IDs for toolbar
124enum { 135enum {
125 BUTTON_TOOL_NEW = 0, 136 BUTTON_TOOL_NEW = 0,
126 BUTTON_TOOL_OPEN, 137 BUTTON_TOOL_OPEN,
127 BUTTON_TOOL_SAVE, 138 BUTTON_TOOL_SAVE,
128 BUTTON_TOOL_SAVEAS, 139 BUTTON_TOOL_SAVEAS,
129 BUTTON_TOOL_PRINT, 140 BUTTON_TOOL_PRINT,
130 BUTTON_TOOL_ADD, 141 BUTTON_TOOL_ADD,
131 BUTTON_TOOL_EDIT, 142 BUTTON_TOOL_EDIT,
132 BUTTON_TOOL_DEL, 143 BUTTON_TOOL_DEL,
133 BUTTON_TOOL_FIND, 144 BUTTON_TOOL_FIND,
134 BUTTON_TOOL_LOCK, 145 BUTTON_TOOL_LOCK,
135 BUTTON_TOOL_DEEPLOCK, 146 BUTTON_TOOL_DEEPLOCK,
136 BUTTON_TOOL_UNLOCK 147 BUTTON_TOOL_UNLOCK
137}; 148};
138 149
139 150
140PwM::PwM(PwMInit *_init, PwMDoc *doc, 151PwM::PwM(PwMInit *_init, PwMDoc *doc,
141 bool virginity, 152 bool virginity,
142 QWidget *parent, const char *name) 153 QWidget *parent, const char *name)
143 : KMainWindow(parent, name) 154 : KMainWindow(parent, name)
144 , forceQuit (false) 155 , forceQuit (false)
145 , forceMinimizeToTray (false) 156 , forceMinimizeToTray (false)
146{ 157{
147 init = _init; 158 init = _init;
148 connect(doc, SIGNAL(docClosed(PwMDoc *)), 159 connect(doc, SIGNAL(docClosed(PwMDoc *)),
149 this, SLOT(docClosed(PwMDoc *))); 160 this, SLOT(docClosed(PwMDoc *)));
150 initMenubar(); 161 initMenubar();
151 initToolbar(); 162 initToolbar();
152 initMetrics(); 163 initMetrics();
153 setVirgin(virginity); 164 setVirgin(virginity);
154 setFocusPolicy(QWidget::WheelFocus); 165 setFocusPolicy(QWidget::WheelFocus);
155#ifndef PWM_EMBEDDED 166#ifndef PWM_EMBEDDED
156 statusBar()->show(); 167 statusBar()->show();
157#endif 168#endif
158 view = makeNewListView(doc); 169 view = makeNewListView(doc);
159 setCentralWidget(view); 170 setCentralWidget(view);
160 updateCaption(); 171 updateCaption();
161 showStatMsg(i18n("Ready.")); 172 showStatMsg(i18n("Ready."));
162} 173}
163 174
164PwM::~PwM() 175PwM::~PwM()
165{ 176{
166 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), 177 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
167 this, SLOT(docClosed(PwMDoc *))); 178 this, SLOT(docClosed(PwMDoc *)));
168 conf()->confWndMainWndSize(size()); 179 conf()->confWndMainWndSize(size());
169 emit closed(this); 180 emit closed(this);
170 delete view; 181 delete view;
171} 182}
172 183
173void PwM::initMenubar() 184void PwM::initMenubar()
174{ 185{
186 KIconLoader* picons;
187#ifndef PWM_EMBEDDED
175 KIconLoader icons; 188 KIconLoader icons;
176 189 picons = &icons;
190#else
191 picons = KGlobal::iconLoader();
192#endif
177 filePopup = new KPopupMenu(this); 193 filePopup = new KPopupMenu(this);
178 importPopup = new KPopupMenu(filePopup); 194 importPopup = new KPopupMenu(filePopup);
179 exportPopup = new KPopupMenu(filePopup); 195 exportPopup = new KPopupMenu(filePopup);
180 managePopup = new KPopupMenu(this); 196 managePopup = new KPopupMenu(this);
181#ifdef CONFIG_KEYCARD 197#ifdef CONFIG_KEYCARD
182 chipcardPopup = new KPopupMenu(this); 198 chipcardPopup = new KPopupMenu(this);
183#endif // CONFIG_KEYCARD 199#endif // CONFIG_KEYCARD
184 viewPopup = new KPopupMenu(this); 200 viewPopup = new KPopupMenu(this);
185 optionsPopup = new KPopupMenu(this); 201 optionsPopup = new KPopupMenu(this);
186 202
187// "file" popup menu 203// "file" popup menu
188 filePopup->insertItem(QIconSet(icons.loadIcon("filenew", KIcon::Small)), 204 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
189 i18n("&New"), this, 205 i18n("&New"), this,
190 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); 206 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW);
191 filePopup->insertItem(QIconSet(icons.loadIcon("fileopen", KIcon::Small)), 207 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)),
192 i18n("&Open"), this, 208 i18n("&Open"), this,
193 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); 209 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN);
194 filePopup->insertItem(QIconSet(icons.loadIcon("fileclose", KIcon::Small)), 210 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)),
195 i18n("&Close"), this, 211 i18n("&Close"), this,
196 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); 212 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE);
197 filePopup->insertSeparator(); 213 filePopup->insertSeparator();
198 filePopup->insertItem(QIconSet(icons.loadIcon("filesave", KIcon::Small)), 214 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)),
199 i18n("&Save"), this, 215 i18n("&Save"), this,
200 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); 216 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
201 filePopup->insertItem(QIconSet(icons.loadIcon("filesaveas", KIcon::Small)), 217 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)),
202 i18n("Save &as..."), 218 i18n("Save &as..."),
203 this, SLOT(saveAs_slot()), 0, 219 this, SLOT(saveAs_slot()), 0,
204 BUTTON_POPUP_FILE_SAVEAS); 220 BUTTON_POPUP_FILE_SAVEAS);
205 filePopup->insertSeparator(); 221 filePopup->insertSeparator();
206 // "file/export" popup menu 222 // "file/export" popup menu
207 exportPopup->insertItem(i18n("&Text-file..."), this, 223 exportPopup->insertItem(i18n("&Text-file..."), this,
208 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); 224 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
209 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 225 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
210 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); 226 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
211#ifdef CONFIG_KWALLETIF 227#ifdef CONFIG_KWALLETIF
212 exportPopup->insertItem(i18n("&KWallet..."), this, 228 exportPopup->insertItem(i18n("&KWallet..."), this,
213 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); 229 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
214#endif 230#endif
215 filePopup->insertItem(QIconSet(icons.loadIcon("fileexport", KIcon::Small)), 231 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
216 i18n("E&xport"), exportPopup, 232 i18n("E&xport"), exportPopup,
217 BUTTON_POPUP_FILE_EXPORT); 233 BUTTON_POPUP_FILE_EXPORT);
218 // "file/import" popup menu 234 // "file/import" popup menu
219 importPopup->insertItem(i18n("&Text-file..."), this, 235 importPopup->insertItem(i18n("&Text-file..."), this,
220 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 236 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
221 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 237 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
222 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 238 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
223#ifdef CONFIG_KWALLETIF 239#ifdef CONFIG_KWALLETIF
224 importPopup->insertItem(i18n("&KWallet..."), this, 240 importPopup->insertItem(i18n("&KWallet..."), this,
225 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 241 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
226#endif 242#endif
227 filePopup->insertItem(QIconSet(icons.loadIcon("fileimport", KIcon::Small)), 243 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
228 i18n("I&mport"), importPopup, 244 i18n("I&mport"), importPopup,
229 BUTTON_POPUP_FILE_IMPORT); 245 BUTTON_POPUP_FILE_IMPORT);
230 filePopup->insertSeparator(); 246 filePopup->insertSeparator();
231 filePopup->insertItem(QIconSet(icons.loadIcon("fileprint", KIcon::Small)), 247 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)),
232 i18n("&Print..."), this, 248 i18n("&Print..."), this,
233 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 249 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
234 filePopup->insertSeparator(); 250 filePopup->insertSeparator();
235 filePopup->insertItem(QIconSet(icons.loadIcon("exit", KIcon::Small)), 251 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)),
236 i18n("&Quit"), this, 252 i18n("&Quit"), this,
237 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 253 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
238 menuBar()->insertItem(i18n("&File"), filePopup); 254 menuBar()->insertItem(i18n("&File"), filePopup);
239// "manage" popup menu 255// "manage" popup menu
240 managePopup->insertItem(QIconSet(icons.loadIcon("pencil", KIcon::Small)), 256 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
241 i18n("&Add password"), this, 257 i18n("&Add password"), this,
242 SLOT(addPwd_slot()), 0, 258 SLOT(addPwd_slot()), 0,
243 BUTTON_POPUP_MANAGE_ADD); 259 BUTTON_POPUP_MANAGE_ADD);
244 managePopup->insertItem(QIconSet(icons.loadIcon("edit", KIcon::Small)), 260 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
245 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 261 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
246 BUTTON_POPUP_MANAGE_EDIT); 262 BUTTON_POPUP_MANAGE_EDIT);
247 managePopup->insertItem(QIconSet(icons.loadIcon("editdelete", KIcon::Small)), 263 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
248 i18n("&Delete"), this, SLOT(deletePwd_slot()), 264 i18n("&Delete"), this, SLOT(deletePwd_slot()),
249 0, BUTTON_POPUP_MANAGE_DEL); 265 0, BUTTON_POPUP_MANAGE_DEL);
250 managePopup->insertSeparator(); 266 managePopup->insertSeparator();
251 managePopup->insertItem(QIconSet(icons.loadIcon("rotate", KIcon::Small)), 267 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
252 i18n("Change &Master Password"), this, 268 i18n("Change &Master Password"), this,
253 SLOT(changeMasterPwd_slot()), 0, 269 SLOT(changeMasterPwd_slot()), 0,
254 BUTTON_POPUP_MANAGE_CHANGEMP); 270 BUTTON_POPUP_MANAGE_CHANGEMP);
255 menuBar()->insertItem(i18n("&Manage"), managePopup); 271 menuBar()->insertItem(i18n("&Manage"), managePopup);
256// "chipcard" popup menu 272// "chipcard" popup menu
257#ifdef CONFIG_KEYCARD 273#ifdef CONFIG_KEYCARD
258 chipcardPopup->insertItem(QIconSet(icons.loadIcon("filenew", KIcon::Small)), 274 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
259 i18n("&Generate new key-card"), this, 275 i18n("&Generate new key-card"), this,
260 SLOT(genNewCard_slot()), 0, 276 SLOT(genNewCard_slot()), 0,
261 BUTTON_POPUP_CHIPCARD_GENNEW); 277 BUTTON_POPUP_CHIPCARD_GENNEW);
262 chipcardPopup->insertItem(QIconSet(icons.loadIcon("editdelete", KIcon::Small)), 278 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
263 i18n("&Erase key-card"), this, 279 i18n("&Erase key-card"), this,
264 SLOT(eraseCard_slot()), 0, 280 SLOT(eraseCard_slot()), 0,
265 BUTTON_POPUP_CHIPCARD_DEL); 281 BUTTON_POPUP_CHIPCARD_DEL);
266 chipcardPopup->insertItem(QIconSet(icons.loadIcon("", KIcon::Small)), 282 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
267 i18n("Read card-&ID"), this, 283 i18n("Read card-&ID"), this,
268 SLOT(readCardId_slot()), 0, 284 SLOT(readCardId_slot()), 0,
269 BUTTON_POPUP_CHIPCARD_READID); 285 BUTTON_POPUP_CHIPCARD_READID);
270 chipcardPopup->insertSeparator(); 286 chipcardPopup->insertSeparator();
271 chipcardPopup->insertItem(QIconSet(icons.loadIcon("2rightarrow", KIcon::Small)), 287 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
272 i18n("&Make card backup-image"), this, 288 i18n("&Make card backup-image"), this,
273 SLOT(makeCardBackup_slot()), 0, 289 SLOT(makeCardBackup_slot()), 0,
274 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 290 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
275 chipcardPopup->insertItem(QIconSet(icons.loadIcon("2leftarrow", KIcon::Small)), 291 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
276 i18n("&Replay card backup-image"), this, 292 i18n("&Replay card backup-image"), this,
277 SLOT(replayCardBackup_slot()), 0, 293 SLOT(replayCardBackup_slot()), 0,
278 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 294 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
279 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 295 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
280#endif // CONFIG_KEYCARD 296#endif // CONFIG_KEYCARD
281// "view" popup menu 297// "view" popup menu
282 viewPopup->insertItem(QIconSet(icons.loadIcon("find", KIcon::Small)), 298 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
283 i18n("&Find"), this, 299 i18n("&Find"), this,
284 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 300 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
285 viewPopup->insertSeparator(); 301 viewPopup->insertSeparator();
286 viewPopup->insertItem(QIconSet(icons.loadIcon("halfencrypted", KIcon::Small)), 302 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
287 i18n("&Lock all entries"), this, 303 i18n("&Lock all entries"), this,
288 SLOT(lockWnd_slot()), 0, 304 SLOT(lockWnd_slot()), 0,
289 BUTTON_POPUP_VIEW_LOCK); 305 BUTTON_POPUP_VIEW_LOCK);
290 viewPopup->insertItem(QIconSet(icons.loadIcon("encrypted", KIcon::Small)), 306 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
291 i18n("&Deep-lock all entries"), this, 307 i18n("&Deep-lock all entries"), this,
292 SLOT(deepLockWnd_slot()), 0, 308 SLOT(deepLockWnd_slot()), 0,
293 BUTTON_POPUP_VIEW_DEEPLOCK); 309 BUTTON_POPUP_VIEW_DEEPLOCK);
294 viewPopup->insertItem(QIconSet(icons.loadIcon("decrypted", KIcon::Small)), 310 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
295 i18n("&Unlock all entries"), this, 311 i18n("&Unlock all entries"), this,
296 SLOT(unlockWnd_slot()), 0, 312 SLOT(unlockWnd_slot()), 0,
297 BUTTON_POPUP_VIEW_UNLOCK); 313 BUTTON_POPUP_VIEW_UNLOCK);
298 menuBar()->insertItem(i18n("&View"), viewPopup); 314 menuBar()->insertItem(i18n("&View"), viewPopup);
299// "options" popup menu 315// "options" popup menu
300 optionsPopup->insertItem(QIconSet(icons.loadIcon("configure", KIcon::Small)), 316 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
301 i18n("&Configure..."), this, 317 i18n("&Configure..."), this,
302 SLOT(config_slot()), 318 SLOT(config_slot()),
303 BUTTON_POPUP_OPTIONS_CONFIG); 319 BUTTON_POPUP_OPTIONS_CONFIG);
304 menuBar()->insertItem(i18n("&Options"), optionsPopup); 320 menuBar()->insertItem(i18n("&Options"), optionsPopup);
305// "help" popup menu 321// "help" popup menu
306#ifndef PWM_EMBEDDED 322#ifndef PWM_EMBEDDED
307 helpPopup = helpMenu(QString::null, false); 323 helpPopup = helpMenu(QString::null, false);
308 menuBar()->insertItem(i18n("&Help"), helpPopup); 324#else
325 helpPopup = new KPopupMenu(this);
326
327
328 helpPopup->insertItem(i18n("&License"), this,
329 SLOT(showLicense_slot()), 0,
330 BUTTON_POPUP_HELP_LICENSE);
331
332 helpPopup->insertItem(i18n("&Faq"), this,
333 SLOT(faq_slot()), 0,
334 BUTTON_POPUP_HELP_FAQ);
335
336 helpPopup->insertItem(i18n("&About PwManager"), this,
337 SLOT(createAboutData_slot()), 0,
338 BUTTON_POPUP_HELP_ABOUT);
339
309#endif 340#endif
341 menuBar()->insertItem(i18n("&Help"), helpPopup);
342
310} 343}
311 344
312void PwM::initToolbar() 345void PwM::initToolbar()
313{ 346{
347 KIconLoader* picons;
348#ifndef PWM_EMBEDDED
314 KIconLoader icons; 349 KIconLoader icons;
350 picons = &icons;
351#else
352 picons = KGlobal::iconLoader();
353#endif
315 354
316 toolBar()->insertButton(icons.loadIcon("filenew", KIcon::Toolbar), 355 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
317 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 356 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
318 SLOT(new_slot()), true, i18n("New")); 357 SLOT(new_slot()), true, i18n("New"));
319 toolBar()->insertButton(icons.loadIcon("fileopen", KIcon::Toolbar), 358 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
320 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 359 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
321 SLOT(open_slot()), true, i18n("Open")); 360 SLOT(open_slot()), true, i18n("Open"));
322 toolBar()->insertSeparator(); 361 toolBar()->insertSeparator();
323 toolBar()->insertButton(icons.loadIcon("filesave", KIcon::Toolbar), 362 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
324 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 363 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
325 SLOT(save_slot()), true, i18n("Save")); 364 SLOT(save_slot()), true, i18n("Save"));
326 toolBar()->insertButton(icons.loadIcon("filesaveas", KIcon::Toolbar), 365 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
327 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 366 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
328 SLOT(saveAs_slot()), true, i18n("Save as")); 367 SLOT(saveAs_slot()), true, i18n("Save as"));
329 toolBar()->insertButton(icons.loadIcon("fileprint", KIcon::Toolbar), 368 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
330 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 369 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
331 SLOT(print_slot()), true, i18n("Print...")); 370 SLOT(print_slot()), true, i18n("Print..."));
332 toolBar()->insertSeparator(); 371 toolBar()->insertSeparator();
333 toolBar()->insertButton(icons.loadIcon("pencil", KIcon::Toolbar), 372 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
334 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, 373 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
335 SLOT(addPwd_slot()), true, 374 SLOT(addPwd_slot()), true,
336 i18n("Add password")); 375 i18n("Add password"));
337 toolBar()->insertButton(icons.loadIcon("edit", KIcon::Toolbar), 376 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
338 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 377 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
339 SLOT(editPwd_slot()), true, 378 SLOT(editPwd_slot()), true,
340 i18n("Edit password")); 379 i18n("Edit password"));
341 toolBar()->insertButton(icons.loadIcon("editdelete", KIcon::Toolbar), 380 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
342 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 381 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
343 SLOT(deletePwd_slot()), true, 382 SLOT(deletePwd_slot()), true,
344 i18n("Delete password")); 383 i18n("Delete password"));
345 toolBar()->insertSeparator(); 384 toolBar()->insertSeparator();
346 toolBar()->insertButton(icons.loadIcon("find", KIcon::Toolbar), 385 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
347 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, 386 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
348 SLOT(find_slot()), true, i18n("Find entry")); 387 SLOT(find_slot()), true, i18n("Find entry"));
349 toolBar()->insertSeparator(); 388 toolBar()->insertSeparator();
350 toolBar()->insertButton(icons.loadIcon("halfencrypted", KIcon::Toolbar), 389 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
351 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 390 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
352 SLOT(lockWnd_slot()), true, 391 SLOT(lockWnd_slot()), true,
353 i18n("Lock all entries")); 392 i18n("Lock all entries"));
354 toolBar()->insertButton(icons.loadIcon("encrypted", KIcon::Toolbar), 393 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
355 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 394 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
356 SLOT(deepLockWnd_slot()), true, 395 SLOT(deepLockWnd_slot()), true,
357 i18n("Deep-Lock all entries")); 396 i18n("Deep-Lock all entries"));
358 toolBar()->insertButton(icons.loadIcon("decrypted", KIcon::Toolbar), 397 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
359 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 398 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
360 SLOT(unlockWnd_slot()), true, 399 SLOT(unlockWnd_slot()), true,
361 i18n("Unlock all entries")); 400 i18n("Unlock all entries"));
362} 401}
363 402
364void PwM::initMetrics() 403void PwM::initMetrics()
365{ 404{
366 QSize s = conf()->confWndMainWndSize(); 405 QSize s = conf()->confWndMainWndSize();
367 if (s.isValid()) 406 if (s.isValid())
368 resize(s); 407 resize(s);
369 else 408 else
370 resize(DEFAULT_SIZE); 409 resize(DEFAULT_SIZE);
371} 410}
372 411
373void PwM::updateCaption() 412void PwM::updateCaption()
374{ 413{
375 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); 414 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER);
376} 415}
377 416
378void PwM::hideEvent(QHideEvent *) 417void PwM::hideEvent(QHideEvent *)
379{ 418{
380 if (isMinimized()) { 419 if (isMinimized()) {
381 if (init->tray()) { 420 if (init->tray()) {
382 forceMinimizeToTray = true; 421 forceMinimizeToTray = true;
383 close(); 422 close();
384 } 423 }
385 int mmlock = conf()->confGlobMinimizeLock(); 424 int mmlock = conf()->confGlobMinimizeLock();
386 switch (mmlock) { 425 switch (mmlock) {
387 case 0: // don't lock anything 426 case 0: // don't lock anything
388 break; 427 break;
389 case 1: {// normal lock 428 case 1: {// normal lock
390 curDoc()->lockAll(true); 429 curDoc()->lockAll(true);
391 break; 430 break;
392 } case 2: {// deep-lock 431 } case 2: {// deep-lock
393 curDoc()->deepLock(); 432 curDoc()->deepLock();
394 break; 433 break;
395 } default: 434 } default:
396 WARN(); 435 WARN();
397 } 436 }
398 } 437 }
399} 438}
400 439
401void PwM::setVirgin(bool v) 440void PwM::setVirgin(bool v)
402{ 441{
403 if (virgin == v) 442 if (virgin == v)
404 return; 443 return;
405 virgin = v; 444 virgin = v;
406 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); 445 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
407 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); 446 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
408 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); 447 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
409 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); 448 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
410 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); 449 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
411 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); 450 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
412 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); 451 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
413 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); 452 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
414 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); 453 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
415 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); 454 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
416 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); 455 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
417 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); 456 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
418 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 457 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
419 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 458 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
420 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 459 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
421 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 460 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
422 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 461 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
423 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 462 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
424 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 463 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
425 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 464 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
426} 465}
427 466
428void PwM::new_slot() 467void PwM::new_slot()
429{ 468{
430 init->createMainWnd(); 469 init->createMainWnd();
431} 470}
432 471
433//US ENH 472//US ENH
434void PwM::open_slot() 473void PwM::open_slot()
435{ 474{
436 open_slot(""); 475 open_slot("");
437} 476}
438 477
439void PwM::open_slot(QString fn) 478void PwM::open_slot(QString fn)
440{ 479{
441 openDoc(fn); 480 openDoc(fn);
442} 481}
443 482
444PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 483PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
445{ 484{
446 if (!isVirgin()) { 485 if (!isVirgin()) {
447 // open the document in a new window. 486 // open the document in a new window.
448 PwM *newInstance = init->createMainWnd(); 487 PwM *newInstance = init->createMainWnd();
449 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 488 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
450 if (!newDoc) { 489 if (!newDoc) {
451 newInstance->setForceQuit(true); 490 newInstance->setForceQuit(true);
452 delete_and_null(newInstance); 491 delete_and_null(newInstance);
453 } 492 }
454 return newDoc; 493 return newDoc;
455 } 494 }
456 495
457 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 496 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
458 return 0; 497 return 0;
459 showStatMsg(i18n("Successfully opened file.")); 498 showStatMsg(i18n("Successfully opened file."));
460 updateCaption(); 499 updateCaption();
461 setVirgin(false); 500 setVirgin(false);
462 return curDoc(); 501 return curDoc();
463} 502}
464 503
465PwMView * PwM::makeNewListView(PwMDoc *doc) 504PwMView * PwM::makeNewListView(PwMDoc *doc)
466{ 505{
467 PwMView *ret = new PwMView(this, this, doc); 506 PwMView *ret = new PwMView(this, this, doc);
468 ret->setFont(conf()->confGlobEntryFont()); 507 ret->setFont(conf()->confGlobEntryFont());
469 ret->show(); 508 ret->show();
470 return ret; 509 return ret;
471} 510}
472 511
473void PwM::close_slot() 512void PwM::close_slot()
474{ 513{
475 close(); 514 close();
476} 515}
477 516
478void PwM::quitButton_slot() 517void PwM::quitButton_slot()
479{ 518{
480 init->shutdownApp(0); 519 init->shutdownApp(0);
481} 520}
482 521
483void PwM::save_slot() 522void PwM::save_slot()
484{ 523{
485 save(); 524 save();
486} 525}
487 526
488bool PwM::save() 527bool PwM::save()
489{ 528{
490 if (!curDoc()->saveDocUi(curDoc())) 529 if (!curDoc()->saveDocUi(curDoc()))
491 return false; 530 return false;
492 showStatMsg(i18n("Successfully saved data.")); 531 showStatMsg(i18n("Successfully saved data."));
493 updateCaption(); 532 updateCaption();
494 return true; 533 return true;
495} 534}
496 535
497void PwM::saveAs_slot() 536void PwM::saveAs_slot()
498{ 537{
499 saveAs(); 538 saveAs();
500} 539}
501 540
502bool PwM::saveAs() 541bool PwM::saveAs()
503{ 542{
504 if (!curDoc()->saveAsDocUi(curDoc())) 543 if (!curDoc()->saveAsDocUi(curDoc()))
505 return false; 544 return false;
506 showStatMsg(i18n("Successfully saved data.")); 545 showStatMsg(i18n("Successfully saved data."));
507 updateCaption(); 546 updateCaption();
508 return true; 547 return true;
509} 548}
510 549
511//US ENH : changed code to run with older MOC 550//US ENH : changed code to run with older MOC
512void PwM::addPwd_slot() 551void PwM::addPwd_slot()
513{ 552{
514 addPwd_slot(0, 0); 553 addPwd_slot(0, 0);
515} 554}
516 555
517void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) 556void PwM::addPwd_slot(QString *pw, PwMDoc *_doc)
518{ 557{
519 PwMDoc *doc; 558 PwMDoc *doc;
520 if (_doc) { 559 if (_doc) {
521 doc = _doc; 560 doc = _doc;
522 } else { 561 } else {
523 doc = curDoc(); 562 doc = curDoc();
524 } 563 }
525 PWM_ASSERT(doc); 564 PWM_ASSERT(doc);
526 doc->timer()->getLock(DocTimer::id_autoLockTimer); 565 doc->timer()->getLock(DocTimer::id_autoLockTimer);
527 AddEntryWndImpl w; 566 AddEntryWndImpl w;
528 vector<string> catList; 567 vector<string> catList;
529 doc->getCategoryList(&catList); 568 doc->getCategoryList(&catList);
530 unsigned i, size = catList.size(); 569 unsigned i, size = catList.size();
531 for (i = 0; i < size; ++i) { 570 for (i = 0; i < size; ++i) {
532 w.addCategory(catList[i].c_str()); 571 w.addCategory(catList[i].c_str());
533 } 572 }
534 w.setCurrCategory(view->getCurrentCategory()); 573 w.setCurrCategory(view->getCurrentCategory());
535 if (pw) 574 if (pw)
536 w.pwLineEdit->setText(*pw); 575 w.pwLineEdit->setText(*pw);
537 576
538 tryAgain: 577 tryAgain:
539 if (w.exec() == 1) { 578 if (w.exec() == 1)
579 {
540 PwMDataItem d; 580 PwMDataItem d;
541 d.desc = w.getDescription().latin1(); 581 d.desc = w.getDescription().latin1();
542 d.name = w.getUsername().latin1(); 582 d.name = w.getUsername().latin1();
543 d.pw = w.getPassword().latin1(); 583 d.pw = w.getPassword().latin1();
544 d.comment = w.getComment().latin1(); 584 d.comment = w.getComment().latin1();
545 d.url = w.getUrl().latin1(); 585 d.url = w.getUrl().latin1();
546 d.launcher = w.getLauncher().latin1(); 586 d.launcher = w.getLauncher().latin1();
547 PwMerror ret = doc->addEntry(w.getCategory(), &d); 587 PwMerror ret = doc->addEntry(w.getCategory(), &d);
548 if (ret == e_entryExists) { 588 if (ret == e_entryExists) {
549 KMessageBox::error(this, 589 KMessageBox::error(this,
550 i18n 590 i18n
551 ("An entry with this \"Description\", " 591 ("An entry with this \"Description\", "
552 "does already exist.\n" 592 "does already exist.\n"
553 "Please select another description."), 593 "Please select another description."),
554 i18n("entry already exists.")); 594 i18n("entry already exists."));
555 goto tryAgain; 595 goto tryAgain;
556 } else if (ret == e_maxAllowedEntr) { 596 } else if (ret == e_maxAllowedEntr) {
557 KMessageBox::error(this, i18n("The maximum possible number of entries " 597 KMessageBox::error(this, i18n("The maximum possible number of entries "
558 "has been reached. You can't add more entries."), 598 "has been reached. You can't add more entries."),
559 i18n("maximum number of entries")); 599 i18n("maximum number of entries"));
560 doc->timer()->putLock(DocTimer::id_autoLockTimer); 600 doc->timer()->putLock(DocTimer::id_autoLockTimer);
561 return; 601 return;
562 } 602 }
563 } 603 }
564 setVirgin(false); 604 setVirgin(false);
565 doc->timer()->putLock(DocTimer::id_autoLockTimer); 605 doc->timer()->putLock(DocTimer::id_autoLockTimer);
566} 606}
567 607
568//US ENH : changed code to run with older MOC 608//US ENH : changed code to run with older MOC
569void PwM::editPwd_slot() 609void PwM::editPwd_slot()
570{ 610{
571 editPwd_slot(0,0,0); 611 editPwd_slot(0,0,0);
572} 612}
573 613
574void PwM::editPwd_slot(const QString *category) 614void PwM::editPwd_slot(const QString *category)
575{ 615{
576 editPwd_slot(category, 0, 0); 616 editPwd_slot(category, 0, 0);
577} 617}
578 618
579void PwM::editPwd_slot(const QString *category, const int *index, 619void PwM::editPwd_slot(const QString *category, const int *index,
580 PwMDoc *_doc) 620 PwMDoc *_doc)
581{ 621{
582 PwMDoc *doc; 622 PwMDoc *doc;
583 if (_doc) { 623 if (_doc) {
584 doc = _doc; 624 doc = _doc;
585 } else { 625 } else {
586 doc = curDoc(); 626 doc = curDoc();
587 } 627 }
588 PWM_ASSERT(doc); 628 PWM_ASSERT(doc);
589 if (doc->isDocEmpty()) 629 if (doc->isDocEmpty())
590 return; 630 return;
591 if (doc->isDeepLocked()) 631 if (doc->isDeepLocked())
592 return; 632 return;
593 doc->timer()->getLock(DocTimer::id_autoLockTimer); 633 doc->timer()->getLock(DocTimer::id_autoLockTimer);
594 unsigned int curEntryIndex; 634 unsigned int curEntryIndex;
595 if (index) { 635 if (index) {
596 curEntryIndex = *index; 636 curEntryIndex = *index;
597 } else { 637 } else {
598 if (!(view->getCurEntryIndex(&curEntryIndex))) { 638 if (!(view->getCurEntryIndex(&curEntryIndex))) {
599 printDebug("couldn't get index. Maybe we have a binary entry here."); 639 printDebug("couldn't get index. Maybe we have a binary entry here.");
600 doc->timer()->putLock(DocTimer::id_autoLockTimer); 640 doc->timer()->putLock(DocTimer::id_autoLockTimer);
601 return; 641 return;
602 } 642 }
603 } 643 }
604 QString curCategory; 644 QString curCategory;
605 if (category) { 645 if (category) {
606 curCategory = *category; 646 curCategory = *category;
607 } else { 647 } else {
608 curCategory = view->getCurrentCategory(); 648 curCategory = view->getCurrentCategory();
609 } 649 }
610 PwMDataItem currItem; 650 PwMDataItem currItem;
611 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 651 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
612 doc->timer()->putLock(DocTimer::id_autoLockTimer); 652 doc->timer()->putLock(DocTimer::id_autoLockTimer);
613 return; 653 return;
614 } 654 }
615 BUG_ON(currItem.binary); 655 BUG_ON(currItem.binary);
616 656
617 AddEntryWndImpl w; 657 AddEntryWndImpl w;
618 vector<string> catList; 658 vector<string> catList;
619 doc->getCategoryList(&catList); 659 doc->getCategoryList(&catList);
620 unsigned i, size = catList.size(); 660 unsigned i, size = catList.size();
621 for (i = 0; i < size; ++i) { 661 for (i = 0; i < size; ++i) {
622 w.addCategory(catList[i].c_str()); 662 w.addCategory(catList[i].c_str());
623 } 663 }
624 w.setCurrCategory(curCategory); 664 w.setCurrCategory(curCategory);
625 w.setDescription(currItem.desc.c_str()); 665 w.setDescription(currItem.desc.c_str());
626 w.setUsername(currItem.name.c_str()); 666 w.setUsername(currItem.name.c_str());
627 w.setPassword(currItem.pw.c_str()); 667 w.setPassword(currItem.pw.c_str());
628 w.setUrl(currItem.url.c_str()); 668 w.setUrl(currItem.url.c_str());
629 w.setLauncher(currItem.launcher.c_str()); 669 w.setLauncher(currItem.launcher.c_str());
630 w.setComment(currItem.comment.c_str()); 670 w.setComment(currItem.comment.c_str());
631 if (w.exec() == 1) { 671 if (w.exec() == 1) {
632 currItem.desc = w.getDescription().latin1(); 672 currItem.desc = w.getDescription().latin1();
633 currItem.name = w.getUsername().latin1(); 673 currItem.name = w.getUsername().latin1();
634 currItem.pw = w.getPassword().latin1(); 674 currItem.pw = w.getPassword().latin1();
635 currItem.comment = w.getComment().latin1(); 675 currItem.comment = w.getComment().latin1();
636 currItem.url = w.getUrl().latin1(); 676 currItem.url = w.getUrl().latin1();
637 currItem.launcher = w.getLauncher().latin1(); 677 currItem.launcher = w.getLauncher().latin1();
638 if (!doc->editEntry(curCategory, w.getCategory(), 678 if (!doc->editEntry(curCategory, w.getCategory(),
639 curEntryIndex, &currItem)) { 679 curEntryIndex, &currItem)) {
640 KMessageBox::error(this, 680 KMessageBox::error(this,
641 i18n("Couldn't edit the entry.\n" 681 i18n("Couldn't edit the entry.\n"
642 "Maybe you changed the category and " 682 "Maybe you changed the category and "
643 "this entry is already present in the new " 683 "this entry is already present in the new "
644 "category?"), 684 "category?"),
645 i18n("couldn't edit entry.")); 685 i18n("couldn't edit entry."));
646 doc->timer()->putLock(DocTimer::id_autoLockTimer); 686 doc->timer()->putLock(DocTimer::id_autoLockTimer);
647 return; 687 return;
648 } 688 }
649 } 689 }
650 doc->timer()->putLock(DocTimer::id_autoLockTimer); 690 doc->timer()->putLock(DocTimer::id_autoLockTimer);
651} 691}
652 692
653void PwM::deletePwd_slot() 693void PwM::deletePwd_slot()
654{ 694{
655 PWM_ASSERT(curDoc()); 695 PWM_ASSERT(curDoc());
656 if (curDoc()->isDocEmpty()) 696 if (curDoc()->isDocEmpty())
657 return; 697 return;
658 if (curDoc()->isDeepLocked()) 698 if (curDoc()->isDeepLocked())
659 return; 699 return;
660 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 700 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
661 unsigned int curEntryIndex = 0; 701 unsigned int curEntryIndex = 0;
662 if (!(view->getCurEntryIndex(&curEntryIndex))) { 702 if (!(view->getCurEntryIndex(&curEntryIndex))) {
663 printDebug("couldn't get index"); 703 printDebug("couldn't get index");
664 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 704 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
665 return; 705 return;
666 } 706 }
667 707
668 PwMDataItem currItem; 708 PwMDataItem currItem;
669 QString curCategory = view->getCurrentCategory(); 709 QString curCategory = view->getCurrentCategory();
670 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 710 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
671 printDebug("couldn't get entry"); 711 printDebug("couldn't get entry");
672 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 712 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
673 return; 713 return;
674 } 714 }
675 if (KMessageBox:: 715 if (KMessageBox::
676 questionYesNo(this, 716 questionYesNo(this,
677 i18n 717 i18n
678 ("Do you really want to delete the selected entry") + 718 ("Do you really want to delete the selected entry") +
679 " \"" + QString(currItem.desc.c_str()) 719 " \"" + QString(currItem.desc.c_str())
680 + "\" ?", i18n("delete?")) 720 + "\" ?", i18n("delete?"))
681 == KMessageBox::Yes) { 721 == KMessageBox::Yes) {
682 722
683 curDoc()->delEntry(curCategory, curEntryIndex); 723 curDoc()->delEntry(curCategory, curEntryIndex);
684 } 724 }
685 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 725 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
686} 726}
687 727
688void PwM::changeMasterPwd_slot() 728void PwM::changeMasterPwd_slot()
689{ 729{
690 PWM_ASSERT(curDoc()); 730 PWM_ASSERT(curDoc());
691 curDoc()->changeCurrentPw(); 731 curDoc()->changeCurrentPw();
692} 732}
693 733
694void PwM::lockWnd_slot() 734void PwM::lockWnd_slot()
695{ 735{
696 PWM_ASSERT(curDoc()); 736 PWM_ASSERT(curDoc());
697 curDoc()->lockAll(true); 737 curDoc()->lockAll(true);
698} 738}
699 739
700void PwM::deepLockWnd_slot() 740void PwM::deepLockWnd_slot()
701{ 741{
702 PWM_ASSERT(curDoc()); 742 PWM_ASSERT(curDoc());
703 curDoc()->deepLock(); 743 curDoc()->deepLock();
704} 744}
705 745
706void PwM::unlockWnd_slot() 746void PwM::unlockWnd_slot()
707{ 747{
708 PWM_ASSERT(curDoc()); 748 PWM_ASSERT(curDoc());
709 curDoc()->lockAll(false); 749 curDoc()->lockAll(false);
710} 750}
711 751
712void PwM::config_slot() 752void PwM::config_slot()
713{ 753{
714 Configuration *conf = Configuration::obj(); 754 Configuration *conf = Configuration::obj();
715 int oldStyle = conf->confWndMainViewStyle(); 755 int oldStyle = conf->confWndMainViewStyle();
716 756
717 // display the configuration window (modal mode) 757 // display the configuration window (modal mode)
718 if (!conf->showConfWnd(this)) 758 if (!conf->showConfWnd(this))
719 return; 759 return;
720 760
721 int newStyle = conf->confWndMainViewStyle(); 761 int newStyle = conf->confWndMainViewStyle();
722 // reinitialize tray 762 // reinitialize tray
723 init->initTray(); 763 init->initTray();
724 // reinitialize KWallet emulation 764 // reinitialize KWallet emulation
725 init->initKWalletEmu(); 765 init->initKWalletEmu();
726 766
727 PwMDocList *_dl = PwMDoc::getOpenDocList(); 767 PwMDocList *_dl = PwMDoc::getOpenDocList();
728 const vector<PwMDocList::listItem> *dl = _dl->getList(); 768 const vector<PwMDocList::listItem> *dl = _dl->getList();
729 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 769 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
730 end = dl->end(); 770 end = dl->end();
731 PwMDoc *doc; 771 PwMDoc *doc;
732 while (i != end) { 772 while (i != end) {
733 doc = (*i).doc; 773 doc = (*i).doc;
734 // unlock-without-mpw timeout 774 // unlock-without-mpw timeout
735 doc->timer()->start(DocTimer::id_mpwTimer); 775 doc->timer()->start(DocTimer::id_mpwTimer);
736 // auto-lock timeout 776 // auto-lock timeout
737 doc->timer()->start(DocTimer::id_autoLockTimer); 777 doc->timer()->start(DocTimer::id_autoLockTimer);
738 ++i; 778 ++i;
739 } 779 }
740 780
741 const QValueList<PwM *> *ml = init->mainWndList(); 781 const QValueList<PwM *> *ml = init->mainWndList();
742#ifndef PWM_EMBEDDED 782#ifndef PWM_EMBEDDED
743 QValueList<PwM *>::const_iterator i2 = ml->begin(), 783 QValueList<PwM *>::const_iterator i2 = ml->begin(),
744 end2 = ml->end(); 784 end2 = ml->end();
745#else 785#else
746 QValueList<PwM *>::ConstIterator i2 = ml->begin(), 786 QValueList<PwM *>::ConstIterator i2 = ml->begin(),
747 end2 = ml->end(); 787 end2 = ml->end();
748#endif 788#endif
749 PwM *pwm; 789 PwM *pwm;
750 while (i2 != end2) { 790 while (i2 != end2) {
751 pwm = *i2; 791 pwm = *i2;
752 // reinitialize the window style. 792 // reinitialize the window style.
753 if (oldStyle != newStyle) 793 if (oldStyle != newStyle)
754 pwm->curView()->initStyle(newStyle); 794 pwm->curView()->initStyle(newStyle);
755 // set the new font 795 // set the new font
756 pwm->curView()->setFont(conf->confGlobEntryFont()); 796 pwm->curView()->setFont(conf->confGlobEntryFont());
757 ++i2; 797 ++i2;
758 } 798 }
759} 799}
760 800
761void PwM::activateMpButton(bool activate) 801void PwM::activateMpButton(bool activate)
762{ 802{
763 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); 803 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
764} 804}
765 805
766void PwM::closeEvent(QCloseEvent *e) 806void PwM::closeEvent(QCloseEvent *e)
767{ 807{
768 e->accept(); 808 e->accept();
769} 809}
770 810
771void PwM::docClosed(PwMDoc *doc) 811void PwM::docClosed(PwMDoc *doc)
772{ 812{
773 PARAM_UNUSED(doc); 813 PARAM_UNUSED(doc);
774 PWM_ASSERT(doc == curDoc()); 814 PWM_ASSERT(doc == curDoc());
775 close(); 815 close();
776} 816}
777 817
778void PwM::find_slot() 818void PwM::find_slot()
779{ 819{
780 PWM_ASSERT(curDoc()); 820 PWM_ASSERT(curDoc());
781 if (curDoc()->isDocEmpty()) 821 if (curDoc()->isDocEmpty())
782 return; 822 return;
783 if (curDoc()->isDeepLocked()) 823 if (curDoc()->isDeepLocked())
784 return; 824 return;
785 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 825 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
786 FindWndImpl findWnd(view); 826 FindWndImpl findWnd(view);
787 findWnd.exec(); 827 findWnd.exec();
788 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 828 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
789} 829}
790 830
791void PwM::exportToText() 831void PwM::exportToText()
792{ 832{
793 PWM_ASSERT(curDoc()); 833 PWM_ASSERT(curDoc());
794 if (curDoc()->isDocEmpty()) { 834 if (curDoc()->isDocEmpty()) {
795 KMessageBox::information(this, 835 KMessageBox::information(this,
796 i18n 836 i18n
797 ("Sorry, there's nothing to export.\n" 837 ("Sorry, there's nothing to export.\n"
798 "Please first add some passwords."), 838 "Please first add some passwords."),
799 i18n("nothing to do")); 839 i18n("nothing to do"));
800 return; 840 return;
801 } 841 }
802 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 842 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
803 QString fn(KFileDialog::getSaveFileName(QString::null, 843 QString fn(KFileDialog::getSaveFileName(QString::null,
804 i18n("*|plain-text file"), 844 i18n("*|plain-text file"),
805 this)); 845 this));
806 if (fn == "") { 846 if (fn == "") {
807 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 847 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
808 return; 848 return;
809 } 849 }
810 850
811 PwMerror ret = curDoc()->exportToText(&fn); 851 PwMerror ret = curDoc()->exportToText(&fn);
812 if (ret != e_success) { 852 if (ret != e_success) {
813 KMessageBox::error(this, 853 KMessageBox::error(this,
814 i18n("Error: Couldn't write to file.\n" 854 i18n("Error: Couldn't write to file.\n"
815 "Please check if you have permission to write " 855 "Please check if you have permission to write "
816 "to the file in that directory."), 856 "to the file in that directory."),
817 i18n("error while writing")); 857 i18n("error while writing"));
818 } else 858 } else
819 showStatMsg(i18n("Successfully exported data.")); 859 showStatMsg(i18n("Successfully exported data."));
820 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 860 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
821} 861}
822 862
823bool PwM::importFromText() 863bool PwM::importFromText()
824{ 864{
825 if (!isVirgin()) { 865 if (!isVirgin()) {
826 if (KMessageBox::questionYesNo(this, 866 if (KMessageBox::questionYesNo(this,
827 i18n("Do you want to import the data " 867 i18n("Do you want to import the data "
828 "into the current document? (If you " 868 "into the current document? (If you "
829 "select \"no\", a new document will be " 869 "select \"no\", a new document will be "
830 "opened.)"), 870 "opened.)"),
831 i18n("import into this document?")) 871 i18n("import into this document?"))
832 == KMessageBox::No) { 872 == KMessageBox::No) {
833 // import the data to a new window. 873 // import the data to a new window.
834 PwM *newInstance = init->createMainWnd(); 874 PwM *newInstance = init->createMainWnd();
835 bool ok = newInstance->importFromText(); 875 bool ok = newInstance->importFromText();
836 if (!ok) { 876 if (!ok) {
837 newInstance->setForceQuit(true); 877 newInstance->setForceQuit(true);
838 delete_and_null(newInstance); 878 delete_and_null(newInstance);
839 } 879 }
840 return ok; 880 return ok;
841 } 881 }
842 } 882 }
843 883
844 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 884 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
845 PwMerror ret; 885 PwMerror ret;
846 QString path(KFileDialog::getOpenFileName(QString::null, 886 QString path(KFileDialog::getOpenFileName(QString::null,
847 i18n("*|PWM-exported text file"), 887 i18n("*|PWM-exported text file"),
848 this)); 888 this));
849 if (path == "") 889 if (path == "")
850 goto cancelImport; 890 goto cancelImport;
851 891
852 ret = curDoc()->importFromText(&path, 0); 892 ret = curDoc()->importFromText(&path, 0);
853 if (ret == e_fileFormat) { 893 if (ret == e_fileFormat) {
854 KMessageBox::error(this, 894 KMessageBox::error(this,
855 i18n("Could not read file-format.\n" 895 i18n("Could not read file-format.\n"
856 "This seems to be _not_ a valid file " 896 "This seems to be _not_ a valid file "
857 "exported by PwM."), 897 "exported by PwM."),
858 i18n("invalid file-format")); 898 i18n("invalid file-format"));
859 goto cancelImport; 899 goto cancelImport;
860 } else if (ret == e_invalidArg) { 900 } else if (ret == e_invalidArg) {
861 BUG(); 901 BUG();
862 goto cancelImport; 902 goto cancelImport;
863 } else if (ret != e_success) { 903 } else if (ret != e_success) {
864 KMessageBox::error(this, 904 KMessageBox::error(this,
865 i18n("Could not import file!\n" 905 i18n("Could not import file!\n"
866 "Do you have permission to read this file? " 906 "Do you have permission to read this file? "
867 "Do you have enough free memory?"), 907 "Do you have enough free memory?"),
868 i18n("import failed")); 908 i18n("import failed"));
869 goto cancelImport; 909 goto cancelImport;
870 } 910 }
871 setVirgin(false); 911 setVirgin(false);
872 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 912 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
873 return true; 913 return true;
874 914
875cancelImport: 915cancelImport:
876 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 916 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
877 return false; 917 return false;
878} 918}
879 919
880void PwM::exportToGpasman() 920void PwM::exportToGpasman()
881{ 921{
882 PWM_ASSERT(curDoc()); 922 PWM_ASSERT(curDoc());
883 if (curDoc()->isDocEmpty()) { 923 if (curDoc()->isDocEmpty()) {
884 KMessageBox::information(this, 924 KMessageBox::information(this,
885 i18n 925 i18n
886 ("Sorry, there's nothing to export.\n" 926 ("Sorry, there's nothing to export.\n"
887 "Please first add some passwords."), 927 "Please first add some passwords."),
888 i18n("nothing to do")); 928 i18n("nothing to do"));
889 return; 929 return;
890 } 930 }
891 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 931 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
892 QString fn(KFileDialog::getSaveFileName(QString::null, 932 QString fn(KFileDialog::getSaveFileName(QString::null,
893 i18n("*|Gpasman or Kpasman file"), 933 i18n("*|Gpasman or Kpasman file"),
894 this)); 934 this));
895 if (fn == "") { 935 if (fn == "") {
896 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 936 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
897 return; 937 return;
898 } 938 }
899 939
900 PwMerror ret = curDoc()->exportToGpasman(&fn); 940 PwMerror ret = curDoc()->exportToGpasman(&fn);
901 if (ret != e_success) { 941 if (ret != e_success) {
902 if (ret == e_noPw) { 942 if (ret == e_noPw) {
903 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 943 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
904 return; 944 return;
905 } 945 }
906 KMessageBox::error(this, 946 KMessageBox::error(this,
907 i18n("Error: Couldn't write to file.\n" 947 i18n("Error: Couldn't write to file.\n"
908 "Please check if you have permission to write " 948 "Please check if you have permission to write "
909 "to the file in that directory."), 949 "to the file in that directory."),
910 i18n("error while writing")); 950 i18n("error while writing"));
911 } else 951 } else
912 showStatMsg(i18n("Successfully exported data.")); 952 showStatMsg(i18n("Successfully exported data."));
913 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 953 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
914} 954}
915 955
916void PwM::exportToKWallet() 956void PwM::exportToKWallet()
917{ 957{
918#ifdef CONFIG_KWALLETIF 958#ifdef CONFIG_KWALLETIF
919 if (!checkAndAskForKWalletEmu()) 959 if (!checkAndAskForKWalletEmu())
920 return; 960 return;
921 PWM_ASSERT(curDoc()); 961 PWM_ASSERT(curDoc());
922 if (curDoc()->isDocEmpty()) { 962 if (curDoc()->isDocEmpty()) {
923 KMessageBox::information(this, 963 KMessageBox::information(this,
924 i18n 964 i18n
925 ("Sorry, there's nothing to export.\n" 965 ("Sorry, there's nothing to export.\n"
926 "Please first add some passwords."), 966 "Please first add some passwords."),
927 i18n("nothing to do")); 967 i18n("nothing to do"));
928 init->initKWalletEmu(); 968 init->initKWalletEmu();
929 return; 969 return;
930 } 970 }
931 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 971 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
932 KWalletIf walletIf(this); 972 KWalletIf walletIf(this);
933 if (walletIf.kwalletExport(curDoc())) { 973 if (walletIf.kwalletExport(curDoc())) {
934 KMessageBox::information(this, 974 KMessageBox::information(this,
935 i18n("Successfully exported the data of the current " 975 i18n("Successfully exported the data of the current "
936 "document to KWallet."), 976 "document to KWallet."),
937 i18n("Successfully exported data.")); 977 i18n("Successfully exported data."));
938 showStatMsg(i18n("Successfully exported data.")); 978 showStatMsg(i18n("Successfully exported data."));
939 } 979 }
940 init->initKWalletEmu(); 980 init->initKWalletEmu();
941 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 981 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
942#endif // CONFIG_KWALLETIF 982#endif // CONFIG_KWALLETIF
943} 983}
944 984
945bool PwM::importFromGpasman() 985bool PwM::importFromGpasman()
946{ 986{
947 if (!isVirgin()) { 987 if (!isVirgin()) {
948 if (KMessageBox::questionYesNo(this, 988 if (KMessageBox::questionYesNo(this,
949 i18n("Do you want to import the data " 989 i18n("Do you want to import the data "
950 "into the current document? (If you " 990 "into the current document? (If you "
951 "select \"no\", a new document will be " 991 "select \"no\", a new document will be "
952 "opened.)"), 992 "opened.)"),
953 i18n("import into this document?")) 993 i18n("import into this document?"))
954 == KMessageBox::No) { 994 == KMessageBox::No) {
955 // import the data to a new window. 995 // import the data to a new window.
956 PwM *newInstance = init->createMainWnd(); 996 PwM *newInstance = init->createMainWnd();
957 bool ok = newInstance->importFromGpasman(); 997 bool ok = newInstance->importFromGpasman();
958 if (!ok) { 998 if (!ok) {
959 newInstance->setForceQuit(true); 999 newInstance->setForceQuit(true);
960 delete_and_null(newInstance); 1000 delete_and_null(newInstance);
961 } 1001 }
962 return ok; 1002 return ok;
963 } 1003 }
964 } 1004 }
965 1005
966 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1006 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
967 PwMerror ret; 1007 PwMerror ret;
968 QString path(KFileDialog::getOpenFileName(QString::null, 1008 QString path(KFileDialog::getOpenFileName(QString::null,
969 i18n("*|Gpasman or Kpasman file"), this)); 1009 i18n("*|Gpasman or Kpasman file"), this));
970 if (path == "") 1010 if (path == "")
971 goto cancelImport; 1011 goto cancelImport;
972 ret = curDoc()->importFromGpasman(&path); 1012 ret = curDoc()->importFromGpasman(&path);
973 if (ret == e_wrongPw) { 1013 if (ret == e_wrongPw) {
974 if (KMessageBox::questionYesNo(this, 1014 if (KMessageBox::questionYesNo(this,
975 i18n 1015 i18n
976 ("This is probably the wrong master-password" 1016 ("This is probably the wrong master-password"
977 "you have typed in.\n" 1017 "you have typed in.\n"
978 "There is no real way to determine the " 1018 "There is no real way to determine the "
979 "correctness of the password in the Gpasman " 1019 "correctness of the password in the Gpasman "
980 "file-format. But I think this " 1020 "file-format. But I think this "
981 "password ist wrong.\n" 1021 "password ist wrong.\n"
982 "Do you want to continue nevertheless?"), 1022 "Do you want to continue nevertheless?"),
983 i18n("password error")) 1023 i18n("password error"))
984 == KMessageBox::No) { 1024 == KMessageBox::No) {
985 goto cancelImport; 1025 goto cancelImport;
986 } 1026 }
987 } else if (ret != e_success) { 1027 } else if (ret != e_success) {
988 KMessageBox::error(this, 1028 KMessageBox::error(this,
989 i18n("Could not import file!\n" 1029 i18n("Could not import file!\n"
990 "Do you have permission to read this file?"), 1030 "Do you have permission to read this file?"),
991 i18n("import failed")); 1031 i18n("import failed"));
992 goto cancelImport; 1032 goto cancelImport;
993 } 1033 }
994 setVirgin(false); 1034 setVirgin(false);
995 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1035 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
996 return true; 1036 return true;
997 1037
998cancelImport: 1038cancelImport:
999 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1039 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1000 return false; 1040 return false;
1001} 1041}
1002 1042
1003#ifdef CONFIG_KWALLETIF 1043#ifdef CONFIG_KWALLETIF
1004bool PwM::checkAndAskForKWalletEmu() 1044bool PwM::checkAndAskForKWalletEmu()
1005{ 1045{
1006 if (init->kwalletEmu()) { 1046 if (init->kwalletEmu()) {
1007 /* KWallet emulation is enabled. We can't import/export 1047 /* KWallet emulation is enabled. We can't import/export
1008 * data from/to it, while emulation is active. 1048 * data from/to it, while emulation is active.
1009 */ 1049 */
1010 if (KMessageBox::questionYesNo(this, 1050 if (KMessageBox::questionYesNo(this,
1011 i18n("KWallet emulation is enabled.\n" 1051 i18n("KWallet emulation is enabled.\n"
1012 "You can't import or export data from/to " 1052 "You can't import or export data from/to "
1013 "the original KWallet, while the emulation " 1053 "the original KWallet, while the emulation "
1014 "is active.\n" 1054 "is active.\n"
1015 "Do you want to tempoarly disable the KWallet emulation?"), 1055 "Do you want to tempoarly disable the KWallet emulation?"),
1016 i18n("Tempoarly disable KWallet emulation?")) 1056 i18n("Tempoarly disable KWallet emulation?"))
1017 == KMessageBox::Yes) { 1057 == KMessageBox::Yes) {
1018 init->initKWalletEmu(true); 1058 init->initKWalletEmu(true);
1019 PWM_ASSERT(!init->kwalletEmu()); 1059 PWM_ASSERT(!init->kwalletEmu());
1020 return true; 1060 return true;
1021 } 1061 }
1022 return false; 1062 return false;
1023 } 1063 }
1024 return true; 1064 return true;
1025} 1065}
1026#endif // CONFIG_KWALLETIF 1066#endif // CONFIG_KWALLETIF
1027 1067
1028bool PwM::importKWallet() 1068bool PwM::importKWallet()
1029{ 1069{
1030#ifdef CONFIG_KWALLETIF 1070#ifdef CONFIG_KWALLETIF
1031 if (!checkAndAskForKWalletEmu()) 1071 if (!checkAndAskForKWalletEmu())
1032 return false; 1072 return false;
1033 KWalletIf walletIf(this); 1073 KWalletIf walletIf(this);
1034 if (!isVirgin()) { 1074 if (!isVirgin()) {
1035 if (KMessageBox::questionYesNo(this, 1075 if (KMessageBox::questionYesNo(this,
1036 i18n("Do you want to import the data " 1076 i18n("Do you want to import the data "
1037 "into the current document? (If you " 1077 "into the current document? (If you "
1038 "select \"no\", a new document will be " 1078 "select \"no\", a new document will be "
1039 "opened.)"), 1079 "opened.)"),
1040 i18n("import into this document?")) 1080 i18n("import into this document?"))
1041 == KMessageBox::No) { 1081 == KMessageBox::No) {
1042 // import the data to a new window. 1082 // import the data to a new window.
1043 PwM *newInstance = init->createMainWnd(); 1083 PwM *newInstance = init->createMainWnd();
1044 bool ok = newInstance->importKWallet(); 1084 bool ok = newInstance->importKWallet();
1045 if (!ok) { 1085 if (!ok) {
1046 newInstance->setForceQuit(true); 1086 newInstance->setForceQuit(true);
1047 delete_and_null(newInstance); 1087 delete_and_null(newInstance);
1048 goto exit_fail; 1088 goto exit_fail;
1049 } else { 1089 } else {
1050 goto exit_ok; 1090 goto exit_ok;
1051 } 1091 }
1052 } 1092 }
1053 } 1093 }
1054 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1094 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1055 if (!walletIf.kwalletImport(curDoc())) { 1095 if (!walletIf.kwalletImport(curDoc())) {
1056 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1096 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1057 showStatMsg(i18n("KWallet import failed")); 1097 showStatMsg(i18n("KWallet import failed"));
1058 goto exit_fail; 1098 goto exit_fail;
1059 } 1099 }
1060 KMessageBox::information(this, 1100 KMessageBox::information(this,
1061 i18n("Successfully imported the KWallet data " 1101 i18n("Successfully imported the KWallet data "
1062 "into the current document."), 1102 "into the current document."),
1063 i18n("successfully imported")); 1103 i18n("successfully imported"));
1064 showStatMsg(i18n("successfully imported")); 1104 showStatMsg(i18n("successfully imported"));
1065 setVirgin(false); 1105 setVirgin(false);
1066 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1106 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1067 1107
1068exit_ok: 1108exit_ok:
1069 init->initKWalletEmu(); 1109 init->initKWalletEmu();
1070 return true; 1110 return true;
1071 1111
1072exit_fail: 1112exit_fail:
1073 init->initKWalletEmu(); 1113 init->initKWalletEmu();
1074#endif // CONFIG_KWALLETIF 1114#endif // CONFIG_KWALLETIF
1075 return false; 1115 return false;
1076} 1116}
1077 1117
1078void PwM::print_slot() 1118void PwM::print_slot()
1079{ 1119{
1080 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1120 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1081#ifndef PWM_EMBEDDED 1121#ifndef PWM_EMBEDDED
1082 PwMPrint p(curDoc(), this); 1122 PwMPrint p(curDoc(), this);
1083 p.printNow(); 1123 p.printNow();
1084#else 1124#else
1085 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); 1125 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED");
1086#endif 1126#endif
1087 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1127 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1088} 1128}
1089 1129
1090void PwM::genNewCard_slot() 1130void PwM::genNewCard_slot()
1091{ 1131{
1092#ifdef CONFIG_KEYCARD 1132#ifdef CONFIG_KEYCARD
1093 init->keycard()->genNewCard(); 1133 init->keycard()->genNewCard();
1094#endif 1134#endif
1095} 1135}
1096 1136
1097void PwM::eraseCard_slot() 1137void PwM::eraseCard_slot()
1098{ 1138{
1099#ifdef CONFIG_KEYCARD 1139#ifdef CONFIG_KEYCARD
1100 init->keycard()->eraseCard(); 1140 init->keycard()->eraseCard();
1101#endif 1141#endif
1102} 1142}
1103 1143
1104void PwM::readCardId_slot() 1144void PwM::readCardId_slot()
1105{ 1145{
1106#ifdef CONFIG_KEYCARD 1146#ifdef CONFIG_KEYCARD
1107 init->keycard()->displayKey(); 1147 init->keycard()->displayKey();
1108#endif 1148#endif
1109} 1149}
1110 1150
1111void PwM::makeCardBackup_slot() 1151void PwM::makeCardBackup_slot()
1112{ 1152{
1113#ifdef CONFIG_KEYCARD 1153#ifdef CONFIG_KEYCARD
1114 init->keycard()->makeBackupImage(); 1154 init->keycard()->makeBackupImage();
1115#endif 1155#endif
1116} 1156}
1117 1157
1118void PwM::replayCardBackup_slot() 1158void PwM::replayCardBackup_slot()
1119{ 1159{
1120#ifdef CONFIG_KEYCARD 1160#ifdef CONFIG_KEYCARD
1121 init->keycard()->replayBackupImage(); 1161 init->keycard()->replayBackupImage();
1122#endif 1162#endif
1123} 1163}
1124 1164
1125void PwM::execLauncher_slot() 1165void PwM::execLauncher_slot()
1126{ 1166{
1127 PWM_ASSERT(curDoc()); 1167 PWM_ASSERT(curDoc());
1128 if (curDoc()->isDeepLocked()) 1168 if (curDoc()->isDeepLocked())
1129 return; 1169 return;
1130 unsigned int curEntryIndex; 1170 unsigned int curEntryIndex;
1131 if (!view->getCurEntryIndex(&curEntryIndex)) 1171 if (!view->getCurEntryIndex(&curEntryIndex))
1132 return; 1172 return;
1133 bool ret = curDoc()->execLauncher(view->getCurrentCategory(), 1173 bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
1134 curEntryIndex); 1174 curEntryIndex);
1135 if (ret) 1175 if (ret)
1136 showStatMsg(i18n("Executed the \"Launcher\".")); 1176 showStatMsg(i18n("Executed the \"Launcher\"."));
1137 else 1177 else
1138 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); 1178 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
1139} 1179}
1140 1180
1141void PwM::goToURL_slot() 1181void PwM::goToURL_slot()
1142{ 1182{
1143 PWM_ASSERT(curDoc()); 1183 PWM_ASSERT(curDoc());
1144 if (curDoc()->isDeepLocked()) 1184 if (curDoc()->isDeepLocked())
1145 return; 1185 return;
1146 unsigned int curEntryIndex; 1186 unsigned int curEntryIndex;
1147 if (!view->getCurEntryIndex(&curEntryIndex)) 1187 if (!view->getCurEntryIndex(&curEntryIndex))
1148 return; 1188 return;
1149 bool ret = curDoc()->goToURL(view->getCurrentCategory(), 1189 bool ret = curDoc()->goToURL(view->getCurrentCategory(),
1150 curEntryIndex); 1190 curEntryIndex);
1151 if (ret) 1191 if (ret)
1152 showStatMsg(i18n("started browser with current URL.")); 1192 showStatMsg(i18n("started browser with current URL."));
1153 else 1193 else
1154 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); 1194 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
1155} 1195}
1156 1196
1157void PwM::copyToClipboard(const QString &s) 1197void PwM::copyToClipboard(const QString &s)
1158{ 1198{
1159 QClipboard *cb = QApplication::clipboard(); 1199 QClipboard *cb = QApplication::clipboard();
1160#ifndef PWM_EMBEDDED 1200#ifndef PWM_EMBEDDED
1161 if (cb->supportsSelection()) 1201 if (cb->supportsSelection())
1162 cb->setText(s, QClipboard::Selection); 1202 cb->setText(s, QClipboard::Selection);
1163 cb->setText(s, QClipboard::Clipboard); 1203 cb->setText(s, QClipboard::Clipboard);
1164#else 1204#else
1165 cb->setText(s); 1205 cb->setText(s);
1166 1206
1167#endif 1207#endif
1168 1208
1169} 1209}
1170 1210
1171void PwM::showStatMsg(const QString &msg) 1211void PwM::showStatMsg(const QString &msg)
1172{ 1212{
1173#ifndef PWM_EMBEDDED 1213#ifndef PWM_EMBEDDED
1174 KStatusBar *statBar = statusBar(); 1214 KStatusBar *statBar = statusBar();
1175 statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); 1215 statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1176#else 1216#else
1177 qDebug("Statusbar : %s",msg.latin1()); 1217 qDebug("Statusbar : %s",msg.latin1());
1178#endif 1218#endif
1179} 1219}
1180 1220
1181void PwM::focusInEvent(QFocusEvent *e) 1221void PwM::focusInEvent(QFocusEvent *e)
1182{ 1222{
1183 if (e->gotFocus()) { 1223 if (e->gotFocus()) {
1184 emit gotFocus(this); 1224 emit gotFocus(this);
1185 } else if (e->lostFocus()) { 1225 } else if (e->lostFocus()) {
1186 emit lostFocus(this); 1226 emit lostFocus(this);
1187 } 1227 }
1188} 1228}
1189 1229
1230
1231#ifdef PWM_EMBEDDED
1232
1233void PwM::showLicense_slot()
1234{
1235 KApplication::showLicence();
1236}
1237
1238void PwM::faq_slot()
1239{
1240 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
1241}
1242
1243void PwM::createAboutData_slot()
1244{
1245 QString version;
1246#include <../version>
1247 QMessageBox::about( this, "About PwManager/Pi",
1248 "PwManager/Platform-independent\n"
1249 "(PWM/Pi) " +version + " - " +
1250#ifdef DESKTOP_VERSION
1251 "Desktop Edition\n"
1252#else
1253 "PDA-Edition\n"
1254 "for: Zaurus 5500 / 7x0 / 8x0\n"
1255#endif
1256
1257 "(c) 2004 Ulf Schenk\n"
1258 "(c) 2004 Lutz Rogowski\n"
1259 "(c) 1997-2003, The KDE PIM Team\n"
1260
1261 "Michael Buesch - main programming and current maintainer\nmbuesch@freenet.de\n"
1262 "Matt Scifo - original implementaion of \n"
1263 "\"categories\" and the password-tree \n"
1264 "in the system-tray. Original implementations of \n"
1265 "numerous view-improvements.\n"
1266 "mscifo@o1.com\n"
1267 "Elias Probst - Gentoo ebuild maintainer.\nelias.probst@gmx.de\n"
1268 "George Staikos - KWallet\nstaikos@kde.org\n"
1269 "Matthew Palmer - rc2 code\nmjp16@uow.edu.au\n"
1270 "Olivier Sessink - gpasman\ngpasman@nl.linux.org\n"
1271 "The libgcrypt developers - Blowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
1272 "Troy Engel - kpasman\n tengel@sonic.net\n"
1273 "Wickey - graphics-design in older versions\nwickey@gmx.at\n"
1274 "Ian MacGregor - original documentation author.\n"
1275 );
1276}
1277
1278#endif
1279
1280
1190#ifndef PWM_EMBEDDED 1281#ifndef PWM_EMBEDDED
1191#include "pwm.moc" 1282#include "pwm.moc"
1192#endif 1283#endif
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index 3a79e67..36a8b5b 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -1,255 +1,261 @@
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#ifndef __PWM_H 20#ifndef __PWM_H
21#define __PWM_H 21#define __PWM_H
22 22
23 23
24#include <kpopupmenu.h> 24#include <kpopupmenu.h>
25#include <klistview.h> 25#include <klistview.h>
26#include <kmainwindow.h> 26#include <kmainwindow.h>
27 27
28#ifndef PWM_EMBEDDED 28#ifndef PWM_EMBEDDED
29#include <kwin.h> 29#include <kwin.h>
30#include <kapp.h> 30#include <kapp.h>
31#include <kdeversion.h> 31#include <kdeversion.h>
32#else 32#else
33#endif 33#endif
34 34
35#include <kaction.h> 35#include <kaction.h>
36 36
37 37
38#include <qglobal.h> 38#include <qglobal.h>
39 39
40#include "pwmview.h" 40#include "pwmview.h"
41#include "pwmexception.h" 41#include "pwmexception.h"
42 42
43 43
44/** timeout for displaying a message on the status-bar (in seconds) */ 44/** timeout for displaying a message on the status-bar (in seconds) */
45 #define STATUSBAR_MSG_TIMEOUT5 45 #define STATUSBAR_MSG_TIMEOUT5
46 46
47 47
48class PwMInit; 48class PwMInit;
49 49
50/** PwM is the base class of the project */ 50/** PwM is the base class of the project */
51class PwM : public KMainWindow 51class PwM : public KMainWindow
52{ 52{
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
55 friend class PwMView; 55 friend class PwMView;
56 /** construtor */ 56 /** construtor */
57 PwM(PwMInit *_init, PwMDoc *doc, 57 PwM(PwMInit *_init, PwMDoc *doc,
58 bool virginity = true, 58 bool virginity = true,
59 QWidget* parent = 0, const char *name = 0); 59 QWidget* parent = 0, const char *name = 0);
60 /** destructor */ 60 /** destructor */
61 ~PwM(); 61 ~PwM();
62 62
63 /** copy some text to the global clipboard */ 63 /** copy some text to the global clipboard */
64 static void copyToClipboard(const QString &s); 64 static void copyToClipboard(const QString &s);
65 65
66 /** returns pointer to the view */ 66 /** returns pointer to the view */
67 PwMView * curView() 67 PwMView * curView()
68 { return view; } 68 { return view; }
69 /** returns pointer to the currently using document. */ 69 /** returns pointer to the currently using document. */
70 PwMDoc * curDoc() 70 PwMDoc * curDoc()
71 { return curView()->document(); } 71 { return curView()->document(); }
72 /** open a new doc with the given filename */ 72 /** open a new doc with the given filename */
73 PwMDoc * openDoc(QString filename, bool openDeepLocked = false); 73 PwMDoc * openDoc(QString filename, bool openDeepLocked = false);
74 /** show a message on the global status bar. 74 /** show a message on the global status bar.
75 * The message times out after some seconds. 75 * The message times out after some seconds.
76 */ 76 */
77 void showStatMsg(const QString &msg); 77 void showStatMsg(const QString &msg);
78 /** ask the user where to save the doc (if it has not been saved, yet) 78 /** ask the user where to save the doc (if it has not been saved, yet)
79 * and write the data to disk. 79 * and write the data to disk.
80 */ 80 */
81 bool save(); 81 bool save();
82 /** ask the user where to save the doc 82 /** ask the user where to save the doc
83 * and write the data to disk. 83 * and write the data to disk.
84 */ 84 */
85 bool saveAs(); 85 bool saveAs();
86 /** force quit. Quit this window, always! Don't minimize it */ 86 /** force quit. Quit this window, always! Don't minimize it */
87 bool isForceQuit() 87 bool isForceQuit()
88 { return forceQuit; } 88 { return forceQuit; }
89 /** set forceQuit */ 89 /** set forceQuit */
90 void setForceQuit(bool force) 90 void setForceQuit(bool force)
91 { forceQuit = force; } 91 { forceQuit = force; }
92 /** force minimize this window */ 92 /** force minimize this window */
93 bool isForceMinimizeToTray() 93 bool isForceMinimizeToTray()
94 { return forceMinimizeToTray; } 94 { return forceMinimizeToTray; }
95 /** set forceMinimizeToTray */ 95 /** set forceMinimizeToTray */
96 void setForceMinimizeToTray(bool force) 96 void setForceMinimizeToTray(bool force)
97 { forceMinimizeToTray = force; } 97 { forceMinimizeToTray = force; }
98 98
99public slots: 99public slots:
100 /** file/new triggered */ 100 /** file/new triggered */
101 void new_slot(); 101 void new_slot();
102 /** file/open triggered */ 102 /** file/open triggered */
103//US ENH 103//US ENH
104 void open_slot(); 104 void open_slot();
105 void open_slot(QString fn); 105 void open_slot(QString fn);
106 /** file/close triggered */ 106 /** file/close triggered */
107 void close_slot(); 107 void close_slot();
108 /** file/quit triggered */ 108 /** file/quit triggered */
109 void quitButton_slot(); 109 void quitButton_slot();
110 /** file/save triggered */ 110 /** file/save triggered */
111 void save_slot(); 111 void save_slot();
112 /** file/saveAs triggered */ 112 /** file/saveAs triggered */
113 void saveAs_slot(); 113 void saveAs_slot();
114 /** file/export/text triggered */ 114 /** file/export/text triggered */
115 void exportToText(); 115 void exportToText();
116 /** file/export/gpasman triggered */ 116 /** file/export/gpasman triggered */
117 void exportToGpasman(); 117 void exportToGpasman();
118 /** file/export/kwallet triggered */ 118 /** file/export/kwallet triggered */
119 void exportToKWallet(); 119 void exportToKWallet();
120 /** file/import/text triggered */ 120 /** file/import/text triggered */
121 bool importFromText(); 121 bool importFromText();
122 /** file/import/gpasman triggered */ 122 /** file/import/gpasman triggered */
123 bool importFromGpasman(); 123 bool importFromGpasman();
124 /** file/import/kwallet triggered */ 124 /** file/import/kwallet triggered */
125 bool importKWallet(); 125 bool importKWallet();
126 /** file/print triggered */ 126 /** file/print triggered */
127 void print_slot(); 127 void print_slot();
128 /** manage/add triggered */ 128 /** manage/add triggered */
129 //US ENH : changed code to run with older MOC 129 //US ENH : changed code to run with older MOC
130 void addPwd_slot(); 130 void addPwd_slot();
131 void addPwd_slot(QString *pw, PwMDoc *_doc); 131 void addPwd_slot(QString *pw, PwMDoc *_doc);
132 /** manage/edit triggered */ 132 /** manage/edit triggered */
133 //US ENH : changed code to run with older MOC 133 //US ENH : changed code to run with older MOC
134 void editPwd_slot(); 134 void editPwd_slot();
135 void editPwd_slot(const QString *category); 135 void editPwd_slot(const QString *category);
136 void editPwd_slot(const QString *category = 0, const int *index = 0, 136 void editPwd_slot(const QString *category = 0, const int *index = 0,
137 PwMDoc *_doc = 0); 137 PwMDoc *_doc = 0);
138 /** manage/delete triggered */ 138 /** manage/delete triggered */
139 void deletePwd_slot(); 139 void deletePwd_slot();
140 /** execute the "Launcher" entry */ 140 /** execute the "Launcher" entry */
141 void execLauncher_slot(); 141 void execLauncher_slot();
142 /** open browser with URL entry */ 142 /** open browser with URL entry */
143 void goToURL_slot(); 143 void goToURL_slot();
144 /** manage/changeMasterPwd triggered */ 144 /** manage/changeMasterPwd triggered */
145 void changeMasterPwd_slot(); 145 void changeMasterPwd_slot();
146 /** lock current document */ 146 /** lock current document */
147 void lockWnd_slot(); 147 void lockWnd_slot();
148 /** deeplock current document */ 148 /** deeplock current document */
149 void deepLockWnd_slot(); 149 void deepLockWnd_slot();
150 /** window/unlock triggered */ 150 /** window/unlock triggered */
151 void unlockWnd_slot(); 151 void unlockWnd_slot();
152 /** find item */ 152 /** find item */
153 void find_slot(); 153 void find_slot();
154 /** configure clicked */ 154 /** configure clicked */
155 void config_slot(); 155 void config_slot();
156 /** (de)activate the "change master pw" button in the menu-bar */ 156 /** (de)activate the "change master pw" button in the menu-bar */
157 void activateMpButton(bool activate = true); 157 void activateMpButton(bool activate = true);
158 /** generate a new chipcard */ 158 /** generate a new chipcard */
159 void genNewCard_slot(); 159 void genNewCard_slot();
160 /** completely erase the current card */ 160 /** completely erase the current card */
161 void eraseCard_slot(); 161 void eraseCard_slot();
162 /** returns the ID number of the current card */ 162 /** returns the ID number of the current card */
163 void readCardId_slot(); 163 void readCardId_slot();
164 /** make backup image of the current card */ 164 /** make backup image of the current card */
165 void makeCardBackup_slot(); 165 void makeCardBackup_slot();
166 /** write backup image to current card */ 166 /** write backup image to current card */
167 void replayCardBackup_slot(); 167 void replayCardBackup_slot();
168 168
169#ifdef PWM_EMBEDDED
170 void showLicense_slot();
171 void faq_slot();
172 void createAboutData_slot();
173#endif
174
169protected: 175protected:
170 /** is this window virgin? */ 176 /** is this window virgin? */
171 bool isVirgin() 177 bool isVirgin()
172 { return virgin; } 178 { return virgin; }
173 /** add/remove virginity */ 179 /** add/remove virginity */
174 void setVirgin(bool v); 180 void setVirgin(bool v);
175 /** initialize the menubar */ 181 /** initialize the menubar */
176 void initMenubar(); 182 void initMenubar();
177 /** initialize the toolbar */ 183 /** initialize the toolbar */
178 void initToolbar(); 184 void initToolbar();
179 /** initialize the window-metrics */ 185 /** initialize the window-metrics */
180 void initMetrics(); 186 void initMetrics();
181 /** close-event */ 187 /** close-event */
182 void closeEvent(QCloseEvent *e); 188 void closeEvent(QCloseEvent *e);
183 /** creates a new PwM-ListView and returns it */ 189 /** creates a new PwM-ListView and returns it */
184 PwMView * makeNewListView(PwMDoc *doc); 190 PwMView * makeNewListView(PwMDoc *doc);
185 /** Window hide-event */ 191 /** Window hide-event */
186 void hideEvent(QHideEvent *); 192 void hideEvent(QHideEvent *);
187 /** is this window minimized? */ 193 /** is this window minimized? */
188 bool isMinimized() 194 bool isMinimized()
189 { 195 {
190#ifndef PWM_EMBEDDED 196#ifndef PWM_EMBEDDED
191 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) 197 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
192 return KWin::windowInfo(winId()).isMinimized(); 198 return KWin::windowInfo(winId()).isMinimized();
193 #else // KDE_VERSION 199 #else // KDE_VERSION
194 return KWin::info(winId()).isIconified(); 200 return KWin::info(winId()).isIconified();
195 #endif // KDE_VERSION 201 #endif // KDE_VERSION
196#else 202#else
197 return false; 203 return false;
198#endif 204#endif
199 } 205 }
200 /** window got the focus */ 206 /** window got the focus */
201 void focusInEvent(QFocusEvent *e); 207 void focusInEvent(QFocusEvent *e);
202 /** update the caption string */ 208 /** update the caption string */
203 void updateCaption(); 209 void updateCaption();
204#ifdef CONFIG_KWALLETIF 210#ifdef CONFIG_KWALLETIF
205 /** check if kwalletemu is enabled and ask the user what to do */ 211 /** check if kwalletemu is enabled and ask the user what to do */
206 bool checkAndAskForKWalletEmu(); 212 bool checkAndAskForKWalletEmu();
207#endif // CONFIG_KWALLETIF 213#endif // CONFIG_KWALLETIF
208 214
209protected slots: 215protected slots:
210 /** doc got closed */ 216 /** doc got closed */
211 void docClosed(PwMDoc *doc); 217 void docClosed(PwMDoc *doc);
212 218
213signals: 219signals:
214 /** window got closed (by user or someone else) */ 220 /** window got closed (by user or someone else) */
215 void closed(PwM *wnd); 221 void closed(PwM *wnd);
216 /** window got the focus (was brought to foreground) */ 222 /** window got the focus (was brought to foreground) */
217 void gotFocus(PwM *wnd); 223 void gotFocus(PwM *wnd);
218 /** window lost the focus */ 224 /** window lost the focus */
219 void lostFocus(PwM *wnd); 225 void lostFocus(PwM *wnd);
220 226
221protected: 227protected:
222 /** pointer to the view active in this KMainWindow */ 228 /** pointer to the view active in this KMainWindow */
223 PwMView *view; 229 PwMView *view;
224 /** pointer to the init class */ 230 /** pointer to the init class */
225 PwMInit *init; 231 PwMInit *init;
226 /** has this window already lost its virginity? 232 /** has this window already lost its virginity?
227 * Means is there an open working document 233 * Means is there an open working document
228 */ 234 */
229 bool virgin; 235 bool virgin;
230 /** "file" popup-menu */ 236 /** "file" popup-menu */
231 KPopupMenu *filePopup; 237 KPopupMenu *filePopup;
232 238
233 /** "manage" popup-menu */ 239 /** "manage" popup-menu */
234 KPopupMenu *managePopup; 240 KPopupMenu *managePopup;
235#ifdef CONFIG_KEYCARD 241#ifdef CONFIG_KEYCARD
236 /** "chipcard" popup-menu */ 242 /** "chipcard" popup-menu */
237 KPopupMenu *chipcardPopup; 243 KPopupMenu *chipcardPopup;
238#endif // CONFIG_KEYCARD 244#endif // CONFIG_KEYCARD
239 /** "view" popup-menu */ 245 /** "view" popup-menu */
240 KPopupMenu *viewPopup; 246 KPopupMenu *viewPopup;
241 /** "options" popup-menu */ 247 /** "options" popup-menu */
242 KPopupMenu *optionsPopup; 248 KPopupMenu *optionsPopup;
243 /** "help" popup-menu */ 249 /** "help" popup-menu */
244 KPopupMenu *helpPopup; 250 KPopupMenu *helpPopup;
245 /** "export" popup-menu */ 251 /** "export" popup-menu */
246 KPopupMenu *exportPopup; 252 KPopupMenu *exportPopup;
247 /** "import" popup-menu */ 253 /** "import" popup-menu */
248 KPopupMenu *importPopup; 254 KPopupMenu *importPopup;
249 /** force quit this window? */ 255 /** force quit this window? */
250 bool forceQuit; 256 bool forceQuit;
251 /** force minimize this window to the tray */ 257 /** force minimize this window to the tray */
252 bool forceMinimizeToTray; 258 bool forceMinimizeToTray;
253}; 259};
254 260
255#endif 261#endif
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index 66a1b59..b308b40 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -1,436 +1,453 @@
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 "pwmdocui.h" 20#include "pwmdocui.h"
21#include "setmasterpwwndimpl.h" 21#include "setmasterpwwndimpl.h"
22#include "getmasterpwwndimpl.h" 22#include "getmasterpwwndimpl.h"
23#include "pwmexception.h" 23#include "pwmexception.h"
24#include "getkeycardwnd.h" 24#include "getkeycardwnd.h"
25#include "pwm.h" 25#include "pwm.h"
26#include "globalstuff.h" 26#include "globalstuff.h"
27#include "spinforsignal.h" 27#include "spinforsignal.h"
28 28
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31 31
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33#include <kfiledialog.h> 33#include <kfiledialog.h>
34 34
35#ifndef PWM_EMBEDDED 35#ifndef PWM_EMBEDDED
36#include <kwin.h> 36#include <kwin.h>
37#else 37#else
38#include <qdir.h>
38#endif 39#endif
39 40
40 41
41#ifdef CONFIG_KEYCARD 42#ifdef CONFIG_KEYCARD
42# include "pwmkeycard.h" 43# include "pwmkeycard.h"
43#endif 44#endif
44 45
45 46
46PwMDocUi::PwMDocUi(QObject *parent, const char *name) 47PwMDocUi::PwMDocUi(QObject *parent, const char *name)
47 : QObject(parent, name) 48 : QObject(parent, name)
48{ 49{
49 currentView = 0; 50 currentView = 0;
50 keyCard = 0; 51 keyCard = 0;
51} 52}
52 53
53PwMDocUi::~PwMDocUi() 54PwMDocUi::~PwMDocUi()
54{ 55{
55} 56}
56 57
57QString PwMDocUi::requestMpw(bool chipcard) 58QString PwMDocUi::requestMpw(bool chipcard)
58{ 59{
59 QString pw; 60 QString pw;
60 61
61 if (chipcard) { 62 if (chipcard) {
62#ifdef CONFIG_KEYCARD 63#ifdef CONFIG_KEYCARD
63 PWM_ASSERT(keyCard); 64 PWM_ASSERT(keyCard);
64 uint32_t id; 65 uint32_t id;
65 string ret; 66 string ret;
66 SpinForSignal *spinner = keyCard->getSpinner(); 67 SpinForSignal *spinner = keyCard->getSpinner();
67 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 68 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
68 spinner, SLOT(u32_str_slot(uint32_t, const string &))); 69 spinner, SLOT(u32_str_slot(uint32_t, const string &)));
69 keyCard->getKey(); 70 keyCard->getKey();
70 spinner->spin(&id, &ret); 71 spinner->spin(&id, &ret);
71 disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 72 disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
72 spinner, SLOT(u32_str_slot(uint32_t, const string &))); 73 spinner, SLOT(u32_str_slot(uint32_t, const string &)));
73 if (ret == "") 74 if (ret == "")
74 return ""; 75 return "";
75 pw = ret.c_str(); 76 pw = ret.c_str();
76#else // CONFIG_KEYCARD 77#else // CONFIG_KEYCARD
77 no_keycard_support_msg_box(currentView); 78 no_keycard_support_msg_box(currentView);
78#endif // CONFIG_KEYCARD 79#endif // CONFIG_KEYCARD
79 } else { 80 } else {
80 GetMasterPwWndImpl pwWnd; 81 GetMasterPwWndImpl pwWnd;
81#ifndef PWM_EMBEDDED 82#ifndef PWM_EMBEDDED
82 KWin::setState(pwWnd.winId(), NET::StaysOnTop); 83 KWin::setState(pwWnd.winId(), NET::StaysOnTop);
83#endif 84#endif
84 if (pwWnd.exec() != 1) 85 if (pwWnd.exec() != 1)
85 return ""; 86 return "";
86 pw = pwWnd.pwLineEdit->text(); 87 pw = pwWnd.pwLineEdit->text();
87 } 88 }
88 89
89 return pw; 90 return pw;
90} 91}
91 92
92QString PwMDocUi::requestNewMpw(bool *chipcard) 93QString PwMDocUi::requestNewMpw(bool *chipcard)
93{ 94{
94 QString pw; 95 QString pw;
95 SetMasterPwWndImpl pwWnd(currentView); 96 SetMasterPwWndImpl pwWnd(currentView);
96 pwWnd.setPwMKeyCard(keyCard); 97 pwWnd.setPwMKeyCard(keyCard);
97#ifndef PWM_EMBEDDED 98#ifndef PWM_EMBEDDED
98 if (!chipcard) { 99 if (!chipcard) {
99 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1)); 100 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1));
100 } 101 }
101#else 102#else
102 qDebug("PwMDocUi::requestNewMpw must be implemented"); 103 qDebug("PwMDocUi::requestNewMpw must be implemented");
103#endif 104#endif
104 105
105 if (pwWnd.exec() != 1) 106 if (pwWnd.exec() != 1)
106 return ""; 107 return "";
107 pw = pwWnd.getPw(chipcard).c_str(); 108 pw = pwWnd.getPw(chipcard).c_str();
108 109
109 return pw; 110 return pw;
110} 111}
111 112
112QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard) 113QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard)
113{ 114{
114 QString pw(requestMpw(*chipcard)); 115 QString pw(requestMpw(*chipcard));
115 if (pw == "") 116 if (pw == "")
116 return ""; 117 return "";
117 if (pw != *currentPw) { 118 if (pw != *currentPw) {
118 wrongMpwMsgBox(*chipcard); 119 wrongMpwMsgBox(*chipcard);
119 return ""; 120 return "";
120 } 121 }
121 122
122 pw = requestNewMpw(chipcard); 123 pw = requestNewMpw(chipcard);
123 if (pw == "") 124 if (pw == "")
124 return ""; 125 return "";
125 return pw; 126 return pw;
126} 127}
127 128
128void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix) 129void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix)
129{ 130{
130 QString msg; 131 QString msg;
131 if (prefix != "") { 132 if (prefix != "") {
132 msg += prefix; 133 msg += prefix;
133 msg += "\n"; 134 msg += "\n";
134 } 135 }
135 136
136 if (chipcard) { 137 if (chipcard) {
137 msg += i18n("Wrong key-card!\n" 138 msg += i18n("Wrong key-card!\n"
138 "Please try again with the " 139 "Please try again with the "
139 "correct key-card."); 140 "correct key-card.");
140 } else { 141 } else {
141 msg += i18n("Wrong master-password!\n" 142 msg += i18n("Wrong master-password!\n"
142 "Please try again."); 143 "Please try again.");
143 } 144 }
144 145
145 if (postfix != "") { 146 if (postfix != "") {
146 msg += "\n"; 147 msg += "\n";
147 msg += postfix; 148 msg += postfix;
148 } 149 }
149 KMessageBox::error(currentView, msg, 150 KMessageBox::error(currentView, msg,
150 (chipcard) ? (i18n("wrong chipcard")) 151 (chipcard) ? (i18n("wrong chipcard"))
151 : (i18n("password error"))); 152 : (i18n("password error")));
152} 153}
153 154
154void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix) 155void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix)
155{ 156{
156 QString msg; 157 QString msg;
157 if (prefix != "") { 158 if (prefix != "") {
158 msg += prefix; 159 msg += prefix;
159 msg += "\n"; 160 msg += "\n";
160 } 161 }
161 162
162 if (chipcard) { 163 if (chipcard) {
163 msg += i18n("No key-card found!\n" 164 msg += i18n("No key-card found!\n"
164 "Please insert the " 165 "Please insert the "
165 "correct key-card."); 166 "correct key-card.");
166 } else { 167 } else {
167 msg += i18n("No master-password given!"); 168 msg += i18n("No master-password given!");
168 } 169 }
169 170
170 if (postfix != "") { 171 if (postfix != "") {
171 msg += "\n"; 172 msg += "\n";
172 msg += postfix; 173 msg += postfix;
173 } 174 }
174 KMessageBox::error(currentView, msg, 175 KMessageBox::error(currentView, msg,
175 (chipcard) ? (i18n("no chipcard")) 176 (chipcard) ? (i18n("no chipcard"))
176 : (i18n("password error"))); 177 : (i18n("password error")));
177} 178}
178 179
179void PwMDocUi::rootAlertMsgBox() 180void PwMDocUi::rootAlertMsgBox()
180{ 181{
181 KMessageBox::error(currentView, 182 KMessageBox::error(currentView,
182 i18n("This feature is not available, " 183 i18n("This feature is not available, "
183 "if you execute PwM with \"root\" " 184 "if you execute PwM with \"root\" "
184 "UID 0 privileges, for security reasons!"), 185 "UID 0 privileges, for security reasons!"),
185 i18n("not allowed as root!")); 186 i18n("not allowed as root!"));
186} 187}
187 188
188void PwMDocUi::cantDeeplock_notSavedMsgBox() 189void PwMDocUi::cantDeeplock_notSavedMsgBox()
189{ 190{
190 KMessageBox::error(currentView, 191 KMessageBox::error(currentView,
191 i18n("Can't deep-lock, because the document " 192 i18n("Can't deep-lock, because the document "
192 "hasn't been saved, yet. Please save " 193 "hasn't been saved, yet. Please save "
193 "to a file and try again."), 194 "to a file and try again."),
194 i18n("not saved, yet")); 195 i18n("not saved, yet"));
195} 196}
196 197
197void PwMDocUi::gpmPwLenErrMsgBox() 198void PwMDocUi::gpmPwLenErrMsgBox()
198{ 199{
199 KMessageBox::error(currentView, 200 KMessageBox::error(currentView,
200 i18n("GPasman does not support passwords " 201 i18n("GPasman does not support passwords "
201 "shorter than 4 characters! Please try " 202 "shorter than 4 characters! Please try "
202 "again with a longer password."), 203 "again with a longer password."),
203 i18n("password too short")); 204 i18n("password too short"));
204} 205}
205 206
206int PwMDocUi::dirtyAskSave(const QString &docTitle) 207int PwMDocUi::dirtyAskSave(const QString &docTitle)
207{ 208{
208 int ret; 209 int ret;
209#ifndef PWM_EMBEDDED 210#ifndef PWM_EMBEDDED
210 ret = KMessageBox::questionYesNoCancel(currentView, 211 ret = KMessageBox::questionYesNoCancel(currentView,
211 i18n("The list \"") + 212 i18n("The list \"") +
212 docTitle + 213 docTitle +
213 i18n 214 i18n
214 ("\" has been modified.\n" 215 ("\" has been modified.\n"
215 "Do you want to save it?"), 216 "Do you want to save it?"),
216 i18n("save?")); 217 i18n("save?"));
217 if (ret == KMessageBox::Yes) { 218 if (ret == KMessageBox::Yes) {
218 return 0; 219 return 0;
219 } else if (ret == KMessageBox::No) { 220 } else if (ret == KMessageBox::No) {
220 return 1; 221 return 1;
221 } 222 }
222#else 223#else
223 ret = KMessageBox::warningYesNoCancel(currentView, 224 ret = KMessageBox::warningYesNoCancel(currentView,
224 i18n("The list \"") + 225 i18n("The list \"") +
225 docTitle + 226 docTitle +
226 i18n 227 i18n
227 ("\" has been modified.\n" 228 ("\" has been modified.\n"
228 "Do you want to save it?"), 229 "Do you want to save it?"),
229 i18n("save?")); 230 i18n("save?"));
230 if (ret == KMessageBox::Yes) { 231 if (ret == KMessageBox::Yes) {
231 return 0; 232 return 0;
232 } else if (ret == KMessageBox::No) { 233 } else if (ret == KMessageBox::No) {
233 return 1; 234 return 1;
234 } 235 }
235 236
236#endif 237#endif
237 238
238 // cancel 239 // cancel
239 return -1; 240 return -1;
240} 241}
241 242
242bool PwMDocUi::saveDocUi(PwMDoc *doc) 243bool PwMDocUi::saveDocUi(PwMDoc *doc)
243{ 244{
244 PWM_ASSERT(doc); 245 PWM_ASSERT(doc);
245 doc->timer()->getLock(DocTimer::id_autoLockTimer); 246 doc->timer()->getLock(DocTimer::id_autoLockTimer);
246 if (doc->isDocEmpty()) { 247 if (doc->isDocEmpty()) {
247 KMessageBox::information(currentView, 248 KMessageBox::information(currentView,
248 i18n 249 i18n
249 ("Sorry, there's nothing to save.\n" 250 ("Sorry, there's nothing to save.\n"
250 "Please first add some passwords."), 251 "Please first add some passwords."),
251 i18n("nothing to do")); 252 i18n("nothing to do"));
252 doc->timer()->putLock(DocTimer::id_autoLockTimer); 253 doc->timer()->putLock(DocTimer::id_autoLockTimer);
253 return true; 254 return true;
254 } 255 }
255 PwMerror ret = doc->saveDoc(conf()->confGlobCompression()); 256 PwMerror ret = doc->saveDoc(conf()->confGlobCompression());
256 if (ret == e_filename) { 257 if (ret == e_filename) {
257 doc->timer()->putLock(DocTimer::id_autoLockTimer); 258 doc->timer()->putLock(DocTimer::id_autoLockTimer);
258 return saveAsDocUi(doc); 259 return saveAsDocUi(doc);
259 } else if (ret == e_weakPw) { 260 } else if (ret == e_weakPw) {
260 KMessageBox::error(currentView, 261 KMessageBox::error(currentView,
261 i18n("Error: This is a weak password.\n" 262 i18n("Error: This is a weak password.\n"
262 "Please select another password."), 263 "Please select another password."),
263 i18n("weak password")); 264 i18n("weak password"));
264 doc->timer()->putLock(DocTimer::id_autoLockTimer); 265 doc->timer()->putLock(DocTimer::id_autoLockTimer);
265 return false; 266 return false;
266 } else if (ret == e_fileBackup) { 267 } else if (ret == e_fileBackup) {
267 KMessageBox::error(currentView, 268 KMessageBox::error(currentView,
268 i18n("Error: Couldn't make backup-file!"), 269 i18n("Error: Couldn't make backup-file!"),
269 i18n("backup failed")); 270 i18n("backup failed"));
270 doc->timer()->putLock(DocTimer::id_autoLockTimer); 271 doc->timer()->putLock(DocTimer::id_autoLockTimer);
271 return false; 272 return false;
272 } else if (ret != e_success) { 273 } else if (ret != e_success) {
273 KMessageBox::error(currentView, 274 KMessageBox::error(currentView,
274 i18n("Error: Couldn't write to file.\n" 275 i18n("Error: Couldn't write to file.\n"
275 "Please check if you have permission to " 276 "Please check if you have permission to "
276 "write to the file in that directory."), 277 "write to the file in that directory."),
277 i18n("error while writing")); 278 i18n("error while writing"));
278 doc->timer()->putLock(DocTimer::id_autoLockTimer); 279 doc->timer()->putLock(DocTimer::id_autoLockTimer);
279 return false; 280 return false;
280 } 281 }
281 doc->timer()->putLock(DocTimer::id_autoLockTimer); 282 doc->timer()->putLock(DocTimer::id_autoLockTimer);
282 return true; 283 return true;
283} 284}
284 285
285bool PwMDocUi::saveAsDocUi(PwMDoc *doc) 286bool PwMDocUi::saveAsDocUi(PwMDoc *doc)
286{ 287{
287 PWM_ASSERT(doc); 288 PWM_ASSERT(doc);
288 doc->timer()->getLock(DocTimer::id_autoLockTimer); 289 doc->timer()->getLock(DocTimer::id_autoLockTimer);
289 if (doc->isDocEmpty()) { 290 if (doc->isDocEmpty()) {
290 KMessageBox::information(currentView, 291 KMessageBox::information(currentView,
291 i18n 292 i18n
292 ("Sorry, there's nothing to save.\n" 293 ("Sorry, there's nothing to save.\n"
293 "Please first add some passwords."), 294 "Please first add some passwords."),
294 i18n("nothing to do")); 295 i18n("nothing to do"));
295 doc->timer()->putLock(DocTimer::id_autoLockTimer); 296 doc->timer()->putLock(DocTimer::id_autoLockTimer);
296 return true; 297 return true;
297 } 298 }
299#ifndef PWM_EMBEDDED
298 QString fn(KFileDialog::getSaveFileName(QString::null, 300 QString fn(KFileDialog::getSaveFileName(QString::null,
299 i18n("*.pwm|PwManager Password file"), 301 i18n("*.pwm|PwManager Password file"),
300 currentView)); 302 currentView));
303#else
304 QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" );
305 fn = KFileDialog::getSaveFileName(fn,
306 i18n("password filename(*.pwm)"),
307 currentView);
308
309#endif
301 if (fn == "") { 310 if (fn == "") {
302 doc->timer()->putLock(DocTimer::id_autoLockTimer); 311 doc->timer()->putLock(DocTimer::id_autoLockTimer);
303 return false; 312 return false;
304 } 313 }
305 if (fn.right(4) != ".pwm") 314 if (fn.right(4) != ".pwm")
306 fn += ".pwm"; 315 fn += ".pwm";
307 316
308 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn); 317 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn);
309 if (ret != e_success) { 318 if (ret != e_success) {
310 KMessageBox::error(currentView, 319 KMessageBox::error(currentView,
311 i18n("Error: Couldn't write to file.\n" 320 i18n("Error: Couldn't write to file.\n"
312 "Please check if you have permission to " 321 "Please check if you have permission to "
313 "write to the file in that directory."), 322 "write to the file in that directory."),
314 i18n("error while writing")); 323 i18n("error while writing"));
315 doc->timer()->putLock(DocTimer::id_autoLockTimer); 324 doc->timer()->putLock(DocTimer::id_autoLockTimer);
316 return false; 325 return false;
317 } 326 }
318 doc->timer()->putLock(DocTimer::id_autoLockTimer); 327 doc->timer()->putLock(DocTimer::id_autoLockTimer);
319 return true; 328 return true;
320} 329}
321 330
322bool PwMDocUi::openDocUi(PwMDoc *doc, 331bool PwMDocUi::openDocUi(PwMDoc *doc,
323 QString filename, 332 QString filename,
324 bool openDeepLocked) 333 bool openDeepLocked)
325{ 334{
326 if (filename.isEmpty()) 335 if (filename.isEmpty())
336 {
337#ifndef PWM_EMBEDDED
327 filename = KFileDialog::getOpenFileName(QString::null, 338 filename = KFileDialog::getOpenFileName(QString::null,
328 i18n("*.pwm|PwManager Password file\n" 339 i18n("*.pwm|PwManager Password file\n"
329 "*|All files"), getCurrentView()); 340 "*|All files"), getCurrentView());
341#else
342 filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm");
343 filename = KFileDialog::getOpenFileName(filename,
344 i18n("password filename(*.pwm)"), getCurrentView());
345#endif
346 }
330 if (filename.isEmpty()) 347 if (filename.isEmpty())
331 goto cancelOpen; 348 goto cancelOpen;
332 PwMerror ret; 349 PwMerror ret;
333 while (true) { 350 while (true) {
334 int lockStat = -1; 351 int lockStat = -1;
335 if (openDeepLocked) { 352 if (openDeepLocked) {
336 lockStat = 2; 353 lockStat = 2;
337 } else { 354 } else {
338 if (conf()->confGlobUnlockOnOpen()) { 355 if (conf()->confGlobUnlockOnOpen()) {
339 lockStat = 0; 356 lockStat = 0;
340 } else { 357 } else {
341 lockStat = 1; 358 lockStat = 1;
342 } 359 }
343 } 360 }
344 ret = doc->openDoc(&filename, lockStat); 361 ret = doc->openDoc(&filename, lockStat);
345 if (ret != e_success) { 362 if (ret != e_success) {
346 if (ret == e_readFile || ret == e_openFile) { 363 if (ret == e_readFile || ret == e_openFile) {
347 KMessageBox::error(getCurrentView(), 364 KMessageBox::error(getCurrentView(),
348 i18n("Could not read file!") 365 i18n("Could not read file!")
349 + "\n" 366 + "\n"
350 + filename, 367 + filename,
351 i18n("file error")); 368 i18n("file error"));
352 goto cancelOpen; 369 goto cancelOpen;
353 } 370 }
354 if (ret == e_alreadyOpen) { 371 if (ret == e_alreadyOpen) {
355 KMessageBox::error(getCurrentView(), 372 KMessageBox::error(getCurrentView(),
356 i18n("This file is already open."), 373 i18n("This file is already open."),
357 i18n("already open")); 374 i18n("already open"));
358 goto cancelOpen; 375 goto cancelOpen;
359 } 376 }
360 if (ret == e_fileVer) { 377 if (ret == e_fileVer) {
361 KMessageBox::error(getCurrentView(), 378 KMessageBox::error(getCurrentView(),
362 i18n 379 i18n
363 ("File-version is not supported!\n" 380 ("File-version is not supported!\n"
364 "Did you create this file with an older or newer version of PwM?"), 381 "Did you create this file with an older or newer version of PwM?"),
365 i18n 382 i18n
366 ("incompatible version")); 383 ("incompatible version"));
367 goto cancelOpen; 384 goto cancelOpen;
368 } 385 }
369 if (ret == e_wrongPw) { 386 if (ret == e_wrongPw) {
370 continue; 387 continue;
371 } 388 }
372 if (ret == e_noPw) { 389 if (ret == e_noPw) {
373 goto cancelOpen; 390 goto cancelOpen;
374 } 391 }
375 if (ret == e_fileFormat) { 392 if (ret == e_fileFormat) {
376 KMessageBox::error(getCurrentView(), 393 KMessageBox::error(getCurrentView(),
377 i18n 394 i18n
378 ("Sorry, this file has not been recognized " 395 ("Sorry, this file has not been recognized "
379 "as a PwM Password file.\n" 396 "as a PwM Password file.\n"
380 "Probably you have selected the wrong file."), 397 "Probably you have selected the wrong file."),
381 i18n 398 i18n
382 ("no PwM password-file")); 399 ("no PwM password-file"));
383 goto cancelOpen; 400 goto cancelOpen;
384 } 401 }
385 if (ret == e_fileCorrupt) { 402 if (ret == e_fileCorrupt) {
386 KMessageBox::error(getCurrentView(), 403 KMessageBox::error(getCurrentView(),
387 i18n 404 i18n
388 ("File corrupt!\n" 405 ("File corrupt!\n"
389 "Maybe the media, you stored this file on, " 406 "Maybe the media, you stored this file on, "
390 "had bad sectors?"), 407 "had bad sectors?"),
391 i18n 408 i18n
392 ("checksum error")); 409 ("checksum error"));
393 goto cancelOpen; 410 goto cancelOpen;
394 } 411 }
395 } 412 }
396 break; 413 break;
397 } 414 }
398 return true; 415 return true;
399 416
400 cancelOpen: 417 cancelOpen:
401 return false; 418 return false;
402} 419}
403 420
404QString PwMDocUi::string_defaultCategory() 421QString PwMDocUi::string_defaultCategory()
405{ 422{
406 return i18n("Default"); 423 return i18n("Default");
407} 424}
408 425
409QString PwMDocUi::string_locked() 426QString PwMDocUi::string_locked()
410{ 427{
411 return i18n("<LOCKED>"); 428 return i18n("<LOCKED>");
412} 429}
413 430
414QString PwMDocUi::string_deepLockedShort() 431QString PwMDocUi::string_deepLockedShort()
415{ 432{
416 return i18n("DEEP-LOCKED"); 433 return i18n("DEEP-LOCKED");
417} 434}
418 435
419QString PwMDocUi::string_deepLockedLong() 436QString PwMDocUi::string_deepLockedLong()
420{ 437{
421 return i18n("This file is DEEP-LOCKED!\n" 438 return i18n("This file is DEEP-LOCKED!\n"
422 "That means all data has been encrypted " 439 "That means all data has been encrypted "
423 "and written out to the file. If you want " 440 "and written out to the file. If you want "
424 "to see the entries, please UNLOCK the file. " 441 "to see the entries, please UNLOCK the file. "
425 "While unlocking, you will be prompted for the " 442 "While unlocking, you will be prompted for the "
426 "master-password or the key-card."); 443 "master-password or the key-card.");
427} 444}
428 445
429QString PwMDocUi::string_defaultTitle() 446QString PwMDocUi::string_defaultTitle()
430{ 447{
431 return i18n("Untitled"); 448 return i18n("Untitled");
432} 449}
433 450
434#ifndef PWM_EMBEDDED 451#ifndef PWM_EMBEDDED
435#include "pwmdocui.moc" 452#include "pwmdocui.moc"
436#endif 453#endif