summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-24 22:21:25 (UTC)
committer ulf69 <ulf69>2004-09-24 22:21:25 (UTC)
commite695903cc49b33e63505b651b13d830e318fc29a (patch) (unidiff)
treefd210e2defbdcb3f3d9d739d0b00e6853705af29
parenta884dac6f756b3702a10ae97aa8782e4d2a84b20 (diff)
downloadkdepimpi-e695903cc49b33e63505b651b13d830e318fc29a.zip
kdepimpi-e695903cc49b33e63505b651b13d830e318fc29a.tar.gz
kdepimpi-e695903cc49b33e63505b651b13d830e318fc29a.tar.bz2
fixed bug with QDomDocument handling, plus some GUI enhancements
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp8
-rw-r--r--pwmanager/pwmanager/pwmexception.cpp7
-rw-r--r--pwmanager/pwmanager/serializer.cpp12
3 files changed, 23 insertions, 4 deletions
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index e42dd9d..5e675fc 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -347,111 +347,111 @@ bool PwMDocUi::openDocUi(PwMDoc *doc,
347 i18n("password filename(*.pwm)"), getCurrentView()); 347 i18n("password filename(*.pwm)"), getCurrentView());
348#endif 348#endif
349 } 349 }
350 if (filename.isEmpty()) 350 if (filename.isEmpty())
351 goto cancelOpen; 351 goto cancelOpen;
352 PwMerror ret; 352 PwMerror ret;
353 while (true) { 353 while (true) {
354 int lockStat = -1; 354 int lockStat = -1;
355 if (openDeepLocked) { 355 if (openDeepLocked) {
356 lockStat = 2; 356 lockStat = 2;
357 } else { 357 } else {
358 if (conf()->confGlobUnlockOnOpen()) { 358 if (conf()->confGlobUnlockOnOpen()) {
359 lockStat = 0; 359 lockStat = 0;
360 } else { 360 } else {
361 lockStat = 1; 361 lockStat = 1;
362 } 362 }
363 } 363 }
364 ret = doc->openDoc(&filename, lockStat); 364 ret = doc->openDoc(&filename, lockStat);
365 qDebug("pwmdocui::OpenDocui %i", ret); 365 qDebug("pwmdocui::OpenDocui %i", ret);
366 if (ret != e_success) { 366 if (ret != e_success) {
367 if (ret == e_readFile || ret == e_openFile) { 367 if (ret == e_readFile || ret == e_openFile) {
368 KMessageBox::error(getCurrentView(), 368 KMessageBox::error(getCurrentView(),
369 i18n("Could not read file!") 369 i18n("Could not read file!")
370 + "\n" 370 + "\n"
371 + filename, 371 + filename,
372 i18n("file error")); 372 i18n("file error"));
373 goto cancelOpen; 373 goto cancelOpen;
374 } 374 }
375 if (ret == e_alreadyOpen) { 375 if (ret == e_alreadyOpen) {
376 KMessageBox::error(getCurrentView(), 376 KMessageBox::error(getCurrentView(),
377 i18n("This file is already open."), 377 i18n("This file is already open."),
378 i18n("already open")); 378 i18n("already open"));
379 goto cancelOpen; 379 goto cancelOpen;
380 } 380 }
381 if (ret == e_fileVer) { 381 if (ret == e_fileVer) {
382 KMessageBox::error(getCurrentView(), 382 KMessageBox::error(getCurrentView(),
383 i18n 383 i18n
384 ("File-version is not supported!\n" 384 ("File-version is not supported!\n"
385 "Did you create this file with an older or newer version of PwM?"), 385 "Did you create this file with an older or newer version of PwM?"),
386 i18n 386 i18n
387 ("incompatible version")); 387 ("incompatible version"));
388 goto cancelOpen; 388 goto cancelOpen;
389 } 389 }
390 if (ret == e_wrongPw) { 390 if (ret == e_wrongPw) {
391 continue; 391 continue;
392 } 392 }
393 if (ret == e_noPw) { 393 if (ret == e_noPw) {
394 goto cancelOpen; 394 goto cancelOpen;
395 } 395 }
396 if (ret == e_fileFormat) { 396 if (ret == e_fileFormat) {
397 KMessageBox::error(getCurrentView(), 397 KMessageBox::error(getCurrentView(),
398 i18n 398 i18n
399 ("Sorry, this file has not been recognized " 399 ("Sorry, this file has not been recognized "
400 "as a PwM Password file.\n" 400 "as a PwM Password file.\n"
401 "Probably you have selected the wrong file."), 401 "Probably you have selected the wrong file."),
402 i18n 402 i18n
403 ("no PwM password-file")); 403 ("no PwM password-file"));
404 goto cancelOpen; 404 goto cancelOpen;
405 } 405 }
406 if (ret == e_fileCorrupt) { 406 if (ret == e_fileCorrupt) {
407 KMessageBox::error(getCurrentView(), 407 KMessageBox::error(getCurrentView(),
408 i18n 408 i18n
409 ("File corrupt!\n" 409 ("File corrupt!\n"
410 "Maybe the media, you stored this file on, " 410 "Maybe the media, you stored this file on, "
411 "had bad sectors?"), 411 "had bad sectors?"),
412 i18n 412 i18n
413 ("checksum error")); 413 ("checksum error"));
414 goto cancelOpen; 414 goto cancelOpen;
415 } 415 }
416 } 416 }
417 break; 417 break;
418 } 418 }
419 return true; 419 return true;
420 420
421 cancelOpen: 421 cancelOpen:
422 return false; 422 return false;
423} 423}
424 424
425QString PwMDocUi::string_defaultCategory() 425QString PwMDocUi::string_defaultCategory()
426{ 426{
427 return i18n("Default"); 427 return i18n("Default");
428} 428}
429 429
430QString PwMDocUi::string_locked() 430QString PwMDocUi::string_locked()
431{ 431{
432 return i18n("<LOCKED>"); 432 return i18n("<LOCKED>");
433} 433}
434 434
435QString PwMDocUi::string_deepLockedShort() 435QString PwMDocUi::string_deepLockedShort()
436{ 436{
437 return i18n("DEEP-LOCKED"); 437 return i18n("DEEP-LOCKED");
438} 438}
439 439
440QString PwMDocUi::string_deepLockedLong() 440QString PwMDocUi::string_deepLockedLong()
441{ 441{
442 return i18n("This file is DEEP-LOCKED!\n" 442 return i18n("This file is DEEP-LOCKED!\n"
443 "That means all data has been encrypted " 443 "That means all data has been encrypted\n"
444 "and written out to the file. If you want " 444 "and written out to the file. If you want\n"
445 "to see the entries, please UNLOCK the file. " 445 "to see the entries, please UNLOCK the file.\n"
446 "While unlocking, you will be prompted for the " 446 "While unlocking, you will be prompted for the\n"
447 "master-password or the key-card."); 447 "master-password or the key-card.");
448} 448}
449 449
450QString PwMDocUi::string_defaultTitle() 450QString PwMDocUi::string_defaultTitle()
451{ 451{
452 return i18n("Untitled"); 452 return i18n("Untitled");
453} 453}
454 454
455#ifndef PWM_EMBEDDED 455#ifndef PWM_EMBEDDED
456#include "pwmdocui.moc" 456#include "pwmdocui.moc"
457#endif 457#endif
diff --git a/pwmanager/pwmanager/pwmexception.cpp b/pwmanager/pwmanager/pwmexception.cpp
index 4c00b04..c0dbb39 100644
--- a/pwmanager/pwmanager/pwmexception.cpp
+++ b/pwmanager/pwmanager/pwmexception.cpp
@@ -1,58 +1,65 @@
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 20
21#include "pwmexception.h" 21#include "pwmexception.h"
22 22
23#include <kmessagebox.h> 23#include <kmessagebox.h>
24 24
25 25
26void pwmFatal(const char *id, 26void pwmFatal(const char *id,
27 const char *file, 27 const char *file,
28 int line) 28 int line)
29{ 29{
30 cerr << PROG_NAME " " << id << " at " 30 cerr << PROG_NAME " " << id << " at "
31 << file << ":" << line 31 << file << ":" << line
32 << endl; 32 << endl;
33} 33}
34 34
35void __printError(const string &msg) 35void __printError(const string &msg)
36{ 36{
37 QString __msg(PROG_NAME " generated a fatal fault:\n"); 37 QString __msg(PROG_NAME " generated a fatal fault:\n");
38 __msg += msg.c_str(); 38 __msg += msg.c_str();
39 cerr << "\n\n" << __msg.latin1() << endl; 39 cerr << "\n\n" << __msg.latin1() << endl;
40 KMessageBox::error(0, __msg, PROG_NAME " fatal ERROR!"); 40 KMessageBox::error(0, __msg, PROG_NAME " fatal ERROR!");
41} 41}
42 42
43void __printInfo(const string &msg) 43void __printInfo(const string &msg)
44{ 44{
45 cout << PROG_NAME " INFO: " << msg << endl; 45 cout << PROG_NAME " INFO: " << msg << endl;
46#ifdef PWM_DEBUG
47 qDebug("%s INFO: %s", PROG_NAME, msg.c_str()) ;
48#endif
46} 49}
47 50
48void __printWarn(const string &msg) 51void __printWarn(const string &msg)
49{ 52{
50 cerr << PROG_NAME " WARNING: " << msg << endl; 53 cerr << PROG_NAME " WARNING: " << msg << endl;
54#ifdef PWM_DEBUG
55 qDebug("%s WARNING: %s", PROG_NAME, msg.c_str()) ;
56#endif
51} 57}
52 58
53#ifdef PWM_DEBUG 59#ifdef PWM_DEBUG
54void __printDebug(const string &msg) 60void __printDebug(const string &msg)
55{ 61{
56 cout << PROG_NAME " DEBUG: " << msg << endl; 62 cout << PROG_NAME " DEBUG: " << msg << endl;
63 qDebug("%s DEBUG: %s", PROG_NAME, msg.c_str()) ;
57} 64}
58#endif // PWM_DEBUG 65#endif // PWM_DEBUG
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 2810b48..fcdcec3 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -27,255 +27,267 @@
27#endif 27#endif
28 28
29/* enable/disable serializer debugging (0/1) */ 29/* enable/disable serializer debugging (0/1) */
30 #define SERIALIZER_DEBUG1 30 #define SERIALIZER_DEBUG1
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 44
45/* This is compatibility stuff. 45/* This is compatibility stuff.
46 * The names of the entries have changed and here are the 46 * The names of the entries have changed and here are the
47 * new and old ones 47 * new and old ones
48 */ 48 */
49 #define ROOT_MAGIC_OLD "PwM-xml-dat" 49 #define ROOT_MAGIC_OLD "PwM-xml-dat"
50 #define VER_STR_OLD "ver" 50 #define VER_STR_OLD "ver"
51 #define COMPAT_VER_OLD "0x02" 51 #define COMPAT_VER_OLD "0x02"
52 #define CAT_ROOT_OLD "categories" 52 #define CAT_ROOT_OLD "categories"
53 #define CAT_PREFIX_OLD "cat_" 53 #define CAT_PREFIX_OLD "cat_"
54 #define CAT_NAME_OLD "name" 54 #define CAT_NAME_OLD "name"
55 #define ENTRY_PREFIX_OLD"entry_" 55 #define ENTRY_PREFIX_OLD"entry_"
56 #define ENTRY_DESC_OLD "desc" 56 #define ENTRY_DESC_OLD "desc"
57 #define ENTRY_NAME_OLD "name" 57 #define ENTRY_NAME_OLD "name"
58 #define ENTRY_PW_OLD "pw" 58 #define ENTRY_PW_OLD "pw"
59 #define ENTRY_COMMENT_OLD"comment" 59 #define ENTRY_COMMENT_OLD"comment"
60 #define ENTRY_URL_OLD "url" 60 #define ENTRY_URL_OLD "url"
61 #define ENTRY_LAUNCHER_OLD"launcher" 61 #define ENTRY_LAUNCHER_OLD"launcher"
62 #define ENTRY_LVP_OLD "listViewPos" 62 #define ENTRY_LVP_OLD "listViewPos"
63 #define ENTRY_BIN_OLD "b" 63 #define ENTRY_BIN_OLD "b"
64 #define ENTRY_META_OLD "m" 64 #define ENTRY_META_OLD "m"
65 65
66 #define ROOT_MAGIC_NEW "P" 66 #define ROOT_MAGIC_NEW "P"
67 #define VER_STR_NEW "v" 67 #define VER_STR_NEW "v"
68 #define COMPAT_VER_NEW "2" 68 #define COMPAT_VER_NEW "2"
69 #define CAT_ROOT_NEW "c" 69 #define CAT_ROOT_NEW "c"
70 #define CAT_PREFIX_NEW "c" 70 #define CAT_PREFIX_NEW "c"
71 #define CAT_NAME_NEW "n" 71 #define CAT_NAME_NEW "n"
72 #define ENTRY_PREFIX_NEW"e" 72 #define ENTRY_PREFIX_NEW"e"
73 #define ENTRY_DESC_NEW "d" 73 #define ENTRY_DESC_NEW "d"
74 #define ENTRY_NAME_NEW "n" 74 #define ENTRY_NAME_NEW "n"
75 #define ENTRY_PW_NEW "p" 75 #define ENTRY_PW_NEW "p"
76 #define ENTRY_COMMENT_NEW"c" 76 #define ENTRY_COMMENT_NEW"c"
77 #define ENTRY_URL_NEW "u" 77 #define ENTRY_URL_NEW "u"
78 #define ENTRY_LAUNCHER_NEW"l" 78 #define ENTRY_LAUNCHER_NEW"l"
79 #define ENTRY_LVP_NEW "v" 79 #define ENTRY_LVP_NEW "v"
80 #define ENTRY_BIN_NEW ENTRY_BIN_OLD 80 #define ENTRY_BIN_NEW ENTRY_BIN_OLD
81 #define ENTRY_META_NEW ENTRY_META_OLD 81 #define ENTRY_META_NEW ENTRY_META_OLD
82 82
83#if USE_OLD_TAGS != 0 83#if USE_OLD_TAGS != 0
84 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD 84 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD
85 # define VER_STR_WR VER_STR_OLD 85 # define VER_STR_WR VER_STR_OLD
86 # define COMPAT_VER_WR COMPAT_VER_OLD 86 # define COMPAT_VER_WR COMPAT_VER_OLD
87 # define CAT_ROOT_WR CAT_ROOT_OLD 87 # define CAT_ROOT_WR CAT_ROOT_OLD
88 # define CAT_PREFIX_WR CAT_PREFIX_OLD 88 # define CAT_PREFIX_WR CAT_PREFIX_OLD
89 # define CAT_NAME_WR CAT_NAME_OLD 89 # define CAT_NAME_WR CAT_NAME_OLD
90 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD 90 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD
91 # define ENTRY_DESC_WR ENTRY_DESC_OLD 91 # define ENTRY_DESC_WR ENTRY_DESC_OLD
92 # define ENTRY_NAME_WR ENTRY_NAME_OLD 92 # define ENTRY_NAME_WR ENTRY_NAME_OLD
93 # define ENTRY_PW_WR ENTRY_PW_OLD 93 # define ENTRY_PW_WR ENTRY_PW_OLD
94 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD 94 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD
95 # define ENTRY_URL_WR ENTRY_URL_OLD 95 # define ENTRY_URL_WR ENTRY_URL_OLD
96 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD 96 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD
97 # define ENTRY_LVP_WR ENTRY_LVP_OLD 97 # define ENTRY_LVP_WR ENTRY_LVP_OLD
98 # define ENTRY_BIN_WR ENTRY_BIN_OLD 98 # define ENTRY_BIN_WR ENTRY_BIN_OLD
99 # define ENTRY_META_WR ENTRY_META_OLD 99 # define ENTRY_META_WR ENTRY_META_OLD
100#else 100#else
101 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW 101 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW
102 # define VER_STR_WR VER_STR_NEW 102 # define VER_STR_WR VER_STR_NEW
103 # define COMPAT_VER_WR COMPAT_VER_NEW 103 # define COMPAT_VER_WR COMPAT_VER_NEW
104 # define CAT_ROOT_WR CAT_ROOT_NEW 104 # define CAT_ROOT_WR CAT_ROOT_NEW
105 # define CAT_PREFIX_WR CAT_PREFIX_NEW 105 # define CAT_PREFIX_WR CAT_PREFIX_NEW
106 # define CAT_NAME_WR CAT_NAME_NEW 106 # define CAT_NAME_WR CAT_NAME_NEW
107 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW 107 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW
108 # define ENTRY_DESC_WR ENTRY_DESC_NEW 108 # define ENTRY_DESC_WR ENTRY_DESC_NEW
109 # define ENTRY_NAME_WR ENTRY_NAME_NEW 109 # define ENTRY_NAME_WR ENTRY_NAME_NEW
110 # define ENTRY_PW_WR ENTRY_PW_NEW 110 # define ENTRY_PW_WR ENTRY_PW_NEW
111 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW 111 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW
112 # define ENTRY_URL_WR ENTRY_URL_NEW 112 # define ENTRY_URL_WR ENTRY_URL_NEW
113 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW 113 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW
114 # define ENTRY_LVP_WR ENTRY_LVP_NEW 114 # define ENTRY_LVP_WR ENTRY_LVP_NEW
115 # define ENTRY_BIN_WR ENTRY_BIN_NEW 115 # define ENTRY_BIN_WR ENTRY_BIN_NEW
116 # define ENTRY_META_WR ENTRY_META_NEW 116 # define ENTRY_META_WR ENTRY_META_NEW
117#endif 117#endif
118 118
119 119
120Serializer::Serializer() 120Serializer::Serializer()
121{ 121{
122 defaultLockStat = true; 122 defaultLockStat = true;
123//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
124#ifndef PWM_EMBEDDED
123 domDoc = new QDomDocument; 125 domDoc = new QDomDocument;
126#else
127 domDoc = new QDomDocument("mydoc");
128#endif
124} 129}
125 130
126Serializer::Serializer(const QCString &buffer) 131Serializer::Serializer(const QCString &buffer)
127{ 132{
128 defaultLockStat = true; 133 defaultLockStat = true;
134//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
135#ifndef PWM_EMBEDDED
129 domDoc = new QDomDocument; 136 domDoc = new QDomDocument;
137#else
138 domDoc = new QDomDocument("mydoc");
139#endif
140
130 if (!parseXml(buffer)) { 141 if (!parseXml(buffer)) {
131 delete domDoc; 142 delete domDoc;
132#ifndef PWM_EMBEDDED 143#ifndef PWM_EMBEDDED
133 throw PwMException(PwMException::EX_PARSE); 144 throw PwMException(PwMException::EX_PARSE);
134#else 145#else
135 qDebug("Serializer::Serializer : Parse Exception "); 146 qDebug("Serializer::Serializer : Parse Exception ");
136#endif 147#endif
137 } 148 }
138} 149}
139 150
140Serializer::~Serializer() 151Serializer::~Serializer()
141{ 152{
142 delete_ifnot_null(domDoc); 153 delete_ifnot_null(domDoc);
143} 154}
144 155
145void Serializer::clear() 156void Serializer::clear()
146{ 157{
147 delete_ifnot_null(domDoc); 158 delete_ifnot_null(domDoc);
148 domDoc = new QDomDocument; 159 domDoc = new QDomDocument;
149} 160}
150 161
151bool Serializer::parseXml(const QCString &buffer) 162bool Serializer::parseXml(const QCString &buffer)
152{ 163{
153 PWM_ASSERT(domDoc); 164 PWM_ASSERT(domDoc);
154#ifndef PWM_EMBEDDED 165#ifndef PWM_EMBEDDED
155 if (!domDoc->setContent(buffer, true)) 166 if (!domDoc->setContent(buffer, true))
156 return false; 167 return false;
157#else 168#else
158 if (!domDoc->setContent(buffer)) 169 if (!domDoc->setContent(buffer))
159 return false; 170 return false;
160#endif 171#endif
161 if (!checkValid()) 172 if (!checkValid())
162 return false; 173 return false;
163 return true; 174 return true;
164} 175}
165 176
166QCString Serializer::getXml() 177QCString Serializer::getXml()
167{ 178{
168 PWM_ASSERT(domDoc); 179 PWM_ASSERT(domDoc);
169 180
170#ifndef PWM_EMBEDDED 181#ifndef PWM_EMBEDDED
171#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 182#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
172 QCString tmp(domDoc->toCString(8)); 183 QCString tmp(domDoc->toCString(8));
173 printDebug("<BEGIN Serializer::getXml() dump>\n"); 184 printDebug("<BEGIN Serializer::getXml() dump>\n");
174 cout << tmp << endl; 185 cout << tmp << endl;
175 printDebug("<END Serializer::getXml() dump>"); 186 printDebug("<END Serializer::getXml() dump>");
176#endif // DEBUG 187#endif // DEBUG
177 188
178 QCString ret(domDoc->toCString(0)); 189 QCString ret(domDoc->toCString(0));
179 ret.replace('\n', ""); 190 ret.replace('\n', "");
180 return ret; 191 return ret;
181#else 192#else
182 193
183#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 194#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
184 QCString tmp(" " + domDoc->toCString()); 195 QCString tmp(" " + domDoc->toCString());
185 printDebug("<BEGIN Serializer::getXml() dump>\n"); 196 printDebug("<BEGIN Serializer::getXml() dump>\n");
197 qDebug(tmp);
186 cout << tmp << endl; 198 cout << tmp << endl;
187 printDebug("<END Serializer::getXml() dump>"); 199 printDebug("<END Serializer::getXml() dump>");
188#endif // DEBUG 200#endif // DEBUG
189 201
190 QCString ret(domDoc->toCString()); 202 QCString ret(domDoc->toCString());
191 ret.replace(QRegExp("\n"), ""); 203 ret.replace(QRegExp("\n"), "");
192 return ret; 204 return ret;
193 205
194#endif 206#endif
195} 207}
196 208
197bool Serializer::serialize(const vector<PwMCategoryItem> &dta) 209bool Serializer::serialize(const vector<PwMCategoryItem> &dta)
198{ 210{
199 PWM_ASSERT(domDoc); 211 PWM_ASSERT(domDoc);
200 QDomElement root(genNewRoot()); 212 QDomElement root(genNewRoot());
201 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); 213 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR));
202 root.appendChild(catNode); 214 root.appendChild(catNode);
203 if (!addCategories(&catNode, dta)) 215 if (!addCategories(&catNode, dta))
204 return false; 216 return false;
205 return true; 217 return true;
206} 218}
207 219
208bool Serializer::deSerialize(vector<PwMCategoryItem> *dta) 220bool Serializer::deSerialize(vector<PwMCategoryItem> *dta)
209{ 221{
210 PWM_ASSERT(domDoc); 222 PWM_ASSERT(domDoc);
211 PWM_ASSERT(dta); 223 PWM_ASSERT(dta);
212 QDomElement root(domDoc->documentElement()); 224 QDomElement root(domDoc->documentElement());
213 QDomNode n; 225 QDomNode n;
214 226
215 dta->clear(); 227 dta->clear();
216 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { 228 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) {
217 // find <categories> ... </categories> 229 // find <categories> ... </categories>
218 // <c> ... </c> 230 // <c> ... </c>
219 if (n.nodeName() == CAT_ROOT_NEW || 231 if (n.nodeName() == CAT_ROOT_NEW ||
220 n.nodeName() == CAT_ROOT_OLD) { 232 n.nodeName() == CAT_ROOT_OLD) {
221 if (!readCategories(n, dta)) { 233 if (!readCategories(n, dta)) {
222 return false; 234 return false;
223 } 235 }
224 236
225 /* NOTE: We can stop processing here, as we 237 /* NOTE: We can stop processing here, as we
226 * don't have more nodes in root, yet. 238 * don't have more nodes in root, yet.
227 */ 239 */
228 return true; 240 return true;
229 } 241 }
230 } 242 }
231 return false; 243 return false;
232} 244}
233 245
234bool Serializer::readCategories(const QDomNode &n, 246bool Serializer::readCategories(const QDomNode &n,
235 vector<PwMCategoryItem> *dta) 247 vector<PwMCategoryItem> *dta)
236{ 248{
237 QDomNodeList nl(n.childNodes()); 249 QDomNodeList nl(n.childNodes());
238 QDomNode cur; 250 QDomNode cur;
239 QString name; 251 QString name;
240 unsigned int numCat = nl.count(), i; 252 unsigned int numCat = nl.count(), i;
241 PwMCategoryItem curCat; 253 PwMCategoryItem curCat;
242 vector<PwMDataItem> curEntr; 254 vector<PwMDataItem> curEntr;
243 255
244 if (!numCat) { 256 if (!numCat) {
245 printDebug("Serializer::readCategories(): empty"); 257 printDebug("Serializer::readCategories(): empty");
246 return false; 258 return false;
247 } 259 }
248 for (i = 0; i < numCat; ++i) { 260 for (i = 0; i < numCat; ++i) {
249 cur = nl.item(i); 261 cur = nl.item(i);
250 if (cur.nodeName().left(1) == CAT_PREFIX_NEW || 262 if (cur.nodeName().left(1) == CAT_PREFIX_NEW ||
251 cur.nodeName().left(4) == CAT_PREFIX_OLD) { 263 cur.nodeName().left(4) == CAT_PREFIX_OLD) {
252 name = cur.toElement().attribute(CAT_NAME_NEW); 264 name = cur.toElement().attribute(CAT_NAME_NEW);
253 if (name == QString::null) 265 if (name == QString::null)
254 name = cur.toElement().attribute(CAT_NAME_OLD); 266 name = cur.toElement().attribute(CAT_NAME_OLD);
255 PWM_ASSERT(name != QString::null); 267 PWM_ASSERT(name != QString::null);
256 PWM_ASSERT(name != ""); 268 PWM_ASSERT(name != "");
257 curCat.clear(); 269 curCat.clear();
258 curCat.name = name.latin1(); 270 curCat.name = name.latin1();
259 if (!readEntries(cur, &curEntr)) { 271 if (!readEntries(cur, &curEntr)) {
260 dta->clear(); 272 dta->clear();
261 return false; 273 return false;
262 } 274 }
263 curCat.d = curEntr; 275 curCat.d = curEntr;
264 dta->push_back(curCat); 276 dta->push_back(curCat);
265 } else { 277 } else {
266 printDebug("Serializer::readCategories(): uh? not a category?"); 278 printDebug("Serializer::readCategories(): uh? not a category?");
267 } 279 }
268 } 280 }
269 return true; 281 return true;
270} 282}
271 283
272bool Serializer::readEntries(const QDomNode &n, 284bool Serializer::readEntries(const QDomNode &n,
273 vector<PwMDataItem> *dta) 285 vector<PwMDataItem> *dta)
274{ 286{
275 QDomNodeList nl(n.childNodes()); 287 QDomNodeList nl(n.childNodes());
276 QDomNode cur; 288 QDomNode cur;
277 unsigned int numEntr = nl.count(), i; 289 unsigned int numEntr = nl.count(), i;
278 PwMDataItem curEntr; 290 PwMDataItem curEntr;
279 291
280 dta->clear(); 292 dta->clear();
281 for (i = 0; i < numEntr; ++i) { 293 for (i = 0; i < numEntr; ++i) {