summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-29 04:49:32 (UTC)
committer ulf69 <ulf69>2004-10-29 04:49:32 (UTC)
commit08a4582f8e5184b8abb7d97781c4fc37ee7edf90 (patch) (unidiff)
tree5131fbfb3992196cf9f4108f7d81b37365104a7d
parentf8dd437160acec2959c462dd43d87f2a0920c0b9 (diff)
downloadkdepimpi-08a4582f8e5184b8abb7d97781c4fc37ee7edf90.zip
kdepimpi-08a4582f8e5184b8abb7d97781c4fc37ee7edf90.tar.gz
kdepimpi-08a4582f8e5184b8abb7d97781c4fc37ee7edf90.tar.bz2
added category edit feature
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
@@ -39,8 +39,9 @@
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
@@ -116,8 +117,11 @@ enum {
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,
@@ -359,8 +363,14 @@ void PwM::initMenubar()
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
@@ -1390,8 +1400,67 @@ void PwM::focusInEvent(QFocusEvent *e)
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}
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
@@ -178,8 +178,9 @@ public slots:
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();
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
@@ -66,8 +66,9 @@ blowfish.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 \
@@ -132,8 +133,9 @@ binentrygen.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 \
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
@@ -64,8 +64,9 @@ blowfish.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 \
@@ -130,8 +131,9 @@ binentrygen.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 \
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
@@ -1051,8 +1051,11 @@ PwMerror PwMDoc::addCategory(const QString &category, unsigned int *categoryInde
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;
@@ -1879,8 +1882,10 @@ void PwMDoc::_deepUnlock()
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);
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
@@ -252,12 +252,21 @@ struct PwMCategoryItem
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
@@ -784,8 +793,13 @@ protected:
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);
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
@@ -259,8 +259,18 @@ void PwMView::shiftToView()
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) {
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
@@ -38,9 +38,9 @@
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"
@@ -55,8 +55,11 @@
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"
@@ -72,8 +75,11 @@
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"
@@ -90,8 +96,12 @@
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
@@ -107,8 +117,12 @@
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
@@ -270,8 +284,9 @@ bool Serializer::readCategories(const QDomNode &n,
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
@@ -289,8 +304,25 @@ bool Serializer::readCategories(const QDomNode &n,
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 }
@@ -500,8 +532,18 @@ bool Serializer::addCategories(QDomElement *e,
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);