-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 167 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.h | 6 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdocui.cpp | 17 |
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 | |||
@@ -9,48 +9,49 @@ | |||
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" |
@@ -99,48 +100,58 @@ enum { | |||
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 |
104 | enum { | 105 | enum { |
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) |
108 | enum { | 109 | enum { |
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) |
116 | enum { | 117 | enum { |
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 | ||
127 | enum { | ||
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 |
124 | enum { | 135 | enum { |
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 | ||
140 | PwM::PwM(PwMInit *_init, PwMDoc *doc, | 151 | PwM::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 | { |
@@ -151,232 +162,260 @@ PwM::PwM(PwMInit *_init, PwMDoc *doc, | |||
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 | ||
164 | PwM::~PwM() | 175 | PwM::~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 | ||
173 | void PwM::initMenubar() | 184 | void 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 | ||
312 | void PwM::initToolbar() | 345 | void 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 | ||
364 | void PwM::initMetrics() | 403 | void 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 | ||
373 | void PwM::updateCaption() | 412 | void PwM::updateCaption() |
374 | { | 413 | { |
375 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); | 414 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); |
376 | } | 415 | } |
377 | 416 | ||
378 | void PwM::hideEvent(QHideEvent *) | 417 | void 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; |
@@ -515,49 +554,50 @@ void PwM::addPwd_slot() | |||
515 | } | 554 | } |
516 | 555 | ||
517 | void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) | 556 | void 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 | } |
@@ -1166,27 +1206,78 @@ void PwM::copyToClipboard(const QString &s) | |||
1166 | 1206 | ||
1167 | #endif | 1207 | #endif |
1168 | 1208 | ||
1169 | } | 1209 | } |
1170 | 1210 | ||
1171 | void PwM::showStatMsg(const QString &msg) | 1211 | void 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 | ||
1181 | void PwM::focusInEvent(QFocusEvent *e) | 1221 | void 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 | |||
1233 | void PwM::showLicense_slot() | ||
1234 | { | ||
1235 | KApplication::showLicence(); | ||
1236 | } | ||
1237 | |||
1238 | void PwM::faq_slot() | ||
1239 | { | ||
1240 | KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); | ||
1241 | } | ||
1242 | |||
1243 | void 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 | |||
@@ -145,48 +145,54 @@ public slots: | |||
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 | |||
169 | protected: | 175 | protected: |
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(); |
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 | |||
@@ -14,48 +14,49 @@ | |||
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 | ||
46 | PwMDocUi::PwMDocUi(QObject *parent, const char *name) | 47 | PwMDocUi::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 | ||
53 | PwMDocUi::~PwMDocUi() | 54 | PwMDocUi::~PwMDocUi() |
54 | { | 55 | { |
55 | } | 56 | } |
56 | 57 | ||
57 | QString PwMDocUi::requestMpw(bool chipcard) | 58 | QString PwMDocUi::requestMpw(bool chipcard) |
58 | { | 59 | { |
59 | QString pw; | 60 | QString pw; |
60 | 61 | ||
61 | if (chipcard) { | 62 | if (chipcard) { |
@@ -274,80 +275,96 @@ bool PwMDocUi::saveDocUi(PwMDoc *doc) | |||
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 | ||
285 | bool PwMDocUi::saveAsDocUi(PwMDoc *doc) | 286 | bool 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 | ||
322 | bool PwMDocUi::openDocUi(PwMDoc *doc, | 331 | bool 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 | } |