summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-24 19:51:43 (UTC)
committer ulf69 <ulf69>2004-09-24 19:51:43 (UTC)
commita884dac6f756b3702a10ae97aa8782e4d2a84b20 (patch) (unidiff)
tree08e50146a3176848455db29e0c0ff0309c6f7b4c
parentae069aa892b29a96a923e49254cc89e65d0393eb (diff)
downloadkdepimpi-a884dac6f756b3702a10ae97aa8782e4d2a84b20.zip
kdepimpi-a884dac6f756b3702a10ae97aa8782e4d2a84b20.tar.gz
kdepimpi-a884dac6f756b3702a10ae97aa8782e4d2a84b20.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/addentrywnd_emb.cpp2
-rw-r--r--pwmanager/pwmanager/findwnd_emb.cpp123
-rw-r--r--pwmanager/pwmanager/findwnd_emb.h62
-rw-r--r--pwmanager/pwmanager/findwndimpl.cpp13
-rw-r--r--pwmanager/pwmanager/findwndimpl.h8
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.cpp86
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.h48
-rw-r--r--pwmanager/pwmanager/getmasterpwwndimpl.cpp14
-rw-r--r--pwmanager/pwmanager/getmasterpwwndimpl.h7
-rw-r--r--pwmanager/pwmanager/listviewpwm.cpp15
-rw-r--r--pwmanager/pwmanager/main.cpp2
-rw-r--r--pwmanager/pwmanager/pwgenwnd_emb.cpp3
-rw-r--r--pwmanager/pwmanager/pwm.cpp35
-rw-r--r--pwmanager/pwmanager/pwmanagerE.pro12
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp15
-rw-r--r--pwmanager/pwmanager/pwmviewstyle.cpp14
-rw-r--r--pwmanager/pwmanager/serializer.cpp2
-rw-r--r--pwmanager/pwmanager/setmasterpwwnd_emb.cpp163
-rw-r--r--pwmanager/pwmanager/setmasterpwwnd_emb.h62
-rw-r--r--pwmanager/pwmanager/setmasterpwwndimpl.cpp43
-rw-r--r--pwmanager/pwmanager/setmasterpwwndimpl.h8
21 files changed, 699 insertions, 38 deletions
diff --git a/pwmanager/pwmanager/addentrywnd_emb.cpp b/pwmanager/pwmanager/addentrywnd_emb.cpp
index 3a40cfc..ed02e6d 100644
--- a/pwmanager/pwmanager/addentrywnd_emb.cpp
+++ b/pwmanager/pwmanager/addentrywnd_emb.cpp
@@ -1,213 +1,213 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 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 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 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 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. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "addentrywnd_emb.h" 26#include "addentrywnd_emb.h"
27 27
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qgroupbox.h> 31#include <qgroupbox.h>
32#include <klocale.h> 32#include <klocale.h>
33#include <kcombobox.h> 33#include <kcombobox.h>
34#include <klineedit.h> 34#include <klineedit.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36 36
37/* 37/*
38 * Constructs a addEntryWnd as a child of 'parent', with the 38 * Constructs a addEntryWnd as a child of 'parent', with the
39 * name 'name' and widget flags set to 'f'. 39 * name 'name' and widget flags set to 'f'.
40 * 40 *
41 * The dialog will by default be modeless, unless you set 'modal' to 41 * The dialog will by default be modeless, unless you set 'modal' to
42 * TRUE to construct a modal dialog. 42 * TRUE to construct a modal dialog.
43 */ 43 */
44addEntryWnd::addEntryWnd( QWidget* parent, const char* name) 44addEntryWnd::addEntryWnd( QWidget* parent, const char* name)
45 : KDialogBase( KDialogBase::Plain, i18n( "Edit Password" ), 45 : KDialogBase( KDialogBase::Plain, i18n( "edit/add a password entry" ),
46 KDialogBase::Ok | KDialogBase::Cancel, 46 KDialogBase::Ok | KDialogBase::Cancel,
47 KDialogBase::Ok, parent, name, true ) 47 KDialogBase::Ok, parent, name, true )
48{ 48{
49 QWidget *page = plainPage(); 49 QWidget *page = plainPage();
50 QVBoxLayout *pageLayout = new QVBoxLayout( page ); 50 QVBoxLayout *pageLayout = new QVBoxLayout( page );
51 51
52 QTabWidget* mTabWidget = new QTabWidget( page ); 52 QTabWidget* mTabWidget = new QTabWidget( page );
53 pageLayout->addWidget( mTabWidget ); 53 pageLayout->addWidget( mTabWidget );
54 54
55 //////////////////////////////////////////////////////////////////// 55 ////////////////////////////////////////////////////////////////////
56 // This is the Password tab 56 // This is the Password tab
57 QWidget *tab1 = new QWidget( mTabWidget ); 57 QWidget *tab1 = new QWidget( mTabWidget );
58 58
59 QGridLayout *layout = new QGridLayout( tab1, 3, 1 ); 59 QGridLayout *layout = new QGridLayout( tab1, 3, 1 );
60 layout->setMargin( KDialogBase::marginHint() ); 60 layout->setMargin( KDialogBase::marginHint() );
61 layout->setSpacing( KDialogBase::spacingHint() ); 61 layout->setSpacing( KDialogBase::spacingHint() );
62 62
63 63
64 64
65 int i = 0; 65 int i = 0;
66 descLineEdit = new KLineEdit( tab1, "descLineEdit" ); 66 descLineEdit = new KLineEdit( tab1, "descLineEdit" );
67 QLabel* label = new QLabel( descLineEdit, i18n("Description:"), tab1 ); 67 QLabel* label = new QLabel( descLineEdit, i18n("Description:"), tab1 );
68 layout->addWidget( label, i, 0 ); 68 layout->addWidget( label, i, 0 );
69 layout->addWidget( descLineEdit, i, 1 ); 69 layout->addWidget( descLineEdit, i, 1 );
70 i++; 70 i++;
71 71
72 categoryComboBox = new KComboBox( tab1 ); 72 categoryComboBox = new KComboBox( tab1 );
73 label = new QLabel( categoryComboBox, i18n("Category:"), tab1 ); 73 label = new QLabel( categoryComboBox, i18n("Category:"), tab1 );
74 layout->addWidget( label, i, 0 ); 74 layout->addWidget( label, i, 0 );
75 layout->addWidget( categoryComboBox, i, 1 ); 75 layout->addWidget( categoryComboBox, i, 1 );
76 i++; 76 i++;
77 categoryComboBox->setEditable( TRUE ); 77 categoryComboBox->setEditable( TRUE );
78 categoryComboBox->setSizeLimit( 100 ); 78 categoryComboBox->setSizeLimit( 100 );
79 categoryComboBox->setAutoCompletion( TRUE ); 79 categoryComboBox->setAutoCompletion( TRUE );
80 categoryComboBox->setDuplicatesEnabled( FALSE ); 80 categoryComboBox->setDuplicatesEnabled( FALSE );
81 81
82 usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" ); 82 usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" );
83 label = new QLabel( usernameLineEdit, i18n("Username:"), tab1 ); 83 label = new QLabel( usernameLineEdit, i18n("Username:"), tab1 );
84 layout->addWidget( label, i, 0 ); 84 layout->addWidget( label, i, 0 );
85 layout->addWidget( usernameLineEdit, i, 1 ); 85 layout->addWidget( usernameLineEdit, i, 1 );
86 i++; 86 i++;
87 87
88 pwLineEdit = new KLineEdit( tab1, "pwLineEdit" ); 88 pwLineEdit = new KLineEdit( tab1, "pwLineEdit" );
89 pwLineEdit->setEchoMode( QLineEdit::Password ); 89 pwLineEdit->setEchoMode( QLineEdit::Password );
90 label = new QLabel( pwLineEdit, i18n("Password:"), tab1 ); 90 label = new QLabel( pwLineEdit, i18n("Password:"), tab1 );
91 layout->addWidget( label, i, 0 ); 91 layout->addWidget( label, i, 0 );
92 layout->addWidget( pwLineEdit, i, 1 ); 92 layout->addWidget( pwLineEdit, i, 1 );
93 i++; 93 i++;
94 94
95 revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" ); 95 revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" );
96 revealButton->setToggleButton( TRUE ); 96 revealButton->setToggleButton( TRUE );
97 layout->addWidget( revealButton, i, 0 ); 97 layout->addWidget( revealButton, i, 0 );
98 98
99 generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" ); 99 generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" );
100 layout->addWidget( generateButton, i, 1 ); 100 layout->addWidget( generateButton, i, 1 );
101 i++; 101 i++;
102 102
103 urlLineEdit = new KLineEdit( tab1, "urlLineEdit" ); 103 urlLineEdit = new KLineEdit( tab1, "urlLineEdit" );
104 label = new QLabel( urlLineEdit, i18n("URL:"), tab1 ); 104 label = new QLabel( urlLineEdit, i18n("URL:"), tab1 );
105 layout->addWidget( label, i, 0 ); 105 layout->addWidget( label, i, 0 );
106 layout->addWidget( urlLineEdit, i, 1 ); 106 layout->addWidget( urlLineEdit, i, 1 );
107 i++; 107 i++;
108 108
109 mTabWidget->addTab( tab1, i18n( "&Password" ) ); 109 mTabWidget->addTab( tab1, i18n( "&Password" ) );
110 110
111 111
112 //////////////////////////////////////////////////////////////////// 112 ////////////////////////////////////////////////////////////////////
113 // This is the Comment tab 113 // This is the Comment tab
114 QWidget *tab2 = new QWidget( mTabWidget ); 114 QWidget *tab2 = new QWidget( mTabWidget );
115 115
116 layout = new QGridLayout( tab2, 3, 1 ); 116 layout = new QGridLayout( tab2, 3, 1 );
117 layout->setMargin( KDialogBase::marginHintSmall() ); 117 layout->setMargin( KDialogBase::marginHintSmall() );
118 layout->setSpacing( KDialogBase::spacingHintSmall() ); 118 layout->setSpacing( KDialogBase::spacingHintSmall() );
119 i = 0; 119 i = 0;
120 120
121 121
122 122
123 groupBox1 = new QGroupBox( tab2, "groupBox1" ); 123 groupBox1 = new QGroupBox( tab2, "groupBox1" );
124 commentDummy = new QLabel( groupBox1, "commentDummy" ); 124 commentDummy = new QLabel( groupBox1, "commentDummy" );
125 commentDummy->setText( QString::null ); 125 commentDummy->setText( QString::null );
126 126
127 groupBox1->setTitle( i18n( "Comment:" ) ); 127 groupBox1->setTitle( i18n( "Comment:" ) );
128 128
129 layout->addMultiCellWidget( groupBox1, i, i, 0, 1 ); 129 layout->addMultiCellWidget( groupBox1, i, i, 0, 1 );
130 i++; 130 i++;
131 131
132 132
133 advancedCommentButton = new QPushButton( i18n("advanced comment"), groupBox1, "advancedCommentButton" ); 133 advancedCommentButton = new QPushButton( i18n("advanced comment"), groupBox1, "advancedCommentButton" );
134 advancedCommentButton->setToggleButton( FALSE ); 134 advancedCommentButton->setToggleButton( FALSE );
135 layout->addMultiCellWidget( advancedCommentButton, i, i, 0, 1 ); 135 layout->addMultiCellWidget( advancedCommentButton, i, i, 0, 1 );
136 i++; 136 i++;
137 137
138 138
139 mTabWidget->addTab( tab2, i18n( "&Comments" ) ); 139 mTabWidget->addTab( tab2, i18n( "&Comments" ) );
140 140
141 141
142 //////////////////////////////////////////////////////////////////// 142 ////////////////////////////////////////////////////////////////////
143 // This is the Launcher tab 143 // This is the Launcher tab
144 QWidget *tab3 = new QWidget( mTabWidget ); 144 QWidget *tab3 = new QWidget( mTabWidget );
145 145
146 layout = new QGridLayout( tab3, 3, 1 ); 146 layout = new QGridLayout( tab3, 3, 1 );
147 layout->setMargin( KDialogBase::marginHintSmall() ); 147 layout->setMargin( KDialogBase::marginHintSmall() );
148 layout->setSpacing( KDialogBase::spacingHintSmall() ); 148 layout->setSpacing( KDialogBase::spacingHintSmall() );
149 i = 0; 149 i = 0;
150 150
151 launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" ); 151 launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" );
152 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); 152 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 );
153 153
154 QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 ); 154 QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 );
155 QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 ); 155 QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 );
156 QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 ); 156 QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 );
157 QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 ); 157 QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 );
158 QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 ); 158 QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 );
159 159
160 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); 160 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 );
161 161
162 layout->addWidget( label1, i, 0 ); 162 layout->addWidget( label1, i, 0 );
163 layout->addWidget( label2, i, 1 ); 163 layout->addWidget( label2, i, 1 );
164 i++; 164 i++;
165 layout->addWidget( label3, i, 0 ); 165 layout->addWidget( label3, i, 0 );
166 layout->addWidget( label4, i, 1 ); 166 layout->addWidget( label4, i, 1 );
167 i++; 167 i++;
168 layout->addWidget( label5, i, 0 ); 168 layout->addWidget( label5, i, 0 );
169 i++; 169 i++;
170 170
171 layout->addWidget( label, i, 0 ); 171 layout->addWidget( label, i, 0 );
172 layout->addWidget( launcherLineEdit, i, 1 ); 172 layout->addWidget( launcherLineEdit, i, 1 );
173 i++; 173 i++;
174 174
175 175
176 mTabWidget->addTab( tab3, i18n( "&Launcher" ) ); 176 mTabWidget->addTab( tab3, i18n( "&Launcher" ) );
177 177
178 // signals and slots connections 178 // signals and slots connections
179 connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) ); 179 connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) );
180 connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) ); 180 connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) );
181 connect( advancedCommentButton, SIGNAL( toggled(bool) ), this, SLOT( advancedCommentButton_slot(bool) ) ); 181 connect( advancedCommentButton, SIGNAL( toggled(bool) ), this, SLOT( advancedCommentButton_slot(bool) ) );
182 182
183} 183}
184 184
185/* 185/*
186 * Destroys the object and frees any allocated resources 186 * Destroys the object and frees any allocated resources
187 */ 187 */
188addEntryWnd::~addEntryWnd() 188addEntryWnd::~addEntryWnd()
189{ 189{
190 // no need to delete child widgets, Qt does it all for us 190 // no need to delete child widgets, Qt does it all for us
191} 191}
192 192
193void addEntryWnd::slotOk() 193void addEntryWnd::slotOk()
194{ 194{
195 qWarning( "addEntryWnd::slotOk(): Not implemented yet" ); 195 qWarning( "addEntryWnd::slotOk(): Not implemented yet" );
196} 196}
197 197
198void addEntryWnd::revealButton_slot() 198void addEntryWnd::revealButton_slot()
199{ 199{
200 qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" ); 200 qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" );
201} 201}
202 202
203void addEntryWnd::generateButton_slot() 203void addEntryWnd::generateButton_slot()
204{ 204{
205 qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" ); 205 qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" );
206} 206}
207 207
208void addEntryWnd::advancedCommentButton_slot(bool) 208void addEntryWnd::advancedCommentButton_slot(bool)
209{ 209{
210 qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" ); 210 qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" );
211} 211}
212 212
213 213
diff --git a/pwmanager/pwmanager/findwnd_emb.cpp b/pwmanager/pwmanager/findwnd_emb.cpp
new file mode 100644
index 0000000..6db2684
--- a/dev/null
+++ b/pwmanager/pwmanager/findwnd_emb.cpp
@@ -0,0 +1,123 @@
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 "findwnd_emb.h"
27
28#include <klocale.h>
29
30#include <qcheckbox.h>
31#include <qbuttongroup.h>
32#include <qradiobutton.h>
33#include <qlayout.h>
34#include <klineedit.h>
35#include <qlabel.h>
36
37/*
38#include <qvariant.h>
39#include <qlabel.h>
40#include <qlineedit.h>
41#include <qpushbutton.h>
42#include <qcheckbox.h>
43#include <qbuttongroup.h>
44#include <qradiobutton.h>
45#include <qlayout.h>
46#include <qtooltip.h>
47#include <qwhatsthis.h>
48*/
49
50/*
51 * Constructs a findWnd as a child of 'parent', with the
52 * name 'name'.
53 */
54findWnd::findWnd( QWidget* parent, const char* name )
55 : KDialogBase( KDialogBase::Plain, i18n( "Find" ),
56 KDialogBase::Ok | KDialogBase::Cancel,
57 KDialogBase::Ok, parent, name, true )
58{
59 QWidget *page = plainPage();
60 QVBoxLayout *layout = new QVBoxLayout( page );
61 layout->setMargin( KDialogBase::marginHint() );
62 layout->setSpacing( KDialogBase::spacingHint() );
63
64 exactCheckBox = new QCheckBox( i18n( "&Exact match" ), page );
65 layout->addWidget( exactCheckBox );
66
67 caseSensCheckBox = new QCheckBox( i18n( "&Case sensitive" ), page );
68 layout->addWidget( caseSensCheckBox );
69
70
71 QButtonGroup* buttonGroup1 = new QButtonGroup(1, Qt::Horizontal, i18n( "Search in Column" ), page );
72 layout->addWidget( buttonGroup1 );
73
74 descRadioButton = new QRadioButton( i18n( "&Description" ), buttonGroup1 );
75 pwRadioButton = new QRadioButton( i18n( "&Password" ), buttonGroup1 );
76 commentRadioButton = new QRadioButton( i18n( "C&omment" ), buttonGroup1 );
77 nameRadioButton = new QRadioButton( i18n( "&Username" ), buttonGroup1 );
78 urlRadioButton = new QRadioButton( i18n( "U&RL" ), buttonGroup1 );
79 launcherRadioButton = new QRadioButton( i18n( "&Launcher" ), buttonGroup1 );
80 descRadioButton->setChecked( TRUE );
81
82 findLineEdit = new KLineEdit( page );
83 QLabel* label = new QLabel( findLineEdit, i18n( "Find:" ), page );
84 layout->addWidget( label );
85 layout->addWidget( findLineEdit );
86
87 setButtonText( KDialogBase::Ok, "&Find" );
88 setButtonText( KDialogBase::Cancel, "&Close" );
89
90
91 // resize( QSize(200, 150) );
92
93
94 connect( buttonGroup1, SIGNAL( clicked(int) ), this, SLOT( selectionChanged_slot() ) );
95 connect( findLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( selectionChanged_slot() ) );
96 connect( caseSensCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( selectionChanged_slot() ) );
97 connect( exactCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( selectionChanged_slot() ) );
98
99}
100
101/*
102 * Destroys the object and frees any allocated resources
103 */
104findWnd::~findWnd()
105{
106 // no need to delete child widgets, Qt does it all for us
107}
108
109void findWnd::findButton_slot()
110{
111 qWarning( "findWnd::findButton_slot(): Not implemented yet" );
112}
113
114void findWnd::selectionChanged_slot()
115{
116 qWarning( "findWnd::selectionChanged_slot(): Not implemented yet" );
117}
118
119void findWnd::closeButton_slot()
120{
121 qWarning( "findWnd::closeButton_slot(): Not implemented yet" );
122}
123
diff --git a/pwmanager/pwmanager/findwnd_emb.h b/pwmanager/pwmanager/findwnd_emb.h
new file mode 100644
index 0000000..9ad5a73
--- a/dev/null
+++ b/pwmanager/pwmanager/findwnd_emb.h
@@ -0,0 +1,62 @@
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
27#ifndef FINDWND_EMB_H
28#define FINDWND_EMB_H
29
30#include <kdialogbase.h>
31
32
33class QLineEdit;
34class QCheckBox;
35class QRadioButton;
36
37
38class findWnd : public KDialogBase
39{
40 Q_OBJECT
41
42public:
43 findWnd( QWidget* parent = 0, const char* name = 0 );
44 ~findWnd();
45
46 QLineEdit* findLineEdit;
47 QCheckBox* exactCheckBox;
48 QCheckBox* caseSensCheckBox;
49 QRadioButton* descRadioButton;
50 QRadioButton* pwRadioButton;
51 QRadioButton* commentRadioButton;
52 QRadioButton* nameRadioButton;
53 QRadioButton* urlRadioButton;
54 QRadioButton* launcherRadioButton;
55
56public slots:
57 virtual void findButton_slot();
58 virtual void selectionChanged_slot();
59 virtual void closeButton_slot();
60};
61
62#endif // FINDWND_H
diff --git a/pwmanager/pwmanager/findwndimpl.cpp b/pwmanager/pwmanager/findwndimpl.cpp
index fec1a6a..059219f 100644
--- a/pwmanager/pwmanager/findwndimpl.cpp
+++ b/pwmanager/pwmanager/findwndimpl.cpp
@@ -1,125 +1,138 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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 "findwndimpl.h" 20#include "findwndimpl.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "pwmdoc.h" 22#include "pwmdoc.h"
23#include "pwmview.h" 23#include "pwmview.h"
24 24
25#include <qradiobutton.h> 25#include <qradiobutton.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28 28
29#include <kmessagebox.h> 29#include <kmessagebox.h>
30#include <klocale.h> 30#include <klocale.h>
31 31
32FindWndImpl::FindWndImpl(PwMView * _parent) 32FindWndImpl::FindWndImpl(PwMView * _parent)
33 : findWnd() 33 : findWnd()
34{ 34{
35 parent = _parent; 35 parent = _parent;
36 fAt = 0; 36 fAt = 0;
37 refVal = 0; 37 refVal = 0;
38 currFoundPos = -1; 38 currFoundPos = -1;
39 numEntries = parent->document()->numEntries(parent->getCurrentCategory()); 39 numEntries = parent->document()->numEntries(parent->getCurrentCategory());
40 connect(this, SIGNAL(foundAt(int)), parent, SLOT(selAt(int))); 40 connect(this, SIGNAL(foundAt(int)), parent, SLOT(selAt(int)));
41} 41}
42 42
43FindWndImpl::~FindWndImpl() 43FindWndImpl::~FindWndImpl()
44{ 44{
45} 45}
46 46
47void FindWndImpl::findButton_slot() 47void FindWndImpl::findButton_slot()
48{ 48{
49 if (findLineEdit->text() == "") 49 if (findLineEdit->text() == "")
50 return; 50 return;
51 static vector<unsigned int> foundPositions; 51 static vector<unsigned int> foundPositions;
52 PwMDoc *doc = parent->document(); 52 PwMDoc *doc = parent->document();
53 53
54 if (currFoundPos < 0) { 54 if (currFoundPos < 0) {
55 bool unlockedTempoary = false; 55 bool unlockedTempoary = false;
56 foundPositions.clear(); 56 foundPositions.clear();
57 PwMDataItem findThis; 57 PwMDataItem findThis;
58 unsigned int searchIn = 0; 58 unsigned int searchIn = 0;
59 59
60 if (descRadioButton->isChecked()) { 60 if (descRadioButton->isChecked()) {
61 searchIn = SEARCH_IN_DESC; 61 searchIn = SEARCH_IN_DESC;
62 findThis.desc = findLineEdit->text().latin1(); 62 findThis.desc = findLineEdit->text().latin1();
63 } else if (nameRadioButton->isChecked()) { 63 } else if (nameRadioButton->isChecked()) {
64 searchIn = SEARCH_IN_NAME; 64 searchIn = SEARCH_IN_NAME;
65 findThis.name = findLineEdit->text().latin1(); 65 findThis.name = findLineEdit->text().latin1();
66 } else if (pwRadioButton->isChecked()) { 66 } else if (pwRadioButton->isChecked()) {
67 searchIn = SEARCH_IN_PW; 67 searchIn = SEARCH_IN_PW;
68 findThis.pw = findLineEdit->text().latin1(); 68 findThis.pw = findLineEdit->text().latin1();
69 } else if (commentRadioButton->isChecked()) { 69 } else if (commentRadioButton->isChecked()) {
70 searchIn = SEARCH_IN_COMMENT; 70 searchIn = SEARCH_IN_COMMENT;
71 findThis.comment = findLineEdit->text().latin1(); 71 findThis.comment = findLineEdit->text().latin1();
72 } else if (urlRadioButton->isChecked()) { 72 } else if (urlRadioButton->isChecked()) {
73 searchIn = SEARCH_IN_URL; 73 searchIn = SEARCH_IN_URL;
74 findThis.url = findLineEdit->text().latin1(); 74 findThis.url = findLineEdit->text().latin1();
75 } else if (launcherRadioButton->isChecked()) { 75 } else if (launcherRadioButton->isChecked()) {
76 searchIn = SEARCH_IN_LAUNCHER; 76 searchIn = SEARCH_IN_LAUNCHER;
77 findThis.launcher = findLineEdit->text().latin1(); 77 findThis.launcher = findLineEdit->text().latin1();
78 } 78 }
79 79
80 if (pwRadioButton->isChecked()) { 80 if (pwRadioButton->isChecked()) {
81 if (!doc->unlockAll_tempoary()) 81 if (!doc->unlockAll_tempoary())
82 return; 82 return;
83 unlockedTempoary = true; 83 unlockedTempoary = true;
84 } 84 }
85 doc->findEntry(parent->getCurrentCategory(), findThis, 85 doc->findEntry(parent->getCurrentCategory(), findThis,
86 searchIn, &foundPositions, false, 86 searchIn, &foundPositions, false,
87 caseSensCheckBox->isChecked(), 87 caseSensCheckBox->isChecked(),
88 exactCheckBox->isChecked(), 88 exactCheckBox->isChecked(),
89 true); 89 true);
90 if (unlockedTempoary) { 90 if (unlockedTempoary) {
91 doc->unlockAll_tempoary(true); 91 doc->unlockAll_tempoary(true);
92 } 92 }
93 93
94 if (!foundPositions.size()) { 94 if (!foundPositions.size()) {
95 KMessageBox::information(this, 95 KMessageBox::information(this,
96 i18n("No entry found."), 96 i18n("No entry found."),
97 i18n("not found")); 97 i18n("not found"));
98 return; 98 return;
99 } 99 }
100 currFoundPos = 0; 100 currFoundPos = 0;
101 } 101 }
102 102
103 int lvp = doc->getListViewPos(parent->getCurrentCategory(), 103 int lvp = doc->getListViewPos(parent->getCurrentCategory(),
104 foundPositions[currFoundPos++]); 104 foundPositions[currFoundPos++]);
105 emit foundAt(numEntries - 1 - lvp); 105 emit foundAt(numEntries - 1 - lvp);
106 106
107 if (currFoundPos + 1 > static_cast<int>(foundPositions.size())) 107 if (currFoundPos + 1 > static_cast<int>(foundPositions.size()))
108 currFoundPos = 0; 108 currFoundPos = 0;
109} 109}
110 110
111
112#ifdef PWM_EMBEDDED
113void FindWndImpl::slotOk()
114{
115 findButton_slot();
116
117 //do not call KDialogBase::slotOk() here
118 // user should press the close button instead
119}
120#endif
121
111void FindWndImpl::closeButton_slot() 122void FindWndImpl::closeButton_slot()
112{ 123{
124#ifndef PWM_EMBEDDED
113 done(0); 125 done(0);
126#endif
114} 127}
115 128
116void FindWndImpl::selectionChanged_slot() 129void FindWndImpl::selectionChanged_slot()
117{ 130{
118 fAt = 0; 131 fAt = 0;
119 refVal = 0; 132 refVal = 0;
120 currFoundPos = -1; 133 currFoundPos = -1;
121} 134}
122 135
123#ifndef PWM_EMBEDDED 136#ifndef PWM_EMBEDDED
124#include "findwndimpl.moc" 137#include "findwndimpl.moc"
125#endif 138#endif
diff --git a/pwmanager/pwmanager/findwndimpl.h b/pwmanager/pwmanager/findwndimpl.h
index d8cb65d..b601390 100644
--- a/pwmanager/pwmanager/findwndimpl.h
+++ b/pwmanager/pwmanager/findwndimpl.h
@@ -1,61 +1,69 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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#ifndef FINDWNDIMPL_H 20#ifndef FINDWNDIMPL_H
21#define FINDWNDIMPL_H 21#define FINDWNDIMPL_H
22 22
23#ifndef PWM_EMBEDDED
23#include "findwnd.h" 24#include "findwnd.h"
25#else
26#include "findwnd_emb.h"
27#endif
24 28
25class PwMView; 29class PwMView;
26 30
27/** "add" Window */ 31/** "add" Window */
28class FindWndImpl : public findWnd 32class FindWndImpl : public findWnd
29{ 33{
30 Q_OBJECT 34 Q_OBJECT
31public: 35public:
32 FindWndImpl(PwMView *_parent); 36 FindWndImpl(PwMView *_parent);
33 ~FindWndImpl(); 37 ~FindWndImpl();
34 38
35signals: 39signals:
36 void foundAt(int index); 40 void foundAt(int index);
37 41
38public slots: 42public slots:
39 /** find button pressed */ 43 /** find button pressed */
40 void findButton_slot(); 44 void findButton_slot();
41 /** close button pressed */ 45 /** close button pressed */
42 void closeButton_slot(); 46 void closeButton_slot();
43 /** selection of one of the radio buttons changed */ 47 /** selection of one of the radio buttons changed */
44 void selectionChanged_slot(); 48 void selectionChanged_slot();
45 49
50#ifdef PWM_EMBEDDED
51 virtual void slotOk();
52#endif
53
46protected: 54protected:
47 /** parent view */ 55 /** parent view */
48 PwMView *parent; 56 PwMView *parent;
49 /** entry found at */ 57 /** entry found at */
50 unsigned int fAt; 58 unsigned int fAt;
51 /** reference value */ 59 /** reference value */
52 unsigned int refVal; 60 unsigned int refVal;
53 /** current position in the found-items-vector */ 61 /** current position in the found-items-vector */
54 int currFoundPos; 62 int currFoundPos;
55 /** the number of entries in the current category */ 63 /** the number of entries in the current category */
56 unsigned int numEntries; 64 unsigned int numEntries;
57 /** index number of the current category */ 65 /** index number of the current category */
58 unsigned int catIndex; 66 unsigned int catIndex;
59}; 67};
60 68
61#endif 69#endif
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
new file mode 100644
index 0000000..3519de8
--- a/dev/null
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
@@ -0,0 +1,86 @@
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 "getmasterpwwnd_emb.h"
27
28#include "klocale.h"
29/*
30#include <qvariant.h>
31#include <qpushbutton.h>
32#include <qlabel.h>
33#include <qlineedit.h>
34#include <qlayout.h>
35#include <qtooltip.h>
36#include <qwhatsthis.h>
37*/
38
39#include <qwidget.h>
40#include <qlayout.h>
41#include <qlabel.h>
42#include <qlineedit.h>
43
44/*
45 * Constructs a getMasterPwWnd as a child of 'parent', with the
46 * name 'name'
47 */
48getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name)
49 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ),
50 KDialogBase::Ok | KDialogBase::Cancel,
51 KDialogBase::Ok, parent, name, true )
52{
53 QWidget *page = plainPage();
54 QVBoxLayout *pageLayout = new QVBoxLayout( page );
55
56 pwLineEdit = new QLineEdit( page, "pwLineEdit" );
57 pwLineEdit->setEchoMode( QLineEdit::Password );
58
59 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" );
60 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
61 pageLayout->addWidget(textLabel1);
62 pageLayout->addWidget(pwLineEdit);
63
64
65 resize( QSize(200, 100) );
66
67}
68
69/*
70 * Destroys the object and frees any allocated resources
71 */
72getMasterPwWnd::~getMasterPwWnd()
73{
74 // no need to delete child widgets, Qt does it all for us
75}
76
77void getMasterPwWnd::okButton_slot()
78{
79 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" );
80}
81
82void getMasterPwWnd::cancelButton_slot()
83{
84 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" );
85}
86
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.h b/pwmanager/pwmanager/getmasterpwwnd_emb.h
new file mode 100644
index 0000000..64121c4
--- a/dev/null
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.h
@@ -0,0 +1,48 @@
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 GETMASTERPWWND_EMB_H
27#define GETMASTERPWWND_EMB_H
28
29#include <kdialogbase.h>
30
31class QLineEdit;
32
33class getMasterPwWnd : public KDialogBase
34{
35 Q_OBJECT
36
37public:
38 getMasterPwWnd( QWidget* parent = 0, const char* name = 0);
39 ~getMasterPwWnd();
40
41 QLineEdit* pwLineEdit;
42
43public slots:
44 virtual void okButton_slot();
45 virtual void cancelButton_slot();
46};
47
48#endif // GETMASTERPWWND_H
diff --git a/pwmanager/pwmanager/getmasterpwwndimpl.cpp b/pwmanager/pwmanager/getmasterpwwndimpl.cpp
index db0223e..6be9618 100644
--- a/pwmanager/pwmanager/getmasterpwwndimpl.cpp
+++ b/pwmanager/pwmanager/getmasterpwwndimpl.cpp
@@ -1,46 +1,60 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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 "getmasterpwwndimpl.h" 20#include "getmasterpwwndimpl.h"
21 21
22#include <qlineedit.h> 22#include <qlineedit.h>
23 23
24GetMasterPwWndImpl::GetMasterPwWndImpl(QWidget * parent, const char *name) 24GetMasterPwWndImpl::GetMasterPwWndImpl(QWidget * parent, const char *name)
25: getMasterPwWnd(parent, name) 25: getMasterPwWnd(parent, name)
26{ 26{
27} 27}
28 28
29GetMasterPwWndImpl::~GetMasterPwWndImpl() 29GetMasterPwWndImpl::~GetMasterPwWndImpl()
30{ 30{
31} 31}
32 32
33void GetMasterPwWndImpl::okButton_slot() 33void GetMasterPwWndImpl::okButton_slot()
34{ 34{
35#ifndef PWM_EMBEDDED
35 if (pwLineEdit->text() != "") 36 if (pwLineEdit->text() != "")
36 done(1); 37 done(1);
38#endif
37} 39}
38 40
39void GetMasterPwWndImpl::cancelButton_slot() 41void GetMasterPwWndImpl::cancelButton_slot()
40{ 42{
43#ifndef PWM_EMBEDDED
41 done(2); 44 done(2);
45#endif
46}
47
48#ifdef PWM_EMBEDDED
49void GetMasterPwWndImpl::slotOk()
50{
51 if (pwLineEdit->text() != "")
52 getMasterPwWnd::slotOk();
53 else
54 return;
42} 55}
56#endif
43 57
44#ifndef PWM_EMBEDDED 58#ifndef PWM_EMBEDDED
45#include "getmasterpwwndimpl.moc" 59#include "getmasterpwwndimpl.moc"
46#endif 60#endif
diff --git a/pwmanager/pwmanager/getmasterpwwndimpl.h b/pwmanager/pwmanager/getmasterpwwndimpl.h
index 28aa427..8a4c03e 100644
--- a/pwmanager/pwmanager/getmasterpwwndimpl.h
+++ b/pwmanager/pwmanager/getmasterpwwndimpl.h
@@ -1,40 +1,47 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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#ifndef GETMASTERPWWNDIMPL_H 20#ifndef GETMASTERPWWNDIMPL_H
21#define GETMASTERPWWNDIMPL_H 21#define GETMASTERPWWNDIMPL_H
22 22
23#ifndef PWM_EMBEDDED
23#include "getmasterpwwnd.h" 24#include "getmasterpwwnd.h"
25#else
26#include "getmasterpwwnd_emb.h"
27#endif
24 28
25/** set master pw wnd */ 29/** set master pw wnd */
26class GetMasterPwWndImpl : public getMasterPwWnd 30class GetMasterPwWndImpl : public getMasterPwWnd
27{ 31{
28 Q_OBJECT 32 Q_OBJECT
29public: 33public:
30 GetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0); 34 GetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0);
31 ~GetMasterPwWndImpl(); 35 ~GetMasterPwWndImpl();
32 36
33public slots: 37public slots:
34 /** ok button pressed */ 38 /** ok button pressed */
35 void okButton_slot(); 39 void okButton_slot();
36 /** cancel button pressed */ 40 /** cancel button pressed */
37 void cancelButton_slot(); 41 void cancelButton_slot();
42#ifdef PWM_EMBEDDED
43 virtual void slotOk();
44#endif
38}; 45};
39 46
40#endif 47#endif
diff --git a/pwmanager/pwmanager/listviewpwm.cpp b/pwmanager/pwmanager/listviewpwm.cpp
index b987c9e..c53cfd7 100644
--- a/pwmanager/pwmanager/listviewpwm.cpp
+++ b/pwmanager/pwmanager/listviewpwm.cpp
@@ -1,86 +1,97 @@
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 * 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 "listviewpwm.h" 20#include "listviewpwm.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22 22
23#include <qpainter.h> 23#include <qpainter.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25 25
26#include <kiconloader.h> 26#include <kiconloader.h>
27 27
28#ifdef PWM_EMBEDDED
29#include <kglobal.h>
30#endif
28 31
29ListViewPwM::ListViewPwM(QWidget *parent, const char *name) 32ListViewPwM::ListViewPwM(QWidget *parent, const char *name)
30 : KListView(parent, name) 33 : KListView(parent, name)
31{ 34{
32 //setResizeMode(QListView::AllColumns); 35 //setResizeMode(QListView::AllColumns);
33} 36}
34 37
35bool ListViewPwM::event(QEvent *e) 38bool ListViewPwM::event(QEvent *e)
36{ 39{
37 if (e->type() == QEvent::LayoutHint) 40 if (e->type() == QEvent::LayoutHint)
38 emit layoutChanged(); 41 emit layoutChanged();
39 return KListView::event(e); 42 return KListView::event(e);
40} 43}
41 44
42 45
43QPixmap * ListViewItemPwM::onPix = 0; 46QPixmap * ListViewItemPwM::onPix = 0;
44QPixmap * ListViewItemPwM::offPix = 0; 47QPixmap * ListViewItemPwM::offPix = 0;
45 48
46ListViewItemPwM::ListViewItemPwM(QListView *parent) 49ListViewItemPwM::ListViewItemPwM(QListView *parent)
47 : QCheckListItem(parent, "", QCheckListItem::CheckBox) 50 : QCheckListItem(parent, "", QCheckListItem::CheckBox)
48{ 51{
49 if (!onPix) { 52 if (!onPix) {
50 PWM_ASSERT(!offPix); 53 PWM_ASSERT(!offPix);
54 KIconLoader* picons;
55#ifndef PWM_EMBEDDED
56 KIconLoader il;
57 picons = &il;
58#else
59 picons = KGlobal::iconLoader();
60#endif
61
51 KIconLoader il; 62 KIconLoader il;
52 static QPixmap onP(il.loadIcon("button_ok", KIcon::Small)); 63 static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small));
53 onPix = &onP; 64 onPix = &onP;
54 static QPixmap offP(il.loadIcon("encrypted", KIcon::Small)); 65 static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small));
55 offPix = &offP; 66 offPix = &offP;
56 } 67 }
57} 68}
58 69
59void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg, 70void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg,
60 int column, int width, int align) 71 int column, int width, int align)
61{ 72{
62 if (!p) 73 if (!p)
63 return; 74 return;
64 if (column != 0) { 75 if (column != 0) {
65 QCheckListItem::paintCell(p, cg, column, width, align); 76 QCheckListItem::paintCell(p, cg, column, width, align);
66 return; 77 return;
67 } 78 }
68 QPixmap *curPix = isOn() ? onPix : offPix; 79 QPixmap *curPix = isOn() ? onPix : offPix;
69 int pixSpace = curPix->width(); 80 int pixSpace = curPix->width();
70 pixSpace += 4; 81 pixSpace += 4;
71#ifndef PWM_EMBEDDED 82#ifndef PWM_EMBEDDED
72 QRect window(p->viewport()); 83 QRect window(p->viewport());
73 // clear the rectangle (we have to clear it first. see QT doc) 84 // clear the rectangle (we have to clear it first. see QT doc)
74 p->eraseRect(0, 0, pixSpace, window.height()); 85 p->eraseRect(0, 0, pixSpace, window.height());
75 // now draw the pixmap 86 // now draw the pixmap
76 int y = (height() - curPix->height()) / 2; 87 int y = (height() - curPix->height()) / 2;
77 p->drawPixmap(1, y, *curPix); 88 p->drawPixmap(1, y, *curPix);
78 window.moveLeft(pixSpace); 89 window.moveLeft(pixSpace);
79 p->setViewport(window); 90 p->setViewport(window);
80#endif 91#endif
81 QListViewItem::paintCell(p, cg, column, width - pixSpace, align); 92 QListViewItem::paintCell(p, cg, column, width - pixSpace, align);
82} 93}
83 94
84#ifndef PWM_EMBEDDED 95#ifndef PWM_EMBEDDED
85#include "listviewpwm.moc" 96#include "listviewpwm.moc"
86#endif 97#endif
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp
index d720e1f..3ae4d55 100644
--- a/pwmanager/pwmanager/main.cpp
+++ b/pwmanager/pwmanager/main.cpp
@@ -1,210 +1,212 @@
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#ifndef PWM_EMBEDDED 20#ifndef PWM_EMBEDDED
21#include <kcmdlineargs.h> 21#include <kcmdlineargs.h>
22#include <kaboutdata.h> 22#include <kaboutdata.h>
23#else 23#else
24#include <qdir.h> 24#include <qdir.h>
25#include <kpimglobalprefs.h>
25#endif 26#endif
26 27
27#include <klocale.h> 28#include <klocale.h>
28#include <kstandarddirs.h> 29#include <kstandarddirs.h>
29 30
30#include "pwmexception.h" 31#include "pwmexception.h"
31#include "pwminit.h" 32#include "pwminit.h"
32 33
33 #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text")) 34 #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text"))
34 35
35int PwMApplication::newInstance() 36int PwMApplication::newInstance()
36{ 37{
37 static bool initial = true; 38 static bool initial = true;
38 if (initial) { 39 if (initial) {
39 initial = false; 40 initial = false;
40 init = new PwMInit(this); 41 init = new PwMInit(this);
41 init->initializeApp(); 42 init->initializeApp();
42 } else { 43 } else {
43 BUG_ON(!init); 44 BUG_ON(!init);
44 printInfo("passing parameters to old instance."); 45 printInfo("passing parameters to old instance.");
45 init->handleCmdLineArgs(false); 46 init->handleCmdLineArgs(false);
46 } 47 }
47 return EXIT_SUCCESS; 48 return EXIT_SUCCESS;
48} 49}
49 50
50 51
51static const char *description = I18N_NOOP("PwManager\n" 52static const char *description = I18N_NOOP("PwManager\n"
52 "The convenient way of managing passwords"); 53 "The convenient way of managing passwords");
53 54
54#ifndef PWM_EMBEDDED 55#ifndef PWM_EMBEDDED
55static KCmdLineOptions options[] = 56static KCmdLineOptions options[] =
56{ 57{
57 { "minimized", I18N_NOOP("Windows minimized"), 0 }, 58 { "minimized", I18N_NOOP("Windows minimized"), 0 },
58 { "mintray", I18N_NOOP("Windows minimized to tray"),0 }, 59 { "mintray", I18N_NOOP("Windows minimized to tray"),0 },
59 { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 }, 60 { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 },
60 { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 }, 61 { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 },
61 { "+[files...]", I18N_NOOP("Files to open on startup"), 0 }, 62 { "+[files...]", I18N_NOOP("Files to open on startup"), 0 },
62 { 0, 0, 0 } 63 { 0, 0, 0 }
63}; 64};
64#endif 65#endif
65 66
66#ifdef PWM_DEBUG 67#ifdef PWM_DEBUG
67static void printDebugConfigureInfo() 68static void printDebugConfigureInfo()
68{ 69{
69 cout << "================================" << endl; 70 cout << "================================" << endl;
70 cout << PROG_NAME " version " PACKAGE_VER << endl; 71 cout << PROG_NAME " version " PACKAGE_VER << endl;
71#ifdef CONFIG_KEYCARD 72#ifdef CONFIG_KEYCARD
72 cout << "CONFIG_KEYCARD: enabled" << endl; 73 cout << "CONFIG_KEYCARD: enabled" << endl;
73#else 74#else
74 cout << "CONFIG_KEYCARD: disabled" << endl; 75 cout << "CONFIG_KEYCARD: disabled" << endl;
75#endif 76#endif
76#ifdef CONFIG_KWALLETIF 77#ifdef CONFIG_KWALLETIF
77 cout << "CONFIG_KWALLETIF: enabled" << endl; 78 cout << "CONFIG_KWALLETIF: enabled" << endl;
78#else 79#else
79 cout << "CONFIG_KWALLETIF: disabled" << endl; 80 cout << "CONFIG_KWALLETIF: disabled" << endl;
80#endif 81#endif
81#ifdef BIG_ENDIAN_HOST 82#ifdef BIG_ENDIAN_HOST
82 cout << "Endianess: big-endian" << endl; 83 cout << "Endianess: big-endian" << endl;
83#else 84#else
84 cout << "Endianess: little-endian" << endl; 85 cout << "Endianess: little-endian" << endl;
85#endif 86#endif
86 cout << "sizeof(long): " << sizeof(long) << endl; 87 cout << "sizeof(long): " << sizeof(long) << endl;
87 cout << "================================" << endl; 88 cout << "================================" << endl;
88} 89}
89#else // PWM_DEBUG 90#else // PWM_DEBUG
90static inline void printDebugConfigureInfo() { /* nothing */ } 91static inline void printDebugConfigureInfo() { /* nothing */ }
91#endif // PWM_DEBUG 92#endif // PWM_DEBUG
92 93
93#ifndef PWM_EMBEDDED 94#ifndef PWM_EMBEDDED
94static void addAuthors(KAboutData *aboutData) 95static void addAuthors(KAboutData *aboutData)
95{ 96{
96 aboutData->addAuthor("Michael Buesch", 97 aboutData->addAuthor("Michael Buesch",
97 I18N_NOOP( 98 I18N_NOOP(
98 "main programming and current maintainer"), 99 "main programming and current maintainer"),
99 "mbuesch@freenet.de"); 100 "mbuesch@freenet.de");
100 aboutData->addAuthor("Matt Scifo", 101 aboutData->addAuthor("Matt Scifo",
101 I18N_NOOP( 102 I18N_NOOP(
102 "original implementaion of \n" 103 "original implementaion of \n"
103 "\"categories\" and the password-tree \n" 104 "\"categories\" and the password-tree \n"
104 "in the system-tray. Original implementations of \n" 105 "in the system-tray. Original implementations of \n"
105 "numerous view-improvements."), 106 "numerous view-improvements."),
106 "mscifo@o1.com"); 107 "mscifo@o1.com");
107 aboutData->addCredit("Elias Probst", 108 aboutData->addCredit("Elias Probst",
108 I18N_NOOP( 109 I18N_NOOP(
109 "Gentoo ebuild maintainer."), 110 "Gentoo ebuild maintainer."),
110 "elias.probst@gmx.de"); 111 "elias.probst@gmx.de");
111 aboutData->addCredit("George Staikos", 112 aboutData->addCredit("George Staikos",
112 I18N_NOOP("KWallet"), 113 I18N_NOOP("KWallet"),
113 "staikos@kde.org"); 114 "staikos@kde.org");
114 aboutData->addCredit("Matthew Palmer", 115 aboutData->addCredit("Matthew Palmer",
115 I18N_NOOP("rc2 code"), 116 I18N_NOOP("rc2 code"),
116 "mjp16@uow.edu.au"); 117 "mjp16@uow.edu.au");
117 aboutData->addCredit("Olivier Sessink", 118 aboutData->addCredit("Olivier Sessink",
118 I18N_NOOP("gpasman"), 119 I18N_NOOP("gpasman"),
119 "gpasman@nl.linux.org"); 120 "gpasman@nl.linux.org");
120 aboutData->addCredit("The libgcrypt developers", 121 aboutData->addCredit("The libgcrypt developers",
121 I18N_NOOP("Blowfish and SHA1 algorithms"), 122 I18N_NOOP("Blowfish and SHA1 algorithms"),
122 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); 123 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/");
123 aboutData->addCredit("Troy Engel", 124 aboutData->addCredit("Troy Engel",
124 I18N_NOOP("kpasman"), 125 I18N_NOOP("kpasman"),
125 "tengel@sonic.net"); 126 "tengel@sonic.net");
126 aboutData->addCredit("Wickey", 127 aboutData->addCredit("Wickey",
127 I18N_NOOP("graphics-design in older versions."), 128 I18N_NOOP("graphics-design in older versions."),
128 "wickey@gmx.at"); 129 "wickey@gmx.at");
129 aboutData->addCredit("Ian MacGregor", 130 aboutData->addCredit("Ian MacGregor",
130 I18N_NOOP( 131 I18N_NOOP(
131 "original documentation author.")); 132 "original documentation author."));
132} 133}
133#endif 134#endif
134 135
135int main(int argc, char *argv[]) 136int main(int argc, char *argv[])
136{ 137{
137 printDebugConfigureInfo(); 138 printDebugConfigureInfo();
138#ifndef PWM_EMBEDDED 139#ifndef PWM_EMBEDDED
139 KAboutData aboutData(PACKAGE_NAME, PROG_NAME, 140 KAboutData aboutData(PACKAGE_NAME, PROG_NAME,
140 PACKAGE_VER, description, KAboutData::License_File, 141 PACKAGE_VER, description, KAboutData::License_File,
141 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, 142 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0,
142 "http://passwordmanager.sourceforge.net/", 143 "http://passwordmanager.sourceforge.net/",
143 "mbuesch@freenet.de"); 144 "mbuesch@freenet.de");
144 addAuthors(&aboutData); 145 addAuthors(&aboutData);
145 146
146 KCmdLineArgs::init(argc, argv, &aboutData); 147 KCmdLineArgs::init(argc, argv, &aboutData);
147 KCmdLineArgs::addCmdLineOptions(options); 148 KCmdLineArgs::addCmdLineOptions(options);
148 149
149 KUniqueApplication::addCmdLineOptions(); 150 KUniqueApplication::addCmdLineOptions();
150 if (!KUniqueApplication::start()) { 151 if (!KUniqueApplication::start()) {
151 printInfo("already running."); 152 printInfo("already running.");
152 return EXIT_SUCCESS; 153 return EXIT_SUCCESS;
153 } 154 }
154 PwMApplication a; 155 PwMApplication a;
155 aboutData.setLicenseTextFile(LICENSE_FILE); 156 aboutData.setLicenseTextFile(LICENSE_FILE);
156 return a.exec(); 157 return a.exec();
157#else 158#else
158 159
159 bool exitHelp = false; 160 bool exitHelp = false;
160 if ( argc > 1 ) { 161 if ( argc > 1 ) {
161 QString command = argv[1]; 162 QString command = argv[1];
162 if ( command == "-help" ){ 163 if ( command == "-help" ){
163 printf("PWM/PI command line commands:\n"); 164 printf("PWM/PI command line commands:\n");
164 printf(" no command: Start PWM/PI in usual way\n"); 165 printf(" no command: Start PWM/PI in usual way\n");
165 printf(" -help: This output\n"); 166 printf(" -help: This output\n");
166 printf(" PWM/PI is exiting now. Bye!\n"); 167 printf(" PWM/PI is exiting now. Bye!\n");
167 exitHelp = true; 168 exitHelp = true;
168 } 169 }
169 } 170 }
170 if ( ! exitHelp ) { 171 if ( ! exitHelp ) {
171 172
172 PwMApplication a(argc, argv); 173 PwMApplication a(argc, argv);
173 174
174 KGlobal::setAppName( "pwmanager" ); 175 KGlobal::setAppName( "pwmanager" );
175#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
176 //US if ( QApplication::desktop()->width() > 320 ) 177 //US if ( QApplication::desktop()->width() > 320 )
177 //US KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); 178 //US KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
178 //US else 179 //US else
179 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); 180 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
180#else 181#else
181 QString fileName ; 182 QString fileName ;
182 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; 183 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
183 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 184 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
184 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 185 QApplication::addLibraryPath ( qApp->applicationDirPath () );
185 186
186#endif 187#endif
187 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); 188 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
189 KPimGlobalPrefs::instance()->setGlobalConfig();
188 190
189 a.newInstance(); 191 a.newInstance();
190 192
191 //US KAddressBookMain m ; 193 //US KAddressBookMain m ;
192 194
193 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 195 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
194 /*US 196 /*US
195#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
196 a.showMainWidget( &m ); 198 a.showMainWidget( &m );
197#else 199#else
198 a.setMainWidget( &m ); 200 a.setMainWidget( &m );
199 m.resize (640, 480 ); 201 m.resize (640, 480 );
200 m.show(); 202 m.show();
201#endif 203#endif
202 */ 204 */
203 a.exec(); 205 a.exec();
204 206
205 } 207 }
206 qDebug("PWMPI: Bye! "); 208 qDebug("PWMPI: Bye! ");
207 209
208#endif 210#endif
209 211
210} 212}
diff --git a/pwmanager/pwmanager/pwgenwnd_emb.cpp b/pwmanager/pwmanager/pwgenwnd_emb.cpp
index 9655e9f..429904c 100644
--- a/pwmanager/pwmanager/pwgenwnd_emb.cpp
+++ b/pwmanager/pwmanager/pwgenwnd_emb.cpp
@@ -1,137 +1,134 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 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 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 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 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. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "pwgenwnd_emb.h" 26#include "pwgenwnd_emb.h"
27 27
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qgroupbox.h> 29#include <qgroupbox.h>
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qspinbox.h> 33#include <qspinbox.h>
34#include <qlayout.h> 34#include <qlayout.h>
35 35
36#include "klocale.h" 36#include "klocale.h"
37 37
38/* 38/*
39 * Constructs a pwGenWnd as a child of 'parent', with the 39 * Constructs a pwGenWnd as a child of 'parent', with the
40 * name 'name'. 40 * name 'name'.
41 * 41 *
42 */ 42 */
43pwGenWnd::pwGenWnd( QWidget* parent, const char* name) 43pwGenWnd::pwGenWnd( QWidget* parent, const char* name)
44 : KDialogBase( KDialogBase::Plain, i18n( "Password generator" ), 44 : KDialogBase( KDialogBase::Plain, i18n( "Password generator" ),
45 KDialogBase::Ok | KDialogBase::Cancel, 45 KDialogBase::Ok | KDialogBase::Cancel,
46 KDialogBase::Ok, parent, name, true ) 46 KDialogBase::Ok, parent, name, true )
47{ 47{
48 if ( !name )
49 setName( "pwGenWnd" );
50
51 QWidget *page = plainPage(); 48 QWidget *page = plainPage();
52 QVBoxLayout* pwGenWndLayout = new QVBoxLayout( page, 11, 6, "pwGenWndLayout"); 49 QVBoxLayout* pwGenWndLayout = new QVBoxLayout( page, 11, 6, "pwGenWndLayout");
53 50
54 QGroupBox* groupBox1 = new QGroupBox( page, "groupBox1" ); 51 QGroupBox* groupBox1 = new QGroupBox( page, "groupBox1" );
55 groupBox1->setTitle( i18n( "Character set:" ) ); 52 groupBox1->setTitle( i18n( "Character set:" ) );
56 groupBox1->setColumnLayout(0, Qt::Vertical ); 53 groupBox1->setColumnLayout(0, Qt::Vertical );
57 groupBox1->layout()->setSpacing( 6 ); 54 groupBox1->layout()->setSpacing( 6 );
58 groupBox1->layout()->setMargin( 11 ); 55 groupBox1->layout()->setMargin( 11 );
59 QVBoxLayout* groupBox1Layout = new QVBoxLayout( groupBox1->layout() ); 56 QVBoxLayout* groupBox1Layout = new QVBoxLayout( groupBox1->layout() );
60 groupBox1Layout->setAlignment( Qt::AlignTop ); 57 groupBox1Layout->setAlignment( Qt::AlignTop );
61 58
62 int_charLowerCheckBox = new QCheckBox( i18n("Lowercase (abc)"), groupBox1, "int_charLowerCheckBox" ); 59 int_charLowerCheckBox = new QCheckBox( i18n("Lowercase (abc)"), groupBox1, "int_charLowerCheckBox" );
63 int_charLowerCheckBox->setChecked( TRUE ); 60 int_charLowerCheckBox->setChecked( TRUE );
64 groupBox1Layout->addWidget( int_charLowerCheckBox ); 61 groupBox1Layout->addWidget( int_charLowerCheckBox );
65 62
66 int_charUpperCheckBox = new QCheckBox( i18n("Uppercase (ABC)"), groupBox1, "int_charUpperCheckBox" ); 63 int_charUpperCheckBox = new QCheckBox( i18n("Uppercase (ABC)"), groupBox1, "int_charUpperCheckBox" );
67 int_charUpperCheckBox->setChecked( TRUE ); 64 int_charUpperCheckBox->setChecked( TRUE );
68 groupBox1Layout->addWidget( int_charUpperCheckBox ); 65 groupBox1Layout->addWidget( int_charUpperCheckBox );
69 66
70 67
71 int_charNumCheckBox = new QCheckBox( i18n("Numbers (123)"), groupBox1, "int_charNumCheckBox" ); 68 int_charNumCheckBox = new QCheckBox( i18n("Numbers (123)"), groupBox1, "int_charNumCheckBox" );
72 int_charNumCheckBox->setChecked( TRUE ); 69 int_charNumCheckBox->setChecked( TRUE );
73 groupBox1Layout->addWidget( int_charNumCheckBox ); 70 groupBox1Layout->addWidget( int_charNumCheckBox );
74 71
75 int_charSpecCheckBox = new QCheckBox( i18n("Special characters:"), groupBox1, "int_charSpecCheckBox" ); 72 int_charSpecCheckBox = new QCheckBox( i18n("Special characters:"), groupBox1, "int_charSpecCheckBox" );
76 groupBox1Layout->addWidget( int_charSpecCheckBox ); 73 groupBox1Layout->addWidget( int_charSpecCheckBox );
77 74
78 QLabel* textLabel7 = new QLabel( groupBox1, "textLabel7" ); 75 QLabel* textLabel7 = new QLabel( groupBox1, "textLabel7" );
79 QString st("\x21\x22\xc2\xa7\x24\x25\x26\x2f\x28\x29\x3d\x3f\x2c\x2e\x2d\x3b\x3a\x5f\x2b"); 76 QString st("\x21\x22\xc2\xa7\x24\x25\x26\x2f\x28\x29\x3d\x3f\x2c\x2e\x2d\x3b\x3a\x5f\x2b");
80 textLabel7->setText( st.utf8() ); 77 textLabel7->setText( st.utf8() );
81 groupBox1Layout->addWidget( textLabel7 ); 78 groupBox1Layout->addWidget( textLabel7 );
82 79
83 int_charBlankCheckBox = new QCheckBox( i18n( "Spaces (blank characters)"), groupBox1, "int_charBlankCheckBox" ); 80 int_charBlankCheckBox = new QCheckBox( i18n( "Spaces (blank characters)"), groupBox1, "int_charBlankCheckBox" );
84 groupBox1Layout->addWidget( int_charBlankCheckBox ); 81 groupBox1Layout->addWidget( int_charBlankCheckBox );
85 82
86 QHBoxLayout* layout7 = new QHBoxLayout( 0, 0, 6, "layout7"); 83 QHBoxLayout* layout7 = new QHBoxLayout( 0, 0, 6, "layout7");
87 84
88 int_charUserCheckBox = new QCheckBox( i18n("User defined:"), groupBox1, "int_charUserCheckBox" ); 85 int_charUserCheckBox = new QCheckBox( i18n("User defined:"), groupBox1, "int_charUserCheckBox" );
89 layout7->addWidget( int_charUserCheckBox ); 86 layout7->addWidget( int_charUserCheckBox );
90 87
91 int_userDefLineEdit = new QLineEdit( groupBox1, "int_userDefLineEdit" ); 88 int_userDefLineEdit = new QLineEdit( groupBox1, "int_userDefLineEdit" );
92 int_userDefLineEdit->setEnabled( FALSE ); 89 int_userDefLineEdit->setEnabled( FALSE );
93 layout7->addWidget( int_userDefLineEdit ); 90 layout7->addWidget( int_userDefLineEdit );
94 groupBox1Layout->addLayout( layout7 ); 91 groupBox1Layout->addLayout( layout7 );
95 pwGenWndLayout->addWidget( groupBox1 ); 92 pwGenWndLayout->addWidget( groupBox1 );
96 93
97 94
98 QHBoxLayout* layout8 = new QHBoxLayout( 0, 0, 6, "layout8"); 95 QHBoxLayout* layout8 = new QHBoxLayout( 0, 0, 6, "layout8");
99 96
100 int_lenSpinBox = new QSpinBox( page, "int_lenSpinBox" ); 97 int_lenSpinBox = new QSpinBox( page, "int_lenSpinBox" );
101 QLabel* textLabel2 = new QLabel( int_lenSpinBox, i18n("Password Length:"), page, "textLabel2" ); 98 QLabel* textLabel2 = new QLabel( int_lenSpinBox, i18n("Password Length:"), page, "textLabel2" );
102 layout8->addWidget( textLabel2 ); 99 layout8->addWidget( textLabel2 );
103 100
104 int_lenSpinBox->setMaxValue( 9999 ); 101 int_lenSpinBox->setMaxValue( 9999 );
105 int_lenSpinBox->setMinValue( 1 ); 102 int_lenSpinBox->setMinValue( 1 );
106 int_lenSpinBox->setValue( 8 ); 103 int_lenSpinBox->setValue( 8 );
107 layout8->addWidget( int_lenSpinBox ); 104 layout8->addWidget( int_lenSpinBox );
108 pwGenWndLayout->addLayout( layout8 ); 105 pwGenWndLayout->addLayout( layout8 );
109 106
110 int_filterCheckBox = new QCheckBox( i18n( "Enable Filtering to get better passwords" ), page, "int_filterCheckBox" ); 107 int_filterCheckBox = new QCheckBox( i18n( "Enable Filtering to get better passwords" ), page, "int_filterCheckBox" );
111 int_filterCheckBox->setChecked( TRUE ); 108 int_filterCheckBox->setChecked( TRUE );
112 pwGenWndLayout->addWidget( int_filterCheckBox ); 109 pwGenWndLayout->addWidget( int_filterCheckBox );
113 110
114 setButtonText( KDialogBase::Ok, "&Generate now" ); 111 setButtonText( KDialogBase::Ok, "&Generate now" );
115 112
116 // signals and slots connections 113 // signals and slots connections
117 connect( int_charUserCheckBox, SIGNAL( toggled(bool) ), int_userDefLineEdit, SLOT( setEnabled(bool) ) ); 114 connect( int_charUserCheckBox, SIGNAL( toggled(bool) ), int_userDefLineEdit, SLOT( setEnabled(bool) ) );
118} 115}
119 116
120/* 117/*
121 * Destroys the object and frees any allocated resources 118 * Destroys the object and frees any allocated resources
122 */ 119 */
123pwGenWnd::~pwGenWnd() 120pwGenWnd::~pwGenWnd()
124{ 121{
125 // no need to delete child widgets, Qt does it all for us 122 // no need to delete child widgets, Qt does it all for us
126} 123}
127 124
128void pwGenWnd::cancelButton_slot() 125void pwGenWnd::cancelButton_slot()
129{ 126{
130 qWarning( "pwGenWnd::cancelButton_slot(): Not implemented yet" ); 127 qWarning( "pwGenWnd::cancelButton_slot(): Not implemented yet" );
131} 128}
132 129
133void pwGenWnd::genButton_slot() 130void pwGenWnd::genButton_slot()
134{ 131{
135 qWarning( "pwGenWnd::genButton_slot(): Not implemented yet" ); 132 qWarning( "pwGenWnd::genButton_slot(): Not implemented yet" );
136} 133}
137 134
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 107e845..bd07c80 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1,1309 +1,1310 @@
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#ifndef PWM_EMBEDDED 27#ifndef PWM_EMBEDDED
28#include <kmenubar.h> 28#include <kmenubar.h>
29#include <kstatusbar.h> 29#include <kstatusbar.h>
30#include <dcopclient.h> 30#include <dcopclient.h>
31#include "configwndimpl.h" 31#include "configwndimpl.h"
32#include "configuration.h" 32#include "configuration.h"
33#else 33#else
34#include <qmenubar.h> 34#include <qmenubar.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <pwmprefs.h> 36#include <pwmprefs.h>
37#include <kpimglobalprefs.h> 37#include <kpimglobalprefs.h>
38#include <kcmconfigs/kcmpwmconfig.h> 38#include <kcmconfigs/kcmpwmconfig.h>
39#include <kcmconfigs/kcmkdepimconfig.h> 39#include <kcmconfigs/kcmkdepimconfig.h>
40#include <kcmultidialog.h> 40#include <kcmultidialog.h>
41#endif 41#endif
42 42
43#include <qpixmap.h> 43#include <qpixmap.h>
44#include <qcheckbox.h> 44#include <qcheckbox.h>
45#include <qspinbox.h> 45#include <qspinbox.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qfileinfo.h> 47#include <qfileinfo.h>
48#include <qclipboard.h> 48#include <qclipboard.h>
49 49
50 50
51#include <stdio.h> 51#include <stdio.h>
52 52
53#include "pwm.h" 53#include "pwm.h"
54#include "pwminit.h" 54#include "pwminit.h"
55#include "pwmprint.h" 55#include "pwmprint.h"
56#include "addentrywndimpl.h" 56#include "addentrywndimpl.h"
57#include "globalstuff.h" 57#include "globalstuff.h"
58#include "findwndimpl.h" 58#include "findwndimpl.h"
59 59
60#ifdef CONFIG_KWALLETIF 60#ifdef CONFIG_KWALLETIF
61# include "kwalletif.h" 61# include "kwalletif.h"
62# include "kwalletemu.h" 62# include "kwalletemu.h"
63#endif 63#endif
64#ifdef CONFIG_KEYCARD 64#ifdef CONFIG_KEYCARD
65# include "pwmkeycard.h" 65# include "pwmkeycard.h"
66#endif 66#endif
67 67
68 68
69 #define DEFAULT_SIZE (QSize(700, 400)) 69 #define DEFAULT_SIZE (QSize(700, 400))
70 70
71// Button IDs for "file" popup menu 71// Button IDs for "file" popup menu
72enum { 72enum {
73 BUTTON_POPUP_FILE_NEW = 0, 73 BUTTON_POPUP_FILE_NEW = 0,
74 BUTTON_POPUP_FILE_OPEN, 74 BUTTON_POPUP_FILE_OPEN,
75 BUTTON_POPUP_FILE_CLOSE, 75 BUTTON_POPUP_FILE_CLOSE,
76 BUTTON_POPUP_FILE_SAVE, 76 BUTTON_POPUP_FILE_SAVE,
77 BUTTON_POPUP_FILE_SAVEAS, 77 BUTTON_POPUP_FILE_SAVEAS,
78 BUTTON_POPUP_FILE_EXPORT, 78 BUTTON_POPUP_FILE_EXPORT,
79 BUTTON_POPUP_FILE_IMPORT, 79 BUTTON_POPUP_FILE_IMPORT,
80 BUTTON_POPUP_FILE_PRINT, 80 BUTTON_POPUP_FILE_PRINT,
81 BUTTON_POPUP_FILE_QUIT 81 BUTTON_POPUP_FILE_QUIT
82}; 82};
83// Button IDs for "manage" popup menu 83// Button IDs for "manage" popup menu
84enum { 84enum {
85 BUTTON_POPUP_MANAGE_ADD = 0, 85 BUTTON_POPUP_MANAGE_ADD = 0,
86 BUTTON_POPUP_MANAGE_EDIT, 86 BUTTON_POPUP_MANAGE_EDIT,
87 BUTTON_POPUP_MANAGE_DEL, 87 BUTTON_POPUP_MANAGE_DEL,
88 BUTTON_POPUP_MANAGE_CHANGEMP 88 BUTTON_POPUP_MANAGE_CHANGEMP
89}; 89};
90// Button IDs for chipcard popup menu 90// Button IDs for chipcard popup menu
91enum { 91enum {
92#ifdef CONFIG_KEYCARD 92#ifdef CONFIG_KEYCARD
93 BUTTON_POPUP_CHIPCARD_GENNEW = 0, 93 BUTTON_POPUP_CHIPCARD_GENNEW = 0,
94 BUTTON_POPUP_CHIPCARD_DEL, 94 BUTTON_POPUP_CHIPCARD_DEL,
95 BUTTON_POPUP_CHIPCARD_READID, 95 BUTTON_POPUP_CHIPCARD_READID,
96 BUTTON_POPUP_CHIPCARD_SAVEBACKUP, 96 BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
97 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP 97 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
98#else // CONFIG_KEYCARD 98#else // CONFIG_KEYCARD
99 BUTTON_POPUP_CHIPCARD_NO = 0 99 BUTTON_POPUP_CHIPCARD_NO = 0
100#endif // CONFIG_KEYCARD 100#endif // CONFIG_KEYCARD
101}; 101};
102// Button IDs for "view" popup menu 102// Button IDs for "view" popup menu
103enum { 103enum {
104 BUTTON_POPUP_VIEW_FIND = 0, 104 BUTTON_POPUP_VIEW_FIND = 0,
105 BUTTON_POPUP_VIEW_LOCK, 105 BUTTON_POPUP_VIEW_LOCK,
106 BUTTON_POPUP_VIEW_DEEPLOCK, 106 BUTTON_POPUP_VIEW_DEEPLOCK,
107 BUTTON_POPUP_VIEW_UNLOCK 107 BUTTON_POPUP_VIEW_UNLOCK
108}; 108};
109// Button IDs for "options" popup menu 109// Button IDs for "options" popup menu
110enum { 110enum {
111 BUTTON_POPUP_OPTIONS_CONFIG = 0 111 BUTTON_POPUP_OPTIONS_CONFIG = 0
112}; 112};
113// Button IDs for "export" popup menu (in "file" popup menu) 113// Button IDs for "export" popup menu (in "file" popup menu)
114enum { 114enum {
115 BUTTON_POPUP_EXPORT_TEXT = 0, 115 BUTTON_POPUP_EXPORT_TEXT = 0,
116 BUTTON_POPUP_EXPORT_GPASMAN 116 BUTTON_POPUP_EXPORT_GPASMAN
117#ifdef CONFIG_KWALLETIF 117#ifdef CONFIG_KWALLETIF
118 ,BUTTON_POPUP_EXPORT_KWALLET 118 ,BUTTON_POPUP_EXPORT_KWALLET
119#endif 119#endif
120}; 120};
121// Button IDs for "import" popup menu (in "file" popup menu) 121// Button IDs for "import" popup menu (in "file" popup menu)
122enum { 122enum {
123 BUTTON_POPUP_IMPORT_TEXT = 0, 123 BUTTON_POPUP_IMPORT_TEXT = 0,
124 BUTTON_POPUP_IMPORT_GPASMAN 124 BUTTON_POPUP_IMPORT_GPASMAN
125#ifdef CONFIG_KWALLETIF 125#ifdef CONFIG_KWALLETIF
126 ,BUTTON_POPUP_IMPORT_KWALLET 126 ,BUTTON_POPUP_IMPORT_KWALLET
127#endif 127#endif
128}; 128};
129 129
130#ifdef PWM_EMBEDDED 130#ifdef PWM_EMBEDDED
131// Button IDs for "help" popup menu 131// Button IDs for "help" popup menu
132enum { 132enum {
133 BUTTON_POPUP_HELP_LICENSE = 0, 133 BUTTON_POPUP_HELP_LICENSE = 0,
134 BUTTON_POPUP_HELP_FAQ, 134 BUTTON_POPUP_HELP_FAQ,
135 BUTTON_POPUP_HELP_ABOUT 135 BUTTON_POPUP_HELP_ABOUT
136}; 136};
137#endif 137#endif
138 138
139// Button IDs for toolbar 139// Button IDs for toolbar
140enum { 140enum {
141 BUTTON_TOOL_NEW = 0, 141 BUTTON_TOOL_NEW = 0,
142 BUTTON_TOOL_OPEN, 142 BUTTON_TOOL_OPEN,
143 BUTTON_TOOL_SAVE, 143 BUTTON_TOOL_SAVE,
144 BUTTON_TOOL_SAVEAS, 144 BUTTON_TOOL_SAVEAS,
145 BUTTON_TOOL_PRINT, 145 BUTTON_TOOL_PRINT,
146 BUTTON_TOOL_ADD, 146 BUTTON_TOOL_ADD,
147 BUTTON_TOOL_EDIT, 147 BUTTON_TOOL_EDIT,
148 BUTTON_TOOL_DEL, 148 BUTTON_TOOL_DEL,
149 BUTTON_TOOL_FIND, 149 BUTTON_TOOL_FIND,
150 BUTTON_TOOL_LOCK, 150 BUTTON_TOOL_LOCK,
151 BUTTON_TOOL_DEEPLOCK, 151 BUTTON_TOOL_DEEPLOCK,
152 BUTTON_TOOL_UNLOCK 152 BUTTON_TOOL_UNLOCK
153}; 153};
154 154
155 155
156PwM::PwM(PwMInit *_init, PwMDoc *doc, 156PwM::PwM(PwMInit *_init, PwMDoc *doc,
157 bool virginity, 157 bool virginity,
158 QWidget *parent, const char *name) 158 QWidget *parent, const char *name)
159 : KMainWindow(parent, name) 159 : KMainWindow(parent, name)
160 , forceQuit (false) 160 , forceQuit (false)
161 , forceMinimizeToTray (false) 161 , forceMinimizeToTray (false)
162{ 162{
163 init = _init; 163 init = _init;
164 connect(doc, SIGNAL(docClosed(PwMDoc *)), 164 connect(doc, SIGNAL(docClosed(PwMDoc *)),
165 this, SLOT(docClosed(PwMDoc *))); 165 this, SLOT(docClosed(PwMDoc *)));
166 initMenubar(); 166 initMenubar();
167 initToolbar(); 167 initToolbar();
168 initMetrics(); 168 initMetrics();
169 setVirgin(virginity); 169 setVirgin(virginity);
170 setFocusPolicy(QWidget::WheelFocus); 170 setFocusPolicy(QWidget::WheelFocus);
171#ifndef PWM_EMBEDDED 171#ifndef PWM_EMBEDDED
172 statusBar()->show(); 172 statusBar()->show();
173#endif 173#endif
174 view = makeNewListView(doc); 174 view = makeNewListView(doc);
175 setCentralWidget(view); 175 setCentralWidget(view);
176 updateCaption(); 176 updateCaption();
177 showStatMsg(i18n("Ready.")); 177 showStatMsg(i18n("Ready."));
178} 178}
179 179
180PwM::~PwM() 180PwM::~PwM()
181{ 181{
182 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), 182 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
183 this, SLOT(docClosed(PwMDoc *))); 183 this, SLOT(docClosed(PwMDoc *)));
184 conf()->confWndMainWndSize(size()); 184 conf()->confWndMainWndSize(size());
185 emit closed(this); 185 emit closed(this);
186 delete view; 186 delete view;
187} 187}
188 188
189void PwM::initMenubar() 189void PwM::initMenubar()
190{ 190{
191 KIconLoader* picons; 191 KIconLoader* picons;
192#ifndef PWM_EMBEDDED 192#ifndef PWM_EMBEDDED
193 KIconLoader icons; 193 KIconLoader icons;
194 picons = &icons; 194 picons = &icons;
195#else 195#else
196 picons = KGlobal::iconLoader(); 196 picons = KGlobal::iconLoader();
197#endif 197#endif
198 filePopup = new KPopupMenu(this); 198 filePopup = new KPopupMenu(this);
199 importPopup = new KPopupMenu(filePopup); 199 importPopup = new KPopupMenu(filePopup);
200 exportPopup = new KPopupMenu(filePopup); 200 exportPopup = new KPopupMenu(filePopup);
201 managePopup = new KPopupMenu(this); 201 managePopup = new KPopupMenu(this);
202#ifdef CONFIG_KEYCARD 202#ifdef CONFIG_KEYCARD
203 chipcardPopup = new KPopupMenu(this); 203 chipcardPopup = new KPopupMenu(this);
204#endif // CONFIG_KEYCARD 204#endif // CONFIG_KEYCARD
205 viewPopup = new KPopupMenu(this); 205 viewPopup = new KPopupMenu(this);
206 optionsPopup = new KPopupMenu(this); 206 optionsPopup = new KPopupMenu(this);
207 207
208// "file" popup menu 208// "file" popup menu
209 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 209 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
210 i18n("&New"), this, 210 i18n("&New"), this,
211 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); 211 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW);
212 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), 212 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)),
213 i18n("&Open"), this, 213 i18n("&Open"), this,
214 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); 214 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN);
215 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), 215 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)),
216 i18n("&Close"), this, 216 i18n("&Close"), this,
217 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); 217 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE);
218 filePopup->insertSeparator(); 218 filePopup->insertSeparator();
219 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), 219 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)),
220 i18n("&Save"), this, 220 i18n("&Save"), this,
221 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); 221 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
222 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), 222 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)),
223 i18n("Save &as..."), 223 i18n("Save &as..."),
224 this, SLOT(saveAs_slot()), 0, 224 this, SLOT(saveAs_slot()), 0,
225 BUTTON_POPUP_FILE_SAVEAS); 225 BUTTON_POPUP_FILE_SAVEAS);
226 filePopup->insertSeparator(); 226 filePopup->insertSeparator();
227 // "file/export" popup menu 227 // "file/export" popup menu
228 exportPopup->insertItem(i18n("&Text-file..."), this, 228 exportPopup->insertItem(i18n("&Text-file..."), this,
229 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); 229 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
230 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 230 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
231 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); 231 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
232#ifdef CONFIG_KWALLETIF 232#ifdef CONFIG_KWALLETIF
233 exportPopup->insertItem(i18n("&KWallet..."), this, 233 exportPopup->insertItem(i18n("&KWallet..."), this,
234 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); 234 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
235#endif 235#endif
236 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), 236 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
237 i18n("E&xport"), exportPopup, 237 i18n("E&xport"), exportPopup,
238 BUTTON_POPUP_FILE_EXPORT); 238 BUTTON_POPUP_FILE_EXPORT);
239 // "file/import" popup menu 239 // "file/import" popup menu
240 importPopup->insertItem(i18n("&Text-file..."), this, 240 importPopup->insertItem(i18n("&Text-file..."), this,
241 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 241 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
242 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 242 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
243 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 243 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
244#ifdef CONFIG_KWALLETIF 244#ifdef CONFIG_KWALLETIF
245 importPopup->insertItem(i18n("&KWallet..."), this, 245 importPopup->insertItem(i18n("&KWallet..."), this,
246 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 246 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
247#endif 247#endif
248 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), 248 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
249 i18n("I&mport"), importPopup, 249 i18n("I&mport"), importPopup,
250 BUTTON_POPUP_FILE_IMPORT); 250 BUTTON_POPUP_FILE_IMPORT);
251 filePopup->insertSeparator(); 251 filePopup->insertSeparator();
252 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), 252 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)),
253 i18n("&Print..."), this, 253 i18n("&Print..."), this,
254 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 254 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
255 filePopup->insertSeparator(); 255 filePopup->insertSeparator();
256 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), 256 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)),
257 i18n("&Quit"), this, 257 i18n("&Quit"), this,
258 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 258 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
259 menuBar()->insertItem(i18n("&File"), filePopup); 259 menuBar()->insertItem(i18n("&File"), filePopup);
260// "manage" popup menu 260// "manage" popup menu
261 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), 261 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
262 i18n("&Add password"), this, 262 i18n("&Add password"), this,
263 SLOT(addPwd_slot()), 0, 263 SLOT(addPwd_slot()), 0,
264 BUTTON_POPUP_MANAGE_ADD); 264 BUTTON_POPUP_MANAGE_ADD);
265 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), 265 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
266 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 266 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
267 BUTTON_POPUP_MANAGE_EDIT); 267 BUTTON_POPUP_MANAGE_EDIT);
268 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 268 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
269 i18n("&Delete"), this, SLOT(deletePwd_slot()), 269 i18n("&Delete"), this, SLOT(deletePwd_slot()),
270 0, BUTTON_POPUP_MANAGE_DEL); 270 0, BUTTON_POPUP_MANAGE_DEL);
271 managePopup->insertSeparator(); 271 managePopup->insertSeparator();
272 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), 272 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
273 i18n("Change &Master Password"), this, 273 i18n("Change &Master Password"), this,
274 SLOT(changeMasterPwd_slot()), 0, 274 SLOT(changeMasterPwd_slot()), 0,
275 BUTTON_POPUP_MANAGE_CHANGEMP); 275 BUTTON_POPUP_MANAGE_CHANGEMP);
276 menuBar()->insertItem(i18n("&Manage"), managePopup); 276 menuBar()->insertItem(i18n("&Manage"), managePopup);
277// "chipcard" popup menu 277// "chipcard" popup menu
278#ifdef CONFIG_KEYCARD 278#ifdef CONFIG_KEYCARD
279 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 279 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
280 i18n("&Generate new key-card"), this, 280 i18n("&Generate new key-card"), this,
281 SLOT(genNewCard_slot()), 0, 281 SLOT(genNewCard_slot()), 0,
282 BUTTON_POPUP_CHIPCARD_GENNEW); 282 BUTTON_POPUP_CHIPCARD_GENNEW);
283 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 283 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
284 i18n("&Erase key-card"), this, 284 i18n("&Erase key-card"), this,
285 SLOT(eraseCard_slot()), 0, 285 SLOT(eraseCard_slot()), 0,
286 BUTTON_POPUP_CHIPCARD_DEL); 286 BUTTON_POPUP_CHIPCARD_DEL);
287 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), 287 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
288 i18n("Read card-&ID"), this, 288 i18n("Read card-&ID"), this,
289 SLOT(readCardId_slot()), 0, 289 SLOT(readCardId_slot()), 0,
290 BUTTON_POPUP_CHIPCARD_READID); 290 BUTTON_POPUP_CHIPCARD_READID);
291 chipcardPopup->insertSeparator(); 291 chipcardPopup->insertSeparator();
292 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), 292 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
293 i18n("&Make card backup-image"), this, 293 i18n("&Make card backup-image"), this,
294 SLOT(makeCardBackup_slot()), 0, 294 SLOT(makeCardBackup_slot()), 0,
295 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 295 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
296 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), 296 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
297 i18n("&Replay card backup-image"), this, 297 i18n("&Replay card backup-image"), this,
298 SLOT(replayCardBackup_slot()), 0, 298 SLOT(replayCardBackup_slot()), 0,
299 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 299 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
300 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 300 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
301#endif // CONFIG_KEYCARD 301#endif // CONFIG_KEYCARD
302// "view" popup menu 302// "view" popup menu
303 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), 303 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
304 i18n("&Find"), this, 304 i18n("&Find"), this,
305 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 305 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
306 viewPopup->insertSeparator(); 306 viewPopup->insertSeparator();
307 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), 307 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
308 i18n("&Lock all entries"), this, 308 i18n("&Lock all entries"), this,
309 SLOT(lockWnd_slot()), 0, 309 SLOT(lockWnd_slot()), 0,
310 BUTTON_POPUP_VIEW_LOCK); 310 BUTTON_POPUP_VIEW_LOCK);
311 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), 311 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
312 i18n("&Deep-lock all entries"), this, 312 i18n("&Deep-lock all entries"), this,
313 SLOT(deepLockWnd_slot()), 0, 313 SLOT(deepLockWnd_slot()), 0,
314 BUTTON_POPUP_VIEW_DEEPLOCK); 314 BUTTON_POPUP_VIEW_DEEPLOCK);
315 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), 315 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
316 i18n("&Unlock all entries"), this, 316 i18n("&Unlock all entries"), this,
317 SLOT(unlockWnd_slot()), 0, 317 SLOT(unlockWnd_slot()), 0,
318 BUTTON_POPUP_VIEW_UNLOCK); 318 BUTTON_POPUP_VIEW_UNLOCK);
319 menuBar()->insertItem(i18n("&View"), viewPopup); 319 menuBar()->insertItem(i18n("&View"), viewPopup);
320// "options" popup menu 320// "options" popup menu
321 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 321 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
322 i18n("&Configure..."), this, 322 i18n("&Configure..."), this,
323 SLOT(config_slot()), 323 SLOT(config_slot()),
324 BUTTON_POPUP_OPTIONS_CONFIG); 324 BUTTON_POPUP_OPTIONS_CONFIG);
325 menuBar()->insertItem(i18n("&Options"), optionsPopup); 325 menuBar()->insertItem(i18n("&Options"), optionsPopup);
326// "help" popup menu 326// "help" popup menu
327#ifndef PWM_EMBEDDED 327#ifndef PWM_EMBEDDED
328 helpPopup = helpMenu(QString::null, false); 328 helpPopup = helpMenu(QString::null, false);
329#else 329#else
330 helpPopup = new KPopupMenu(this); 330 helpPopup = new KPopupMenu(this);
331 331
332 332
333 helpPopup->insertItem(i18n("&License"), this, 333 helpPopup->insertItem(i18n("&License"), this,
334 SLOT(showLicense_slot()), 0, 334 SLOT(showLicense_slot()), 0,
335 BUTTON_POPUP_HELP_LICENSE); 335 BUTTON_POPUP_HELP_LICENSE);
336 336
337 helpPopup->insertItem(i18n("&Faq"), this, 337 helpPopup->insertItem(i18n("&Faq"), this,
338 SLOT(faq_slot()), 0, 338 SLOT(faq_slot()), 0,
339 BUTTON_POPUP_HELP_FAQ); 339 BUTTON_POPUP_HELP_FAQ);
340 340
341 helpPopup->insertItem(i18n("&About PwManager"), this, 341 helpPopup->insertItem(i18n("&About PwManager"), this,
342 SLOT(createAboutData_slot()), 0, 342 SLOT(createAboutData_slot()), 0,
343 BUTTON_POPUP_HELP_ABOUT); 343 BUTTON_POPUP_HELP_ABOUT);
344 344
345#endif 345#endif
346 menuBar()->insertItem(i18n("&Help"), helpPopup); 346 menuBar()->insertItem(i18n("&Help"), helpPopup);
347 347
348} 348}
349 349
350void PwM::initToolbar() 350void PwM::initToolbar()
351{ 351{
352 KIconLoader* picons; 352 KIconLoader* picons;
353#ifndef PWM_EMBEDDED 353#ifndef PWM_EMBEDDED
354 KIconLoader icons; 354 KIconLoader icons;
355 picons = &icons; 355 picons = &icons;
356#else 356#else
357 picons = KGlobal::iconLoader(); 357 picons = KGlobal::iconLoader();
358#endif 358#endif
359 359
360#ifdef PWM_EMBEDDED
361 if ( QApplication::desktop()->width() > 320 )
362#endif
363 {
360 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), 364 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
361 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 365 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
362 SLOT(new_slot()), true, i18n("New")); 366 SLOT(new_slot()), true, i18n("New"));
363 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), 367 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
364 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 368 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
365 SLOT(open_slot()), true, i18n("Open")); 369 SLOT(open_slot()), true, i18n("Open"));
366 toolBar()->insertSeparator(); 370 toolBar()->insertSeparator();
371 }
367 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), 372 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
368 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 373 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
369 SLOT(save_slot()), true, i18n("Save")); 374 SLOT(save_slot()), true, i18n("Save"));
370 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), 375 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
371 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 376 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
372 SLOT(saveAs_slot()), true, i18n("Save as")); 377 SLOT(saveAs_slot()), true, i18n("Save as"));
373 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), 378 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
374 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 379 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
375 SLOT(print_slot()), true, i18n("Print...")); 380 SLOT(print_slot()), true, i18n("Print..."));
376 toolBar()->insertSeparator(); 381 toolBar()->insertSeparator();
377 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), 382 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
378 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, 383 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
379 SLOT(addPwd_slot()), true, 384 SLOT(addPwd_slot()), true,
380 i18n("Add password")); 385 i18n("Add password"));
381 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), 386 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
382 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 387 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
383 SLOT(editPwd_slot()), true, 388 SLOT(editPwd_slot()), true,
384 i18n("Edit password")); 389 i18n("Edit password"));
385 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), 390 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
386 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 391 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
387 SLOT(deletePwd_slot()), true, 392 SLOT(deletePwd_slot()), true,
388 i18n("Delete password")); 393 i18n("Delete password"));
389 toolBar()->insertSeparator(); 394 toolBar()->insertSeparator();
390 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), 395 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
391 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, 396 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
392 SLOT(find_slot()), true, i18n("Find entry")); 397 SLOT(find_slot()), true, i18n("Find entry"));
393 toolBar()->insertSeparator(); 398 toolBar()->insertSeparator();
394 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), 399 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
395 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 400 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
396 SLOT(lockWnd_slot()), true, 401 SLOT(lockWnd_slot()), true,
397 i18n("Lock all entries")); 402 i18n("Lock all entries"));
398 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), 403 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
399 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 404 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
400 SLOT(deepLockWnd_slot()), true, 405 SLOT(deepLockWnd_slot()), true,
401 i18n("Deep-Lock all entries")); 406 i18n("Deep-Lock all entries"));
402 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), 407 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
403 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 408 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
404 SLOT(unlockWnd_slot()), true, 409 SLOT(unlockWnd_slot()), true,
405 i18n("Unlock all entries")); 410 i18n("Unlock all entries"));
406} 411}
407 412
408void PwM::initMetrics() 413void PwM::initMetrics()
409{ 414{
410 QSize s = conf()->confWndMainWndSize(); 415 QSize s = conf()->confWndMainWndSize();
411 if (s.isValid()) 416 if (s.isValid())
412 resize(s); 417 resize(s);
413 else 418 else
414 resize(DEFAULT_SIZE); 419 resize(DEFAULT_SIZE);
415} 420}
416 421
417void PwM::updateCaption() 422void PwM::updateCaption()
418{ 423{
419 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); 424 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER);
420} 425}
421 426
422void PwM::hideEvent(QHideEvent *) 427void PwM::hideEvent(QHideEvent *)
423{ 428{
424 if (isMinimized()) { 429 if (isMinimized()) {
425 if (init->tray()) { 430 if (init->tray()) {
426 forceMinimizeToTray = true; 431 forceMinimizeToTray = true;
427 close(); 432 close();
428 } 433 }
429 int mmlock = conf()->confGlobMinimizeLock(); 434 int mmlock = conf()->confGlobMinimizeLock();
430 switch (mmlock) { 435 switch (mmlock) {
431 case 0: // don't lock anything 436 case 0: // don't lock anything
432 break; 437 break;
433 case 1: {// normal lock 438 case 1: {// normal lock
434 curDoc()->lockAll(true); 439 curDoc()->lockAll(true);
435 break; 440 break;
436 } case 2: {// deep-lock 441 } case 2: {// deep-lock
437 curDoc()->deepLock(); 442 curDoc()->deepLock();
438 break; 443 break;
439 } default: 444 } default:
440 WARN(); 445 WARN();
441 } 446 }
442 } 447 }
443} 448}
444 449
445void PwM::setVirgin(bool v) 450void PwM::setVirgin(bool v)
446{ 451{
447 if (virgin == v) 452 if (virgin == v)
448 return; 453 return;
449 virgin = v; 454 virgin = v;
450 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); 455 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
451 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); 456 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
452 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); 457 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
453 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); 458 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
454 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); 459 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
455 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); 460 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
456 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); 461 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
457 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); 462 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
458 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); 463 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
459 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); 464 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
460 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); 465 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
461 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); 466 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
462 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 467 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
463 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 468 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
464 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 469 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
465 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 470 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
466 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 471 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
467 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 472 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
468 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 473 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
469 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 474 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
470} 475}
471 476
472void PwM::new_slot() 477void PwM::new_slot()
473{ 478{
474 init->createMainWnd(); 479 init->createMainWnd();
475} 480}
476 481
477//US ENH 482//US ENH
478void PwM::open_slot() 483void PwM::open_slot()
479{ 484{
480 open_slot(""); 485 open_slot("");
481} 486}
482 487
483void PwM::open_slot(QString fn) 488void PwM::open_slot(QString fn)
484{ 489{
485 openDoc(fn); 490 openDoc(fn);
486} 491}
487 492
488PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 493PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
489{ 494{
490 if (!isVirgin()) { 495 if (!isVirgin()) {
491 // open the document in a new window. 496 // open the document in a new window.
492 PwM *newInstance = init->createMainWnd(); 497 PwM *newInstance = init->createMainWnd();
493 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 498 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
494 if (!newDoc) { 499 if (!newDoc) {
495 newInstance->setForceQuit(true); 500 newInstance->setForceQuit(true);
496 delete_and_null(newInstance); 501 delete_and_null(newInstance);
497 } 502 }
498 return newDoc; 503 return newDoc;
499 } 504 }
500 505
501 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 506 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
502 return 0; 507 return 0;
503 showStatMsg(i18n("Successfully opened file.")); 508 showStatMsg(i18n("Successfully opened file."));
504 updateCaption(); 509 updateCaption();
505 setVirgin(false); 510 setVirgin(false);
506 return curDoc(); 511 return curDoc();
507} 512}
508 513
509PwMView * PwM::makeNewListView(PwMDoc *doc) 514PwMView * PwM::makeNewListView(PwMDoc *doc)
510{ 515{
511 PwMView *ret = new PwMView(this, this, doc); 516 PwMView *ret = new PwMView(this, this, doc);
512 ret->setFont(conf()->confGlobEntryFont()); 517 ret->setFont(conf()->confGlobEntryFont());
513 ret->show(); 518 ret->show();
514 return ret; 519 return ret;
515} 520}
516 521
517void PwM::close_slot() 522void PwM::close_slot()
518{ 523{
519 close(); 524 close();
520} 525}
521 526
522void PwM::quitButton_slot() 527void PwM::quitButton_slot()
523{ 528{
524 init->shutdownApp(0); 529 init->shutdownApp(0);
525} 530}
526 531
527void PwM::save_slot() 532void PwM::save_slot()
528{ 533{
529 save(); 534 save();
530} 535}
531 536
532bool PwM::save() 537bool PwM::save()
533{ 538{
534 if (!curDoc()->saveDocUi(curDoc())) 539 if (!curDoc()->saveDocUi(curDoc()))
535 return false; 540 return false;
536 showStatMsg(i18n("Successfully saved data.")); 541 showStatMsg(i18n("Successfully saved data."));
537 updateCaption(); 542 updateCaption();
538 return true; 543 return true;
539} 544}
540 545
541void PwM::saveAs_slot() 546void PwM::saveAs_slot()
542{ 547{
543 saveAs(); 548 saveAs();
544} 549}
545 550
546bool PwM::saveAs() 551bool PwM::saveAs()
547{ 552{
548 if (!curDoc()->saveAsDocUi(curDoc())) 553 if (!curDoc()->saveAsDocUi(curDoc()))
549 return false; 554 return false;
550 showStatMsg(i18n("Successfully saved data.")); 555 showStatMsg(i18n("Successfully saved data."));
551 updateCaption(); 556 updateCaption();
552 return true; 557 return true;
553} 558}
554 559
555//US ENH : changed code to run with older MOC 560//US ENH : changed code to run with older MOC
556void PwM::addPwd_slot() 561void PwM::addPwd_slot()
557{ 562{
558 addPwd_slot(0, 0); 563 addPwd_slot(0, 0);
559} 564}
560 565
561void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) 566void PwM::addPwd_slot(QString *pw, PwMDoc *_doc)
562{ 567{
563 PwMDoc *doc; 568 PwMDoc *doc;
564 if (_doc) { 569 if (_doc) {
565 doc = _doc; 570 doc = _doc;
566 } else { 571 } else {
567 doc = curDoc(); 572 doc = curDoc();
568 } 573 }
569 PWM_ASSERT(doc); 574 PWM_ASSERT(doc);
570 doc->timer()->getLock(DocTimer::id_autoLockTimer); 575 doc->timer()->getLock(DocTimer::id_autoLockTimer);
571#ifndef PWM_EMBEDDED 576#ifndef PWM_EMBEDDED
572 AddEntryWndImpl w; 577 AddEntryWndImpl w;
573#else 578#else
574 AddEntryWndImpl w(this, "addentrywndimpl"); 579 AddEntryWndImpl w(this, "addentrywndimpl");
575#endif 580#endif
576 581
577 vector<string> catList; 582 vector<string> catList;
578 doc->getCategoryList(&catList); 583 doc->getCategoryList(&catList);
579 unsigned i, size = catList.size(); 584 unsigned i, size = catList.size();
580 for (i = 0; i < size; ++i) { 585 for (i = 0; i < size; ++i) {
581 w.addCategory(catList[i].c_str()); 586 w.addCategory(catList[i].c_str());
582 } 587 }
583 w.setCurrCategory(view->getCurrentCategory()); 588 w.setCurrCategory(view->getCurrentCategory());
584 if (pw) 589 if (pw)
585 w.pwLineEdit->setText(*pw); 590 w.pwLineEdit->setText(*pw);
586 591
587 tryAgain: 592 tryAgain:
588 if (w.exec() == 1) 593 if (w.exec() == 1)
589 { 594 {
590 PwMDataItem d; 595 PwMDataItem d;
591 d.desc = w.getDescription().latin1(); 596 d.desc = w.getDescription().latin1();
592 d.name = w.getUsername().latin1(); 597 d.name = w.getUsername().latin1();
593 d.pw = w.getPassword().latin1(); 598 d.pw = w.getPassword().latin1();
594 d.comment = w.getComment().latin1(); 599 d.comment = w.getComment().latin1();
595 d.url = w.getUrl().latin1(); 600 d.url = w.getUrl().latin1();
596 d.launcher = w.getLauncher().latin1(); 601 d.launcher = w.getLauncher().latin1();
597 PwMerror ret = doc->addEntry(w.getCategory(), &d); 602 PwMerror ret = doc->addEntry(w.getCategory(), &d);
598 if (ret == e_entryExists) { 603 if (ret == e_entryExists) {
599 KMessageBox::error(this, 604 KMessageBox::error(this,
600 i18n 605 i18n
601 ("An entry with this \"Description\", " 606 ("An entry with this \"Description\", "
602 "does already exist.\n" 607 "does already exist.\n"
603 "Please select another description."), 608 "Please select another description."),
604 i18n("entry already exists.")); 609 i18n("entry already exists."));
605 goto tryAgain; 610 goto tryAgain;
606 } else if (ret == e_maxAllowedEntr) { 611 } else if (ret == e_maxAllowedEntr) {
607 KMessageBox::error(this, i18n("The maximum possible number of entries " 612 KMessageBox::error(this, i18n("The maximum possible number of entries "
608 "has been reached. You can't add more entries."), 613 "has been reached. You can't add more entries."),
609 i18n("maximum number of entries")); 614 i18n("maximum number of entries"));
610 doc->timer()->putLock(DocTimer::id_autoLockTimer); 615 doc->timer()->putLock(DocTimer::id_autoLockTimer);
611 return; 616 return;
612 } 617 }
613 } 618 }
614 setVirgin(false); 619 setVirgin(false);
615 doc->timer()->putLock(DocTimer::id_autoLockTimer); 620 doc->timer()->putLock(DocTimer::id_autoLockTimer);
616} 621}
617 622
618//US ENH : changed code to run with older MOC 623//US ENH : changed code to run with older MOC
619void PwM::editPwd_slot() 624void PwM::editPwd_slot()
620{ 625{
621 editPwd_slot(0,0,0); 626 editPwd_slot(0,0,0);
622} 627}
623 628
624void PwM::editPwd_slot(const QString *category) 629void PwM::editPwd_slot(const QString *category)
625{ 630{
626 editPwd_slot(category, 0, 0); 631 editPwd_slot(category, 0, 0);
627} 632}
628 633
629void PwM::editPwd_slot(const QString *category, const int *index, 634void PwM::editPwd_slot(const QString *category, const int *index,
630 PwMDoc *_doc) 635 PwMDoc *_doc)
631{ 636{
632 PwMDoc *doc; 637 PwMDoc *doc;
633 if (_doc) { 638 if (_doc) {
634 doc = _doc; 639 doc = _doc;
635 } else { 640 } else {
636 doc = curDoc(); 641 doc = curDoc();
637 } 642 }
638 PWM_ASSERT(doc); 643 PWM_ASSERT(doc);
639 if (doc->isDocEmpty()) 644 if (doc->isDocEmpty())
640 return; 645 return;
641 if (doc->isDeepLocked()) 646 if (doc->isDeepLocked())
642 return; 647 return;
643 doc->timer()->getLock(DocTimer::id_autoLockTimer); 648 doc->timer()->getLock(DocTimer::id_autoLockTimer);
644 unsigned int curEntryIndex; 649 unsigned int curEntryIndex;
645 if (index) { 650 if (index) {
646 curEntryIndex = *index; 651 curEntryIndex = *index;
647 } else { 652 } else {
648 if (!(view->getCurEntryIndex(&curEntryIndex))) { 653 if (!(view->getCurEntryIndex(&curEntryIndex))) {
649 printDebug("couldn't get index. Maybe we have a binary entry here."); 654 printDebug("couldn't get index. Maybe we have a binary entry here.");
650 doc->timer()->putLock(DocTimer::id_autoLockTimer); 655 doc->timer()->putLock(DocTimer::id_autoLockTimer);
651 return; 656 return;
652 } 657 }
653 } 658 }
654 QString curCategory; 659 QString curCategory;
655 if (category) { 660 if (category) {
656 curCategory = *category; 661 curCategory = *category;
657 } else { 662 } else {
658 curCategory = view->getCurrentCategory(); 663 curCategory = view->getCurrentCategory();
659 } 664 }
660 PwMDataItem currItem; 665 PwMDataItem currItem;
661 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 666 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
662 doc->timer()->putLock(DocTimer::id_autoLockTimer); 667 doc->timer()->putLock(DocTimer::id_autoLockTimer);
663 return; 668 return;
664 } 669 }
665 BUG_ON(currItem.binary); 670 BUG_ON(currItem.binary);
666 671
667 AddEntryWndImpl w; 672 AddEntryWndImpl w;
668 vector<string> catList; 673 vector<string> catList;
669 doc->getCategoryList(&catList); 674 doc->getCategoryList(&catList);
670 unsigned i, size = catList.size(); 675 unsigned i, size = catList.size();
671 for (i = 0; i < size; ++i) { 676 for (i = 0; i < size; ++i) {
672 w.addCategory(catList[i].c_str()); 677 w.addCategory(catList[i].c_str());
673 } 678 }
674 w.setCurrCategory(curCategory); 679 w.setCurrCategory(curCategory);
675 w.setDescription(currItem.desc.c_str()); 680 w.setDescription(currItem.desc.c_str());
676 w.setUsername(currItem.name.c_str()); 681 w.setUsername(currItem.name.c_str());
677 w.setPassword(currItem.pw.c_str()); 682 w.setPassword(currItem.pw.c_str());
678 w.setUrl(currItem.url.c_str()); 683 w.setUrl(currItem.url.c_str());
679 w.setLauncher(currItem.launcher.c_str()); 684 w.setLauncher(currItem.launcher.c_str());
680 w.setComment(currItem.comment.c_str()); 685 w.setComment(currItem.comment.c_str());
681 if (w.exec() == 1) { 686 if (w.exec() == 1) {
682 currItem.desc = w.getDescription().latin1(); 687 currItem.desc = w.getDescription().latin1();
683 currItem.name = w.getUsername().latin1(); 688 currItem.name = w.getUsername().latin1();
684 currItem.pw = w.getPassword().latin1(); 689 currItem.pw = w.getPassword().latin1();
685 currItem.comment = w.getComment().latin1(); 690 currItem.comment = w.getComment().latin1();
686 currItem.url = w.getUrl().latin1(); 691 currItem.url = w.getUrl().latin1();
687 currItem.launcher = w.getLauncher().latin1(); 692 currItem.launcher = w.getLauncher().latin1();
688 if (!doc->editEntry(curCategory, w.getCategory(), 693 if (!doc->editEntry(curCategory, w.getCategory(),
689 curEntryIndex, &currItem)) { 694 curEntryIndex, &currItem)) {
690 KMessageBox::error(this, 695 KMessageBox::error(this,
691 i18n("Couldn't edit the entry.\n" 696 i18n("Couldn't edit the entry.\n"
692 "Maybe you changed the category and " 697 "Maybe you changed the category and "
693 "this entry is already present in the new " 698 "this entry is already present in the new "
694 "category?"), 699 "category?"),
695 i18n("couldn't edit entry.")); 700 i18n("couldn't edit entry."));
696 doc->timer()->putLock(DocTimer::id_autoLockTimer); 701 doc->timer()->putLock(DocTimer::id_autoLockTimer);
697 return; 702 return;
698 } 703 }
699 } 704 }
700 doc->timer()->putLock(DocTimer::id_autoLockTimer); 705 doc->timer()->putLock(DocTimer::id_autoLockTimer);
701} 706}
702 707
703void PwM::deletePwd_slot() 708void PwM::deletePwd_slot()
704{ 709{
705 PWM_ASSERT(curDoc()); 710 PWM_ASSERT(curDoc());
706 if (curDoc()->isDocEmpty()) 711 if (curDoc()->isDocEmpty())
707 return; 712 return;
708 if (curDoc()->isDeepLocked()) 713 if (curDoc()->isDeepLocked())
709 return; 714 return;
710 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 715 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
711 unsigned int curEntryIndex = 0; 716 unsigned int curEntryIndex = 0;
712 if (!(view->getCurEntryIndex(&curEntryIndex))) { 717 if (!(view->getCurEntryIndex(&curEntryIndex))) {
713 printDebug("couldn't get index"); 718 printDebug("couldn't get index");
714 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 719 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
715 return; 720 return;
716 } 721 }
717 722
718 PwMDataItem currItem; 723 PwMDataItem currItem;
719 QString curCategory = view->getCurrentCategory(); 724 QString curCategory = view->getCurrentCategory();
720 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 725 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
721 printDebug("couldn't get entry"); 726 printDebug("couldn't get entry");
722 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 727 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
723 return; 728 return;
724 } 729 }
725 if (KMessageBox:: 730 if (KMessageBox::
726 questionYesNo(this, 731 questionYesNo(this,
727 i18n 732 i18n
728 ("Do you really want to delete the selected entry") + 733 ("Do you really want to delete\nthe selected entry") +
729 " \"" + QString(currItem.desc.c_str()) 734 " \n\"" + QString(currItem.desc.c_str())
730 + "\" ?", i18n("delete?")) 735 + "\" ?", i18n("delete?"))
731 == KMessageBox::Yes) { 736 == KMessageBox::Yes) {
732 737
733 curDoc()->delEntry(curCategory, curEntryIndex); 738 curDoc()->delEntry(curCategory, curEntryIndex);
734 } 739 }
735 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 740 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
736} 741}
737 742
738void PwM::changeMasterPwd_slot() 743void PwM::changeMasterPwd_slot()
739{ 744{
740 PWM_ASSERT(curDoc()); 745 PWM_ASSERT(curDoc());
741 curDoc()->changeCurrentPw(); 746 curDoc()->changeCurrentPw();
742} 747}
743 748
744void PwM::lockWnd_slot() 749void PwM::lockWnd_slot()
745{ 750{
746 PWM_ASSERT(curDoc()); 751 PWM_ASSERT(curDoc());
747 curDoc()->lockAll(true); 752 curDoc()->lockAll(true);
748} 753}
749 754
750void PwM::deepLockWnd_slot() 755void PwM::deepLockWnd_slot()
751{ 756{
752 PWM_ASSERT(curDoc()); 757 PWM_ASSERT(curDoc());
753 curDoc()->deepLock(); 758 curDoc()->deepLock();
754} 759}
755 760
756void PwM::unlockWnd_slot() 761void PwM::unlockWnd_slot()
757{ 762{
758 PWM_ASSERT(curDoc()); 763 PWM_ASSERT(curDoc());
759 curDoc()->lockAll(false); 764 curDoc()->lockAll(false);
760} 765}
761 766
762void PwM::config_slot() 767void PwM::config_slot()
763{ 768{
764 int oldStyle = conf()->confWndMainViewStyle(); 769 int oldStyle = conf()->confWndMainViewStyle();
765#ifdef PWM_EMBEDDED 770#ifdef PWM_EMBEDDED
766 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); 771 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true );
767 772
768 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); 773 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" );
769 ConfigureDialog->addModule(pwmcfg ); 774 ConfigureDialog->addModule(pwmcfg );
770 775
771 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 776 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
772 ConfigureDialog->addModule(kdelibcfg ); 777 ConfigureDialog->addModule(kdelibcfg );
773 778
774#ifndef DESKTOP_VERSION 779#ifndef DESKTOP_VERSION
775 ConfigureDialog->showMaximized(); 780 ConfigureDialog->showMaximized();
776#endif 781#endif
777 if ( ConfigureDialog->exec() ) 782 if ( ConfigureDialog->exec() )
778 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 783 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
779 delete ConfigureDialog; 784 delete ConfigureDialog;
780 785
781#else //PWM_EMBEDDED 786#else //PWM_EMBEDDED
782 // display the configuration window (modal mode) 787 // display the configuration window (modal mode)
783 if (!conf()->showConfWnd(this)) 788 if (!conf()->showConfWnd(this))
784 return; 789 return;
785#endif 790#endif
786 791
787 int newStyle = conf()->confWndMainViewStyle(); 792 int newStyle = conf()->confWndMainViewStyle();
788 // reinitialize tray 793 // reinitialize tray
789 init->initTray(); 794 init->initTray();
790 // reinitialize KWallet emulation 795 // reinitialize KWallet emulation
791 init->initKWalletEmu(); 796 init->initKWalletEmu();
792 797
793 PwMDocList *_dl = PwMDoc::getOpenDocList(); 798 PwMDocList *_dl = PwMDoc::getOpenDocList();
794 const vector<PwMDocList::listItem> *dl = _dl->getList(); 799 const vector<PwMDocList::listItem> *dl = _dl->getList();
795 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 800 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
796 end = dl->end(); 801 end = dl->end();
797 PwMDoc *doc; 802 PwMDoc *doc;
798 while (i != end) { 803 while (i != end) {
799 doc = (*i).doc; 804 doc = (*i).doc;
800 // unlock-without-mpw timeout 805 // unlock-without-mpw timeout
801 doc->timer()->start(DocTimer::id_mpwTimer); 806 doc->timer()->start(DocTimer::id_mpwTimer);
802 // auto-lock timeout 807 // auto-lock timeout
803 doc->timer()->start(DocTimer::id_autoLockTimer); 808 doc->timer()->start(DocTimer::id_autoLockTimer);
804 ++i; 809 ++i;
805 } 810 }
806 811
807 const QValueList<PwM *> *ml = init->mainWndList(); 812 const QValueList<PwM *> *ml = init->mainWndList();
808#ifndef PWM_EMBEDDED 813#ifndef PWM_EMBEDDED
809 QValueList<PwM *>::const_iterator i2 = ml->begin(), 814 QValueList<PwM *>::const_iterator i2 = ml->begin(),
810 end2 = ml->end(); 815 end2 = ml->end();
811#else 816#else
812 QValueList<PwM *>::ConstIterator i2 = ml->begin(), 817 QValueList<PwM *>::ConstIterator i2 = ml->begin(),
813 end2 = ml->end(); 818 end2 = ml->end();
814#endif 819#endif
815 PwM *pwm; 820 PwM *pwm;
816 while (i2 != end2) { 821 while (i2 != end2) {
817 pwm = *i2; 822 pwm = *i2;
818 // reinitialize the window style. 823 // reinitialize the window style.
819 if (oldStyle != newStyle) 824 if (oldStyle != newStyle)
820 pwm->curView()->initStyle(newStyle); 825 pwm->curView()->initStyle(newStyle);
821 // set the new font 826 // set the new font
822 pwm->curView()->setFont(conf()->confGlobEntryFont()); 827 pwm->curView()->setFont(conf()->confGlobEntryFont());
823 ++i2; 828 ++i2;
824 } 829 }
825} 830}
826 831
827void PwM::activateMpButton(bool activate) 832void PwM::activateMpButton(bool activate)
828{ 833{
829 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); 834 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
830} 835}
831 836
832void PwM::closeEvent(QCloseEvent *e) 837void PwM::closeEvent(QCloseEvent *e)
833{ 838{
834 e->accept(); 839 e->accept();
835} 840}
836 841
837void PwM::docClosed(PwMDoc *doc) 842void PwM::docClosed(PwMDoc *doc)
838{ 843{
839 PARAM_UNUSED(doc); 844 PARAM_UNUSED(doc);
840 PWM_ASSERT(doc == curDoc()); 845 PWM_ASSERT(doc == curDoc());
841 close(); 846 close();
842} 847}
843 848
844void PwM::find_slot() 849void PwM::find_slot()
845{ 850{
846 PWM_ASSERT(curDoc()); 851 PWM_ASSERT(curDoc());
847 if (curDoc()->isDocEmpty()) 852 if (curDoc()->isDocEmpty())
848 return; 853 return;
849 if (curDoc()->isDeepLocked()) 854 if (curDoc()->isDeepLocked())
850 return; 855 return;
851 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 856 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
852 FindWndImpl findWnd(view); 857 FindWndImpl findWnd(view);
853 findWnd.exec(); 858 findWnd.exec();
854 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 859 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
855} 860}
856 861
857void PwM::exportToText() 862void PwM::exportToText()
858{ 863{
859 PWM_ASSERT(curDoc()); 864 PWM_ASSERT(curDoc());
860 if (curDoc()->isDocEmpty()) { 865 if (curDoc()->isDocEmpty()) {
861 KMessageBox::information(this, 866 KMessageBox::information(this,
862 i18n 867 i18n
863 ("Sorry, there's nothing to export.\n" 868 ("Sorry, there's nothing to export.\n"
864 "Please first add some passwords."), 869 "Please first add some passwords."),
865 i18n("nothing to do")); 870 i18n("nothing to do"));
866 return; 871 return;
867 } 872 }
868 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 873 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
869 QString fn(KFileDialog::getSaveFileName(QString::null, 874 QString fn(KFileDialog::getSaveFileName(QString::null,
870 i18n("*|plain-text file"), 875 i18n("*|plain-text file"),
871 this)); 876 this));
872 if (fn == "") { 877 if (fn == "") {
873 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 878 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
874 return; 879 return;
875 } 880 }
876 881
877 PwMerror ret = curDoc()->exportToText(&fn); 882 PwMerror ret = curDoc()->exportToText(&fn);
878 if (ret != e_success) { 883 if (ret != e_success) {
879 KMessageBox::error(this, 884 KMessageBox::error(this,
880 i18n("Error: Couldn't write to file.\n" 885 i18n("Error: Couldn't write to file.\n"
881 "Please check if you have permission to write " 886 "Please check if you have permission to write "
882 "to the file in that directory."), 887 "to the file in that directory."),
883 i18n("error while writing")); 888 i18n("error while writing"));
884 } else 889 } else
885 showStatMsg(i18n("Successfully exported data.")); 890 showStatMsg(i18n("Successfully exported data."));
886 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 891 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
887} 892}
888 893
889bool PwM::importFromText() 894bool PwM::importFromText()
890{ 895{
891 if (!isVirgin()) { 896 if (!isVirgin()) {
892 if (KMessageBox::questionYesNo(this, 897 if (KMessageBox::questionYesNo(this,
893 i18n("Do you want to import the data " 898 i18n("Do you want to import the data "
894 "into the current document? (If you " 899 "into the current document? (If you "
895 "select \"no\", a new document will be " 900 "select \"no\", a new document will be "
896 "opened.)"), 901 "opened.)"),
897 i18n("import into this document?")) 902 i18n("import into this document?"))
898 == KMessageBox::No) { 903 == KMessageBox::No) {
899 // import the data to a new window. 904 // import the data to a new window.
900 PwM *newInstance = init->createMainWnd(); 905 PwM *newInstance = init->createMainWnd();
901 bool ok = newInstance->importFromText(); 906 bool ok = newInstance->importFromText();
902 if (!ok) { 907 if (!ok) {
903 newInstance->setForceQuit(true); 908 newInstance->setForceQuit(true);
904 delete_and_null(newInstance); 909 delete_and_null(newInstance);
905 } 910 }
906 return ok; 911 return ok;
907 } 912 }
908 } 913 }
909 914
910 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 915 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
911 PwMerror ret; 916 PwMerror ret;
912 QString path(KFileDialog::getOpenFileName(QString::null, 917 QString path(KFileDialog::getOpenFileName(QString::null,
913 i18n("*|PWM-exported text file"), 918 i18n("*|PWM-exported text file"),
914 this)); 919 this));
915 if (path == "") 920 if (path == "")
916 goto cancelImport; 921 goto cancelImport;
917 922
918 ret = curDoc()->importFromText(&path, 0); 923 ret = curDoc()->importFromText(&path, 0);
919 if (ret == e_fileFormat) { 924 if (ret == e_fileFormat) {
920 KMessageBox::error(this, 925 KMessageBox::error(this,
921 i18n("Could not read file-format.\n" 926 i18n("Could not read file-format.\n"
922 "This seems to be _not_ a valid file " 927 "This seems to be _not_ a valid file "
923 "exported by PwM."), 928 "exported by PwM."),
924 i18n("invalid file-format")); 929 i18n("invalid file-format"));
925 goto cancelImport; 930 goto cancelImport;
926 } else if (ret == e_invalidArg) { 931 } else if (ret == e_invalidArg) {
927 BUG(); 932 BUG();
928 goto cancelImport; 933 goto cancelImport;
929 } else if (ret != e_success) { 934 } else if (ret != e_success) {
930 KMessageBox::error(this, 935 KMessageBox::error(this,
931 i18n("Could not import file!\n" 936 i18n("Could not import file!\n"
932 "Do you have permission to read this file? " 937 "Do you have permission to read this file? "
933 "Do you have enough free memory?"), 938 "Do you have enough free memory?"),
934 i18n("import failed")); 939 i18n("import failed"));
935 goto cancelImport; 940 goto cancelImport;
936 } 941 }
937 setVirgin(false); 942 setVirgin(false);
938 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 943 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
939 return true; 944 return true;
940 945
941cancelImport: 946cancelImport:
942 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 947 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
943 return false; 948 return false;
944} 949}
945 950
946void PwM::exportToGpasman() 951void PwM::exportToGpasman()
947{ 952{
948 PWM_ASSERT(curDoc()); 953 PWM_ASSERT(curDoc());
949 if (curDoc()->isDocEmpty()) { 954 if (curDoc()->isDocEmpty()) {
950 KMessageBox::information(this, 955 KMessageBox::information(this,
951 i18n 956 i18n
952 ("Sorry, there's nothing to export.\n" 957 ("Sorry, there's nothing to export.\n"
953 "Please first add some passwords."), 958 "Please first add some passwords."),
954 i18n("nothing to do")); 959 i18n("nothing to do"));
955 return; 960 return;
956 } 961 }
957 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 962 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
958 QString fn(KFileDialog::getSaveFileName(QString::null, 963 QString fn(KFileDialog::getSaveFileName(QString::null,
959 i18n("*|Gpasman or Kpasman file"), 964 i18n("*|Gpasman or Kpasman file"),
960 this)); 965 this));
961 if (fn == "") { 966 if (fn == "") {
962 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 967 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
963 return; 968 return;
964 } 969 }
965 970
966 PwMerror ret = curDoc()->exportToGpasman(&fn); 971 PwMerror ret = curDoc()->exportToGpasman(&fn);
967 if (ret != e_success) { 972 if (ret != e_success) {
968 if (ret == e_noPw) { 973 if (ret == e_noPw) {
969 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 974 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
970 return; 975 return;
971 } 976 }
972 KMessageBox::error(this, 977 KMessageBox::error(this,
973 i18n("Error: Couldn't write to file.\n" 978 i18n("Error: Couldn't write to file.\n"
974 "Please check if you have permission to write " 979 "Please check if you have permission to write "
975 "to the file in that directory."), 980 "to the file in that directory."),
976 i18n("error while writing")); 981 i18n("error while writing"));
977 } else 982 } else
978 showStatMsg(i18n("Successfully exported data.")); 983 showStatMsg(i18n("Successfully exported data."));
979 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 984 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
980} 985}
981 986
982void PwM::exportToKWallet() 987void PwM::exportToKWallet()
983{ 988{
984#ifdef CONFIG_KWALLETIF 989#ifdef CONFIG_KWALLETIF
985 if (!checkAndAskForKWalletEmu()) 990 if (!checkAndAskForKWalletEmu())
986 return; 991 return;
987 PWM_ASSERT(curDoc()); 992 PWM_ASSERT(curDoc());
988 if (curDoc()->isDocEmpty()) { 993 if (curDoc()->isDocEmpty()) {
989 KMessageBox::information(this, 994 KMessageBox::information(this,
990 i18n 995 i18n
991 ("Sorry, there's nothing to export.\n" 996 ("Sorry, there's nothing to export.\n"
992 "Please first add some passwords."), 997 "Please first add some passwords."),
993 i18n("nothing to do")); 998 i18n("nothing to do"));
994 init->initKWalletEmu(); 999 init->initKWalletEmu();
995 return; 1000 return;
996 } 1001 }
997 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1002 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
998 KWalletIf walletIf(this); 1003 KWalletIf walletIf(this);
999 if (walletIf.kwalletExport(curDoc())) { 1004 if (walletIf.kwalletExport(curDoc())) {
1000 KMessageBox::information(this, 1005 KMessageBox::information(this,
1001 i18n("Successfully exported the data of the current " 1006 i18n("Successfully exported the data of the current "
1002 "document to KWallet."), 1007 "document to KWallet."),
1003 i18n("Successfully exported data.")); 1008 i18n("Successfully exported data."));
1004 showStatMsg(i18n("Successfully exported data.")); 1009 showStatMsg(i18n("Successfully exported data."));
1005 } 1010 }
1006 init->initKWalletEmu(); 1011 init->initKWalletEmu();
1007 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1012 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1008#endif // CONFIG_KWALLETIF 1013#endif // CONFIG_KWALLETIF
1009} 1014}
1010 1015
1011bool PwM::importFromGpasman() 1016bool PwM::importFromGpasman()
1012{ 1017{
1013 if (!isVirgin()) { 1018 if (!isVirgin()) {
1014 if (KMessageBox::questionYesNo(this, 1019 if (KMessageBox::questionYesNo(this,
1015 i18n("Do you want to import the data " 1020 i18n("Do you want to import the data "
1016 "into the current document? (If you " 1021 "into the current document? (If you "
1017 "select \"no\", a new document will be " 1022 "select \"no\", a new document will be "
1018 "opened.)"), 1023 "opened.)"),
1019 i18n("import into this document?")) 1024 i18n("import into this document?"))
1020 == KMessageBox::No) { 1025 == KMessageBox::No) {
1021 // import the data to a new window. 1026 // import the data to a new window.
1022 PwM *newInstance = init->createMainWnd(); 1027 PwM *newInstance = init->createMainWnd();
1023 bool ok = newInstance->importFromGpasman(); 1028 bool ok = newInstance->importFromGpasman();
1024 if (!ok) { 1029 if (!ok) {
1025 newInstance->setForceQuit(true); 1030 newInstance->setForceQuit(true);
1026 delete_and_null(newInstance); 1031 delete_and_null(newInstance);
1027 } 1032 }
1028 return ok; 1033 return ok;
1029 } 1034 }
1030 } 1035 }
1031 1036
1032 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1037 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1033 PwMerror ret; 1038 PwMerror ret;
1034 QString path(KFileDialog::getOpenFileName(QString::null, 1039 QString path(KFileDialog::getOpenFileName(QString::null,
1035 i18n("*|Gpasman or Kpasman file"), this)); 1040 i18n("*|Gpasman or Kpasman file"), this));
1036 if (path == "") 1041 if (path == "")
1037 goto cancelImport; 1042 goto cancelImport;
1038 ret = curDoc()->importFromGpasman(&path); 1043 ret = curDoc()->importFromGpasman(&path);
1039 if (ret == e_wrongPw) { 1044 if (ret == e_wrongPw) {
1040 if (KMessageBox::questionYesNo(this, 1045 if (KMessageBox::questionYesNo(this,
1041 i18n 1046 i18n
1042 ("This is probably the wrong master-password" 1047 ("This is probably the wrong master-password"
1043 "you have typed in.\n" 1048 "you have typed in.\n"
1044 "There is no real way to determine the " 1049 "There is no real way to determine the "
1045 "correctness of the password in the Gpasman " 1050 "correctness of the password in the Gpasman "
1046 "file-format. But I think this " 1051 "file-format. But I think this "
1047 "password ist wrong.\n" 1052 "password ist wrong.\n"
1048 "Do you want to continue nevertheless?"), 1053 "Do you want to continue nevertheless?"),
1049 i18n("password error")) 1054 i18n("password error"))
1050 == KMessageBox::No) { 1055 == KMessageBox::No) {
1051 goto cancelImport; 1056 goto cancelImport;
1052 } 1057 }
1053 } else if (ret != e_success) { 1058 } else if (ret != e_success) {
1054 KMessageBox::error(this, 1059 KMessageBox::error(this,
1055 i18n("Could not import file!\n" 1060 i18n("Could not import file!\n"
1056 "Do you have permission to read this file?"), 1061 "Do you have permission to read this file?"),
1057 i18n("import failed")); 1062 i18n("import failed"));
1058 goto cancelImport; 1063 goto cancelImport;
1059 } 1064 }
1060 setVirgin(false); 1065 setVirgin(false);
1061 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1066 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1062 return true; 1067 return true;
1063 1068
1064cancelImport: 1069cancelImport:
1065 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1070 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1066 return false; 1071 return false;
1067} 1072}
1068 1073
1069#ifdef CONFIG_KWALLETIF 1074#ifdef CONFIG_KWALLETIF
1070bool PwM::checkAndAskForKWalletEmu() 1075bool PwM::checkAndAskForKWalletEmu()
1071{ 1076{
1072 if (init->kwalletEmu()) { 1077 if (init->kwalletEmu()) {
1073 /* KWallet emulation is enabled. We can't import/export 1078 /* KWallet emulation is enabled. We can't import/export
1074 * data from/to it, while emulation is active. 1079 * data from/to it, while emulation is active.
1075 */ 1080 */
1076 if (KMessageBox::questionYesNo(this, 1081 if (KMessageBox::questionYesNo(this,
1077 i18n("KWallet emulation is enabled.\n" 1082 i18n("KWallet emulation is enabled.\n"
1078 "You can't import or export data from/to " 1083 "You can't import or export data from/to "
1079 "the original KWallet, while the emulation " 1084 "the original KWallet, while the emulation "
1080 "is active.\n" 1085 "is active.\n"
1081 "Do you want to tempoarly disable the KWallet emulation?"), 1086 "Do you want to tempoarly disable the KWallet emulation?"),
1082 i18n("Tempoarly disable KWallet emulation?")) 1087 i18n("Tempoarly disable KWallet emulation?"))
1083 == KMessageBox::Yes) { 1088 == KMessageBox::Yes) {
1084 init->initKWalletEmu(true); 1089 init->initKWalletEmu(true);
1085 PWM_ASSERT(!init->kwalletEmu()); 1090 PWM_ASSERT(!init->kwalletEmu());
1086 return true; 1091 return true;
1087 } 1092 }
1088 return false; 1093 return false;
1089 } 1094 }
1090 return true; 1095 return true;
1091} 1096}
1092#endif // CONFIG_KWALLETIF 1097#endif // CONFIG_KWALLETIF
1093 1098
1094bool PwM::importKWallet() 1099bool PwM::importKWallet()
1095{ 1100{
1096#ifdef CONFIG_KWALLETIF 1101#ifdef CONFIG_KWALLETIF
1097 if (!checkAndAskForKWalletEmu()) 1102 if (!checkAndAskForKWalletEmu())
1098 return false; 1103 return false;
1099 KWalletIf walletIf(this); 1104 KWalletIf walletIf(this);
1100 if (!isVirgin()) { 1105 if (!isVirgin()) {
1101 if (KMessageBox::questionYesNo(this, 1106 if (KMessageBox::questionYesNo(this,
1102 i18n("Do you want to import the data " 1107 i18n("Do you want to import the data "
1103 "into the current document? (If you " 1108 "into the current document? (If you "
1104 "select \"no\", a new document will be " 1109 "select \"no\", a new document will be "
1105 "opened.)"), 1110 "opened.)"),
1106 i18n("import into this document?")) 1111 i18n("import into this document?"))
1107 == KMessageBox::No) { 1112 == KMessageBox::No) {
1108 // import the data to a new window. 1113 // import the data to a new window.
1109 PwM *newInstance = init->createMainWnd(); 1114 PwM *newInstance = init->createMainWnd();
1110 bool ok = newInstance->importKWallet(); 1115 bool ok = newInstance->importKWallet();
1111 if (!ok) { 1116 if (!ok) {
1112 newInstance->setForceQuit(true); 1117 newInstance->setForceQuit(true);
1113 delete_and_null(newInstance); 1118 delete_and_null(newInstance);
1114 goto exit_fail; 1119 goto exit_fail;
1115 } else { 1120 } else {
1116 goto exit_ok; 1121 goto exit_ok;
1117 } 1122 }
1118 } 1123 }
1119 } 1124 }
1120 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1125 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1121 if (!walletIf.kwalletImport(curDoc())) { 1126 if (!walletIf.kwalletImport(curDoc())) {
1122 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1127 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1123 showStatMsg(i18n("KWallet import failed")); 1128 showStatMsg(i18n("KWallet import failed"));
1124 goto exit_fail; 1129 goto exit_fail;
1125 } 1130 }
1126 KMessageBox::information(this, 1131 KMessageBox::information(this,
1127 i18n("Successfully imported the KWallet data " 1132 i18n("Successfully imported the KWallet data "
1128 "into the current document."), 1133 "into the current document."),
1129 i18n("successfully imported")); 1134 i18n("successfully imported"));
1130 showStatMsg(i18n("successfully imported")); 1135 showStatMsg(i18n("successfully imported"));
1131 setVirgin(false); 1136 setVirgin(false);
1132 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1137 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1133 1138
1134exit_ok: 1139exit_ok:
1135 init->initKWalletEmu(); 1140 init->initKWalletEmu();
1136 return true; 1141 return true;
1137 1142
1138exit_fail: 1143exit_fail:
1139 init->initKWalletEmu(); 1144 init->initKWalletEmu();
1140#endif // CONFIG_KWALLETIF 1145#endif // CONFIG_KWALLETIF
1141 return false; 1146 return false;
1142} 1147}
1143 1148
1144void PwM::print_slot() 1149void PwM::print_slot()
1145{ 1150{
1146 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1151 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1147#ifndef PWM_EMBEDDED 1152#ifndef PWM_EMBEDDED
1148 PwMPrint p(curDoc(), this); 1153 PwMPrint p(curDoc(), this);
1149 p.printNow(); 1154 p.printNow();
1150#else 1155#else
1151 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); 1156 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED");
1152#endif 1157#endif
1153 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1158 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1154} 1159}
1155 1160
1156void PwM::genNewCard_slot() 1161void PwM::genNewCard_slot()
1157{ 1162{
1158#ifdef CONFIG_KEYCARD 1163#ifdef CONFIG_KEYCARD
1159 init->keycard()->genNewCard(); 1164 init->keycard()->genNewCard();
1160#endif 1165#endif
1161} 1166}
1162 1167
1163void PwM::eraseCard_slot() 1168void PwM::eraseCard_slot()
1164{ 1169{
1165#ifdef CONFIG_KEYCARD 1170#ifdef CONFIG_KEYCARD
1166 init->keycard()->eraseCard(); 1171 init->keycard()->eraseCard();
1167#endif 1172#endif
1168} 1173}
1169 1174
1170void PwM::readCardId_slot() 1175void PwM::readCardId_slot()
1171{ 1176{
1172#ifdef CONFIG_KEYCARD 1177#ifdef CONFIG_KEYCARD
1173 init->keycard()->displayKey(); 1178 init->keycard()->displayKey();
1174#endif 1179#endif
1175} 1180}
1176 1181
1177void PwM::makeCardBackup_slot() 1182void PwM::makeCardBackup_slot()
1178{ 1183{
1179#ifdef CONFIG_KEYCARD 1184#ifdef CONFIG_KEYCARD
1180 init->keycard()->makeBackupImage(); 1185 init->keycard()->makeBackupImage();
1181#endif 1186#endif
1182} 1187}
1183 1188
1184void PwM::replayCardBackup_slot() 1189void PwM::replayCardBackup_slot()
1185{ 1190{
1186#ifdef CONFIG_KEYCARD 1191#ifdef CONFIG_KEYCARD
1187 init->keycard()->replayBackupImage(); 1192 init->keycard()->replayBackupImage();
1188#endif 1193#endif
1189} 1194}
1190 1195
1191void PwM::execLauncher_slot() 1196void PwM::execLauncher_slot()
1192{ 1197{
1193 PWM_ASSERT(curDoc()); 1198 PWM_ASSERT(curDoc());
1194 if (curDoc()->isDeepLocked()) 1199 if (curDoc()->isDeepLocked())
1195 return; 1200 return;
1196 unsigned int curEntryIndex; 1201 unsigned int curEntryIndex;
1197 if (!view->getCurEntryIndex(&curEntryIndex)) 1202 if (!view->getCurEntryIndex(&curEntryIndex))
1198 return; 1203 return;
1199 bool ret = curDoc()->execLauncher(view->getCurrentCategory(), 1204 bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
1200 curEntryIndex); 1205 curEntryIndex);
1201 if (ret) 1206 if (ret)
1202 showStatMsg(i18n("Executed the \"Launcher\".")); 1207 showStatMsg(i18n("Executed the \"Launcher\"."));
1203 else 1208 else
1204 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); 1209 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
1205} 1210}
1206 1211
1207void PwM::goToURL_slot() 1212void PwM::goToURL_slot()
1208{ 1213{
1209 PWM_ASSERT(curDoc()); 1214 PWM_ASSERT(curDoc());
1210 if (curDoc()->isDeepLocked()) 1215 if (curDoc()->isDeepLocked())
1211 return; 1216 return;
1212 unsigned int curEntryIndex; 1217 unsigned int curEntryIndex;
1213 if (!view->getCurEntryIndex(&curEntryIndex)) 1218 if (!view->getCurEntryIndex(&curEntryIndex))
1214 return; 1219 return;
1215 bool ret = curDoc()->goToURL(view->getCurrentCategory(), 1220 bool ret = curDoc()->goToURL(view->getCurrentCategory(),
1216 curEntryIndex); 1221 curEntryIndex);
1217 if (ret) 1222 if (ret)
1218 showStatMsg(i18n("started browser with current URL.")); 1223 showStatMsg(i18n("started browser with current URL."));
1219 else 1224 else
1220 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); 1225 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
1221} 1226}
1222 1227
1223void PwM::copyToClipboard(const QString &s) 1228void PwM::copyToClipboard(const QString &s)
1224{ 1229{
1225 QClipboard *cb = QApplication::clipboard(); 1230 QClipboard *cb = QApplication::clipboard();
1226#ifndef PWM_EMBEDDED 1231#ifndef PWM_EMBEDDED
1227 if (cb->supportsSelection()) 1232 if (cb->supportsSelection())
1228 cb->setText(s, QClipboard::Selection); 1233 cb->setText(s, QClipboard::Selection);
1229 cb->setText(s, QClipboard::Clipboard); 1234 cb->setText(s, QClipboard::Clipboard);
1230#else 1235#else
1231 cb->setText(s); 1236 cb->setText(s);
1232 1237
1233#endif 1238#endif
1234 1239
1235} 1240}
1236 1241
1237void PwM::showStatMsg(const QString &msg) 1242void PwM::showStatMsg(const QString &msg)
1238{ 1243{
1239#ifndef PWM_EMBEDDED 1244#ifndef PWM_EMBEDDED
1240 KStatusBar *statBar = statusBar(); 1245 KStatusBar *statBar = statusBar();
1241 statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); 1246 statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1242#else 1247#else
1243 qDebug("Statusbar : %s",msg.latin1()); 1248 qDebug("Statusbar : %s",msg.latin1());
1244#endif 1249#endif
1245} 1250}
1246 1251
1247void PwM::focusInEvent(QFocusEvent *e) 1252void PwM::focusInEvent(QFocusEvent *e)
1248{ 1253{
1249 if (e->gotFocus()) { 1254 if (e->gotFocus()) {
1250 emit gotFocus(this); 1255 emit gotFocus(this);
1251 } else if (e->lostFocus()) { 1256 } else if (e->lostFocus()) {
1252 emit lostFocus(this); 1257 emit lostFocus(this);
1253 } 1258 }
1254} 1259}
1255 1260
1256 1261
1257#ifdef PWM_EMBEDDED 1262#ifdef PWM_EMBEDDED
1258 1263
1259void PwM::showLicense_slot() 1264void PwM::showLicense_slot()
1260{ 1265{
1261 KApplication::showLicence(); 1266 KApplication::showLicence();
1262} 1267}
1263 1268
1264void PwM::faq_slot() 1269void PwM::faq_slot()
1265{ 1270{
1266 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); 1271 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
1267} 1272}
1268 1273
1269void PwM::createAboutData_slot() 1274void PwM::createAboutData_slot()
1270{ 1275{
1271 QString version; 1276 QString version;
1272#include <../version> 1277#include <../version>
1273 QMessageBox::about( this, "About PwManager/Pi", 1278 QMessageBox::about( this, "About PwManager/Pi",
1274 "PwManager/Platform-independent\n" 1279 "PwManager/Platform-independent\n"
1275 "(PWM/Pi) " +version + " - " + 1280 "(PWM/Pi) " +version + " - " +
1276#ifdef DESKTOP_VERSION 1281#ifdef DESKTOP_VERSION
1277 "Desktop Edition\n" 1282 "Desktop Edition\n"
1278#else 1283#else
1279 "PDA-Edition\n" 1284 "PDA-Edition\n"
1280 "for: Zaurus 5500 / 7x0 / 8x0\n" 1285 "for: Zaurus 5500 / 7x0 / 8x0\n"
1281#endif 1286#endif
1282 1287
1283 "(c) 2004 Ulf Schenk\n" 1288 "(c) 2004 Ulf Schenk\n"
1284 "(c) 2004 Lutz Rogowski\n" 1289 "(c) 2004 Lutz Rogowski\n"
1285 "(c) 1997-2003, The KDE PIM Team\n" 1290 "(c) 1997-2004, The KDE PIM Team\n"
1286 1291
1287 "Michael Buesch - main programming and current maintainer\nmbuesch@freenet.de\n" 1292 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n"
1288 "Matt Scifo - original implementaion of \n" 1293 "Matt Scifo - mscifo@o1.com\n"
1289 "\"categories\" and the password-tree \n" 1294 "Elias Probst - elias.probst@gmx.de\n"
1290 "in the system-tray. Original implementations of \n" 1295 "George Staikos - staikos@kde.org\n"
1291 "numerous view-improvements.\n" 1296 "Matthew Palmer - mjp16@uow.edu.au\n"
1292 "mscifo@o1.com\n" 1297 "Olivier Sessink - gpasman@nl.linux.org\n"
1293 "Elias Probst - Gentoo ebuild maintainer.\nelias.probst@gmx.de\n" 1298 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
1294 "George Staikos - KWallet\nstaikos@kde.org\n" 1299 "Troy Engel - tengel@sonic.net\n"
1295 "Matthew Palmer - rc2 code\nmjp16@uow.edu.au\n" 1300 "Wickey - wickey@gmx.at\n"
1296 "Olivier Sessink - gpasman\ngpasman@nl.linux.org\n"
1297 "The libgcrypt developers - Blowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
1298 "Troy Engel - kpasman\n tengel@sonic.net\n"
1299 "Wickey - graphics-design in older versions\nwickey@gmx.at\n"
1300 "Ian MacGregor - original documentation author.\n" 1301 "Ian MacGregor - original documentation author.\n"
1301 ); 1302 );
1302} 1303}
1303 1304
1304#endif 1305#endif
1305 1306
1306 1307
1307#ifndef PWM_EMBEDDED 1308#ifndef PWM_EMBEDDED
1308#include "pwm.moc" 1309#include "pwm.moc"
1309#endif 1310#endif
diff --git a/pwmanager/pwmanager/pwmanagerE.pro b/pwmanager/pwmanager/pwmanagerE.pro
index 87142b7..b0c9236 100644
--- a/pwmanager/pwmanager/pwmanagerE.pro
+++ b/pwmanager/pwmanager/pwmanagerE.pro
@@ -1,153 +1,153 @@
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 $(QPEDIR)/include 10INCLUDEPATH += . ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include
11DEFINES += PWM_EMBEDDED PWM_DEBUG 11DEFINES += PWM_EMBEDDED PWM_DEBUG
12LIBS += -lmicrokde 12LIBS += -lmicrokde
13LIBS += -lmicroqtcompat 13LIBS += -lmicroqtcompat
14LIBS += -lmicrokdepim 14LIBS += -lmicrokdepim
15LIBS += -L$(QPEDIR)/lib 15LIBS += -L$(QPEDIR)/lib
16LIBS += -lqpe 16LIBS += -lqpe
17LIBS += -lbz2 17LIBS += -lbz2
18LIBS += $(QTOPIALIB) 18LIBS += $(QTOPIALIB)
19 19
20#INTERFACES = \ 20#INTERFACES = \
21#addentrywnd.ui \ 21#addentrywnd.ui \
22#configwnd.ui \ 22#configwnd.ui \
23#findwnd.ui \ 23#findwnd.ui \
24#getmasterpwwnd.ui \ 24#getmasterpwwnd.ui \
25#pwgenwnd.ui \ 25#pwgenwnd.ui \
26#setmasterpwwnd.ui \ 26#setmasterpwwnd.ui \
27#subtbledit.ui 27#subtbledit.ui
28 28
29#INTERFACES = \ 29#INTERFACES = \
30#subtbledit.ui \ 30#subtbledit.ui \
31 31
32 32
33 33
34#HEADERS = \ 34#HEADERS = \
35#configuration_31compat.h \ 35#configuration_31compat.h \
36#configuration.h \ 36#configuration.h \
37#configwnd.h \ 37#configwnd.h \
38#configwndimpl.h \ 38#configwndimpl.h \
39#selftest.h 39#selftest.h
40 40
41HEADERS = \ 41HEADERS = \
42addentrywnd_emb.h \ 42addentrywnd_emb.h \
43addentrywndimpl.h \ 43addentrywndimpl.h \
44base64.h \ 44base64.h \
45binentrygen.h \ 45binentrygen.h \
46blowfish.h \ 46blowfish.h \
47commentbox.h \ 47commentbox.h \
48compiler.h \ 48compiler.h \
49compressbzip2.h \ 49compressbzip2.h \
50compressgzip.h \ 50compressgzip.h \
51findwnd.h \ 51findwnd_emb.h \
52findwndimpl.h \ 52findwndimpl.h \
53genpasswd.h \ 53genpasswd.h \
54getkeycardwnd.h \ 54getkeycardwnd.h \
55getmasterpwwnd.h \ 55getmasterpwwnd_emb.h \
56getmasterpwwndimpl.h \ 56getmasterpwwndimpl.h \
57globalstuff.h \ 57globalstuff.h \
58gpasmanfile.h \ 58gpasmanfile.h \
59htmlgen.h \ 59htmlgen.h \
60htmlparse.h \ 60htmlparse.h \
61ipc.h \ 61ipc.h \
62listobjselectwnd.h \ 62listobjselectwnd.h \
63listviewpwm.h \ 63listviewpwm.h \
64printtext.h \ 64printtext.h \
65pwgenwnd_emb.h \ 65pwgenwnd_emb.h \
66pwgenwndimpl.h \ 66pwgenwndimpl.h \
67pwmdoc.h \ 67pwmdoc.h \
68pwmdocui.h \ 68pwmdocui.h \
69pwmexception.h \ 69pwmexception.h \
70pwm.h \ 70pwm.h \
71pwminit.h \ 71pwminit.h \
72pwmprefs.h \ 72pwmprefs.h \
73pwmprint.h \ 73pwmprint.h \
74pwmtray.h \ 74pwmtray.h \
75pwmview.h \ 75pwmview.h \
76pwmviewstyle_0.h \ 76pwmviewstyle_0.h \
77pwmviewstyle_1.h \ 77pwmviewstyle_1.h \
78pwmviewstyle.h \ 78pwmviewstyle.h \
79randomizer.h \ 79randomizer.h \
80rc2.h \ 80rc2.h \
81rencatwnd.h \ 81rencatwnd.h \
82serializer.h \ 82serializer.h \
83setmasterpwwnd.h \ 83setmasterpwwnd_emb.h \
84setmasterpwwndimpl.h \ 84setmasterpwwndimpl.h \
85sha1.h \ 85sha1.h \
86subtbledit.h \ 86subtbledit.h \
87subtbleditimpl.h \ 87subtbleditimpl.h \
88waitwnd.h \ 88waitwnd.h \
89kcmconfigs/kcmpwmconfig.h \ 89kcmconfigs/kcmpwmconfig.h \
90kcmconfigs/pwmconfigwidget.h \ 90kcmconfigs/pwmconfigwidget.h \
91 91
92#sources that need not be build 92#sources that need not be build
93#SOURCES = \ 93#SOURCES = \
94#advcommeditimpl.cpp \ 94#advcommeditimpl.cpp \
95#configuration.cpp \ 95#configuration.cpp \
96#configwnd.cpp \ 96#configwnd.cpp \
97#configwndimpl.cpp \ 97#configwndimpl.cpp \
98#configuration_31compat.cpp \ 98#configuration_31compat.cpp \
99#htmlparse.cpp \ 99#htmlparse.cpp \
100#printtext.cpp \ 100#printtext.cpp \
101#selftest.cpp \ 101#selftest.cpp \
102#pwmprint.cpp \ 102#pwmprint.cpp \
103#spinforsignal.cpp 103#spinforsignal.cpp
104 104
105SOURCES = \ 105SOURCES = \
106addentrywnd_emb.cpp \ 106addentrywnd_emb.cpp \
107addentrywndimpl.cpp \ 107addentrywndimpl.cpp \
108base64.cpp \ 108base64.cpp \
109binentrygen.cpp \ 109binentrygen.cpp \
110blowfish.cpp \ 110blowfish.cpp \
111commentbox.cpp \ 111commentbox.cpp \
112compressbzip2.cpp \ 112compressbzip2.cpp \
113compressgzip.cpp \ 113compressgzip.cpp \
114findwnd.cpp \ 114findwnd_emb.cpp \
115findwndimpl.cpp \ 115findwndimpl.cpp \
116genpasswd.cpp \ 116genpasswd.cpp \
117getkeycardwnd.cpp \ 117getkeycardwnd.cpp \
118getmasterpwwnd.cpp \ 118getmasterpwwnd_emb.cpp \
119getmasterpwwndimpl.cpp \ 119getmasterpwwndimpl.cpp \
120globalstuff.cpp \ 120globalstuff.cpp \
121gpasmanfile.cpp \ 121gpasmanfile.cpp \
122htmlgen.cpp \ 122htmlgen.cpp \
123ipc.cpp \ 123ipc.cpp \
124listobjselectwnd.cpp \ 124listobjselectwnd.cpp \
125listviewpwm.cpp \ 125listviewpwm.cpp \
126main.cpp \ 126main.cpp \
127pwgenwnd_emb.cpp \ 127pwgenwnd_emb.cpp \
128pwgenwndimpl.cpp \ 128pwgenwndimpl.cpp \
129pwm.cpp \ 129pwm.cpp \
130pwmdoc.cpp \ 130pwmdoc.cpp \
131pwmdocui.cpp \ 131pwmdocui.cpp \
132pwmexception.cpp \ 132pwmexception.cpp \
133pwminit.cpp \ 133pwminit.cpp \
134pwmprefs.cpp \ 134pwmprefs.cpp \
135pwmtray.cpp \ 135pwmtray.cpp \
136pwmview.cpp \ 136pwmview.cpp \
137pwmviewstyle_0.cpp \ 137pwmviewstyle_0.cpp \
138pwmviewstyle_1.cpp \ 138pwmviewstyle_1.cpp \
139pwmviewstyle.cpp \ 139pwmviewstyle.cpp \
140randomizer.cpp \ 140randomizer.cpp \
141rc2.cpp \ 141rc2.cpp \
142rencatwnd.cpp \ 142rencatwnd.cpp \
143serializer.cpp \ 143serializer.cpp \
144setmasterpwwnd.cpp \ 144setmasterpwwnd_emb.cpp \
145setmasterpwwndimpl.cpp \ 145setmasterpwwndimpl.cpp \
146sha1.cpp \ 146sha1.cpp \
147subtbledit.cpp \ 147subtbledit.cpp \
148subtbleditimpl.cpp \ 148subtbleditimpl.cpp \
149waitwnd.cpp \ 149waitwnd.cpp \
150kcmconfigs/kcmpwmconfig.cpp \ 150kcmconfigs/kcmpwmconfig.cpp \
151kcmconfigs/pwmconfigwidget.cpp \ 151kcmconfigs/pwmconfigwidget.cpp \
152 152
153 153
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index 3993fa8..e42dd9d 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -1,454 +1,457 @@
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 "pwmdocui.h" 20#include "pwmdocui.h"
21#include "setmasterpwwndimpl.h" 21#include "setmasterpwwndimpl.h"
22#include "getmasterpwwndimpl.h" 22#include "getmasterpwwndimpl.h"
23#include "pwmexception.h" 23#include "pwmexception.h"
24#include "getkeycardwnd.h" 24#include "getkeycardwnd.h"
25#include "pwm.h" 25#include "pwm.h"
26#include "globalstuff.h" 26#include "globalstuff.h"
27#include "spinforsignal.h" 27#include "spinforsignal.h"
28 28
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31 31
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33#include <kfiledialog.h> 33#include <kfiledialog.h>
34 34
35#ifndef PWM_EMBEDDED 35#ifndef PWM_EMBEDDED
36#include <kwin.h> 36#include <kwin.h>
37#else 37#else
38#include <qdir.h> 38#include <qdir.h>
39#include "pwmprefs.h" 39#include "pwmprefs.h"
40#endif 40#endif
41 41
42 42
43#ifdef CONFIG_KEYCARD 43#ifdef CONFIG_KEYCARD
44# include "pwmkeycard.h" 44# include "pwmkeycard.h"
45#endif 45#endif
46 46
47 47
48PwMDocUi::PwMDocUi(QObject *parent, const char *name) 48PwMDocUi::PwMDocUi(QObject *parent, const char *name)
49 : QObject(parent, name) 49 : QObject(parent, name)
50{ 50{
51 currentView = 0; 51 currentView = 0;
52 keyCard = 0; 52 keyCard = 0;
53} 53}
54 54
55PwMDocUi::~PwMDocUi() 55PwMDocUi::~PwMDocUi()
56{ 56{
57} 57}
58 58
59QString PwMDocUi::requestMpw(bool chipcard) 59QString PwMDocUi::requestMpw(bool chipcard)
60{ 60{
61 QString pw; 61 QString pw;
62 62
63 if (chipcard) { 63 if (chipcard) {
64#ifdef CONFIG_KEYCARD 64#ifdef CONFIG_KEYCARD
65 PWM_ASSERT(keyCard); 65 PWM_ASSERT(keyCard);
66 uint32_t id; 66 uint32_t id;
67 string ret; 67 string ret;
68 SpinForSignal *spinner = keyCard->getSpinner(); 68 SpinForSignal *spinner = keyCard->getSpinner();
69 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 69 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
70 spinner, SLOT(u32_str_slot(uint32_t, const string &))); 70 spinner, SLOT(u32_str_slot(uint32_t, const string &)));
71 keyCard->getKey(); 71 keyCard->getKey();
72 spinner->spin(&id, &ret); 72 spinner->spin(&id, &ret);
73 disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 73 disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
74 spinner, SLOT(u32_str_slot(uint32_t, const string &))); 74 spinner, SLOT(u32_str_slot(uint32_t, const string &)));
75 if (ret == "") 75 if (ret == "")
76 return ""; 76 return "";
77 pw = ret.c_str(); 77 pw = ret.c_str();
78#else // CONFIG_KEYCARD 78#else // CONFIG_KEYCARD
79 no_keycard_support_msg_box(currentView); 79 no_keycard_support_msg_box(currentView);
80#endif // CONFIG_KEYCARD 80#endif // CONFIG_KEYCARD
81 } else { 81 } else {
82 GetMasterPwWndImpl pwWnd;
83#ifndef PWM_EMBEDDED 82#ifndef PWM_EMBEDDED
83 GetMasterPwWndImpl pwWnd;
84 KWin::setState(pwWnd.winId(), NET::StaysOnTop); 84 KWin::setState(pwWnd.winId(), NET::StaysOnTop);
85#else
86 GetMasterPwWndImpl pwWnd;
85#endif 87#endif
86 if (pwWnd.exec() != 1) 88 if (pwWnd.exec() != 1)
87 return ""; 89 return "";
88 pw = pwWnd.pwLineEdit->text(); 90 pw = pwWnd.pwLineEdit->text();
89 } 91 }
90 92
91 return pw; 93 return pw;
92} 94}
93 95
94QString PwMDocUi::requestNewMpw(bool *chipcard) 96QString PwMDocUi::requestNewMpw(bool *chipcard)
95{ 97{
96 QString pw; 98 QString pw;
97 SetMasterPwWndImpl pwWnd(currentView); 99 SetMasterPwWndImpl pwWnd(currentView);
98 pwWnd.setPwMKeyCard(keyCard); 100 pwWnd.setPwMKeyCard(keyCard);
99#ifndef PWM_EMBEDDED
100 if (!chipcard) { 101 if (!chipcard) {
102#ifndef PWM_EMBEDDED
101 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1)); 103 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1));
102 }
103#else 104#else
104 qDebug("PwMDocUi::requestNewMpw must be implemented"); 105 pwWnd.mainTab->removePage(pwWnd.tab_2);
105#endif 106#endif
107 }
106 108
107 if (pwWnd.exec() != 1) 109 if (pwWnd.exec() != 1)
108 return ""; 110 return "";
109 pw = pwWnd.getPw(chipcard).c_str(); 111 pw = pwWnd.getPw(chipcard).c_str();
110 112
111 return pw; 113 return pw;
112} 114}
113 115
114QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard) 116QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard)
115{ 117{
116 QString pw(requestMpw(*chipcard)); 118 QString pw(requestMpw(*chipcard));
117 if (pw == "") 119 if (pw == "")
118 return ""; 120 return "";
119 if (pw != *currentPw) { 121 if (pw != *currentPw) {
120 wrongMpwMsgBox(*chipcard); 122 wrongMpwMsgBox(*chipcard);
121 return ""; 123 return "";
122 } 124 }
123 125
124 pw = requestNewMpw(chipcard); 126 pw = requestNewMpw(chipcard);
125 if (pw == "") 127 if (pw == "")
126 return ""; 128 return "";
127 return pw; 129 return pw;
128} 130}
129 131
130void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix) 132void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix)
131{ 133{
132 QString msg; 134 QString msg;
133 if (prefix != "") { 135 if (prefix != "") {
134 msg += prefix; 136 msg += prefix;
135 msg += "\n"; 137 msg += "\n";
136 } 138 }
137 139
138 if (chipcard) { 140 if (chipcard) {
139 msg += i18n("Wrong key-card!\n" 141 msg += i18n("Wrong key-card!\n"
140 "Please try again with the " 142 "Please try again with the\n"
141 "correct key-card."); 143 "correct key-card.");
142 } else { 144 } else {
143 msg += i18n("Wrong master-password!\n" 145 msg += i18n("Wrong master-password!\n"
144 "Please try again."); 146 "Please try again.");
145 } 147 }
146 148
147 if (postfix != "") { 149 if (postfix != "") {
148 msg += "\n"; 150 msg += "\n";
149 msg += postfix; 151 msg += postfix;
150 } 152 }
151 KMessageBox::error(currentView, msg, 153 KMessageBox::error(currentView, msg,
152 (chipcard) ? (i18n("wrong chipcard")) 154 (chipcard) ? (i18n("wrong chipcard"))
153 : (i18n("password error"))); 155 : (i18n("password error")));
154} 156}
155 157
156void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix) 158void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix)
157{ 159{
158 QString msg; 160 QString msg;
159 if (prefix != "") { 161 if (prefix != "") {
160 msg += prefix; 162 msg += prefix;
161 msg += "\n"; 163 msg += "\n";
162 } 164 }
163 165
164 if (chipcard) { 166 if (chipcard) {
165 msg += i18n("No key-card found!\n" 167 msg += i18n("No key-card found!\n"
166 "Please insert the " 168 "Please insert the\n"
167 "correct key-card."); 169 "correct key-card.");
168 } else { 170 } else {
169 msg += i18n("No master-password given!"); 171 msg += i18n("No master-password given!");
170 } 172 }
171 173
172 if (postfix != "") { 174 if (postfix != "") {
173 msg += "\n"; 175 msg += "\n";
174 msg += postfix; 176 msg += postfix;
175 } 177 }
176 KMessageBox::error(currentView, msg, 178 KMessageBox::error(currentView, msg,
177 (chipcard) ? (i18n("no chipcard")) 179 (chipcard) ? (i18n("no chipcard"))
178 : (i18n("password error"))); 180 : (i18n("password error")));
179} 181}
180 182
181void PwMDocUi::rootAlertMsgBox() 183void PwMDocUi::rootAlertMsgBox()
182{ 184{
183 KMessageBox::error(currentView, 185 KMessageBox::error(currentView,
184 i18n("This feature is not available, " 186 i18n("This feature is not available, "
185 "if you execute PwM with \"root\" " 187 "if you execute PwM with \"root\" "
186 "UID 0 privileges, for security reasons!"), 188 "UID 0 privileges, for security reasons!"),
187 i18n("not allowed as root!")); 189 i18n("not allowed as root!"));
188} 190}
189 191
190void PwMDocUi::cantDeeplock_notSavedMsgBox() 192void PwMDocUi::cantDeeplock_notSavedMsgBox()
191{ 193{
192 KMessageBox::error(currentView, 194 KMessageBox::error(currentView,
193 i18n("Can't deep-lock, because the document " 195 i18n("Can't deep-lock, because the document "
194 "hasn't been saved, yet. Please save " 196 "hasn't been saved, yet. Please save "
195 "to a file and try again."), 197 "to a file and try again."),
196 i18n("not saved, yet")); 198 i18n("not saved, yet"));
197} 199}
198 200
199void PwMDocUi::gpmPwLenErrMsgBox() 201void PwMDocUi::gpmPwLenErrMsgBox()
200{ 202{
201 KMessageBox::error(currentView, 203 KMessageBox::error(currentView,
202 i18n("GPasman does not support passwords " 204 i18n("GPasman does not support passwords "
203 "shorter than 4 characters! Please try " 205 "shorter than 4 characters! Please try "
204 "again with a longer password."), 206 "again with a longer password."),
205 i18n("password too short")); 207 i18n("password too short"));
206} 208}
207 209
208int PwMDocUi::dirtyAskSave(const QString &docTitle) 210int PwMDocUi::dirtyAskSave(const QString &docTitle)
209{ 211{
210 int ret; 212 int ret;
211#ifndef PWM_EMBEDDED 213#ifndef PWM_EMBEDDED
212 ret = KMessageBox::questionYesNoCancel(currentView, 214 ret = KMessageBox::questionYesNoCancel(currentView,
213 i18n("The list \"") + 215 i18n("The list \"") +
214 docTitle + 216 docTitle +
215 i18n 217 i18n
216 ("\" has been modified.\n" 218 ("\" has been modified.\n"
217 "Do you want to save it?"), 219 "Do you want to save it?"),
218 i18n("save?")); 220 i18n("save?"));
219 if (ret == KMessageBox::Yes) { 221 if (ret == KMessageBox::Yes) {
220 return 0; 222 return 0;
221 } else if (ret == KMessageBox::No) { 223 } else if (ret == KMessageBox::No) {
222 return 1; 224 return 1;
223 } 225 }
224#else 226#else
225 ret = KMessageBox::warningYesNoCancel(currentView, 227 ret = KMessageBox::warningYesNoCancel(currentView,
226 i18n("The list \"") + 228 i18n("The list \"") +
227 docTitle + 229 docTitle +
228 i18n 230 i18n
229 ("\" has been modified.\n" 231 ("\" has been modified.\n"
230 "Do you want to save it?"), 232 "Do you want to save it?"),
231 i18n("save?")); 233 i18n("save?"));
232 if (ret == KMessageBox::Yes) { 234 if (ret == KMessageBox::Yes) {
233 return 0; 235 return 0;
234 } else if (ret == KMessageBox::No) { 236 } else if (ret == KMessageBox::No) {
235 return 1; 237 return 1;
236 } 238 }
237 239
238#endif 240#endif
239 241
240 // cancel 242 // cancel
241 return -1; 243 return -1;
242} 244}
243 245
244bool PwMDocUi::saveDocUi(PwMDoc *doc) 246bool PwMDocUi::saveDocUi(PwMDoc *doc)
245{ 247{
246 PWM_ASSERT(doc); 248 PWM_ASSERT(doc);
247 doc->timer()->getLock(DocTimer::id_autoLockTimer); 249 doc->timer()->getLock(DocTimer::id_autoLockTimer);
248 if (doc->isDocEmpty()) { 250 if (doc->isDocEmpty()) {
249 KMessageBox::information(currentView, 251 KMessageBox::information(currentView,
250 i18n 252 i18n
251 ("Sorry, there's nothing to save.\n" 253 ("Sorry, there's nothing to save.\n"
252 "Please first add some passwords."), 254 "Please first add some passwords."),
253 i18n("nothing to do")); 255 i18n("nothing to do"));
254 doc->timer()->putLock(DocTimer::id_autoLockTimer); 256 doc->timer()->putLock(DocTimer::id_autoLockTimer);
255 return true; 257 return true;
256 } 258 }
257 PwMerror ret = doc->saveDoc(conf()->confGlobCompression()); 259 PwMerror ret = doc->saveDoc(conf()->confGlobCompression());
258 if (ret == e_filename) { 260 if (ret == e_filename) {
259 doc->timer()->putLock(DocTimer::id_autoLockTimer); 261 doc->timer()->putLock(DocTimer::id_autoLockTimer);
260 return saveAsDocUi(doc); 262 return saveAsDocUi(doc);
261 } else if (ret == e_weakPw) { 263 } else if (ret == e_weakPw) {
262 KMessageBox::error(currentView, 264 KMessageBox::error(currentView,
263 i18n("Error: This is a weak password.\n" 265 i18n("Error: This is a weak password.\n"
264 "Please select another password."), 266 "Please select another password."),
265 i18n("weak password")); 267 i18n("weak password"));
266 doc->timer()->putLock(DocTimer::id_autoLockTimer); 268 doc->timer()->putLock(DocTimer::id_autoLockTimer);
267 return false; 269 return false;
268 } else if (ret == e_fileBackup) { 270 } else if (ret == e_fileBackup) {
269 KMessageBox::error(currentView, 271 KMessageBox::error(currentView,
270 i18n("Error: Couldn't make backup-file!"), 272 i18n("Error: Couldn't make backup-file!"),
271 i18n("backup failed")); 273 i18n("backup failed"));
272 doc->timer()->putLock(DocTimer::id_autoLockTimer); 274 doc->timer()->putLock(DocTimer::id_autoLockTimer);
273 return false; 275 return false;
274 } else if (ret != e_success) { 276 } else if (ret != e_success) {
275 KMessageBox::error(currentView, 277 KMessageBox::error(currentView,
276 i18n("Error: Couldn't write to file.\n" 278 i18n("Error: Couldn't write to file.\n"
277 "Please check if you have permission to " 279 "Please check if you have permission to "
278 "write to the file in that directory."), 280 "write to the file in that directory."),
279 i18n("error while writing")); 281 i18n("error while writing"));
280 doc->timer()->putLock(DocTimer::id_autoLockTimer); 282 doc->timer()->putLock(DocTimer::id_autoLockTimer);
281 return false; 283 return false;
282 } 284 }
283 doc->timer()->putLock(DocTimer::id_autoLockTimer); 285 doc->timer()->putLock(DocTimer::id_autoLockTimer);
284 return true; 286 return true;
285} 287}
286 288
287bool PwMDocUi::saveAsDocUi(PwMDoc *doc) 289bool PwMDocUi::saveAsDocUi(PwMDoc *doc)
288{ 290{
289 PWM_ASSERT(doc); 291 PWM_ASSERT(doc);
290 doc->timer()->getLock(DocTimer::id_autoLockTimer); 292 doc->timer()->getLock(DocTimer::id_autoLockTimer);
291 if (doc->isDocEmpty()) { 293 if (doc->isDocEmpty()) {
292 KMessageBox::information(currentView, 294 KMessageBox::information(currentView,
293 i18n 295 i18n
294 ("Sorry, there's nothing to save.\n" 296 ("Sorry, there's nothing to save.\n"
295 "Please first add some passwords."), 297 "Please first add some passwords."),
296 i18n("nothing to do")); 298 i18n("nothing to do"));
297 doc->timer()->putLock(DocTimer::id_autoLockTimer); 299 doc->timer()->putLock(DocTimer::id_autoLockTimer);
298 return true; 300 return true;
299 } 301 }
300#ifndef PWM_EMBEDDED 302#ifndef PWM_EMBEDDED
301 QString fn(KFileDialog::getSaveFileName(QString::null, 303 QString fn(KFileDialog::getSaveFileName(QString::null,
302 i18n("*.pwm|PwManager Password file"), 304 i18n("*.pwm|PwManager Password file"),
303 currentView)); 305 currentView));
304#else 306#else
305 QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" ); 307 QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" );
306 fn = KFileDialog::getSaveFileName(fn, 308 fn = KFileDialog::getSaveFileName(fn,
307 i18n("password filename(*.pwm)"), 309 i18n("password filename(*.pwm)"),
308 currentView); 310 currentView);
309 311
310#endif 312#endif
311 if (fn == "") { 313 if (fn == "") {
312 doc->timer()->putLock(DocTimer::id_autoLockTimer); 314 doc->timer()->putLock(DocTimer::id_autoLockTimer);
313 return false; 315 return false;
314 } 316 }
315 if (fn.right(4) != ".pwm") 317 if (fn.right(4) != ".pwm")
316 fn += ".pwm"; 318 fn += ".pwm";
317 319
318 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn); 320 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn);
319 if (ret != e_success) { 321 if (ret != e_success) {
320 KMessageBox::error(currentView, 322 KMessageBox::error(currentView,
321 i18n("Error: Couldn't write to file.\n" 323 i18n("Error: Couldn't write to file.\n"
322 "Please check if you have permission to " 324 "Please check if you have permission to "
323 "write to the file in that directory."), 325 "write to the file in that directory."),
324 i18n("error while writing")); 326 i18n("error while writing"));
325 doc->timer()->putLock(DocTimer::id_autoLockTimer); 327 doc->timer()->putLock(DocTimer::id_autoLockTimer);
326 return false; 328 return false;
327 } 329 }
328 doc->timer()->putLock(DocTimer::id_autoLockTimer); 330 doc->timer()->putLock(DocTimer::id_autoLockTimer);
329 return true; 331 return true;
330} 332}
331 333
332bool PwMDocUi::openDocUi(PwMDoc *doc, 334bool PwMDocUi::openDocUi(PwMDoc *doc,
333 QString filename, 335 QString filename,
334 bool openDeepLocked) 336 bool openDeepLocked)
335{ 337{
336 if (filename.isEmpty()) 338 if (filename.isEmpty())
337 { 339 {
338#ifndef PWM_EMBEDDED 340#ifndef PWM_EMBEDDED
339 filename = KFileDialog::getOpenFileName(QString::null, 341 filename = KFileDialog::getOpenFileName(QString::null,
340 i18n("*.pwm|PwManager Password file\n" 342 i18n("*.pwm|PwManager Password file\n"
341 "*|All files"), getCurrentView()); 343 "*|All files"), getCurrentView());
342#else 344#else
343 filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm"); 345 filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm");
344 filename = KFileDialog::getOpenFileName(filename, 346 filename = KFileDialog::getOpenFileName(filename,
345 i18n("password filename(*.pwm)"), getCurrentView()); 347 i18n("password filename(*.pwm)"), getCurrentView());
346#endif 348#endif
347 } 349 }
348 if (filename.isEmpty()) 350 if (filename.isEmpty())
349 goto cancelOpen; 351 goto cancelOpen;
350 PwMerror ret; 352 PwMerror ret;
351 while (true) { 353 while (true) {
352 int lockStat = -1; 354 int lockStat = -1;
353 if (openDeepLocked) { 355 if (openDeepLocked) {
354 lockStat = 2; 356 lockStat = 2;
355 } else { 357 } else {
356 if (conf()->confGlobUnlockOnOpen()) { 358 if (conf()->confGlobUnlockOnOpen()) {
357 lockStat = 0; 359 lockStat = 0;
358 } else { 360 } else {
359 lockStat = 1; 361 lockStat = 1;
360 } 362 }
361 } 363 }
362 ret = doc->openDoc(&filename, lockStat); 364 ret = doc->openDoc(&filename, lockStat);
365 qDebug("pwmdocui::OpenDocui %i", ret);
363 if (ret != e_success) { 366 if (ret != e_success) {
364 if (ret == e_readFile || ret == e_openFile) { 367 if (ret == e_readFile || ret == e_openFile) {
365 KMessageBox::error(getCurrentView(), 368 KMessageBox::error(getCurrentView(),
366 i18n("Could not read file!") 369 i18n("Could not read file!")
367 + "\n" 370 + "\n"
368 + filename, 371 + filename,
369 i18n("file error")); 372 i18n("file error"));
370 goto cancelOpen; 373 goto cancelOpen;
371 } 374 }
372 if (ret == e_alreadyOpen) { 375 if (ret == e_alreadyOpen) {
373 KMessageBox::error(getCurrentView(), 376 KMessageBox::error(getCurrentView(),
374 i18n("This file is already open."), 377 i18n("This file is already open."),
375 i18n("already open")); 378 i18n("already open"));
376 goto cancelOpen; 379 goto cancelOpen;
377 } 380 }
378 if (ret == e_fileVer) { 381 if (ret == e_fileVer) {
379 KMessageBox::error(getCurrentView(), 382 KMessageBox::error(getCurrentView(),
380 i18n 383 i18n
381 ("File-version is not supported!\n" 384 ("File-version is not supported!\n"
382 "Did you create this file with an older or newer version of PwM?"), 385 "Did you create this file with an older or newer version of PwM?"),
383 i18n 386 i18n
384 ("incompatible version")); 387 ("incompatible version"));
385 goto cancelOpen; 388 goto cancelOpen;
386 } 389 }
387 if (ret == e_wrongPw) { 390 if (ret == e_wrongPw) {
388 continue; 391 continue;
389 } 392 }
390 if (ret == e_noPw) { 393 if (ret == e_noPw) {
391 goto cancelOpen; 394 goto cancelOpen;
392 } 395 }
393 if (ret == e_fileFormat) { 396 if (ret == e_fileFormat) {
394 KMessageBox::error(getCurrentView(), 397 KMessageBox::error(getCurrentView(),
395 i18n 398 i18n
396 ("Sorry, this file has not been recognized " 399 ("Sorry, this file has not been recognized "
397 "as a PwM Password file.\n" 400 "as a PwM Password file.\n"
398 "Probably you have selected the wrong file."), 401 "Probably you have selected the wrong file."),
399 i18n 402 i18n
400 ("no PwM password-file")); 403 ("no PwM password-file"));
401 goto cancelOpen; 404 goto cancelOpen;
402 } 405 }
403 if (ret == e_fileCorrupt) { 406 if (ret == e_fileCorrupt) {
404 KMessageBox::error(getCurrentView(), 407 KMessageBox::error(getCurrentView(),
405 i18n 408 i18n
406 ("File corrupt!\n" 409 ("File corrupt!\n"
407 "Maybe the media, you stored this file on, " 410 "Maybe the media, you stored this file on, "
408 "had bad sectors?"), 411 "had bad sectors?"),
409 i18n 412 i18n
410 ("checksum error")); 413 ("checksum error"));
411 goto cancelOpen; 414 goto cancelOpen;
412 } 415 }
413 } 416 }
414 break; 417 break;
415 } 418 }
416 return true; 419 return true;
417 420
418 cancelOpen: 421 cancelOpen:
419 return false; 422 return false;
420} 423}
421 424
422QString PwMDocUi::string_defaultCategory() 425QString PwMDocUi::string_defaultCategory()
423{ 426{
424 return i18n("Default"); 427 return i18n("Default");
425} 428}
426 429
427QString PwMDocUi::string_locked() 430QString PwMDocUi::string_locked()
428{ 431{
429 return i18n("<LOCKED>"); 432 return i18n("<LOCKED>");
430} 433}
431 434
432QString PwMDocUi::string_deepLockedShort() 435QString PwMDocUi::string_deepLockedShort()
433{ 436{
434 return i18n("DEEP-LOCKED"); 437 return i18n("DEEP-LOCKED");
435} 438}
436 439
437QString PwMDocUi::string_deepLockedLong() 440QString PwMDocUi::string_deepLockedLong()
438{ 441{
439 return i18n("This file is DEEP-LOCKED!\n" 442 return i18n("This file is DEEP-LOCKED!\n"
440 "That means all data has been encrypted " 443 "That means all data has been encrypted "
441 "and written out to the file. If you want " 444 "and written out to the file. If you want "
442 "to see the entries, please UNLOCK the file. " 445 "to see the entries, please UNLOCK the file. "
443 "While unlocking, you will be prompted for the " 446 "While unlocking, you will be prompted for the "
444 "master-password or the key-card."); 447 "master-password or the key-card.");
445} 448}
446 449
447QString PwMDocUi::string_defaultTitle() 450QString PwMDocUi::string_defaultTitle()
448{ 451{
449 return i18n("Untitled"); 452 return i18n("Untitled");
450} 453}
451 454
452#ifndef PWM_EMBEDDED 455#ifndef PWM_EMBEDDED
453#include "pwmdocui.moc" 456#include "pwmdocui.moc"
454#endif 457#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle.cpp b/pwmanager/pwmanager/pwmviewstyle.cpp
index 67b5197..51d8f6c 100644
--- a/pwmanager/pwmanager/pwmviewstyle.cpp
+++ b/pwmanager/pwmanager/pwmviewstyle.cpp
@@ -1,205 +1,217 @@
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.0.1 of pwmanager 15 * This file is originaly based on version 1.0.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 "pwmviewstyle.h" 21#include "pwmviewstyle.h"
22#include "pwmexception.h" 22#include "pwmexception.h"
23#include "pwmviewstyle_0.h" 23#include "pwmviewstyle_0.h"
24#include "pwmviewstyle_1.h" 24#include "pwmviewstyle_1.h"
25#include "listviewpwm.h" 25#include "listviewpwm.h"
26#include "pwmview.h" 26#include "pwmview.h"
27#include "commentbox.h" 27#include "commentbox.h"
28 28#ifndef PWM_EMBEDDED
29#include "configuration.h"
30#else
31#include "pwmprefs.h"
32#endif
29 33
30PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name) 34PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name)
31 : QWidget(parent, name) 35 : QWidget(parent, name)
32{ 36{
33 curStyle = style_notset; 37 curStyle = style_notset;
34 s0 = 0; 38 s0 = 0;
35 s1 = 0; 39 s1 = 0;
36} 40}
37 41
38PwMViewStyle::~PwMViewStyle() 42PwMViewStyle::~PwMViewStyle()
39{ 43{
44 //US ENH : load and store the size of the listviewcolumns
45 lv->saveLayout(conf()->getConfig(), "listview");
46 conf()->getConfig()->sync();
47
40 delete_ifnot_null(s0); 48 delete_ifnot_null(s0);
41 delete_ifnot_null(s1); 49 delete_ifnot_null(s1);
42} 50}
43 51
44void PwMViewStyle::initStyle(style_t style) 52void PwMViewStyle::initStyle(style_t style)
45{ 53{
46 printDebug(string("initializing style ") + tostr(style)); 54 printDebug(string("initializing style ") + tostr(style));
47 bool wasMaximized = v->isMaximized(); 55 bool wasMaximized = v->isMaximized();
48 if (v->isVisible()) 56 if (v->isVisible())
49 v->hide(); 57 v->hide();
50 switch (style) { 58 switch (style) {
51 case style_0: 59 case style_0:
52 delete_ifnot_null(s0); 60 delete_ifnot_null(s0);
53 delete_ifnot_null(s1); 61 delete_ifnot_null(s1);
54 s0 = new PwMViewStyle_0(v); 62 s0 = new PwMViewStyle_0(v);
55 lv = s0->getLv(); 63 lv = s0->getLv();
56 commentBox = s0->getCommentBox(); 64 commentBox = s0->getCommentBox();
57 break; 65 break;
58 case style_1: 66 case style_1:
59 delete_ifnot_null(s0); 67 delete_ifnot_null(s0);
60 delete_ifnot_null(s1); 68 delete_ifnot_null(s1);
61 s1 = new PwMViewStyle_1(v); 69 s1 = new PwMViewStyle_1(v);
62 lv = s1->getLv(); 70 lv = s1->getLv();
63 commentBox = s1->getCommentBox(); 71 commentBox = s1->getCommentBox();
64 break; 72 break;
65 default: 73 default:
66 BUG(); 74 BUG();
67 return; 75 return;
68 } 76 }
69 curStyle = style; 77 curStyle = style;
70 connect(lv, SIGNAL(pressed(QListViewItem *)), 78 connect(lv, SIGNAL(pressed(QListViewItem *)),
71 v, SLOT(handleToggle(QListViewItem *))); 79 v, SLOT(handleToggle(QListViewItem *)));
72 connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)), 80 connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)),
73 v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int))); 81 v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int)));
74 connect(lv, SIGNAL(clicked(QListViewItem *)), 82 connect(lv, SIGNAL(clicked(QListViewItem *)),
75 v, SLOT(refreshCommentTextEdit(QListViewItem *))); 83 v, SLOT(refreshCommentTextEdit(QListViewItem *)));
76 lv->addColumn(i18n("Description"), 180); 84 lv->addColumn(i18n("Description"), 180);
77 lv->addColumn(i18n("Username"), 150); 85 lv->addColumn(i18n("Username"), 150);
78 lv->addColumn(i18n("Password"), 150); 86 lv->addColumn(i18n("Password"), 150);
79 lv->addColumn(i18n("URL"), 180); 87 lv->addColumn(i18n("URL"), 180);
80 lv->addColumn(i18n("Launcher"), 120); 88 lv->addColumn(i18n("Launcher"), 120);
81 v->tmpReEnableSort(); 89 v->tmpReEnableSort();
90
91 //US ENH : load and store the size of the listviewcolumns
92 lv->restoreLayout(conf()->getConfig(), "listview");
93
82 resizeView(v->size()); 94 resizeView(v->size());
83 v->updateView(); 95 v->updateView();
84 if (wasMaximized) { 96 if (wasMaximized) {
85 v->showMaximized(); 97 v->showMaximized();
86 } else { 98 } else {
87 v->show(); 99 v->show();
88 } 100 }
89 connect(lv, SIGNAL(layoutChanged()), 101 connect(lv, SIGNAL(layoutChanged()),
90 v, SLOT(reorgLp())); 102 v, SLOT(reorgLp()));
91} 103}
92 104
93void PwMViewStyle::resizeView(const QSize &size) 105void PwMViewStyle::resizeView(const QSize &size)
94{ 106{
95 switch (curStyle) { 107 switch (curStyle) {
96 case style_0: 108 case style_0:
97 PWM_ASSERT(s0); 109 PWM_ASSERT(s0);
98 s0->resize(size); 110 s0->resize(size);
99 return; 111 return;
100 case style_1: 112 case style_1:
101 PWM_ASSERT(s1); 113 PWM_ASSERT(s1);
102 s1->resize(size); 114 s1->resize(size);
103 return; 115 return;
104 default: 116 default:
105 BUG(); 117 BUG();
106 } 118 }
107} 119}
108 120
109QString PwMViewStyle::getCurrentCategory() 121QString PwMViewStyle::getCurrentCategory()
110{ 122{
111 switch (curStyle) { 123 switch (curStyle) {
112 case style_0: 124 case style_0:
113 PWM_ASSERT(s0); 125 PWM_ASSERT(s0);
114 return s0->getCurrentCategory(); 126 return s0->getCurrentCategory();
115 case style_1: 127 case style_1:
116 PWM_ASSERT(s1); 128 PWM_ASSERT(s1);
117 return s1->getCurrentCategory(); 129 return s1->getCurrentCategory();
118 default: 130 default:
119 BUG(); 131 BUG();
120 } 132 }
121 return ""; 133 return "";
122} 134}
123 135
124void PwMViewStyle::addCategory(const QString &cat) 136void PwMViewStyle::addCategory(const QString &cat)
125{ 137{
126 switch (curStyle) { 138 switch (curStyle) {
127 case style_0: 139 case style_0:
128 PWM_ASSERT(s0); 140 PWM_ASSERT(s0);
129 s0->addCategory(cat); 141 s0->addCategory(cat);
130 return; 142 return;
131 case style_1: 143 case style_1:
132 PWM_ASSERT(s1); 144 PWM_ASSERT(s1);
133 s1->addCategory(cat); 145 s1->addCategory(cat);
134 return; 146 return;
135 default: 147 default:
136 BUG(); 148 BUG();
137 } 149 }
138} 150}
139 151
140void PwMViewStyle::delCategory(const QString &cat) 152void PwMViewStyle::delCategory(const QString &cat)
141{ 153{
142 switch (curStyle) { 154 switch (curStyle) {
143 case style_0: 155 case style_0:
144 PWM_ASSERT(s0); 156 PWM_ASSERT(s0);
145 s0->delCategory(cat); 157 s0->delCategory(cat);
146 return; 158 return;
147 case style_1: 159 case style_1:
148 PWM_ASSERT(s1); 160 PWM_ASSERT(s1);
149 s1->delCategory(cat); 161 s1->delCategory(cat);
150 return; 162 return;
151 default: 163 default:
152 BUG(); 164 BUG();
153 } 165 }
154} 166}
155 167
156void PwMViewStyle::delAllCategories() 168void PwMViewStyle::delAllCategories()
157{ 169{
158 switch (curStyle) { 170 switch (curStyle) {
159 case style_0: 171 case style_0:
160 PWM_ASSERT(s0); 172 PWM_ASSERT(s0);
161 s0->delAllCategories(); 173 s0->delAllCategories();
162 return; 174 return;
163 case style_1: 175 case style_1:
164 PWM_ASSERT(s1); 176 PWM_ASSERT(s1);
165 s1->delAllCategories(); 177 s1->delAllCategories();
166 return; 178 return;
167 default: 179 default:
168 BUG(); 180 BUG();
169 } 181 }
170} 182}
171 183
172void PwMViewStyle::selectCategory(const QString &cat) 184void PwMViewStyle::selectCategory(const QString &cat)
173{ 185{
174 switch (curStyle) { 186 switch (curStyle) {
175 case style_0: 187 case style_0:
176 PWM_ASSERT(s0); 188 PWM_ASSERT(s0);
177 s0->selectCategory(cat); 189 s0->selectCategory(cat);
178 return; 190 return;
179 case style_1: 191 case style_1:
180 PWM_ASSERT(s1); 192 PWM_ASSERT(s1);
181 s1->selectCategory(cat); 193 s1->selectCategory(cat);
182 return; 194 return;
183 default: 195 default:
184 BUG(); 196 BUG();
185 } 197 }
186} 198}
187 199
188int PwMViewStyle::numCategories() 200int PwMViewStyle::numCategories()
189{ 201{
190 switch (curStyle) { 202 switch (curStyle) {
191 case style_0: 203 case style_0:
192 PWM_ASSERT(s0); 204 PWM_ASSERT(s0);
193 return s0->numCategories(); 205 return s0->numCategories();
194 case style_1: 206 case style_1:
195 PWM_ASSERT(s1); 207 PWM_ASSERT(s1);
196 return s1->numCategories(); 208 return s1->numCategories();
197 default: 209 default:
198 BUG(); 210 BUG();
199 } 211 }
200 return 0; 212 return 0;
201} 213}
202 214
203#ifndef PWM_EMBEDDED 215#ifndef PWM_EMBEDDED
204#include "pwmviewstyle.moc" 216#include "pwmviewstyle.moc"
205#endif 217#endif
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index f29ef6c..2810b48 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -1,414 +1,414 @@
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 2.0 of pwmanager 15 * This file is originaly based on version 2.0 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_DEBUG1
31/* use the old xml tags for writing (0/1) */ 31/* use the old xml tags for writing (0/1) */
32 #define USE_OLD_TAGS 0 32 #define USE_OLD_TAGS 0
33/* write a CDATA section (0/1) */ 33/* write a CDATA section (0/1) */
34 #define WRITE_CDATA_SEC 0 34 #define WRITE_CDATA_SEC 0
35 35
36 36
37 #define META_CREATE_DATE"c" 37 #define META_CREATE_DATE"c"
38 #define META_VALID_DATE "v" 38 #define META_VALID_DATE "v"
39 #define META_EXPIRE_DATE"e" 39 #define META_EXPIRE_DATE"e"
40 #define META_UPDATE_DATE"u" 40 #define META_UPDATE_DATE"u"
41 #define META_UPDATE_INT "i" 41 #define META_UPDATE_INT "i"
42//US ENH : uniqueid 42//US ENH : uniqueid
43#define META_UNIQUEID "n" 43#define META_UNIQUEID "n"
44 44
45/* This is compatibility stuff. 45/* This is compatibility stuff.
46 * The names of the entries have changed and here are the 46 * The names of the entries have changed and here are the
47 * new and old ones 47 * new and old ones
48 */ 48 */
49 #define ROOT_MAGIC_OLD "PwM-xml-dat" 49 #define ROOT_MAGIC_OLD "PwM-xml-dat"
50 #define VER_STR_OLD "ver" 50 #define VER_STR_OLD "ver"
51 #define COMPAT_VER_OLD "0x02" 51 #define COMPAT_VER_OLD "0x02"
52 #define CAT_ROOT_OLD "categories" 52 #define CAT_ROOT_OLD "categories"
53 #define CAT_PREFIX_OLD "cat_" 53 #define CAT_PREFIX_OLD "cat_"
54 #define CAT_NAME_OLD "name" 54 #define CAT_NAME_OLD "name"
55 #define ENTRY_PREFIX_OLD"entry_" 55 #define ENTRY_PREFIX_OLD"entry_"
56 #define ENTRY_DESC_OLD "desc" 56 #define ENTRY_DESC_OLD "desc"
57 #define ENTRY_NAME_OLD "name" 57 #define ENTRY_NAME_OLD "name"
58 #define ENTRY_PW_OLD "pw" 58 #define ENTRY_PW_OLD "pw"
59 #define ENTRY_COMMENT_OLD"comment" 59 #define ENTRY_COMMENT_OLD"comment"
60 #define ENTRY_URL_OLD "url" 60 #define ENTRY_URL_OLD "url"
61 #define ENTRY_LAUNCHER_OLD"launcher" 61 #define ENTRY_LAUNCHER_OLD"launcher"
62 #define ENTRY_LVP_OLD "listViewPos" 62 #define ENTRY_LVP_OLD "listViewPos"
63 #define ENTRY_BIN_OLD "b" 63 #define ENTRY_BIN_OLD "b"
64 #define ENTRY_META_OLD "m" 64 #define ENTRY_META_OLD "m"
65 65
66 #define ROOT_MAGIC_NEW "P" 66 #define ROOT_MAGIC_NEW "P"
67 #define VER_STR_NEW "v" 67 #define VER_STR_NEW "v"
68 #define COMPAT_VER_NEW "2" 68 #define COMPAT_VER_NEW "2"
69 #define CAT_ROOT_NEW "c" 69 #define CAT_ROOT_NEW "c"
70 #define CAT_PREFIX_NEW "c" 70 #define CAT_PREFIX_NEW "c"
71 #define CAT_NAME_NEW "n" 71 #define CAT_NAME_NEW "n"
72 #define ENTRY_PREFIX_NEW"e" 72 #define ENTRY_PREFIX_NEW"e"
73 #define ENTRY_DESC_NEW "d" 73 #define ENTRY_DESC_NEW "d"
74 #define ENTRY_NAME_NEW "n" 74 #define ENTRY_NAME_NEW "n"
75 #define ENTRY_PW_NEW "p" 75 #define ENTRY_PW_NEW "p"
76 #define ENTRY_COMMENT_NEW"c" 76 #define ENTRY_COMMENT_NEW"c"
77 #define ENTRY_URL_NEW "u" 77 #define ENTRY_URL_NEW "u"
78 #define ENTRY_LAUNCHER_NEW"l" 78 #define ENTRY_LAUNCHER_NEW"l"
79 #define ENTRY_LVP_NEW "v" 79 #define ENTRY_LVP_NEW "v"
80 #define ENTRY_BIN_NEW ENTRY_BIN_OLD 80 #define ENTRY_BIN_NEW ENTRY_BIN_OLD
81 #define ENTRY_META_NEW ENTRY_META_OLD 81 #define ENTRY_META_NEW ENTRY_META_OLD
82 82
83#if USE_OLD_TAGS != 0 83#if USE_OLD_TAGS != 0
84 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD 84 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD
85 # define VER_STR_WR VER_STR_OLD 85 # define VER_STR_WR VER_STR_OLD
86 # define COMPAT_VER_WR COMPAT_VER_OLD 86 # define COMPAT_VER_WR COMPAT_VER_OLD
87 # define CAT_ROOT_WR CAT_ROOT_OLD 87 # define CAT_ROOT_WR CAT_ROOT_OLD
88 # define CAT_PREFIX_WR CAT_PREFIX_OLD 88 # define CAT_PREFIX_WR CAT_PREFIX_OLD
89 # define CAT_NAME_WR CAT_NAME_OLD 89 # define CAT_NAME_WR CAT_NAME_OLD
90 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD 90 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD
91 # define ENTRY_DESC_WR ENTRY_DESC_OLD 91 # define ENTRY_DESC_WR ENTRY_DESC_OLD
92 # define ENTRY_NAME_WR ENTRY_NAME_OLD 92 # define ENTRY_NAME_WR ENTRY_NAME_OLD
93 # define ENTRY_PW_WR ENTRY_PW_OLD 93 # define ENTRY_PW_WR ENTRY_PW_OLD
94 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD 94 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD
95 # define ENTRY_URL_WR ENTRY_URL_OLD 95 # define ENTRY_URL_WR ENTRY_URL_OLD
96 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD 96 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD
97 # define ENTRY_LVP_WR ENTRY_LVP_OLD 97 # define ENTRY_LVP_WR ENTRY_LVP_OLD
98 # define ENTRY_BIN_WR ENTRY_BIN_OLD 98 # define ENTRY_BIN_WR ENTRY_BIN_OLD
99 # define ENTRY_META_WR ENTRY_META_OLD 99 # define ENTRY_META_WR ENTRY_META_OLD
100#else 100#else
101 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW 101 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW
102 # define VER_STR_WR VER_STR_NEW 102 # define VER_STR_WR VER_STR_NEW
103 # define COMPAT_VER_WR COMPAT_VER_NEW 103 # define COMPAT_VER_WR COMPAT_VER_NEW
104 # define CAT_ROOT_WR CAT_ROOT_NEW 104 # define CAT_ROOT_WR CAT_ROOT_NEW
105 # define CAT_PREFIX_WR CAT_PREFIX_NEW 105 # define CAT_PREFIX_WR CAT_PREFIX_NEW
106 # define CAT_NAME_WR CAT_NAME_NEW 106 # define CAT_NAME_WR CAT_NAME_NEW
107 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW 107 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW
108 # define ENTRY_DESC_WR ENTRY_DESC_NEW 108 # define ENTRY_DESC_WR ENTRY_DESC_NEW
109 # define ENTRY_NAME_WR ENTRY_NAME_NEW 109 # define ENTRY_NAME_WR ENTRY_NAME_NEW
110 # define ENTRY_PW_WR ENTRY_PW_NEW 110 # define ENTRY_PW_WR ENTRY_PW_NEW
111 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW 111 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW
112 # define ENTRY_URL_WR ENTRY_URL_NEW 112 # define ENTRY_URL_WR ENTRY_URL_NEW
113 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW 113 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW
114 # define ENTRY_LVP_WR ENTRY_LVP_NEW 114 # define ENTRY_LVP_WR ENTRY_LVP_NEW
115 # define ENTRY_BIN_WR ENTRY_BIN_NEW 115 # define ENTRY_BIN_WR ENTRY_BIN_NEW
116 # define ENTRY_META_WR ENTRY_META_NEW 116 # define ENTRY_META_WR ENTRY_META_NEW
117#endif 117#endif
118 118
119 119
120Serializer::Serializer() 120Serializer::Serializer()
121{ 121{
122 defaultLockStat = true; 122 defaultLockStat = true;
123 domDoc = new QDomDocument; 123 domDoc = new QDomDocument;
124} 124}
125 125
126Serializer::Serializer(const QCString &buffer) 126Serializer::Serializer(const QCString &buffer)
127{ 127{
128 defaultLockStat = true; 128 defaultLockStat = true;
129 domDoc = new QDomDocument; 129 domDoc = new QDomDocument;
130 if (!parseXml(buffer)) { 130 if (!parseXml(buffer)) {
131 delete domDoc; 131 delete domDoc;
132#ifndef PWM_EMBEDDED 132#ifndef PWM_EMBEDDED
133 throw PwMException(PwMException::EX_PARSE); 133 throw PwMException(PwMException::EX_PARSE);
134#else 134#else
135 qDebug("Serializer::Serializer : Parse Exception "); 135 qDebug("Serializer::Serializer : Parse Exception ");
136#endif 136#endif
137 } 137 }
138} 138}
139 139
140Serializer::~Serializer() 140Serializer::~Serializer()
141{ 141{
142 delete_ifnot_null(domDoc); 142 delete_ifnot_null(domDoc);
143} 143}
144 144
145void Serializer::clear() 145void Serializer::clear()
146{ 146{
147 delete_ifnot_null(domDoc); 147 delete_ifnot_null(domDoc);
148 domDoc = new QDomDocument; 148 domDoc = new QDomDocument;
149} 149}
150 150
151bool Serializer::parseXml(const QCString &buffer) 151bool Serializer::parseXml(const QCString &buffer)
152{ 152{
153 PWM_ASSERT(domDoc); 153 PWM_ASSERT(domDoc);
154#ifndef PWM_EMBEDDED 154#ifndef PWM_EMBEDDED
155 if (!domDoc->setContent(buffer, true)) 155 if (!domDoc->setContent(buffer, true))
156 return false; 156 return false;
157#else 157#else
158 if (!domDoc->setContent(buffer)) 158 if (!domDoc->setContent(buffer))
159 return false; 159 return false;
160#endif 160#endif
161 if (!checkValid()) 161 if (!checkValid())
162 return false; 162 return false;
163 return true; 163 return true;
164} 164}
165 165
166QCString Serializer::getXml() 166QCString Serializer::getXml()
167{ 167{
168 PWM_ASSERT(domDoc); 168 PWM_ASSERT(domDoc);
169 169
170#ifndef PWM_EMBEDDED 170#ifndef PWM_EMBEDDED
171#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 171#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
172 QCString tmp(domDoc->toCString(8)); 172 QCString tmp(domDoc->toCString(8));
173 printDebug("<BEGIN Serializer::getXml() dump>\n"); 173 printDebug("<BEGIN Serializer::getXml() dump>\n");
174 cout << tmp << endl; 174 cout << tmp << endl;
175 printDebug("<END Serializer::getXml() dump>"); 175 printDebug("<END Serializer::getXml() dump>");
176#endif // DEBUG 176#endif // DEBUG
177 177
178 QCString ret(domDoc->toCString(0)); 178 QCString ret(domDoc->toCString(0));
179 ret.replace('\n', ""); 179 ret.replace('\n', "");
180 return ret; 180 return ret;
181#else 181#else
182 182
183#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 183#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
184 QCString tmp(" " + domDoc->toCString()); 184 QCString tmp(" " + domDoc->toCString());
185 printDebug("<BEGIN Serializer::getXml() dump>\n"); 185 printDebug("<BEGIN Serializer::getXml() dump>\n");
186 cout << tmp << endl; 186 cout << tmp << endl;
187 printDebug("<END Serializer::getXml() dump>"); 187 printDebug("<END Serializer::getXml() dump>");
188#endif // DEBUG 188#endif // DEBUG
189 189
190 QCString ret(domDoc->toCString()); 190 QCString ret(domDoc->toCString());
191 ret.replace(QRegExp("\n"), ""); 191 ret.replace(QRegExp("\n"), "");
192 return ret; 192 return ret;
193 193
194#endif 194#endif
195} 195}
196 196
197bool Serializer::serialize(const vector<PwMCategoryItem> &dta) 197bool Serializer::serialize(const vector<PwMCategoryItem> &dta)
198{ 198{
199 PWM_ASSERT(domDoc); 199 PWM_ASSERT(domDoc);
200 QDomElement root(genNewRoot()); 200 QDomElement root(genNewRoot());
201 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); 201 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR));
202 root.appendChild(catNode); 202 root.appendChild(catNode);
203 if (!addCategories(&catNode, dta)) 203 if (!addCategories(&catNode, dta))
204 return false; 204 return false;
205 return true; 205 return true;
206} 206}
207 207
208bool Serializer::deSerialize(vector<PwMCategoryItem> *dta) 208bool Serializer::deSerialize(vector<PwMCategoryItem> *dta)
209{ 209{
210 PWM_ASSERT(domDoc); 210 PWM_ASSERT(domDoc);
211 PWM_ASSERT(dta); 211 PWM_ASSERT(dta);
212 QDomElement root(domDoc->documentElement()); 212 QDomElement root(domDoc->documentElement());
213 QDomNode n; 213 QDomNode n;
214 214
215 dta->clear(); 215 dta->clear();
216 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { 216 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) {
217 // find <categories> ... </categories> 217 // find <categories> ... </categories>
218 // <c> ... </c> 218 // <c> ... </c>
219 if (n.nodeName() == CAT_ROOT_NEW || 219 if (n.nodeName() == CAT_ROOT_NEW ||
220 n.nodeName() == CAT_ROOT_OLD) { 220 n.nodeName() == CAT_ROOT_OLD) {
221 if (!readCategories(n, dta)) { 221 if (!readCategories(n, dta)) {
222 return false; 222 return false;
223 } 223 }
224 224
225 /* NOTE: We can stop processing here, as we 225 /* NOTE: We can stop processing here, as we
226 * don't have more nodes in root, yet. 226 * don't have more nodes in root, yet.
227 */ 227 */
228 return true; 228 return true;
229 } 229 }
230 } 230 }
231 return false; 231 return false;
232} 232}
233 233
234bool Serializer::readCategories(const QDomNode &n, 234bool Serializer::readCategories(const QDomNode &n,
235 vector<PwMCategoryItem> *dta) 235 vector<PwMCategoryItem> *dta)
236{ 236{
237 QDomNodeList nl(n.childNodes()); 237 QDomNodeList nl(n.childNodes());
238 QDomNode cur; 238 QDomNode cur;
239 QString name; 239 QString name;
240 unsigned int numCat = nl.count(), i; 240 unsigned int numCat = nl.count(), i;
241 PwMCategoryItem curCat; 241 PwMCategoryItem curCat;
242 vector<PwMDataItem> curEntr; 242 vector<PwMDataItem> curEntr;
243 243
244 if (!numCat) { 244 if (!numCat) {
245 printDebug("Serializer::readCategories(): empty"); 245 printDebug("Serializer::readCategories(): empty");
246 return false; 246 return false;
247 } 247 }
248 for (i = 0; i < numCat; ++i) { 248 for (i = 0; i < numCat; ++i) {
249 cur = nl.item(i); 249 cur = nl.item(i);
250 if (cur.nodeName().left(1) == CAT_PREFIX_NEW || 250 if (cur.nodeName().left(1) == CAT_PREFIX_NEW ||
251 cur.nodeName().left(4) == CAT_PREFIX_OLD) { 251 cur.nodeName().left(4) == CAT_PREFIX_OLD) {
252 name = cur.toElement().attribute(CAT_NAME_NEW); 252 name = cur.toElement().attribute(CAT_NAME_NEW);
253 if (name == QString::null) 253 if (name == QString::null)
254 name = cur.toElement().attribute(CAT_NAME_OLD); 254 name = cur.toElement().attribute(CAT_NAME_OLD);
255 PWM_ASSERT(name != QString::null); 255 PWM_ASSERT(name != QString::null);
256 PWM_ASSERT(name != ""); 256 PWM_ASSERT(name != "");
257 curCat.clear(); 257 curCat.clear();
258 curCat.name = name.latin1(); 258 curCat.name = name.latin1();
259 if (!readEntries(cur, &curEntr)) { 259 if (!readEntries(cur, &curEntr)) {
260 dta->clear(); 260 dta->clear();
261 return false; 261 return false;
262 } 262 }
263 curCat.d = curEntr; 263 curCat.d = curEntr;
264 dta->push_back(curCat); 264 dta->push_back(curCat);
265 } else { 265 } else {
266 printDebug("Serializer::readCategories(): uh? not a category?"); 266 printDebug("Serializer::readCategories(): uh? not a category?");
267 } 267 }
268 } 268 }
269 return true; 269 return true;
270} 270}
271 271
272bool Serializer::readEntries(const QDomNode &n, 272bool Serializer::readEntries(const QDomNode &n,
273 vector<PwMDataItem> *dta) 273 vector<PwMDataItem> *dta)
274{ 274{
275 QDomNodeList nl(n.childNodes()); 275 QDomNodeList nl(n.childNodes());
276 QDomNode cur; 276 QDomNode cur;
277 unsigned int numEntr = nl.count(), i; 277 unsigned int numEntr = nl.count(), i;
278 PwMDataItem curEntr; 278 PwMDataItem curEntr;
279 279
280 dta->clear(); 280 dta->clear();
281 for (i = 0; i < numEntr; ++i) { 281 for (i = 0; i < numEntr; ++i) {
282 cur = nl.item(i); 282 cur = nl.item(i);
283 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW || 283 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW ||
284 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) { 284 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) {
285 if (!extractEntry(cur, &curEntr)) { 285 if (!extractEntry(cur, &curEntr)) {
286 return false; 286 return false;
287 } 287 }
288 dta->push_back(curEntr); 288 dta->push_back(curEntr);
289 } else { 289 } else {
290 printDebug("Serializer::readEntries(): hm? not an entry?"); 290 printDebug("Serializer::readEntries(): hm? not an entry?");
291 } 291 }
292 } 292 }
293 return true; 293 return true;
294} 294}
295 295
296bool Serializer::extractEntry(const QDomNode &n, 296bool Serializer::extractEntry(const QDomNode &n,
297 PwMDataItem *dta) 297 PwMDataItem *dta)
298{ 298{
299 QDomNodeList nl(n.childNodes()); 299 QDomNodeList nl(n.childNodes());
300 QDomNode cur, cdata; 300 QDomNode cur, cdata;
301 unsigned int cnt = nl.count(), i; 301 unsigned int cnt = nl.count(), i;
302 QString name, text; 302 QString name, text;
303 303
304 if (!cnt) { 304 if (!cnt) {
305 printDebug("Serializer::extractEntry(): empty"); 305 printDebug("Serializer::extractEntry(): empty");
306 return false; 306 return false;
307 } 307 }
308 dta->clear(); 308 dta->clear();
309 for (i = 0; i < cnt; ++i) { 309 for (i = 0; i < cnt; ++i) {
310 cur = nl.item(i); 310 cur = nl.item(i);
311 name = cur.nodeName(); 311 name = cur.nodeName();
312 cdata = cur.firstChild(); 312 cdata = cur.firstChild();
313 if (unlikely(cdata.isCDATASection())) { 313 if (unlikely(cdata.isCDATASection())) {
314 text = cdata.toCDATASection().data(); 314 text = cdata.toCDATASection().data();
315 } else if (likely(cur.isElement())) { 315 } else if (likely(cur.isElement())) {
316 text = cur.toElement().text(); 316 text = cur.toElement().text();
317 } else { 317 } else {
318 printDebug("Serializer::extractEntry(): neither CDATA nor element."); 318 printDebug("Serializer::extractEntry(): neither CDATA nor element.");
319 return false; 319 return false;
320 } 320 }
321 if (text == " ") 321 if (text == " ")
322 text = ""; // for backward compatibility. 322 text = ""; // for backward compatibility.
323 if (name == ENTRY_DESC_NEW || 323 if (name == ENTRY_DESC_NEW ||
324 name == ENTRY_DESC_OLD) { 324 name == ENTRY_DESC_OLD) {
325 dta->desc = unescapeEntryData(text).latin1(); 325 dta->desc = unescapeEntryData(text).latin1();
326 } else if (name == ENTRY_NAME_NEW || 326 } else if (name == ENTRY_NAME_NEW ||
327 name == ENTRY_NAME_OLD) { 327 name == ENTRY_NAME_OLD) {
328 dta->name = unescapeEntryData(text).latin1(); 328 dta->name = unescapeEntryData(text).latin1();
329 } else if (name == ENTRY_PW_NEW || 329 } else if (name == ENTRY_PW_NEW ||
330 name == ENTRY_PW_OLD) { 330 name == ENTRY_PW_OLD) {
331 dta->pw = unescapeEntryData(text).latin1(); 331 dta->pw = unescapeEntryData(text).latin1();
332 } else if (name == ENTRY_COMMENT_NEW || 332 } else if (name == ENTRY_COMMENT_NEW ||
333 name == ENTRY_COMMENT_OLD) { 333 name == ENTRY_COMMENT_OLD) {
334 dta->comment = unescapeEntryData(text).latin1(); 334 dta->comment = unescapeEntryData(text).latin1();
335 } else if (name == ENTRY_URL_NEW || 335 } else if (name == ENTRY_URL_NEW ||
336 name == ENTRY_URL_OLD) { 336 name == ENTRY_URL_OLD) {
337 dta->url = unescapeEntryData(text).latin1(); 337 dta->url = unescapeEntryData(text).latin1();
338 } else if (name == ENTRY_LAUNCHER_NEW || 338 } else if (name == ENTRY_LAUNCHER_NEW ||
339 name == ENTRY_LAUNCHER_OLD) { 339 name == ENTRY_LAUNCHER_OLD) {
340 dta->launcher = unescapeEntryData(text).latin1(); 340 dta->launcher = unescapeEntryData(text).latin1();
341 } else if (name == ENTRY_LVP_NEW || 341 } else if (name == ENTRY_LVP_NEW ||
342 name == ENTRY_LVP_OLD) { 342 name == ENTRY_LVP_OLD) {
343 dta->listViewPos = strtol(text.latin1(), 0, 10); 343 dta->listViewPos = strtol(text.latin1(), 0, 10);
344 } else if (name == ENTRY_BIN_NEW) { 344 } else if (name == ENTRY_BIN_NEW) {
345 // ENTRY_BIN_NEW == ENTRY_BIN_OLD 345 // ENTRY_BIN_NEW == ENTRY_BIN_OLD
346 if (text == "0") { 346 if (text == "0") {
347 dta->binary = false; 347 dta->binary = false;
348 } else { 348 } else {
349 dta->binary = true; 349 dta->binary = true;
350 } 350 }
351 } else if (name == ENTRY_META_NEW) { 351 } else if (name == ENTRY_META_NEW) {
352 // ENTRY_META_NEW == ENTRY_META_OLD 352 // ENTRY_META_NEW == ENTRY_META_OLD
353 if (!extractMeta(cur, &dta->meta)) 353 if (!extractMeta(cur, &dta->meta))
354 return false; 354 return false;
355 } else { 355 } else {
356 printDebug(string("Serializer::extractEntry(): invalid: ") 356 printDebug(string("Serializer::extractEntry(): invalid: ")
357 + name.latin1()); 357 + name.latin1());
358 } 358 }
359 } 359 }
360 dta->lockStat = defaultLockStat; 360 dta->lockStat = defaultLockStat;
361 return true; 361 return true;
362} 362}
363 363
364bool Serializer::extractMeta(const QDomNode &n, 364bool Serializer::extractMeta(const QDomNode &n,
365 PwMMetaData *dta) 365 PwMMetaData *dta)
366{ 366{
367 QDomNode cur(n.firstChild()); 367 QDomNode cur(n.firstChild());
368 QString name, val; 368 QString name, val;
369 while (!cur.isNull()) { 369 while (!cur.isNull()) {
370 name = cur.nodeName(); 370 name = cur.nodeName();
371 val = cur.toElement().text(); 371 val = cur.toElement().text();
372 if (val == "") { 372 if (val == "") {
373 cur = cur.nextSibling(); 373 cur = cur.nextSibling();
374 continue; 374 continue;
375 } 375 }
376#ifndef PWM_EMBEDDED 376#ifndef PWM_EMBEDDED
377 if (name == META_CREATE_DATE) { 377 if (name == META_CREATE_DATE) {
378 dta->create = QDateTime::fromString(val, Qt::ISODate); 378 dta->create = QDateTime::fromString(val, Qt::ISODate);
379 } else if (name == META_VALID_DATE) { 379 } else if (name == META_VALID_DATE) {
380 dta->valid = QDateTime::fromString(val, Qt::ISODate); 380 dta->valid = QDateTime::fromString(val, Qt::ISODate);
381 } else if (name == META_EXPIRE_DATE) { 381 } else if (name == META_EXPIRE_DATE) {
382 dta->expire = QDateTime::fromString(val, Qt::ISODate); 382 dta->expire = QDateTime::fromString(val, Qt::ISODate);
383 } else if (name == META_UPDATE_DATE) { 383 } else if (name == META_UPDATE_DATE) {
384 dta->update = QDateTime::fromString(val, Qt::ISODate); 384 dta->update = QDateTime::fromString(val, Qt::ISODate);
385 } else if (name == META_UPDATE_INT) { 385 } else if (name == META_UPDATE_INT) {
386 dta->updateInt = strtoul(val.latin1(), 0, 10); 386 dta->updateInt = strtoul(val.latin1(), 0, 10);
387 } else if (name == META_UNIQUEID) { 387 } else if (name == META_UNIQUEID) {
388 dta->uniqueid = unescapeEntryData(val).latin1(); 388 dta->uniqueid = unescapeEntryData(val).latin1();
389 } else { 389 } else {
390 printDebug(string("extractMeta(): invalid: ") 390 printDebug(string("extractMeta(): invalid: ")
391 + name.latin1()); 391 + name.latin1());
392 } 392 }
393#else 393#else
394 394
395 QDateTime m_dt; 395 QDateTime m_dt;
396 396
397 if ((name == META_CREATE_DATE) || 397 if ((name == META_CREATE_DATE) ||
398 (name == META_VALID_DATE) || 398 (name == META_VALID_DATE) ||
399 (name == META_EXPIRE_DATE) || 399 (name == META_EXPIRE_DATE) ||
400 (name == META_UPDATE_DATE)) 400 (name == META_UPDATE_DATE))
401 { 401 {
402 int pos = val.find("T"); 402 int pos = val.find("T");
403 QString date = val.left(pos); 403 QString date = val.left(pos);
404 QString time = val.mid(pos+1); 404 QString time = val.mid(pos+1);
405 qDebug("Serializer::extractMeta : date=%s ,time=%s",date.latin1(), time.latin1() ); 405 qDebug("Serializer::extractMeta : date=%s ,time=%s",date.latin1(), time.latin1() );
406 bool ok1, ok2; 406 bool ok1, ok2;
407 407
408 QDate m_date = KGlobal::locale()->readDate(date, &ok1); 408 QDate m_date = KGlobal::locale()->readDate(date, &ok1);
409 QTime m_time = KGlobal::locale()->readTime(time, &ok2); 409 QTime m_time = KGlobal::locale()->readTime(time, &ok2);
410 if ((ok1 == false) || (ok2 == false)) 410 if ((ok1 == false) || (ok2 == false))
411 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); 411 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
412 m_dt.setDate(m_date); 412 m_dt.setDate(m_date);
413 m_dt.setTime(m_time); 413 m_dt.setTime(m_time);
414 } 414 }
diff --git a/pwmanager/pwmanager/setmasterpwwnd_emb.cpp b/pwmanager/pwmanager/setmasterpwwnd_emb.cpp
new file mode 100644
index 0000000..e6471e6
--- a/dev/null
+++ b/pwmanager/pwmanager/setmasterpwwnd_emb.cpp
@@ -0,0 +1,163 @@
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 "setmasterpwwnd_emb.h"
27
28#include <qpushbutton.h>
29#include <qtabwidget.h>
30#include <qwidget.h>
31#include <qlabel.h>
32#include <qlineedit.h>
33#include <qlayout.h>
34
35#include <klocale.h>
36
37/*US
38#include <qvariant.h>
39#include <qpushbutton.h>
40#include <qtabwidget.h>
41#include <qwidget.h>
42#include <qlabel.h>
43#include <qlineedit.h>
44#include <qlayout.h>
45#include <qtooltip.h>
46#include <qwhatsthis.h>
47*/
48
49/*
50 * Constructs a setMasterPwWnd as a child of 'parent', with the
51 * name 'name'
52 *
53 */
54setMasterPwWnd::setMasterPwWnd( QWidget* parent, const char* name )
55 : KDialogBase( KDialogBase::Plain, i18n( "Set master-password" ),
56 KDialogBase::Ok | KDialogBase::Cancel,
57 KDialogBase::Ok, parent, name, true )
58{
59 QWidget *page = plainPage();
60 QVBoxLayout *pageLayout = new QVBoxLayout( page );
61
62 mainTab = new QTabWidget( page );
63 pageLayout->addWidget( mainTab );
64
65
66 if ( !name )
67 setName( "setMasterPwWnd" );
68
69 ////////////////////////////////////////////////////////////////////
70 // This is the Password tab1
71 tab = new QWidget( mainTab );
72
73 QGridLayout *layout = new QGridLayout( tab, 5, 1 );
74 layout->setMargin( KDialogBase::marginHint() );
75 layout->setSpacing( KDialogBase::spacingHint() );
76
77 QLabel* label = new QLabel( i18n( "Using a normal password-string to encrypt the data." ), tab );
78 label->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
79 layout->addWidget(label, 0, 0);
80
81 pwEdit_1 = new QLineEdit( tab, "pwEdit_1" );
82 pwEdit_1->setEchoMode( QLineEdit::Password );
83
84 label = new QLabel( pwEdit_1, i18n( "Please enter the new master-password:" ), tab );
85 layout->addWidget(label, 1, 0);
86 layout->addWidget(pwEdit_1, 2, 0);
87
88 pwEdit_2 = new QLineEdit( tab, "pwEdit_2" );
89 pwEdit_2->setEchoMode( QLineEdit::Password );
90
91 label = new QLabel( pwEdit_2, i18n( "Please enter the password again:" ), tab );
92 layout->addWidget(label, 3, 0);
93 layout->addWidget(pwEdit_2, 4, 0);
94
95 mainTab->insertTab( tab, i18n("Normal password") );
96
97
98 ////////////////////////////////////////////////////////////////////
99 // This is the Password tab2
100 tab_2 = new QWidget( mainTab );
101
102 layout = new QGridLayout( tab_2, 5, 1 );
103 layout->setMargin( KDialogBase::marginHint() );
104 layout->setSpacing( KDialogBase::spacingHint() );
105
106 label = new QLabel( i18n( "Using a PwM key-card to encrypt the data." ), tab_2 );
107 label->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
108 layout->addWidget(label, 0, 0);
109
110 label = new QLabel( i18n( "selected card:" ), tab_2 );
111 label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
112 layout->addWidget(label, 1, 0);
113
114 selCardButton = new QPushButton( i18n( "&Select the currently inserted card as key-card" ), tab_2 );
115 layout->addWidget(selCardButton, 2, 0);
116
117 genCardButton = new QPushButton( i18n( "&generate new key-card") , tab_2 );
118 layout->addWidget(genCardButton, 3, 0);
119
120 curCardIdLabel = new QLabel( QString("") , tab_2 );
121 layout->addWidget(curCardIdLabel, 4, 0);
122
123 mainTab->insertTab( tab_2, i18n("Key-card (chipcard)" ) );
124
125
126 // resize( QSize(411, 313).expandedTo(minimumSizeHint()) );
127
128 // signals and slots connections
129 // connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_slot() ) );
130 // connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_slot() ) );
131 connect( genCardButton, SIGNAL( clicked() ), this, SLOT( genCardButton_slot() ) );
132 connect( selCardButton, SIGNAL( clicked() ), this, SLOT( selCardButton_slot() ) );
133
134}
135
136/*
137 * Destroys the object and frees any allocated resources
138 */
139setMasterPwWnd::~setMasterPwWnd()
140{
141 // no need to delete child widgets, Qt does it all for us
142}
143
144void setMasterPwWnd::okButton_slot()
145{
146 qWarning( "setMasterPwWnd::okButton_slot(): Not implemented yet" );
147}
148
149void setMasterPwWnd::cancelButton_slot()
150{
151 qWarning( "setMasterPwWnd::cancelButton_slot(): Not implemented yet" );
152}
153
154void setMasterPwWnd::genCardButton_slot()
155{
156 qWarning( "setMasterPwWnd::genCardButton_slot(): Not implemented yet" );
157}
158
159void setMasterPwWnd::selCardButton_slot()
160{
161 qWarning( "setMasterPwWnd::selCardButton_slot(): Not implemented yet" );
162}
163
diff --git a/pwmanager/pwmanager/setmasterpwwnd_emb.h b/pwmanager/pwmanager/setmasterpwwnd_emb.h
new file mode 100644
index 0000000..c8ddec6
--- a/dev/null
+++ b/pwmanager/pwmanager/setmasterpwwnd_emb.h
@@ -0,0 +1,62 @@
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 SETMASTERPWWND_EMB_H
27#define SETMASTERPWWND_EMB_H
28
29#include <kdialogbase.h>
30
31class QLineEdit;
32class QPushButton;
33class QLabel;
34class QTabWidget;
35class QWidget;
36
37class setMasterPwWnd : public KDialogBase
38{
39 Q_OBJECT
40
41public:
42 setMasterPwWnd( QWidget* parent = 0, const char* name = 0 );
43 ~setMasterPwWnd();
44
45 QTabWidget* mainTab;
46 QWidget* tab;
47 QWidget* tab_2;
48 QLineEdit* pwEdit_1;
49 QLineEdit* pwEdit_2;
50 QPushButton* selCardButton;
51 QPushButton* genCardButton;
52 QLabel* curCardIdLabel;
53
54public slots:
55 virtual void okButton_slot();
56 virtual void cancelButton_slot();
57 virtual void genCardButton_slot();
58 virtual void selCardButton_slot();
59
60};
61
62#endif // SETMASTERPWWND_H
diff --git a/pwmanager/pwmanager/setmasterpwwndimpl.cpp b/pwmanager/pwmanager/setmasterpwwndimpl.cpp
index aac0408..3482643 100644
--- a/pwmanager/pwmanager/setmasterpwwndimpl.cpp
+++ b/pwmanager/pwmanager/setmasterpwwndimpl.cpp
@@ -1,152 +1,193 @@
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/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.0.1 of pwmanager 15 * This file is originaly based on version 1.0.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 "setmasterpwwndimpl.h" 21#include "setmasterpwwndimpl.h"
22#include "pwm.h" 22#include "pwm.h"
23#include "globalstuff.h" 23#include "globalstuff.h"
24 24
25#include <kmessagebox.h> 25#include <kmessagebox.h>
26 26
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30 30
31#include <stdio.h> 31#include <stdio.h>
32 32
33#ifdef CONFIG_KEYCARD 33#ifdef CONFIG_KEYCARD
34# include "pwmkeycard.h" 34# include "pwmkeycard.h"
35#endif 35#endif
36 36
37 #define STRING_CARD_NONE(SetMasterPwWndImpl::string_cardNone()) 37 #define STRING_CARD_NONE(SetMasterPwWndImpl::string_cardNone())
38 38
39 39
40SetMasterPwWndImpl::SetMasterPwWndImpl(QWidget * parent, const char *name) 40SetMasterPwWndImpl::SetMasterPwWndImpl(QWidget * parent, const char *name)
41: setMasterPwWnd(parent, name) 41: setMasterPwWnd(parent, name)
42{ 42{
43#ifdef CONFIG_KEYCARD 43#ifdef CONFIG_KEYCARD
44 curCardIdLabel->setText(STRING_CARD_NONE); 44 curCardIdLabel->setText(STRING_CARD_NONE);
45#else // CONFIG_KEYCARD 45#else // CONFIG_KEYCARD
46#ifndef PWM_EMBEDDED 46#ifndef PWM_EMBEDDED
47 mainTab->removePage(mainTab->page(1)); 47 mainTab->removePage(mainTab->page(1));
48#else 48#else
49 qDebug("SetMasterPwWndImpl::SetMasterPwWndImpl has to be fixed"); 49 mainTab->removePage(tab_2);
50#endif 50#endif
51
51#endif // CONFIG_KEYCARD 52#endif // CONFIG_KEYCARD
52 keyCard = 0; 53 keyCard = 0;
53} 54}
54 55
55SetMasterPwWndImpl::~SetMasterPwWndImpl() 56SetMasterPwWndImpl::~SetMasterPwWndImpl()
56{ 57{
57} 58}
58 59
59void SetMasterPwWndImpl::okButton_slot() 60void SetMasterPwWndImpl::okButton_slot()
60{ 61{
62#ifndef PWM_EMBEDDED
61 int index = mainTab->currentPageIndex(); 63 int index = mainTab->currentPageIndex();
62 if (index == 0) { 64 if (index == 0) {
63 // normal password 65 // normal password
64 if (pwEdit_1->text() != pwEdit_2->text()) { 66 if (pwEdit_1->text() != pwEdit_2->text()) {
65 KMessageBox::error(this, 67 KMessageBox::error(this,
66 i18n 68 i18n
67 ("The two passwords you have entered don't match.\n" 69 ("The two passwords you have entered don't match.\n"
68 "Please try entering them again."), 70 "Please try entering them again."),
69 i18n("Different passwords")); 71 i18n("Different passwords"));
70 return; 72 return;
71 } 73 }
72 if (pwEdit_1->text() == "") { 74 if (pwEdit_1->text() == "") {
73 KMessageBox::error(this, 75 KMessageBox::error(this,
74 i18n("No password entered. " 76 i18n("No password entered. "
75 "Please type in a password, that " 77 "Please type in a password, that "
76 "you want to use for the encryption."), 78 "you want to use for the encryption."),
77 i18n("no password")); 79 i18n("no password"));
78 return; 80 return;
79 } 81 }
80 } else { 82 } else {
81 // key-card 83 // key-card
82 if (curCardIdLabel->text() == STRING_CARD_NONE) { 84 if (curCardIdLabel->text() == STRING_CARD_NONE) {
83 KMessageBox::error(this, 85 KMessageBox::error(this,
84 i18n("You didn't select a card as " 86 i18n("You didn't select a card as "
85 "PwM-key-card."), 87 "PwM-key-card."),
86 i18n("no card")); 88 i18n("no card"));
87 return; 89 return;
88 } 90 }
89 } 91 }
90 done(1); 92 done(1);
93#endif
91} 94}
92 95
93void SetMasterPwWndImpl::cancelButton_slot() 96void SetMasterPwWndImpl::cancelButton_slot()
94{ 97{
98#ifndef PWM_EMBEDDED
95 done(2); 99 done(2);
100#endif
101}
102
103void SetMasterPwWndImpl::slotOk()
104{
105 int index = mainTab->currentPageIndex();
106 if (index == 0) {
107 // normal password
108 if (pwEdit_1->text() != pwEdit_2->text()) {
109 KMessageBox::error(this,
110 i18n
111 ("The two passwords you have entered\ndon't match.\n"
112 "Please try entering them again."),
113 i18n("Different passwords"));
114 return;
115 }
116 if (pwEdit_1->text() == "") {
117 KMessageBox::error(this,
118 i18n("No password entered.\n"
119 "Please type in a password,\nthat "
120 "you want to use for\nthe encryption."),
121 i18n("no password"));
122 return;
123 }
124 } else {
125 // key-card
126 if (curCardIdLabel->text() == STRING_CARD_NONE) {
127 KMessageBox::error(this,
128 i18n("You didn't select a card as\n"
129 "PwM-key-card."),
130 i18n("no card"));
131 return;
132 }
133 }
134
135 setMasterPwWnd::slotOk();
96} 136}
97 137
138
98void SetMasterPwWndImpl::genCardButton_slot() 139void SetMasterPwWndImpl::genCardButton_slot()
99{ 140{
100#ifdef CONFIG_KEYCARD 141#ifdef CONFIG_KEYCARD
101 PWM_ASSERT(keyCard); 142 PWM_ASSERT(keyCard);
102 keyCard->genNewCard(); 143 keyCard->genNewCard();
103#endif // CONFIG_KEYCARD 144#endif // CONFIG_KEYCARD
104} 145}
105 146
106void SetMasterPwWndImpl::selCardButton_slot() 147void SetMasterPwWndImpl::selCardButton_slot()
107{ 148{
108#ifdef CONFIG_KEYCARD 149#ifdef CONFIG_KEYCARD
109 PWM_ASSERT(keyCard); 150 PWM_ASSERT(keyCard);
110 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 151 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
111 this, SLOT(keyAvailable_slot(uint32_t, const string &))); 152 this, SLOT(keyAvailable_slot(uint32_t, const string &)));
112 keyCard->getKey(); 153 keyCard->getKey();
113#endif // CONFIG_KEYCARD 154#endif // CONFIG_KEYCARD
114} 155}
115 156
116void SetMasterPwWndImpl::keyAvailable_slot(uint32_t cardId, 157void SetMasterPwWndImpl::keyAvailable_slot(uint32_t cardId,
117 const string &key) 158 const string &key)
118{ 159{
119 if (key == "") 160 if (key == "")
120 return; 161 return;
121 curCardKey = key; 162 curCardKey = key;
122 char id_buf[(sizeof(cardId) * 2) + 2 /* "0x" */ + 1 /* NULL */]; 163 char id_buf[(sizeof(cardId) * 2) + 2 /* "0x" */ + 1 /* NULL */];
123 memcpy(id_buf, "0x", 2); 164 memcpy(id_buf, "0x", 2);
124 sprintf(id_buf + 2, "%X", cardId); 165 sprintf(id_buf + 2, "%X", cardId);
125 curCardIdLabel->setText(id_buf); 166 curCardIdLabel->setText(id_buf);
126} 167}
127 168
128string SetMasterPwWndImpl::getPw(bool *useCard) 169string SetMasterPwWndImpl::getPw(bool *useCard)
129{ 170{
130 int index = mainTab->currentPageIndex(); 171 int index = mainTab->currentPageIndex();
131 if (index == 0) { 172 if (index == 0) {
132 // normal password 173 // normal password
133 if (useCard) 174 if (useCard)
134 *useCard = false; 175 *useCard = false;
135 PWM_ASSERT(pwEdit_1->text() == pwEdit_2->text()); 176 PWM_ASSERT(pwEdit_1->text() == pwEdit_2->text());
136 return pwEdit_1->text().latin1(); 177 return pwEdit_1->text().latin1();
137 } else { 178 } else {
138#ifdef CONFIG_KEYCARD 179#ifdef CONFIG_KEYCARD
139 // key-card 180 // key-card
140 if (useCard) 181 if (useCard)
141 *useCard = true; 182 *useCard = true;
142 PWM_ASSERT(curCardKey != ""); 183 PWM_ASSERT(curCardKey != "");
143 PWM_ASSERT(curCardIdLabel->text() != STRING_CARD_NONE); 184 PWM_ASSERT(curCardIdLabel->text() != STRING_CARD_NONE);
144 return curCardKey; 185 return curCardKey;
145#endif // CONFIG_KEYCARD 186#endif // CONFIG_KEYCARD
146 } 187 }
147 return ""; 188 return "";
148} 189}
149 190
150#ifndef PWM_EMBEDDED 191#ifndef PWM_EMBEDDED
151#include "setmasterpwwndimpl.moc" 192#include "setmasterpwwndimpl.moc"
152#endif 193#endif
diff --git a/pwmanager/pwmanager/setmasterpwwndimpl.h b/pwmanager/pwmanager/setmasterpwwndimpl.h
index 56effc1..3203d4d 100644
--- a/pwmanager/pwmanager/setmasterpwwndimpl.h
+++ b/pwmanager/pwmanager/setmasterpwwndimpl.h
@@ -1,72 +1,80 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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.0.1 of pwmanager 15 * This file is originaly based on version 1.0.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#ifndef SETMASTERPWWNDIMPL_H 21#ifndef SETMASTERPWWNDIMPL_H
22#define SETMASTERPWWNDIMPL_H 22#define SETMASTERPWWNDIMPL_H
23 23
24#ifndef PWM_EMBEDDED
24#include "setmasterpwwnd.h" 25#include "setmasterpwwnd.h"
26#else
27#include "setmasterpwwnd_emb.h"
28#endif
25 29
26#include <klocale.h> 30#include <klocale.h>
27 31
28#include <stdint.h> 32#include <stdint.h>
29#include <string> 33#include <string>
30using std::string; 34using std::string;
31 35
32class PwMKeyCard; 36class PwMKeyCard;
33 37
34/** set master pw wnd */ 38/** set master pw wnd */
35class SetMasterPwWndImpl : public setMasterPwWnd 39class SetMasterPwWndImpl : public setMasterPwWnd
36{ 40{
37 Q_OBJECT 41 Q_OBJECT
38public: 42public:
39 SetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0); 43 SetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0);
40 ~SetMasterPwWndImpl(); 44 ~SetMasterPwWndImpl();
41 45
42 static QString string_cardNone() 46 static QString string_cardNone()
43 { return i18n("NONE"); } 47 { return i18n("NONE"); }
44 48
45 /** returns the selected pw (or the key on the card) */ 49 /** returns the selected pw (or the key on the card) */
46 string getPw(bool *useCard); 50 string getPw(bool *useCard);
47 /** set pointer to the keycard-access object */ 51 /** set pointer to the keycard-access object */
48 void setPwMKeyCard(PwMKeyCard *_keyCard) 52 void setPwMKeyCard(PwMKeyCard *_keyCard)
49 { keyCard = _keyCard; } 53 { keyCard = _keyCard; }
50 54
51public slots: 55public slots:
52 /** ok button pressed */ 56 /** ok button pressed */
53 void okButton_slot(); 57 void okButton_slot();
54 /** cancel button pressed */ 58 /** cancel button pressed */
55 void cancelButton_slot(); 59 void cancelButton_slot();
56 /** "generate a new card" button pressed */ 60 /** "generate a new card" button pressed */
57 void genCardButton_slot(); 61 void genCardButton_slot();
58 /** "select current card" button pressed */ 62 /** "select current card" button pressed */
59 void selCardButton_slot(); 63 void selCardButton_slot();
60 64
65#ifdef PWM_EMBEDDED
66 virtual void slotOk();
67#endif
68
61protected slots: 69protected slots:
62 /** key from PwMKeyCard is available */ 70 /** key from PwMKeyCard is available */
63 void keyAvailable_slot(uint32_t cardId, const string &key); 71 void keyAvailable_slot(uint32_t cardId, const string &key);
64 72
65protected: 73protected:
66 /** key of currently inserted card */ 74 /** key of currently inserted card */
67 string curCardKey; 75 string curCardKey;
68 /** pointer to the keycard-access object */ 76 /** pointer to the keycard-access object */
69 PwMKeyCard *keyCard; 77 PwMKeyCard *keyCard;
70}; 78};
71 79
72#endif 80#endif