summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-23 09:04:58 (UTC)
committer zautrix <zautrix>2004-10-23 09:04:58 (UTC)
commitba2583db0431059cd7368be23c9653e81af16d29 (patch) (unidiff)
tree75d4a662731651d391a5e5bb60e89d1245781593
parenteb0bc46bfbba45a84c7353f1c9c4dba27273f021 (diff)
downloadkdepimpi-ba2583db0431059cd7368be23c9653e81af16d29.zip
kdepimpi-ba2583db0431059cd7368be23c9653e81af16d29.tar.gz
kdepimpi-ba2583db0431059cd7368be23c9653e81af16d29.tar.bz2
fixed desktop descape bug. added statusbar to embedded and desktop
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwm.cpp10
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp10
-rw-r--r--pwmanager/pwmanager/serializer.cpp8
3 files changed, 18 insertions, 10 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 9798e8e..b7b5307 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1,1463 +1,1463 @@
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#include <qstatusbar.h>
28
27#ifndef PWM_EMBEDDED 29#ifndef PWM_EMBEDDED
28#include <kmenubar.h> 30#include <kmenubar.h>
29#include <kstatusbar.h> 31#include <kstatusbar.h>
30#include <dcopclient.h> 32#include <dcopclient.h>
31#include "configwndimpl.h" 33#include "configwndimpl.h"
32#include "configuration.h" 34#include "configuration.h"
33#else 35#else
34#include <qmenubar.h> 36#include <qmenubar.h>
35#include <qmessagebox.h> 37#include <qmessagebox.h>
36#include <pwmprefs.h> 38#include <pwmprefs.h>
37#include <kpimglobalprefs.h> 39#include <kpimglobalprefs.h>
38#include <kcmconfigs/kcmpwmconfig.h> 40#include <kcmconfigs/kcmpwmconfig.h>
39#include <kcmconfigs/kcmkdepimconfig.h> 41#include <kcmconfigs/kcmkdepimconfig.h>
40#include <kcmultidialog.h> 42#include <kcmultidialog.h>
41#endif 43#endif
42 44
43 45
44#ifndef DESKTOP_VERSION 46#ifndef DESKTOP_VERSION
45#include <qpe/global.h> 47#include <qpe/global.h>
46#endif 48#endif
47 49
48#include <qpixmap.h> 50#include <qpixmap.h>
49#include <qcheckbox.h> 51#include <qcheckbox.h>
50#include <qspinbox.h> 52#include <qspinbox.h>
51#include <qlineedit.h> 53#include <qlineedit.h>
52#include <qfileinfo.h> 54#include <qfileinfo.h>
53#include <qclipboard.h> 55#include <qclipboard.h>
54 56
55 57
56#include <stdio.h> 58#include <stdio.h>
57 59
58#include "pwm.h" 60#include "pwm.h"
59#include "pwminit.h" 61#include "pwminit.h"
60#include "pwmprint.h" 62#include "pwmprint.h"
61#include "addentrywndimpl.h" 63#include "addentrywndimpl.h"
62#include "globalstuff.h" 64#include "globalstuff.h"
63#include "findwndimpl.h" 65#include "findwndimpl.h"
64#include "csv.h" 66#include "csv.h"
65 67
66#ifdef CONFIG_KWALLETIF 68#ifdef CONFIG_KWALLETIF
67# include "kwalletif.h" 69# include "kwalletif.h"
68# include "kwalletemu.h" 70# include "kwalletemu.h"
69#endif 71#endif
70#ifdef CONFIG_KEYCARD 72#ifdef CONFIG_KEYCARD
71# include "pwmkeycard.h" 73# include "pwmkeycard.h"
72#endif 74#endif
73 75
74 76
75 #define DEFAULT_SIZE (QSize(700, 400)) 77 #define DEFAULT_SIZE (QSize(700, 400))
76 78
77// Button IDs for "file" popup menu 79// Button IDs for "file" popup menu
78enum { 80enum {
79 BUTTON_POPUP_FILE_NEW = 0, 81 BUTTON_POPUP_FILE_NEW = 0,
80 BUTTON_POPUP_FILE_OPEN, 82 BUTTON_POPUP_FILE_OPEN,
81 BUTTON_POPUP_FILE_CLOSE, 83 BUTTON_POPUP_FILE_CLOSE,
82 BUTTON_POPUP_FILE_SAVE, 84 BUTTON_POPUP_FILE_SAVE,
83 BUTTON_POPUP_FILE_SAVEAS, 85 BUTTON_POPUP_FILE_SAVEAS,
84 BUTTON_POPUP_FILE_EXPORT, 86 BUTTON_POPUP_FILE_EXPORT,
85 BUTTON_POPUP_FILE_IMPORT, 87 BUTTON_POPUP_FILE_IMPORT,
86 BUTTON_POPUP_FILE_PRINT, 88 BUTTON_POPUP_FILE_PRINT,
87 BUTTON_POPUP_FILE_QUIT 89 BUTTON_POPUP_FILE_QUIT
88}; 90};
89// Button IDs for "manage" popup menu 91// Button IDs for "manage" popup menu
90enum { 92enum {
91 BUTTON_POPUP_MANAGE_ADD = 0, 93 BUTTON_POPUP_MANAGE_ADD = 0,
92 BUTTON_POPUP_MANAGE_EDIT, 94 BUTTON_POPUP_MANAGE_EDIT,
93 BUTTON_POPUP_MANAGE_DEL, 95 BUTTON_POPUP_MANAGE_DEL,
94 BUTTON_POPUP_MANAGE_CHANGEMP 96 BUTTON_POPUP_MANAGE_CHANGEMP
95}; 97};
96// Button IDs for chipcard popup menu 98// Button IDs for chipcard popup menu
97enum { 99enum {
98#ifdef CONFIG_KEYCARD 100#ifdef CONFIG_KEYCARD
99 BUTTON_POPUP_CHIPCARD_GENNEW = 0, 101 BUTTON_POPUP_CHIPCARD_GENNEW = 0,
100 BUTTON_POPUP_CHIPCARD_DEL, 102 BUTTON_POPUP_CHIPCARD_DEL,
101 BUTTON_POPUP_CHIPCARD_READID, 103 BUTTON_POPUP_CHIPCARD_READID,
102 BUTTON_POPUP_CHIPCARD_SAVEBACKUP, 104 BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
103 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP 105 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
104#else // CONFIG_KEYCARD 106#else // CONFIG_KEYCARD
105 BUTTON_POPUP_CHIPCARD_NO = 0 107 BUTTON_POPUP_CHIPCARD_NO = 0
106#endif // CONFIG_KEYCARD 108#endif // CONFIG_KEYCARD
107}; 109};
108// Button IDs for "view" popup menu 110// Button IDs for "view" popup menu
109enum { 111enum {
110 BUTTON_POPUP_VIEW_FIND = 0, 112 BUTTON_POPUP_VIEW_FIND = 0,
111 BUTTON_POPUP_VIEW_LOCK, 113 BUTTON_POPUP_VIEW_LOCK,
112 BUTTON_POPUP_VIEW_DEEPLOCK, 114 BUTTON_POPUP_VIEW_DEEPLOCK,
113 BUTTON_POPUP_VIEW_UNLOCK 115 BUTTON_POPUP_VIEW_UNLOCK
114}; 116};
115// Button IDs for "options" popup menu 117// Button IDs for "options" popup menu
116enum { 118enum {
117 BUTTON_POPUP_OPTIONS_CONFIG = 0 119 BUTTON_POPUP_OPTIONS_CONFIG = 0
118}; 120};
119// Button IDs for "export" popup menu (in "file" popup menu) 121// Button IDs for "export" popup menu (in "file" popup menu)
120enum { 122enum {
121 BUTTON_POPUP_EXPORT_TEXT = 0, 123 BUTTON_POPUP_EXPORT_TEXT = 0,
122 BUTTON_POPUP_EXPORT_GPASMAN, 124 BUTTON_POPUP_EXPORT_GPASMAN,
123 BUTTON_POPUP_EXPORT_CSV 125 BUTTON_POPUP_EXPORT_CSV
124#ifdef CONFIG_KWALLETIF 126#ifdef CONFIG_KWALLETIF
125 ,BUTTON_POPUP_EXPORT_KWALLET 127 ,BUTTON_POPUP_EXPORT_KWALLET
126#endif 128#endif
127}; 129};
128// Button IDs for "import" popup menu (in "file" popup menu) 130// Button IDs for "import" popup menu (in "file" popup menu)
129enum { 131enum {
130 BUTTON_POPUP_IMPORT_TEXT = 0, 132 BUTTON_POPUP_IMPORT_TEXT = 0,
131 BUTTON_POPUP_IMPORT_GPASMAN, 133 BUTTON_POPUP_IMPORT_GPASMAN,
132 BUTTON_POPUP_IMPORT_CSV 134 BUTTON_POPUP_IMPORT_CSV
133#ifdef CONFIG_KWALLETIF 135#ifdef CONFIG_KWALLETIF
134 ,BUTTON_POPUP_IMPORT_KWALLET 136 ,BUTTON_POPUP_IMPORT_KWALLET
135#endif 137#endif
136}; 138};
137 139
138#ifdef PWM_EMBEDDED 140#ifdef PWM_EMBEDDED
139// Button IDs for "help" popup menu 141// Button IDs for "help" popup menu
140enum { 142enum {
141 BUTTON_POPUP_HELP_LICENSE = 0, 143 BUTTON_POPUP_HELP_LICENSE = 0,
142 BUTTON_POPUP_HELP_FAQ, 144 BUTTON_POPUP_HELP_FAQ,
143 BUTTON_POPUP_HELP_ABOUT, 145 BUTTON_POPUP_HELP_ABOUT,
144 BUTTON_POPUP_HELP_SYNC, 146 BUTTON_POPUP_HELP_SYNC,
145 BUTTON_POPUP_HELP_WHATSNEW 147 BUTTON_POPUP_HELP_WHATSNEW
146}; 148};
147#endif 149#endif
148 150
149// Button IDs for toolbar 151// Button IDs for toolbar
150enum { 152enum {
151 BUTTON_TOOL_NEW = 0, 153 BUTTON_TOOL_NEW = 0,
152 BUTTON_TOOL_OPEN, 154 BUTTON_TOOL_OPEN,
153 BUTTON_TOOL_SAVE, 155 BUTTON_TOOL_SAVE,
154 BUTTON_TOOL_SAVEAS, 156 BUTTON_TOOL_SAVEAS,
155 BUTTON_TOOL_PRINT, 157 BUTTON_TOOL_PRINT,
156 BUTTON_TOOL_ADD, 158 BUTTON_TOOL_ADD,
157 BUTTON_TOOL_EDIT, 159 BUTTON_TOOL_EDIT,
158 BUTTON_TOOL_DEL, 160 BUTTON_TOOL_DEL,
159 BUTTON_TOOL_FIND, 161 BUTTON_TOOL_FIND,
160 BUTTON_TOOL_LOCK, 162 BUTTON_TOOL_LOCK,
161 BUTTON_TOOL_DEEPLOCK, 163 BUTTON_TOOL_DEEPLOCK,
162 BUTTON_TOOL_UNLOCK 164 BUTTON_TOOL_UNLOCK
163}; 165};
164 166
165 167
166PwM::PwM(PwMInit *_init, PwMDoc *doc, 168PwM::PwM(PwMInit *_init, PwMDoc *doc,
167 bool virginity, 169 bool virginity,
168 QWidget *parent, const char *name) 170 QWidget *parent, const char *name)
169 : KMainWindow(parent, "HALLO") 171 : KMainWindow(parent, "HALLO")
170 , forceQuit (false) 172 , forceQuit (false)
171 , forceMinimizeToTray (false) 173 , forceMinimizeToTray (false)
172{ 174{
173 virgin = !virginity; 175 virgin = !virginity;
174 init = _init; 176 init = _init;
175 connect(doc, SIGNAL(docClosed(PwMDoc *)), 177 connect(doc, SIGNAL(docClosed(PwMDoc *)),
176 this, SLOT(docClosed(PwMDoc *))); 178 this, SLOT(docClosed(PwMDoc *)));
177 initMenubar(); 179 initMenubar();
178 initToolbar(); 180 initToolbar();
179 initMetrics(); 181 initMetrics();
180 setVirgin(virginity); 182 setVirgin(virginity);
181 setFocusPolicy(QWidget::WheelFocus); 183 setFocusPolicy(QWidget::WheelFocus);
182#ifndef PWM_EMBEDDED 184#ifndef PWM_EMBEDDED
183 statusBar()->show(); 185 statusBar()->show();
184#endif 186#endif
185 view = makeNewListView(doc); 187 view = makeNewListView(doc);
186 setCentralWidget(view); 188 setCentralWidget(view);
187 updateCaption(); 189 updateCaption();
188 showStatMsg(i18n("Ready.")); 190 showStatMsg(i18n("Ready."));
189} 191}
190 192
191PwM::~PwM() 193PwM::~PwM()
192{ 194{
193 //qDebug("PwM::~PwM()"); 195 //qDebug("PwM::~PwM()");
194 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), 196 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
195 this, SLOT(docClosed(PwMDoc *))); 197 this, SLOT(docClosed(PwMDoc *)));
196 conf()->confWndMainWndSize(size()); 198 conf()->confWndMainWndSize(size());
197 emit closed(this); 199 emit closed(this);
198 //qDebug("PwM::~PwM() emited closed(this)"); 200 //qDebug("PwM::~PwM() emited closed(this)");
199 delete view; 201 delete view;
200} 202}
201 203
202void PwM::initMenubar() 204void PwM::initMenubar()
203{ 205{
204 KIconLoader* picons; 206 KIconLoader* picons;
205#ifndef PWM_EMBEDDED 207#ifndef PWM_EMBEDDED
206 KIconLoader icons; 208 KIconLoader icons;
207 picons = &icons; 209 picons = &icons;
208#else 210#else
209 picons = KGlobal::iconLoader(); 211 picons = KGlobal::iconLoader();
210 212
211 213
212 syncPopup = new KPopupMenu(this); 214 syncPopup = new KPopupMenu(this);
213 215
214 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); 216 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup);
215 syncManager->setBlockSave(false); 217 syncManager->setBlockSave(false);
216 218
217 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 219 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
218 syncManager->fillSyncMenu(); 220 syncManager->fillSyncMenu();
219 221
220#endif 222#endif
221 filePopup = new KPopupMenu(this); 223 filePopup = new KPopupMenu(this);
222 importPopup = new KPopupMenu(filePopup); 224 importPopup = new KPopupMenu(filePopup);
223 exportPopup = new KPopupMenu(filePopup); 225 exportPopup = new KPopupMenu(filePopup);
224 managePopup = new KPopupMenu(this); 226 managePopup = new KPopupMenu(this);
225#ifdef CONFIG_KEYCARD 227#ifdef CONFIG_KEYCARD
226 chipcardPopup = new KPopupMenu(this); 228 chipcardPopup = new KPopupMenu(this);
227#endif // CONFIG_KEYCARD 229#endif // CONFIG_KEYCARD
228 viewPopup = new KPopupMenu(this); 230 viewPopup = new KPopupMenu(this);
229 optionsPopup = new KPopupMenu(this); 231 optionsPopup = new KPopupMenu(this);
230 232
231// "file" popup menu 233// "file" popup menu
232 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 234 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
233 i18n("&New"), this, 235 i18n("&New"), this,
234 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); 236 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW);
235 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), 237 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)),
236 i18n("&Open"), this, 238 i18n("&Open"), this,
237 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); 239 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN);
238 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), 240 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)),
239 i18n("&Close"), this, 241 i18n("&Close"), this,
240 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); 242 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE);
241 filePopup->insertSeparator(); 243 filePopup->insertSeparator();
242 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), 244 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)),
243 i18n("&Save"), this, 245 i18n("&Save"), this,
244 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); 246 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
245 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), 247 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)),
246 i18n("Save &as..."), 248 i18n("Save &as..."),
247 this, SLOT(saveAs_slot()), 0, 249 this, SLOT(saveAs_slot()), 0,
248 BUTTON_POPUP_FILE_SAVEAS); 250 BUTTON_POPUP_FILE_SAVEAS);
249 filePopup->insertSeparator(); 251 filePopup->insertSeparator();
250 // "file/export" popup menu 252 // "file/export" popup menu
251 exportPopup->insertItem(i18n("&Text-file..."), this, 253 exportPopup->insertItem(i18n("&Text-file..."), this,
252 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); 254 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
253 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 255 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
254 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); 256 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
255 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 257 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
256 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); 258 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV);
257#ifdef CONFIG_KWALLETIF 259#ifdef CONFIG_KWALLETIF
258 exportPopup->insertItem(i18n("&KWallet..."), this, 260 exportPopup->insertItem(i18n("&KWallet..."), this,
259 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); 261 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
260#endif 262#endif
261 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), 263 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
262 i18n("E&xport"), exportPopup, 264 i18n("E&xport"), exportPopup,
263 BUTTON_POPUP_FILE_EXPORT); 265 BUTTON_POPUP_FILE_EXPORT);
264 // "file/import" popup menu 266 // "file/import" popup menu
265 importPopup->insertItem(i18n("&Text-file..."), this, 267 importPopup->insertItem(i18n("&Text-file..."), this,
266 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 268 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
267 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 269 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
268 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 270 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
269 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 271 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
270 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); 272 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV);
271#ifdef CONFIG_KWALLETIF 273#ifdef CONFIG_KWALLETIF
272 importPopup->insertItem(i18n("&KWallet..."), this, 274 importPopup->insertItem(i18n("&KWallet..."), this,
273 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 275 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
274#endif 276#endif
275 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), 277 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
276 i18n("I&mport"), importPopup, 278 i18n("I&mport"), importPopup,
277 BUTTON_POPUP_FILE_IMPORT); 279 BUTTON_POPUP_FILE_IMPORT);
278 filePopup->insertSeparator(); 280 filePopup->insertSeparator();
279 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), 281 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)),
280 i18n("&Print..."), this, 282 i18n("&Print..."), this,
281 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 283 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
282 filePopup->insertSeparator(); 284 filePopup->insertSeparator();
283 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), 285 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)),
284 i18n("&Quit"), this, 286 i18n("&Quit"), this,
285 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 287 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
286 menuBar()->insertItem(i18n("&File"), filePopup); 288 menuBar()->insertItem(i18n("&File"), filePopup);
287// "manage" popup menu 289// "manage" popup menu
288 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), 290 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
289 i18n("&Add password"), this, 291 i18n("&Add password"), this,
290 SLOT(addPwd_slot()), 0, 292 SLOT(addPwd_slot()), 0,
291 BUTTON_POPUP_MANAGE_ADD); 293 BUTTON_POPUP_MANAGE_ADD);
292 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), 294 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
293 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 295 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
294 BUTTON_POPUP_MANAGE_EDIT); 296 BUTTON_POPUP_MANAGE_EDIT);
295 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 297 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
296 i18n("&Delete"), this, SLOT(deletePwd_slot()), 298 i18n("&Delete"), this, SLOT(deletePwd_slot()),
297 0, BUTTON_POPUP_MANAGE_DEL); 299 0, BUTTON_POPUP_MANAGE_DEL);
298 managePopup->insertSeparator(); 300 managePopup->insertSeparator();
299 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), 301 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
300 i18n("Change &Master Password"), this, 302 i18n("Change &Master Password"), this,
301 SLOT(changeMasterPwd_slot()), 0, 303 SLOT(changeMasterPwd_slot()), 0,
302 BUTTON_POPUP_MANAGE_CHANGEMP); 304 BUTTON_POPUP_MANAGE_CHANGEMP);
303 menuBar()->insertItem(i18n("&Manage"), managePopup); 305 menuBar()->insertItem(i18n("&Manage"), managePopup);
304// "chipcard" popup menu 306// "chipcard" popup menu
305#ifdef CONFIG_KEYCARD 307#ifdef CONFIG_KEYCARD
306 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 308 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
307 i18n("&Generate new key-card"), this, 309 i18n("&Generate new key-card"), this,
308 SLOT(genNewCard_slot()), 0, 310 SLOT(genNewCard_slot()), 0,
309 BUTTON_POPUP_CHIPCARD_GENNEW); 311 BUTTON_POPUP_CHIPCARD_GENNEW);
310 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 312 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
311 i18n("&Erase key-card"), this, 313 i18n("&Erase key-card"), this,
312 SLOT(eraseCard_slot()), 0, 314 SLOT(eraseCard_slot()), 0,
313 BUTTON_POPUP_CHIPCARD_DEL); 315 BUTTON_POPUP_CHIPCARD_DEL);
314 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), 316 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
315 i18n("Read card-&ID"), this, 317 i18n("Read card-&ID"), this,
316 SLOT(readCardId_slot()), 0, 318 SLOT(readCardId_slot()), 0,
317 BUTTON_POPUP_CHIPCARD_READID); 319 BUTTON_POPUP_CHIPCARD_READID);
318 chipcardPopup->insertSeparator(); 320 chipcardPopup->insertSeparator();
319 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), 321 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
320 i18n("&Make card backup-image"), this, 322 i18n("&Make card backup-image"), this,
321 SLOT(makeCardBackup_slot()), 0, 323 SLOT(makeCardBackup_slot()), 0,
322 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 324 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
323 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), 325 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
324 i18n("&Replay card backup-image"), this, 326 i18n("&Replay card backup-image"), this,
325 SLOT(replayCardBackup_slot()), 0, 327 SLOT(replayCardBackup_slot()), 0,
326 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 328 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
327 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 329 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
328#endif // CONFIG_KEYCARD 330#endif // CONFIG_KEYCARD
329// "view" popup menu 331// "view" popup menu
330 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), 332 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
331 i18n("&Find"), this, 333 i18n("&Find"), this,
332 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 334 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
333 viewPopup->insertSeparator(); 335 viewPopup->insertSeparator();
334 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), 336 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
335 i18n("&Lock all entries"), this, 337 i18n("&Lock all entries"), this,
336 SLOT(lockWnd_slot()), 0, 338 SLOT(lockWnd_slot()), 0,
337 BUTTON_POPUP_VIEW_LOCK); 339 BUTTON_POPUP_VIEW_LOCK);
338 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), 340 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
339 i18n("&Deep-lock all entries"), this, 341 i18n("&Deep-lock all entries"), this,
340 SLOT(deepLockWnd_slot()), 0, 342 SLOT(deepLockWnd_slot()), 0,
341 BUTTON_POPUP_VIEW_DEEPLOCK); 343 BUTTON_POPUP_VIEW_DEEPLOCK);
342 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), 344 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
343 i18n("&Unlock all entries"), this, 345 i18n("&Unlock all entries"), this,
344 SLOT(unlockWnd_slot()), 0, 346 SLOT(unlockWnd_slot()), 0,
345 BUTTON_POPUP_VIEW_UNLOCK); 347 BUTTON_POPUP_VIEW_UNLOCK);
346 menuBar()->insertItem(i18n("&View"), viewPopup); 348 menuBar()->insertItem(i18n("&View"), viewPopup);
347// "options" popup menu 349// "options" popup menu
348 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 350 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
349 i18n("&Configure..."), this, 351 i18n("&Configure..."), this,
350 SLOT(config_slot()), 352 SLOT(config_slot()),
351 BUTTON_POPUP_OPTIONS_CONFIG); 353 BUTTON_POPUP_OPTIONS_CONFIG);
352 menuBar()->insertItem(i18n("&Options"), optionsPopup); 354 menuBar()->insertItem(i18n("&Options"), optionsPopup);
353// "help" popup menu 355// "help" popup menu
354#ifndef PWM_EMBEDDED 356#ifndef PWM_EMBEDDED
355 helpPopup = helpMenu(QString::null, false); 357 helpPopup = helpMenu(QString::null, false);
356#else 358#else
357 menuBar()->insertItem(i18n("&Sync"), syncPopup); 359 menuBar()->insertItem(i18n("&Sync"), syncPopup);
358 360
359 361
360 362
361 363
362 364
363 helpPopup = new KPopupMenu(this); 365 helpPopup = new KPopupMenu(this);
364 366
365 367
366 helpPopup->insertItem(i18n("&License"), this, 368 helpPopup->insertItem(i18n("&License"), this,
367 SLOT(showLicense_slot()), 0, 369 SLOT(showLicense_slot()), 0,
368 BUTTON_POPUP_HELP_LICENSE); 370 BUTTON_POPUP_HELP_LICENSE);
369 371
370 helpPopup->insertItem(i18n("&Faq"), this, 372 helpPopup->insertItem(i18n("&Faq"), this,
371 SLOT(faq_slot()), 0, 373 SLOT(faq_slot()), 0,
372 BUTTON_POPUP_HELP_FAQ); 374 BUTTON_POPUP_HELP_FAQ);
373 375
374 helpPopup->insertItem(i18n("&About PwManager"), this, 376 helpPopup->insertItem(i18n("&About PwManager"), this,
375 SLOT(createAboutData_slot()), 0, 377 SLOT(createAboutData_slot()), 0,
376 BUTTON_POPUP_HELP_ABOUT); 378 BUTTON_POPUP_HELP_ABOUT);
377 379
378 helpPopup->insertItem(i18n("&Sync HowTo"), this, 380 helpPopup->insertItem(i18n("&Sync HowTo"), this,
379 SLOT(syncHowTo_slot()), 0, 381 SLOT(syncHowTo_slot()), 0,
380 BUTTON_POPUP_HELP_SYNC); 382 BUTTON_POPUP_HELP_SYNC);
381 383
382 helpPopup->insertItem(i18n("&What's New"), this, 384 helpPopup->insertItem(i18n("&What's New"), this,
383 SLOT(whatsnew_slot()), 0, 385 SLOT(whatsnew_slot()), 0,
384 BUTTON_POPUP_HELP_WHATSNEW); 386 BUTTON_POPUP_HELP_WHATSNEW);
385 387
386#endif 388#endif
387 menuBar()->insertItem(i18n("&Help"), helpPopup); 389 menuBar()->insertItem(i18n("&Help"), helpPopup);
388 390
389} 391}
390 392
391void PwM::initToolbar() 393void PwM::initToolbar()
392{ 394{
393 KIconLoader* picons; 395 KIconLoader* picons;
394#ifndef PWM_EMBEDDED 396#ifndef PWM_EMBEDDED
395 KIconLoader icons; 397 KIconLoader icons;
396 picons = &icons; 398 picons = &icons;
397#else 399#else
398 picons = KGlobal::iconLoader(); 400 picons = KGlobal::iconLoader();
399#endif 401#endif
400 402
401#ifdef PWM_EMBEDDED 403#ifdef PWM_EMBEDDED
402 if ( QApplication::desktop()->width() > 320 ) 404 if ( QApplication::desktop()->width() > 320 )
403#endif 405#endif
404 { 406 {
405 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), 407 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
406 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 408 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
407 SLOT(new_slot()), true, i18n("New")); 409 SLOT(new_slot()), true, i18n("New"));
408 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), 410 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
409 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 411 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
410 SLOT(open_slot()), true, i18n("Open")); 412 SLOT(open_slot()), true, i18n("Open"));
411 toolBar()->insertSeparator(); 413 toolBar()->insertSeparator();
412 } 414 }
413 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), 415 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
414 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 416 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
415 SLOT(save_slot()), true, i18n("Save")); 417 SLOT(save_slot()), true, i18n("Save"));
416 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), 418 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
417 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 419 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
418 SLOT(saveAs_slot()), true, i18n("Save as")); 420 SLOT(saveAs_slot()), true, i18n("Save as"));
419 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), 421 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
420 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 422 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
421 SLOT(print_slot()), true, i18n("Print...")); 423 SLOT(print_slot()), true, i18n("Print..."));
422 toolBar()->insertSeparator(); 424 toolBar()->insertSeparator();
423 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), 425 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
424 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, 426 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
425 SLOT(addPwd_slot()), true, 427 SLOT(addPwd_slot()), true,
426 i18n("Add password")); 428 i18n("Add password"));
427 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), 429 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
428 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 430 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
429 SLOT(editPwd_slot()), true, 431 SLOT(editPwd_slot()), true,
430 i18n("Edit password")); 432 i18n("Edit password"));
431 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), 433 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
432 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 434 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
433 SLOT(deletePwd_slot()), true, 435 SLOT(deletePwd_slot()), true,
434 i18n("Delete password")); 436 i18n("Delete password"));
435 toolBar()->insertSeparator(); 437 toolBar()->insertSeparator();
436 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), 438 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
437 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, 439 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
438 SLOT(find_slot()), true, i18n("Find entry")); 440 SLOT(find_slot()), true, i18n("Find entry"));
439 toolBar()->insertSeparator(); 441 toolBar()->insertSeparator();
440 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), 442 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
441 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 443 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
442 SLOT(lockWnd_slot()), true, 444 SLOT(lockWnd_slot()), true,
443 i18n("Lock all entries")); 445 i18n("Lock all entries"));
444 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), 446 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
445 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 447 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
446 SLOT(deepLockWnd_slot()), true, 448 SLOT(deepLockWnd_slot()), true,
447 i18n("Deep-Lock all entries")); 449 i18n("Deep-Lock all entries"));
448 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), 450 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
449 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 451 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
450 SLOT(unlockWnd_slot()), true, 452 SLOT(unlockWnd_slot()), true,
451 i18n("Unlock all entries")); 453 i18n("Unlock all entries"));
452} 454}
453 455
454void PwM::initMetrics() 456void PwM::initMetrics()
455{ 457{
456 QSize s = conf()->confWndMainWndSize(); 458 QSize s = conf()->confWndMainWndSize();
457 if (s.isValid()) 459 if (s.isValid())
458 resize(s); 460 resize(s);
459 else 461 else
460 resize(DEFAULT_SIZE); 462 resize(DEFAULT_SIZE);
461} 463}
462 464
463void PwM::updateCaption() 465void PwM::updateCaption()
464{ 466{
465 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); 467 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER);
466} 468}
467 469
468void PwM::hideEvent(QHideEvent *) 470void PwM::hideEvent(QHideEvent *)
469{ 471{
470 if (isMinimized()) { 472 if (isMinimized()) {
471 if (init->tray()) { 473 if (init->tray()) {
472 forceMinimizeToTray = true; 474 forceMinimizeToTray = true;
473 close(); 475 close();
474 } 476 }
475 int mmlock = conf()->confGlobMinimizeLock(); 477 int mmlock = conf()->confGlobMinimizeLock();
476 switch (mmlock) { 478 switch (mmlock) {
477 case 0: // don't lock anything 479 case 0: // don't lock anything
478 break; 480 break;
479 case 1: {// normal lock 481 case 1: {// normal lock
480 curDoc()->lockAll(true); 482 curDoc()->lockAll(true);
481 break; 483 break;
482 } case 2: {// deep-lock 484 } case 2: {// deep-lock
483 curDoc()->deepLock(); 485 curDoc()->deepLock();
484 break; 486 break;
485 } default: 487 } default:
486 WARN(); 488 WARN();
487 } 489 }
488 } 490 }
489} 491}
490 492
491void PwM::setVirgin(bool v) 493void PwM::setVirgin(bool v)
492{ 494{
493 if (virgin == v) 495 if (virgin == v)
494 return; 496 return;
495 virgin = v; 497 virgin = v;
496 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); 498 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
497 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); 499 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
498 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); 500 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
499 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); 501 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
500 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); 502 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
501 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); 503 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
502 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); 504 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
503 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); 505 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
504 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); 506 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
505 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); 507 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
506 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); 508 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
507 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); 509 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
508 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 510 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
509 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 511 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
510 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 512 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
511 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 513 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
512 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 514 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
513 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 515 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
514 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 516 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
515 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 517 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
516} 518}
517 519
518void PwM::new_slot() 520void PwM::new_slot()
519{ 521{
520 init->createMainWnd(); 522 init->createMainWnd();
521} 523}
522 524
523//US ENH 525//US ENH
524void PwM::open_slot() 526void PwM::open_slot()
525{ 527{
526 open_slot(""); 528 open_slot("");
527} 529}
528 530
529void PwM::open_slot(QString fn) 531void PwM::open_slot(QString fn)
530{ 532{
531 openDoc(fn); 533 openDoc(fn);
532} 534}
533 535
534PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 536PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
535{ 537{
536 if (!isVirgin()) { 538 if (!isVirgin()) {
537 // open the document in a new window. 539 // open the document in a new window.
538 PwM *newInstance = init->createMainWnd(); 540 PwM *newInstance = init->createMainWnd();
539 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 541 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
540 if (!newDoc) { 542 if (!newDoc) {
541 newInstance->setForceQuit(true); 543 newInstance->setForceQuit(true);
542 delete_and_null(newInstance); 544 delete_and_null(newInstance);
543 } 545 }
544 return newDoc; 546 return newDoc;
545 } 547 }
546 548
547 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 549 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
548 return 0; 550 return 0;
549 showStatMsg(i18n("Successfully opened file.")); 551 showStatMsg(i18n("Successfully opened file."));
550 updateCaption(); 552 updateCaption();
551 setVirgin(false); 553 setVirgin(false);
552 return curDoc(); 554 return curDoc();
553} 555}
554 556
555PwMView * PwM::makeNewListView(PwMDoc *doc) 557PwMView * PwM::makeNewListView(PwMDoc *doc)
556{ 558{
557 PwMView *ret = new PwMView(this, this, doc); 559 PwMView *ret = new PwMView(this, this, doc);
558 ret->setFont(conf()->confGlobEntryFont()); 560 ret->setFont(conf()->confGlobEntryFont());
559 ret->show(); 561 ret->show();
560 return ret; 562 return ret;
561} 563}
562 564
563void PwM::close_slot() 565void PwM::close_slot()
564{ 566{
565 close(); 567 close();
566} 568}
567 569
568void PwM::quitButton_slot() 570void PwM::quitButton_slot()
569{ 571{
570 init->shutdownApp(0); 572 init->shutdownApp(0);
571} 573}
572 574
573void PwM::save_slot() 575void PwM::save_slot()
574{ 576{
575 save(); 577 save();
576} 578}
577 579
578bool PwM::save() 580bool PwM::save()
579{ 581{
580 if (!curDoc()->saveDocUi(curDoc())) 582 if (!curDoc()->saveDocUi(curDoc()))
581 return false; 583 return false;
582 showStatMsg(i18n("Successfully saved data.")); 584 showStatMsg(i18n("Successfully saved data."));
583 updateCaption(); 585 updateCaption();
584 return true; 586 return true;
585} 587}
586 588
587void PwM::saveAs_slot() 589void PwM::saveAs_slot()
588{ 590{
589 saveAs(); 591 saveAs();
590} 592}
591 593
592bool PwM::saveAs() 594bool PwM::saveAs()
593{ 595{
594 if (!curDoc()->saveAsDocUi(curDoc())) 596 if (!curDoc()->saveAsDocUi(curDoc()))
595 return false; 597 return false;
596 showStatMsg(i18n("Successfully saved data.")); 598 showStatMsg(i18n("Successfully saved data."));
597 updateCaption(); 599 updateCaption();
598 return true; 600 return true;
599} 601}
600 602
601//US ENH : changed code to run with older MOC 603//US ENH : changed code to run with older MOC
602void PwM::addPwd_slot() 604void PwM::addPwd_slot()
603{ 605{
604 addPwd_slot1(0, 0); 606 addPwd_slot1(0, 0);
605} 607}
606 608
607void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) 609void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc)
608{ 610{
609 PwMDoc *doc; 611 PwMDoc *doc;
610 if (_doc) { 612 if (_doc) {
611 doc = _doc; 613 doc = _doc;
612 } else { 614 } else {
613 doc = curDoc(); 615 doc = curDoc();
614 } 616 }
615 PWM_ASSERT(doc); 617 PWM_ASSERT(doc);
616 doc->timer()->getLock(DocTimer::id_autoLockTimer); 618 doc->timer()->getLock(DocTimer::id_autoLockTimer);
617#ifndef PWM_EMBEDDED 619#ifndef PWM_EMBEDDED
618 AddEntryWndImpl w; 620 AddEntryWndImpl w;
619#else 621#else
620 AddEntryWndImpl w(this, "addentrywndimpl"); 622 AddEntryWndImpl w(this, "addentrywndimpl");
621#endif 623#endif
622 624
623 vector<string> catList; 625 vector<string> catList;
624 doc->getCategoryList(&catList); 626 doc->getCategoryList(&catList);
625 unsigned i, size = catList.size(); 627 unsigned i, size = catList.size();
626 for (i = 0; i < size; ++i) { 628 for (i = 0; i < size; ++i) {
627 w.addCategory(catList[i].c_str()); 629 w.addCategory(catList[i].c_str());
628 } 630 }
629 w.setCurrCategory(view->getCurrentCategory()); 631 w.setCurrCategory(view->getCurrentCategory());
630 if (pw) 632 if (pw)
631 w.pwLineEdit->setText(*pw); 633 w.pwLineEdit->setText(*pw);
632 634
633 tryAgain: 635 tryAgain:
634 if (w.exec() == 1) 636 if (w.exec() == 1)
635 { 637 {
636 PwMDataItem d; 638 PwMDataItem d;
637 639
638 //US BUG: to initialize all values of curEntr with meaningfulldata, 640 //US BUG: to initialize all values of curEntr with meaningfulldata,
639 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 641 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
640 // another option would be to create a constructor for PwMDataItem 642 // another option would be to create a constructor for PwMDataItem
641 d.clear(true); 643 d.clear(true);
642 644
643 d.desc = w.getDescription().latin1(); 645 d.desc = w.getDescription().latin1();
644 d.name = w.getUsername().latin1(); 646 d.name = w.getUsername().latin1();
645 d.pw = w.getPassword().latin1(); 647 d.pw = w.getPassword().latin1();
646 d.comment = w.getComment().latin1(); 648 d.comment = w.getComment().latin1();
647 d.url = w.getUrl().latin1(); 649 d.url = w.getUrl().latin1();
648 d.launcher = w.getLauncher().latin1(); 650 d.launcher = w.getLauncher().latin1();
649 PwMerror ret = doc->addEntry(w.getCategory(), &d); 651 PwMerror ret = doc->addEntry(w.getCategory(), &d);
650 if (ret == e_entryExists) { 652 if (ret == e_entryExists) {
651 KMessageBox::error(this, 653 KMessageBox::error(this,
652 i18n 654 i18n
653 ("An entry with this \"Description\",\n" 655 ("An entry with this \"Description\",\n"
654 "does already exist.\n" 656 "does already exist.\n"
655 "Please select another description."), 657 "Please select another description."),
656 i18n("entry already exists.")); 658 i18n("entry already exists."));
657 goto tryAgain; 659 goto tryAgain;
658 } else if (ret == e_maxAllowedEntr) { 660 } else if (ret == e_maxAllowedEntr) {
659 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 661 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
660 "has been reached.\nYou can't add more entries."), 662 "has been reached.\nYou can't add more entries."),
661 i18n("maximum number of entries")); 663 i18n("maximum number of entries"));
662 doc->timer()->putLock(DocTimer::id_autoLockTimer); 664 doc->timer()->putLock(DocTimer::id_autoLockTimer);
663 return; 665 return;
664 } 666 }
665 } 667 }
666 setVirgin(false); 668 setVirgin(false);
667 doc->timer()->putLock(DocTimer::id_autoLockTimer); 669 doc->timer()->putLock(DocTimer::id_autoLockTimer);
668} 670}
669 671
670//US ENH : changed code to run with older MOC 672//US ENH : changed code to run with older MOC
671void PwM::editPwd_slot() 673void PwM::editPwd_slot()
672{ 674{
673 editPwd_slot3(0,0,0); 675 editPwd_slot3(0,0,0);
674} 676}
675 677
676void PwM::editPwd_slot1(const QString *category) 678void PwM::editPwd_slot1(const QString *category)
677{ 679{
678 editPwd_slot3(category, 0, 0); 680 editPwd_slot3(category, 0, 0);
679} 681}
680 682
681void PwM::editPwd_slot3(const QString *category, const int *index, 683void PwM::editPwd_slot3(const QString *category, const int *index,
682 PwMDoc *_doc) 684 PwMDoc *_doc)
683{ 685{
684 PwMDoc *doc; 686 PwMDoc *doc;
685 if (_doc) { 687 if (_doc) {
686 doc = _doc; 688 doc = _doc;
687 } else { 689 } else {
688 doc = curDoc(); 690 doc = curDoc();
689 } 691 }
690 PWM_ASSERT(doc); 692 PWM_ASSERT(doc);
691 if (doc->isDocEmpty()) 693 if (doc->isDocEmpty())
692 return; 694 return;
693 if (doc->isDeepLocked()) 695 if (doc->isDeepLocked())
694 return; 696 return;
695 doc->timer()->getLock(DocTimer::id_autoLockTimer); 697 doc->timer()->getLock(DocTimer::id_autoLockTimer);
696 unsigned int curEntryIndex; 698 unsigned int curEntryIndex;
697 if (index) { 699 if (index) {
698 curEntryIndex = *index; 700 curEntryIndex = *index;
699 } else { 701 } else {
700 if (!(view->getCurEntryIndex(&curEntryIndex))) { 702 if (!(view->getCurEntryIndex(&curEntryIndex))) {
701 printDebug("couldn't get index. Maybe we have a binary entry here."); 703 printDebug("couldn't get index. Maybe we have a binary entry here.");
702 doc->timer()->putLock(DocTimer::id_autoLockTimer); 704 doc->timer()->putLock(DocTimer::id_autoLockTimer);
703 return; 705 return;
704 } 706 }
705 } 707 }
706 QString curCategory; 708 QString curCategory;
707 if (category) { 709 if (category) {
708 curCategory = *category; 710 curCategory = *category;
709 } else { 711 } else {
710 curCategory = view->getCurrentCategory(); 712 curCategory = view->getCurrentCategory();
711 } 713 }
712 PwMDataItem currItem; 714 PwMDataItem currItem;
713 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 715 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
714 doc->timer()->putLock(DocTimer::id_autoLockTimer); 716 doc->timer()->putLock(DocTimer::id_autoLockTimer);
715 return; 717 return;
716 } 718 }
717 BUG_ON(currItem.binary); 719 BUG_ON(currItem.binary);
718 720
719 AddEntryWndImpl w; 721 AddEntryWndImpl w;
720 vector<string> catList; 722 vector<string> catList;
721 doc->getCategoryList(&catList); 723 doc->getCategoryList(&catList);
722 unsigned i, size = catList.size(); 724 unsigned i, size = catList.size();
723 for (i = 0; i < size; ++i) { 725 for (i = 0; i < size; ++i) {
724 w.addCategory(catList[i].c_str()); 726 w.addCategory(catList[i].c_str());
725 } 727 }
726 w.setCurrCategory(curCategory); 728 w.setCurrCategory(curCategory);
727 w.setDescription(currItem.desc.c_str()); 729 w.setDescription(currItem.desc.c_str());
728 w.setUsername(currItem.name.c_str()); 730 w.setUsername(currItem.name.c_str());
729 w.setPassword(currItem.pw.c_str()); 731 w.setPassword(currItem.pw.c_str());
730 w.setUrl(currItem.url.c_str()); 732 w.setUrl(currItem.url.c_str());
731 w.setLauncher(currItem.launcher.c_str()); 733 w.setLauncher(currItem.launcher.c_str());
732 w.setComment(currItem.comment.c_str()); 734 w.setComment(currItem.comment.c_str());
733 if (w.exec() == 1) { 735 if (w.exec() == 1) {
734 currItem.desc = w.getDescription().latin1(); 736 currItem.desc = w.getDescription().latin1();
735 currItem.name = w.getUsername().latin1(); 737 currItem.name = w.getUsername().latin1();
736 currItem.pw = w.getPassword().latin1(); 738 currItem.pw = w.getPassword().latin1();
737 currItem.comment = w.getComment().latin1(); 739 currItem.comment = w.getComment().latin1();
738 currItem.url = w.getUrl().latin1(); 740 currItem.url = w.getUrl().latin1();
739 currItem.launcher = w.getLauncher().latin1(); 741 currItem.launcher = w.getLauncher().latin1();
740 if (!doc->editEntry(curCategory, w.getCategory(), 742 if (!doc->editEntry(curCategory, w.getCategory(),
741 curEntryIndex, &currItem)) { 743 curEntryIndex, &currItem)) {
742 KMessageBox::error(this, 744 KMessageBox::error(this,
743 i18n("Couldn't edit the entry.\n" 745 i18n("Couldn't edit the entry.\n"
744 "Maybe you changed the category and\n" 746 "Maybe you changed the category and\n"
745 "this entry is already present\nin the new " 747 "this entry is already present\nin the new "
746 "category?"), 748 "category?"),
747 i18n("couldn't edit entry.")); 749 i18n("couldn't edit entry."));
748 doc->timer()->putLock(DocTimer::id_autoLockTimer); 750 doc->timer()->putLock(DocTimer::id_autoLockTimer);
749 return; 751 return;
750 } 752 }
751 } 753 }
752 doc->timer()->putLock(DocTimer::id_autoLockTimer); 754 doc->timer()->putLock(DocTimer::id_autoLockTimer);
753} 755}
754 756
755void PwM::deletePwd_slot() 757void PwM::deletePwd_slot()
756{ 758{
757 PWM_ASSERT(curDoc()); 759 PWM_ASSERT(curDoc());
758 if (curDoc()->isDocEmpty()) 760 if (curDoc()->isDocEmpty())
759 return; 761 return;
760 if (curDoc()->isDeepLocked()) 762 if (curDoc()->isDeepLocked())
761 return; 763 return;
762 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 764 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
763 unsigned int curEntryIndex = 0; 765 unsigned int curEntryIndex = 0;
764 if (!(view->getCurEntryIndex(&curEntryIndex))) { 766 if (!(view->getCurEntryIndex(&curEntryIndex))) {
765 printDebug("couldn't get index"); 767 printDebug("couldn't get index");
766 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 768 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
767 return; 769 return;
768 } 770 }
769 771
770 PwMDataItem currItem; 772 PwMDataItem currItem;
771 QString curCategory = view->getCurrentCategory(); 773 QString curCategory = view->getCurrentCategory();
772 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 774 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
773 printDebug("couldn't get entry"); 775 printDebug("couldn't get entry");
774 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 776 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
775 return; 777 return;
776 } 778 }
777 if (KMessageBox:: 779 if (KMessageBox::
778 questionYesNo(this, 780 questionYesNo(this,
779 i18n 781 i18n
780 ("Do you really want to delete\nthe selected entry") + 782 ("Do you really want to delete\nthe selected entry") +
781 " \n\"" + QString(currItem.desc.c_str()) 783 " \n\"" + QString(currItem.desc.c_str())
782 + "\" ?", i18n("delete?")) 784 + "\" ?", i18n("delete?"))
783 == KMessageBox::Yes) { 785 == KMessageBox::Yes) {
784 786
785 curDoc()->delEntry(curCategory, curEntryIndex); 787 curDoc()->delEntry(curCategory, curEntryIndex);
786 } 788 }
787 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 789 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
788} 790}
789 791
790void PwM::changeMasterPwd_slot() 792void PwM::changeMasterPwd_slot()
791{ 793{
792 PWM_ASSERT(curDoc()); 794 PWM_ASSERT(curDoc());
793 curDoc()->changeCurrentPw(); 795 curDoc()->changeCurrentPw();
794} 796}
795 797
796void PwM::lockWnd_slot() 798void PwM::lockWnd_slot()
797{ 799{
798 PWM_ASSERT(curDoc()); 800 PWM_ASSERT(curDoc());
799 curDoc()->lockAll(true); 801 curDoc()->lockAll(true);
800} 802}
801 803
802void PwM::deepLockWnd_slot() 804void PwM::deepLockWnd_slot()
803{ 805{
804 PWM_ASSERT(curDoc()); 806 PWM_ASSERT(curDoc());
805 curDoc()->deepLock(); 807 curDoc()->deepLock();
806} 808}
807 809
808void PwM::unlockWnd_slot() 810void PwM::unlockWnd_slot()
809{ 811{
810 PWM_ASSERT(curDoc()); 812 PWM_ASSERT(curDoc());
811 curDoc()->lockAll(false); 813 curDoc()->lockAll(false);
812} 814}
813 815
814void PwM::config_slot() 816void PwM::config_slot()
815{ 817{
816 int oldStyle = conf()->confWndMainViewStyle(); 818 int oldStyle = conf()->confWndMainViewStyle();
817#ifdef PWM_EMBEDDED 819#ifdef PWM_EMBEDDED
818 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); 820 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true );
819 821
820 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); 822 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" );
821 ConfigureDialog->addModule(pwmcfg ); 823 ConfigureDialog->addModule(pwmcfg );
822 824
823 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 825 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
824 ConfigureDialog->addModule(kdelibcfg ); 826 ConfigureDialog->addModule(kdelibcfg );
825 827
826#ifndef DESKTOP_VERSION 828#ifndef DESKTOP_VERSION
827 ConfigureDialog->showMaximized(); 829 ConfigureDialog->showMaximized();
828#endif 830#endif
829 if ( ConfigureDialog->exec() ) 831 if ( ConfigureDialog->exec() )
830 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 832 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
831 delete ConfigureDialog; 833 delete ConfigureDialog;
832 834
833#else //PWM_EMBEDDED 835#else //PWM_EMBEDDED
834 // display the configuration window (modal mode) 836 // display the configuration window (modal mode)
835 if (!conf()->showConfWnd(this)) 837 if (!conf()->showConfWnd(this))
836 return; 838 return;
837#endif 839#endif
838 840
839 int newStyle = conf()->confWndMainViewStyle(); 841 int newStyle = conf()->confWndMainViewStyle();
840 // reinitialize tray 842 // reinitialize tray
841 init->initTray(); 843 init->initTray();
842 // reinitialize KWallet emulation 844 // reinitialize KWallet emulation
843 init->initKWalletEmu(); 845 init->initKWalletEmu();
844 846
845 PwMDocList *_dl = PwMDoc::getOpenDocList(); 847 PwMDocList *_dl = PwMDoc::getOpenDocList();
846 const vector<PwMDocList::listItem> *dl = _dl->getList(); 848 const vector<PwMDocList::listItem> *dl = _dl->getList();
847 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 849 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
848 end = dl->end(); 850 end = dl->end();
849 PwMDoc *doc; 851 PwMDoc *doc;
850 while (i != end) { 852 while (i != end) {
851 doc = (*i).doc; 853 doc = (*i).doc;
852 // unlock-without-mpw timeout 854 // unlock-without-mpw timeout
853 doc->timer()->start(DocTimer::id_mpwTimer); 855 doc->timer()->start(DocTimer::id_mpwTimer);
854 // auto-lock timeout 856 // auto-lock timeout
855 doc->timer()->start(DocTimer::id_autoLockTimer); 857 doc->timer()->start(DocTimer::id_autoLockTimer);
856 ++i; 858 ++i;
857 } 859 }
858 860
859 const QValueList<PwM *> *ml = init->mainWndList(); 861 const QValueList<PwM *> *ml = init->mainWndList();
860#ifndef PWM_EMBEDDED 862#ifndef PWM_EMBEDDED
861 QValueList<PwM *>::const_iterator i2 = ml->begin(), 863 QValueList<PwM *>::const_iterator i2 = ml->begin(),
862 end2 = ml->end(); 864 end2 = ml->end();
863#else 865#else
864 QValueList<PwM *>::ConstIterator i2 = ml->begin(), 866 QValueList<PwM *>::ConstIterator i2 = ml->begin(),
865 end2 = ml->end(); 867 end2 = ml->end();
866#endif 868#endif
867 PwM *pwm; 869 PwM *pwm;
868 while (i2 != end2) { 870 while (i2 != end2) {
869 pwm = *i2; 871 pwm = *i2;
870 // reinitialize the window style. 872 // reinitialize the window style.
871 if (oldStyle != newStyle) 873 if (oldStyle != newStyle)
872 pwm->curView()->initStyle(newStyle); 874 pwm->curView()->initStyle(newStyle);
873 // set the new font 875 // set the new font
874 pwm->curView()->setFont(conf()->confGlobEntryFont()); 876 pwm->curView()->setFont(conf()->confGlobEntryFont());
875 ++i2; 877 ++i2;
876 } 878 }
877} 879}
878 880
879void PwM::activateMpButton(bool activate) 881void PwM::activateMpButton(bool activate)
880{ 882{
881 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); 883 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
882} 884}
883 885
884void PwM::closeEvent(QCloseEvent *e) 886void PwM::closeEvent(QCloseEvent *e)
885{ 887{
886 e->accept(); 888 e->accept();
887} 889}
888 890
889void PwM::docClosed(PwMDoc *doc) 891void PwM::docClosed(PwMDoc *doc)
890{ 892{
891 PARAM_UNUSED(doc); 893 PARAM_UNUSED(doc);
892 PWM_ASSERT(doc == curDoc()); 894 PWM_ASSERT(doc == curDoc());
893 close(); 895 close();
894} 896}
895 897
896void PwM::find_slot() 898void PwM::find_slot()
897{ 899{
898 PWM_ASSERT(curDoc()); 900 PWM_ASSERT(curDoc());
899 if (curDoc()->isDocEmpty()) 901 if (curDoc()->isDocEmpty())
900 return; 902 return;
901 if (curDoc()->isDeepLocked()) 903 if (curDoc()->isDeepLocked())
902 return; 904 return;
903 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 905 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
904 FindWndImpl findWnd(view); 906 FindWndImpl findWnd(view);
905 findWnd.exec(); 907 findWnd.exec();
906 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 908 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
907} 909}
908 910
909void PwM::exportToText() 911void PwM::exportToText()
910{ 912{
911 PWM_ASSERT(curDoc()); 913 PWM_ASSERT(curDoc());
912 if (curDoc()->isDocEmpty()) { 914 if (curDoc()->isDocEmpty()) {
913 KMessageBox::information(this, 915 KMessageBox::information(this,
914 i18n 916 i18n
915 ("Sorry, there's nothing to export.\n" 917 ("Sorry, there's nothing to export.\n"
916 "Please first add some passwords."), 918 "Please first add some passwords."),
917 i18n("nothing to do")); 919 i18n("nothing to do"));
918 return; 920 return;
919 } 921 }
920 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 922 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
921 QString fn(KFileDialog::getSaveFileName(QString::null, 923 QString fn(KFileDialog::getSaveFileName(QString::null,
922 i18n("*|plain-text file"), 924 i18n("*|plain-text file"),
923 this)); 925 this));
924 if (fn == "") { 926 if (fn == "") {
925 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 927 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
926 return; 928 return;
927 } 929 }
928 930
929 PwMerror ret = curDoc()->exportToText(&fn); 931 PwMerror ret = curDoc()->exportToText(&fn);
930 if (ret != e_success) { 932 if (ret != e_success) {
931 KMessageBox::error(this, 933 KMessageBox::error(this,
932 i18n("Error: Couldn't write to file.\n" 934 i18n("Error: Couldn't write to file.\n"
933 "Please check if you have permission to write\n" 935 "Please check if you have permission to write\n"
934 "to the file in that directory."), 936 "to the file in that directory."),
935 i18n("error while writing")); 937 i18n("error while writing"));
936 } else 938 } else
937 showStatMsg(i18n("Successfully exported data.")); 939 showStatMsg(i18n("Successfully exported data."));
938 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 940 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
939} 941}
940 942
941bool PwM::importFromText() 943bool PwM::importFromText()
942{ 944{
943 if (!isVirgin()) { 945 if (!isVirgin()) {
944 if (KMessageBox::questionYesNo(this, 946 if (KMessageBox::questionYesNo(this,
945 i18n("Do you want to import the data\n" 947 i18n("Do you want to import the data\n"
946 "into the current document? (If you\n" 948 "into the current document? (If you\n"
947 "select \"no\", a new document will be\n" 949 "select \"no\", a new document will be\n"
948 "opened.)"), 950 "opened.)"),
949 i18n("import into this document?")) 951 i18n("import into this document?"))
950 == KMessageBox::No) { 952 == KMessageBox::No) {
951 // import the data to a new window. 953 // import the data to a new window.
952 PwM *newInstance = init->createMainWnd(); 954 PwM *newInstance = init->createMainWnd();
953 bool ok = newInstance->importFromText(); 955 bool ok = newInstance->importFromText();
954 if (!ok) { 956 if (!ok) {
955 newInstance->setForceQuit(true); 957 newInstance->setForceQuit(true);
956 delete_and_null(newInstance); 958 delete_and_null(newInstance);
957 } 959 }
958 return ok; 960 return ok;
959 } 961 }
960 } 962 }
961 963
962 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 964 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
963 PwMerror ret; 965 PwMerror ret;
964 QString path(KFileDialog::getOpenFileName(QString::null, 966 QString path(KFileDialog::getOpenFileName(QString::null,
965 i18n("*|PWM-exported text file"), 967 i18n("*|PWM-exported text file"),
966 this)); 968 this));
967 if (path == "") 969 if (path == "")
968 goto cancelImport; 970 goto cancelImport;
969 971
970 ret = curDoc()->importFromText(&path, 0); 972 ret = curDoc()->importFromText(&path, 0);
971 if (ret == e_fileFormat) { 973 if (ret == e_fileFormat) {
972 KMessageBox::error(this, 974 KMessageBox::error(this,
973 i18n("Could not read file-format.\n" 975 i18n("Could not read file-format.\n"
974 "This seems to be _not_ a valid file\n" 976 "This seems to be _not_ a valid file\n"
975 "exported by PwM."), 977 "exported by PwM."),
976 i18n("invalid file-format")); 978 i18n("invalid file-format"));
977 goto cancelImport; 979 goto cancelImport;
978 } else if (ret == e_invalidArg) { 980 } else if (ret == e_invalidArg) {
979 BUG(); 981 BUG();
980 goto cancelImport; 982 goto cancelImport;
981 } else if (ret != e_success) { 983 } else if (ret != e_success) {
982 KMessageBox::error(this, 984 KMessageBox::error(this,
983 i18n("Could not import file!\n" 985 i18n("Could not import file!\n"
984 "Do you have permission to read this file?\n" 986 "Do you have permission to read this file?\n"
985 "Do you have enough free memory?"), 987 "Do you have enough free memory?"),
986 i18n("import failed")); 988 i18n("import failed"));
987 goto cancelImport; 989 goto cancelImport;
988 } 990 }
989 setVirgin(false); 991 setVirgin(false);
990 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 992 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
991 return true; 993 return true;
992 994
993cancelImport: 995cancelImport:
994 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 996 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
995 return false; 997 return false;
996} 998}
997 999
998void PwM::exportToGpasman() 1000void PwM::exportToGpasman()
999{ 1001{
1000 PWM_ASSERT(curDoc()); 1002 PWM_ASSERT(curDoc());
1001 if (curDoc()->isDocEmpty()) { 1003 if (curDoc()->isDocEmpty()) {
1002 KMessageBox::information(this, 1004 KMessageBox::information(this,
1003 i18n 1005 i18n
1004 ("Sorry, there's nothing to export.\n" 1006 ("Sorry, there's nothing to export.\n"
1005 "Please first add some passwords."), 1007 "Please first add some passwords."),
1006 i18n("nothing to do")); 1008 i18n("nothing to do"));
1007 return; 1009 return;
1008 } 1010 }
1009 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1011 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1010 QString fn(KFileDialog::getSaveFileName(QString::null, 1012 QString fn(KFileDialog::getSaveFileName(QString::null,
1011 i18n("*|Gpasman or Kpasman file"), 1013 i18n("*|Gpasman or Kpasman file"),
1012 this)); 1014 this));
1013 if (fn == "") { 1015 if (fn == "") {
1014 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1016 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1015 return; 1017 return;
1016 } 1018 }
1017 1019
1018 PwMerror ret = curDoc()->exportToGpasman(&fn); 1020 PwMerror ret = curDoc()->exportToGpasman(&fn);
1019 if (ret != e_success) { 1021 if (ret != e_success) {
1020 if (ret == e_noPw) { 1022 if (ret == e_noPw) {
1021 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1023 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1022 return; 1024 return;
1023 } 1025 }
1024 KMessageBox::error(this, 1026 KMessageBox::error(this,
1025 i18n("Error: Couldn't write to file.\n" 1027 i18n("Error: Couldn't write to file.\n"
1026 "Please check if you have permission to write " 1028 "Please check if you have permission to write "
1027 "to the file in that directory."), 1029 "to the file in that directory."),
1028 i18n("error while writing")); 1030 i18n("error while writing"));
1029 } else 1031 } else
1030 showStatMsg(i18n("Successfully exported data.")); 1032 showStatMsg(i18n("Successfully exported data."));
1031 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1033 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1032} 1034}
1033 1035
1034 1036
1035 1037
1036void PwM::exportToCsv() 1038void PwM::exportToCsv()
1037{ 1039{
1038 PWM_ASSERT(curDoc()); 1040 PWM_ASSERT(curDoc());
1039 if (curDoc()->isDocEmpty()) { 1041 if (curDoc()->isDocEmpty()) {
1040 KMessageBox::information(this, 1042 KMessageBox::information(this,
1041 i18n 1043 i18n
1042 ("Sorry, there is nothing to export;\n" 1044 ("Sorry, there is nothing to export;\n"
1043 "please add some passwords first."), 1045 "please add some passwords first."),
1044 i18n("Nothing to Do")); 1046 i18n("Nothing to Do"));
1045 return; 1047 return;
1046 } 1048 }
1047 1049
1048 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1050 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1049 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); 1051 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this));
1050 if (fn.isEmpty()) { 1052 if (fn.isEmpty()) {
1051 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1053 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1052 return; 1054 return;
1053 } 1055 }
1054 1056
1055 Csv csv(this); 1057 Csv csv(this);
1056 if (!csv.exportData(fn, curDoc())) { 1058 if (!csv.exportData(fn, curDoc())) {
1057 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1059 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1058 showStatMsg(i18n("CSV file export failed.")); 1060 showStatMsg(i18n("CSV file export failed."));
1059 return; 1061 return;
1060 } 1062 }
1061 showStatMsg(i18n("Successfully exported data.")); 1063 showStatMsg(i18n("Successfully exported data."));
1062 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1064 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1063} 1065}
1064 1066
1065bool PwM::importCsv() 1067bool PwM::importCsv()
1066{ 1068{
1067 Csv csv(this); 1069 Csv csv(this);
1068 if (!isVirgin()) { 1070 if (!isVirgin()) {
1069 if (KMessageBox::questionYesNo(this, 1071 if (KMessageBox::questionYesNo(this,
1070 i18n("Do you want to import the data\n" 1072 i18n("Do you want to import the data\n"
1071 "into the current document? (If you\n" 1073 "into the current document? (If you\n"
1072 "select \"no\", a new document will be\n" 1074 "select \"no\", a new document will be\n"
1073 "opened.)"), 1075 "opened.)"),
1074 i18n("Import into This Document?")) 1076 i18n("Import into This Document?"))
1075 == KMessageBox::No) { 1077 == KMessageBox::No) {
1076 // import the data to a new window. 1078 // import the data to a new window.
1077 PwM *newInstance = init->createMainWnd(); 1079 PwM *newInstance = init->createMainWnd();
1078 bool ok = newInstance->importCsv(); 1080 bool ok = newInstance->importCsv();
1079 if (!ok) { 1081 if (!ok) {
1080 newInstance->setForceQuit(true); 1082 newInstance->setForceQuit(true);
1081 delete_and_null(newInstance); 1083 delete_and_null(newInstance);
1082 } 1084 }
1083 return ok; 1085 return ok;
1084 } 1086 }
1085 } 1087 }
1086 1088
1087 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); 1089 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this);
1088 if (filename.isEmpty()) 1090 if (filename.isEmpty())
1089 return false; 1091 return false;
1090 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1092 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1091 if (!csv.importData(filename, curDoc())) { 1093 if (!csv.importData(filename, curDoc())) {
1092 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1094 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1093 showStatMsg(i18n("CSV file import failed.")); 1095 showStatMsg(i18n("CSV file import failed."));
1094 return false; 1096 return false;
1095 } 1097 }
1096 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1098 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1097 KMessageBox::information(this, 1099 KMessageBox::information(this,
1098 i18n("Successfully imported the CSV data\n" 1100 i18n("Successfully imported the CSV data\n"
1099 "into the current document."), i18n("Successfully Imported")); 1101 "into the current document."), i18n("Successfully Imported"));
1100 showStatMsg(i18n("Successfully imported")); 1102 showStatMsg(i18n("Successfully imported"));
1101 setVirgin(false); 1103 setVirgin(false);
1102 return true; 1104 return true;
1103} 1105}
1104 1106
1105 1107
1106void PwM::exportToKWallet() 1108void PwM::exportToKWallet()
1107{ 1109{
1108#ifdef CONFIG_KWALLETIF 1110#ifdef CONFIG_KWALLETIF
1109 if (!checkAndAskForKWalletEmu()) 1111 if (!checkAndAskForKWalletEmu())
1110 return; 1112 return;
1111 PWM_ASSERT(curDoc()); 1113 PWM_ASSERT(curDoc());
1112 if (curDoc()->isDocEmpty()) { 1114 if (curDoc()->isDocEmpty()) {
1113 KMessageBox::information(this, 1115 KMessageBox::information(this,
1114 i18n 1116 i18n
1115 ("Sorry, there's nothing to export.\n" 1117 ("Sorry, there's nothing to export.\n"
1116 "Please first add some passwords."), 1118 "Please first add some passwords."),
1117 i18n("nothing to do")); 1119 i18n("nothing to do"));
1118 init->initKWalletEmu(); 1120 init->initKWalletEmu();
1119 return; 1121 return;
1120 } 1122 }
1121 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1123 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1122 KWalletIf walletIf(this); 1124 KWalletIf walletIf(this);
1123 if (walletIf.kwalletExport(curDoc())) { 1125 if (walletIf.kwalletExport(curDoc())) {
1124 KMessageBox::information(this, 1126 KMessageBox::information(this,
1125 i18n("Successfully exported the data of the current " 1127 i18n("Successfully exported the data of the current "
1126 "document to KWallet."), 1128 "document to KWallet."),
1127 i18n("Successfully exported data.")); 1129 i18n("Successfully exported data."));
1128 showStatMsg(i18n("Successfully exported data.")); 1130 showStatMsg(i18n("Successfully exported data."));
1129 } 1131 }
1130 init->initKWalletEmu(); 1132 init->initKWalletEmu();
1131 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1133 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1132#endif // CONFIG_KWALLETIF 1134#endif // CONFIG_KWALLETIF
1133} 1135}
1134 1136
1135bool PwM::importFromGpasman() 1137bool PwM::importFromGpasman()
1136{ 1138{
1137 if (!isVirgin()) { 1139 if (!isVirgin()) {
1138 if (KMessageBox::questionYesNo(this, 1140 if (KMessageBox::questionYesNo(this,
1139 i18n("Do you want to import the data\n" 1141 i18n("Do you want to import the data\n"
1140 "into the current document? (If you\n" 1142 "into the current document? (If you\n"
1141 "select \"no\", a new document will be\n" 1143 "select \"no\", a new document will be\n"
1142 "opened.)"), 1144 "opened.)"),
1143 i18n("import into this document?")) 1145 i18n("import into this document?"))
1144 == KMessageBox::No) { 1146 == KMessageBox::No) {
1145 // import the data to a new window. 1147 // import the data to a new window.
1146 PwM *newInstance = init->createMainWnd(); 1148 PwM *newInstance = init->createMainWnd();
1147 bool ok = newInstance->importFromGpasman(); 1149 bool ok = newInstance->importFromGpasman();
1148 if (!ok) { 1150 if (!ok) {
1149 newInstance->setForceQuit(true); 1151 newInstance->setForceQuit(true);
1150 delete_and_null(newInstance); 1152 delete_and_null(newInstance);
1151 } 1153 }
1152 return ok; 1154 return ok;
1153 } 1155 }
1154 } 1156 }
1155 1157
1156 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1158 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1157 PwMerror ret; 1159 PwMerror ret;
1158 QString path(KFileDialog::getOpenFileName(QString::null, 1160 QString path(KFileDialog::getOpenFileName(QString::null,
1159 i18n("*|Gpasman or Kpasman file"), this)); 1161 i18n("*|Gpasman or Kpasman file"), this));
1160 if (path == "") 1162 if (path == "")
1161 goto cancelImport; 1163 goto cancelImport;
1162 ret = curDoc()->importFromGpasman(&path); 1164 ret = curDoc()->importFromGpasman(&path);
1163 if (ret == e_wrongPw) { 1165 if (ret == e_wrongPw) {
1164 if (KMessageBox::questionYesNo(this, 1166 if (KMessageBox::questionYesNo(this,
1165 i18n 1167 i18n
1166 ("This is probably the wrong master-password\n" 1168 ("This is probably the wrong master-password\n"
1167 "you have typed in.\n" 1169 "you have typed in.\n"
1168 "There is no real way to determine the\n" 1170 "There is no real way to determine the\n"
1169 "correctness of the password in the Gpasman\n" 1171 "correctness of the password in the Gpasman\n"
1170 "file-format. But I think this\n" 1172 "file-format. But I think this\n"
1171 "password ist wrong.\n" 1173 "password ist wrong.\n"
1172 "Do you want to continue nevertheless?"), 1174 "Do you want to continue nevertheless?"),
1173 i18n("password error")) 1175 i18n("password error"))
1174 == KMessageBox::No) { 1176 == KMessageBox::No) {
1175 goto cancelImport; 1177 goto cancelImport;
1176 } 1178 }
1177 } else if (ret != e_success) { 1179 } else if (ret != e_success) {
1178 KMessageBox::error(this, 1180 KMessageBox::error(this,
1179 i18n("Could not import file!\n" 1181 i18n("Could not import file!\n"
1180 "Do you have permission to read this file?"), 1182 "Do you have permission to read this file?"),
1181 i18n("import failed")); 1183 i18n("import failed"));
1182 goto cancelImport; 1184 goto cancelImport;
1183 } 1185 }
1184 setVirgin(false); 1186 setVirgin(false);
1185 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1187 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1186 return true; 1188 return true;
1187 1189
1188cancelImport: 1190cancelImport:
1189 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1191 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1190 return false; 1192 return false;
1191} 1193}
1192 1194
1193#ifdef CONFIG_KWALLETIF 1195#ifdef CONFIG_KWALLETIF
1194bool PwM::checkAndAskForKWalletEmu() 1196bool PwM::checkAndAskForKWalletEmu()
1195{ 1197{
1196 if (init->kwalletEmu()) { 1198 if (init->kwalletEmu()) {
1197 /* KWallet emulation is enabled. We can't import/export 1199 /* KWallet emulation is enabled. We can't import/export
1198 * data from/to it, while emulation is active. 1200 * data from/to it, while emulation is active.
1199 */ 1201 */
1200 if (KMessageBox::questionYesNo(this, 1202 if (KMessageBox::questionYesNo(this,
1201 i18n("KWallet emulation is enabled.\n" 1203 i18n("KWallet emulation is enabled.\n"
1202 "You can't import or export data from/to " 1204 "You can't import or export data from/to "
1203 "the original KWallet, while the emulation " 1205 "the original KWallet, while the emulation "
1204 "is active.\n" 1206 "is active.\n"
1205 "Do you want to tempoarly disable the KWallet emulation?"), 1207 "Do you want to tempoarly disable the KWallet emulation?"),
1206 i18n("Tempoarly disable KWallet emulation?")) 1208 i18n("Tempoarly disable KWallet emulation?"))
1207 == KMessageBox::Yes) { 1209 == KMessageBox::Yes) {
1208 init->initKWalletEmu(true); 1210 init->initKWalletEmu(true);
1209 PWM_ASSERT(!init->kwalletEmu()); 1211 PWM_ASSERT(!init->kwalletEmu());
1210 return true; 1212 return true;
1211 } 1213 }
1212 return false; 1214 return false;
1213 } 1215 }
1214 return true; 1216 return true;
1215} 1217}
1216#endif // CONFIG_KWALLETIF 1218#endif // CONFIG_KWALLETIF
1217 1219
1218bool PwM::importKWallet() 1220bool PwM::importKWallet()
1219{ 1221{
1220#ifdef CONFIG_KWALLETIF 1222#ifdef CONFIG_KWALLETIF
1221 if (!checkAndAskForKWalletEmu()) 1223 if (!checkAndAskForKWalletEmu())
1222 return false; 1224 return false;
1223 KWalletIf walletIf(this); 1225 KWalletIf walletIf(this);
1224 if (!isVirgin()) { 1226 if (!isVirgin()) {
1225 if (KMessageBox::questionYesNo(this, 1227 if (KMessageBox::questionYesNo(this,
1226 i18n("Do you want to import the data " 1228 i18n("Do you want to import the data "
1227 "into the current document? (If you " 1229 "into the current document? (If you "
1228 "select \"no\", a new document will be " 1230 "select \"no\", a new document will be "
1229 "opened.)"), 1231 "opened.)"),
1230 i18n("import into this document?")) 1232 i18n("import into this document?"))
1231 == KMessageBox::No) { 1233 == KMessageBox::No) {
1232 // import the data to a new window. 1234 // import the data to a new window.
1233 PwM *newInstance = init->createMainWnd(); 1235 PwM *newInstance = init->createMainWnd();
1234 bool ok = newInstance->importKWallet(); 1236 bool ok = newInstance->importKWallet();
1235 if (!ok) { 1237 if (!ok) {
1236 newInstance->setForceQuit(true); 1238 newInstance->setForceQuit(true);
1237 delete_and_null(newInstance); 1239 delete_and_null(newInstance);
1238 goto exit_fail; 1240 goto exit_fail;
1239 } else { 1241 } else {
1240 goto exit_ok; 1242 goto exit_ok;
1241 } 1243 }
1242 } 1244 }
1243 } 1245 }
1244 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1246 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1245 if (!walletIf.kwalletImport(curDoc())) { 1247 if (!walletIf.kwalletImport(curDoc())) {
1246 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1248 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1247 showStatMsg(i18n("KWallet import failed")); 1249 showStatMsg(i18n("KWallet import failed"));
1248 goto exit_fail; 1250 goto exit_fail;
1249 } 1251 }
1250 KMessageBox::information(this, 1252 KMessageBox::information(this,
1251 i18n("Successfully imported the KWallet data " 1253 i18n("Successfully imported the KWallet data "
1252 "into the current document."), 1254 "into the current document."),
1253 i18n("successfully imported")); 1255 i18n("successfully imported"));
1254 showStatMsg(i18n("successfully imported")); 1256 showStatMsg(i18n("successfully imported"));
1255 setVirgin(false); 1257 setVirgin(false);
1256 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1258 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1257 1259
1258exit_ok: 1260exit_ok:
1259 init->initKWalletEmu(); 1261 init->initKWalletEmu();
1260 return true; 1262 return true;
1261 1263
1262exit_fail: 1264exit_fail:
1263 init->initKWalletEmu(); 1265 init->initKWalletEmu();
1264#endif // CONFIG_KWALLETIF 1266#endif // CONFIG_KWALLETIF
1265 return false; 1267 return false;
1266} 1268}
1267 1269
1268void PwM::print_slot() 1270void PwM::print_slot()
1269{ 1271{
1270 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1272 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1271#ifndef PWM_EMBEDDED 1273#ifndef PWM_EMBEDDED
1272 PwMPrint p(curDoc(), this); 1274 PwMPrint p(curDoc(), this);
1273 p.printNow(); 1275 p.printNow();
1274#else 1276#else
1275 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); 1277 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED");
1276#endif 1278#endif
1277 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1279 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1278} 1280}
1279 1281
1280void PwM::genNewCard_slot() 1282void PwM::genNewCard_slot()
1281{ 1283{
1282#ifdef CONFIG_KEYCARD 1284#ifdef CONFIG_KEYCARD
1283 init->keycard()->genNewCard(); 1285 init->keycard()->genNewCard();
1284#endif 1286#endif
1285} 1287}
1286 1288
1287void PwM::eraseCard_slot() 1289void PwM::eraseCard_slot()
1288{ 1290{
1289#ifdef CONFIG_KEYCARD 1291#ifdef CONFIG_KEYCARD
1290 init->keycard()->eraseCard(); 1292 init->keycard()->eraseCard();
1291#endif 1293#endif
1292} 1294}
1293 1295
1294void PwM::readCardId_slot() 1296void PwM::readCardId_slot()
1295{ 1297{
1296#ifdef CONFIG_KEYCARD 1298#ifdef CONFIG_KEYCARD
1297 init->keycard()->displayKey(); 1299 init->keycard()->displayKey();
1298#endif 1300#endif
1299} 1301}
1300 1302
1301void PwM::makeCardBackup_slot() 1303void PwM::makeCardBackup_slot()
1302{ 1304{
1303#ifdef CONFIG_KEYCARD 1305#ifdef CONFIG_KEYCARD
1304 init->keycard()->makeBackupImage(); 1306 init->keycard()->makeBackupImage();
1305#endif 1307#endif
1306} 1308}
1307 1309
1308void PwM::replayCardBackup_slot() 1310void PwM::replayCardBackup_slot()
1309{ 1311{
1310#ifdef CONFIG_KEYCARD 1312#ifdef CONFIG_KEYCARD
1311 init->keycard()->replayBackupImage(); 1313 init->keycard()->replayBackupImage();
1312#endif 1314#endif
1313} 1315}
1314 1316
1315void PwM::execLauncher_slot() 1317void PwM::execLauncher_slot()
1316{ 1318{
1317 PWM_ASSERT(curDoc()); 1319 PWM_ASSERT(curDoc());
1318 if (curDoc()->isDeepLocked()) 1320 if (curDoc()->isDeepLocked())
1319 return; 1321 return;
1320 unsigned int curEntryIndex; 1322 unsigned int curEntryIndex;
1321 if (!view->getCurEntryIndex(&curEntryIndex)) 1323 if (!view->getCurEntryIndex(&curEntryIndex))
1322 return; 1324 return;
1323 bool ret = curDoc()->execLauncher(view->getCurrentCategory(), 1325 bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
1324 curEntryIndex); 1326 curEntryIndex);
1325 if (ret) 1327 if (ret)
1326 showStatMsg(i18n("Executed the \"Launcher\".")); 1328 showStatMsg(i18n("Executed the \"Launcher\"."));
1327 else 1329 else
1328 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); 1330 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
1329} 1331}
1330 1332
1331void PwM::goToURL_slot() 1333void PwM::goToURL_slot()
1332{ 1334{
1333 PWM_ASSERT(curDoc()); 1335 PWM_ASSERT(curDoc());
1334 if (curDoc()->isDeepLocked()) 1336 if (curDoc()->isDeepLocked())
1335 return; 1337 return;
1336 unsigned int curEntryIndex; 1338 unsigned int curEntryIndex;
1337 if (!view->getCurEntryIndex(&curEntryIndex)) 1339 if (!view->getCurEntryIndex(&curEntryIndex))
1338 return; 1340 return;
1339 bool ret = curDoc()->goToURL(view->getCurrentCategory(), 1341 bool ret = curDoc()->goToURL(view->getCurrentCategory(),
1340 curEntryIndex); 1342 curEntryIndex);
1341 if (ret) 1343 if (ret)
1342 showStatMsg(i18n("started browser with current URL.")); 1344 showStatMsg(i18n("started browser with current URL."));
1343 else 1345 else
1344 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); 1346 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
1345} 1347}
1346 1348
1347void PwM::copyToClipboard(const QString &s) 1349void PwM::copyToClipboard(const QString &s)
1348{ 1350{
1349 QClipboard *cb = QApplication::clipboard(); 1351 QClipboard *cb = QApplication::clipboard();
1350#ifndef PWM_EMBEDDED 1352#ifndef PWM_EMBEDDED
1351 if (cb->supportsSelection()) 1353 if (cb->supportsSelection())
1352 cb->setText(s, QClipboard::Selection); 1354 cb->setText(s, QClipboard::Selection);
1353 cb->setText(s, QClipboard::Clipboard); 1355 cb->setText(s, QClipboard::Clipboard);
1354#else 1356#else
1355 cb->setText(s); 1357 cb->setText(s);
1356 1358
1357#endif 1359#endif
1358 1360
1359} 1361}
1360 1362
1363
1361void PwM::showStatMsg(const QString &msg) 1364void PwM::showStatMsg(const QString &msg)
1362{ 1365{
1363#ifndef PWM_EMBEDDED 1366#ifdef DESKTOP_VERSION
1364 KStatusBar *statBar = statusBar(); 1367 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1365 statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1366#else 1368#else
1367 qDebug("Statusbar : %s",msg.latin1()); 1369 qDebug("Statusbar : %s",msg.latin1());
1368#ifndef DESKTOP_VERSION
1369 Global::statusMessage(msg); 1370 Global::statusMessage(msg);
1370#endif 1371#endif
1371#endif
1372} 1372}
1373 1373
1374void PwM::focusInEvent(QFocusEvent *e) 1374void PwM::focusInEvent(QFocusEvent *e)
1375{ 1375{
1376 if (e->gotFocus()) { 1376 if (e->gotFocus()) {
1377 emit gotFocus(this); 1377 emit gotFocus(this);
1378 } else if (e->lostFocus()) { 1378 } else if (e->lostFocus()) {
1379 emit lostFocus(this); 1379 emit lostFocus(this);
1380 } 1380 }
1381} 1381}
1382 1382
1383 1383
1384#ifdef PWM_EMBEDDED 1384#ifdef PWM_EMBEDDED
1385 1385
1386void PwM::whatsnew_slot() 1386void PwM::whatsnew_slot()
1387{ 1387{
1388 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1388 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1389} 1389}
1390 1390
1391void PwM::showLicense_slot() 1391void PwM::showLicense_slot()
1392{ 1392{
1393 KApplication::showLicence(); 1393 KApplication::showLicence();
1394} 1394}
1395 1395
1396void PwM::faq_slot() 1396void PwM::faq_slot()
1397{ 1397{
1398 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); 1398 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
1399} 1399}
1400 1400
1401void PwM::syncHowTo_slot() 1401void PwM::syncHowTo_slot()
1402{ 1402{
1403 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1403 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1404} 1404}
1405 1405
1406 1406
1407void PwM::createAboutData_slot() 1407void PwM::createAboutData_slot()
1408{ 1408{
1409 QString version; 1409 QString version;
1410#include <../version> 1410#include <../version>
1411 QMessageBox::about( this, "About PwManager/Pi", 1411 QMessageBox::about( this, "About PwManager/Pi",
1412 "PwManager/Platform-independent\n" 1412 "PwManager/Platform-independent\n"
1413 "(PWM/Pi) " +version + " - " + 1413 "(PWM/Pi) " +version + " - " +
1414#ifdef DESKTOP_VERSION 1414#ifdef DESKTOP_VERSION
1415 "Desktop Edition\n" 1415 "Desktop Edition\n"
1416#else 1416#else
1417 "PDA-Edition\n" 1417 "PDA-Edition\n"
1418 "for: Zaurus 5500 / 7x0 / 8x0\n" 1418 "for: Zaurus 5500 / 7x0 / 8x0\n"
1419#endif 1419#endif
1420 1420
1421 "(c) 2004 Ulf Schenk\n" 1421 "(c) 2004 Ulf Schenk\n"
1422 "(c) 2004 Lutz Rogowski\n" 1422 "(c) 2004 Lutz Rogowski\n"
1423 "(c) 1997-2004, The KDE PIM Team\n" 1423 "(c) 1997-2004, The KDE PIM Team\n"
1424 1424
1425 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" 1425 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n"
1426 "Matt Scifo - mscifo@o1.com\n" 1426 "Matt Scifo - mscifo@o1.com\n"
1427 "Elias Probst - elias.probst@gmx.de\n" 1427 "Elias Probst - elias.probst@gmx.de\n"
1428 "George Staikos - staikos@kde.org\n" 1428 "George Staikos - staikos@kde.org\n"
1429 "Matthew Palmer - mjp16@uow.edu.au\n" 1429 "Matthew Palmer - mjp16@uow.edu.au\n"
1430 "Olivier Sessink - gpasman@nl.linux.org\n" 1430 "Olivier Sessink - gpasman@nl.linux.org\n"
1431 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" 1431 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
1432 "Troy Engel - tengel@sonic.net\n" 1432 "Troy Engel - tengel@sonic.net\n"
1433 "Wickey - wickey@gmx.at\n" 1433 "Wickey - wickey@gmx.at\n"
1434 "Ian MacGregor - original documentation author.\n" 1434 "Ian MacGregor - original documentation author.\n"
1435 ); 1435 );
1436} 1436}
1437 1437
1438 1438
1439//this are the overwritten callbackmethods from the syncinterface 1439//this are the overwritten callbackmethods from the syncinterface
1440bool PwM::sync(KSyncManager* manager, QString filename, int mode) 1440bool PwM::sync(KSyncManager* manager, QString filename, int mode)
1441{ 1441{
1442 PWM_ASSERT(curDoc()); 1442 PWM_ASSERT(curDoc());
1443 1443
1444 bool ret = curDoc()->sync(manager, filename, mode); 1444 bool ret = curDoc()->sync(manager, filename, mode);
1445 1445
1446 qDebug("PwM::sync save now: ret=%i", ret); 1446 qDebug("PwM::sync save now: ret=%i", ret);
1447 1447
1448 if (ret == true) { 1448 if (ret == true) {
1449 //US BUG: what can we call here to update the view of the current doc? 1449 //US BUG: what can we call here to update the view of the current doc?
1450 //mViewManager->refreshView(); 1450 //mViewManager->refreshView();
1451 1451
1452 //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. 1452 //US curDoc()->sync sets the dirtyFlag in case the sync was successfull.
1453 save(); 1453 save();
1454 } 1454 }
1455 1455
1456 return ret; 1456 return ret;
1457} 1457}
1458#endif 1458#endif
1459 1459
1460 1460
1461#ifndef PWM_EMBEDDED 1461#ifndef PWM_EMBEDDED
1462#include "pwm.moc" 1462#include "pwm.moc"
1463#endif 1463#endif
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index 6ddb6f5..71b4a8d 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -1,467 +1,467 @@
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#include <qdir.h>
39#include "pwmprefs.h" 39#include "pwmprefs.h"
40#endif 40#endif
41 41
42 42
43#ifdef CONFIG_KEYCARD 43#ifdef CONFIG_KEYCARD
44# include "pwmkeycard.h" 44# include "pwmkeycard.h"
45#endif 45#endif
46 46
47 47
48PwMDocUi::PwMDocUi(QObject *parent, const char *name) 48PwMDocUi::PwMDocUi(QObject *parent, const char *name)
49 : QObject(parent, name) 49 : QObject(parent, name)
50{ 50{
51 currentView = 0; 51 currentView = 0;
52 keyCard = 0; 52 keyCard = 0;
53} 53}
54 54
55PwMDocUi::~PwMDocUi() 55PwMDocUi::~PwMDocUi()
56{ 56{
57} 57}
58 58
59QString PwMDocUi::requestMpw(bool chipcard) 59QString PwMDocUi::requestMpw(bool chipcard)
60{ 60{
61 QString pw; 61 QString pw;
62 62
63 if (chipcard) { 63 if (chipcard) {
64#ifdef CONFIG_KEYCARD 64#ifdef CONFIG_KEYCARD
65 PWM_ASSERT(keyCard); 65 PWM_ASSERT(keyCard);
66 uint32_t id; 66 uint32_t id;
67 string ret; 67 string ret;
68 SpinForSignal *spinner = keyCard->getSpinner(); 68 SpinForSignal *spinner = keyCard->getSpinner();
69 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 69 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
70 spinner, SLOT(u32_str_slot(uint32_t, const string &))); 70 spinner, SLOT(u32_str_slot(uint32_t, const string &)));
71 keyCard->getKey(); 71 keyCard->getKey();
72 spinner->spin(&id, &ret); 72 spinner->spin(&id, &ret);
73 disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 73 disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
74 spinner, SLOT(u32_str_slot(uint32_t, const string &))); 74 spinner, SLOT(u32_str_slot(uint32_t, const string &)));
75 if (ret == "") 75 if (ret == "")
76 return ""; 76 return "";
77 pw = ret.c_str(); 77 pw = ret.c_str();
78#else // CONFIG_KEYCARD 78#else // CONFIG_KEYCARD
79 no_keycard_support_msg_box(currentView); 79 no_keycard_support_msg_box(currentView);
80#endif // CONFIG_KEYCARD 80#endif // CONFIG_KEYCARD
81 } else { 81 } else {
82#ifndef PWM_EMBEDDED 82#ifndef PWM_EMBEDDED
83 GetMasterPwWndImpl pwWnd; 83 GetMasterPwWndImpl pwWnd;
84 KWin::setState(pwWnd.winId(), NET::StaysOnTop); 84 KWin::setState(pwWnd.winId(), NET::StaysOnTop);
85#else 85#else
86 GetMasterPwWndImpl pwWnd; 86 GetMasterPwWndImpl pwWnd;
87#endif 87#endif
88 if (pwWnd.exec() != 1) 88 if (pwWnd.exec() != 1)
89 return ""; 89 return "";
90 pw = pwWnd.pwLineEdit->text(); 90 pw = pwWnd.pwLineEdit->text();
91 } 91 }
92 92
93 return pw; 93 return pw;
94} 94}
95 95
96QString PwMDocUi::requestNewMpw(bool *chipcard) 96QString PwMDocUi::requestNewMpw(bool *chipcard)
97{ 97{
98 QString pw; 98 QString pw;
99 SetMasterPwWndImpl pwWnd(currentView); 99 SetMasterPwWndImpl pwWnd(currentView);
100 pwWnd.setPwMKeyCard(keyCard); 100 pwWnd.setPwMKeyCard(keyCard);
101 if (!chipcard) { 101 if (!chipcard) {
102#ifndef PWM_EMBEDDED 102#ifndef PWM_EMBEDDED
103 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1)); 103 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1));
104#else 104#else
105 pwWnd.mainTab->removePage(pwWnd.tab_2); 105 pwWnd.mainTab->removePage(pwWnd.tab_2);
106#endif 106#endif
107 } 107 }
108 108
109 if (pwWnd.exec() != 1) 109 if (pwWnd.exec() != 1)
110 return ""; 110 return "";
111 pw = pwWnd.getPw(chipcard).c_str(); 111 pw = pwWnd.getPw(chipcard).c_str();
112 112
113 return pw; 113 return pw;
114} 114}
115 115
116QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard) 116QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard)
117{ 117{
118 QString pw(requestMpw(*chipcard)); 118 QString pw(requestMpw(*chipcard));
119 if (pw == "") 119 if (pw == "")
120 return ""; 120 return "";
121 if (pw != *currentPw) { 121 if (pw != *currentPw) {
122 wrongMpwMsgBox(*chipcard); 122 wrongMpwMsgBox(*chipcard);
123 return ""; 123 return "";
124 } 124 }
125 125
126 pw = requestNewMpw(chipcard); 126 pw = requestNewMpw(chipcard);
127 if (pw == "") 127 if (pw == "")
128 return ""; 128 return "";
129 return pw; 129 return pw;
130} 130}
131 131
132void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix) 132void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix)
133{ 133{
134 QString msg; 134 QString msg;
135 if (prefix != "") { 135 if (prefix != "") {
136 msg += prefix; 136 msg += prefix;
137 msg += "\n"; 137 msg += "\n";
138 } 138 }
139 139
140 if (chipcard) { 140 if (chipcard) {
141 msg += i18n("Wrong key-card!\n" 141 msg += i18n("Wrong key-card!\n"
142 "Please try again with the\n" 142 "Please try again with the\n"
143 "correct key-card."); 143 "correct key-card.");
144 } else { 144 } else {
145 msg += i18n("Wrong master-password!\n" 145 msg += i18n("Wrong master-password!\n"
146 "Please try again."); 146 "Please try again.");
147 } 147 }
148 148
149 if (postfix != "") { 149 if (postfix != "") {
150 msg += "\n"; 150 msg += "\n";
151 msg += postfix; 151 msg += postfix;
152 } 152 }
153 KMessageBox::error(currentView, msg, 153 KMessageBox::error(currentView, msg,
154 (chipcard) ? (i18n("wrong chipcard")) 154 (chipcard) ? (i18n("wrong chipcard"))
155 : (i18n("password error"))); 155 : (i18n("password error")));
156} 156}
157 157
158void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix) 158void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix)
159{ 159{
160 QString msg; 160 QString msg;
161 if (prefix != "") { 161 if (prefix != "") {
162 msg += prefix; 162 msg += prefix;
163 msg += "\n"; 163 msg += "\n";
164 } 164 }
165 165
166 if (chipcard) { 166 if (chipcard) {
167 msg += i18n("No key-card found!\n" 167 msg += i18n("No key-card found!\n"
168 "Please insert the\n" 168 "Please insert the\n"
169 "correct key-card."); 169 "correct key-card.");
170 } else { 170 } else {
171 msg += i18n("No master-password given!"); 171 msg += i18n("No master-password given!");
172 } 172 }
173 173
174 if (postfix != "") { 174 if (postfix != "") {
175 msg += "\n"; 175 msg += "\n";
176 msg += postfix; 176 msg += postfix;
177 } 177 }
178 KMessageBox::error(currentView, msg, 178 KMessageBox::error(currentView, msg,
179 (chipcard) ? (i18n("no chipcard")) 179 (chipcard) ? (i18n("no chipcard"))
180 : (i18n("password error"))); 180 : (i18n("password error")));
181} 181}
182 182
183void PwMDocUi::rootAlertMsgBox() 183void PwMDocUi::rootAlertMsgBox()
184{ 184{
185 KMessageBox::error(currentView, 185 KMessageBox::error(currentView,
186 i18n("This feature is not available,n" 186 i18n("This feature is not available,n"
187 "if you execute PwM with \"root\" \n" 187 "if you execute PwM with \"root\" \n"
188 "UID 0 privileges, for security reasons!"), 188 "UID 0 privileges, for security reasons!"),
189 i18n("not allowed as root!")); 189 i18n("not allowed as root!"));
190} 190}
191 191
192void PwMDocUi::cantDeeplock_notSavedMsgBox() 192void PwMDocUi::cantDeeplock_notSavedMsgBox()
193{ 193{
194 KMessageBox::error(currentView, 194 KMessageBox::error(currentView,
195 i18n("Can't deep-lock, because the document\n" 195 i18n("Can't deep-lock, because the document\n"
196 "hasn't been saved, yet. Please save\n" 196 "hasn't been saved, yet. Please save\n"
197 "to a file and try again."), 197 "to a file and try again."),
198 i18n("not saved, yet")); 198 i18n("not saved, yet"));
199} 199}
200 200
201void PwMDocUi::gpmPwLenErrMsgBox() 201void PwMDocUi::gpmPwLenErrMsgBox()
202{ 202{
203 KMessageBox::error(currentView, 203 KMessageBox::error(currentView,
204 i18n("GPasman does not support passwords\n" 204 i18n("GPasman does not support passwords\n"
205 "shorter than 4 characters! Please try\n" 205 "shorter than 4 characters! Please try\n"
206 "again with a longer password."), 206 "again with a longer password."),
207 i18n("password too short")); 207 i18n("password too short"));
208} 208}
209 209
210int PwMDocUi::dirtyAskSave(const QString &docTitle) 210int PwMDocUi::dirtyAskSave(const QString &docTitle)
211{ 211{
212 int ret; 212 int ret;
213#ifndef PWM_EMBEDDED 213#ifndef PWM_EMBEDDED
214 ret = KMessageBox::questionYesNoCancel(currentView, 214 ret = KMessageBox::questionYesNoCancel(currentView,
215 i18n("The list \"") + 215 i18n("The list \"") +
216 docTitle + 216 docTitle +
217 i18n 217 i18n
218 ("\" has been modified.\n" 218 ("\" has been modified.\n"
219 "Do you want to save it?"), 219 "Do you want to save it?"),
220 i18n("save?")); 220 i18n("save?"));
221 if (ret == KMessageBox::Yes) { 221 if (ret == KMessageBox::Yes) {
222 return 0; 222 return 0;
223 } else if (ret == KMessageBox::No) { 223 } else if (ret == KMessageBox::No) {
224 return 1; 224 return 1;
225 } 225 }
226#else 226#else
227 ret = KMessageBox::warningYesNoCancel(currentView, 227 ret = KMessageBox::warningYesNoCancel(currentView,
228 i18n("The list \"") + 228 i18n("The list \"") +
229 docTitle + 229 docTitle +
230 i18n 230 i18n
231 ("\"\nhas been modified.\n" 231 ("\"\nhas been modified.\n"
232 "Do you want to save it?"), 232 "Do you want to save it?"),
233 i18n("save?")); 233 i18n("save?"));
234 if (ret == KMessageBox::Yes) { 234 if (ret == KMessageBox::Yes) {
235 return 0; 235 return 0;
236 } else if (ret == KMessageBox::No) { 236 } else if (ret == KMessageBox::No) {
237 return 1; 237 return 1;
238 } 238 }
239 239
240#endif 240#endif
241 241
242 // cancel 242 // cancel
243 return -1; 243 return -1;
244} 244}
245 245
246bool PwMDocUi::saveDocUi(PwMDoc *doc) 246bool PwMDocUi::saveDocUi(PwMDoc *doc)
247{ 247{
248 PWM_ASSERT(doc); 248 PWM_ASSERT(doc);
249 doc->timer()->getLock(DocTimer::id_autoLockTimer); 249 doc->timer()->getLock(DocTimer::id_autoLockTimer);
250 if (doc->isDocEmpty()) { 250 if (doc->isDocEmpty()) {
251 KMessageBox::information(currentView, 251 KMessageBox::information(currentView,
252 i18n 252 i18n
253 ("Sorry, there's nothing to save.\n" 253 ("Sorry, there's nothing to save.\n"
254 "Please first add some passwords."), 254 "Please first add some passwords."),
255 i18n("nothing to do")); 255 i18n("nothing to do"));
256 doc->timer()->putLock(DocTimer::id_autoLockTimer); 256 doc->timer()->putLock(DocTimer::id_autoLockTimer);
257 return true; 257 return true;
258 } 258 }
259 PwMerror ret = doc->saveDoc(conf()->confGlobCompression()); 259 PwMerror ret = doc->saveDoc(conf()->confGlobCompression());
260 if (ret == e_filename) { 260 if (ret == e_filename) {
261 doc->timer()->putLock(DocTimer::id_autoLockTimer); 261 doc->timer()->putLock(DocTimer::id_autoLockTimer);
262 return saveAsDocUi(doc); 262 return saveAsDocUi(doc);
263 } else if (ret == e_weakPw) { 263 } else if (ret == e_weakPw) {
264 KMessageBox::error(currentView, 264 KMessageBox::error(currentView,
265 i18n("Error: This is a weak password.\n" 265 i18n("Error: This is a weak password.\n"
266 "Please select another password."), 266 "Please select another password."),
267 i18n("weak password")); 267 i18n("weak password"));
268 doc->timer()->putLock(DocTimer::id_autoLockTimer); 268 doc->timer()->putLock(DocTimer::id_autoLockTimer);
269 return false; 269 return false;
270 } else if (ret == e_fileBackup) { 270 } else if (ret == e_fileBackup) {
271 KMessageBox::error(currentView, 271 KMessageBox::error(currentView,
272 i18n("Error: Couldn't make backup-file!"), 272 i18n("Error: Couldn't make backup-file!"),
273 i18n("backup failed")); 273 i18n("backup failed"));
274 doc->timer()->putLock(DocTimer::id_autoLockTimer); 274 doc->timer()->putLock(DocTimer::id_autoLockTimer);
275 return false; 275 return false;
276 } else if (ret == e_noPw || 276 } else if (ret == e_noPw ||
277 ret == e_wrongPw || 277 ret == e_wrongPw ||
278 ret == e_openFile) { 278 ret == e_openFile) {
279 doc->timer()->putLock(DocTimer::id_autoLockTimer); 279 doc->timer()->putLock(DocTimer::id_autoLockTimer);
280 return false; 280 return false;
281 } else if (ret != e_success) { 281 } else if (ret != e_success) {
282 KMessageBox::error(currentView, 282 KMessageBox::error(currentView,
283 i18n("Error: Couldn't write to file.\n" 283 i18n("Error: Couldn't write to file.\n"
284 "Please check if you have permission to\n" 284 "Please check if you have permission to\n"
285 "write to the file in that directory."), 285 "write to the file in that directory."),
286 i18n("error while writing")); 286 i18n("error while writing"));
287 doc->timer()->putLock(DocTimer::id_autoLockTimer); 287 doc->timer()->putLock(DocTimer::id_autoLockTimer);
288 return false; 288 return false;
289 } 289 }
290 doc->timer()->putLock(DocTimer::id_autoLockTimer); 290 doc->timer()->putLock(DocTimer::id_autoLockTimer);
291 return true; 291 return true;
292} 292}
293 293
294bool PwMDocUi::saveAsDocUi(PwMDoc *doc) 294bool PwMDocUi::saveAsDocUi(PwMDoc *doc)
295{ 295{
296 PWM_ASSERT(doc); 296 PWM_ASSERT(doc);
297 doc->timer()->getLock(DocTimer::id_autoLockTimer); 297 doc->timer()->getLock(DocTimer::id_autoLockTimer);
298 if (doc->isDocEmpty()) { 298 if (doc->isDocEmpty()) {
299 KMessageBox::information(currentView, 299 KMessageBox::information(currentView,
300 i18n 300 i18n
301 ("Sorry, there's nothing to save.\n" 301 ("Sorry, there's nothing to save.\n"
302 "Please first add some passwords."), 302 "Please first add some passwords."),
303 i18n("nothing to do")); 303 i18n("nothing to do"));
304 doc->timer()->putLock(DocTimer::id_autoLockTimer); 304 doc->timer()->putLock(DocTimer::id_autoLockTimer);
305 return true; 305 return true;
306 } 306 }
307#ifndef PWM_EMBEDDED 307#ifndef PWM_EMBEDDED
308 QString fn(KFileDialog::getSaveFileName(QString::null, 308 QString fn(KFileDialog::getSaveFileName(QString::null,
309 i18n("*.pwm|PwManager Password file"), 309 i18n("*.pwm|PwManager Password file"),
310 currentView)); 310 currentView));
311#else 311#else
312 QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" ); 312 QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" );
313 fn = KFileDialog::getSaveFileName(fn, 313 fn = KFileDialog::getSaveFileName(fn,
314 i18n("password filename(*.pwm)"), 314 i18n("password filename(*.pwm)"),
315 currentView); 315 currentView);
316 316
317#endif 317#endif
318 if (fn == "") { 318 if (fn == "") {
319 doc->timer()->putLock(DocTimer::id_autoLockTimer); 319 doc->timer()->putLock(DocTimer::id_autoLockTimer);
320 return false; 320 return false;
321 } 321 }
322 if (fn.right(4) != ".pwm") 322 if (fn.right(4) != ".pwm")
323 fn += ".pwm"; 323 fn += ".pwm";
324 324
325 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn); 325 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn);
326 if (ret == e_noPw || 326 if (ret == e_noPw ||
327 ret == e_wrongPw || 327 ret == e_wrongPw ||
328 ret == e_openFile) { 328 ret == e_openFile) {
329 doc->timer()->putLock(DocTimer::id_autoLockTimer); 329 doc->timer()->putLock(DocTimer::id_autoLockTimer);
330 return false; 330 return false;
331 } else if (ret != e_success) { 331 } else if (ret != e_success) {
332 KMessageBox::error(currentView, 332 KMessageBox::error(currentView,
333 i18n("Error: Couldn't write to file.\n" 333 i18n("Error: Couldn't write to file.\n"
334 "Please check if you have permission to\n" 334 "Please check if you have permission to\n"
335 "write to the file in that directory."), 335 "write to the file in that directory."),
336 i18n("error while writing")); 336 i18n("error while writing"));
337 doc->timer()->putLock(DocTimer::id_autoLockTimer); 337 doc->timer()->putLock(DocTimer::id_autoLockTimer);
338 return false; 338 return false;
339 } 339 }
340 doc->timer()->putLock(DocTimer::id_autoLockTimer); 340 doc->timer()->putLock(DocTimer::id_autoLockTimer);
341 return true; 341 return true;
342} 342}
343 343
344bool PwMDocUi::openDocUi(PwMDoc *doc, 344bool PwMDocUi::openDocUi(PwMDoc *doc,
345 QString filename, 345 QString filename,
346 bool openDeepLocked) 346 bool openDeepLocked)
347{ 347{
348 if (filename.isEmpty()) 348 if (filename.isEmpty())
349 { 349 {
350#ifndef PWM_EMBEDDED 350#ifndef PWM_EMBEDDED
351 filename = KFileDialog::getOpenFileName(QString::null, 351 filename = KFileDialog::getOpenFileName(QString::null,
352 i18n("*.pwm|PwManager Password file\n" 352 i18n("*.pwm|PwManager Password file\n"
353 "*|All files"), getCurrentView()); 353 "*|All files"), getCurrentView());
354#else 354#else
355 filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm"); 355 filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm");
356 filename = KFileDialog::getOpenFileName(filename, 356 filename = KFileDialog::getOpenFileName(filename,
357 i18n("password filename(*.pwm)"), getCurrentView()); 357 i18n("password filename(*.pwm)"), getCurrentView());
358#endif 358#endif
359 } 359 }
360 if (filename.isEmpty()) 360 if (filename.isEmpty())
361 goto cancelOpen; 361 goto cancelOpen;
362 PwMerror ret; 362 PwMerror ret;
363 while (true) { 363 while (true) {
364 int lockStat = -1; 364 int lockStat = -1;
365 if (openDeepLocked) { 365 if (openDeepLocked) {
366 lockStat = 2; 366 lockStat = 2;
367 } else { 367 } else {
368 if (conf()->confGlobUnlockOnOpen()) { 368 if (conf()->confGlobUnlockOnOpen()) {
369 lockStat = 0; 369 lockStat = 0;
370 } else { 370 } else {
371 lockStat = 1; 371 lockStat = 1;
372 } 372 }
373 } 373 }
374 ret = doc->openDoc(&filename, lockStat); 374 ret = doc->openDoc(&filename, lockStat);
375 //qDebug("pwmdocui::OpenDocui %i", ret); 375 //qDebug("pwmdocui::OpenDocui %i", ret);
376 if (ret != e_success) { 376 if (ret != e_success) {
377 if (ret == e_readFile || ret == e_openFile) { 377 if (ret == e_readFile || ret == e_openFile) {
378 KMessageBox::error(getCurrentView(), 378 KMessageBox::error(getCurrentView(),
379 i18n("Could not read file!") 379 i18n("Could not read file!")
380 + "\n" 380 + "\n"
381 + filename, 381 + filename,
382 i18n("file error")); 382 i18n("File error"));
383 goto cancelOpen; 383 goto cancelOpen;
384 } 384 }
385 if (ret == e_alreadyOpen) { 385 if (ret == e_alreadyOpen) {
386 KMessageBox::error(getCurrentView(), 386 KMessageBox::error(getCurrentView(),
387 i18n("This file is already open."), 387 i18n("This file is already open."),
388 i18n("already open")); 388 i18n("Already open"));
389 goto cancelOpen; 389 goto cancelOpen;
390 } 390 }
391 if (ret == e_fileVer) { 391 if (ret == e_fileVer) {
392 KMessageBox::error(getCurrentView(), 392 KMessageBox::error(getCurrentView(),
393 i18n 393 i18n
394 ("File-version is not supported!\n" 394 ("File-version is not supported!\n"
395 "Did you create this file with an\nolder or newer version of PwM?"), 395 "Did you create this file with an\nolder or newer version of PwM?"),
396 i18n 396 i18n
397 ("incompatible version")); 397 ("Incompatible version"));
398 goto cancelOpen; 398 goto cancelOpen;
399 } 399 }
400 if (ret == e_wrongPw) { 400 if (ret == e_wrongPw) {
401 continue; 401 continue;
402 } 402 }
403 if (ret == e_noPw) { 403 if (ret == e_noPw) {
404 goto cancelOpen; 404 goto cancelOpen;
405 } 405 }
406 if (ret == e_fileFormat) { 406 if (ret == e_fileFormat) {
407 KMessageBox::error(getCurrentView(), 407 KMessageBox::error(getCurrentView(),
408 i18n 408 i18n
409 ("Sorry, this file has not been recognized\n" 409 ("Sorry, this file has not been recognized\n"
410 "as a PwM Password file.\n" 410 "as a PwM Password file.\n"
411 "Probably you have selected the wrong file."), 411 "Probably you have selected the wrong file."),
412 i18n 412 i18n
413 ("no PwM password-file")); 413 ("No PwM password-file"));
414 goto cancelOpen; 414 goto cancelOpen;
415 } 415 }
416 if (ret == e_fileCorrupt) { 416 if (ret == e_fileCorrupt) {
417 KMessageBox::error(getCurrentView(), 417 KMessageBox::error(getCurrentView(),
418 i18n 418 i18n
419 ("File corrupt!\n" 419 ("File corrupt!\n"
420 "Maybe the media, you stored this file on,\n" 420 "Maybe the media, you stored this file on,\n"
421 "had bad sectors?"), 421 "had bad sectors?"),
422 i18n 422 i18n
423 ("checksum error")); 423 ("Checksum error"));
424 goto cancelOpen; 424 goto cancelOpen;
425 } 425 }
426 } 426 }
427 break; 427 break;
428 } 428 }
429 return true; 429 return true;
430 430
431 cancelOpen: 431 cancelOpen:
432 return false; 432 return false;
433} 433}
434 434
435QString PwMDocUi::string_defaultCategory() 435QString PwMDocUi::string_defaultCategory()
436{ 436{
437 return i18n("Default"); 437 return i18n("Default");
438} 438}
439 439
440QString PwMDocUi::string_locked() 440QString PwMDocUi::string_locked()
441{ 441{
442 return i18n("<LOCKED>"); 442 return i18n("<LOCKED>");
443} 443}
444 444
445QString PwMDocUi::string_deepLockedShort() 445QString PwMDocUi::string_deepLockedShort()
446{ 446{
447 return i18n("DEEP-LOCKED"); 447 return i18n("DEEP-LOCKED");
448} 448}
449 449
450QString PwMDocUi::string_deepLockedLong() 450QString PwMDocUi::string_deepLockedLong()
451{ 451{
452 return i18n("This file is DEEP-LOCKED!\n" 452 return i18n("This file is DEEP-LOCKED!\n"
453 "That means all data has been encrypted\n" 453 "That means all data has been encrypted\n"
454 "and written out to the file. If you want\n" 454 "and written out to the file. If you want\n"
455 "to see the entries, please UNLOCK the file.\n" 455 "to see the entries, please UNLOCK the file.\n"
456 "While unlocking, you will be prompted for the\n" 456 "While unlocking, you will be prompted for the\n"
457 "master-password or the key-card."); 457 "master-password or the key-card.");
458} 458}
459 459
460QString PwMDocUi::string_defaultTitle() 460QString PwMDocUi::string_defaultTitle()
461{ 461{
462 return i18n("Untitled"); 462 return i18n("Untitled");
463} 463}
464 464
465#ifndef PWM_EMBEDDED 465#ifndef PWM_EMBEDDED
466#include "pwmdocui.moc" 466#include "pwmdocui.moc"
467#endif 467#endif
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index ed0f754..5753c1d 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -1,784 +1,792 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.1 of pwmanager 15 * This file is originaly based on version 1.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#include "serializer.h" 21#include "serializer.h"
22#include "pwmexception.h" 22#include "pwmexception.h"
23 23
24#ifdef PWM_EMBEDDED 24#ifdef PWM_EMBEDDED
25#include <kglobal.h> 25#include <kglobal.h>
26#include <klocale.h> 26#include <klocale.h>
27#endif 27#endif
28 28
29/* enable/disable serializer debugging (0/1) */ 29/* enable/disable serializer debugging (0/1) */
30 #define SERIALIZER_DEBUG0 30 #define SERIALIZER_DEBUG0
31/* use the old xml tags for writing (0/1) */ 31/* use the old xml tags for writing (0/1) */
32 #define USE_OLD_TAGS 0 32 #define USE_OLD_TAGS 0
33/* write a CDATA section (0/1) */ 33/* write a CDATA section (0/1) */
34 #define WRITE_CDATA_SEC 0 34 #define WRITE_CDATA_SEC 0
35 35
36 36
37 #define META_CREATE_DATE"c" 37 #define META_CREATE_DATE"c"
38 #define META_VALID_DATE "v" 38 #define META_VALID_DATE "v"
39 #define META_EXPIRE_DATE"e" 39 #define META_EXPIRE_DATE"e"
40 #define META_UPDATE_DATE"u" 40 #define META_UPDATE_DATE"u"
41 #define META_UPDATE_INT "i" 41 #define META_UPDATE_INT "i"
42//US ENH : uniqueid 42//US ENH : uniqueid
43#define META_UNIQUEID "n" 43#define META_UNIQUEID "n"
44#define SYNC_ROOT "s" 44#define SYNC_ROOT "s"
45#define SYNC_TARGET_PREFIX "t" 45#define SYNC_TARGET_PREFIX "t"
46#define SYNC_TARGET_NAME "n" 46#define SYNC_TARGET_NAME "n"
47 47
48 48
49/* This is compatibility stuff. 49/* This is compatibility stuff.
50 * The names of the entries have changed and here are the 50 * The names of the entries have changed and here are the
51 * new and old ones 51 * new and old ones
52 */ 52 */
53 #define ROOT_MAGIC_OLD "PwM-xml-dat" 53 #define ROOT_MAGIC_OLD "PwM-xml-dat"
54 #define VER_STR_OLD "ver" 54 #define VER_STR_OLD "ver"
55 #define COMPAT_VER_OLD "0x02" 55 #define COMPAT_VER_OLD "0x02"
56 #define CAT_ROOT_OLD "categories" 56 #define CAT_ROOT_OLD "categories"
57 #define CAT_PREFIX_OLD "cat_" 57 #define CAT_PREFIX_OLD "cat_"
58 #define CAT_NAME_OLD "name" 58 #define CAT_NAME_OLD "name"
59 #define ENTRY_PREFIX_OLD"entry_" 59 #define ENTRY_PREFIX_OLD"entry_"
60 #define ENTRY_DESC_OLD "desc" 60 #define ENTRY_DESC_OLD "desc"
61 #define ENTRY_NAME_OLD "name" 61 #define ENTRY_NAME_OLD "name"
62 #define ENTRY_PW_OLD "pw" 62 #define ENTRY_PW_OLD "pw"
63 #define ENTRY_COMMENT_OLD"comment" 63 #define ENTRY_COMMENT_OLD"comment"
64 #define ENTRY_URL_OLD "url" 64 #define ENTRY_URL_OLD "url"
65 #define ENTRY_LAUNCHER_OLD"launcher" 65 #define ENTRY_LAUNCHER_OLD"launcher"
66 #define ENTRY_LVP_OLD "listViewPos" 66 #define ENTRY_LVP_OLD "listViewPos"
67 #define ENTRY_BIN_OLD "b" 67 #define ENTRY_BIN_OLD "b"
68 #define ENTRY_META_OLD "m" 68 #define ENTRY_META_OLD "m"
69 69
70 #define ROOT_MAGIC_NEW "P" 70 #define ROOT_MAGIC_NEW "P"
71 #define VER_STR_NEW "v" 71 #define VER_STR_NEW "v"
72 #define COMPAT_VER_NEW "2" 72 #define COMPAT_VER_NEW "2"
73 #define CAT_ROOT_NEW "c" 73 #define CAT_ROOT_NEW "c"
74 #define CAT_PREFIX_NEW "c" 74 #define CAT_PREFIX_NEW "c"
75 #define CAT_NAME_NEW "n" 75 #define CAT_NAME_NEW "n"
76 #define ENTRY_PREFIX_NEW"e" 76 #define ENTRY_PREFIX_NEW"e"
77 #define ENTRY_DESC_NEW "d" 77 #define ENTRY_DESC_NEW "d"
78 #define ENTRY_NAME_NEW "n" 78 #define ENTRY_NAME_NEW "n"
79 #define ENTRY_PW_NEW "p" 79 #define ENTRY_PW_NEW "p"
80 #define ENTRY_COMMENT_NEW"c" 80 #define ENTRY_COMMENT_NEW"c"
81 #define ENTRY_URL_NEW "u" 81 #define ENTRY_URL_NEW "u"
82 #define ENTRY_LAUNCHER_NEW"l" 82 #define ENTRY_LAUNCHER_NEW"l"
83 #define ENTRY_LVP_NEW "v" 83 #define ENTRY_LVP_NEW "v"
84 #define ENTRY_BIN_NEW ENTRY_BIN_OLD 84 #define ENTRY_BIN_NEW ENTRY_BIN_OLD
85 #define ENTRY_META_NEW ENTRY_META_OLD 85 #define ENTRY_META_NEW ENTRY_META_OLD
86 86
87#if USE_OLD_TAGS != 0 87#if USE_OLD_TAGS != 0
88 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD 88 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD
89 # define VER_STR_WR VER_STR_OLD 89 # define VER_STR_WR VER_STR_OLD
90 # define COMPAT_VER_WR COMPAT_VER_OLD 90 # define COMPAT_VER_WR COMPAT_VER_OLD
91 # define CAT_ROOT_WR CAT_ROOT_OLD 91 # define CAT_ROOT_WR CAT_ROOT_OLD
92 # define CAT_PREFIX_WR CAT_PREFIX_OLD 92 # define CAT_PREFIX_WR CAT_PREFIX_OLD
93 # define CAT_NAME_WR CAT_NAME_OLD 93 # define CAT_NAME_WR CAT_NAME_OLD
94 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD 94 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD
95 # define ENTRY_DESC_WR ENTRY_DESC_OLD 95 # define ENTRY_DESC_WR ENTRY_DESC_OLD
96 # define ENTRY_NAME_WR ENTRY_NAME_OLD 96 # define ENTRY_NAME_WR ENTRY_NAME_OLD
97 # define ENTRY_PW_WR ENTRY_PW_OLD 97 # define ENTRY_PW_WR ENTRY_PW_OLD
98 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD 98 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD
99 # define ENTRY_URL_WR ENTRY_URL_OLD 99 # define ENTRY_URL_WR ENTRY_URL_OLD
100 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD 100 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD
101 # define ENTRY_LVP_WR ENTRY_LVP_OLD 101 # define ENTRY_LVP_WR ENTRY_LVP_OLD
102 # define ENTRY_BIN_WR ENTRY_BIN_OLD 102 # define ENTRY_BIN_WR ENTRY_BIN_OLD
103 # define ENTRY_META_WR ENTRY_META_OLD 103 # define ENTRY_META_WR ENTRY_META_OLD
104#else 104#else
105 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW 105 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW
106 # define VER_STR_WR VER_STR_NEW 106 # define VER_STR_WR VER_STR_NEW
107 # define COMPAT_VER_WR COMPAT_VER_NEW 107 # define COMPAT_VER_WR COMPAT_VER_NEW
108 # define CAT_ROOT_WR CAT_ROOT_NEW 108 # define CAT_ROOT_WR CAT_ROOT_NEW
109 # define CAT_PREFIX_WR CAT_PREFIX_NEW 109 # define CAT_PREFIX_WR CAT_PREFIX_NEW
110 # define CAT_NAME_WR CAT_NAME_NEW 110 # define CAT_NAME_WR CAT_NAME_NEW
111 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW 111 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW
112 # define ENTRY_DESC_WR ENTRY_DESC_NEW 112 # define ENTRY_DESC_WR ENTRY_DESC_NEW
113 # define ENTRY_NAME_WR ENTRY_NAME_NEW 113 # define ENTRY_NAME_WR ENTRY_NAME_NEW
114 # define ENTRY_PW_WR ENTRY_PW_NEW 114 # define ENTRY_PW_WR ENTRY_PW_NEW
115 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW 115 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW
116 # define ENTRY_URL_WR ENTRY_URL_NEW 116 # define ENTRY_URL_WR ENTRY_URL_NEW
117 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW 117 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW
118 # define ENTRY_LVP_WR ENTRY_LVP_NEW 118 # define ENTRY_LVP_WR ENTRY_LVP_NEW
119 # define ENTRY_BIN_WR ENTRY_BIN_NEW 119 # define ENTRY_BIN_WR ENTRY_BIN_NEW
120 # define ENTRY_META_WR ENTRY_META_NEW 120 # define ENTRY_META_WR ENTRY_META_NEW
121#endif 121#endif
122 122
123 123
124Serializer::Serializer() 124Serializer::Serializer()
125{ 125{
126 defaultLockStat = true; 126 defaultLockStat = true;
127//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing 127//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
128#ifndef PWM_EMBEDDED 128#ifndef PWM_EMBEDDED
129 domDoc = new QDomDocument; 129 domDoc = new QDomDocument;
130#else 130#else
131 domDoc = new QDomDocument("mydoc"); 131 domDoc = new QDomDocument("mydoc");
132#endif 132#endif
133} 133}
134 134
135Serializer::Serializer(const QCString &buffer) 135Serializer::Serializer(const QCString &buffer)
136{ 136{
137 defaultLockStat = true; 137 defaultLockStat = true;
138//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing 138//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
139#ifndef PWM_EMBEDDED 139#ifndef PWM_EMBEDDED
140 domDoc = new QDomDocument; 140 domDoc = new QDomDocument;
141#else 141#else
142 domDoc = new QDomDocument("mydoc"); 142 domDoc = new QDomDocument("mydoc");
143#endif 143#endif
144 144
145 if (!parseXml(buffer)) { 145 if (!parseXml(buffer)) {
146 delete domDoc; 146 delete domDoc;
147#ifndef PWM_EMBEDDED 147#ifndef PWM_EMBEDDED
148 throw PwMException(PwMException::EX_PARSE); 148 throw PwMException(PwMException::EX_PARSE);
149#else 149#else
150 qDebug("Serializer::Serializer : Parse Exception "); 150 qDebug("Serializer::Serializer : Parse Exception ");
151#endif 151#endif
152 } 152 }
153} 153}
154 154
155Serializer::~Serializer() 155Serializer::~Serializer()
156{ 156{
157 delete_ifnot_null(domDoc); 157 delete_ifnot_null(domDoc);
158} 158}
159 159
160void Serializer::clear() 160void Serializer::clear()
161{ 161{
162 delete_ifnot_null(domDoc); 162 delete_ifnot_null(domDoc);
163 domDoc = new QDomDocument; 163 domDoc = new QDomDocument;
164} 164}
165 165
166bool Serializer::parseXml(const QCString &buffer) 166bool Serializer::parseXml(const QCString &buffer)
167{ 167{
168 //abort();
169 //qDebug("parse %s ", buffer.data());
168 PWM_ASSERT(domDoc); 170 PWM_ASSERT(domDoc);
169#ifndef PWM_EMBEDDED 171#ifndef PWM_EMBEDDED
170 if (!domDoc->setContent(buffer, true)) 172 if (!domDoc->setContent(buffer, true))
171 return false; 173 return false;
172#else 174#else
173#ifdef DESKTOP_VERSION 175#ifdef DESKTOP_VERSION
174 if (!domDoc->setContent(buffer, true)) 176 if (!domDoc->setContent(buffer, true))
175#else 177#else
176 if (!domDoc->setContent(buffer)) 178 if (!domDoc->setContent(buffer))
177#endif 179#endif
178 return false; 180 return false;
179#endif 181#endif
180 if (!checkValid()) 182 if (!checkValid())
181 return false; 183 return false;
182 return true; 184 return true;
183} 185}
184 186
185QCString Serializer::getXml() 187QCString Serializer::getXml()
186{ 188{
187 PWM_ASSERT(domDoc); 189 PWM_ASSERT(domDoc);
188 190
189#ifndef PWM_EMBEDDED 191#ifndef PWM_EMBEDDED
190#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 192#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
191 QCString tmp(domDoc->toCString(8)); 193 QCString tmp(domDoc->toCString(8));
192 printDebug("<BEGIN Serializer::getXml() dump>\n"); 194 printDebug("<BEGIN Serializer::getXml() dump>\n");
193 cout << tmp << endl; 195 cout << tmp << endl;
194 printDebug("<END Serializer::getXml() dump>"); 196 printDebug("<END Serializer::getXml() dump>");
195#endif // DEBUG 197#endif // DEBUG
196 198
197 QCString ret(domDoc->toCString(0)); 199 QCString ret(domDoc->toCString(0));
198 ret.replace('\n', ""); 200 ret.replace('\n', "");
199 return ret; 201 return ret;
200#else 202#else
201 203
202#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 204#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
203 QCString tmp(" " + domDoc->toCString()); 205 QCString tmp(" " + domDoc->toCString());
204 printDebug("<BEGIN Serializer::getXml() dump>\n"); 206 printDebug("<BEGIN Serializer::getXml() dump>\n");
205 qDebug(tmp); 207 qDebug(tmp);
206 cout << tmp << endl; 208 cout << tmp << endl;
207 printDebug("<END Serializer::getXml() dump>"); 209 printDebug("<END Serializer::getXml() dump>");
208#endif // DEBUG 210#endif // DEBUG
209 211
210 QCString ret(domDoc->toCString()); 212 QCString ret(domDoc->toCString());
211 ret.replace(QRegExp("\n"), ""); 213 ret.replace(QRegExp("\n"), "");
212 return ret; 214 return ret;
213 215
214#endif 216#endif
215} 217}
216 218
217bool Serializer::serialize(PwMItem &dta) 219bool Serializer::serialize(PwMItem &dta)
218{ 220{
219 PWM_ASSERT(domDoc); 221 PWM_ASSERT(domDoc);
220 QDomElement root(genNewRoot()); 222 QDomElement root(genNewRoot());
221 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); 223 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR));
222 QDomElement syncNode(domDoc->createElement(SYNC_ROOT)); 224 QDomElement syncNode(domDoc->createElement(SYNC_ROOT));
223 if (!addSyncData(&syncNode, dta.syncDta)) 225 if (!addSyncData(&syncNode, dta.syncDta))
224 return false; 226 return false;
225 root.appendChild(syncNode); 227 root.appendChild(syncNode);
226 if (!addCategories(&catNode, dta.dta)) 228 if (!addCategories(&catNode, dta.dta))
227 return false; 229 return false;
228 root.appendChild(catNode); 230 root.appendChild(catNode);
229 return true; 231 return true;
230} 232}
231 233
232bool Serializer::deSerialize(PwMItem *dta) 234bool Serializer::deSerialize(PwMItem *dta)
233{ 235{
234 PWM_ASSERT(domDoc); 236 PWM_ASSERT(domDoc);
235 PWM_ASSERT(dta); 237 PWM_ASSERT(dta);
236 QDomElement root(domDoc->documentElement()); 238 QDomElement root(domDoc->documentElement());
237 QDomNode n; 239 QDomNode n;
238 240
239 dta->clear(); 241 dta->clear();
240 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { 242 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) {
241 // find <categories> ... </categories> 243 // find <categories> ... </categories>
242 // <c> ... </c> 244 // <c> ... </c>
243 if (n.nodeName() == CAT_ROOT_NEW || 245 if (n.nodeName() == CAT_ROOT_NEW ||
244 n.nodeName() == CAT_ROOT_OLD) { 246 n.nodeName() == CAT_ROOT_OLD) {
245 if (!readCategories(n, &(dta->dta))) { 247 if (!readCategories(n, &(dta->dta))) {
246 return false; 248 return false;
247 } 249 }
248 continue; 250 continue;
249 } 251 }
250 else if (n.nodeName() == SYNC_ROOT) { 252 else if (n.nodeName() == SYNC_ROOT) {
251 if (!readSyncData(n, &(dta->syncDta))) { 253 if (!readSyncData(n, &(dta->syncDta))) {
252 return false; 254 return false;
253 } 255 }
254 continue; 256 continue;
255 } 257 }
256 258
257 /* NOTE: We can stop processing here, as we 259 /* NOTE: We can stop processing here, as we
258 * don't have more nodes in root, yet. 260 * don't have more nodes in root, yet.
259 */ 261 */
260 return false; 262 return false;
261 263
262 } 264 }
263 return true; 265 return true;
264} 266}
265 267
266bool Serializer::readCategories(const QDomNode &n, 268bool Serializer::readCategories(const QDomNode &n,
267 vector<PwMCategoryItem> *dta) 269 vector<PwMCategoryItem> *dta)
268{ 270{
269 QDomNodeList nl(n.childNodes()); 271 QDomNodeList nl(n.childNodes());
270 QDomNode cur; 272 QDomNode cur;
271 QString name; 273 QString name;
272 unsigned int numCat = nl.count(), i; 274 unsigned int numCat = nl.count(), i;
273 PwMCategoryItem curCat; 275 PwMCategoryItem curCat;
274 vector<PwMDataItem> curEntr; 276 vector<PwMDataItem> curEntr;
275 277
276 if (!numCat) { 278 if (!numCat) {
277 printDebug("Serializer::readCategories(): empty"); 279 printDebug("Serializer::readCategories(): empty");
278 return false; 280 return false;
279 } 281 }
280 for (i = 0; i < numCat; ++i) { 282 for (i = 0; i < numCat; ++i) {
281 cur = nl.item(i); 283 cur = nl.item(i);
282 if (cur.nodeName().left(1) == CAT_PREFIX_NEW || 284 if (cur.nodeName().left(1) == CAT_PREFIX_NEW ||
283 cur.nodeName().left(4) == CAT_PREFIX_OLD) { 285 cur.nodeName().left(4) == CAT_PREFIX_OLD) {
284 name = cur.toElement().attribute(CAT_NAME_NEW); 286 name = cur.toElement().attribute(CAT_NAME_NEW);
285 if (name == QString::null) 287 if (name == QString::null)
286 name = cur.toElement().attribute(CAT_NAME_OLD); 288 name = cur.toElement().attribute(CAT_NAME_OLD);
287 PWM_ASSERT(name != QString::null); 289 PWM_ASSERT(name != QString::null);
288 PWM_ASSERT(name != ""); 290 PWM_ASSERT(name != "");
289 curCat.clear(); 291 curCat.clear();
290 curCat.name = name.latin1(); 292 curCat.name = name.latin1();
291 if (!readEntries(cur, &curEntr)) { 293 if (!readEntries(cur, &curEntr)) {
292 dta->clear(); 294 dta->clear();
293 return false; 295 return false;
294 } 296 }
295 curCat.d = curEntr; 297 curCat.d = curEntr;
296 dta->push_back(curCat); 298 dta->push_back(curCat);
297 } else { 299 } else {
298 printDebug("Serializer::readCategories(): uh? not a category?"); 300 printDebug("Serializer::readCategories(): uh? not a category?");
299 } 301 }
300 } 302 }
301 return true; 303 return true;
302} 304}
303 305
304bool Serializer::readEntries(const QDomNode &n, 306bool Serializer::readEntries(const QDomNode &n,
305 vector<PwMDataItem> *dta) 307 vector<PwMDataItem> *dta)
306{ 308{
307 QDomNodeList nl(n.childNodes()); 309 QDomNodeList nl(n.childNodes());
308 QDomNode cur; 310 QDomNode cur;
309 unsigned int numEntr = nl.count(), i; 311 unsigned int numEntr = nl.count(), i;
310 PwMDataItem curEntr; 312 PwMDataItem curEntr;
311 //US BUG: to initialize all values of curEntr with meaningfulldata, 313 //US BUG: to initialize all values of curEntr with meaningfulldata,
312 // we call clear on it. Reason: Information in the file we will read might be incomplete. 314 // we call clear on it. Reason: Information in the file we will read might be incomplete.
313 // e.g. the metadata is missing. 315 // e.g. the metadata is missing.
314 curEntr.clear(true); 316 curEntr.clear(true);
315 317
316 dta->clear(); 318 dta->clear();
317 for (i = 0; i < numEntr; ++i) { 319 for (i = 0; i < numEntr; ++i) {
318 cur = nl.item(i); 320 cur = nl.item(i);
319 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW || 321 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW ||
320 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) { 322 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) {
321 if (!extractEntry(cur, &curEntr)) { 323 if (!extractEntry(cur, &curEntr)) {
322 return false; 324 return false;
323 } 325 }
324 dta->push_back(curEntr); 326 dta->push_back(curEntr);
325 } else { 327 } else {
326 printDebug("Serializer::readEntries(): hm? not an entry?"); 328 printDebug("Serializer::readEntries(): hm? not an entry?");
327 } 329 }
328 } 330 }
329 return true; 331 return true;
330} 332}
331 333
332bool Serializer::extractEntry(const QDomNode &n, 334bool Serializer::extractEntry(const QDomNode &n,
333 PwMDataItem *dta) 335 PwMDataItem *dta)
334{ 336{
335 QDomNodeList nl(n.childNodes()); 337 QDomNodeList nl(n.childNodes());
336 QDomNode cur, cdata; 338 QDomNode cur, cdata;
337 unsigned int cnt = nl.count(), i; 339 unsigned int cnt = nl.count(), i;
338 QString name, text; 340 QString name, text;
339 341
340 if (!cnt) { 342 if (!cnt) {
341 printDebug("Serializer::extractEntry(): empty"); 343 printDebug("Serializer::extractEntry(): empty");
342 return false; 344 return false;
343 } 345 }
344 dta->clear(); 346 dta->clear();
345 for (i = 0; i < cnt; ++i) { 347 for (i = 0; i < cnt; ++i) {
346 cur = nl.item(i); 348 cur = nl.item(i);
347 name = cur.nodeName(); 349 name = cur.nodeName();
348 cdata = cur.firstChild(); 350 cdata = cur.firstChild();
349 if (unlikely(cdata.isCDATASection())) { 351 if (unlikely(cdata.isCDATASection())) {
350 text = cdata.toCDATASection().data(); 352 text = cdata.toCDATASection().data();
351 } else if (likely(cur.isElement())) { 353 } else if (likely(cur.isElement())) {
352 text = cur.toElement().text(); 354 text = cur.toElement().text();
353 } else { 355 } else {
354 printDebug("Serializer::extractEntry(): neither CDATA nor element."); 356 printDebug("Serializer::extractEntry(): neither CDATA nor element.");
355 return false; 357 return false;
356 } 358 }
357 if (text == " ") 359 if (text == " ")
358 text = ""; // for backward compatibility. 360 text = ""; // for backward compatibility.
361 //qDebug("entry %s ",unescapeEntryData(text).latin1());
359 if (name == ENTRY_DESC_NEW || 362 if (name == ENTRY_DESC_NEW ||
360 name == ENTRY_DESC_OLD) { 363 name == ENTRY_DESC_OLD) {
361 dta->desc = unescapeEntryData(text).latin1(); 364 dta->desc = unescapeEntryData(text).latin1();
362 } else if (name == ENTRY_NAME_NEW || 365 } else if (name == ENTRY_NAME_NEW ||
363 name == ENTRY_NAME_OLD) { 366 name == ENTRY_NAME_OLD) {
364 dta->name = unescapeEntryData(text).latin1(); 367 dta->name = unescapeEntryData(text).latin1();
365 } else if (name == ENTRY_PW_NEW || 368 } else if (name == ENTRY_PW_NEW ||
366 name == ENTRY_PW_OLD) { 369 name == ENTRY_PW_OLD) {
367 dta->pw = unescapeEntryData(text).latin1(); 370 dta->pw = unescapeEntryData(text).latin1();
368 } else if (name == ENTRY_COMMENT_NEW || 371 } else if (name == ENTRY_COMMENT_NEW ||
369 name == ENTRY_COMMENT_OLD) { 372 name == ENTRY_COMMENT_OLD) {
370 dta->comment = unescapeEntryData(text).latin1(); 373 dta->comment = unescapeEntryData(text).latin1();
371 } else if (name == ENTRY_URL_NEW || 374 } else if (name == ENTRY_URL_NEW ||
372 name == ENTRY_URL_OLD) { 375 name == ENTRY_URL_OLD) {
373 dta->url = unescapeEntryData(text).latin1(); 376 dta->url = unescapeEntryData(text).latin1();
374 } else if (name == ENTRY_LAUNCHER_NEW || 377 } else if (name == ENTRY_LAUNCHER_NEW ||
375 name == ENTRY_LAUNCHER_OLD) { 378 name == ENTRY_LAUNCHER_OLD) {
376 dta->launcher = unescapeEntryData(text).latin1(); 379 dta->launcher = unescapeEntryData(text).latin1();
377 } else if (name == ENTRY_LVP_NEW || 380 } else if (name == ENTRY_LVP_NEW ||
378 name == ENTRY_LVP_OLD) { 381 name == ENTRY_LVP_OLD) {
379 dta->listViewPos = strtol(text.latin1(), 0, 10); 382 dta->listViewPos = strtol(text.latin1(), 0, 10);
380 } else if (name == ENTRY_BIN_NEW) { 383 } else if (name == ENTRY_BIN_NEW) {
381 // ENTRY_BIN_NEW == ENTRY_BIN_OLD 384 // ENTRY_BIN_NEW == ENTRY_BIN_OLD
382 if (text == "0") { 385 if (text == "0") {
383 dta->binary = false; 386 dta->binary = false;
384 } else { 387 } else {
385 dta->binary = true; 388 dta->binary = true;
386 } 389 }
387 } else if (name == ENTRY_META_NEW) { 390 } else if (name == ENTRY_META_NEW) {
388 // ENTRY_META_NEW == ENTRY_META_OLD 391 // ENTRY_META_NEW == ENTRY_META_OLD
389 if (!extractMeta(cur, &dta->meta)) 392 if (!extractMeta(cur, &dta->meta))
390 return false; 393 return false;
391 } else { 394 } else {
392 printDebug(string("Serializer::extractEntry(): invalid: ") 395 printDebug(string("Serializer::extractEntry(): invalid: ")
393 + name.latin1()); 396 + name.latin1());
394 } 397 }
395 } 398 }
396 dta->lockStat = defaultLockStat; 399 dta->lockStat = defaultLockStat;
397 return true; 400 return true;
398} 401}
399 402
400bool Serializer::extractMeta(const QDomNode &n, 403bool Serializer::extractMeta(const QDomNode &n,
401 PwMMetaData *dta) 404 PwMMetaData *dta)
402{ 405{
403 QDomNode cur(n.firstChild()); 406 QDomNode cur(n.firstChild());
404 QString name, val; 407 QString name, val;
405 while (!cur.isNull()) { 408 while (!cur.isNull()) {
406 name = cur.nodeName(); 409 name = cur.nodeName();
407 val = cur.toElement().text(); 410 val = cur.toElement().text();
408 if (val == "") { 411 if (val == "") {
409 cur = cur.nextSibling(); 412 cur = cur.nextSibling();
410 continue; 413 continue;
411 } 414 }
412 415
413 //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers. 416 //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers.
414 //because of that it is possible that here some values are not set, which means they are null. 417 //because of that it is possible that here some values are not set, which means they are null.
415 //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates. 418 //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates.
416 419
417 QDateTime dtval; //dtval should be invalid by definition. 420 QDateTime dtval; //dtval should be invalid by definition.
418 421
419 if ((name == META_CREATE_DATE) || 422 if ((name == META_CREATE_DATE) ||
420 (name == META_VALID_DATE) || 423 (name == META_VALID_DATE) ||
421 (name == META_EXPIRE_DATE) || 424 (name == META_EXPIRE_DATE) ||
422 (name == META_UPDATE_DATE)) 425 (name == META_UPDATE_DATE))
423 { 426 {
424 //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length()); 427 //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length());
425 428
426#ifndef PWM_EMBEDDED 429#ifndef PWM_EMBEDDED
427 dtval = QDateTime::fromString(val, Qt::ISODate); 430 dtval = QDateTime::fromString(val, Qt::ISODate);
428#else 431#else
429 bool ok; 432 bool ok;
430 dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); 433 dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
431 434
432 if (ok == false) 435 if (ok == false)
433 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); 436 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
434#endif 437#endif
435 438
436 //if the parsed data is wrong, dtval should be invalid at this time. 439 //if the parsed data is wrong, dtval should be invalid at this time.
437 440
438 } 441 }
439 442
440 if (name == META_CREATE_DATE) { 443 if (name == META_CREATE_DATE) {
441 dta->create = dtval; 444 dta->create = dtval;
442 } else if (name == META_VALID_DATE) { 445 } else if (name == META_VALID_DATE) {
443 dta->valid = dtval; 446 dta->valid = dtval;
444 } else if (name == META_EXPIRE_DATE) { 447 } else if (name == META_EXPIRE_DATE) {
445 dta->expire = dtval; 448 dta->expire = dtval;
446 } else if (name == META_UPDATE_DATE) { 449 } else if (name == META_UPDATE_DATE) {
447 dta->update = dtval; 450 dta->update = dtval;
448 } else if (name == META_UPDATE_INT) { 451 } else if (name == META_UPDATE_INT) {
449 dta->updateInt = strtoul(val.latin1(), 0, 10); 452 dta->updateInt = strtoul(val.latin1(), 0, 10);
450 } else if (name == META_UNIQUEID) { 453 } else if (name == META_UNIQUEID) {
451 dta->uniqueid = unescapeEntryData(val).latin1(); 454 dta->uniqueid = unescapeEntryData(val).latin1();
452 } else { 455 } else {
453 printDebug(string("extractMeta(): invalid: ") 456 printDebug(string("extractMeta(): invalid: ")
454 + name.latin1()); 457 + name.latin1());
455 } 458 }
456 459
457 cur = cur.nextSibling(); 460 cur = cur.nextSibling();
458 } 461 }
459 return true; 462 return true;
460} 463}
461 464
462bool Serializer::checkValid() 465bool Serializer::checkValid()
463{ 466{
464 PWM_ASSERT(domDoc); 467 PWM_ASSERT(domDoc);
465 QDomElement root(domDoc->documentElement()); 468 QDomElement root(domDoc->documentElement());
466 if (root.nodeName() != ROOT_MAGIC_NEW && 469 if (root.nodeName() != ROOT_MAGIC_NEW &&
467 root.nodeName() != ROOT_MAGIC_OLD) { 470 root.nodeName() != ROOT_MAGIC_OLD) {
468 printDebug("Serializer: wrong magic"); 471 printDebug("Serializer: wrong magic");
469 return false; 472 return false;
470 } 473 }
471 if (root.attribute(VER_STR_NEW) != COMPAT_VER_NEW && 474 if (root.attribute(VER_STR_NEW) != COMPAT_VER_NEW &&
472 root.attribute(VER_STR_OLD) != COMPAT_VER_OLD) { 475 root.attribute(VER_STR_OLD) != COMPAT_VER_OLD) {
473 printDebug("Serializer: wrong version"); 476 printDebug("Serializer: wrong version");
474 return false; 477 return false;
475 } 478 }
476 return true; 479 return true;
477} 480}
478 481
479QDomElement Serializer::genNewRoot() 482QDomElement Serializer::genNewRoot()
480{ 483{
481 PWM_ASSERT(domDoc); 484 PWM_ASSERT(domDoc);
482 QDomElement root(domDoc->createElement(ROOT_MAGIC_WR)); 485 QDomElement root(domDoc->createElement(ROOT_MAGIC_WR));
483 root.setAttribute(VER_STR_WR, COMPAT_VER_WR); 486 root.setAttribute(VER_STR_WR, COMPAT_VER_WR);
484 domDoc->appendChild(root); 487 domDoc->appendChild(root);
485 return root; 488 return root;
486} 489}
487 490
488bool Serializer::addCategories(QDomElement *e, 491bool Serializer::addCategories(QDomElement *e,
489 const vector<PwMCategoryItem> &dta) 492 const vector<PwMCategoryItem> &dta)
490{ 493{
491 unsigned int numCat = dta.size(), i; 494 unsigned int numCat = dta.size(), i;
492 QString curId, curName; 495 QString curId, curName;
493 QDomElement curCat; 496 QDomElement curCat;
494 497
495 for (i = 0; i < numCat; ++i) { 498 for (i = 0; i < numCat; ++i) {
496 curId = CAT_PREFIX_WR; 499 curId = CAT_PREFIX_WR;
497 curId += tostr(i).c_str(); 500 curId += tostr(i).c_str();
498 curName = dta[i].name.c_str(); 501 curName = dta[i].name.c_str();
499 curCat = domDoc->createElement(curId); 502 curCat = domDoc->createElement(curId);
500 curCat.setAttribute(CAT_NAME_WR, curName); 503 curCat.setAttribute(CAT_NAME_WR, curName);
501 if (!addEntries(&curCat, dta[i].d)) { 504 if (!addEntries(&curCat, dta[i].d)) {
502 return false; 505 return false;
503 } 506 }
504 e->appendChild(curCat); 507 e->appendChild(curCat);
505 } 508 }
506 return true; 509 return true;
507} 510}
508 511
509bool Serializer::addEntries(QDomElement *e, 512bool Serializer::addEntries(QDomElement *e,
510 const vector<PwMDataItem> &dta) 513 const vector<PwMDataItem> &dta)
511{ 514{
512 unsigned int numEntr = dta.size(), i; 515 unsigned int numEntr = dta.size(), i;
513 QString curId; 516 QString curId;
514 QDomElement curEntr; 517 QDomElement curEntr;
515 518
516 for (i = 0; i < numEntr; ++i) { 519 for (i = 0; i < numEntr; ++i) {
517 curId = ENTRY_PREFIX_WR; 520 curId = ENTRY_PREFIX_WR;
518 curId += tostr(i).c_str(); 521 curId += tostr(i).c_str();
519 curEntr = domDoc->createElement(curId); 522 curEntr = domDoc->createElement(curId);
520 if (!writeEntry(&curEntr, dta[i])) { 523 if (!writeEntry(&curEntr, dta[i])) {
521 return false; 524 return false;
522 } 525 }
523 e->appendChild(curEntr); 526 e->appendChild(curEntr);
524 } 527 }
525 return true; 528 return true;
526} 529}
527 530
528bool Serializer::writeEntry(QDomElement *e, 531bool Serializer::writeEntry(QDomElement *e,
529 const PwMDataItem &_dta) 532 const PwMDataItem &_dta)
530{ 533{
531#if WRITE_CDATA_SEC != 0 534#if WRITE_CDATA_SEC != 0
532 # define new_text(x)domDoc->createCDATASection(x) 535 # define new_text(x)domDoc->createCDATASection(x)
533 QDomCDATASection curText; 536 QDomCDATASection curText;
534#else 537#else
535 # define new_text(x)domDoc->createTextNode(x) 538 # define new_text(x)domDoc->createTextNode(x)
536 QDomText curText; 539 QDomText curText;
537#endif 540#endif
538 541
539 QDomText plainText; 542 QDomText plainText;
540 QDomElement tag; 543 QDomElement tag;
541 544
542 // begin -- This is for compatibility with the old serializer 545 // begin -- This is for compatibility with the old serializer
543 PwMDataItem dta = _dta; 546 PwMDataItem dta = _dta;
544 if (!dta.desc.size()) 547 if (!dta.desc.size())
545 dta.desc = " "; 548 dta.desc = " ";
546 if (!dta.name.size()) 549 if (!dta.name.size())
547 dta.name = " "; 550 dta.name = " ";
548 if (!dta.pw.size()) 551 if (!dta.pw.size())
549 dta.pw = " "; 552 dta.pw = " ";
550 if (!dta.comment.size()) 553 if (!dta.comment.size())
551 dta.comment = " "; 554 dta.comment = " ";
552 if (!dta.url.size()) 555 if (!dta.url.size())
553 dta.url = " "; 556 dta.url = " ";
554 if (!dta.launcher.size()) 557 if (!dta.launcher.size())
555 dta.launcher = " "; 558 dta.launcher = " ";
556 // end -- This is for compatibility with the old serializer 559 // end -- This is for compatibility with the old serializer
557 560
558 tag = domDoc->createElement(ENTRY_DESC_WR); 561 tag = domDoc->createElement(ENTRY_DESC_WR);
559 curText = new_text(escapeEntryData(dta.desc.c_str())); 562 curText = new_text(escapeEntryData(dta.desc.c_str()));
560 tag.appendChild(curText); 563 tag.appendChild(curText);
561 e->appendChild(tag); 564 e->appendChild(tag);
562 565
563 tag = domDoc->createElement(ENTRY_NAME_WR); 566 tag = domDoc->createElement(ENTRY_NAME_WR);
564 curText = new_text(escapeEntryData(dta.name.c_str())); 567 curText = new_text(escapeEntryData(dta.name.c_str()));
565 tag.appendChild(curText); 568 tag.appendChild(curText);
566 e->appendChild(tag); 569 e->appendChild(tag);
567 570
568 tag = domDoc->createElement(ENTRY_PW_WR); 571 tag = domDoc->createElement(ENTRY_PW_WR);
569 curText = new_text(escapeEntryData(dta.pw.c_str())); 572 curText = new_text(escapeEntryData(dta.pw.c_str()));
570 tag.appendChild(curText); 573 tag.appendChild(curText);
571 e->appendChild(tag); 574 e->appendChild(tag);
572 575
573 tag = domDoc->createElement(ENTRY_COMMENT_WR); 576 tag = domDoc->createElement(ENTRY_COMMENT_WR);
574 curText = new_text(escapeEntryData(dta.comment.c_str())); 577 curText = new_text(escapeEntryData(dta.comment.c_str()));
575 tag.appendChild(curText); 578 tag.appendChild(curText);
576 e->appendChild(tag); 579 e->appendChild(tag);
577 580
578 tag = domDoc->createElement(ENTRY_URL_WR); 581 tag = domDoc->createElement(ENTRY_URL_WR);
579 curText = new_text(escapeEntryData(dta.url.c_str())); 582 curText = new_text(escapeEntryData(dta.url.c_str()));
580 tag.appendChild(curText); 583 tag.appendChild(curText);
581 e->appendChild(tag); 584 e->appendChild(tag);
582 585
583 tag = domDoc->createElement(ENTRY_LAUNCHER_WR); 586 tag = domDoc->createElement(ENTRY_LAUNCHER_WR);
584 curText = new_text(escapeEntryData(dta.launcher.c_str())); 587 curText = new_text(escapeEntryData(dta.launcher.c_str()));
585 tag.appendChild(curText); 588 tag.appendChild(curText);
586 e->appendChild(tag); 589 e->appendChild(tag);
587 590
588 tag = domDoc->createElement(ENTRY_LVP_WR); 591 tag = domDoc->createElement(ENTRY_LVP_WR);
589 plainText = domDoc->createTextNode(tostr(dta.listViewPos).c_str()); 592 plainText = domDoc->createTextNode(tostr(dta.listViewPos).c_str());
590 tag.appendChild(plainText); 593 tag.appendChild(plainText);
591 e->appendChild(tag); 594 e->appendChild(tag);
592 595
593 tag = domDoc->createElement(ENTRY_BIN_WR); 596 tag = domDoc->createElement(ENTRY_BIN_WR);
594 if (dta.binary) 597 if (dta.binary)
595 plainText = domDoc->createTextNode("1"); 598 plainText = domDoc->createTextNode("1");
596 else 599 else
597 plainText = domDoc->createTextNode("0"); 600 plainText = domDoc->createTextNode("0");
598 tag.appendChild(plainText); 601 tag.appendChild(plainText);
599 e->appendChild(tag); 602 e->appendChild(tag);
600 603
601 tag = domDoc->createElement(ENTRY_META_WR); 604 tag = domDoc->createElement(ENTRY_META_WR);
602 if (!writeMeta(&tag, dta.meta)) 605 if (!writeMeta(&tag, dta.meta))
603 return false; 606 return false;
604 e->appendChild(tag); 607 e->appendChild(tag);
605 608
606#undef new_text 609#undef new_text
607 return true; 610 return true;
608} 611}
609 612
610bool Serializer::writeMeta(QDomElement *e, 613bool Serializer::writeMeta(QDomElement *e,
611 const PwMMetaData &dta) 614 const PwMMetaData &dta)
612{ 615{
613 QDomText text; 616 QDomText text;
614 QDomElement tag; 617 QDomElement tag;
615 618
616 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. 619 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
617 //So do not transform an empty value at all. 620 //So do not transform an empty value at all.
618 if (dta.create.isValid()) 621 if (dta.create.isValid())
619 { 622 {
620 tag = domDoc->createElement(META_CREATE_DATE); 623 tag = domDoc->createElement(META_CREATE_DATE);
621#ifndef PWM_EMBEDDED 624#ifndef PWM_EMBEDDED
622 text = domDoc->createTextNode(dta.create.toString(Qt::ISODate)); 625 text = domDoc->createTextNode(dta.create.toString(Qt::ISODate));
623#else 626#else
624 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.create, KLocale::ISODate)); 627 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.create, KLocale::ISODate));
625#endif 628#endif
626 tag.appendChild(text); 629 tag.appendChild(text);
627 e->appendChild(tag); 630 e->appendChild(tag);
628 } 631 }
629 632
630 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. 633 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
631 //So do not transform an empty value at all. 634 //So do not transform an empty value at all.
632 if (dta.valid.isValid()) 635 if (dta.valid.isValid())
633 { 636 {
634 tag = domDoc->createElement(META_VALID_DATE); 637 tag = domDoc->createElement(META_VALID_DATE);
635#ifndef PWM_EMBEDDED 638#ifndef PWM_EMBEDDED
636 text = domDoc->createTextNode(dta.valid.toString(Qt::ISODate)); 639 text = domDoc->createTextNode(dta.valid.toString(Qt::ISODate));
637#else 640#else
638 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.valid, KLocale::ISODate)); 641 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.valid, KLocale::ISODate));
639#endif 642#endif
640 tag.appendChild(text); 643 tag.appendChild(text);
641 e->appendChild(tag); 644 e->appendChild(tag);
642 } 645 }
643 646
644 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. 647 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
645 //So do not transform an empty value at all. 648 //So do not transform an empty value at all.
646 if (dta.expire.isValid()) 649 if (dta.expire.isValid())
647 { 650 {
648 tag = domDoc->createElement(META_EXPIRE_DATE); 651 tag = domDoc->createElement(META_EXPIRE_DATE);
649#ifndef PWM_EMBEDDED 652#ifndef PWM_EMBEDDED
650 text = domDoc->createTextNode(dta.expire.toString(Qt::ISODate)); 653 text = domDoc->createTextNode(dta.expire.toString(Qt::ISODate));
651#else 654#else
652 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.expire, KLocale::ISODate)); 655 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.expire, KLocale::ISODate));
653#endif 656#endif
654 tag.appendChild(text); 657 tag.appendChild(text);
655 e->appendChild(tag); 658 e->appendChild(tag);
656 } 659 }
657 660
658 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. 661 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
659 //So do not transform an empty value at all. 662 //So do not transform an empty value at all.
660 if (dta.update.isValid()) 663 if (dta.update.isValid())
661 { 664 {
662 tag = domDoc->createElement(META_UPDATE_DATE); 665 tag = domDoc->createElement(META_UPDATE_DATE);
663#ifndef PWM_EMBEDDED 666#ifndef PWM_EMBEDDED
664 text = domDoc->createTextNode(dta.update.toString(Qt::ISODate)); 667 text = domDoc->createTextNode(dta.update.toString(Qt::ISODate));
665#else 668#else
666 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.update, KLocale::ISODate)); 669 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.update, KLocale::ISODate));
667#endif 670#endif
668 tag.appendChild(text); 671 tag.appendChild(text);
669 e->appendChild(tag); 672 e->appendChild(tag);
670 } 673 }
671 674
672 tag = domDoc->createElement(META_UPDATE_INT); 675 tag = domDoc->createElement(META_UPDATE_INT);
673 text = domDoc->createTextNode(tostr(dta.updateInt).c_str()); 676 text = domDoc->createTextNode(tostr(dta.updateInt).c_str());
674 tag.appendChild(text); 677 tag.appendChild(text);
675 e->appendChild(tag); 678 e->appendChild(tag);
676 679
677 tag = domDoc->createElement(META_UNIQUEID); 680 tag = domDoc->createElement(META_UNIQUEID);
678 text = domDoc->createTextNode(escapeEntryData(dta.uniqueid.c_str())); 681 text = domDoc->createTextNode(escapeEntryData(dta.uniqueid.c_str()));
679 tag.appendChild(text); 682 tag.appendChild(text);
680 e->appendChild(tag); 683 e->appendChild(tag);
681 684
682#undef new_text 685#undef new_text
683 return true; 686 return true;
684} 687}
685 688
686QString Serializer::escapeEntryData(QString dta) 689QString Serializer::escapeEntryData(QString dta)
687{ 690{
688#ifndef PWM_EMBEDDED 691#ifndef PWM_EMBEDDED
689 dta.replace('\n', "$>--endl--<$"); 692 dta.replace('\n', "$>--endl--<$");
690 dta.replace("]]>", "||>"); 693 dta.replace("]]>", "||>");
691#else 694#else
692 dta.replace(QRegExp("\n"), "$>--endl--<$"); 695 dta.replace(QRegExp("\n"), "$>--endl--<$");
693 dta.replace(QRegExp("]]>"), "||>"); 696 dta.replace(QRegExp("]]>"), "||>");
694#endif 697#endif
695 return dta; 698 return dta;
696} 699}
697 700
698QString Serializer::unescapeEntryData(QString dta) 701QString Serializer::unescapeEntryData(QString dta)
699{ 702{
700#ifndef PWM_EMBEDDED 703#ifndef PWM_EMBEDDED
701 dta.replace("$>--endl--<$", "\n"); 704 dta.replace("$>--endl--<$", "\n");
702 dta.replace("||>", "]]>"); 705 dta.replace("||>", "]]>");
703#else 706#else
707#ifdef DESKTOP_VERSION
708 dta.replace("$>--endl--<$", "\n");
709 dta.replace("||>", "]]>");
710#else
704 dta.replace(QRegExp("\\$>--endl--<\\$"), "\n"); 711 dta.replace(QRegExp("\\$>--endl--<\\$"), "\n");
705 dta.replace(QRegExp("||>"), "]]>"); 712 dta.replace(QRegExp("||>"), "]]>");
706#endif 713#endif
714#endif
707 return dta; 715 return dta;
708} 716}
709 717
710 718
711//US ENH: the following methods are getting used to write/read sync entries 719//US ENH: the following methods are getting used to write/read sync entries
712/** read the syncentries in the node "n" */ 720/** read the syncentries in the node "n" */
713bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta) 721bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta)
714{ 722{
715 QDomNodeList nl(n.childNodes()); 723 QDomNodeList nl(n.childNodes());
716 QDomNode cur; 724 QDomNode cur;
717 725
718 QString devicename, val; 726 QString devicename, val;
719 unsigned int numSync = nl.count(), i; 727 unsigned int numSync = nl.count(), i;
720 PwMSyncItem curSync; 728 PwMSyncItem curSync;
721 bool ok = true; 729 bool ok = true;
722 730
723 if (!numSync) { 731 if (!numSync) {
724 //no sync entries is a possible result 732 //no sync entries is a possible result
725 printDebug("Serializer::readSyncData(): empty"); 733 printDebug("Serializer::readSyncData(): empty");
726 return true; 734 return true;
727 } 735 }
728 for (i = 0; i < numSync; ++i) { 736 for (i = 0; i < numSync; ++i) {
729 cur = nl.item(i); 737 cur = nl.item(i);
730 if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) { 738 if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) {
731 devicename = cur.toElement().attribute(SYNC_TARGET_NAME); 739 devicename = cur.toElement().attribute(SYNC_TARGET_NAME);
732 val = cur.toElement().text(); 740 val = cur.toElement().text();
733 741
734 if ((val == "") || (devicename == QString::null)) { 742 if ((val == "") || (devicename == QString::null)) {
735 printDebug("Serializer::readSyncData(): empty synctarget name or syncdate"); 743 printDebug("Serializer::readSyncData(): empty synctarget name or syncdate");
736 continue; 744 continue;
737 } 745 }
738 746
739 curSync.syncName = devicename.latin1(); 747 curSync.syncName = devicename.latin1();
740#ifndef PWM_EMBEDDED 748#ifndef PWM_EMBEDDED
741 curSync.lastSyncDate = QDateTime::fromString(val, Qt::ISODate); 749 curSync.lastSyncDate = QDateTime::fromString(val, Qt::ISODate);
742#else 750#else
743 curSync.lastSyncDate = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); 751 curSync.lastSyncDate = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
744 if (ok == false) 752 if (ok == false)
745 qDebug("Serializer::readSyncData(): could not parse syncdate:%s",val.latin1()); 753 qDebug("Serializer::readSyncData(): could not parse syncdate:%s",val.latin1());
746 754
747#endif 755#endif
748 dta->push_back(curSync); 756 dta->push_back(curSync);
749 } 757 }
750 } 758 }
751 return true; 759 return true;
752 760
753} 761}
754 762
755 763
756 764
757bool Serializer::addSyncData(QDomElement *e, 765bool Serializer::addSyncData(QDomElement *e,
758 const vector<PwMSyncItem> &dta) 766 const vector<PwMSyncItem> &dta)
759{ 767{
760 unsigned int numSync = dta.size(), i; 768 unsigned int numSync = dta.size(), i;
761 QString curId, curDeviceName; 769 QString curId, curDeviceName;
762 QDomElement curSync; 770 QDomElement curSync;
763 QDomText text; 771 QDomText text;
764 772
765 for (i = 0; i < numSync; ++i) { 773 for (i = 0; i < numSync; ++i) {
766 curId = SYNC_TARGET_PREFIX; 774 curId = SYNC_TARGET_PREFIX;
767 curId += tostr(i).c_str(); 775 curId += tostr(i).c_str();
768 curDeviceName = dta[i].syncName.c_str(); 776 curDeviceName = dta[i].syncName.c_str();
769 curSync = domDoc->createElement(curId); 777 curSync = domDoc->createElement(curId);
770 curSync.setAttribute(SYNC_TARGET_NAME, curDeviceName); 778 curSync.setAttribute(SYNC_TARGET_NAME, curDeviceName);
771 779
772#ifndef PWM_EMBEDDED 780#ifndef PWM_EMBEDDED
773 text = domDoc->createTextNode(dta[i].lastSyncDate.toString(Qt::ISODate)); 781 text = domDoc->createTextNode(dta[i].lastSyncDate.toString(Qt::ISODate));
774#else 782#else
775 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate)); 783 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate));
776#endif 784#endif
777 curSync.appendChild(text); 785 curSync.appendChild(text);
778 786
779 e->appendChild(curSync); 787 e->appendChild(curSync);
780 788
781 } 789 }
782 return true; 790 return true;
783} 791}
784 792