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,122 +1,124 @@
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,
@@ -1265,199 +1267,197 @@ exit_fail:
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
@@ -286,182 +286,182 @@ bool PwMDocUi::saveDocUi(PwMDoc *doc)
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
@@ -72,383 +72,386 @@
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());
@@ -608,177 +611,182 @@ bool Serializer::writeEntry(QDomElement *e,
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