summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/editcategory.cpp188
-rw-r--r--pwmanager/pwmanager/editcategory.h77
-rw-r--r--pwmanager/pwmanager/pwm.cpp69
-rw-r--r--pwmanager/pwmanager/pwm.h1
-rw-r--r--pwmanager/pwmanager/pwmanager.pro2
-rw-r--r--pwmanager/pwmanager/pwmanagerE.pro2
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp5
-rw-r--r--pwmanager/pwmanager/pwmdoc.h14
-rw-r--r--pwmanager/pwmanager/pwmview.cpp10
-rw-r--r--pwmanager/pwmanager/serializer.cpp44
10 files changed, 411 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/editcategory.cpp b/pwmanager/pwmanager/editcategory.cpp
new file mode 100644
index 0000000..4e55de8
--- a/dev/null
+++ b/pwmanager/pwmanager/editcategory.cpp
@@ -0,0 +1,188 @@
1/*
2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22
23$Id$
24*/
25
26#include "editcategory.h"
27#include "pwmdoc.h"
28
29#include <qlayout.h>
30#include <qlabel.h>
31#include <qgroupbox.h>
32#include <klocale.h>
33#include <kcombobox.h>
34#include <klineedit.h>
35#include <qpushbutton.h>
36
37
38/*
39 * Constructs a addEntryWnd as a child of 'parent', with the
40 * name 'name' and widget flags set to 'f'.
41 *
42 * The dialog will by default be modeless, unless you set 'modal' to
43 * TRUE to construct a modal dialog.
44 */
45editCategoryWnd::editCategoryWnd( PwMDoc* d, QWidget* parent, const char* name)
46 : KDialogBase( KDialogBase::Plain, i18n( "edit category descriptions" ),
47 Apply | User2 | Ok,
48 Ok, parent, name, true ),
49 doc(d)
50{
51 findButton( Ok )->setText (i18n("Close" )) ;
52 findButton( User2 )->setText (i18n("Cancel" )) ;
53 connect(this,SIGNAL(user2Clicked()), SLOT(cancel_slot()));
54 enableButton( KDialogBase::Apply, false );
55
56
57 QWidget *page = plainPage();
58 QGridLayout *layout = new QGridLayout( page, 3, 1 );
59 layout->setMargin( KDialogBase::marginHint() );
60 layout->setSpacing( KDialogBase::spacingHint() );
61
62 int i = 0;
63 categoryComboBox = new KComboBox( page );
64 QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), page );
65 layout->addWidget( label, i, 0 );
66 layout->addWidget( categoryComboBox, i, 1 );
67 i++;
68 categoryComboBox->setEditable( FALSE );
69 categoryComboBox->setSizeLimit( 100 );
70 connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&)));
71
72
73 descLineEdit = new KLineEdit( page, "descLineEdit" );
74 label = new QLabel( descLineEdit, i18n("Text1 (Description):"), page );
75 layout->addWidget( label, i, 0 );
76 layout->addWidget( descLineEdit, i, 1 );
77 connect( descLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) );
78 i++;
79
80 usernameLineEdit = new KLineEdit( page, "usernameLineEdit" );
81 label = new QLabel( usernameLineEdit, i18n("Text2 (Username):"), page );
82 layout->addWidget( label, i, 0 );
83 layout->addWidget( usernameLineEdit, i, 1 );
84 connect( usernameLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) );
85 i++;
86
87 pwLineEdit = new KLineEdit( page, "pwLineEdit" );
88 label = new QLabel( pwLineEdit, i18n("Text3 (Password):"), page );
89 layout->addWidget( label, i, 0 );
90 layout->addWidget( pwLineEdit, i, 1 );
91 connect( pwLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) );
92 i++;
93
94 unsigned int count = doc->numCategories();
95
96 for (unsigned int i = 0; i < count; ++i) {
97 categoryComboBox->insertItem(doc->getCategory(i)->c_str());
98 }
99
100 //PwMCategoryItem* getCategoryEntry(unsigned int index)
101 // { return &(dti.dta[index]); }
102
103
104
105}
106
107/*
108 * Destroys the object and frees any allocated resources
109 */
110editCategoryWnd::~editCategoryWnd()
111{
112 // no need to delete child widgets, Qt does it all for us
113}
114
115void editCategoryWnd::slotOk()
116{
117 // qDebug( "addEntryWnd::slotOk(): Not implemented yet" );
118 slotApply();
119 accept();
120}
121
122void editCategoryWnd::slotApply()
123{
124 QString cat = categoryComboBox->currentText();
125
126 unsigned int idx;
127 bool found = doc->findCategory(cat, &idx);
128
129 if (found == true)
130 {
131 PwMCategoryItem* catitem = doc->getCategoryEntry(idx);
132
133 catitem->desc_text = descLineEdit->text().latin1();
134 catitem->name_text = usernameLineEdit->text().latin1();
135 catitem->pw_text = pwLineEdit->text().latin1();
136 enableButton( KDialogBase::Apply, false );
137 return;
138 }
139
140 BUG();
141
142}
143
144void editCategoryWnd::cancel_slot()
145{
146 QString cat = categoryComboBox->currentText();
147 categorySelected ( cat );
148}
149
150void editCategoryWnd::setCurrCategory(const QString &cat)
151{
152 int i, count = categoryComboBox->count();
153
154 for (i = 0; i < count; ++i) {
155 if (categoryComboBox->text(i) == cat) {
156 categoryComboBox->setCurrentItem(i);
157 categorySelected ( cat );
158 return;
159 }
160 }
161 BUG();
162}
163
164void editCategoryWnd::categorySelected ( const QString & string )
165{
166 unsigned int idx;
167 bool found = doc->findCategory(string, &idx);
168
169 if (found == true)
170 {
171 PwMCategoryItem* catitem = doc->getCategoryEntry(idx);
172
173 descLineEdit->setText(catitem->desc_text.c_str());
174 usernameLineEdit->setText(catitem->name_text.c_str());
175 pwLineEdit->setText(catitem->pw_text.c_str());
176 enableButton( KDialogBase::Apply, false );
177 return;
178 }
179
180 BUG();
181
182}
183
184void editCategoryWnd::widgetModified(const QString &)
185{
186 enableButton( KDialogBase::Apply, true );
187}
188
diff --git a/pwmanager/pwmanager/editcategory.h b/pwmanager/pwmanager/editcategory.h
new file mode 100644
index 0000000..90b685b
--- a/dev/null
+++ b/pwmanager/pwmanager/editcategory.h
@@ -0,0 +1,77 @@
1/*
2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22
23$Id$
24*/
25
26#ifndef EDITCATEGORY_H
27#define EDITCATEGORY_H
28
29#include <qvariant.h>
30#include <kdialogbase.h>
31
32class QVBoxLayout;
33class QHBoxLayout;
34class QGridLayout;
35class QSpacerItem;
36class KLineEdit;
37class QPushButton;
38class KComboBox;
39class QLabel;
40class QGroupBox;
41class QMultiLineEdit;
42class PwMDoc;
43
44class editCategoryWnd : public KDialogBase
45{
46 Q_OBJECT
47
48public:
49 editCategoryWnd( PwMDoc* doc, QWidget* parent = 0, const char* name = 0);
50 ~editCategoryWnd();
51
52 void setCurrCategory(const QString &cat);
53
54 KComboBox* categoryComboBox;
55 KLineEdit* descLineEdit;
56 KLineEdit* usernameLineEdit;
57 KLineEdit* pwLineEdit;
58
59 //public slots:
60 // virtual void revealButton_slot();
61 // virtual void generateButton_slot();
62 // virtual void advancedCommentButton_slot(bool on);
63
64 protected slots:
65 virtual void slotOk();
66 virtual void slotApply();
67 virtual void cancel_slot();
68
69 virtual void categorySelected ( const QString & string );
70 virtual void widgetModified(const QString &);
71
72 private:
73 PwMDoc* doc;
74
75};
76
77#endif // EDITCATEGORY_H
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 6ae6e28..bd98d72 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -19,48 +19,49 @@
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> 27#include <qstatusbar.h>
28 28
29#ifndef PWM_EMBEDDED 29#ifndef PWM_EMBEDDED
30#include <kmenubar.h> 30#include <kmenubar.h>
31#include <kstatusbar.h> 31#include <kstatusbar.h>
32#include <dcopclient.h> 32#include <dcopclient.h>
33#include "configwndimpl.h" 33#include "configwndimpl.h"
34#include "configuration.h" 34#include "configuration.h"
35#else 35#else
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38#include <pwmprefs.h> 38#include <pwmprefs.h>
39#include <kpimglobalprefs.h> 39#include <kpimglobalprefs.h>
40#include <kcmconfigs/kcmpwmconfig.h> 40#include <kcmconfigs/kcmpwmconfig.h>
41#include <kcmconfigs/kcmkdepimconfig.h> 41#include <kcmconfigs/kcmkdepimconfig.h>
42#include <kcmultidialog.h> 42#include <kcmultidialog.h>
43#include "editcategory.h"
43#endif 44#endif
44 45
45 46
46#ifndef DESKTOP_VERSION 47#ifndef DESKTOP_VERSION
47#include <qpe/global.h> 48#include <qpe/global.h>
48#endif 49#endif
49 50
50#include <qpixmap.h> 51#include <qpixmap.h>
51#include <qcheckbox.h> 52#include <qcheckbox.h>
52#include <qspinbox.h> 53#include <qspinbox.h>
53#include <qlineedit.h> 54#include <qlineedit.h>
54#include <qfileinfo.h> 55#include <qfileinfo.h>
55#include <qclipboard.h> 56#include <qclipboard.h>
56 57
57 58
58#include <stdio.h> 59#include <stdio.h>
59 60
60#include "pwm.h" 61#include "pwm.h"
61#include "pwminit.h" 62#include "pwminit.h"
62#include "pwmprint.h" 63#include "pwmprint.h"
63#include "addentrywndimpl.h" 64#include "addentrywndimpl.h"
64#include "globalstuff.h" 65#include "globalstuff.h"
65#include "findwndimpl.h" 66#include "findwndimpl.h"
66#include "csv.h" 67#include "csv.h"
@@ -96,48 +97,51 @@ enum {
96 BUTTON_POPUP_MANAGE_CHANGEMP 97 BUTTON_POPUP_MANAGE_CHANGEMP
97}; 98};
98// Button IDs for chipcard popup menu 99// Button IDs for chipcard popup menu
99enum { 100enum {
100#ifdef CONFIG_KEYCARD 101#ifdef CONFIG_KEYCARD
101 BUTTON_POPUP_CHIPCARD_GENNEW = 0, 102 BUTTON_POPUP_CHIPCARD_GENNEW = 0,
102 BUTTON_POPUP_CHIPCARD_DEL, 103 BUTTON_POPUP_CHIPCARD_DEL,
103 BUTTON_POPUP_CHIPCARD_READID, 104 BUTTON_POPUP_CHIPCARD_READID,
104 BUTTON_POPUP_CHIPCARD_SAVEBACKUP, 105 BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
105 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP 106 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
106#else // CONFIG_KEYCARD 107#else // CONFIG_KEYCARD
107 BUTTON_POPUP_CHIPCARD_NO = 0 108 BUTTON_POPUP_CHIPCARD_NO = 0
108#endif // CONFIG_KEYCARD 109#endif // CONFIG_KEYCARD
109}; 110};
110// Button IDs for "view" popup menu 111// Button IDs for "view" popup menu
111enum { 112enum {
112 BUTTON_POPUP_VIEW_FIND = 0, 113 BUTTON_POPUP_VIEW_FIND = 0,
113 BUTTON_POPUP_VIEW_LOCK, 114 BUTTON_POPUP_VIEW_LOCK,
114 BUTTON_POPUP_VIEW_DEEPLOCK, 115 BUTTON_POPUP_VIEW_DEEPLOCK,
115 BUTTON_POPUP_VIEW_UNLOCK 116 BUTTON_POPUP_VIEW_UNLOCK
116}; 117};
117// Button IDs for "options" popup menu 118// Button IDs for "options" popup menu
118enum { 119enum {
119 BUTTON_POPUP_OPTIONS_CONFIG = 0 120 BUTTON_POPUP_OPTIONS_CONFIG = 0
121#ifdef PWM_EMBEDDED
122 ,BUTTON_POPUP_OPTIONS_CATEGORY
123#endif
120}; 124};
121// Button IDs for "export" popup menu (in "file" popup menu) 125// Button IDs for "export" popup menu (in "file" popup menu)
122enum { 126enum {
123 BUTTON_POPUP_EXPORT_TEXT = 0, 127 BUTTON_POPUP_EXPORT_TEXT = 0,
124 BUTTON_POPUP_EXPORT_GPASMAN, 128 BUTTON_POPUP_EXPORT_GPASMAN,
125 BUTTON_POPUP_EXPORT_CSV 129 BUTTON_POPUP_EXPORT_CSV
126#ifdef CONFIG_KWALLETIF 130#ifdef CONFIG_KWALLETIF
127 ,BUTTON_POPUP_EXPORT_KWALLET 131 ,BUTTON_POPUP_EXPORT_KWALLET
128#endif 132#endif
129}; 133};
130// Button IDs for "import" popup menu (in "file" popup menu) 134// Button IDs for "import" popup menu (in "file" popup menu)
131enum { 135enum {
132 BUTTON_POPUP_IMPORT_TEXT = 0, 136 BUTTON_POPUP_IMPORT_TEXT = 0,
133 BUTTON_POPUP_IMPORT_GPASMAN, 137 BUTTON_POPUP_IMPORT_GPASMAN,
134 BUTTON_POPUP_IMPORT_CSV 138 BUTTON_POPUP_IMPORT_CSV
135#ifdef CONFIG_KWALLETIF 139#ifdef CONFIG_KWALLETIF
136 ,BUTTON_POPUP_IMPORT_KWALLET 140 ,BUTTON_POPUP_IMPORT_KWALLET
137#endif 141#endif
138}; 142};
139 143
140#ifdef PWM_EMBEDDED 144#ifdef PWM_EMBEDDED
141// Button IDs for "help" popup menu 145// Button IDs for "help" popup menu
142enum { 146enum {
143 BUTTON_POPUP_HELP_LICENSE = 0, 147 BUTTON_POPUP_HELP_LICENSE = 0,
@@ -339,48 +343,54 @@ void PwM::initMenubar()
339 viewPopup->insertSeparator(); 343 viewPopup->insertSeparator();
340 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), 344 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
341 i18n("&Lock all entries"), this, 345 i18n("&Lock all entries"), this,
342 SLOT(lockWnd_slot()), 0, 346 SLOT(lockWnd_slot()), 0,
343 BUTTON_POPUP_VIEW_LOCK); 347 BUTTON_POPUP_VIEW_LOCK);
344 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), 348 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
345 i18n("&Deep-lock all entries"), this, 349 i18n("&Deep-lock all entries"), this,
346 SLOT(deepLockWnd_slot()), 0, 350 SLOT(deepLockWnd_slot()), 0,
347 BUTTON_POPUP_VIEW_DEEPLOCK); 351 BUTTON_POPUP_VIEW_DEEPLOCK);
348 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), 352 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
349 i18n("&Unlock all entries"), this, 353 i18n("&Unlock all entries"), this,
350 SLOT(unlockWnd_slot()), 0, 354 SLOT(unlockWnd_slot()), 0,
351 BUTTON_POPUP_VIEW_UNLOCK); 355 BUTTON_POPUP_VIEW_UNLOCK);
352 menuBar()->insertItem(i18n("&View"), viewPopup); 356 menuBar()->insertItem(i18n("&View"), viewPopup);
353// "options" popup menu 357// "options" popup menu
354 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 358 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
355 i18n("&Configure..."), this, 359 i18n("&Configure..."), this,
356 SLOT(config_slot()), 360 SLOT(config_slot()),
357 BUTTON_POPUP_OPTIONS_CONFIG); 361 BUTTON_POPUP_OPTIONS_CONFIG);
358 menuBar()->insertItem(i18n("&Options"), optionsPopup); 362 menuBar()->insertItem(i18n("&Options"), optionsPopup);
359// "help" popup menu 363// "help" popup menu
360#ifndef PWM_EMBEDDED 364#ifndef PWM_EMBEDDED
361 helpPopup = helpMenu(QString::null, false); 365 helpPopup = helpMenu(QString::null, false);
362#else 366#else
367 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
368 i18n("C&ategories..."), this,
369 SLOT(category_slot()),
370 BUTTON_POPUP_OPTIONS_CATEGORY);
371
372
363 menuBar()->insertItem(i18n("&Sync"), syncPopup); 373 menuBar()->insertItem(i18n("&Sync"), syncPopup);
364 374
365 375
366 376
367 377
368 378
369 helpPopup = new KPopupMenu(this); 379 helpPopup = new KPopupMenu(this);
370 380
371 381
372 helpPopup->insertItem(i18n("&License"), this, 382 helpPopup->insertItem(i18n("&License"), this,
373 SLOT(showLicense_slot()), 0, 383 SLOT(showLicense_slot()), 0,
374 BUTTON_POPUP_HELP_LICENSE); 384 BUTTON_POPUP_HELP_LICENSE);
375 385
376 helpPopup->insertItem(i18n("&Faq"), this, 386 helpPopup->insertItem(i18n("&Faq"), this,
377 SLOT(faq_slot()), 0, 387 SLOT(faq_slot()), 0,
378 BUTTON_POPUP_HELP_FAQ); 388 BUTTON_POPUP_HELP_FAQ);
379 389
380 helpPopup->insertItem(i18n("&About PwManager"), this, 390 helpPopup->insertItem(i18n("&About PwManager"), this,
381 SLOT(createAboutData_slot()), 0, 391 SLOT(createAboutData_slot()), 0,
382 BUTTON_POPUP_HELP_ABOUT); 392 BUTTON_POPUP_HELP_ABOUT);
383 393
384 helpPopup->insertItem(i18n("&Sync HowTo"), this, 394 helpPopup->insertItem(i18n("&Sync HowTo"), this,
385 SLOT(syncHowTo_slot()), 0, 395 SLOT(syncHowTo_slot()), 0,
386 BUTTON_POPUP_HELP_SYNC); 396 BUTTON_POPUP_HELP_SYNC);
@@ -1370,48 +1380,107 @@ void PwM::copyToClipboard(const QString &s)
1370 1380
1371 1381
1372void PwM::showStatMsg(const QString &msg) 1382void PwM::showStatMsg(const QString &msg)
1373{ 1383{
1374#ifdef DESKTOP_VERSION 1384#ifdef DESKTOP_VERSION
1375 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); 1385 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1376#else 1386#else
1377 qDebug("Statusbar : %s",msg.latin1()); 1387 qDebug("Statusbar : %s",msg.latin1());
1378 Global::statusMessage(msg); 1388 Global::statusMessage(msg);
1379#endif 1389#endif
1380} 1390}
1381 1391
1382void PwM::focusInEvent(QFocusEvent *e) 1392void PwM::focusInEvent(QFocusEvent *e)
1383{ 1393{
1384 if (e->gotFocus()) { 1394 if (e->gotFocus()) {
1385 emit gotFocus(this); 1395 emit gotFocus(this);
1386 } else if (e->lostFocus()) { 1396 } else if (e->lostFocus()) {
1387 emit lostFocus(this); 1397 emit lostFocus(this);
1388 } 1398 }
1389} 1399}
1390 1400
1391 1401
1392#ifdef PWM_EMBEDDED 1402#ifdef PWM_EMBEDDED
1393 1403
1404void PwM::category_slot()
1405{
1406 PwMDoc *doc = curDoc();
1407 PWM_ASSERT(doc);
1408 doc->timer()->getLock(DocTimer::id_autoLockTimer);
1409
1410 editCategoryWnd w(doc, this, "editcategory");
1411/*
1412 vector<string> catList;
1413 doc->getCategoryList(&catList);
1414 unsigned i, size = catList.size();
1415 for (i = 0; i < size; ++i) {
1416 w.addCategory(catList[i].c_str());
1417 }
1418 w.setCurrCategory(view->getCurrentCategory());
1419 if (pw)
1420 w.pwLineEdit->setText(*pw);
1421*/
1422 w.setCurrCategory(view->getCurrentCategory());
1423
1424 tryAgain:
1425 if (w.exec() == 1)
1426 {
1427 PwMDataItem d;
1428
1429 //US BUG: to initialize all values of curEntr with meaningfulldata,
1430 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
1431 // another option would be to create a constructor for PwMDataItem
1432 d.clear(true);
1433 /*
1434 d.desc = w.getDescription().latin1();
1435 d.name = w.getUsername().latin1();
1436 d.pw = w.getPassword().latin1();
1437 d.comment = w.getComment().latin1();
1438 d.url = w.getUrl().latin1();
1439 d.launcher = w.getLauncher().latin1();
1440 PwMerror ret = doc->addEntry(w.getCategory(), &d);
1441 if (ret == e_entryExists) {
1442 KMessageBox::error(this,
1443 i18n
1444 ("An entry with this \"Description\",\n"
1445 "does already exist.\n"
1446 "Please select another description."),
1447 i18n("entry already exists."));
1448 goto tryAgain;
1449 } else if (ret == e_maxAllowedEntr) {
1450 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
1451 "has been reached.\nYou can't add more entries."),
1452 i18n("maximum number of entries"));
1453 doc->timer()->putLock(DocTimer::id_autoLockTimer);
1454 return;
1455 }
1456 */
1457 }
1458 setVirgin(false);
1459 doc->timer()->putLock(DocTimer::id_autoLockTimer);
1460}
1461
1462
1394void PwM::whatsnew_slot() 1463void PwM::whatsnew_slot()
1395{ 1464{
1396 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1465 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1397} 1466}
1398 1467
1399void PwM::showLicense_slot() 1468void PwM::showLicense_slot()
1400{ 1469{
1401 KApplication::showLicence(); 1470 KApplication::showLicence();
1402} 1471}
1403 1472
1404void PwM::faq_slot() 1473void PwM::faq_slot()
1405{ 1474{
1406 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); 1475 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
1407} 1476}
1408 1477
1409void PwM::syncHowTo_slot() 1478void PwM::syncHowTo_slot()
1410{ 1479{
1411 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1480 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1412} 1481}
1413 1482
1414 1483
1415void PwM::createAboutData_slot() 1484void PwM::createAboutData_slot()
1416{ 1485{
1417 QString version; 1486 QString version;
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index fb34bca..9fa9edc 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -158,48 +158,49 @@ public slots:
158 /** lock current document */ 158 /** lock current document */
159 void lockWnd_slot(); 159 void lockWnd_slot();
160 /** deeplock current document */ 160 /** deeplock current document */
161 void deepLockWnd_slot(); 161 void deepLockWnd_slot();
162 /** window/unlock triggered */ 162 /** window/unlock triggered */
163 void unlockWnd_slot(); 163 void unlockWnd_slot();
164 /** find item */ 164 /** find item */
165 void find_slot(); 165 void find_slot();
166 /** configure clicked */ 166 /** configure clicked */
167 void config_slot(); 167 void config_slot();
168 /** (de)activate the "change master pw" button in the menu-bar */ 168 /** (de)activate the "change master pw" button in the menu-bar */
169 void activateMpButton(bool activate = true); 169 void activateMpButton(bool activate = true);
170 /** generate a new chipcard */ 170 /** generate a new chipcard */
171 void genNewCard_slot(); 171 void genNewCard_slot();
172 /** completely erase the current card */ 172 /** completely erase the current card */
173 void eraseCard_slot(); 173 void eraseCard_slot();
174 /** returns the ID number of the current card */ 174 /** returns the ID number of the current card */
175 void readCardId_slot(); 175 void readCardId_slot();
176 /** make backup image of the current card */ 176 /** make backup image of the current card */
177 void makeCardBackup_slot(); 177 void makeCardBackup_slot();
178 /** write backup image to current card */ 178 /** write backup image to current card */
179 void replayCardBackup_slot(); 179 void replayCardBackup_slot();
180 180
181#ifdef PWM_EMBEDDED 181#ifdef PWM_EMBEDDED
182 void category_slot();
182 void whatsnew_slot(); 183 void whatsnew_slot();
183 void showLicense_slot(); 184 void showLicense_slot();
184 void faq_slot(); 185 void faq_slot();
185 void createAboutData_slot(); 186 void createAboutData_slot();
186 void syncHowTo_slot(); 187 void syncHowTo_slot();
187#endif 188#endif
188 189
189protected: 190protected:
190 /** is this window virgin? */ 191 /** is this window virgin? */
191 bool isVirgin() 192 bool isVirgin()
192 { return virgin; } 193 { return virgin; }
193 /** add/remove virginity */ 194 /** add/remove virginity */
194 void setVirgin(bool v); 195 void setVirgin(bool v);
195 /** initialize the menubar */ 196 /** initialize the menubar */
196 void initMenubar(); 197 void initMenubar();
197 /** initialize the toolbar */ 198 /** initialize the toolbar */
198 void initToolbar(); 199 void initToolbar();
199 /** initialize the window-metrics */ 200 /** initialize the window-metrics */
200 void initMetrics(); 201 void initMetrics();
201 /** close-event */ 202 /** close-event */
202 void closeEvent(QCloseEvent *e); 203 void closeEvent(QCloseEvent *e);
203 /** creates a new PwM-ListView and returns it */ 204 /** creates a new PwM-ListView and returns it */
204 PwMView * makeNewListView(PwMDoc *doc); 205 PwMView * makeNewListView(PwMDoc *doc);
205 /** Window hide-event */ 206 /** Window hide-event */
diff --git a/pwmanager/pwmanager/pwmanager.pro b/pwmanager/pwmanager/pwmanager.pro
index fbc0554..7efe45c 100644
--- a/pwmanager/pwmanager/pwmanager.pro
+++ b/pwmanager/pwmanager/pwmanager.pro
@@ -46,48 +46,49 @@ QMAKE_CXXFLAGS += /TP /GX /GR /Ehsc
46#subtbledit.ui \ 46#subtbledit.ui \
47 47
48 48
49 49
50#HEADERS = \ 50#HEADERS = \
51#configuration_31compat.h \ 51#configuration_31compat.h \
52#configuration.h \ 52#configuration.h \
53#configwnd.h \ 53#configwnd.h \
54#configwndimpl.h \ 54#configwndimpl.h \
55#selftest.h 55#selftest.h
56#subtbledit.h \ 56#subtbledit.h \
57#subtbleditimpl.h \ 57#subtbleditimpl.h \
58#compressbzip2.h \ 58#compressbzip2.h \
59 59
60HEADERS = \ 60HEADERS = \
61addentrywnd_emb.h \ 61addentrywnd_emb.h \
62addentrywndimpl.h \ 62addentrywndimpl.h \
63base64.h \ 63base64.h \
64binentrygen.h \ 64binentrygen.h \
65blowfish.h \ 65blowfish.h \
66commentbox.h \ 66commentbox.h \
67compiler.h \ 67compiler.h \
68compressgzip.h \ 68compressgzip.h \
69csv.h \ 69csv.h \
70editcategory.h \
70findwnd_emb.h \ 71findwnd_emb.h \
71findwndimpl.h \ 72findwndimpl.h \
72genpasswd.h \ 73genpasswd.h \
73getkeycardwnd.h \ 74getkeycardwnd.h \
74getmasterpwwnd_emb.h \ 75getmasterpwwnd_emb.h \
75getmasterpwwndimpl.h \ 76getmasterpwwndimpl.h \
76globalstuff.h \ 77globalstuff.h \
77gpasmanfile.h \ 78gpasmanfile.h \
78htmlgen.h \ 79htmlgen.h \
79htmlparse.h \ 80htmlparse.h \
80ipc.h \ 81ipc.h \
81libgcryptif.h \ 82libgcryptif.h \
82listobjselectwnd.h \ 83listobjselectwnd.h \
83listviewpwm.h \ 84listviewpwm.h \
84printtext.h \ 85printtext.h \
85pwgenwnd_emb.h \ 86pwgenwnd_emb.h \
86pwgenwndimpl.h \ 87pwgenwndimpl.h \
87pwmdoc.h \ 88pwmdoc.h \
88pwmdocui.h \ 89pwmdocui.h \
89pwmexception.h \ 90pwmexception.h \
90pwm.h \ 91pwm.h \
91pwminit.h \ 92pwminit.h \
92pwmprefs.h \ 93pwmprefs.h \
93pwmprint.h \ 94pwmprint.h \
@@ -112,48 +113,49 @@ kcmconfigs/pwmconfigwidget.h
112#advcommeditimpl.cpp \ 113#advcommeditimpl.cpp \
113#configuration.cpp \ 114#configuration.cpp \
114#configwnd.cpp \ 115#configwnd.cpp \
115#configwndimpl.cpp \ 116#configwndimpl.cpp \
116#configuration_31compat.cpp \ 117#configuration_31compat.cpp \
117#htmlparse.cpp \ 118#htmlparse.cpp \
118#printtext.cpp \ 119#printtext.cpp \
119#selftest.cpp \ 120#selftest.cpp \
120#pwmprint.cpp \ 121#pwmprint.cpp \
121#spinforsignal.cpp 122#spinforsignal.cpp
122#subtbledit.cpp \ 123#subtbledit.cpp \
123#subtbleditimpl.cpp \ 124#subtbleditimpl.cpp \
124#compressbzip2.cpp 125#compressbzip2.cpp
125 126
126 127
127SOURCES = \ 128SOURCES = \
128addentrywnd_emb.cpp \ 129addentrywnd_emb.cpp \
129addentrywndimpl.cpp \ 130addentrywndimpl.cpp \
130base64.cpp \ 131base64.cpp \
131binentrygen.cpp \ 132binentrygen.cpp \
132blowfish.cpp \ 133blowfish.cpp \
133commentbox.cpp \ 134commentbox.cpp \
134compressgzip.cpp \ 135compressgzip.cpp \
135csv.cpp \ 136csv.cpp \
137editcategory.cpp \
136findwnd_emb.cpp \ 138findwnd_emb.cpp \
137findwndimpl.cpp \ 139findwndimpl.cpp \
138genpasswd.cpp \ 140genpasswd.cpp \
139getkeycardwnd.cpp \ 141getkeycardwnd.cpp \
140getmasterpwwnd_emb.cpp \ 142getmasterpwwnd_emb.cpp \
141getmasterpwwndimpl.cpp \ 143getmasterpwwndimpl.cpp \
142globalstuff.cpp \ 144globalstuff.cpp \
143gpasmanfile.cpp \ 145gpasmanfile.cpp \
144htmlgen.cpp \ 146htmlgen.cpp \
145ipc.cpp \ 147ipc.cpp \
146libgcryptif.cpp \ 148libgcryptif.cpp \
147listobjselectwnd.cpp \ 149listobjselectwnd.cpp \
148listviewpwm.cpp \ 150listviewpwm.cpp \
149main.cpp \ 151main.cpp \
150pwgenwnd_emb.cpp \ 152pwgenwnd_emb.cpp \
151pwgenwndimpl.cpp \ 153pwgenwndimpl.cpp \
152pwm.cpp \ 154pwm.cpp \
153pwmdoc.cpp \ 155pwmdoc.cpp \
154pwmdocui.cpp \ 156pwmdocui.cpp \
155pwmexception.cpp \ 157pwmexception.cpp \
156pwminit.cpp \ 158pwminit.cpp \
157pwmprefs.cpp \ 159pwmprefs.cpp \
158pwmtray.cpp \ 160pwmtray.cpp \
159pwmview.cpp \ 161pwmview.cpp \
diff --git a/pwmanager/pwmanager/pwmanagerE.pro b/pwmanager/pwmanager/pwmanagerE.pro
index e195178..6b68514 100644
--- a/pwmanager/pwmanager/pwmanagerE.pro
+++ b/pwmanager/pwmanager/pwmanagerE.pro
@@ -44,48 +44,49 @@ LIBS += $(GCC3EXTRALIB2)
44#subtbledit.ui \ 44#subtbledit.ui \
45 45
46 46
47 47
48#HEADERS = \ 48#HEADERS = \
49#configuration_31compat.h \ 49#configuration_31compat.h \
50#configuration.h \ 50#configuration.h \
51#configwnd.h \ 51#configwnd.h \
52#configwndimpl.h \ 52#configwndimpl.h \
53#selftest.h 53#selftest.h
54#subtbledit.h \ 54#subtbledit.h \
55#subtbleditimpl.h \ 55#subtbleditimpl.h \
56#compressbzip2.h \ 56#compressbzip2.h \
57 57
58HEADERS = \ 58HEADERS = \
59addentrywnd_emb.h \ 59addentrywnd_emb.h \
60addentrywndimpl.h \ 60addentrywndimpl.h \
61base64.h \ 61base64.h \
62binentrygen.h \ 62binentrygen.h \
63blowfish.h \ 63blowfish.h \
64commentbox.h \ 64commentbox.h \
65compiler.h \ 65compiler.h \
66compressgzip.h \ 66compressgzip.h \
67csv.h \ 67csv.h \
68editcategory.h \
68findwnd_emb.h \ 69findwnd_emb.h \
69findwndimpl.h \ 70findwndimpl.h \
70genpasswd.h \ 71genpasswd.h \
71getkeycardwnd.h \ 72getkeycardwnd.h \
72getmasterpwwnd_emb.h \ 73getmasterpwwnd_emb.h \
73getmasterpwwndimpl.h \ 74getmasterpwwndimpl.h \
74globalstuff.h \ 75globalstuff.h \
75gpasmanfile.h \ 76gpasmanfile.h \
76htmlgen.h \ 77htmlgen.h \
77htmlparse.h \ 78htmlparse.h \
78ipc.h \ 79ipc.h \
79libgcryptif.h \ 80libgcryptif.h \
80listobjselectwnd.h \ 81listobjselectwnd.h \
81listviewpwm.h \ 82listviewpwm.h \
82printtext.h \ 83printtext.h \
83pwgenwnd_emb.h \ 84pwgenwnd_emb.h \
84pwgenwndimpl.h \ 85pwgenwndimpl.h \
85pwmdoc.h \ 86pwmdoc.h \
86pwmdocui.h \ 87pwmdocui.h \
87pwmexception.h \ 88pwmexception.h \
88pwm.h \ 89pwm.h \
89pwminit.h \ 90pwminit.h \
90pwmprefs.h \ 91pwmprefs.h \
91pwmprint.h \ 92pwmprint.h \
@@ -110,48 +111,49 @@ kcmconfigs/pwmconfigwidget.h
110#advcommeditimpl.cpp \ 111#advcommeditimpl.cpp \
111#configuration.cpp \ 112#configuration.cpp \
112#configwnd.cpp \ 113#configwnd.cpp \
113#configwndimpl.cpp \ 114#configwndimpl.cpp \
114#configuration_31compat.cpp \ 115#configuration_31compat.cpp \
115#htmlparse.cpp \ 116#htmlparse.cpp \
116#printtext.cpp \ 117#printtext.cpp \
117#selftest.cpp \ 118#selftest.cpp \
118#pwmprint.cpp \ 119#pwmprint.cpp \
119#spinforsignal.cpp 120#spinforsignal.cpp
120#subtbledit.cpp \ 121#subtbledit.cpp \
121#subtbleditimpl.cpp \ 122#subtbleditimpl.cpp \
122#compressbzip2.cpp 123#compressbzip2.cpp
123 124
124 125
125SOURCES = \ 126SOURCES = \
126addentrywnd_emb.cpp \ 127addentrywnd_emb.cpp \
127addentrywndimpl.cpp \ 128addentrywndimpl.cpp \
128base64.cpp \ 129base64.cpp \
129binentrygen.cpp \ 130binentrygen.cpp \
130blowfish.cpp \ 131blowfish.cpp \
131commentbox.cpp \ 132commentbox.cpp \
132compressgzip.cpp \ 133compressgzip.cpp \
133csv.cpp \ 134csv.cpp \
135editcategory.cpp \
134findwnd_emb.cpp \ 136findwnd_emb.cpp \
135findwndimpl.cpp \ 137findwndimpl.cpp \
136genpasswd.cpp \ 138genpasswd.cpp \
137getkeycardwnd.cpp \ 139getkeycardwnd.cpp \
138getmasterpwwnd_emb.cpp \ 140getmasterpwwnd_emb.cpp \
139getmasterpwwndimpl.cpp \ 141getmasterpwwndimpl.cpp \
140globalstuff.cpp \ 142globalstuff.cpp \
141gpasmanfile.cpp \ 143gpasmanfile.cpp \
142htmlgen.cpp \ 144htmlgen.cpp \
143ipc.cpp \ 145ipc.cpp \
144libgcryptif.cpp \ 146libgcryptif.cpp \
145listobjselectwnd.cpp \ 147listobjselectwnd.cpp \
146listviewpwm.cpp \ 148listviewpwm.cpp \
147main.cpp \ 149main.cpp \
148pwgenwnd_emb.cpp \ 150pwgenwnd_emb.cpp \
149pwgenwndimpl.cpp \ 151pwgenwndimpl.cpp \
150pwm.cpp \ 152pwm.cpp \
151pwmdoc.cpp \ 153pwmdoc.cpp \
152pwmdocui.cpp \ 154pwmdocui.cpp \
153pwmexception.cpp \ 155pwmexception.cpp \
154pwminit.cpp \ 156pwminit.cpp \
155pwmprefs.cpp \ 157pwmprefs.cpp \
156pwmtray.cpp \ 158pwmtray.cpp \
157pwmview.cpp \ 159pwmview.cpp \
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 9043acc..ddbf4f2 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -1031,48 +1031,51 @@ PwMerror PwMDoc::addEntry(const QString &category, PwMDataItem *d,
1031 } 1031 }
1032 dti.dta[cat].d.push_back(*d); 1032 dti.dta[cat].d.push_back(*d);
1033 1033
1034 delAllEmptyCat(true); 1034 delAllEmptyCat(true);
1035 1035
1036 if (!dontFlagDirty) 1036 if (!dontFlagDirty)
1037 flagDirty(); 1037 flagDirty();
1038 return e_success; 1038 return e_success;
1039} 1039}
1040 1040
1041PwMerror PwMDoc::addCategory(const QString &category, unsigned int *categoryIndex, 1041PwMerror PwMDoc::addCategory(const QString &category, unsigned int *categoryIndex,
1042 bool checkIfExist) 1042 bool checkIfExist)
1043{ 1043{
1044 if (isDeepLocked()) { 1044 if (isDeepLocked()) {
1045 PwMerror ret; 1045 PwMerror ret;
1046 ret = deepLock(false); 1046 ret = deepLock(false);
1047 if (ret != e_success) 1047 if (ret != e_success)
1048 return e_lock; 1048 return e_lock;
1049 } 1049 }
1050 if (checkIfExist) { 1050 if (checkIfExist) {
1051 if (findCategory(category, categoryIndex)) 1051 if (findCategory(category, categoryIndex))
1052 return e_categoryExists; 1052 return e_categoryExists;
1053 } 1053 }
1054 PwMCategoryItem item; 1054 PwMCategoryItem item;
1055 //US ENH: clear item to initialize with default values, or create a constructor
1056 item.clear();
1057
1055 item.name = category.latin1(); 1058 item.name = category.latin1();
1056 dti.dta.push_back(item); 1059 dti.dta.push_back(item);
1057 if (categoryIndex) 1060 if (categoryIndex)
1058 *categoryIndex = dti.dta.size() - 1; 1061 *categoryIndex = dti.dta.size() - 1;
1059 return e_success; 1062 return e_success;
1060} 1063}
1061 1064
1062bool PwMDoc::delEntry(const QString &category, unsigned int index, bool dontFlagDirty) 1065bool PwMDoc::delEntry(const QString &category, unsigned int index, bool dontFlagDirty)
1063{ 1066{
1064 unsigned int cat = 0; 1067 unsigned int cat = 0;
1065 1068
1066 if (!findCategory(category, &cat)) { 1069 if (!findCategory(category, &cat)) {
1067 BUG(); 1070 BUG();
1068 return false; 1071 return false;
1069 } 1072 }
1070 1073
1071 return delEntry(cat, index, dontFlagDirty); 1074 return delEntry(cat, index, dontFlagDirty);
1072} 1075}
1073 1076
1074bool PwMDoc::delEntry(unsigned int category, unsigned int index, bool dontFlagDirty) 1077bool PwMDoc::delEntry(unsigned int category, unsigned int index, bool dontFlagDirty)
1075{ 1078{
1076 if (isDeepLocked()) 1079 if (isDeepLocked())
1077 return false; 1080 return false;
1078 if (index > dti.dta[category].d.size() - 1) 1081 if (index > dti.dta[category].d.size() - 1)
@@ -1859,48 +1862,50 @@ PwMerror PwMDoc::deepLock(bool lock, bool saveToFile)
1859 if (ret == e_wrongPw) { 1862 if (ret == e_wrongPw) {
1860 return e_wrongPw; 1863 return e_wrongPw;
1861 } else if (ret != e_success) { 1864 } else if (ret != e_success) {
1862 printDebug(string("PwMDoc::deepLock(false): ERR! openDoc() == ") 1865 printDebug(string("PwMDoc::deepLock(false): ERR! openDoc() == ")
1863 + tostr(static_cast<int>(ret))); 1866 + tostr(static_cast<int>(ret)));
1864 return e_lock; 1867 return e_lock;
1865 } 1868 }
1866 unsetDocStatFlag(DOC_STAT_DEEPLOCKED); 1869 unsetDocStatFlag(DOC_STAT_DEEPLOCKED);
1867 timer()->start(DocTimer::id_autoLockTimer); 1870 timer()->start(DocTimer::id_autoLockTimer);
1868 } 1871 }
1869 1872
1870 emitDataChanged(this); 1873 emitDataChanged(this);
1871 return e_success; 1874 return e_success;
1872} 1875}
1873 1876
1874void PwMDoc::_deepUnlock() 1877void PwMDoc::_deepUnlock()
1875{ 1878{
1876 deepLock(false); 1879 deepLock(false);
1877} 1880}
1878 1881
1879void PwMDoc::clearDoc() 1882void PwMDoc::clearDoc()
1880{ 1883{
1881 dti.clear(); 1884 dti.clear();
1882 PwMCategoryItem d; 1885 PwMCategoryItem d;
1886 //US ENH: to initialize all members with meaningfull data.
1887 d.clear();
1883 d.name = DEFAULT_CATEGORY.latin1(); 1888 d.name = DEFAULT_CATEGORY.latin1();
1884 dti.dta.push_back(d); 1889 dti.dta.push_back(d);
1885 currentPw = ""; 1890 currentPw = "";
1886 unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); 1891 unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW);
1887} 1892}
1888 1893
1889void PwMDoc::changeCurrentPw() 1894void PwMDoc::changeCurrentPw()
1890{ 1895{
1891 if (currentPw == "") 1896 if (currentPw == "")
1892 return; // doc hasn't been saved. No mpw available. 1897 return; // doc hasn't been saved. No mpw available.
1893 bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); 1898 bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD);
1894 QString pw = requestMpwChange(&currentPw, &useChipcard); 1899 QString pw = requestMpwChange(&currentPw, &useChipcard);
1895 if (pw == "") 1900 if (pw == "")
1896 return; 1901 return;
1897 if (useChipcard) 1902 if (useChipcard)
1898 setDocStatFlag(DOC_STAT_USE_CHIPCARD); 1903 setDocStatFlag(DOC_STAT_USE_CHIPCARD);
1899 else 1904 else
1900 unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); 1905 unsetDocStatFlag(DOC_STAT_USE_CHIPCARD);
1901 setCurrentPw(pw); 1906 setCurrentPw(pw);
1902} 1907}
1903 1908
1904void PwMDoc::setListViewPos(const QString &category, unsigned int index, 1909void PwMDoc::setListViewPos(const QString &category, unsigned int index,
1905 int pos) 1910 int pos)
1906{ 1911{
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 09923ab..ef81dfc 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -232,52 +232,61 @@ struct PwMDataItem
232 desc = a.desc; 232 desc = a.desc;
233 name = a.name; 233 name = a.name;
234 pw = a.pw; 234 pw = a.pw;
235 comment = a.comment; 235 comment = a.comment;
236 url = a.url; 236 url = a.url;
237 if (syncLauncher == true) 237 if (syncLauncher == true)
238 launcher = a.launcher; 238 launcher = a.launcher;
239 meta = a.meta; 239 meta = a.meta;
240 binary = a.binary; 240 binary = a.binary;
241 lockStat = a.lockStat; 241 lockStat = a.lockStat;
242 rev = a.rev; 242 rev = a.rev;
243 243
244 return true; 244 return true;
245 } 245 }
246 246
247}; 247};
248 248
249struct PwMCategoryItem 249struct PwMCategoryItem
250{ 250{
251 /** all PwMDataItems (all passwords) within this category */ 251 /** all PwMDataItems (all passwords) within this category */
252 vector<PwMDataItem>d; 252 vector<PwMDataItem>d;
253 /** category name/description */ 253 /** category name/description */
254 string name; 254 string name;
255 255
256 //US ENH: enhancements of the filestructure
257 /* each category stores the text for description,name and password */
258 string desc_text;
259 string name_text;
260 string pw_text;
261
256 void clear() 262 void clear()
257 { 263 {
258 d.clear(); 264 d.clear();
259 name = ""; 265 name = "";
266 desc_text = "Description";
267 name_text = "Username";
268 pw_text = "Password";
260 } 269 }
261}; 270};
262 271
263struct PwMSyncItem 272struct PwMSyncItem
264{ 273{
265 string syncName; 274 string syncName;
266 QDateTime lastSyncDate; 275 QDateTime lastSyncDate;
267 276
268 void clear() 277 void clear()
269 { 278 {
270 lastSyncDate = QDateTime(); 279 lastSyncDate = QDateTime();
271 syncName = ""; 280 syncName = "";
272 } 281 }
273}; 282};
274 283
275struct PwMItem 284struct PwMItem
276{ 285{
277 vector<PwMCategoryItem> dta; 286 vector<PwMCategoryItem> dta;
278 vector<PwMSyncItem> syncDta; 287 vector<PwMSyncItem> syncDta;
279 288
280 void clear() 289 void clear()
281 { 290 {
282 dta.clear(); 291 dta.clear();
283 syncDta.clear(); 292 syncDta.clear();
@@ -764,46 +773,51 @@ protected:
764 } 773 }
765 /** make a backup-copy of the given file */ 774 /** make a backup-copy of the given file */
766 bool backupFile(const QString &filePath); 775 bool backupFile(const QString &filePath);
767 /** copy a file from src to dst */ 776 /** copy a file from src to dst */
768 bool copyFile(const QString &src, const QString &dst); 777 bool copyFile(const QString &src, const QString &dst);
769 778
770 779
771 public: 780 public:
772#ifdef PWM_EMBEDDED 781#ifdef PWM_EMBEDDED
773 //US ENH: this is the magic function that syncronizes the local doc with the remote doc. 782 //US ENH: this is the magic function that syncronizes the local doc with the remote doc.
774 PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode ); 783 PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode );
775 784
776 //takePwMDataItem returns the following values 785 //takePwMDataItem returns the following values
777 // 0 equal 786 // 0 equal
778 // 1 take local 787 // 1 take local
779 // 2 take remote 788 // 2 take remote
780 // 3 cancel 789 // 3 cancel
781 int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); 790 int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full );
782 791
783 //the following methods are the overwritten callbackmethods from the syncinterface 792 //the following methods are the overwritten callbackmethods from the syncinterface
784 virtual bool sync(KSyncManager* manager, QString filename, int mode); 793 virtual bool sync(KSyncManager* manager, QString filename, int mode);
785 virtual void removeSyncInfo( QString syncProfile); 794 virtual void removeSyncInfo( QString syncProfile);
786 795
787#endif 796#endif
797 //US ENH: helpermethods to return a whole category entry
798 /** returns a pointer to the categoryitem */
799 PwMCategoryItem* getCategoryEntry(unsigned int index)
800 { return &(dti.dta[index]); }
801
788 private: 802 private:
789 //US ENH: helpermethods to access the sync data for a certain syncname. 803 //US ENH: helpermethods to access the sync data for a certain syncname.
790 // It returns the syncdatas index 804 // It returns the syncdatas index
791 bool findSyncData(const QString &syncname, unsigned int *index); 805 bool findSyncData(const QString &syncname, unsigned int *index);
792 806
793 /** add new syncdataentry */ 807 /** add new syncdataentry */
794 PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); 808 PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false);
795 809
796 /** returns a pointer to the syncdata */ 810 /** returns a pointer to the syncdata */
797 PwMSyncItem* getSyncDataEntry(unsigned int index) 811 PwMSyncItem* getSyncDataEntry(unsigned int index)
798 { return &(dti.syncDta[index]); } 812 { return &(dti.syncDta[index]); }
799 813
800 /** delete entry */ 814 /** delete entry */
801 bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); 815 bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false);
802 816
803 PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); 817 PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index);
804 818
805 QStringList getIDEntryList(); 819 QStringList getIDEntryList();
806 820
807}; 821};
808 822
809#endif 823#endif
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index 5aaf66e..7733028 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -239,48 +239,58 @@ void PwMView::shiftToView()
239 239
240 // ensure all listViewPos are set 240 // ensure all listViewPos are set
241 doc->ensureLvp(); 241 doc->ensureLvp();
242 242
243 // clear all tmp-data vectors 243 // clear all tmp-data vectors
244 unsigned int i, entries = doc->numEntries(catDocIndex); 244 unsigned int i, entries = doc->numEntries(catDocIndex);
245 if (entries) { 245 if (entries) {
246 mainClass->setVirgin(false); 246 mainClass->setVirgin(false);
247 } 247 }
248 vector<PwMDataItem> tmpSorted; 248 vector<PwMDataItem> tmpSorted;
249 PwMDataItem currItem; 249 PwMDataItem currItem;
250 currItem.clear(); 250 currItem.clear();
251 tmpSorted.insert(tmpSorted.begin(), entries, currItem); 251 tmpSorted.insert(tmpSorted.begin(), entries, currItem);
252 252
253 // Sort items and store them in tempoary tmpSorted. 253 // Sort items and store them in tempoary tmpSorted.
254 for (i = 0; i < entries; ++i) { 254 for (i = 0; i < entries; ++i) {
255 doc->getEntry(catDocIndex, i, &currItem); 255 doc->getEntry(catDocIndex, i, &currItem);
256 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos); 256 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos);
257 tmpSorted[currItem.listViewPos] = currItem; 257 tmpSorted[currItem.listViewPos] = currItem;
258 } 258 }
259 259
260 // shift tempoary data to ListView. 260 // shift tempoary data to ListView.
261 tmpDisableSort(); 261 tmpDisableSort();
262 lv->clear(); 262 lv->clear();
263
264 //US ENH: adjust the headers of the table according the category texts
265 {
266 PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex);
267 // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str());
268 lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str());
269 lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str());
270 lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str());
271 }
272
263 QCheckListItem *newItem; 273 QCheckListItem *newItem;
264 vector<PwMDataItem>::iterator it = tmpSorted.begin(), 274 vector<PwMDataItem>::iterator it = tmpSorted.begin(),
265 end = tmpSorted.end(); 275 end = tmpSorted.end();
266 while (it != end) { 276 while (it != end) {
267 newItem = new ListViewItemPwM(lv); 277 newItem = new ListViewItemPwM(lv);
268 newItem->setText(COLUMN_DESC, (*it).desc.c_str()); 278 newItem->setText(COLUMN_DESC, (*it).desc.c_str());
269 if ((*it).binary) { 279 if ((*it).binary) {
270 newItem->setText(COLUMN_NAME, ""); 280 newItem->setText(COLUMN_NAME, "");
271 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>")); 281 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>"));
272 newItem->setText(COLUMN_URL, ""); 282 newItem->setText(COLUMN_URL, "");
273 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 283 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
274 } else { 284 } else {
275 newItem->setText(COLUMN_NAME, (*it).name.c_str()); 285 newItem->setText(COLUMN_NAME, (*it).name.c_str());
276 if ((*it).lockStat) { 286 if ((*it).lockStat) {
277 newItem->setText(COLUMN_PW, QString((*it).pw.c_str()) 287 newItem->setText(COLUMN_PW, QString((*it).pw.c_str())
278 + " " 288 + " "
279 + i18n("To unlock click the icon on the left.")); 289 + i18n("To unlock click the icon on the left."));
280 } else { 290 } else {
281 newItem->setText(COLUMN_PW, (*it).pw.c_str()); 291 newItem->setText(COLUMN_PW, (*it).pw.c_str());
282 } 292 }
283 newItem->setText(COLUMN_URL, (*it).url.c_str()); 293 newItem->setText(COLUMN_URL, (*it).url.c_str());
284 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 294 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
285 } 295 }
286 newItem->setOn(!((*it).lockStat)); 296 newItem->setOn(!((*it).lockStat));
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 5753c1d..507fa30 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -18,117 +18,131 @@
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 and sync information
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//US ENH : optional text for categories
60 #define CAT_TEXT_OLD "text"
61
59 #define ENTRY_PREFIX_OLD"entry_" 62 #define ENTRY_PREFIX_OLD"entry_"
60 #define ENTRY_DESC_OLD "desc" 63 #define ENTRY_DESC_OLD "desc"
61 #define ENTRY_NAME_OLD "name" 64 #define ENTRY_NAME_OLD "name"
62 #define ENTRY_PW_OLD "pw" 65 #define ENTRY_PW_OLD "pw"
63 #define ENTRY_COMMENT_OLD"comment" 66 #define ENTRY_COMMENT_OLD"comment"
64 #define ENTRY_URL_OLD "url" 67 #define ENTRY_URL_OLD "url"
65 #define ENTRY_LAUNCHER_OLD"launcher" 68 #define ENTRY_LAUNCHER_OLD"launcher"
66 #define ENTRY_LVP_OLD "listViewPos" 69 #define ENTRY_LVP_OLD "listViewPos"
67 #define ENTRY_BIN_OLD "b" 70 #define ENTRY_BIN_OLD "b"
68 #define ENTRY_META_OLD "m" 71 #define ENTRY_META_OLD "m"
69 72
70 #define ROOT_MAGIC_NEW "P" 73 #define ROOT_MAGIC_NEW "P"
71 #define VER_STR_NEW "v" 74 #define VER_STR_NEW "v"
72 #define COMPAT_VER_NEW "2" 75 #define COMPAT_VER_NEW "2"
73 #define CAT_ROOT_NEW "c" 76 #define CAT_ROOT_NEW "c"
74 #define CAT_PREFIX_NEW "c" 77 #define CAT_PREFIX_NEW "c"
75 #define CAT_NAME_NEW "n" 78 #define CAT_NAME_NEW "n"
79//US ENH : optional text for categories
80 #define CAT_TEXT_NEW "t"
81
76 #define ENTRY_PREFIX_NEW"e" 82 #define ENTRY_PREFIX_NEW"e"
77 #define ENTRY_DESC_NEW "d" 83 #define ENTRY_DESC_NEW "d"
78 #define ENTRY_NAME_NEW "n" 84 #define ENTRY_NAME_NEW "n"
79 #define ENTRY_PW_NEW "p" 85 #define ENTRY_PW_NEW "p"
80 #define ENTRY_COMMENT_NEW"c" 86 #define ENTRY_COMMENT_NEW"c"
81 #define ENTRY_URL_NEW "u" 87 #define ENTRY_URL_NEW "u"
82 #define ENTRY_LAUNCHER_NEW"l" 88 #define ENTRY_LAUNCHER_NEW"l"
83 #define ENTRY_LVP_NEW "v" 89 #define ENTRY_LVP_NEW "v"
84 #define ENTRY_BIN_NEW ENTRY_BIN_OLD 90 #define ENTRY_BIN_NEW ENTRY_BIN_OLD
85 #define ENTRY_META_NEW ENTRY_META_OLD 91 #define ENTRY_META_NEW ENTRY_META_OLD
86 92
87#if USE_OLD_TAGS != 0 93#if USE_OLD_TAGS != 0
88 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD 94 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD
89 # define VER_STR_WR VER_STR_OLD 95 # define VER_STR_WR VER_STR_OLD
90 # define COMPAT_VER_WR COMPAT_VER_OLD 96 # define COMPAT_VER_WR COMPAT_VER_OLD
91 # define CAT_ROOT_WR CAT_ROOT_OLD 97 # define CAT_ROOT_WR CAT_ROOT_OLD
92 # define CAT_PREFIX_WR CAT_PREFIX_OLD 98 # define CAT_PREFIX_WR CAT_PREFIX_OLD
93 # define CAT_NAME_WR CAT_NAME_OLD 99 # define CAT_NAME_WR CAT_NAME_OLD
100
101//US ENH : optional text for categories
102 # define CAT_TEXT_WR CAT_TEXT_OLD
103
94 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD 104 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD
95 # define ENTRY_DESC_WR ENTRY_DESC_OLD 105 # define ENTRY_DESC_WR ENTRY_DESC_OLD
96 # define ENTRY_NAME_WR ENTRY_NAME_OLD 106 # define ENTRY_NAME_WR ENTRY_NAME_OLD
97 # define ENTRY_PW_WR ENTRY_PW_OLD 107 # define ENTRY_PW_WR ENTRY_PW_OLD
98 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD 108 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD
99 # define ENTRY_URL_WR ENTRY_URL_OLD 109 # define ENTRY_URL_WR ENTRY_URL_OLD
100 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD 110 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD
101 # define ENTRY_LVP_WR ENTRY_LVP_OLD 111 # define ENTRY_LVP_WR ENTRY_LVP_OLD
102 # define ENTRY_BIN_WR ENTRY_BIN_OLD 112 # define ENTRY_BIN_WR ENTRY_BIN_OLD
103 # define ENTRY_META_WR ENTRY_META_OLD 113 # define ENTRY_META_WR ENTRY_META_OLD
104#else 114#else
105 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW 115 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW
106 # define VER_STR_WR VER_STR_NEW 116 # define VER_STR_WR VER_STR_NEW
107 # define COMPAT_VER_WR COMPAT_VER_NEW 117 # define COMPAT_VER_WR COMPAT_VER_NEW
108 # define CAT_ROOT_WR CAT_ROOT_NEW 118 # define CAT_ROOT_WR CAT_ROOT_NEW
109 # define CAT_PREFIX_WR CAT_PREFIX_NEW 119 # define CAT_PREFIX_WR CAT_PREFIX_NEW
110 # define CAT_NAME_WR CAT_NAME_NEW 120 # define CAT_NAME_WR CAT_NAME_NEW
121
122//US ENH : optional text for categories
123 # define CAT_TEXT_WR CAT_TEXT_NEW
124
111 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW 125 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW
112 # define ENTRY_DESC_WR ENTRY_DESC_NEW 126 # define ENTRY_DESC_WR ENTRY_DESC_NEW
113 # define ENTRY_NAME_WR ENTRY_NAME_NEW 127 # define ENTRY_NAME_WR ENTRY_NAME_NEW
114 # define ENTRY_PW_WR ENTRY_PW_NEW 128 # define ENTRY_PW_WR ENTRY_PW_NEW
115 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW 129 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW
116 # define ENTRY_URL_WR ENTRY_URL_NEW 130 # define ENTRY_URL_WR ENTRY_URL_NEW
117 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW 131 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW
118 # define ENTRY_LVP_WR ENTRY_LVP_NEW 132 # define ENTRY_LVP_WR ENTRY_LVP_NEW
119 # define ENTRY_BIN_WR ENTRY_BIN_NEW 133 # define ENTRY_BIN_WR ENTRY_BIN_NEW
120 # define ENTRY_META_WR ENTRY_META_NEW 134 # define ENTRY_META_WR ENTRY_META_NEW
121#endif 135#endif
122 136
123 137
124Serializer::Serializer() 138Serializer::Serializer()
125{ 139{
126 defaultLockStat = true; 140 defaultLockStat = true;
127//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing 141//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
128#ifndef PWM_EMBEDDED 142#ifndef PWM_EMBEDDED
129 domDoc = new QDomDocument; 143 domDoc = new QDomDocument;
130#else 144#else
131 domDoc = new QDomDocument("mydoc"); 145 domDoc = new QDomDocument("mydoc");
132#endif 146#endif
133} 147}
134 148
@@ -250,67 +264,85 @@ bool Serializer::deSerialize(PwMItem *dta)
250 continue; 264 continue;
251 } 265 }
252 else if (n.nodeName() == SYNC_ROOT) { 266 else if (n.nodeName() == SYNC_ROOT) {
253 if (!readSyncData(n, &(dta->syncDta))) { 267 if (!readSyncData(n, &(dta->syncDta))) {
254 return false; 268 return false;
255 } 269 }
256 continue; 270 continue;
257 } 271 }
258 272
259 /* NOTE: We can stop processing here, as we 273 /* NOTE: We can stop processing here, as we
260 * don't have more nodes in root, yet. 274 * don't have more nodes in root, yet.
261 */ 275 */
262 return false; 276 return false;
263 277
264 } 278 }
265 return true; 279 return true;
266} 280}
267 281
268bool Serializer::readCategories(const QDomNode &n, 282bool Serializer::readCategories(const QDomNode &n,
269 vector<PwMCategoryItem> *dta) 283 vector<PwMCategoryItem> *dta)
270{ 284{
271 QDomNodeList nl(n.childNodes()); 285 QDomNodeList nl(n.childNodes());
272 QDomNode cur; 286 QDomNode cur;
273 QString name; 287 QString name;
288 QString text;
274 unsigned int numCat = nl.count(), i; 289 unsigned int numCat = nl.count(), i;
275 PwMCategoryItem curCat; 290 PwMCategoryItem curCat;
276 vector<PwMDataItem> curEntr; 291 vector<PwMDataItem> curEntr;
277 292
278 if (!numCat) { 293 if (!numCat) {
279 printDebug("Serializer::readCategories(): empty"); 294 printDebug("Serializer::readCategories(): empty");
280 return false; 295 return false;
281 } 296 }
282 for (i = 0; i < numCat; ++i) { 297 for (i = 0; i < numCat; ++i) {
283 cur = nl.item(i); 298 cur = nl.item(i);
284 if (cur.nodeName().left(1) == CAT_PREFIX_NEW || 299 if (cur.nodeName().left(1) == CAT_PREFIX_NEW ||
285 cur.nodeName().left(4) == CAT_PREFIX_OLD) { 300 cur.nodeName().left(4) == CAT_PREFIX_OLD) {
286 name = cur.toElement().attribute(CAT_NAME_NEW); 301 name = cur.toElement().attribute(CAT_NAME_NEW);
287 if (name == QString::null) 302 if (name == QString::null)
288 name = cur.toElement().attribute(CAT_NAME_OLD); 303 name = cur.toElement().attribute(CAT_NAME_OLD);
289 PWM_ASSERT(name != QString::null); 304 PWM_ASSERT(name != QString::null);
290 PWM_ASSERT(name != ""); 305 PWM_ASSERT(name != "");
291 curCat.clear(); 306 curCat.clear();
292 curCat.name = name.latin1(); 307 curCat.name = name.latin1();
308
309 //US ENH: new version might include text for description, name and pw
310 text = cur.toElement().attribute(CAT_TEXT_NEW);
311 if (text == QString::null)
312 text = cur.toElement().attribute(CAT_TEXT_OLD);
313 if (text != QString::null)
314 {
315 QStringList textlist = QStringList::split(";", text, true);
316 unsigned int num = textlist.count();
317 if (num > 0)
318 curCat.desc_text = textlist[0].latin1();
319 if (num > 1)
320 curCat.name_text = textlist[1].latin1();
321 if (num > 2)
322 curCat.pw_text = textlist[2].latin1();
323 }
324
293 if (!readEntries(cur, &curEntr)) { 325 if (!readEntries(cur, &curEntr)) {
294 dta->clear(); 326 dta->clear();
295 return false; 327 return false;
296 } 328 }
297 curCat.d = curEntr; 329 curCat.d = curEntr;
298 dta->push_back(curCat); 330 dta->push_back(curCat);
299 } else { 331 } else {
300 printDebug("Serializer::readCategories(): uh? not a category?"); 332 printDebug("Serializer::readCategories(): uh? not a category?");
301 } 333 }
302 } 334 }
303 return true; 335 return true;
304} 336}
305 337
306bool Serializer::readEntries(const QDomNode &n, 338bool Serializer::readEntries(const QDomNode &n,
307 vector<PwMDataItem> *dta) 339 vector<PwMDataItem> *dta)
308{ 340{
309 QDomNodeList nl(n.childNodes()); 341 QDomNodeList nl(n.childNodes());
310 QDomNode cur; 342 QDomNode cur;
311 unsigned int numEntr = nl.count(), i; 343 unsigned int numEntr = nl.count(), i;
312 PwMDataItem curEntr; 344 PwMDataItem curEntr;
313 //US BUG: to initialize all values of curEntr with meaningfulldata, 345 //US BUG: to initialize all values of curEntr with meaningfulldata,
314 // we call clear on it. Reason: Information in the file we will read might be incomplete. 346 // we call clear on it. Reason: Information in the file we will read might be incomplete.
315 // e.g. the metadata is missing. 347 // e.g. the metadata is missing.
316 curEntr.clear(true); 348 curEntr.clear(true);
@@ -480,48 +512,58 @@ bool Serializer::checkValid()
480} 512}
481 513
482QDomElement Serializer::genNewRoot() 514QDomElement Serializer::genNewRoot()
483{ 515{
484 PWM_ASSERT(domDoc); 516 PWM_ASSERT(domDoc);
485 QDomElement root(domDoc->createElement(ROOT_MAGIC_WR)); 517 QDomElement root(domDoc->createElement(ROOT_MAGIC_WR));
486 root.setAttribute(VER_STR_WR, COMPAT_VER_WR); 518 root.setAttribute(VER_STR_WR, COMPAT_VER_WR);
487 domDoc->appendChild(root); 519 domDoc->appendChild(root);
488 return root; 520 return root;
489} 521}
490 522
491bool Serializer::addCategories(QDomElement *e, 523bool Serializer::addCategories(QDomElement *e,
492 const vector<PwMCategoryItem> &dta) 524 const vector<PwMCategoryItem> &dta)
493{ 525{
494 unsigned int numCat = dta.size(), i; 526 unsigned int numCat = dta.size(), i;
495 QString curId, curName; 527 QString curId, curName;
496 QDomElement curCat; 528 QDomElement curCat;
497 529
498 for (i = 0; i < numCat; ++i) { 530 for (i = 0; i < numCat; ++i) {
499 curId = CAT_PREFIX_WR; 531 curId = CAT_PREFIX_WR;
500 curId += tostr(i).c_str(); 532 curId += tostr(i).c_str();
501 curName = dta[i].name.c_str(); 533 curName = dta[i].name.c_str();
502 curCat = domDoc->createElement(curId); 534 curCat = domDoc->createElement(curId);
503 curCat.setAttribute(CAT_NAME_WR, curName); 535 curCat.setAttribute(CAT_NAME_WR, curName);
536
537 //US ENH: new version includes text for description, name and pw
538 QStringList curTextList;
539 curTextList << dta[i].desc_text.c_str();
540 curTextList << dta[i].name_text.c_str();
541 curTextList << dta[i].pw_text.c_str();
542 QString text = curTextList.join(";");
543 curCat.setAttribute(CAT_TEXT_WR, text);
544
545
504 if (!addEntries(&curCat, dta[i].d)) { 546 if (!addEntries(&curCat, dta[i].d)) {
505 return false; 547 return false;
506 } 548 }
507 e->appendChild(curCat); 549 e->appendChild(curCat);
508 } 550 }
509 return true; 551 return true;
510} 552}
511 553
512bool Serializer::addEntries(QDomElement *e, 554bool Serializer::addEntries(QDomElement *e,
513 const vector<PwMDataItem> &dta) 555 const vector<PwMDataItem> &dta)
514{ 556{
515 unsigned int numEntr = dta.size(), i; 557 unsigned int numEntr = dta.size(), i;
516 QString curId; 558 QString curId;
517 QDomElement curEntr; 559 QDomElement curEntr;
518 560
519 for (i = 0; i < numEntr; ++i) { 561 for (i = 0; i < numEntr; ++i) {
520 curId = ENTRY_PREFIX_WR; 562 curId = ENTRY_PREFIX_WR;
521 curId += tostr(i).c_str(); 563 curId += tostr(i).c_str();
522 curEntr = domDoc->createElement(curId); 564 curEntr = domDoc->createElement(curId);
523 if (!writeEntry(&curEntr, dta[i])) { 565 if (!writeEntry(&curEntr, dta[i])) {
524 return false; 566 return false;
525 } 567 }
526 e->appendChild(curEntr); 568 e->appendChild(curEntr);
527 } 569 }