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
@@ -1,215 +1,219 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include <klocale.h> 20#include <klocale.h>
21#include <klistview.h> 21#include <klistview.h>
22#include <ktoolbar.h> 22#include <ktoolbar.h>
23#include <kfiledialog.h> 23#include <kfiledialog.h>
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include <kmessagebox.h> 25#include <kmessagebox.h>
26 26
27#include <qstatusbar.h> 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"
67 68
68#ifdef CONFIG_KWALLETIF 69#ifdef CONFIG_KWALLETIF
69# include "kwalletif.h" 70# include "kwalletif.h"
70# include "kwalletemu.h" 71# include "kwalletemu.h"
71#endif 72#endif
72#ifdef CONFIG_KEYCARD 73#ifdef CONFIG_KEYCARD
73# include "pwmkeycard.h" 74# include "pwmkeycard.h"
74#endif 75#endif
75 76
76 77
77 #define DEFAULT_SIZE (QSize(700, 400)) 78 #define DEFAULT_SIZE (QSize(700, 400))
78 79
79// Button IDs for "file" popup menu 80// Button IDs for "file" popup menu
80enum { 81enum {
81 BUTTON_POPUP_FILE_NEW = 0, 82 BUTTON_POPUP_FILE_NEW = 0,
82 BUTTON_POPUP_FILE_OPEN, 83 BUTTON_POPUP_FILE_OPEN,
83 BUTTON_POPUP_FILE_CLOSE, 84 BUTTON_POPUP_FILE_CLOSE,
84 BUTTON_POPUP_FILE_SAVE, 85 BUTTON_POPUP_FILE_SAVE,
85 BUTTON_POPUP_FILE_SAVEAS, 86 BUTTON_POPUP_FILE_SAVEAS,
86 BUTTON_POPUP_FILE_EXPORT, 87 BUTTON_POPUP_FILE_EXPORT,
87 BUTTON_POPUP_FILE_IMPORT, 88 BUTTON_POPUP_FILE_IMPORT,
88 BUTTON_POPUP_FILE_PRINT, 89 BUTTON_POPUP_FILE_PRINT,
89 BUTTON_POPUP_FILE_QUIT 90 BUTTON_POPUP_FILE_QUIT
90}; 91};
91// Button IDs for "manage" popup menu 92// Button IDs for "manage" popup menu
92enum { 93enum {
93 BUTTON_POPUP_MANAGE_ADD = 0, 94 BUTTON_POPUP_MANAGE_ADD = 0,
94 BUTTON_POPUP_MANAGE_EDIT, 95 BUTTON_POPUP_MANAGE_EDIT,
95 BUTTON_POPUP_MANAGE_DEL, 96 BUTTON_POPUP_MANAGE_DEL,
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,
144 BUTTON_POPUP_HELP_FAQ, 148 BUTTON_POPUP_HELP_FAQ,
145 BUTTON_POPUP_HELP_ABOUT, 149 BUTTON_POPUP_HELP_ABOUT,
146 BUTTON_POPUP_HELP_SYNC, 150 BUTTON_POPUP_HELP_SYNC,
147 BUTTON_POPUP_HELP_WHATSNEW 151 BUTTON_POPUP_HELP_WHATSNEW
148}; 152};
149#endif 153#endif
150 154
151// Button IDs for toolbar 155// Button IDs for toolbar
152enum { 156enum {
153 BUTTON_TOOL_NEW = 0, 157 BUTTON_TOOL_NEW = 0,
154 BUTTON_TOOL_OPEN, 158 BUTTON_TOOL_OPEN,
155 BUTTON_TOOL_SAVE, 159 BUTTON_TOOL_SAVE,
156 BUTTON_TOOL_SAVEAS, 160 BUTTON_TOOL_SAVEAS,
157 BUTTON_TOOL_PRINT, 161 BUTTON_TOOL_PRINT,
158 BUTTON_TOOL_ADD, 162 BUTTON_TOOL_ADD,
159 BUTTON_TOOL_EDIT, 163 BUTTON_TOOL_EDIT,
160 BUTTON_TOOL_DEL, 164 BUTTON_TOOL_DEL,
161 BUTTON_TOOL_FIND, 165 BUTTON_TOOL_FIND,
162 BUTTON_TOOL_LOCK, 166 BUTTON_TOOL_LOCK,
163 BUTTON_TOOL_DEEPLOCK, 167 BUTTON_TOOL_DEEPLOCK,
164 BUTTON_TOOL_UNLOCK 168 BUTTON_TOOL_UNLOCK
165}; 169};
166 170
167 171
168PwM::PwM(PwMInit *_init, PwMDoc *doc, 172PwM::PwM(PwMInit *_init, PwMDoc *doc,
169 bool virginity, 173 bool virginity,
170 QWidget *parent, const char *name) 174 QWidget *parent, const char *name)
171 : KMainWindow(parent, "HALLO") 175 : KMainWindow(parent, "HALLO")
172 , forceQuit (false) 176 , forceQuit (false)
173 , forceMinimizeToTray (false) 177 , forceMinimizeToTray (false)
174{ 178{
175 syncManager = 0; 179 syncManager = 0;
176 virgin = !virginity; 180 virgin = !virginity;
177 init = _init; 181 init = _init;
178 connect(doc, SIGNAL(docClosed(PwMDoc *)), 182 connect(doc, SIGNAL(docClosed(PwMDoc *)),
179 this, SLOT(docClosed(PwMDoc *))); 183 this, SLOT(docClosed(PwMDoc *)));
180 initMenubar(); 184 initMenubar();
181 initToolbar(); 185 initToolbar();
182 initMetrics(); 186 initMetrics();
183 setVirgin(virginity); 187 setVirgin(virginity);
184 setFocusPolicy(QWidget::WheelFocus); 188 setFocusPolicy(QWidget::WheelFocus);
185#ifndef PWM_EMBEDDED 189#ifndef PWM_EMBEDDED
186 statusBar()->show(); 190 statusBar()->show();
187#endif 191#endif
188 view = makeNewListView(doc); 192 view = makeNewListView(doc);
189 setCentralWidget(view); 193 setCentralWidget(view);
190 updateCaption(); 194 updateCaption();
191 showStatMsg(i18n("Ready.")); 195 showStatMsg(i18n("Ready."));
192} 196}
193 197
194PwM::~PwM() 198PwM::~PwM()
195{ 199{
196 qDebug("PwM::~PwM() %x", this); 200 qDebug("PwM::~PwM() %x", this);
197 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), 201 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
198 this, SLOT(docClosed(PwMDoc *))); 202 this, SLOT(docClosed(PwMDoc *)));
199 conf()->confWndMainWndSize(size()); 203 conf()->confWndMainWndSize(size());
200 //LR closing of windows changed 204 //LR closing of windows changed
201 //needed for fastload option on PDA 205 //needed for fastload option on PDA
202 //emit closed(this); 206 //emit closed(this);
203 //qDebug("PwM::~PwM() emited closed(this)"); 207 //qDebug("PwM::~PwM() emited closed(this)");
204 delete view; 208 delete view;
205 delete syncManager; 209 delete syncManager;
206} 210}
207 211
208void PwM::initMenubar() 212void PwM::initMenubar()
209{ 213{
210 KIconLoader* picons; 214 KIconLoader* picons;
211#ifndef PWM_EMBEDDED 215#ifndef PWM_EMBEDDED
212 KIconLoader icons; 216 KIconLoader icons;
213 picons = &icons; 217 picons = &icons;
214#else 218#else
215 picons = KGlobal::iconLoader(); 219 picons = KGlobal::iconLoader();
@@ -267,192 +271,198 @@ void PwM::initMenubar()
267 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), 271 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
268 i18n("E&xport"), exportPopup, 272 i18n("E&xport"), exportPopup,
269 BUTTON_POPUP_FILE_EXPORT); 273 BUTTON_POPUP_FILE_EXPORT);
270 // "file/import" popup menu 274 // "file/import" popup menu
271 importPopup->insertItem(i18n("&Text-file..."), this, 275 importPopup->insertItem(i18n("&Text-file..."), this,
272 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 276 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
273 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 277 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
274 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 278 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
275 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 279 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
276 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); 280 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV);
277#ifdef CONFIG_KWALLETIF 281#ifdef CONFIG_KWALLETIF
278 importPopup->insertItem(i18n("&KWallet..."), this, 282 importPopup->insertItem(i18n("&KWallet..."), this,
279 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 283 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
280#endif 284#endif
281 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), 285 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
282 i18n("I&mport"), importPopup, 286 i18n("I&mport"), importPopup,
283 BUTTON_POPUP_FILE_IMPORT); 287 BUTTON_POPUP_FILE_IMPORT);
284 filePopup->insertSeparator(); 288 filePopup->insertSeparator();
285 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), 289 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)),
286 i18n("&Print..."), this, 290 i18n("&Print..."), this,
287 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 291 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
288 filePopup->insertSeparator(); 292 filePopup->insertSeparator();
289 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), 293 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)),
290 i18n("&Quit"), this, 294 i18n("&Quit"), this,
291 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 295 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
292 menuBar()->insertItem(i18n("&File"), filePopup); 296 menuBar()->insertItem(i18n("&File"), filePopup);
293// "manage" popup menu 297// "manage" popup menu
294 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), 298 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
295 i18n("&Add password"), this, 299 i18n("&Add password"), this,
296 SLOT(addPwd_slot()), 0, 300 SLOT(addPwd_slot()), 0,
297 BUTTON_POPUP_MANAGE_ADD); 301 BUTTON_POPUP_MANAGE_ADD);
298 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), 302 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
299 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 303 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
300 BUTTON_POPUP_MANAGE_EDIT); 304 BUTTON_POPUP_MANAGE_EDIT);
301 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 305 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
302 i18n("&Delete"), this, SLOT(deletePwd_slot()), 306 i18n("&Delete"), this, SLOT(deletePwd_slot()),
303 0, BUTTON_POPUP_MANAGE_DEL); 307 0, BUTTON_POPUP_MANAGE_DEL);
304 managePopup->insertSeparator(); 308 managePopup->insertSeparator();
305 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), 309 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
306 i18n("Change &Master Password"), this, 310 i18n("Change &Master Password"), this,
307 SLOT(changeMasterPwd_slot()), 0, 311 SLOT(changeMasterPwd_slot()), 0,
308 BUTTON_POPUP_MANAGE_CHANGEMP); 312 BUTTON_POPUP_MANAGE_CHANGEMP);
309 menuBar()->insertItem(i18n("&Manage"), managePopup); 313 menuBar()->insertItem(i18n("&Manage"), managePopup);
310// "chipcard" popup menu 314// "chipcard" popup menu
311#ifdef CONFIG_KEYCARD 315#ifdef CONFIG_KEYCARD
312 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 316 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
313 i18n("&Generate new key-card"), this, 317 i18n("&Generate new key-card"), this,
314 SLOT(genNewCard_slot()), 0, 318 SLOT(genNewCard_slot()), 0,
315 BUTTON_POPUP_CHIPCARD_GENNEW); 319 BUTTON_POPUP_CHIPCARD_GENNEW);
316 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 320 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
317 i18n("&Erase key-card"), this, 321 i18n("&Erase key-card"), this,
318 SLOT(eraseCard_slot()), 0, 322 SLOT(eraseCard_slot()), 0,
319 BUTTON_POPUP_CHIPCARD_DEL); 323 BUTTON_POPUP_CHIPCARD_DEL);
320 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), 324 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
321 i18n("Read card-&ID"), this, 325 i18n("Read card-&ID"), this,
322 SLOT(readCardId_slot()), 0, 326 SLOT(readCardId_slot()), 0,
323 BUTTON_POPUP_CHIPCARD_READID); 327 BUTTON_POPUP_CHIPCARD_READID);
324 chipcardPopup->insertSeparator(); 328 chipcardPopup->insertSeparator();
325 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), 329 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
326 i18n("&Make card backup-image"), this, 330 i18n("&Make card backup-image"), this,
327 SLOT(makeCardBackup_slot()), 0, 331 SLOT(makeCardBackup_slot()), 0,
328 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 332 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
329 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), 333 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
330 i18n("&Replay card backup-image"), this, 334 i18n("&Replay card backup-image"), this,
331 SLOT(replayCardBackup_slot()), 0, 335 SLOT(replayCardBackup_slot()), 0,
332 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 336 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
333 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 337 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
334#endif // CONFIG_KEYCARD 338#endif // CONFIG_KEYCARD
335// "view" popup menu 339// "view" popup menu
336 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), 340 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
337 i18n("&Find"), this, 341 i18n("&Find"), this,
338 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 342 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
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);
387 397
388 helpPopup->insertItem(i18n("&What's New"), this, 398 helpPopup->insertItem(i18n("&What's New"), this,
389 SLOT(whatsnew_slot()), 0, 399 SLOT(whatsnew_slot()), 0,
390 BUTTON_POPUP_HELP_WHATSNEW); 400 BUTTON_POPUP_HELP_WHATSNEW);
391 401
392#endif 402#endif
393 menuBar()->insertItem(i18n("&Help"), helpPopup); 403 menuBar()->insertItem(i18n("&Help"), helpPopup);
394 404
395} 405}
396 406
397void PwM::initToolbar() 407void PwM::initToolbar()
398{ 408{
399 KIconLoader* picons; 409 KIconLoader* picons;
400#ifndef PWM_EMBEDDED 410#ifndef PWM_EMBEDDED
401 KIconLoader icons; 411 KIconLoader icons;
402 picons = &icons; 412 picons = &icons;
403#else 413#else
404 picons = KGlobal::iconLoader(); 414 picons = KGlobal::iconLoader();
405#endif 415#endif
406 416
407#ifdef PWM_EMBEDDED 417#ifdef PWM_EMBEDDED
408 if ( QApplication::desktop()->width() > 320 ) 418 if ( QApplication::desktop()->width() > 320 )
409#endif 419#endif
410 { 420 {
411 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), 421 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
412 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 422 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
413 SLOT(new_slot()), true, i18n("New")); 423 SLOT(new_slot()), true, i18n("New"));
414 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), 424 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
415 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 425 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
416 SLOT(open_slot()), true, i18n("Open")); 426 SLOT(open_slot()), true, i18n("Open"));
417 toolBar()->insertSeparator(); 427 toolBar()->insertSeparator();
418 } 428 }
419 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), 429 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
420 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 430 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
421 SLOT(save_slot()), true, i18n("Save")); 431 SLOT(save_slot()), true, i18n("Save"));
422 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), 432 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
423 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 433 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
424 SLOT(saveAs_slot()), true, i18n("Save as")); 434 SLOT(saveAs_slot()), true, i18n("Save as"));
425 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), 435 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
426 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 436 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
427 SLOT(print_slot()), true, i18n("Print...")); 437 SLOT(print_slot()), true, i18n("Print..."));
428 toolBar()->insertSeparator(); 438 toolBar()->insertSeparator();
429 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), 439 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
430 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, 440 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
431 SLOT(addPwd_slot()), true, 441 SLOT(addPwd_slot()), true,
432 i18n("Add password")); 442 i18n("Add password"));
433 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), 443 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
434 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 444 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
435 SLOT(editPwd_slot()), true, 445 SLOT(editPwd_slot()), true,
436 i18n("Edit password")); 446 i18n("Edit password"));
437 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), 447 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
438 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 448 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
439 SLOT(deletePwd_slot()), true, 449 SLOT(deletePwd_slot()), true,
440 i18n("Delete password")); 450 i18n("Delete password"));
441 toolBar()->insertSeparator(); 451 toolBar()->insertSeparator();
442 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), 452 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
443 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, 453 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
444 SLOT(find_slot()), true, i18n("Find entry")); 454 SLOT(find_slot()), true, i18n("Find entry"));
445 toolBar()->insertSeparator(); 455 toolBar()->insertSeparator();
446 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), 456 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
447 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 457 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
448 SLOT(lockWnd_slot()), true, 458 SLOT(lockWnd_slot()), true,
449 i18n("Lock all entries")); 459 i18n("Lock all entries"));
450 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), 460 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
451 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 461 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
452 SLOT(deepLockWnd_slot()), true, 462 SLOT(deepLockWnd_slot()), true,
453 i18n("Deep-Lock all entries")); 463 i18n("Deep-Lock all entries"));
454 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), 464 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
455 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 465 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
456 SLOT(unlockWnd_slot()), true, 466 SLOT(unlockWnd_slot()), true,
457 i18n("Unlock all entries")); 467 i18n("Unlock all entries"));
458} 468}
@@ -1298,181 +1308,240 @@ void PwM::eraseCard_slot()
1298{ 1308{
1299#ifdef CONFIG_KEYCARD 1309#ifdef CONFIG_KEYCARD
1300 init->keycard()->eraseCard(); 1310 init->keycard()->eraseCard();
1301#endif 1311#endif
1302} 1312}
1303 1313
1304void PwM::readCardId_slot() 1314void PwM::readCardId_slot()
1305{ 1315{
1306#ifdef CONFIG_KEYCARD 1316#ifdef CONFIG_KEYCARD
1307 init->keycard()->displayKey(); 1317 init->keycard()->displayKey();
1308#endif 1318#endif
1309} 1319}
1310 1320
1311void PwM::makeCardBackup_slot() 1321void PwM::makeCardBackup_slot()
1312{ 1322{
1313#ifdef CONFIG_KEYCARD 1323#ifdef CONFIG_KEYCARD
1314 init->keycard()->makeBackupImage(); 1324 init->keycard()->makeBackupImage();
1315#endif 1325#endif
1316} 1326}
1317 1327
1318void PwM::replayCardBackup_slot() 1328void PwM::replayCardBackup_slot()
1319{ 1329{
1320#ifdef CONFIG_KEYCARD 1330#ifdef CONFIG_KEYCARD
1321 init->keycard()->replayBackupImage(); 1331 init->keycard()->replayBackupImage();
1322#endif 1332#endif
1323} 1333}
1324 1334
1325void PwM::execLauncher_slot() 1335void PwM::execLauncher_slot()
1326{ 1336{
1327 PWM_ASSERT(curDoc()); 1337 PWM_ASSERT(curDoc());
1328 if (curDoc()->isDeepLocked()) 1338 if (curDoc()->isDeepLocked())
1329 return; 1339 return;
1330 unsigned int curEntryIndex; 1340 unsigned int curEntryIndex;
1331 if (!view->getCurEntryIndex(&curEntryIndex)) 1341 if (!view->getCurEntryIndex(&curEntryIndex))
1332 return; 1342 return;
1333 bool ret = curDoc()->execLauncher(view->getCurrentCategory(), 1343 bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
1334 curEntryIndex); 1344 curEntryIndex);
1335 if (ret) 1345 if (ret)
1336 showStatMsg(i18n("Executed the \"Launcher\".")); 1346 showStatMsg(i18n("Executed the \"Launcher\"."));
1337 else 1347 else
1338 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); 1348 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
1339} 1349}
1340 1350
1341void PwM::goToURL_slot() 1351void PwM::goToURL_slot()
1342{ 1352{
1343 PWM_ASSERT(curDoc()); 1353 PWM_ASSERT(curDoc());
1344 if (curDoc()->isDeepLocked()) 1354 if (curDoc()->isDeepLocked())
1345 return; 1355 return;
1346 unsigned int curEntryIndex; 1356 unsigned int curEntryIndex;
1347 if (!view->getCurEntryIndex(&curEntryIndex)) 1357 if (!view->getCurEntryIndex(&curEntryIndex))
1348 return; 1358 return;
1349 bool ret = curDoc()->goToURL(view->getCurrentCategory(), 1359 bool ret = curDoc()->goToURL(view->getCurrentCategory(),
1350 curEntryIndex); 1360 curEntryIndex);
1351 if (ret) 1361 if (ret)
1352 showStatMsg(i18n("started browser with current URL.")); 1362 showStatMsg(i18n("started browser with current URL."));
1353 else 1363 else
1354 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); 1364 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
1355} 1365}
1356 1366
1357void PwM::copyToClipboard(const QString &s) 1367void PwM::copyToClipboard(const QString &s)
1358{ 1368{
1359 QClipboard *cb = QApplication::clipboard(); 1369 QClipboard *cb = QApplication::clipboard();
1360#ifndef PWM_EMBEDDED 1370#ifndef PWM_EMBEDDED
1361 if (cb->supportsSelection()) 1371 if (cb->supportsSelection())
1362 cb->setText(s, QClipboard::Selection); 1372 cb->setText(s, QClipboard::Selection);
1363 cb->setText(s, QClipboard::Clipboard); 1373 cb->setText(s, QClipboard::Clipboard);
1364#else 1374#else
1365 cb->setText(s); 1375 cb->setText(s);
1366 1376
1367#endif 1377#endif
1368 1378
1369} 1379}
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;
1418#include <../version> 1487#include <../version>
1419; 1488;
1420 QMessageBox::about( this, "About PwManager/Pi", 1489 QMessageBox::about( this, "About PwManager/Pi",
1421 "PwManager/Platform-independent\n" 1490 "PwManager/Platform-independent\n"
1422 "(PWM/Pi) " +version + " - " + 1491 "(PWM/Pi) " +version + " - " +
1423#ifdef DESKTOP_VERSION 1492#ifdef DESKTOP_VERSION
1424 "Desktop Edition\n" 1493 "Desktop Edition\n"
1425#else 1494#else
1426 "PDA-Edition\n" 1495 "PDA-Edition\n"
1427 "for: Zaurus 5500 / 7x0 / 8x0\n" 1496 "for: Zaurus 5500 / 7x0 / 8x0\n"
1428#endif 1497#endif
1429 1498
1430 "(c) 2004 Ulf Schenk\n" 1499 "(c) 2004 Ulf Schenk\n"
1431 "(c) 2004 Lutz Rogowski\n" 1500 "(c) 2004 Lutz Rogowski\n"
1432 "(c) 1997-2004, The KDE PIM Team\n" 1501 "(c) 1997-2004, The KDE PIM Team\n"
1433 1502
1434 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" 1503 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n"
1435 "Matt Scifo - mscifo@o1.com\n" 1504 "Matt Scifo - mscifo@o1.com\n"
1436 "Elias Probst - elias.probst@gmx.de\n" 1505 "Elias Probst - elias.probst@gmx.de\n"
1437 "George Staikos - staikos@kde.org\n" 1506 "George Staikos - staikos@kde.org\n"
1438 "Matthew Palmer - mjp16@uow.edu.au\n" 1507 "Matthew Palmer - mjp16@uow.edu.au\n"
1439 "Olivier Sessink - gpasman@nl.linux.org\n" 1508 "Olivier Sessink - gpasman@nl.linux.org\n"
1440 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" 1509 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
1441 "Troy Engel - tengel@sonic.net\n" 1510 "Troy Engel - tengel@sonic.net\n"
1442 "Wickey - wickey@gmx.at\n" 1511 "Wickey - wickey@gmx.at\n"
1443 "Ian MacGregor - original documentation author.\n" 1512 "Ian MacGregor - original documentation author.\n"
1444 ); 1513 );
1445} 1514}
1446 1515
1447 1516
1448//this are the overwritten callbackmethods from the syncinterface 1517//this are the overwritten callbackmethods from the syncinterface
1449bool PwM::sync(KSyncManager* manager, QString filename, int mode) 1518bool PwM::sync(KSyncManager* manager, QString filename, int mode)
1450{ 1519{
1451 PWM_ASSERT(curDoc()); 1520 PWM_ASSERT(curDoc());
1452 1521
1453 bool ret = curDoc()->sync(manager, filename, mode); 1522 bool ret = curDoc()->sync(manager, filename, mode);
1454 1523
1455 qDebug("PwM::sync save now: ret=%i", ret); 1524 qDebug("PwM::sync save now: ret=%i", ret);
1456 1525
1457 if (ret == true) { 1526 if (ret == true) {
1458 //US BUG: what can we call here to update the view of the current doc? 1527 //US BUG: what can we call here to update the view of the current doc?
1459 //mViewManager->refreshView(); 1528 //mViewManager->refreshView();
1460 1529
1461 //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. 1530 //US curDoc()->sync sets the dirtyFlag in case the sync was successfull.
1462 save(); 1531 save();
1463 } 1532 }
1464 1533
1465 return ret; 1534 return ret;
1466} 1535}
1467 1536
1468void PwM::removeSyncInfo( QString syncProfile) 1537void PwM::removeSyncInfo( QString syncProfile)
1469{ 1538{
1470 qDebug("PWM::not implemented: removeSyncInfo for profile %s ", syncProfile.latin1()); 1539 qDebug("PWM::not implemented: removeSyncInfo for profile %s ", syncProfile.latin1());
1471} 1540}
1472 1541
1473#endif 1542#endif
1474 1543
1475 1544
1476#ifndef PWM_EMBEDDED 1545#ifndef PWM_EMBEDDED
1477#include "pwm.moc" 1546#include "pwm.moc"
1478#endif 1547#endif
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
@@ -86,192 +86,193 @@ public:
86 * and write the data to disk. 86 * and write the data to disk.
87 */ 87 */
88 bool save(); 88 bool save();
89 /** ask the user where to save the doc 89 /** ask the user where to save the doc
90 * and write the data to disk. 90 * and write the data to disk.
91 */ 91 */
92 bool saveAs(); 92 bool saveAs();
93 /** force quit. Quit this window, always! Don't minimize it */ 93 /** force quit. Quit this window, always! Don't minimize it */
94 bool isForceQuit() 94 bool isForceQuit()
95 { return forceQuit; } 95 { return forceQuit; }
96 /** set forceQuit */ 96 /** set forceQuit */
97 void setForceQuit(bool force) 97 void setForceQuit(bool force)
98 { forceQuit = force; } 98 { forceQuit = force; }
99 /** force minimize this window */ 99 /** force minimize this window */
100 bool isForceMinimizeToTray() 100 bool isForceMinimizeToTray()
101 { return forceMinimizeToTray; } 101 { return forceMinimizeToTray; }
102 /** set forceMinimizeToTray */ 102 /** set forceMinimizeToTray */
103 void setForceMinimizeToTray(bool force) 103 void setForceMinimizeToTray(bool force)
104 { forceMinimizeToTray = force; } 104 { forceMinimizeToTray = force; }
105 105
106public slots: 106public slots:
107 /** file/new triggered */ 107 /** file/new triggered */
108 void new_slot(); 108 void new_slot();
109 /** file/open triggered */ 109 /** file/open triggered */
110//US ENH 110//US ENH
111 void open_slot(); 111 void open_slot();
112 void open_slot(QString fn); 112 void open_slot(QString fn);
113 /** file/close triggered */ 113 /** file/close triggered */
114 void close_slot(); 114 void close_slot();
115 /** file/quit triggered */ 115 /** file/quit triggered */
116 void quitButton_slot(); 116 void quitButton_slot();
117 /** file/save triggered */ 117 /** file/save triggered */
118 void save_slot(); 118 void save_slot();
119 /** file/saveAs triggered */ 119 /** file/saveAs triggered */
120 void saveAs_slot(); 120 void saveAs_slot();
121 /** file/export/text triggered */ 121 /** file/export/text triggered */
122 void exportToText(); 122 void exportToText();
123 /** file/export/gpasman triggered */ 123 /** file/export/gpasman triggered */
124 void exportToGpasman(); 124 void exportToGpasman();
125 /** file/export/kwallet triggered */ 125 /** file/export/kwallet triggered */
126 void exportToKWallet(); 126 void exportToKWallet();
127 /** file/export/csv triggered */ 127 /** file/export/csv triggered */
128 void exportToCsv(); 128 void exportToCsv();
129 /** file/import/text triggered */ 129 /** file/import/text triggered */
130 bool importFromText(); 130 bool importFromText();
131 /** file/import/gpasman triggered */ 131 /** file/import/gpasman triggered */
132 bool importFromGpasman(); 132 bool importFromGpasman();
133 /** file/import/kwallet triggered */ 133 /** file/import/kwallet triggered */
134 bool importKWallet(); 134 bool importKWallet();
135 /** file/import/csv triggered */ 135 /** file/import/csv triggered */
136 bool importCsv(); 136 bool importCsv();
137 /** file/print triggered */ 137 /** file/print triggered */
138 void print_slot(); 138 void print_slot();
139 /** manage/add triggered */ 139 /** manage/add triggered */
140 //US ENH : changed code to run with older MOC 140 //US ENH : changed code to run with older MOC
141 141
142 void addPwd_slot(); 142 void addPwd_slot();
143 void addPwd_slot1(QString *pw, PwMDoc *_doc); 143 void addPwd_slot1(QString *pw, PwMDoc *_doc);
144 /** manage/edit triggered */ 144 /** manage/edit triggered */
145 //US ENH : changed code to run with older MOC 145 //US ENH : changed code to run with older MOC
146 void editPwd_slot(); 146 void editPwd_slot();
147 void editPwd_slot1(const QString *category); 147 void editPwd_slot1(const QString *category);
148 void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc ); 148 void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc );
149 149
150 /** manage/delete triggered */ 150 /** manage/delete triggered */
151 void deletePwd_slot(); 151 void deletePwd_slot();
152 /** execute the "Launcher" entry */ 152 /** execute the "Launcher" entry */
153 void execLauncher_slot(); 153 void execLauncher_slot();
154 /** open browser with URL entry */ 154 /** open browser with URL entry */
155 void goToURL_slot(); 155 void goToURL_slot();
156 /** manage/changeMasterPwd triggered */ 156 /** manage/changeMasterPwd triggered */
157 void changeMasterPwd_slot(); 157 void changeMasterPwd_slot();
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 */
206 void hideEvent(QHideEvent *); 207 void hideEvent(QHideEvent *);
207 /** is this window minimized? */ 208 /** is this window minimized? */
208 bool isMinimized() 209 bool isMinimized()
209 { 210 {
210#ifndef PWM_EMBEDDED 211#ifndef PWM_EMBEDDED
211 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) 212 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
212 return KWin::windowInfo(winId()).isMinimized(); 213 return KWin::windowInfo(winId()).isMinimized();
213 #else // KDE_VERSION 214 #else // KDE_VERSION
214 return KWin::info(winId()).isIconified(); 215 return KWin::info(winId()).isIconified();
215 #endif // KDE_VERSION 216 #endif // KDE_VERSION
216#else 217#else
217 return false; 218 return false;
218#endif 219#endif
219 } 220 }
220 /** window got the focus */ 221 /** window got the focus */
221 void focusInEvent(QFocusEvent *e); 222 void focusInEvent(QFocusEvent *e);
222 /** update the caption string */ 223 /** update the caption string */
223 void updateCaption(); 224 void updateCaption();
224#ifdef CONFIG_KWALLETIF 225#ifdef CONFIG_KWALLETIF
225 /** check if kwalletemu is enabled and ask the user what to do */ 226 /** check if kwalletemu is enabled and ask the user what to do */
226 bool checkAndAskForKWalletEmu(); 227 bool checkAndAskForKWalletEmu();
227#endif // CONFIG_KWALLETIF 228#endif // CONFIG_KWALLETIF
228 229
229protected slots: 230protected slots:
230 /** doc got closed */ 231 /** doc got closed */
231 void docClosed(PwMDoc *doc); 232 void docClosed(PwMDoc *doc);
232 233
233signals: 234signals:
234 /** window got closed (by user or someone else) */ 235 /** window got closed (by user or someone else) */
235 void closed(PwM *wnd); 236 void closed(PwM *wnd);
236 /** window got the focus (was brought to foreground) */ 237 /** window got the focus (was brought to foreground) */
237 void gotFocus(PwM *wnd); 238 void gotFocus(PwM *wnd);
238 /** window lost the focus */ 239 /** window lost the focus */
239 void lostFocus(PwM *wnd); 240 void lostFocus(PwM *wnd);
240 241
241protected: 242protected:
242 /** pointer to the view active in this KMainWindow */ 243 /** pointer to the view active in this KMainWindow */
243 PwMView *view; 244 PwMView *view;
244 /** pointer to the init class */ 245 /** pointer to the init class */
245 PwMInit *init; 246 PwMInit *init;
246 /** has this window already lost its virginity? 247 /** has this window already lost its virginity?
247 * Means is there an open working document 248 * Means is there an open working document
248 */ 249 */
249 bool virgin; 250 bool virgin;
250 /** "file" popup-menu */ 251 /** "file" popup-menu */
251 KPopupMenu *filePopup; 252 KPopupMenu *filePopup;
252 253
253 /** "manage" popup-menu */ 254 /** "manage" popup-menu */
254 KPopupMenu *managePopup; 255 KPopupMenu *managePopup;
255#ifdef CONFIG_KEYCARD 256#ifdef CONFIG_KEYCARD
256 /** "chipcard" popup-menu */ 257 /** "chipcard" popup-menu */
257 KPopupMenu *chipcardPopup; 258 KPopupMenu *chipcardPopup;
258#endif // CONFIG_KEYCARD 259#endif // CONFIG_KEYCARD
259 /** "view" popup-menu */ 260 /** "view" popup-menu */
260 KPopupMenu *viewPopup; 261 KPopupMenu *viewPopup;
261 /** "options" popup-menu */ 262 /** "options" popup-menu */
262 KPopupMenu *optionsPopup; 263 KPopupMenu *optionsPopup;
263 /** "help" popup-menu */ 264 /** "help" popup-menu */
264 KPopupMenu *helpPopup; 265 KPopupMenu *helpPopup;
265 /** "export" popup-menu */ 266 /** "export" popup-menu */
266 KPopupMenu *exportPopup; 267 KPopupMenu *exportPopup;
267 /** "import" popup-menu */ 268 /** "import" popup-menu */
268 KPopupMenu *importPopup; 269 KPopupMenu *importPopup;
269 /** force quit this window? */ 270 /** force quit this window? */
270 bool forceQuit; 271 bool forceQuit;
271 /** force minimize this window to the tray */ 272 /** force minimize this window to the tray */
272 bool forceMinimizeToTray; 273 bool forceMinimizeToTray;
273 274
274 275
275 276
276 277
277 private: 278 private:
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
@@ -1,175 +1,177 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_off 2 CONFIG += qt warn_off
3DESTDIR= ../../bin 3DESTDIR= ../../bin
4 TARGET = pwmpi 4 TARGET = pwmpi
5include( ../../variables.pri ) 5include( ../../variables.pri )
6 6
7INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils ../libcrypt/crypt ../libcrypt/error ../libcrypt/zlib 7INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils ../libcrypt/crypt ../libcrypt/error ../libcrypt/zlib
8DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION 8DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION
9 9
10#enable this setting if you want debugoutput for pwmanager 10#enable this setting if you want debugoutput for pwmanager
11#DEFINES += CONFIG_DEBUG 11#DEFINES += CONFIG_DEBUG
12LIBS += -L../libcrypt/ 12LIBS += -L../libcrypt/
13LIBS += -L../../bin/ 13LIBS += -L../../bin/
14LIBS += -lmicrokde 14LIBS += -lmicrokde
15LIBS += -lmicrokdepim 15LIBS += -lmicrokdepim
16LIBS += -lzlib 16LIBS += -lzlib
17LIBS += -lkpmicrocipher 17LIBS += -lkpmicrocipher
18LIBS += -lkpmicroerror 18LIBS += -lkpmicroerror
19LIBS += -lkpmicrompi 19LIBS += -lkpmicrompi
20LIBS += -lstdc++ 20LIBS += -lstdc++
21 21
22unix:{ 22unix:{
23OBJECTS_DIR = obj/unix 23OBJECTS_DIR = obj/unix
24MOC_DIR = moc/unix 24MOC_DIR = moc/unix
25 25
26} 26}
27win32:{ 27win32:{
28 28
29DEFINES += _WIN32_ 29DEFINES += _WIN32_
30OBJECTS_DIR = obj/win 30OBJECTS_DIR = obj/win
31MOC_DIR = moc/win 31MOC_DIR = moc/win
32QMAKE_LINK += /NODEFAULTLIB:LIBC 32QMAKE_LINK += /NODEFAULTLIB:LIBC
33QMAKE_CXXFLAGS += /TP /GX /GR /Ehsc 33QMAKE_CXXFLAGS += /TP /GX /GR /Ehsc
34} 34}
35 35
36#INTERFACES = \ 36#INTERFACES = \
37#addentrywnd.ui \ 37#addentrywnd.ui \
38#configwnd.ui \ 38#configwnd.ui \
39#findwnd.ui \ 39#findwnd.ui \
40#getmasterpwwnd.ui \ 40#getmasterpwwnd.ui \
41#pwgenwnd.ui \ 41#pwgenwnd.ui \
42#setmasterpwwnd.ui \ 42#setmasterpwwnd.ui \
43#subtbledit.ui 43#subtbledit.ui
44 44
45#INTERFACES = \ 45#INTERFACES = \
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 \
94pwmtray.h \ 95pwmtray.h \
95pwmview.h \ 96pwmview.h \
96pwmviewstyle_0.h \ 97pwmviewstyle_0.h \
97pwmviewstyle_1.h \ 98pwmviewstyle_1.h \
98pwmviewstyle.h \ 99pwmviewstyle.h \
99randomizer.h \ 100randomizer.h \
100rc2.h \ 101rc2.h \
101rencatwnd.h \ 102rencatwnd.h \
102serializer.h \ 103serializer.h \
103setmasterpwwnd_emb.h \ 104setmasterpwwnd_emb.h \
104setmasterpwwndimpl.h \ 105setmasterpwwndimpl.h \
105sha1.h \ 106sha1.h \
106waitwnd.h \ 107waitwnd.h \
107kcmconfigs/kcmpwmconfig.h \ 108kcmconfigs/kcmpwmconfig.h \
108kcmconfigs/pwmconfigwidget.h 109kcmconfigs/pwmconfigwidget.h
109 110
110#sources that need not be build 111#sources that need not be build
111#SOURCES = \ 112#SOURCES = \
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 \
160pwmviewstyle_0.cpp \ 162pwmviewstyle_0.cpp \
161pwmviewstyle_1.cpp \ 163pwmviewstyle_1.cpp \
162pwmviewstyle.cpp \ 164pwmviewstyle.cpp \
163randomizer.cpp \ 165randomizer.cpp \
164rc2.cpp \ 166rc2.cpp \
165rencatwnd.cpp \ 167rencatwnd.cpp \
166serializer.cpp \ 168serializer.cpp \
167setmasterpwwnd_emb.cpp \ 169setmasterpwwnd_emb.cpp \
168setmasterpwwndimpl.cpp \ 170setmasterpwwndimpl.cpp \
169sha1.cpp \ 171sha1.cpp \
170waitwnd.cpp \ 172waitwnd.cpp \
171kcmconfigs/kcmpwmconfig.cpp \ 173kcmconfigs/kcmpwmconfig.cpp \
172kcmconfigs/pwmconfigwidget.cpp 174kcmconfigs/pwmconfigwidget.cpp
173 175
174 176
175 177
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
@@ -1,173 +1,175 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 3
4 4
5 TARGET = pwmpi 5 TARGET = pwmpi
6OBJECTS_DIR = obj/$(PLATFORM) 6OBJECTS_DIR = obj/$(PLATFORM)
7MOC_DIR = moc/$(PLATFORM) 7MOC_DIR = moc/$(PLATFORM)
8DESTDIR=$(QPEDIR)/bin 8DESTDIR=$(QPEDIR)/bin
9 9
10INCLUDEPATH += . ../../ ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils ../libcrypt/crypt ../libcrypt/error $(QPEDIR)/include 10INCLUDEPATH += . ../../ ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils ../libcrypt/crypt ../libcrypt/error $(QPEDIR)/include
11DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY 11DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY
12 12
13#enable this setting if you want debugoutput for pwmanager 13#enable this setting if you want debugoutput for pwmanager
14#DEFINES += CONFIG_DEBUG 14#DEFINES += CONFIG_DEBUG
15 15
16LIBS += -L../libcrypt/$(PLATFORM) 16LIBS += -L../libcrypt/$(PLATFORM)
17LIBS += -lmicrokde 17LIBS += -lmicrokde
18LIBS += -lmicroqtcompat 18LIBS += -lmicroqtcompat
19LIBS += -lmicrokdepim 19LIBS += -lmicrokdepim
20LIBS += -L$(QPEDIR)/lib 20LIBS += -L$(QPEDIR)/lib
21LIBS += -lqpe 21LIBS += -lqpe
22LIBS += -lzlib 22LIBS += -lzlib
23#LIBS += -lbz2 23#LIBS += -lbz2
24#LIBS += -lkpmicrogcrypt 24#LIBS += -lkpmicrogcrypt
25LIBS += -ljpeg 25LIBS += -ljpeg
26LIBS += $(QTOPIALIB) 26LIBS += $(QTOPIALIB)
27LIBS += -lkpmicrocipher 27LIBS += -lkpmicrocipher
28LIBS += -lkpmicroerror 28LIBS += -lkpmicroerror
29LIBS += -lkpmicrompi 29LIBS += -lkpmicrompi
30LIBS += -lstdc++ 30LIBS += -lstdc++
31LIBS += $(GCC3EXTRALIB1) 31LIBS += $(GCC3EXTRALIB1)
32LIBS += $(GCC3EXTRALIB2) 32LIBS += $(GCC3EXTRALIB2)
33 33
34#INTERFACES = \ 34#INTERFACES = \
35#addentrywnd.ui \ 35#addentrywnd.ui \
36#configwnd.ui \ 36#configwnd.ui \
37#findwnd.ui \ 37#findwnd.ui \
38#getmasterpwwnd.ui \ 38#getmasterpwwnd.ui \
39#pwgenwnd.ui \ 39#pwgenwnd.ui \
40#setmasterpwwnd.ui \ 40#setmasterpwwnd.ui \
41#subtbledit.ui 41#subtbledit.ui
42 42
43#INTERFACES = \ 43#INTERFACES = \
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 \
92pwmtray.h \ 93pwmtray.h \
93pwmview.h \ 94pwmview.h \
94pwmviewstyle_0.h \ 95pwmviewstyle_0.h \
95pwmviewstyle_1.h \ 96pwmviewstyle_1.h \
96pwmviewstyle.h \ 97pwmviewstyle.h \
97randomizer.h \ 98randomizer.h \
98rc2.h \ 99rc2.h \
99rencatwnd.h \ 100rencatwnd.h \
100serializer.h \ 101serializer.h \
101setmasterpwwnd_emb.h \ 102setmasterpwwnd_emb.h \
102setmasterpwwndimpl.h \ 103setmasterpwwndimpl.h \
103sha1.h \ 104sha1.h \
104waitwnd.h \ 105waitwnd.h \
105kcmconfigs/kcmpwmconfig.h \ 106kcmconfigs/kcmpwmconfig.h \
106kcmconfigs/pwmconfigwidget.h 107kcmconfigs/pwmconfigwidget.h
107 108
108#sources that need not be build 109#sources that need not be build
109#SOURCES = \ 110#SOURCES = \
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 \
158pwmviewstyle_0.cpp \ 160pwmviewstyle_0.cpp \
159pwmviewstyle_1.cpp \ 161pwmviewstyle_1.cpp \
160pwmviewstyle.cpp \ 162pwmviewstyle.cpp \
161randomizer.cpp \ 163randomizer.cpp \
162rc2.cpp \ 164rc2.cpp \
163rencatwnd.cpp \ 165rencatwnd.cpp \
164serializer.cpp \ 166serializer.cpp \
165setmasterpwwnd_emb.cpp \ 167setmasterpwwnd_emb.cpp \
166setmasterpwwndimpl.cpp \ 168setmasterpwwndimpl.cpp \
167sha1.cpp \ 169sha1.cpp \
168waitwnd.cpp \ 170waitwnd.cpp \
169kcmconfigs/kcmpwmconfig.cpp \ 171kcmconfigs/kcmpwmconfig.cpp \
170kcmconfigs/pwmconfigwidget.cpp 172kcmconfigs/pwmconfigwidget.cpp
171 173
172 174
173 175
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
@@ -959,192 +959,195 @@ bool PwMDoc::copyFile(const QString &src, const QString &dst)
959 QFile srcFd(src); 959 QFile srcFd(src);
960 if (!srcFd.open(IO_ReadOnly)) 960 if (!srcFd.open(IO_ReadOnly))
961 return false; 961 return false;
962 QFile dstFd(dst); 962 QFile dstFd(dst);
963 if (!dstFd.open(IO_ReadWrite)) { 963 if (!dstFd.open(IO_ReadWrite)) {
964 srcFd.close(); 964 srcFd.close();
965 return false; 965 return false;
966 } 966 }
967 const int tmpBuf_size = 512; 967 const int tmpBuf_size = 512;
968 char tmpBuf[tmpBuf_size]; 968 char tmpBuf[tmpBuf_size];
969 Q_LONG bytesRead, bytesWritten; 969 Q_LONG bytesRead, bytesWritten;
970 970
971 while (!srcFd.atEnd()) { 971 while (!srcFd.atEnd()) {
972 bytesRead = srcFd.readBlock(tmpBuf, 972 bytesRead = srcFd.readBlock(tmpBuf,
973 static_cast<Q_ULONG>(tmpBuf_size)); 973 static_cast<Q_ULONG>(tmpBuf_size));
974 if (bytesRead == -1) { 974 if (bytesRead == -1) {
975 srcFd.close(); 975 srcFd.close();
976 dstFd.close(); 976 dstFd.close();
977 return false; 977 return false;
978 } 978 }
979 bytesWritten = dstFd.writeBlock(tmpBuf, 979 bytesWritten = dstFd.writeBlock(tmpBuf,
980 static_cast<Q_ULONG>(bytesRead)); 980 static_cast<Q_ULONG>(bytesRead));
981 if (bytesWritten != bytesRead) { 981 if (bytesWritten != bytesRead) {
982 srcFd.close(); 982 srcFd.close();
983 dstFd.close(); 983 dstFd.close();
984 return false; 984 return false;
985 } 985 }
986 } 986 }
987 srcFd.close(); 987 srcFd.close();
988 dstFd.close(); 988 dstFd.close();
989 return true; 989 return true;
990} 990}
991 991
992PwMerror PwMDoc::addEntry(const QString &category, PwMDataItem *d, 992PwMerror PwMDoc::addEntry(const QString &category, PwMDataItem *d,
993 bool dontFlagDirty, bool updateMeta) 993 bool dontFlagDirty, bool updateMeta)
994{ 994{
995 PWM_ASSERT(d); 995 PWM_ASSERT(d);
996 unsigned int cat = 0; 996 unsigned int cat = 0;
997 997
998 if (isDeepLocked()) { 998 if (isDeepLocked()) {
999 PwMerror ret; 999 PwMerror ret;
1000 ret = deepLock(false); 1000 ret = deepLock(false);
1001 if (ret != e_success) 1001 if (ret != e_success)
1002 return e_lock; 1002 return e_lock;
1003 } 1003 }
1004 1004
1005 addCategory(category, &cat); 1005 addCategory(category, &cat);
1006 1006
1007 if (numEntries(category) >= maxEntries) 1007 if (numEntries(category) >= maxEntries)
1008 return e_maxAllowedEntr; 1008 return e_maxAllowedEntr;
1009 1009
1010 vector<unsigned int> foundPositions; 1010 vector<unsigned int> foundPositions;
1011 /* historically this was: 1011 /* historically this was:
1012 *const int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | 1012 *const int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME |
1013 * SEARCH_IN_URL | SEARCH_IN_LAUNCHER; 1013 * SEARCH_IN_URL | SEARCH_IN_LAUNCHER;
1014 * But for now we only search in desc. 1014 * But for now we only search in desc.
1015 * That's a tweak to be KWallet compatible. But it should not add 1015 * That's a tweak to be KWallet compatible. But it should not add
1016 * usability-drop onto PwManager, does it? 1016 * usability-drop onto PwManager, does it?
1017 * (And yes, "int" was a bug. Correct is "unsigned int") 1017 * (And yes, "int" was a bug. Correct is "unsigned int")
1018 */ 1018 */
1019 const unsigned int searchIn = SEARCH_IN_DESC; 1019 const unsigned int searchIn = SEARCH_IN_DESC;
1020 findEntry(cat, *d, searchIn, &foundPositions, true); 1020 findEntry(cat, *d, searchIn, &foundPositions, true);
1021 if (foundPositions.size()) { 1021 if (foundPositions.size()) {
1022 // DOH! We found this entry. 1022 // DOH! We found this entry.
1023 return e_entryExists; 1023 return e_entryExists;
1024 } 1024 }
1025 1025
1026 d->listViewPos = -1; 1026 d->listViewPos = -1;
1027 d->lockStat = conf()->confGlobNewEntrLockStat(); 1027 d->lockStat = conf()->confGlobNewEntrLockStat();
1028 if (updateMeta) { 1028 if (updateMeta) {
1029 d->meta.create = QDateTime::currentDateTime(); 1029 d->meta.create = QDateTime::currentDateTime();
1030 d->meta.update = d->meta.create; 1030 d->meta.update = d->meta.create;
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)
1079 return false; 1082 return false;
1080 getDataChangedLock(); 1083 getDataChangedLock();
1081 if (!lockAt(category, index, false)) { 1084 if (!lockAt(category, index, false)) {
1082 putDataChangedLock(); 1085 putDataChangedLock();
1083 return false; 1086 return false;
1084 } 1087 }
1085 putDataChangedLock(); 1088 putDataChangedLock();
1086 int lvPos = dti.dta[category].d[index].listViewPos; 1089 int lvPos = dti.dta[category].d[index].listViewPos;
1087 1090
1088 // delete entry 1091 // delete entry
1089 dti.dta[category].d.erase(dti.dta[category].d.begin() + index); 1092 dti.dta[category].d.erase(dti.dta[category].d.begin() + index);
1090 1093
1091 unsigned int i, entries = numEntries(category); 1094 unsigned int i, entries = numEntries(category);
1092 if (!entries) { 1095 if (!entries) {
1093 // no more entries in this category, so 1096 // no more entries in this category, so
1094 // we can delete it, too. 1097 // we can delete it, too.
1095 BUG_ON(!delCategory(category)); 1098 BUG_ON(!delCategory(category));
1096 // delCategory() flags it dirty, so we need not to do so. 1099 // delCategory() flags it dirty, so we need not to do so.
1097 return true; 1100 return true;
1098 } 1101 }
1099 for (i = 0; i < entries; ++i) { 1102 for (i = 0; i < entries; ++i) {
1100 // decrement all listViewPositions that are greater than the deleted. 1103 // decrement all listViewPositions that are greater than the deleted.
1101 if (dti.dta[category].d[i].listViewPos > lvPos) 1104 if (dti.dta[category].d[i].listViewPos > lvPos)
1102 --dti.dta[category].d[i].listViewPos; 1105 --dti.dta[category].d[i].listViewPos;
1103 } 1106 }
1104 1107
1105 if (!dontFlagDirty) 1108 if (!dontFlagDirty)
1106 flagDirty(); 1109 flagDirty();
1107 return true; 1110 return true;
1108} 1111}
1109 1112
1110bool PwMDoc::editEntry(const QString &oldCategory, const QString &newCategory, 1113bool PwMDoc::editEntry(const QString &oldCategory, const QString &newCategory,
1111 unsigned int index, PwMDataItem *d, bool updateMeta) 1114 unsigned int index, PwMDataItem *d, bool updateMeta)
1112{ 1115{
1113 PWM_ASSERT(d); 1116 PWM_ASSERT(d);
1114 unsigned int oldCat = 0; 1117 unsigned int oldCat = 0;
1115 1118
1116 if (!findCategory(oldCategory, &oldCat)) { 1119 if (!findCategory(oldCategory, &oldCat)) {
1117 BUG(); 1120 BUG();
1118 return false; 1121 return false;
1119 } 1122 }
1120 1123
1121 return editEntry(oldCat, newCategory, index, d, updateMeta); 1124 return editEntry(oldCat, newCategory, index, d, updateMeta);
1122} 1125}
1123 1126
1124bool PwMDoc::editEntry(unsigned int oldCategory, const QString &newCategory, 1127bool PwMDoc::editEntry(unsigned int oldCategory, const QString &newCategory,
1125 unsigned int index, PwMDataItem *d, bool updateMeta) 1128 unsigned int index, PwMDataItem *d, bool updateMeta)
1126{ 1129{
1127 if (isDeepLocked()) 1130 if (isDeepLocked())
1128 return false; 1131 return false;
1129 if (updateMeta) { 1132 if (updateMeta) {
1130 d->meta.update = QDateTime::currentDateTime(); 1133 d->meta.update = QDateTime::currentDateTime();
1131 if (d->meta.create.isNull()) { 1134 if (d->meta.create.isNull()) {
1132 d->meta.create = d->meta.update; 1135 d->meta.create = d->meta.update;
1133 } 1136 }
1134 } 1137 }
1135 if (dti.dta[oldCategory].name != newCategory.latin1()) { 1138 if (dti.dta[oldCategory].name != newCategory.latin1()) {
1136 // the user changed the category. 1139 // the user changed the category.
1137 PwMerror ret; 1140 PwMerror ret;
1138 d->rev = 0; 1141 d->rev = 0;
1139 ret = addEntry(newCategory, d, true, false); 1142 ret = addEntry(newCategory, d, true, false);
1140 if (ret != e_success) 1143 if (ret != e_success)
1141 return false; 1144 return false;
1142 if (!delEntry(oldCategory, index, true)) 1145 if (!delEntry(oldCategory, index, true))
1143 return false; 1146 return false;
1144 } else { 1147 } else {
1145 d->rev = dti.dta[oldCategory].d[index].rev + 1; // increment revision counter. 1148 d->rev = dti.dta[oldCategory].d[index].rev + 1; // increment revision counter.
1146 dti.dta[oldCategory].d[index] = *d; 1149 dti.dta[oldCategory].d[index] = *d;
1147 } 1150 }
1148 flagDirty(); 1151 flagDirty();
1149 return true; 1152 return true;
1150} 1153}
@@ -1787,192 +1790,194 @@ bool PwMDoc::unlockAll_tempoary(bool revert)
1787 } 1790 }
1788 } 1791 }
1789 } 1792 }
1790 timer()->stop(DocTimer::id_autoLockTimer); 1793 timer()->stop(DocTimer::id_autoLockTimer);
1791 oldLockStates = new vector< vector<bool> >; 1794 oldLockStates = new vector< vector<bool> >;
1792 vector<bool> tmp_vec; 1795 vector<bool> tmp_vec;
1793 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), 1796 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
1794 catEnd = dti.dta.end(), 1797 catEnd = dti.dta.end(),
1795 catI = catBegin; 1798 catI = catBegin;
1796 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 1799 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
1797 while (catI != catEnd) { 1800 while (catI != catEnd) {
1798 entrBegin = catI->d.begin(); 1801 entrBegin = catI->d.begin();
1799 entrEnd = catI->d.end(); 1802 entrEnd = catI->d.end();
1800 entrI = entrBegin; 1803 entrI = entrBegin;
1801 while (entrI != entrEnd) { 1804 while (entrI != entrEnd) {
1802 if (!wasDeepLocked) { 1805 if (!wasDeepLocked) {
1803 tmp_vec.push_back(entrI->lockStat); 1806 tmp_vec.push_back(entrI->lockStat);
1804 } 1807 }
1805 entrI->lockStat = false; 1808 entrI->lockStat = false;
1806 ++entrI; 1809 ++entrI;
1807 } 1810 }
1808 if (!wasDeepLocked) { 1811 if (!wasDeepLocked) {
1809 oldLockStates->push_back(tmp_vec); 1812 oldLockStates->push_back(tmp_vec);
1810 tmp_vec.clear(); 1813 tmp_vec.clear();
1811 } 1814 }
1812 ++catI; 1815 ++catI;
1813 } 1816 }
1814 printDebug("tempoary unlocked dta."); 1817 printDebug("tempoary unlocked dta.");
1815 } 1818 }
1816 1819
1817 return true; 1820 return true;
1818} 1821}
1819 1822
1820PwMerror PwMDoc::deepLock(bool lock, bool saveToFile) 1823PwMerror PwMDoc::deepLock(bool lock, bool saveToFile)
1821{ 1824{
1822 PwMerror ret; 1825 PwMerror ret;
1823 /* NOTE: saveDoc() depends on this function to return 1826 /* NOTE: saveDoc() depends on this function to return
1824 * e_success if saveToFile == false 1827 * e_success if saveToFile == false
1825 */ 1828 */
1826 1829
1827 if (lock) { 1830 if (lock) {
1828 if (isDeepLocked()) 1831 if (isDeepLocked())
1829 return e_lock; 1832 return e_lock;
1830 if (saveToFile) { 1833 if (saveToFile) {
1831 if (isDocEmpty()) 1834 if (isDocEmpty())
1832 return e_docIsEmpty; 1835 return e_docIsEmpty;
1833 ret = saveDoc(conf()->confGlobCompression()); 1836 ret = saveDoc(conf()->confGlobCompression());
1834 if (ret == e_filename) { 1837 if (ret == e_filename) {
1835 /* the doc wasn't saved to a file 1838 /* the doc wasn't saved to a file
1836 * by the user, yet. 1839 * by the user, yet.
1837 */ 1840 */
1838 cantDeeplock_notSavedMsgBox(); 1841 cantDeeplock_notSavedMsgBox();
1839 return e_docNotSaved; 1842 return e_docNotSaved;
1840 } else if (ret != e_success) { 1843 } else if (ret != e_success) {
1841 return e_lock; 1844 return e_lock;
1842 } 1845 }
1843 } 1846 }
1844 timer()->stop(DocTimer::id_autoLockTimer); 1847 timer()->stop(DocTimer::id_autoLockTimer);
1845 clearDoc(); 1848 clearDoc();
1846 PwMDataItem d; 1849 PwMDataItem d;
1847 d.desc = IS_DEEPLOCKED_SHORTMSG.latin1(); 1850 d.desc = IS_DEEPLOCKED_SHORTMSG.latin1();
1848 d.comment = IS_DEEPLOCKED_MSG.latin1(); 1851 d.comment = IS_DEEPLOCKED_MSG.latin1();
1849 d.listViewPos = 0; 1852 d.listViewPos = 0;
1850 addEntry(DEFAULT_CATEGORY, &d, true); 1853 addEntry(DEFAULT_CATEGORY, &d, true);
1851 lockAt(DEFAULT_CATEGORY, 0, true); 1854 lockAt(DEFAULT_CATEGORY, 0, true);
1852 unsetDocStatFlag(DOC_STAT_DISK_DIRTY); 1855 unsetDocStatFlag(DOC_STAT_DISK_DIRTY);
1853 setDocStatFlag(DOC_STAT_DEEPLOCKED); 1856 setDocStatFlag(DOC_STAT_DEEPLOCKED);
1854 } else { 1857 } else {
1855 if (!isDeepLocked()) 1858 if (!isDeepLocked())
1856 return e_lock; 1859 return e_lock;
1857 ret = openDoc(&filename, (conf()->confGlobUnlockOnOpen()) 1860 ret = openDoc(&filename, (conf()->confGlobUnlockOnOpen())
1858 ? 0 : 1); 1861 ? 0 : 1);
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{
1907 unsigned int cat = 0; 1912 unsigned int cat = 0;
1908 1913
1909 if (!findCategory(category, &cat)) { 1914 if (!findCategory(category, &cat)) {
1910 BUG(); 1915 BUG();
1911 return; 1916 return;
1912 } 1917 }
1913 setListViewPos(cat, index, pos); 1918 setListViewPos(cat, index, pos);
1914} 1919}
1915 1920
1916void PwMDoc::setListViewPos(unsigned int category, unsigned int index, 1921void PwMDoc::setListViewPos(unsigned int category, unsigned int index,
1917 int pos) 1922 int pos)
1918{ 1923{
1919 dti.dta[category].d[index].listViewPos = pos; 1924 dti.dta[category].d[index].listViewPos = pos;
1920 1925
1921/* FIXME workaround: don't flag dirty, because this function sometimes 1926/* FIXME workaround: don't flag dirty, because this function sometimes
1922 * get's called when it shouldn't. It's because PwMView assumes 1927 * get's called when it shouldn't. It's because PwMView assumes
1923 * the user resorted the UI on behalf of signal layoutChanged(). 1928 * the user resorted the UI on behalf of signal layoutChanged().
1924 * This is somewhat broken and incorrect, but I've no other 1929 * This is somewhat broken and incorrect, but I've no other
1925 * solution for now. 1930 * solution for now.
1926 */ 1931 */
1927 //setDocStatFlag(DOC_STAT_DISK_DIRTY); 1932 //setDocStatFlag(DOC_STAT_DISK_DIRTY);
1928} 1933}
1929 1934
1930int PwMDoc::getListViewPos(const QString &category, unsigned int index) 1935int PwMDoc::getListViewPos(const QString &category, unsigned int index)
1931{ 1936{
1932 unsigned int cat = 0; 1937 unsigned int cat = 0;
1933 1938
1934 if (!findCategory(category, &cat)) { 1939 if (!findCategory(category, &cat)) {
1935 BUG(); 1940 BUG();
1936 return -1; 1941 return -1;
1937 } 1942 }
1938 1943
1939 return dti.dta[cat].d[index].listViewPos; 1944 return dti.dta[cat].d[index].listViewPos;
1940} 1945}
1941 1946
1942void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, 1947void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn,
1943 vector<unsigned int> *foundPositions, bool breakAfterFound, 1948 vector<unsigned int> *foundPositions, bool breakAfterFound,
1944 bool caseSensitive, bool exactWordMatch, bool sortByLvp) 1949 bool caseSensitive, bool exactWordMatch, bool sortByLvp)
1945{ 1950{
1946 PWM_ASSERT(foundPositions); 1951 PWM_ASSERT(foundPositions);
1947 PWM_ASSERT(searchIn); 1952 PWM_ASSERT(searchIn);
1948 foundPositions->clear(); 1953 foundPositions->clear();
1949 1954
1950 unsigned int i, entries = numEntries(category); 1955 unsigned int i, entries = numEntries(category);
1951 for (i = 0; i < entries; ++i) { 1956 for (i = 0; i < entries; ++i) {
1952 if (searchIn & SEARCH_IN_DESC) { 1957 if (searchIn & SEARCH_IN_DESC) {
1953 if (!compareString(find.desc, dti.dta[category].d[i].desc, 1958 if (!compareString(find.desc, dti.dta[category].d[i].desc,
1954 caseSensitive, exactWordMatch)) { 1959 caseSensitive, exactWordMatch)) {
1955 continue; 1960 continue;
1956 } 1961 }
1957 } 1962 }
1958 if (searchIn & SEARCH_IN_NAME) { 1963 if (searchIn & SEARCH_IN_NAME) {
1959 if (!compareString(find.name, dti.dta[category].d[i].name, 1964 if (!compareString(find.name, dti.dta[category].d[i].name,
1960 caseSensitive, exactWordMatch)) { 1965 caseSensitive, exactWordMatch)) {
1961 continue; 1966 continue;
1962 } 1967 }
1963 } 1968 }
1964 if (searchIn & SEARCH_IN_PW) { 1969 if (searchIn & SEARCH_IN_PW) {
1965 bool wasLocked = isLocked(category, i); 1970 bool wasLocked = isLocked(category, i);
1966 getDataChangedLock(); 1971 getDataChangedLock();
1967 lockAt(category, i, false); 1972 lockAt(category, i, false);
1968 if (!compareString(find.pw, dti.dta[category].d[i].pw, 1973 if (!compareString(find.pw, dti.dta[category].d[i].pw,
1969 caseSensitive, exactWordMatch)) { 1974 caseSensitive, exactWordMatch)) {
1970 lockAt(category, i, wasLocked); 1975 lockAt(category, i, wasLocked);
1971 putDataChangedLock(); 1976 putDataChangedLock();
1972 continue; 1977 continue;
1973 } 1978 }
1974 lockAt(category, i, wasLocked); 1979 lockAt(category, i, wasLocked);
1975 putDataChangedLock(); 1980 putDataChangedLock();
1976 } 1981 }
1977 if (searchIn & SEARCH_IN_COMMENT) { 1982 if (searchIn & SEARCH_IN_COMMENT) {
1978 if (!compareString(find.comment, dti.dta[category].d[i].comment, 1983 if (!compareString(find.comment, dti.dta[category].d[i].comment,
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
@@ -160,196 +160,205 @@ struct PwMDataItem
160 : lockStat (true) 160 : lockStat (true)
161 , listViewPos (-1) 161 , listViewPos (-1)
162 , binary (false) 162 , binary (false)
163 , rev (0) 163 , rev (0)
164 { } 164 { }
165 165
166 /** password description */ 166 /** password description */
167 stringdesc; 167 stringdesc;
168 /** user-name */ 168 /** user-name */
169 stringname; 169 stringname;
170 /** the password itself */ 170 /** the password itself */
171 stringpw; 171 stringpw;
172 /** some comment */ 172 /** some comment */
173 stringcomment; 173 stringcomment;
174 /** an URL string */ 174 /** an URL string */
175 stringurl; 175 stringurl;
176 /** launcher. Can be executed as a system() command */ 176 /** launcher. Can be executed as a system() command */
177 stringlauncher; 177 stringlauncher;
178 /** locking status. If locked (true), pw is not emitted through getEntry() */ 178 /** locking status. If locked (true), pw is not emitted through getEntry() */
179 boollockStat; 179 boollockStat;
180 /** position of this item in main "list-view" 180 /** position of this item in main "list-view"
181 * If -1, the position is not yet specified and should be appended to the list 181 * If -1, the position is not yet specified and should be appended to the list
182 */ 182 */
183 intlistViewPos; 183 intlistViewPos;
184 /** does this entry contain binary data? */ 184 /** does this entry contain binary data? */
185 bool binary; 185 bool binary;
186 /** meta data for this data item. */ 186 /** meta data for this data item. */
187 PwMMetaData meta; 187 PwMMetaData meta;
188 /** data revision counter. This counter can be used 188 /** data revision counter. This counter can be used
189 * to easily, efficiently determine if this data item 189 * to easily, efficiently determine if this data item
190 * has changed since some time. 190 * has changed since some time.
191 * This counter is incremented on every update. 191 * This counter is incremented on every update.
192 */ 192 */
193 unsigned int rev; 193 unsigned int rev;
194 194
195 void clear(bool clearMeta = true) 195 void clear(bool clearMeta = true)
196 { 196 {
197 /* NOTE: Don't use .clear() here to be 197 /* NOTE: Don't use .clear() here to be
198 * backward compatible with gcc-2 (Debian Woody) 198 * backward compatible with gcc-2 (Debian Woody)
199 */ 199 */
200 desc = ""; 200 desc = "";
201 name = ""; 201 name = "";
202 pw = ""; 202 pw = "";
203 comment = ""; 203 comment = "";
204 url = ""; 204 url = "";
205 launcher = ""; 205 launcher = "";
206 lockStat = true; 206 lockStat = true;
207 listViewPos = -1; 207 listViewPos = -1;
208 binary = false; 208 binary = false;
209 if (clearMeta) 209 if (clearMeta)
210 meta.clear(); 210 meta.clear();
211 } 211 }
212 //US ENH: we need this operator to compare two items if we have no unique ids 212 //US ENH: we need this operator to compare two items if we have no unique ids
213 //available. Generaly this happens before the first sync 213 //available. Generaly this happens before the first sync
214 214
215 bool PwMDataItem::operator==( const PwMDataItem &a ) const 215 bool PwMDataItem::operator==( const PwMDataItem &a ) const
216 { 216 {
217 //qDebug("oper==%s", a.desc.c_str()); 217 //qDebug("oper==%s", a.desc.c_str());
218 if ( desc != a.desc ) return false; 218 if ( desc != a.desc ) return false;
219 if ( name != a.name ) return false; 219 if ( name != a.name ) return false;
220 if ( pw != a.pw ) return false; 220 if ( pw != a.pw ) return false;
221 if ( comment != a.comment ) return false; 221 if ( comment != a.comment ) return false;
222 if ( url != a.url ) return false; 222 if ( url != a.url ) return false;
223 if ( launcher != a.launcher ) return false; 223 if ( launcher != a.launcher ) return false;
224 //all other field will not be checked. 224 //all other field will not be checked.
225 return true; 225 return true;
226 } 226 }
227 227
228 //US ENH: this sync method actually copies all values from the parameter like the =operator 228 //US ENH: this sync method actually copies all values from the parameter like the =operator
229 //does with two exceptions: listViewPos will not be changed, and the launcher only if required. 229 //does with two exceptions: listViewPos will not be changed, and the launcher only if required.
230 bool PwMDataItem::syncItem(const PwMDataItem &a, bool syncLauncher=true ) 230 bool PwMDataItem::syncItem(const PwMDataItem &a, bool syncLauncher=true )
231 { 231 {
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();
284 } 293 }
285}; 294};
286 295
287 296
288/** "Function Object" for sort()ing PwMDataItem::listViewPos */ 297/** "Function Object" for sort()ing PwMDataItem::listViewPos */
289class dta_lvp_greater 298class dta_lvp_greater
290{ 299{
291public: 300public:
292 bool operator() (const pair<unsigned int, unsigned int> &d1, 301 bool operator() (const pair<unsigned int, unsigned int> &d1,
293 const pair<unsigned int, unsigned int> &d2) 302 const pair<unsigned int, unsigned int> &d2)
294 { 303 {
295 return d1.second > d2.second; 304 return d1.second > d2.second;
296 } 305 }
297}; 306};
298 307
299/** list of PwMDoc documents and it's IDs */ 308/** list of PwMDoc documents and it's IDs */
300class PwMDocList 309class PwMDocList
301{ 310{
302public: 311public:
303 struct listItem 312 struct listItem
304 { 313 {
305 /** document filename (known as ID, here) */ 314 /** document filename (known as ID, here) */
306 string docId; 315 string docId;
307 /** pointer to the document class */ 316 /** pointer to the document class */
308 PwMDoc *doc; 317 PwMDoc *doc;
309 }; 318 };
310 319
311 PwMDocList() {} 320 PwMDocList() {}
312 321
313 /** add a new item to the list */ 322 /** add a new item to the list */
314 void add(PwMDoc *doc, const string &id); 323 void add(PwMDoc *doc, const string &id);
315 /** changes the contents of an existing item */ 324 /** changes the contents of an existing item */
316 void edit(PwMDoc *doc, const string &newId); 325 void edit(PwMDoc *doc, const string &newId);
317 /** remove the given item */ 326 /** remove the given item */
318 void del(PwMDoc *doc); 327 void del(PwMDoc *doc);
319 /** get the item at index */ 328 /** get the item at index */
320 listItem getAt(int index) 329 listItem getAt(int index)
321 { return docList[index]; } 330 { return docList[index]; }
322 /** find an entry with this id */ 331 /** find an entry with this id */
323 bool find(const string &id, listItem *ret = 0); 332 bool find(const string &id, listItem *ret = 0);
324 /** returns a copy of the list */ 333 /** returns a copy of the list */
325 const vector<listItem>* getList() const 334 const vector<listItem>* getList() const
326 { return &docList; } 335 { return &docList; }
327 336
328 337
329 /** returns a new unique number to extend the name of 338 /** returns a new unique number to extend the name of
330 * an unnamed document. 339 * an unnamed document.
331 */ 340 */
332 static unsigned int getNewUnnamedNumber() 341 static unsigned int getNewUnnamedNumber()
333 { return unnamedDocCnt++; } 342 { return unnamedDocCnt++; }
334 343
335protected: 344protected:
336 /* Hm, I think we shouldn't really use a "list" here, should we? 345 /* Hm, I think we shouldn't really use a "list" here, should we?
337 * So I decided to actually use a vector. 346 * So I decided to actually use a vector.
338 */ 347 */
339 vector<listItem> docList; 348 vector<listItem> docList;
340 /** This value is used to get a new number for yet unnamed 349 /** This value is used to get a new number for yet unnamed
341 * documents. It is incremented on every request. So it's 350 * documents. It is incremented on every request. So it's
342 * theoretically possible to overflow it, but... :) 351 * theoretically possible to overflow it, but... :)
343 */ 352 */
344 static unsigned int unnamedDocCnt; 353 static unsigned int unnamedDocCnt;
345}; 354};
346 355
347/** implements timers for the document */ 356/** implements timers for the document */
348class DocTimer : public QObject 357class DocTimer : public QObject
349{ 358{
350 Q_OBJECT 359 Q_OBJECT
351public: 360public:
352 enum TimerIDs 361 enum TimerIDs
353 { 362 {
354 id_mpwTimer, 363 id_mpwTimer,
355 id_autoLockTimer, 364 id_autoLockTimer,
@@ -692,118 +701,123 @@ protected:
692 /** pointer to the list-view, using this document. 701 /** pointer to the list-view, using this document.
693 * As there can only be one list-view per doc, we 702 * As there can only be one list-view per doc, we
694 * don't need a list here. 703 * don't need a list here.
695 */ 704 */
696 PwMView *listView; 705 PwMView *listView;
697 /** unnamedNum is used to store the "unnamed counter" 706 /** unnamedNum is used to store the "unnamed counter"
698 * for this document, while it's unnamed. If it's 0, 707 * for this document, while it's unnamed. If it's 0,
699 * we have to get a new unique one. 708 * we have to get a new unique one.
700 */ 709 */
701 unsigned int unnamedNum; 710 unsigned int unnamedNum;
702 /** is this doc going to be deleted (executing in destructor context) */ 711 /** is this doc going to be deleted (executing in destructor context) */
703 bool deleted; 712 bool deleted;
704 /** document timer */ 713 /** document timer */
705 DocTimer *_timer; 714 DocTimer *_timer;
706 /** lock counter for the "dataChanged" signal */ 715 /** lock counter for the "dataChanged" signal */
707 unsigned int dataChangedLock; 716 unsigned int dataChangedLock;
708 717
709 /** list of all open documents */ 718 /** list of all open documents */
710 static PwMDocList openDocList; 719 static PwMDocList openDocList;
711 720
712protected: 721protected:
713 /** serialize "dta" and return it in "d". */ 722 /** serialize "dta" and return it in "d". */
714 bool serializeDta(string *d); 723 bool serializeDta(string *d);
715 /** de-serialize "d" and overwrite "dta" */ 724 /** de-serialize "d" and overwrite "dta" */
716 bool deSerializeDta(const string *d, bool entriesLocked); 725 bool deSerializeDta(const string *d, bool entriesLocked);
717 /** write header to file */ 726 /** write header to file */
718 PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, 727 PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress,
719 QString *pw, QFile *f); 728 QString *pw, QFile *f);
720 /** write data-hash to file */ 729 /** write data-hash to file */
721 PwMerror writeDataHash(char dataHash, string *d, QFile *f); 730 PwMerror writeDataHash(char dataHash, string *d, QFile *f);
722 /** check header. Read header info and verify key-hash and filever. 731 /** check header. Read header info and verify key-hash and filever.
723 * returns length of header in "headerLength" */ 732 * returns length of header in "headerLength" */
724 PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress, 733 PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress,
725 unsigned int *headerLength, char *dataHashType, 734 unsigned int *headerLength, char *dataHashType,
726 string *dataHash, QFile *f); 735 string *dataHash, QFile *f);
727 /** check the data-hash */ 736 /** check the data-hash */
728 PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream); 737 PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream);
729 /** encrypt data "d" and write to "filename" */ 738 /** encrypt data "d" and write to "filename" */
730 PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo); 739 PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo);
731 /** read data from file beginning at "pos", decrypt and return it */ 740 /** read data from file beginning at "pos", decrypt and return it */
732 PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f); 741 PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f);
733 /** compress the data */ 742 /** compress the data */
734 bool compressDta(string *d, char algo); 743 bool compressDta(string *d, char algo);
735 /** uncompress the data */ 744 /** uncompress the data */
736 bool decompressDta(string *d, char algo); 745 bool decompressDta(string *d, char algo);
737 /** internal import function for a text-file generated by PwM. 746 /** internal import function for a text-file generated by PwM.
738 * If this is not a valid PwM-exported file, it returns e_fileFormat */ 747 * If this is not a valid PwM-exported file, it returns e_fileFormat */
739 PwMerror importText_PwM(const QString *file); 748 PwMerror importText_PwM(const QString *file);
740 /** PwM-text-import helper function to extract the name/pw/comment out 749 /** PwM-text-import helper function to extract the name/pw/comment out
741 * of one entry-line */ 750 * of one entry-line */
742 bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out); 751 bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out);
743 /** compare two strings */ 752 /** compare two strings */
744 bool compareString(const string &s1, const string &s2, bool caseSensitive, 753 bool compareString(const string &s1, const string &s2, bool caseSensitive,
745 bool exactWordMatch); 754 bool exactWordMatch);
746 /** clears all document-data */ 755 /** clears all document-data */
747 void clearDoc(); 756 void clearDoc();
748 /** delete all empty categories */ 757 /** delete all empty categories */
749 void delAllEmptyCat(bool dontFlagDirty); 758 void delAllEmptyCat(bool dontFlagDirty);
750 /** set a document status flag */ 759 /** set a document status flag */
751 void setDocStatFlag(unsigned int statFlag) 760 void setDocStatFlag(unsigned int statFlag)
752 { curDocStat |= statFlag; } 761 { curDocStat |= statFlag; }
753 /** unset a document status flag */ 762 /** unset a document status flag */
754 void unsetDocStatFlag(unsigned int statFlag) 763 void unsetDocStatFlag(unsigned int statFlag)
755 { curDocStat &= ~statFlag; } 764 { curDocStat &= ~statFlag; }
756 /** get a document status flag */ 765 /** get a document status flag */
757 bool getDocStatFlag(unsigned int statFlag) const 766 bool getDocStatFlag(unsigned int statFlag) const
758 { return (curDocStat & statFlag); } 767 { return (curDocStat & statFlag); }
759 /** set the "currentPassword" */ 768 /** set the "currentPassword" */
760 void setCurrentPw(const QString &pw) 769 void setCurrentPw(const QString &pw)
761 { 770 {
762 currentPw = pw; 771 currentPw = pw;
763 setDocStatFlag(DOC_STAT_DISK_DIRTY); 772 setDocStatFlag(DOC_STAT_DISK_DIRTY);
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
@@ -167,192 +167,202 @@ void PwMView::handleToggle(QListViewItem *item)
167{ 167{
168 PWM_ASSERT(doc); 168 PWM_ASSERT(doc);
169 if (!item) 169 if (!item)
170 return; 170 return;
171 QCheckListItem *clItem = (QCheckListItem *)item; 171 QCheckListItem *clItem = (QCheckListItem *)item;
172 QString curCat(getCurrentCategory()); 172 QString curCat(getCurrentCategory());
173 173
174 // find document position of this entry. 174 // find document position of this entry.
175 unsigned int curEntryDocIndex; 175 unsigned int curEntryDocIndex;
176 if (!getDocEntryIndex(&curEntryDocIndex, item)) 176 if (!getDocEntryIndex(&curEntryDocIndex, item))
177 return; 177 return;
178 178
179 // hack to refresh the comment, if only one item is present 179 // hack to refresh the comment, if only one item is present
180 if (lv->childCount() == 1) 180 if (lv->childCount() == 1)
181 refreshCommentTextEdit(lv->currentItem()); 181 refreshCommentTextEdit(lv->currentItem());
182 182
183 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn()) 183 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn())
184 return; // this is just a click somewhere on the entry 184 return; // this is just a click somewhere on the entry
185 if (doc->isDeepLocked()) { 185 if (doc->isDeepLocked()) {
186 PwMerror ret; 186 PwMerror ret;
187 ret = doc->deepLock(false); 187 ret = doc->deepLock(false);
188 if (ret != e_success) 188 if (ret != e_success)
189 clItem->setOn(false); 189 clItem->setOn(false);
190 return; 190 return;
191 } 191 }
192 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); 192 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn());
193} 193}
194 194
195void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) 195void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int)
196{ 196{
197 if (!item) 197 if (!item)
198 return; 198 return;
199 ctxMenu->move(point); 199 ctxMenu->move(point);
200 /* don't use ctxMenu->exec() here, as it generates race conditions 200 /* don't use ctxMenu->exec() here, as it generates race conditions
201 * with the card interface code. Believe it or not. :) 201 * with the card interface code. Believe it or not. :)
202 */ 202 */
203 ctxMenu->show(); 203 ctxMenu->show();
204} 204}
205 205
206void PwMView::updateCategories() 206void PwMView::updateCategories()
207{ 207{
208 QString oldSel(getCurrentCategory()); 208 QString oldSel(getCurrentCategory());
209 delAllCategories(); 209 delAllCategories();
210 QStringList catList; 210 QStringList catList;
211 document()->getCategoryList(&catList); 211 document()->getCategoryList(&catList);
212 catList.sort(); 212 catList.sort();
213#ifndef PWM_EMBEDDED 213#ifndef PWM_EMBEDDED
214 QStringList::iterator i = catList.begin(), 214 QStringList::iterator i = catList.begin(),
215 end = catList.end(); 215 end = catList.end();
216#else 216#else
217 QStringList::Iterator i = catList.begin(), 217 QStringList::Iterator i = catList.begin(),
218 end = catList.end(); 218 end = catList.end();
219#endif 219#endif
220 while (i != end) { 220 while (i != end) {
221 addCategory(*i); 221 addCategory(*i);
222 ++i; 222 ++i;
223 } 223 }
224 selectCategory(oldSel); 224 selectCategory(oldSel);
225} 225}
226 226
227void PwMView::shiftToView() 227void PwMView::shiftToView()
228{ 228{
229 int cX = lv->contentsX(); 229 int cX = lv->contentsX();
230 int cY = lv->contentsY(); 230 int cY = lv->contentsY();
231 commentBox->clear(); 231 commentBox->clear();
232 232
233 unsigned int catDocIndex; 233 unsigned int catDocIndex;
234 if (unlikely( 234 if (unlikely(
235 !(document()->findCategory(getCurrentCategory(), 235 !(document()->findCategory(getCurrentCategory(),
236 &catDocIndex)))) { 236 &catDocIndex)))) {
237 BUG(); 237 BUG();
238 } 238 }
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));
287 lv->insertItem(newItem); 297 lv->insertItem(newItem);
288 ++it; 298 ++it;
289 } 299 }
290 tmpReEnableSort(); 300 tmpReEnableSort();
291 301
292 if (cY || cX) 302 if (cY || cX)
293 lv->setContentsPos(cX, cY); 303 lv->setContentsPos(cX, cY);
294} 304}
295 305
296void PwMView::reorgLp() 306void PwMView::reorgLp()
297{ 307{
298 if (!lv->childCount()) 308 if (!lv->childCount())
299 return; 309 return;
300 PWM_ASSERT(doc); 310 PWM_ASSERT(doc);
301 PWM_ASSERT(!doc->isDocEmpty()); 311 PWM_ASSERT(!doc->isDocEmpty());
302 QListViewItem *currItem; 312 QListViewItem *currItem;
303 vector<unsigned int> foundPos; 313 vector<unsigned int> foundPos;
304 /* This searchIn _should_ be: 314 /* This searchIn _should_ be:
305 *const unsigned int searchIn = SEARCH_IN_DESC; 315 *const unsigned int searchIn = SEARCH_IN_DESC;
306 * But we want backward compatibility (see comment in PwMDoc::addEntry()). 316 * But we want backward compatibility (see comment in PwMDoc::addEntry()).
307 * So we need to search again, if we don't find the entry. (see below) 317 * So we need to search again, if we don't find the entry. (see below)
308 */ 318 */
309 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | 319 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME |
310 SEARCH_IN_URL | SEARCH_IN_LAUNCHER; 320 SEARCH_IN_URL | SEARCH_IN_LAUNCHER;
311 QString curCat(getCurrentCategory()); 321 QString curCat(getCurrentCategory());
312 PwMDataItem findThis; 322 PwMDataItem findThis;
313 unsigned int i, cnt = lv->childCount(); 323 unsigned int i, cnt = lv->childCount();
314 for (i = 0; i < cnt; ++i) { 324 for (i = 0; i < cnt; ++i) {
315 currItem = lv->itemAtIndex(i); 325 currItem = lv->itemAtIndex(i);
316 findThis.desc = currItem->text(COLUMN_DESC).latin1(); 326 findThis.desc = currItem->text(COLUMN_DESC).latin1();
317 findThis.name = currItem->text(COLUMN_NAME).latin1(); 327 findThis.name = currItem->text(COLUMN_NAME).latin1();
318 findThis.url = currItem->text(COLUMN_URL).latin1(); 328 findThis.url = currItem->text(COLUMN_URL).latin1();
319 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1(); 329 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1();
320 doc->findEntry(curCat, findThis, searchIn, 330 doc->findEntry(curCat, findThis, searchIn,
321 &foundPos, true); 331 &foundPos, true);
322 if (!foundPos.size()) { 332 if (!foundPos.size()) {
323 /* Did not find the entry. We seem to have a binary 333 /* Did not find the entry. We seem to have a binary
324 * entry here (pray for it!). So search again with 334 * entry here (pray for it!). So search again with
325 * the "correct" searchIn flags. 335 * the "correct" searchIn flags.
326 */ 336 */
327 const unsigned int searchIn2 = SEARCH_IN_DESC; 337 const unsigned int searchIn2 = SEARCH_IN_DESC;
328 doc->findEntry(curCat, findThis, searchIn2, 338 doc->findEntry(curCat, findThis, searchIn2,
329 &foundPos, true); 339 &foundPos, true);
330 if (unlikely(!foundPos.size())) { 340 if (unlikely(!foundPos.size())) {
331 BUG(); 341 BUG();
332 continue; 342 continue;
333 } 343 }
334 /* We assert that it's a binary entry, now. 344 /* We assert that it's a binary entry, now.
335 * No chance to efficiently verify it here. 345 * No chance to efficiently verify it here.
336 */ 346 */
337 } 347 }
338 doc->setListViewPos(curCat, foundPos[0], cnt - i - 1); 348 doc->setListViewPos(curCat, foundPos[0], cnt - i - 1);
339 } 349 }
340} 350}
341 351
342void PwMView::selAt(int index) 352void PwMView::selAt(int index)
343{ 353{
344 QListViewItem *item = lv->itemAtIndex(index); 354 QListViewItem *item = lv->itemAtIndex(index);
345 if (!item) 355 if (!item)
346 return; 356 return;
347 lv->setCurrentItem(item); 357 lv->setCurrentItem(item);
348 lv->ensureItemVisible(item); 358 lv->ensureItemVisible(item);
349} 359}
350 360
351void PwMView::renCatButton_slot() 361void PwMView::renCatButton_slot()
352{ 362{
353 if (doc->isDeepLocked()) 363 if (doc->isDeepLocked())
354 return; 364 return;
355 RenCatWnd wnd(this); 365 RenCatWnd wnd(this);
356 if (wnd.exec() == 1) { 366 if (wnd.exec() == 1) {
357 QString newName(wnd.getNewName()); 367 QString newName(wnd.getNewName());
358 if (newName == "") 368 if (newName == "")
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
@@ -1,388 +1,420 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12 12
13/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.1 of pwmanager 15 * This file is originaly based on version 1.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#include "serializer.h" 21#include "serializer.h"
22#include "pwmexception.h" 22#include "pwmexception.h"
23 23
24#ifdef PWM_EMBEDDED 24#ifdef PWM_EMBEDDED
25#include <kglobal.h> 25#include <kglobal.h>
26#include <klocale.h> 26#include <klocale.h>
27#endif 27#endif
28 28
29/* enable/disable serializer debugging (0/1) */ 29/* enable/disable serializer debugging (0/1) */
30 #define SERIALIZER_DEBUG0 30 #define SERIALIZER_DEBUG0
31/* use the old xml tags for writing (0/1) */ 31/* use the old xml tags for writing (0/1) */
32 #define USE_OLD_TAGS 0 32 #define USE_OLD_TAGS 0
33/* write a CDATA section (0/1) */ 33/* write a CDATA section (0/1) */
34 #define WRITE_CDATA_SEC 0 34 #define WRITE_CDATA_SEC 0
35 35
36 36
37 #define META_CREATE_DATE"c" 37 #define META_CREATE_DATE"c"
38 #define META_VALID_DATE "v" 38 #define META_VALID_DATE "v"
39 #define META_EXPIRE_DATE"e" 39 #define META_EXPIRE_DATE"e"
40 #define META_UPDATE_DATE"u" 40 #define META_UPDATE_DATE"u"
41 #define META_UPDATE_INT "i" 41 #define META_UPDATE_INT "i"
42//US ENH : uniqueid 42//US ENH : uniqueid 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
135Serializer::Serializer(const QCString &buffer) 149Serializer::Serializer(const QCString &buffer)
136{ 150{
137 defaultLockStat = true; 151 defaultLockStat = true;
138//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing 152//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
139#ifndef PWM_EMBEDDED 153#ifndef PWM_EMBEDDED
140 domDoc = new QDomDocument; 154 domDoc = new QDomDocument;
141#else 155#else
142 domDoc = new QDomDocument("mydoc"); 156 domDoc = new QDomDocument("mydoc");
143#endif 157#endif
144 158
145 if (!parseXml(buffer)) { 159 if (!parseXml(buffer)) {
146 delete domDoc; 160 delete domDoc;
147#ifndef PWM_EMBEDDED 161#ifndef PWM_EMBEDDED
148 throw PwMException(PwMException::EX_PARSE); 162 throw PwMException(PwMException::EX_PARSE);
149#else 163#else
150 qDebug("Serializer::Serializer : Parse Exception "); 164 qDebug("Serializer::Serializer : Parse Exception ");
151#endif 165#endif
152 } 166 }
153} 167}
154 168
155Serializer::~Serializer() 169Serializer::~Serializer()
156{ 170{
157 delete_ifnot_null(domDoc); 171 delete_ifnot_null(domDoc);
158} 172}
159 173
160void Serializer::clear() 174void Serializer::clear()
161{ 175{
162 delete_ifnot_null(domDoc); 176 delete_ifnot_null(domDoc);
163 domDoc = new QDomDocument; 177 domDoc = new QDomDocument;
164} 178}
165 179
166bool Serializer::parseXml(const QCString &buffer) 180bool Serializer::parseXml(const QCString &buffer)
167{ 181{
168 //abort(); 182 //abort();
169 //qDebug("parse %s ", buffer.data()); 183 //qDebug("parse %s ", buffer.data());
170 PWM_ASSERT(domDoc); 184 PWM_ASSERT(domDoc);
171#ifndef PWM_EMBEDDED 185#ifndef PWM_EMBEDDED
172 if (!domDoc->setContent(buffer, true)) 186 if (!domDoc->setContent(buffer, true))
173 return false; 187 return false;
174#else 188#else
175#ifdef DESKTOP_VERSION 189#ifdef DESKTOP_VERSION
176 if (!domDoc->setContent(buffer, true)) 190 if (!domDoc->setContent(buffer, true))
177#else 191#else
178 if (!domDoc->setContent(buffer)) 192 if (!domDoc->setContent(buffer))
179#endif 193#endif
180 return false; 194 return false;
181#endif 195#endif
182 if (!checkValid()) 196 if (!checkValid())
183 return false; 197 return false;
184 return true; 198 return true;
185} 199}
186 200
187QCString Serializer::getXml() 201QCString Serializer::getXml()
188{ 202{
189 PWM_ASSERT(domDoc); 203 PWM_ASSERT(domDoc);
190 204
191#ifndef PWM_EMBEDDED 205#ifndef PWM_EMBEDDED
192#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 206#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
193 QCString tmp(domDoc->toCString(8)); 207 QCString tmp(domDoc->toCString(8));
194 printDebug("<BEGIN Serializer::getXml() dump>\n"); 208 printDebug("<BEGIN Serializer::getXml() dump>\n");
195 cout << tmp << endl; 209 cout << tmp << endl;
196 printDebug("<END Serializer::getXml() dump>"); 210 printDebug("<END Serializer::getXml() dump>");
197#endif // DEBUG 211#endif // DEBUG
198 212
199 QCString ret(domDoc->toCString(0)); 213 QCString ret(domDoc->toCString(0));
200 ret.replace('\n', ""); 214 ret.replace('\n', "");
201 return ret; 215 return ret;
202#else 216#else
203 217
204#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 218#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
205 QCString tmp(" " + domDoc->toCString()); 219 QCString tmp(" " + domDoc->toCString());
206 printDebug("<BEGIN Serializer::getXml() dump>\n"); 220 printDebug("<BEGIN Serializer::getXml() dump>\n");
207 qDebug(tmp); 221 qDebug(tmp);
208 cout << tmp << endl; 222 cout << tmp << endl;
209 printDebug("<END Serializer::getXml() dump>"); 223 printDebug("<END Serializer::getXml() dump>");
210#endif // DEBUG 224#endif // DEBUG
211 225
212 QCString ret(domDoc->toCString()); 226 QCString ret(domDoc->toCString());
213 ret.replace(QRegExp("\n"), ""); 227 ret.replace(QRegExp("\n"), "");
214 return ret; 228 return ret;
215 229
216#endif 230#endif
217} 231}
218 232
219bool Serializer::serialize(PwMItem &dta) 233bool Serializer::serialize(PwMItem &dta)
220{ 234{
221 PWM_ASSERT(domDoc); 235 PWM_ASSERT(domDoc);
222 QDomElement root(genNewRoot()); 236 QDomElement root(genNewRoot());
223 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); 237 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR));
224 QDomElement syncNode(domDoc->createElement(SYNC_ROOT)); 238 QDomElement syncNode(domDoc->createElement(SYNC_ROOT));
225 if (!addSyncData(&syncNode, dta.syncDta)) 239 if (!addSyncData(&syncNode, dta.syncDta))
226 return false; 240 return false;
227 root.appendChild(syncNode); 241 root.appendChild(syncNode);
228 if (!addCategories(&catNode, dta.dta)) 242 if (!addCategories(&catNode, dta.dta))
229 return false; 243 return false;
230 root.appendChild(catNode); 244 root.appendChild(catNode);
231 return true; 245 return true;
232} 246}
233 247
234bool Serializer::deSerialize(PwMItem *dta) 248bool Serializer::deSerialize(PwMItem *dta)
235{ 249{
236 PWM_ASSERT(domDoc); 250 PWM_ASSERT(domDoc);
237 PWM_ASSERT(dta); 251 PWM_ASSERT(dta);
238 QDomElement root(domDoc->documentElement()); 252 QDomElement root(domDoc->documentElement());
239 QDomNode n; 253 QDomNode n;
240 254
241 dta->clear(); 255 dta->clear();
242 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { 256 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) {
243 // find <categories> ... </categories> 257 // find <categories> ... </categories>
244 // <c> ... </c> 258 // <c> ... </c>
245 if (n.nodeName() == CAT_ROOT_NEW || 259 if (n.nodeName() == CAT_ROOT_NEW ||
246 n.nodeName() == CAT_ROOT_OLD) { 260 n.nodeName() == CAT_ROOT_OLD) {
247 if (!readCategories(n, &(dta->dta))) { 261 if (!readCategories(n, &(dta->dta))) {
248 return false; 262 return false;
249 } 263 }
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);
317 349
318 dta->clear(); 350 dta->clear();
319 for (i = 0; i < numEntr; ++i) { 351 for (i = 0; i < numEntr; ++i) {
320 cur = nl.item(i); 352 cur = nl.item(i);
321 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW || 353 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW ||
322 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) { 354 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) {
323 if (!extractEntry(cur, &curEntr)) { 355 if (!extractEntry(cur, &curEntr)) {
324 return false; 356 return false;
325 } 357 }
326 dta->push_back(curEntr); 358 dta->push_back(curEntr);
327 } else { 359 } else {
328 printDebug("Serializer::readEntries(): hm? not an entry?"); 360 printDebug("Serializer::readEntries(): hm? not an entry?");
329 } 361 }
330 } 362 }
331 return true; 363 return true;
332} 364}
333 365
334bool Serializer::extractEntry(const QDomNode &n, 366bool Serializer::extractEntry(const QDomNode &n,
335 PwMDataItem *dta) 367 PwMDataItem *dta)
336{ 368{
337 QDomNodeList nl(n.childNodes()); 369 QDomNodeList nl(n.childNodes());
338 QDomNode cur, cdata; 370 QDomNode cur, cdata;
339 unsigned int cnt = nl.count(), i; 371 unsigned int cnt = nl.count(), i;
340 QString name, text; 372 QString name, text;
341 373
342 if (!cnt) { 374 if (!cnt) {
343 printDebug("Serializer::extractEntry(): empty"); 375 printDebug("Serializer::extractEntry(): empty");
344 return false; 376 return false;
345 } 377 }
346 dta->clear(); 378 dta->clear();
347 for (i = 0; i < cnt; ++i) { 379 for (i = 0; i < cnt; ++i) {
348 cur = nl.item(i); 380 cur = nl.item(i);
349 name = cur.nodeName(); 381 name = cur.nodeName();
350 cdata = cur.firstChild(); 382 cdata = cur.firstChild();
351 if (unlikely(cdata.isCDATASection())) { 383 if (unlikely(cdata.isCDATASection())) {
352 text = cdata.toCDATASection().data(); 384 text = cdata.toCDATASection().data();
353 } else if (likely(cur.isElement())) { 385 } else if (likely(cur.isElement())) {
354 text = cur.toElement().text(); 386 text = cur.toElement().text();
355 } else { 387 } else {
356 printDebug("Serializer::extractEntry(): neither CDATA nor element."); 388 printDebug("Serializer::extractEntry(): neither CDATA nor element.");
357 return false; 389 return false;
358 } 390 }
359 if (text == " ") 391 if (text == " ")
360 text = ""; // for backward compatibility. 392 text = ""; // for backward compatibility.
361 //qDebug("entry %s ",unescapeEntryData(text).latin1()); 393 //qDebug("entry %s ",unescapeEntryData(text).latin1());
362 if (name == ENTRY_DESC_NEW || 394 if (name == ENTRY_DESC_NEW ||
363 name == ENTRY_DESC_OLD) { 395 name == ENTRY_DESC_OLD) {
364 dta->desc = unescapeEntryData(text).latin1(); 396 dta->desc = unescapeEntryData(text).latin1();
365 } else if (name == ENTRY_NAME_NEW || 397 } else if (name == ENTRY_NAME_NEW ||
366 name == ENTRY_NAME_OLD) { 398 name == ENTRY_NAME_OLD) {
367 dta->name = unescapeEntryData(text).latin1(); 399 dta->name = unescapeEntryData(text).latin1();
368 } else if (name == ENTRY_PW_NEW || 400 } else if (name == ENTRY_PW_NEW ||
369 name == ENTRY_PW_OLD) { 401 name == ENTRY_PW_OLD) {
370 dta->pw = unescapeEntryData(text).latin1(); 402 dta->pw = unescapeEntryData(text).latin1();
371 } else if (name == ENTRY_COMMENT_NEW || 403 } else if (name == ENTRY_COMMENT_NEW ||
372 name == ENTRY_COMMENT_OLD) { 404 name == ENTRY_COMMENT_OLD) {
373 dta->comment = unescapeEntryData(text).latin1(); 405 dta->comment = unescapeEntryData(text).latin1();
374 } else if (name == ENTRY_URL_NEW || 406 } else if (name == ENTRY_URL_NEW ||
375 name == ENTRY_URL_OLD) { 407 name == ENTRY_URL_OLD) {
376 dta->url = unescapeEntryData(text).latin1(); 408 dta->url = unescapeEntryData(text).latin1();
377 } else if (name == ENTRY_LAUNCHER_NEW || 409 } else if (name == ENTRY_LAUNCHER_NEW ||
378 name == ENTRY_LAUNCHER_OLD) { 410 name == ENTRY_LAUNCHER_OLD) {
379 dta->launcher = unescapeEntryData(text).latin1(); 411 dta->launcher = unescapeEntryData(text).latin1();
380 } else if (name == ENTRY_LVP_NEW || 412 } else if (name == ENTRY_LVP_NEW ||
381 name == ENTRY_LVP_OLD) { 413 name == ENTRY_LVP_OLD) {
382 dta->listViewPos = strtol(text.latin1(), 0, 10); 414 dta->listViewPos = strtol(text.latin1(), 0, 10);
383 } else if (name == ENTRY_BIN_NEW) { 415 } else if (name == ENTRY_BIN_NEW) {
384 // ENTRY_BIN_NEW == ENTRY_BIN_OLD 416 // ENTRY_BIN_NEW == ENTRY_BIN_OLD
385 if (text == "0") { 417 if (text == "0") {
386 dta->binary = false; 418 dta->binary = false;
387 } else { 419 } else {
388 dta->binary = true; 420 dta->binary = true;
@@ -408,192 +440,202 @@ bool Serializer::extractMeta(const QDomNode &n,
408 while (!cur.isNull()) { 440 while (!cur.isNull()) {
409 name = cur.nodeName(); 441 name = cur.nodeName();
410 val = cur.toElement().text(); 442 val = cur.toElement().text();
411 if (val == "") { 443 if (val == "") {
412 cur = cur.nextSibling(); 444 cur = cur.nextSibling();
413 continue; 445 continue;
414 } 446 }
415 447
416 //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers. 448 //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers.
417 //because of that it is possible that here some values are not set, which means they are null. 449 //because of that it is possible that here some values are not set, which means they are null.
418 //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates. 450 //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates.
419 451
420 QDateTime dtval; //dtval should be invalid by definition. 452 QDateTime dtval; //dtval should be invalid by definition.
421 453
422 if ((name == META_CREATE_DATE) || 454 if ((name == META_CREATE_DATE) ||
423 (name == META_VALID_DATE) || 455 (name == META_VALID_DATE) ||
424 (name == META_EXPIRE_DATE) || 456 (name == META_EXPIRE_DATE) ||
425 (name == META_UPDATE_DATE)) 457 (name == META_UPDATE_DATE))
426 { 458 {
427 //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length()); 459 //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length());
428 460
429#ifndef PWM_EMBEDDED 461#ifndef PWM_EMBEDDED
430 dtval = QDateTime::fromString(val, Qt::ISODate); 462 dtval = QDateTime::fromString(val, Qt::ISODate);
431#else 463#else
432 bool ok; 464 bool ok;
433 dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); 465 dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
434 466
435 if (ok == false) 467 if (ok == false)
436 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); 468 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
437#endif 469#endif
438 470
439 //if the parsed data is wrong, dtval should be invalid at this time. 471 //if the parsed data is wrong, dtval should be invalid at this time.
440 472
441 } 473 }
442 474
443 if (name == META_CREATE_DATE) { 475 if (name == META_CREATE_DATE) {
444 dta->create = dtval; 476 dta->create = dtval;
445 } else if (name == META_VALID_DATE) { 477 } else if (name == META_VALID_DATE) {
446 dta->valid = dtval; 478 dta->valid = dtval;
447 } else if (name == META_EXPIRE_DATE) { 479 } else if (name == META_EXPIRE_DATE) {
448 dta->expire = dtval; 480 dta->expire = dtval;
449 } else if (name == META_UPDATE_DATE) { 481 } else if (name == META_UPDATE_DATE) {
450 dta->update = dtval; 482 dta->update = dtval;
451 } else if (name == META_UPDATE_INT) { 483 } else if (name == META_UPDATE_INT) {
452 dta->updateInt = strtoul(val.latin1(), 0, 10); 484 dta->updateInt = strtoul(val.latin1(), 0, 10);
453 } else if (name == META_UNIQUEID) { 485 } else if (name == META_UNIQUEID) {
454 dta->uniqueid = unescapeEntryData(val).latin1(); 486 dta->uniqueid = unescapeEntryData(val).latin1();
455 } else { 487 } else {
456 printDebug(string("extractMeta(): invalid: ") 488 printDebug(string("extractMeta(): invalid: ")
457 + name.latin1()); 489 + name.latin1());
458 } 490 }
459 491
460 cur = cur.nextSibling(); 492 cur = cur.nextSibling();
461 } 493 }
462 return true; 494 return true;
463} 495}
464 496
465bool Serializer::checkValid() 497bool Serializer::checkValid()
466{ 498{
467 PWM_ASSERT(domDoc); 499 PWM_ASSERT(domDoc);
468 QDomElement root(domDoc->documentElement()); 500 QDomElement root(domDoc->documentElement());
469 if (root.nodeName() != ROOT_MAGIC_NEW && 501 if (root.nodeName() != ROOT_MAGIC_NEW &&
470 root.nodeName() != ROOT_MAGIC_OLD) { 502 root.nodeName() != ROOT_MAGIC_OLD) {
471 printDebug("Serializer: wrong magic"); 503 printDebug("Serializer: wrong magic");
472 return false; 504 return false;
473 } 505 }
474 if (root.attribute(VER_STR_NEW) != COMPAT_VER_NEW && 506 if (root.attribute(VER_STR_NEW) != COMPAT_VER_NEW &&
475 root.attribute(VER_STR_OLD) != COMPAT_VER_OLD) { 507 root.attribute(VER_STR_OLD) != COMPAT_VER_OLD) {
476 printDebug("Serializer: wrong version"); 508 printDebug("Serializer: wrong version");
477 return false; 509 return false;
478 } 510 }
479 return true; 511 return true;
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 }
528 return true; 570 return true;
529} 571}
530 572
531bool Serializer::writeEntry(QDomElement *e, 573bool Serializer::writeEntry(QDomElement *e,
532 const PwMDataItem &_dta) 574 const PwMDataItem &_dta)
533{ 575{
534#if WRITE_CDATA_SEC != 0 576#if WRITE_CDATA_SEC != 0
535 # define new_text(x)domDoc->createCDATASection(x) 577 # define new_text(x)domDoc->createCDATASection(x)
536 QDomCDATASection curText; 578 QDomCDATASection curText;
537#else 579#else
538 # define new_text(x)domDoc->createTextNode(x) 580 # define new_text(x)domDoc->createTextNode(x)
539 QDomText curText; 581 QDomText curText;
540#endif 582#endif
541 583
542 QDomText plainText; 584 QDomText plainText;
543 QDomElement tag; 585 QDomElement tag;
544 586
545 // begin -- This is for compatibility with the old serializer 587 // begin -- This is for compatibility with the old serializer
546 PwMDataItem dta = _dta; 588 PwMDataItem dta = _dta;
547 if (!dta.desc.size()) 589 if (!dta.desc.size())
548 dta.desc = " "; 590 dta.desc = " ";
549 if (!dta.name.size()) 591 if (!dta.name.size())
550 dta.name = " "; 592 dta.name = " ";
551 if (!dta.pw.size()) 593 if (!dta.pw.size())
552 dta.pw = " "; 594 dta.pw = " ";
553 if (!dta.comment.size()) 595 if (!dta.comment.size())
554 dta.comment = " "; 596 dta.comment = " ";
555 if (!dta.url.size()) 597 if (!dta.url.size())
556 dta.url = " "; 598 dta.url = " ";
557 if (!dta.launcher.size()) 599 if (!dta.launcher.size())
558 dta.launcher = " "; 600 dta.launcher = " ";
559 // end -- This is for compatibility with the old serializer 601 // end -- This is for compatibility with the old serializer
560 602
561 tag = domDoc->createElement(ENTRY_DESC_WR); 603 tag = domDoc->createElement(ENTRY_DESC_WR);
562 curText = new_text(escapeEntryData(dta.desc.c_str())); 604 curText = new_text(escapeEntryData(dta.desc.c_str()));
563 tag.appendChild(curText); 605 tag.appendChild(curText);
564 e->appendChild(tag); 606 e->appendChild(tag);
565 607
566 tag = domDoc->createElement(ENTRY_NAME_WR); 608 tag = domDoc->createElement(ENTRY_NAME_WR);
567 curText = new_text(escapeEntryData(dta.name.c_str())); 609 curText = new_text(escapeEntryData(dta.name.c_str()));
568 tag.appendChild(curText); 610 tag.appendChild(curText);
569 e->appendChild(tag); 611 e->appendChild(tag);
570 612
571 tag = domDoc->createElement(ENTRY_PW_WR); 613 tag = domDoc->createElement(ENTRY_PW_WR);
572 curText = new_text(escapeEntryData(dta.pw.c_str())); 614 curText = new_text(escapeEntryData(dta.pw.c_str()));
573 tag.appendChild(curText); 615 tag.appendChild(curText);
574 e->appendChild(tag); 616 e->appendChild(tag);
575 617
576 tag = domDoc->createElement(ENTRY_COMMENT_WR); 618 tag = domDoc->createElement(ENTRY_COMMENT_WR);
577 curText = new_text(escapeEntryData(dta.comment.c_str())); 619 curText = new_text(escapeEntryData(dta.comment.c_str()));
578 tag.appendChild(curText); 620 tag.appendChild(curText);
579 e->appendChild(tag); 621 e->appendChild(tag);
580 622
581 tag = domDoc->createElement(ENTRY_URL_WR); 623 tag = domDoc->createElement(ENTRY_URL_WR);
582 curText = new_text(escapeEntryData(dta.url.c_str())); 624 curText = new_text(escapeEntryData(dta.url.c_str()));
583 tag.appendChild(curText); 625 tag.appendChild(curText);
584 e->appendChild(tag); 626 e->appendChild(tag);
585 627
586 tag = domDoc->createElement(ENTRY_LAUNCHER_WR); 628 tag = domDoc->createElement(ENTRY_LAUNCHER_WR);
587 curText = new_text(escapeEntryData(dta.launcher.c_str())); 629 curText = new_text(escapeEntryData(dta.launcher.c_str()));
588 tag.appendChild(curText); 630 tag.appendChild(curText);
589 e->appendChild(tag); 631 e->appendChild(tag);
590 632
591 tag = domDoc->createElement(ENTRY_LVP_WR); 633 tag = domDoc->createElement(ENTRY_LVP_WR);
592 plainText = domDoc->createTextNode(tostr(dta.listViewPos).c_str()); 634 plainText = domDoc->createTextNode(tostr(dta.listViewPos).c_str());
593 tag.appendChild(plainText); 635 tag.appendChild(plainText);
594 e->appendChild(tag); 636 e->appendChild(tag);
595 637
596 tag = domDoc->createElement(ENTRY_BIN_WR); 638 tag = domDoc->createElement(ENTRY_BIN_WR);
597 if (dta.binary) 639 if (dta.binary)
598 plainText = domDoc->createTextNode("1"); 640 plainText = domDoc->createTextNode("1");
599 else 641 else