author | ulf69 <ulf69> | 2004-09-21 19:44:23 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-21 19:44:23 (UTC) |
commit | a6a6544fc57542752fecc3763e0d35e6a38040ac (patch) (unidiff) | |
tree | 3324285a4aaee1db873e0c83d0c8e911cbe1aefb | |
parent | 6a40d65ddd6657e34c69d839da458810a8d8ff98 (diff) | |
download | kdepimpi-a6a6544fc57542752fecc3763e0d35e6a38040ac.zip kdepimpi-a6a6544fc57542752fecc3763e0d35e6a38040ac.tar.gz kdepimpi-a6a6544fc57542752fecc3763e0d35e6a38040ac.tar.bz2 |
*** empty log message ***
-rw-r--r-- | pwmanager/pwmanager/configwnd.cpp | 11 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 35 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmanagerE.pro | 27 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdocui.cpp | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwminit.cpp | 19 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmtray.cpp | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmview.cpp | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/serializer.cpp | 1 |
10 files changed, 83 insertions, 23 deletions
diff --git a/pwmanager/pwmanager/configwnd.cpp b/pwmanager/pwmanager/configwnd.cpp index 230ca1b..108c40f 100644 --- a/pwmanager/pwmanager/configwnd.cpp +++ b/pwmanager/pwmanager/configwnd.cpp | |||
@@ -1,264 +1,265 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'configwnd.ui' | 2 | ** Form implementation generated from reading ui file 'configwnd.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Sep 14 15:20:58 2004 | 4 | ** Created: Tue Sep 14 15:20:58 2004 |
5 | ** by: The User Interface Compiler ($Id$) | 5 | ** by: The User Interface Compiler ($Id$) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | 9 | ||
10 | #include "configwnd.h" | 10 | #include "configwnd.h" |
11 | 11 | ||
12 | #include <qvariant.h> | 12 | #include <qvariant.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
15 | #include <qwidget.h> | 15 | #include <qwidget.h> |
16 | #include <qcombobox.h> | 16 | #include <qcombobox.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qlineedit.h> | 18 | #include <qlineedit.h> |
19 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
20 | #include <qspinbox.h> | 20 | #include <qspinbox.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qtooltip.h> | 22 | #include <qtooltip.h> |
23 | #include <qwhatsthis.h> | 23 | #include <qwhatsthis.h> |
24 | 24 | ||
25 | /* | 25 | /* |
26 | * Constructs a configWnd as a child of 'parent', with the | 26 | * Constructs a configWnd as a child of 'parent', with the |
27 | * name 'name' and widget flags set to 'f'. | 27 | * name 'name' and widget flags set to 'f'. |
28 | * | 28 | * |
29 | * The dialog will by default be modeless, unless you set 'modal' to | 29 | * The dialog will by default be modeless, unless you set 'modal' to |
30 | * TRUE to construct a modal dialog. | 30 | * TRUE to construct a modal dialog. |
31 | */ | 31 | */ |
32 | configWnd::configWnd( QWidget* parent, const char* name, bool modal, WFlags fl ) | 32 | configWnd::configWnd( QWidget* parent, const char* name, bool modal, WFlags fl ) |
33 | : QDialog( parent, name, modal, fl ) | 33 | : QDialog( parent, name, modal, fl ) |
34 | { | 34 | { |
35 | if ( !name ) | 35 | if ( !name ) |
36 | setName( "configWnd" ); | 36 | setName( "configWnd" ); |
37 | 37 | ||
38 | okButton = new QPushButton( this, "okButton" ); | 38 | okButton = new QPushButton( this, "okButton" ); |
39 | okButton->setGeometry( QRect( 10, 280, 107, 27 ) ); | 39 | okButton->setGeometry( QRect( 10, 280, 107, 27 ) ); |
40 | 40 | ||
41 | cancelButton = new QPushButton( this, "cancelButton" ); | 41 | cancelButton = new QPushButton( this, "cancelButton" ); |
42 | cancelButton->setGeometry( QRect( 370, 280, 107, 27 ) ); | 42 | cancelButton->setGeometry( QRect( 370, 280, 107, 27 ) ); |
43 | 43 | ||
44 | tabWidget2 = new QTabWidget( this, "tabWidget2" ); | 44 | tabWidget2 = new QTabWidget( this, "tabWidget2" ); |
45 | tabWidget2->setGeometry( QRect( 10, 10, 470, 260 ) ); | 45 | tabWidget2->setGeometry( QRect( 10, 10, 470, 260 ) ); |
46 | 46 | ||
47 | ////////////////////////////// | ||
47 | tab = new QWidget( tabWidget2, "tab" ); | 48 | tab = new QWidget( tabWidget2, "tab" ); |
48 | 49 | ||
49 | windowStyleComboBox = new QComboBox( FALSE, tab, "windowStyleComboBox" ); | 50 | windowStyleComboBox = new QComboBox( FALSE, tab, "windowStyleComboBox" ); |
50 | windowStyleComboBox->setGeometry( QRect( 220, 180, 210, 28 ) ); | 51 | windowStyleComboBox->setGeometry( QRect( 220, 180, 210, 28 ) ); |
51 | 52 | ||
52 | textLabel1_5 = new QLabel( tab, "textLabel1_5" ); | 53 | textLabel1_5 = new QLabel( tab, "textLabel1_5" ); |
53 | textLabel1_5->setGeometry( QRect( 30, 180, 180, 20 ) ); | 54 | textLabel1_5->setGeometry( QRect( 30, 180, 180, 20 ) ); |
54 | textLabel1_5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 55 | textLabel1_5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
55 | 56 | ||
56 | textLabel1_4 = new QLabel( tab, "textLabel1_4" ); | 57 | textLabel1_4 = new QLabel( tab, "textLabel1_4" ); |
57 | textLabel1_4->setGeometry( QRect( 30, 40, 400, 20 ) ); | 58 | textLabel1_4->setGeometry( QRect( 30, 40, 400, 20 ) ); |
58 | 59 | ||
59 | selEntrFontButton = new QPushButton( tab, "selEntrFontButton" ); | 60 | selEntrFontButton = new QPushButton( tab, "selEntrFontButton" ); |
60 | selEntrFontButton->setGeometry( QRect( 30, 90, 160, 27 ) ); | 61 | selEntrFontButton->setGeometry( QRect( 30, 90, 160, 27 ) ); |
61 | 62 | ||
62 | currEntrFont = new QLabel( tab, "currEntrFont" ); | 63 | currEntrFont = new QLabel( tab, "currEntrFont" ); |
63 | currEntrFont->setGeometry( QRect( 30, 70, 230, 20 ) ); | 64 | currEntrFont->setGeometry( QRect( 30, 70, 230, 20 ) ); |
64 | tabWidget2->insertTab( tab, QString("") ); | 65 | tabWidget2->insertTab( tab, QString("") ); |
65 | 66 | ////////////////////////////////////// | |
66 | TabPage = new QWidget( tabWidget2, "TabPage" ); | 67 | TabPage = new QWidget( tabWidget2, "TabPage" ); |
67 | 68 | ||
68 | compressionComboBox = new QComboBox( FALSE, TabPage, "compressionComboBox" ); | 69 | compressionComboBox = new QComboBox( FALSE, TabPage, "compressionComboBox" ); |
69 | compressionComboBox->setGeometry( QRect( 290, 50, 150, 28 ) ); | 70 | compressionComboBox->setGeometry( QRect( 290, 50, 150, 28 ) ); |
70 | 71 | ||
71 | textLabel1_6 = new QLabel( TabPage, "textLabel1_6" ); | 72 | textLabel1_6 = new QLabel( TabPage, "textLabel1_6" ); |
72 | textLabel1_6->setGeometry( QRect( 10, 50, 270, 20 ) ); | 73 | textLabel1_6->setGeometry( QRect( 10, 50, 270, 20 ) ); |
73 | textLabel1_6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 74 | textLabel1_6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
74 | 75 | ||
75 | textLabel1_8 = new QLabel( TabPage, "textLabel1_8" ); | 76 | textLabel1_8 = new QLabel( TabPage, "textLabel1_8" ); |
76 | textLabel1_8->setGeometry( QRect( 10, 90, 270, 20 ) ); | 77 | textLabel1_8->setGeometry( QRect( 10, 90, 270, 20 ) ); |
77 | textLabel1_8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 78 | textLabel1_8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
78 | 79 | ||
79 | permissionLineEdit = new QLineEdit( TabPage, "permissionLineEdit" ); | 80 | permissionLineEdit = new QLineEdit( TabPage, "permissionLineEdit" ); |
80 | permissionLineEdit->setGeometry( QRect( 290, 90, 142, 27 ) ); | 81 | permissionLineEdit->setGeometry( QRect( 290, 90, 142, 27 ) ); |
81 | permissionLineEdit->setMaxLength( 3 ); | 82 | permissionLineEdit->setMaxLength( 3 ); |
82 | 83 | ||
83 | fileBackupCheckBox = new QCheckBox( TabPage, "fileBackupCheckBox" ); | 84 | fileBackupCheckBox = new QCheckBox( TabPage, "fileBackupCheckBox" ); |
84 | fileBackupCheckBox->setGeometry( QRect( 80, 140, 360, 23 ) ); | 85 | fileBackupCheckBox->setGeometry( QRect( 80, 140, 360, 23 ) ); |
85 | tabWidget2->insertTab( TabPage, QString("") ); | 86 | tabWidget2->insertTab( TabPage, QString("") ); |
86 | 87 | ////////////////////////////////////// | |
87 | tab_2 = new QWidget( tabWidget2, "tab_2" ); | 88 | tab_2 = new QWidget( tabWidget2, "tab_2" ); |
88 | 89 | ||
89 | pwTimeoutSpinBox = new QSpinBox( tab_2, "pwTimeoutSpinBox" ); | 90 | pwTimeoutSpinBox = new QSpinBox( tab_2, "pwTimeoutSpinBox" ); |
90 | pwTimeoutSpinBox->setGeometry( QRect( 390, 50, 55, 23 ) ); | 91 | pwTimeoutSpinBox->setGeometry( QRect( 390, 50, 55, 23 ) ); |
91 | 92 | ||
92 | textLabel1 = new QLabel( tab_2, "textLabel1" ); | 93 | textLabel1 = new QLabel( tab_2, "textLabel1" ); |
93 | textLabel1->setGeometry( QRect( 10, 20, 370, 80 ) ); | 94 | textLabel1->setGeometry( QRect( 10, 20, 370, 80 ) ); |
94 | textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); | 95 | textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); |
95 | 96 | ||
96 | textLabel1_7 = new QLabel( tab_2, "textLabel1_7" ); | 97 | textLabel1_7 = new QLabel( tab_2, "textLabel1_7" ); |
97 | textLabel1_7->setGeometry( QRect( 10, 110, 370, 80 ) ); | 98 | textLabel1_7->setGeometry( QRect( 10, 110, 370, 80 ) ); |
98 | textLabel1_7->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); | 99 | textLabel1_7->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); |
99 | 100 | ||
100 | lockTimeoutSpinBox = new QSpinBox( tab_2, "lockTimeoutSpinBox" ); | 101 | lockTimeoutSpinBox = new QSpinBox( tab_2, "lockTimeoutSpinBox" ); |
101 | lockTimeoutSpinBox->setGeometry( QRect( 390, 140, 55, 23 ) ); | 102 | lockTimeoutSpinBox->setGeometry( QRect( 390, 140, 55, 23 ) ); |
102 | 103 | ||
103 | autoDeepLockCheckBox = new QCheckBox( tab_2, "autoDeepLockCheckBox" ); | 104 | autoDeepLockCheckBox = new QCheckBox( tab_2, "autoDeepLockCheckBox" ); |
104 | autoDeepLockCheckBox->setGeometry( QRect( 60, 180, 380, 25 ) ); | 105 | autoDeepLockCheckBox->setGeometry( QRect( 60, 180, 380, 25 ) ); |
105 | tabWidget2->insertTab( tab_2, QString("") ); | 106 | tabWidget2->insertTab( tab_2, QString("") ); |
106 | 107 | /////////////////////////////////////////// | |
107 | tab_3 = new QWidget( tabWidget2, "tab_3" ); | 108 | tab_3 = new QWidget( tabWidget2, "tab_3" ); |
108 | 109 | ||
109 | textLabel1_3 = new QLabel( tab_3, "textLabel1_3" ); | 110 | textLabel1_3 = new QLabel( tab_3, "textLabel1_3" ); |
110 | textLabel1_3->setGeometry( QRect( 30, 30, 400, 20 ) ); | 111 | textLabel1_3->setGeometry( QRect( 30, 30, 400, 20 ) ); |
111 | 112 | ||
112 | autoStartLineEdit = new QLineEdit( tab_3, "autoStartLineEdit" ); | 113 | autoStartLineEdit = new QLineEdit( tab_3, "autoStartLineEdit" ); |
113 | autoStartLineEdit->setGeometry( QRect( 30, 50, 360, 20 ) ); | 114 | autoStartLineEdit->setGeometry( QRect( 30, 50, 360, 20 ) ); |
114 | 115 | ||
115 | browseAutoStButton = new QPushButton( tab_3, "browseAutoStButton" ); | 116 | browseAutoStButton = new QPushButton( tab_3, "browseAutoStButton" ); |
116 | browseAutoStButton->setGeometry( QRect( 400, 50, 30, 20 ) ); | 117 | browseAutoStButton->setGeometry( QRect( 400, 50, 30, 20 ) ); |
117 | 118 | ||
118 | autostartDeeplockedCheckBox = new QCheckBox( tab_3, "autostartDeeplockedCheckBox" ); | 119 | autostartDeeplockedCheckBox = new QCheckBox( tab_3, "autostartDeeplockedCheckBox" ); |
119 | autostartDeeplockedCheckBox->setGeometry( QRect( 40, 80, 390, 25 ) ); | 120 | autostartDeeplockedCheckBox->setGeometry( QRect( 40, 80, 390, 25 ) ); |
120 | tabWidget2->insertTab( tab_3, QString("") ); | 121 | tabWidget2->insertTab( tab_3, QString("") ); |
121 | 122 | //////////////////////////////////////////// | |
122 | tab_4 = new QWidget( tabWidget2, "tab_4" ); | 123 | tab_4 = new QWidget( tabWidget2, "tab_4" ); |
123 | 124 | ||
124 | textLabel2 = new QLabel( tab_4, "textLabel2" ); | 125 | textLabel2 = new QLabel( tab_4, "textLabel2" ); |
125 | textLabel2->setGeometry( QRect( 20, 40, 280, 20 ) ); | 126 | textLabel2->setGeometry( QRect( 20, 40, 280, 20 ) ); |
126 | textLabel2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 127 | textLabel2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
127 | 128 | ||
128 | browserLineEdit = new QLineEdit( tab_4, "browserLineEdit" ); | 129 | browserLineEdit = new QLineEdit( tab_4, "browserLineEdit" ); |
129 | browserLineEdit->setGeometry( QRect( 310, 40, 130, 27 ) ); | 130 | browserLineEdit->setGeometry( QRect( 310, 40, 130, 27 ) ); |
130 | 131 | ||
131 | xtermLineEdit = new QLineEdit( tab_4, "xtermLineEdit" ); | 132 | xtermLineEdit = new QLineEdit( tab_4, "xtermLineEdit" ); |
132 | xtermLineEdit->setGeometry( QRect( 310, 100, 130, 27 ) ); | 133 | xtermLineEdit->setGeometry( QRect( 310, 100, 130, 27 ) ); |
133 | 134 | ||
134 | textLabel3 = new QLabel( tab_4, "textLabel3" ); | 135 | textLabel3 = new QLabel( tab_4, "textLabel3" ); |
135 | textLabel3->setGeometry( QRect( 20, 100, 280, 20 ) ); | 136 | textLabel3->setGeometry( QRect( 20, 100, 280, 20 ) ); |
136 | textLabel3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 137 | textLabel3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
137 | tabWidget2->insertTab( tab_4, QString("") ); | 138 | tabWidget2->insertTab( tab_4, QString("") ); |
138 | 139 | /////////////////////////////////////////////// | |
139 | tab_5 = new QWidget( tabWidget2, "tab_5" ); | 140 | tab_5 = new QWidget( tabWidget2, "tab_5" ); |
140 | 141 | ||
141 | trayCheckBox = new QCheckBox( tab_5, "trayCheckBox" ); | 142 | trayCheckBox = new QCheckBox( tab_5, "trayCheckBox" ); |
142 | trayCheckBox->setGeometry( QRect( 30, 30, 400, 20 ) ); | 143 | trayCheckBox->setGeometry( QRect( 30, 30, 400, 20 ) ); |
143 | 144 | ||
144 | openUnlockedCheckBox = new QCheckBox( tab_5, "openUnlockedCheckBox" ); | 145 | openUnlockedCheckBox = new QCheckBox( tab_5, "openUnlockedCheckBox" ); |
145 | openUnlockedCheckBox->setGeometry( QRect( 30, 80, 400, 20 ) ); | 146 | openUnlockedCheckBox->setGeometry( QRect( 30, 80, 400, 20 ) ); |
146 | 147 | ||
147 | autoMinimizeCheckBox = new QCheckBox( tab_5, "autoMinimizeCheckBox" ); | 148 | autoMinimizeCheckBox = new QCheckBox( tab_5, "autoMinimizeCheckBox" ); |
148 | autoMinimizeCheckBox->setEnabled( FALSE ); | 149 | autoMinimizeCheckBox->setEnabled( FALSE ); |
149 | autoMinimizeCheckBox->setGeometry( QRect( 50, 50, 380, 25 ) ); | 150 | autoMinimizeCheckBox->setGeometry( QRect( 50, 50, 380, 25 ) ); |
150 | 151 | ||
151 | minimizeLockComboBox = new QComboBox( FALSE, tab_5, "minimizeLockComboBox" ); | 152 | minimizeLockComboBox = new QComboBox( FALSE, tab_5, "minimizeLockComboBox" ); |
152 | minimizeLockComboBox->setGeometry( QRect( 310, 170, 120, 27 ) ); | 153 | minimizeLockComboBox->setGeometry( QRect( 310, 170, 120, 27 ) ); |
153 | 154 | ||
154 | textLabel1_9 = new QLabel( tab_5, "textLabel1_9" ); | 155 | textLabel1_9 = new QLabel( tab_5, "textLabel1_9" ); |
155 | textLabel1_9->setGeometry( QRect( 30, 180, 270, 20 ) ); | 156 | textLabel1_9->setGeometry( QRect( 30, 180, 270, 20 ) ); |
156 | textLabel1_9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 157 | textLabel1_9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
157 | 158 | ||
158 | kwalletEmuCheckBox = new QCheckBox( tab_5, "kwalletEmuCheckBox" ); | 159 | kwalletEmuCheckBox = new QCheckBox( tab_5, "kwalletEmuCheckBox" ); |
159 | kwalletEmuCheckBox->setGeometry( QRect( 30, 110, 400, 25 ) ); | 160 | kwalletEmuCheckBox->setGeometry( QRect( 30, 110, 400, 25 ) ); |
160 | 161 | ||
161 | wndCloseCheckBox = new QCheckBox( tab_5, "wndCloseCheckBox" ); | 162 | wndCloseCheckBox = new QCheckBox( tab_5, "wndCloseCheckBox" ); |
162 | wndCloseCheckBox->setGeometry( QRect( 30, 140, 430, 24 ) ); | 163 | wndCloseCheckBox->setGeometry( QRect( 30, 140, 430, 24 ) ); |
163 | tabWidget2->insertTab( tab_5, QString("") ); | 164 | tabWidget2->insertTab( tab_5, QString("") ); |
164 | languageChange(); | 165 | languageChange(); |
165 | resize( QSize(490, 318).expandedTo(minimumSizeHint()) ); | 166 | resize( QSize(490, 318).expandedTo(minimumSizeHint()) ); |
166 | clearWState( WState_Polished ); | 167 | clearWState( WState_Polished ); |
167 | 168 | ||
168 | // signals and slots connections | 169 | // signals and slots connections |
169 | connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_slot() ) ); | 170 | connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_slot() ) ); |
170 | connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_slot() ) ); | 171 | connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_slot() ) ); |
171 | connect( browseAutoStButton, SIGNAL( clicked() ), this, SLOT( browseAutoStButton_slot() ) ); | 172 | connect( browseAutoStButton, SIGNAL( clicked() ), this, SLOT( browseAutoStButton_slot() ) ); |
172 | connect( selEntrFontButton, SIGNAL( clicked() ), this, SLOT( selEntrFontButton_slot() ) ); | 173 | connect( selEntrFontButton, SIGNAL( clicked() ), this, SLOT( selEntrFontButton_slot() ) ); |
173 | connect( trayCheckBox, SIGNAL( toggled(bool) ), autoMinimizeCheckBox, SLOT( setEnabled(bool) ) ); | 174 | connect( trayCheckBox, SIGNAL( toggled(bool) ), autoMinimizeCheckBox, SLOT( setEnabled(bool) ) ); |
174 | 175 | ||
175 | // tab order | 176 | // tab order |
176 | setTabOrder( pwTimeoutSpinBox, trayCheckBox ); | 177 | setTabOrder( pwTimeoutSpinBox, trayCheckBox ); |
177 | setTabOrder( trayCheckBox, okButton ); | 178 | setTabOrder( trayCheckBox, okButton ); |
178 | setTabOrder( okButton, cancelButton ); | 179 | setTabOrder( okButton, cancelButton ); |
179 | } | 180 | } |
180 | 181 | ||
181 | /* | 182 | /* |
182 | * Destroys the object and frees any allocated resources | 183 | * Destroys the object and frees any allocated resources |
183 | */ | 184 | */ |
184 | configWnd::~configWnd() | 185 | configWnd::~configWnd() |
185 | { | 186 | { |
186 | // no need to delete child widgets, Qt does it all for us | 187 | // no need to delete child widgets, Qt does it all for us |
187 | } | 188 | } |
188 | 189 | ||
189 | /* | 190 | /* |
190 | * Sets the strings of the subwidgets using the current | 191 | * Sets the strings of the subwidgets using the current |
191 | * language. | 192 | * language. |
192 | */ | 193 | */ |
193 | void configWnd::languageChange() | 194 | void configWnd::languageChange() |
194 | { | 195 | { |
195 | setCaption( tr( "PwManager Configuration" ) ); | 196 | setCaption( tr( "PwManager Configuration" ) ); |
196 | okButton->setText( tr( "&OK" ) ); | 197 | okButton->setText( tr( "&OK" ) ); |
197 | //US ENH okButton->setAccel( QKeySequence( tr( "Alt+O" ) ) ); | 198 | //US ENH okButton->setAccel( QKeySequence( tr( "Alt+O" ) ) ); |
198 | cancelButton->setText( tr( "&Cancel" ) ); | 199 | cancelButton->setText( tr( "&Cancel" ) ); |
199 | //US ENH cancelButton->setAccel( QKeySequence( tr( "Alt+C" ) ) ); | 200 | //US ENH cancelButton->setAccel( QKeySequence( tr( "Alt+C" ) ) ); |
200 | windowStyleComboBox->clear(); | 201 | windowStyleComboBox->clear(); |
201 | windowStyleComboBox->insertItem( tr( "Category on top" ) ); | 202 | windowStyleComboBox->insertItem( tr( "Category on top" ) ); |
202 | windowStyleComboBox->insertItem( tr( "Category-list left" ) ); | 203 | windowStyleComboBox->insertItem( tr( "Category-list left" ) ); |
203 | textLabel1_5->setText( tr( "Window-style:" ) ); | 204 | textLabel1_5->setText( tr( "Window-style:" ) ); |
204 | textLabel1_4->setText( tr( "Font for the password entries:" ) ); | 205 | textLabel1_4->setText( tr( "Font for the password entries:" ) ); |
205 | selEntrFontButton->setText( tr( "select Font" ) ); | 206 | selEntrFontButton->setText( tr( "select Font" ) ); |
206 | currEntrFont->setText( QString::null ); | 207 | currEntrFont->setText( QString::null ); |
207 | tabWidget2->changeTab( tab, tr( "Look && feel" ) ); | 208 | tabWidget2->changeTab( tab, tr( "Look && feel" ) ); |
208 | compressionComboBox->clear(); | 209 | compressionComboBox->clear(); |
209 | compressionComboBox->insertItem( tr( "none" ) ); | 210 | compressionComboBox->insertItem( tr( "none" ) ); |
210 | compressionComboBox->insertItem( tr( "gzip" ) ); | 211 | compressionComboBox->insertItem( tr( "gzip" ) ); |
211 | compressionComboBox->insertItem( tr( "bzip2" ) ); | 212 | compressionComboBox->insertItem( tr( "bzip2" ) ); |
212 | textLabel1_6->setText( tr( "*.pwm file compression:" ) ); | 213 | textLabel1_6->setText( tr( "*.pwm file compression:" ) ); |
213 | textLabel1_8->setText( tr( "permissions:" ) ); | 214 | textLabel1_8->setText( tr( "permissions:" ) ); |
214 | fileBackupCheckBox->setText( tr( "Make file backup before saving" ) ); | 215 | fileBackupCheckBox->setText( tr( "Make file backup before saving" ) ); |
215 | tabWidget2->changeTab( TabPage, tr( "File" ) ); | 216 | tabWidget2->changeTab( TabPage, tr( "File" ) ); |
216 | textLabel1->setText( tr( "Password timeout (timeout to hold password in memory, so you don't have to re-enter it, if you already have entered it) [set to 0 to disable]:" ) ); | 217 | textLabel1->setText( tr( "Password timeout (timeout to hold password in memory, so you don't have to re-enter it, if you already have entered it) [set to 0 to disable]:" ) ); |
217 | textLabel1_7->setText( tr( "Auto-lock timeout (auto lock document after this amount of seconds) [set to 0 to disable]:" ) ); | 218 | textLabel1_7->setText( tr( "Auto-lock timeout (auto lock document after this amount of seconds) [set to 0 to disable]:" ) ); |
218 | autoDeepLockCheckBox->setText( tr( "deep-lock on autolock" ) ); | 219 | autoDeepLockCheckBox->setText( tr( "deep-lock on autolock" ) ); |
219 | tabWidget2->changeTab( tab_2, tr( "Timeout" ) ); | 220 | tabWidget2->changeTab( tab_2, tr( "Timeout" ) ); |
220 | textLabel1_3->setText( tr( "Open this file automatically on startup:" ) ); | 221 | textLabel1_3->setText( tr( "Open this file automatically on startup:" ) ); |
221 | browseAutoStButton->setText( tr( "..." ) ); | 222 | browseAutoStButton->setText( tr( "..." ) ); |
222 | autostartDeeplockedCheckBox->setText( tr( "open deeplocked" ) ); | 223 | autostartDeeplockedCheckBox->setText( tr( "open deeplocked" ) ); |
223 | tabWidget2->changeTab( tab_3, tr( "Autostart" ) ); | 224 | tabWidget2->changeTab( tab_3, tr( "Autostart" ) ); |
224 | textLabel2->setText( tr( "Favourite browser:" ) ); | 225 | textLabel2->setText( tr( "Favourite browser:" ) ); |
225 | textLabel3->setText( tr( "Favourite X-terminal:" ) ); | 226 | textLabel3->setText( tr( "Favourite X-terminal:" ) ); |
226 | tabWidget2->changeTab( tab_4, tr( "External apps" ) ); | 227 | tabWidget2->changeTab( tab_4, tr( "External apps" ) ); |
227 | trayCheckBox->setText( tr( "Show icon in system-tray" ) ); | 228 | trayCheckBox->setText( tr( "Show icon in system-tray" ) ); |
228 | openUnlockedCheckBox->setText( tr( "Open document with passwords unlocked" ) ); | 229 | openUnlockedCheckBox->setText( tr( "Open document with passwords unlocked" ) ); |
229 | autoMinimizeCheckBox->setText( tr( "auto-minimize to tray on startup" ) ); | 230 | autoMinimizeCheckBox->setText( tr( "auto-minimize to tray on startup" ) ); |
230 | minimizeLockComboBox->clear(); | 231 | minimizeLockComboBox->clear(); |
231 | minimizeLockComboBox->insertItem( tr( "don't lock" ) ); | 232 | minimizeLockComboBox->insertItem( tr( "don't lock" ) ); |
232 | minimizeLockComboBox->insertItem( tr( "normal lock" ) ); | 233 | minimizeLockComboBox->insertItem( tr( "normal lock" ) ); |
233 | minimizeLockComboBox->insertItem( tr( "deep-lock" ) ); | 234 | minimizeLockComboBox->insertItem( tr( "deep-lock" ) ); |
234 | textLabel1_9->setText( tr( "auto-lock on minimize:" ) ); | 235 | textLabel1_9->setText( tr( "auto-lock on minimize:" ) ); |
235 | kwalletEmuCheckBox->setText( tr( "KWallet emulation" ) ); | 236 | kwalletEmuCheckBox->setText( tr( "KWallet emulation" ) ); |
236 | wndCloseCheckBox->setText( tr( "Do not minimize windows into tray. (Close the window)" ) ); | 237 | wndCloseCheckBox->setText( tr( "Do not minimize windows into tray. (Close the window)" ) ); |
237 | tabWidget2->changeTab( tab_5, tr( "Miscellaneous" ) ); | 238 | tabWidget2->changeTab( tab_5, tr( "Miscellaneous" ) ); |
238 | } | 239 | } |
239 | 240 | ||
240 | void configWnd::okButton_slot() | 241 | void configWnd::okButton_slot() |
241 | { | 242 | { |
242 | qWarning( "configWnd::okButton_slot(): Not implemented yet" ); | 243 | qWarning( "configWnd::okButton_slot(): Not implemented yet" ); |
243 | } | 244 | } |
244 | 245 | ||
245 | void configWnd::cancelButton_slot() | 246 | void configWnd::cancelButton_slot() |
246 | { | 247 | { |
247 | qWarning( "configWnd::cancelButton_slot(): Not implemented yet" ); | 248 | qWarning( "configWnd::cancelButton_slot(): Not implemented yet" ); |
248 | } | 249 | } |
249 | 250 | ||
250 | void configWnd::browseBgButton_slot() | 251 | void configWnd::browseBgButton_slot() |
251 | { | 252 | { |
252 | qWarning( "configWnd::browseBgButton_slot(): Not implemented yet" ); | 253 | qWarning( "configWnd::browseBgButton_slot(): Not implemented yet" ); |
253 | } | 254 | } |
254 | 255 | ||
255 | void configWnd::browseAutoStButton_slot() | 256 | void configWnd::browseAutoStButton_slot() |
256 | { | 257 | { |
257 | qWarning( "configWnd::browseAutoStButton_slot(): Not implemented yet" ); | 258 | qWarning( "configWnd::browseAutoStButton_slot(): Not implemented yet" ); |
258 | } | 259 | } |
259 | 260 | ||
260 | void configWnd::selEntrFontButton_slot() | 261 | void configWnd::selEntrFontButton_slot() |
261 | { | 262 | { |
262 | qWarning( "configWnd::selEntrFontButton_slot(): Not implemented yet" ); | 263 | qWarning( "configWnd::selEntrFontButton_slot(): Not implemented yet" ); |
263 | } | 264 | } |
264 | 265 | ||
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index e5579f8..08fcb25 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp | |||
@@ -1,1180 +1,1201 @@ | |||
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" | ||
32 | #include "configuration.h" | ||
31 | #else | 33 | #else |
32 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
33 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <pwmprefs.h> | ||
37 | #include <kpimglobalprefs.h> | ||
38 | #include <kcmconfigs/kcmpwmconfig.h> | ||
39 | #include <kcmconfigs/kcmkdepimconfig.h> | ||
40 | #include <kcmultidialog.h> | ||
34 | #endif | 41 | #endif |
35 | 42 | ||
36 | #include <qpixmap.h> | 43 | #include <qpixmap.h> |
37 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
38 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
39 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
40 | #include <qfileinfo.h> | 47 | #include <qfileinfo.h> |
41 | #include <qclipboard.h> | 48 | #include <qclipboard.h> |
42 | 49 | ||
43 | 50 | ||
44 | #include <stdio.h> | 51 | #include <stdio.h> |
45 | 52 | ||
46 | #include "pwm.h" | 53 | #include "pwm.h" |
47 | #include "pwminit.h" | 54 | #include "pwminit.h" |
48 | #include "configwndimpl.h" | ||
49 | #include "pwmprint.h" | 55 | #include "pwmprint.h" |
50 | #include "addentrywndimpl.h" | 56 | #include "addentrywndimpl.h" |
51 | #include "globalstuff.h" | 57 | #include "globalstuff.h" |
52 | #include "findwndimpl.h" | 58 | #include "findwndimpl.h" |
53 | #include "configuration.h" | ||
54 | 59 | ||
55 | #ifdef CONFIG_KWALLETIF | 60 | #ifdef CONFIG_KWALLETIF |
56 | # include "kwalletif.h" | 61 | # include "kwalletif.h" |
57 | # include "kwalletemu.h" | 62 | # include "kwalletemu.h" |
58 | #endif | 63 | #endif |
59 | #ifdef CONFIG_KEYCARD | 64 | #ifdef CONFIG_KEYCARD |
60 | # include "pwmkeycard.h" | 65 | # include "pwmkeycard.h" |
61 | #endif | 66 | #endif |
62 | 67 | ||
63 | 68 | ||
64 | #define DEFAULT_SIZE (QSize(700, 400)) | 69 | #define DEFAULT_SIZE (QSize(700, 400)) |
65 | 70 | ||
66 | // Button IDs for "file" popup menu | 71 | // Button IDs for "file" popup menu |
67 | enum { | 72 | enum { |
68 | BUTTON_POPUP_FILE_NEW = 0, | 73 | BUTTON_POPUP_FILE_NEW = 0, |
69 | BUTTON_POPUP_FILE_OPEN, | 74 | BUTTON_POPUP_FILE_OPEN, |
70 | BUTTON_POPUP_FILE_CLOSE, | 75 | BUTTON_POPUP_FILE_CLOSE, |
71 | BUTTON_POPUP_FILE_SAVE, | 76 | BUTTON_POPUP_FILE_SAVE, |
72 | BUTTON_POPUP_FILE_SAVEAS, | 77 | BUTTON_POPUP_FILE_SAVEAS, |
73 | BUTTON_POPUP_FILE_EXPORT, | 78 | BUTTON_POPUP_FILE_EXPORT, |
74 | BUTTON_POPUP_FILE_IMPORT, | 79 | BUTTON_POPUP_FILE_IMPORT, |
75 | BUTTON_POPUP_FILE_PRINT, | 80 | BUTTON_POPUP_FILE_PRINT, |
76 | BUTTON_POPUP_FILE_QUIT | 81 | BUTTON_POPUP_FILE_QUIT |
77 | }; | 82 | }; |
78 | // Button IDs for "manage" popup menu | 83 | // Button IDs for "manage" popup menu |
79 | enum { | 84 | enum { |
80 | BUTTON_POPUP_MANAGE_ADD = 0, | 85 | BUTTON_POPUP_MANAGE_ADD = 0, |
81 | BUTTON_POPUP_MANAGE_EDIT, | 86 | BUTTON_POPUP_MANAGE_EDIT, |
82 | BUTTON_POPUP_MANAGE_DEL, | 87 | BUTTON_POPUP_MANAGE_DEL, |
83 | BUTTON_POPUP_MANAGE_CHANGEMP | 88 | BUTTON_POPUP_MANAGE_CHANGEMP |
84 | }; | 89 | }; |
85 | // Button IDs for chipcard popup menu | 90 | // Button IDs for chipcard popup menu |
86 | enum { | 91 | enum { |
87 | #ifdef CONFIG_KEYCARD | 92 | #ifdef CONFIG_KEYCARD |
88 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, | 93 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, |
89 | BUTTON_POPUP_CHIPCARD_DEL, | 94 | BUTTON_POPUP_CHIPCARD_DEL, |
90 | BUTTON_POPUP_CHIPCARD_READID, | 95 | BUTTON_POPUP_CHIPCARD_READID, |
91 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, | 96 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, |
92 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP | 97 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP |
93 | #else // CONFIG_KEYCARD | 98 | #else // CONFIG_KEYCARD |
94 | BUTTON_POPUP_CHIPCARD_NO = 0 | 99 | BUTTON_POPUP_CHIPCARD_NO = 0 |
95 | #endif // CONFIG_KEYCARD | 100 | #endif // CONFIG_KEYCARD |
96 | }; | 101 | }; |
97 | // Button IDs for "view" popup menu | 102 | // Button IDs for "view" popup menu |
98 | enum { | 103 | enum { |
99 | BUTTON_POPUP_VIEW_FIND = 0, | 104 | BUTTON_POPUP_VIEW_FIND = 0, |
100 | BUTTON_POPUP_VIEW_LOCK, | 105 | BUTTON_POPUP_VIEW_LOCK, |
101 | BUTTON_POPUP_VIEW_DEEPLOCK, | 106 | BUTTON_POPUP_VIEW_DEEPLOCK, |
102 | BUTTON_POPUP_VIEW_UNLOCK | 107 | BUTTON_POPUP_VIEW_UNLOCK |
103 | }; | 108 | }; |
104 | // Button IDs for "options" popup menu | 109 | // Button IDs for "options" popup menu |
105 | enum { | 110 | enum { |
106 | BUTTON_POPUP_OPTIONS_CONFIG = 0 | 111 | BUTTON_POPUP_OPTIONS_CONFIG = 0 |
107 | }; | 112 | }; |
108 | // Button IDs for "export" popup menu (in "file" popup menu) | 113 | // Button IDs for "export" popup menu (in "file" popup menu) |
109 | enum { | 114 | enum { |
110 | BUTTON_POPUP_EXPORT_TEXT = 0, | 115 | BUTTON_POPUP_EXPORT_TEXT = 0, |
111 | BUTTON_POPUP_EXPORT_GPASMAN | 116 | BUTTON_POPUP_EXPORT_GPASMAN |
112 | #ifdef CONFIG_KWALLETIF | 117 | #ifdef CONFIG_KWALLETIF |
113 | ,BUTTON_POPUP_EXPORT_KWALLET | 118 | ,BUTTON_POPUP_EXPORT_KWALLET |
114 | #endif | 119 | #endif |
115 | }; | 120 | }; |
116 | // Button IDs for "import" popup menu (in "file" popup menu) | 121 | // Button IDs for "import" popup menu (in "file" popup menu) |
117 | enum { | 122 | enum { |
118 | BUTTON_POPUP_IMPORT_TEXT = 0, | 123 | BUTTON_POPUP_IMPORT_TEXT = 0, |
119 | BUTTON_POPUP_IMPORT_GPASMAN | 124 | BUTTON_POPUP_IMPORT_GPASMAN |
120 | #ifdef CONFIG_KWALLETIF | 125 | #ifdef CONFIG_KWALLETIF |
121 | ,BUTTON_POPUP_IMPORT_KWALLET | 126 | ,BUTTON_POPUP_IMPORT_KWALLET |
122 | #endif | 127 | #endif |
123 | }; | 128 | }; |
124 | 129 | ||
125 | #ifdef PWM_EMBEDDED | 130 | #ifdef PWM_EMBEDDED |
126 | // Button IDs for "help" popup menu | 131 | // Button IDs for "help" popup menu |
127 | enum { | 132 | enum { |
128 | BUTTON_POPUP_HELP_LICENSE = 0, | 133 | BUTTON_POPUP_HELP_LICENSE = 0, |
129 | BUTTON_POPUP_HELP_FAQ, | 134 | BUTTON_POPUP_HELP_FAQ, |
130 | BUTTON_POPUP_HELP_ABOUT | 135 | BUTTON_POPUP_HELP_ABOUT |
131 | }; | 136 | }; |
132 | #endif | 137 | #endif |
133 | 138 | ||
134 | // Button IDs for toolbar | 139 | // Button IDs for toolbar |
135 | enum { | 140 | enum { |
136 | BUTTON_TOOL_NEW = 0, | 141 | BUTTON_TOOL_NEW = 0, |
137 | BUTTON_TOOL_OPEN, | 142 | BUTTON_TOOL_OPEN, |
138 | BUTTON_TOOL_SAVE, | 143 | BUTTON_TOOL_SAVE, |
139 | BUTTON_TOOL_SAVEAS, | 144 | BUTTON_TOOL_SAVEAS, |
140 | BUTTON_TOOL_PRINT, | 145 | BUTTON_TOOL_PRINT, |
141 | BUTTON_TOOL_ADD, | 146 | BUTTON_TOOL_ADD, |
142 | BUTTON_TOOL_EDIT, | 147 | BUTTON_TOOL_EDIT, |
143 | BUTTON_TOOL_DEL, | 148 | BUTTON_TOOL_DEL, |
144 | BUTTON_TOOL_FIND, | 149 | BUTTON_TOOL_FIND, |
145 | BUTTON_TOOL_LOCK, | 150 | BUTTON_TOOL_LOCK, |
146 | BUTTON_TOOL_DEEPLOCK, | 151 | BUTTON_TOOL_DEEPLOCK, |
147 | BUTTON_TOOL_UNLOCK | 152 | BUTTON_TOOL_UNLOCK |
148 | }; | 153 | }; |
149 | 154 | ||
150 | 155 | ||
151 | PwM::PwM(PwMInit *_init, PwMDoc *doc, | 156 | PwM::PwM(PwMInit *_init, PwMDoc *doc, |
152 | bool virginity, | 157 | bool virginity, |
153 | QWidget *parent, const char *name) | 158 | QWidget *parent, const char *name) |
154 | : KMainWindow(parent, name) | 159 | : KMainWindow(parent, name) |
155 | , forceQuit (false) | 160 | , forceQuit (false) |
156 | , forceMinimizeToTray (false) | 161 | , forceMinimizeToTray (false) |
157 | { | 162 | { |
158 | init = _init; | 163 | init = _init; |
159 | connect(doc, SIGNAL(docClosed(PwMDoc *)), | 164 | connect(doc, SIGNAL(docClosed(PwMDoc *)), |
160 | this, SLOT(docClosed(PwMDoc *))); | 165 | this, SLOT(docClosed(PwMDoc *))); |
161 | initMenubar(); | 166 | initMenubar(); |
162 | initToolbar(); | 167 | initToolbar(); |
163 | initMetrics(); | 168 | initMetrics(); |
164 | setVirgin(virginity); | 169 | setVirgin(virginity); |
165 | setFocusPolicy(QWidget::WheelFocus); | 170 | setFocusPolicy(QWidget::WheelFocus); |
166 | #ifndef PWM_EMBEDDED | 171 | #ifndef PWM_EMBEDDED |
167 | statusBar()->show(); | 172 | statusBar()->show(); |
168 | #endif | 173 | #endif |
169 | view = makeNewListView(doc); | 174 | view = makeNewListView(doc); |
170 | setCentralWidget(view); | 175 | setCentralWidget(view); |
171 | updateCaption(); | 176 | updateCaption(); |
172 | showStatMsg(i18n("Ready.")); | 177 | showStatMsg(i18n("Ready.")); |
173 | } | 178 | } |
174 | 179 | ||
175 | PwM::~PwM() | 180 | PwM::~PwM() |
176 | { | 181 | { |
177 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), | 182 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), |
178 | this, SLOT(docClosed(PwMDoc *))); | 183 | this, SLOT(docClosed(PwMDoc *))); |
179 | conf()->confWndMainWndSize(size()); | 184 | conf()->confWndMainWndSize(size()); |
180 | emit closed(this); | 185 | emit closed(this); |
181 | delete view; | 186 | delete view; |
182 | } | 187 | } |
183 | 188 | ||
184 | void PwM::initMenubar() | 189 | void PwM::initMenubar() |
185 | { | 190 | { |
186 | KIconLoader* picons; | 191 | KIconLoader* picons; |
187 | #ifndef PWM_EMBEDDED | 192 | #ifndef PWM_EMBEDDED |
188 | KIconLoader icons; | 193 | KIconLoader icons; |
189 | picons = &icons; | 194 | picons = &icons; |
190 | #else | 195 | #else |
191 | picons = KGlobal::iconLoader(); | 196 | picons = KGlobal::iconLoader(); |
192 | #endif | 197 | #endif |
193 | filePopup = new KPopupMenu(this); | 198 | filePopup = new KPopupMenu(this); |
194 | importPopup = new KPopupMenu(filePopup); | 199 | importPopup = new KPopupMenu(filePopup); |
195 | exportPopup = new KPopupMenu(filePopup); | 200 | exportPopup = new KPopupMenu(filePopup); |
196 | managePopup = new KPopupMenu(this); | 201 | managePopup = new KPopupMenu(this); |
197 | #ifdef CONFIG_KEYCARD | 202 | #ifdef CONFIG_KEYCARD |
198 | chipcardPopup = new KPopupMenu(this); | 203 | chipcardPopup = new KPopupMenu(this); |
199 | #endif // CONFIG_KEYCARD | 204 | #endif // CONFIG_KEYCARD |
200 | viewPopup = new KPopupMenu(this); | 205 | viewPopup = new KPopupMenu(this); |
201 | optionsPopup = new KPopupMenu(this); | 206 | optionsPopup = new KPopupMenu(this); |
202 | 207 | ||
203 | // "file" popup menu | 208 | // "file" popup menu |
204 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 209 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
205 | i18n("&New"), this, | 210 | i18n("&New"), this, |
206 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); | 211 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); |
207 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), | 212 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), |
208 | i18n("&Open"), this, | 213 | i18n("&Open"), this, |
209 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); | 214 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); |
210 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), | 215 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), |
211 | i18n("&Close"), this, | 216 | i18n("&Close"), this, |
212 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); | 217 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); |
213 | filePopup->insertSeparator(); | 218 | filePopup->insertSeparator(); |
214 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), | 219 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), |
215 | i18n("&Save"), this, | 220 | i18n("&Save"), this, |
216 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); | 221 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); |
217 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), | 222 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), |
218 | i18n("Save &as..."), | 223 | i18n("Save &as..."), |
219 | this, SLOT(saveAs_slot()), 0, | 224 | this, SLOT(saveAs_slot()), 0, |
220 | BUTTON_POPUP_FILE_SAVEAS); | 225 | BUTTON_POPUP_FILE_SAVEAS); |
221 | filePopup->insertSeparator(); | 226 | filePopup->insertSeparator(); |
222 | // "file/export" popup menu | 227 | // "file/export" popup menu |
223 | exportPopup->insertItem(i18n("&Text-file..."), this, | 228 | exportPopup->insertItem(i18n("&Text-file..."), this, |
224 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); | 229 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); |
225 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 230 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
226 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); | 231 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); |
227 | #ifdef CONFIG_KWALLETIF | 232 | #ifdef CONFIG_KWALLETIF |
228 | exportPopup->insertItem(i18n("&KWallet..."), this, | 233 | exportPopup->insertItem(i18n("&KWallet..."), this, |
229 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); | 234 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); |
230 | #endif | 235 | #endif |
231 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), | 236 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), |
232 | i18n("E&xport"), exportPopup, | 237 | i18n("E&xport"), exportPopup, |
233 | BUTTON_POPUP_FILE_EXPORT); | 238 | BUTTON_POPUP_FILE_EXPORT); |
234 | // "file/import" popup menu | 239 | // "file/import" popup menu |
235 | importPopup->insertItem(i18n("&Text-file..."), this, | 240 | importPopup->insertItem(i18n("&Text-file..."), this, |
236 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); | 241 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); |
237 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 242 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
238 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); | 243 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); |
239 | #ifdef CONFIG_KWALLETIF | 244 | #ifdef CONFIG_KWALLETIF |
240 | importPopup->insertItem(i18n("&KWallet..."), this, | 245 | importPopup->insertItem(i18n("&KWallet..."), this, |
241 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); | 246 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); |
242 | #endif | 247 | #endif |
243 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), | 248 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), |
244 | i18n("I&mport"), importPopup, | 249 | i18n("I&mport"), importPopup, |
245 | BUTTON_POPUP_FILE_IMPORT); | 250 | BUTTON_POPUP_FILE_IMPORT); |
246 | filePopup->insertSeparator(); | 251 | filePopup->insertSeparator(); |
247 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), | 252 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), |
248 | i18n("&Print..."), this, | 253 | i18n("&Print..."), this, |
249 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); | 254 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); |
250 | filePopup->insertSeparator(); | 255 | filePopup->insertSeparator(); |
251 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), | 256 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), |
252 | i18n("&Quit"), this, | 257 | i18n("&Quit"), this, |
253 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); | 258 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); |
254 | menuBar()->insertItem(i18n("&File"), filePopup); | 259 | menuBar()->insertItem(i18n("&File"), filePopup); |
255 | // "manage" popup menu | 260 | // "manage" popup menu |
256 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), | 261 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), |
257 | i18n("&Add password"), this, | 262 | i18n("&Add password"), this, |
258 | SLOT(addPwd_slot()), 0, | 263 | SLOT(addPwd_slot()), 0, |
259 | BUTTON_POPUP_MANAGE_ADD); | 264 | BUTTON_POPUP_MANAGE_ADD); |
260 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), | 265 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), |
261 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, | 266 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, |
262 | BUTTON_POPUP_MANAGE_EDIT); | 267 | BUTTON_POPUP_MANAGE_EDIT); |
263 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 268 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
264 | i18n("&Delete"), this, SLOT(deletePwd_slot()), | 269 | i18n("&Delete"), this, SLOT(deletePwd_slot()), |
265 | 0, BUTTON_POPUP_MANAGE_DEL); | 270 | 0, BUTTON_POPUP_MANAGE_DEL); |
266 | managePopup->insertSeparator(); | 271 | managePopup->insertSeparator(); |
267 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), | 272 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), |
268 | i18n("Change &Master Password"), this, | 273 | i18n("Change &Master Password"), this, |
269 | SLOT(changeMasterPwd_slot()), 0, | 274 | SLOT(changeMasterPwd_slot()), 0, |
270 | BUTTON_POPUP_MANAGE_CHANGEMP); | 275 | BUTTON_POPUP_MANAGE_CHANGEMP); |
271 | menuBar()->insertItem(i18n("&Manage"), managePopup); | 276 | menuBar()->insertItem(i18n("&Manage"), managePopup); |
272 | // "chipcard" popup menu | 277 | // "chipcard" popup menu |
273 | #ifdef CONFIG_KEYCARD | 278 | #ifdef CONFIG_KEYCARD |
274 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 279 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
275 | i18n("&Generate new key-card"), this, | 280 | i18n("&Generate new key-card"), this, |
276 | SLOT(genNewCard_slot()), 0, | 281 | SLOT(genNewCard_slot()), 0, |
277 | BUTTON_POPUP_CHIPCARD_GENNEW); | 282 | BUTTON_POPUP_CHIPCARD_GENNEW); |
278 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 283 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
279 | i18n("&Erase key-card"), this, | 284 | i18n("&Erase key-card"), this, |
280 | SLOT(eraseCard_slot()), 0, | 285 | SLOT(eraseCard_slot()), 0, |
281 | BUTTON_POPUP_CHIPCARD_DEL); | 286 | BUTTON_POPUP_CHIPCARD_DEL); |
282 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), | 287 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), |
283 | i18n("Read card-&ID"), this, | 288 | i18n("Read card-&ID"), this, |
284 | SLOT(readCardId_slot()), 0, | 289 | SLOT(readCardId_slot()), 0, |
285 | BUTTON_POPUP_CHIPCARD_READID); | 290 | BUTTON_POPUP_CHIPCARD_READID); |
286 | chipcardPopup->insertSeparator(); | 291 | chipcardPopup->insertSeparator(); |
287 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), | 292 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), |
288 | i18n("&Make card backup-image"), this, | 293 | i18n("&Make card backup-image"), this, |
289 | SLOT(makeCardBackup_slot()), 0, | 294 | SLOT(makeCardBackup_slot()), 0, |
290 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); | 295 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); |
291 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), | 296 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), |
292 | i18n("&Replay card backup-image"), this, | 297 | i18n("&Replay card backup-image"), this, |
293 | SLOT(replayCardBackup_slot()), 0, | 298 | SLOT(replayCardBackup_slot()), 0, |
294 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); | 299 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); |
295 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); | 300 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); |
296 | #endif // CONFIG_KEYCARD | 301 | #endif // CONFIG_KEYCARD |
297 | // "view" popup menu | 302 | // "view" popup menu |
298 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), | 303 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), |
299 | i18n("&Find"), this, | 304 | i18n("&Find"), this, |
300 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); | 305 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); |
301 | viewPopup->insertSeparator(); | 306 | viewPopup->insertSeparator(); |
302 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), | 307 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), |
303 | i18n("&Lock all entries"), this, | 308 | i18n("&Lock all entries"), this, |
304 | SLOT(lockWnd_slot()), 0, | 309 | SLOT(lockWnd_slot()), 0, |
305 | BUTTON_POPUP_VIEW_LOCK); | 310 | BUTTON_POPUP_VIEW_LOCK); |
306 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), | 311 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), |
307 | i18n("&Deep-lock all entries"), this, | 312 | i18n("&Deep-lock all entries"), this, |
308 | SLOT(deepLockWnd_slot()), 0, | 313 | SLOT(deepLockWnd_slot()), 0, |
309 | BUTTON_POPUP_VIEW_DEEPLOCK); | 314 | BUTTON_POPUP_VIEW_DEEPLOCK); |
310 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), | 315 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), |
311 | i18n("&Unlock all entries"), this, | 316 | i18n("&Unlock all entries"), this, |
312 | SLOT(unlockWnd_slot()), 0, | 317 | SLOT(unlockWnd_slot()), 0, |
313 | BUTTON_POPUP_VIEW_UNLOCK); | 318 | BUTTON_POPUP_VIEW_UNLOCK); |
314 | menuBar()->insertItem(i18n("&View"), viewPopup); | 319 | menuBar()->insertItem(i18n("&View"), viewPopup); |
315 | // "options" popup menu | 320 | // "options" popup menu |
316 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), | 321 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), |
317 | i18n("&Configure..."), this, | 322 | i18n("&Configure..."), this, |
318 | SLOT(config_slot()), | 323 | SLOT(config_slot()), |
319 | BUTTON_POPUP_OPTIONS_CONFIG); | 324 | BUTTON_POPUP_OPTIONS_CONFIG); |
320 | menuBar()->insertItem(i18n("&Options"), optionsPopup); | 325 | menuBar()->insertItem(i18n("&Options"), optionsPopup); |
321 | // "help" popup menu | 326 | // "help" popup menu |
322 | #ifndef PWM_EMBEDDED | 327 | #ifndef PWM_EMBEDDED |
323 | helpPopup = helpMenu(QString::null, false); | 328 | helpPopup = helpMenu(QString::null, false); |
324 | #else | 329 | #else |
325 | helpPopup = new KPopupMenu(this); | 330 | helpPopup = new KPopupMenu(this); |
326 | 331 | ||
327 | 332 | ||
328 | helpPopup->insertItem(i18n("&License"), this, | 333 | helpPopup->insertItem(i18n("&License"), this, |
329 | SLOT(showLicense_slot()), 0, | 334 | SLOT(showLicense_slot()), 0, |
330 | BUTTON_POPUP_HELP_LICENSE); | 335 | BUTTON_POPUP_HELP_LICENSE); |
331 | 336 | ||
332 | helpPopup->insertItem(i18n("&Faq"), this, | 337 | helpPopup->insertItem(i18n("&Faq"), this, |
333 | SLOT(faq_slot()), 0, | 338 | SLOT(faq_slot()), 0, |
334 | BUTTON_POPUP_HELP_FAQ); | 339 | BUTTON_POPUP_HELP_FAQ); |
335 | 340 | ||
336 | helpPopup->insertItem(i18n("&About PwManager"), this, | 341 | helpPopup->insertItem(i18n("&About PwManager"), this, |
337 | SLOT(createAboutData_slot()), 0, | 342 | SLOT(createAboutData_slot()), 0, |
338 | BUTTON_POPUP_HELP_ABOUT); | 343 | BUTTON_POPUP_HELP_ABOUT); |
339 | 344 | ||
340 | #endif | 345 | #endif |
341 | menuBar()->insertItem(i18n("&Help"), helpPopup); | 346 | menuBar()->insertItem(i18n("&Help"), helpPopup); |
342 | 347 | ||
343 | } | 348 | } |
344 | 349 | ||
345 | void PwM::initToolbar() | 350 | void PwM::initToolbar() |
346 | { | 351 | { |
347 | KIconLoader* picons; | 352 | KIconLoader* picons; |
348 | #ifndef PWM_EMBEDDED | 353 | #ifndef PWM_EMBEDDED |
349 | KIconLoader icons; | 354 | KIconLoader icons; |
350 | picons = &icons; | 355 | picons = &icons; |
351 | #else | 356 | #else |
352 | picons = KGlobal::iconLoader(); | 357 | picons = KGlobal::iconLoader(); |
353 | #endif | 358 | #endif |
354 | 359 | ||
355 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), | 360 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), |
356 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, | 361 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, |
357 | SLOT(new_slot()), true, i18n("New")); | 362 | SLOT(new_slot()), true, i18n("New")); |
358 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), | 363 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), |
359 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, | 364 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, |
360 | SLOT(open_slot()), true, i18n("Open")); | 365 | SLOT(open_slot()), true, i18n("Open")); |
361 | toolBar()->insertSeparator(); | 366 | toolBar()->insertSeparator(); |
362 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), | 367 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), |
363 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, | 368 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, |
364 | SLOT(save_slot()), true, i18n("Save")); | 369 | SLOT(save_slot()), true, i18n("Save")); |
365 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), | 370 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), |
366 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, | 371 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, |
367 | SLOT(saveAs_slot()), true, i18n("Save as")); | 372 | SLOT(saveAs_slot()), true, i18n("Save as")); |
368 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), | 373 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), |
369 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, | 374 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, |
370 | SLOT(print_slot()), true, i18n("Print...")); | 375 | SLOT(print_slot()), true, i18n("Print...")); |
371 | toolBar()->insertSeparator(); | 376 | toolBar()->insertSeparator(); |
372 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), | 377 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), |
373 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, | 378 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, |
374 | SLOT(addPwd_slot()), true, | 379 | SLOT(addPwd_slot()), true, |
375 | i18n("Add password")); | 380 | i18n("Add password")); |
376 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), | 381 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), |
377 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, | 382 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, |
378 | SLOT(editPwd_slot()), true, | 383 | SLOT(editPwd_slot()), true, |
379 | i18n("Edit password")); | 384 | i18n("Edit password")); |
380 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), | 385 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), |
381 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, | 386 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, |
382 | SLOT(deletePwd_slot()), true, | 387 | SLOT(deletePwd_slot()), true, |
383 | i18n("Delete password")); | 388 | i18n("Delete password")); |
384 | toolBar()->insertSeparator(); | 389 | toolBar()->insertSeparator(); |
385 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), | 390 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), |
386 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, | 391 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, |
387 | SLOT(find_slot()), true, i18n("Find entry")); | 392 | SLOT(find_slot()), true, i18n("Find entry")); |
388 | toolBar()->insertSeparator(); | 393 | toolBar()->insertSeparator(); |
389 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), | 394 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), |
390 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, | 395 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, |
391 | SLOT(lockWnd_slot()), true, | 396 | SLOT(lockWnd_slot()), true, |
392 | i18n("Lock all entries")); | 397 | i18n("Lock all entries")); |
393 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), | 398 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), |
394 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, | 399 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, |
395 | SLOT(deepLockWnd_slot()), true, | 400 | SLOT(deepLockWnd_slot()), true, |
396 | i18n("Deep-Lock all entries")); | 401 | i18n("Deep-Lock all entries")); |
397 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), | 402 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), |
398 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, | 403 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, |
399 | SLOT(unlockWnd_slot()), true, | 404 | SLOT(unlockWnd_slot()), true, |
400 | i18n("Unlock all entries")); | 405 | i18n("Unlock all entries")); |
401 | } | 406 | } |
402 | 407 | ||
403 | void PwM::initMetrics() | 408 | void PwM::initMetrics() |
404 | { | 409 | { |
405 | QSize s = conf()->confWndMainWndSize(); | 410 | QSize s = conf()->confWndMainWndSize(); |
406 | if (s.isValid()) | 411 | if (s.isValid()) |
407 | resize(s); | 412 | resize(s); |
408 | else | 413 | else |
409 | resize(DEFAULT_SIZE); | 414 | resize(DEFAULT_SIZE); |
410 | } | 415 | } |
411 | 416 | ||
412 | void PwM::updateCaption() | 417 | void PwM::updateCaption() |
413 | { | 418 | { |
414 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); | 419 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); |
415 | } | 420 | } |
416 | 421 | ||
417 | void PwM::hideEvent(QHideEvent *) | 422 | void PwM::hideEvent(QHideEvent *) |
418 | { | 423 | { |
419 | if (isMinimized()) { | 424 | if (isMinimized()) { |
420 | if (init->tray()) { | 425 | if (init->tray()) { |
421 | forceMinimizeToTray = true; | 426 | forceMinimizeToTray = true; |
422 | close(); | 427 | close(); |
423 | } | 428 | } |
424 | int mmlock = conf()->confGlobMinimizeLock(); | 429 | int mmlock = conf()->confGlobMinimizeLock(); |
425 | switch (mmlock) { | 430 | switch (mmlock) { |
426 | case 0: // don't lock anything | 431 | case 0: // don't lock anything |
427 | break; | 432 | break; |
428 | case 1: {// normal lock | 433 | case 1: {// normal lock |
429 | curDoc()->lockAll(true); | 434 | curDoc()->lockAll(true); |
430 | break; | 435 | break; |
431 | } case 2: {// deep-lock | 436 | } case 2: {// deep-lock |
432 | curDoc()->deepLock(); | 437 | curDoc()->deepLock(); |
433 | break; | 438 | break; |
434 | } default: | 439 | } default: |
435 | WARN(); | 440 | WARN(); |
436 | } | 441 | } |
437 | } | 442 | } |
438 | } | 443 | } |
439 | 444 | ||
440 | void PwM::setVirgin(bool v) | 445 | void PwM::setVirgin(bool v) |
441 | { | 446 | { |
442 | if (virgin == v) | 447 | if (virgin == v) |
443 | return; | 448 | return; |
444 | virgin = v; | 449 | virgin = v; |
445 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); | 450 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); |
446 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); | 451 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); |
447 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); | 452 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); |
448 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); | 453 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); |
449 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); | 454 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); |
450 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); | 455 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); |
451 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); | 456 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); |
452 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); | 457 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); |
453 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); | 458 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); |
454 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); | 459 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); |
455 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); | 460 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); |
456 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); | 461 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); |
457 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); | 462 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); |
458 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); | 463 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); |
459 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); | 464 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); |
460 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); | 465 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); |
461 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); | 466 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); |
462 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); | 467 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); |
463 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); | 468 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); |
464 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); | 469 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); |
465 | } | 470 | } |
466 | 471 | ||
467 | void PwM::new_slot() | 472 | void PwM::new_slot() |
468 | { | 473 | { |
469 | init->createMainWnd(); | 474 | init->createMainWnd(); |
470 | } | 475 | } |
471 | 476 | ||
472 | //US ENH | 477 | //US ENH |
473 | void PwM::open_slot() | 478 | void PwM::open_slot() |
474 | { | 479 | { |
475 | open_slot(""); | 480 | open_slot(""); |
476 | } | 481 | } |
477 | 482 | ||
478 | void PwM::open_slot(QString fn) | 483 | void PwM::open_slot(QString fn) |
479 | { | 484 | { |
480 | openDoc(fn); | 485 | openDoc(fn); |
481 | } | 486 | } |
482 | 487 | ||
483 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) | 488 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) |
484 | { | 489 | { |
485 | if (!isVirgin()) { | 490 | if (!isVirgin()) { |
486 | // open the document in a new window. | 491 | // open the document in a new window. |
487 | PwM *newInstance = init->createMainWnd(); | 492 | PwM *newInstance = init->createMainWnd(); |
488 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); | 493 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); |
489 | if (!newDoc) { | 494 | if (!newDoc) { |
490 | newInstance->setForceQuit(true); | 495 | newInstance->setForceQuit(true); |
491 | delete_and_null(newInstance); | 496 | delete_and_null(newInstance); |
492 | } | 497 | } |
493 | return newDoc; | 498 | return newDoc; |
494 | } | 499 | } |
495 | 500 | ||
496 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) | 501 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) |
497 | return 0; | 502 | return 0; |
498 | showStatMsg(i18n("Successfully opened file.")); | 503 | showStatMsg(i18n("Successfully opened file.")); |
499 | updateCaption(); | 504 | updateCaption(); |
500 | setVirgin(false); | 505 | setVirgin(false); |
501 | return curDoc(); | 506 | return curDoc(); |
502 | } | 507 | } |
503 | 508 | ||
504 | PwMView * PwM::makeNewListView(PwMDoc *doc) | 509 | PwMView * PwM::makeNewListView(PwMDoc *doc) |
505 | { | 510 | { |
506 | PwMView *ret = new PwMView(this, this, doc); | 511 | PwMView *ret = new PwMView(this, this, doc); |
507 | ret->setFont(conf()->confGlobEntryFont()); | 512 | ret->setFont(conf()->confGlobEntryFont()); |
508 | ret->show(); | 513 | ret->show(); |
509 | return ret; | 514 | return ret; |
510 | } | 515 | } |
511 | 516 | ||
512 | void PwM::close_slot() | 517 | void PwM::close_slot() |
513 | { | 518 | { |
514 | close(); | 519 | close(); |
515 | } | 520 | } |
516 | 521 | ||
517 | void PwM::quitButton_slot() | 522 | void PwM::quitButton_slot() |
518 | { | 523 | { |
519 | init->shutdownApp(0); | 524 | init->shutdownApp(0); |
520 | } | 525 | } |
521 | 526 | ||
522 | void PwM::save_slot() | 527 | void PwM::save_slot() |
523 | { | 528 | { |
524 | save(); | 529 | save(); |
525 | } | 530 | } |
526 | 531 | ||
527 | bool PwM::save() | 532 | bool PwM::save() |
528 | { | 533 | { |
529 | if (!curDoc()->saveDocUi(curDoc())) | 534 | if (!curDoc()->saveDocUi(curDoc())) |
530 | return false; | 535 | return false; |
531 | showStatMsg(i18n("Successfully saved data.")); | 536 | showStatMsg(i18n("Successfully saved data.")); |
532 | updateCaption(); | 537 | updateCaption(); |
533 | return true; | 538 | return true; |
534 | } | 539 | } |
535 | 540 | ||
536 | void PwM::saveAs_slot() | 541 | void PwM::saveAs_slot() |
537 | { | 542 | { |
538 | saveAs(); | 543 | saveAs(); |
539 | } | 544 | } |
540 | 545 | ||
541 | bool PwM::saveAs() | 546 | bool PwM::saveAs() |
542 | { | 547 | { |
543 | if (!curDoc()->saveAsDocUi(curDoc())) | 548 | if (!curDoc()->saveAsDocUi(curDoc())) |
544 | return false; | 549 | return false; |
545 | showStatMsg(i18n("Successfully saved data.")); | 550 | showStatMsg(i18n("Successfully saved data.")); |
546 | updateCaption(); | 551 | updateCaption(); |
547 | return true; | 552 | return true; |
548 | } | 553 | } |
549 | 554 | ||
550 | //US ENH : changed code to run with older MOC | 555 | //US ENH : changed code to run with older MOC |
551 | void PwM::addPwd_slot() | 556 | void PwM::addPwd_slot() |
552 | { | 557 | { |
553 | addPwd_slot(0, 0); | 558 | addPwd_slot(0, 0); |
554 | } | 559 | } |
555 | 560 | ||
556 | void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) | 561 | void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) |
557 | { | 562 | { |
558 | PwMDoc *doc; | 563 | PwMDoc *doc; |
559 | if (_doc) { | 564 | if (_doc) { |
560 | doc = _doc; | 565 | doc = _doc; |
561 | } else { | 566 | } else { |
562 | doc = curDoc(); | 567 | doc = curDoc(); |
563 | } | 568 | } |
564 | PWM_ASSERT(doc); | 569 | PWM_ASSERT(doc); |
565 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 570 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
566 | AddEntryWndImpl w; | 571 | AddEntryWndImpl w; |
567 | vector<string> catList; | 572 | vector<string> catList; |
568 | doc->getCategoryList(&catList); | 573 | doc->getCategoryList(&catList); |
569 | unsigned i, size = catList.size(); | 574 | unsigned i, size = catList.size(); |
570 | for (i = 0; i < size; ++i) { | 575 | for (i = 0; i < size; ++i) { |
571 | w.addCategory(catList[i].c_str()); | 576 | w.addCategory(catList[i].c_str()); |
572 | } | 577 | } |
573 | w.setCurrCategory(view->getCurrentCategory()); | 578 | w.setCurrCategory(view->getCurrentCategory()); |
574 | if (pw) | 579 | if (pw) |
575 | w.pwLineEdit->setText(*pw); | 580 | w.pwLineEdit->setText(*pw); |
576 | 581 | ||
577 | tryAgain: | 582 | tryAgain: |
578 | if (w.exec() == 1) | 583 | if (w.exec() == 1) |
579 | { | 584 | { |
580 | PwMDataItem d; | 585 | PwMDataItem d; |
581 | d.desc = w.getDescription().latin1(); | 586 | d.desc = w.getDescription().latin1(); |
582 | d.name = w.getUsername().latin1(); | 587 | d.name = w.getUsername().latin1(); |
583 | d.pw = w.getPassword().latin1(); | 588 | d.pw = w.getPassword().latin1(); |
584 | d.comment = w.getComment().latin1(); | 589 | d.comment = w.getComment().latin1(); |
585 | d.url = w.getUrl().latin1(); | 590 | d.url = w.getUrl().latin1(); |
586 | d.launcher = w.getLauncher().latin1(); | 591 | d.launcher = w.getLauncher().latin1(); |
587 | PwMerror ret = doc->addEntry(w.getCategory(), &d); | 592 | PwMerror ret = doc->addEntry(w.getCategory(), &d); |
588 | if (ret == e_entryExists) { | 593 | if (ret == e_entryExists) { |
589 | KMessageBox::error(this, | 594 | KMessageBox::error(this, |
590 | i18n | 595 | i18n |
591 | ("An entry with this \"Description\", " | 596 | ("An entry with this \"Description\", " |
592 | "does already exist.\n" | 597 | "does already exist.\n" |
593 | "Please select another description."), | 598 | "Please select another description."), |
594 | i18n("entry already exists.")); | 599 | i18n("entry already exists.")); |
595 | goto tryAgain; | 600 | goto tryAgain; |
596 | } else if (ret == e_maxAllowedEntr) { | 601 | } else if (ret == e_maxAllowedEntr) { |
597 | KMessageBox::error(this, i18n("The maximum possible number of entries " | 602 | KMessageBox::error(this, i18n("The maximum possible number of entries " |
598 | "has been reached. You can't add more entries."), | 603 | "has been reached. You can't add more entries."), |
599 | i18n("maximum number of entries")); | 604 | i18n("maximum number of entries")); |
600 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 605 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
601 | return; | 606 | return; |
602 | } | 607 | } |
603 | } | 608 | } |
604 | setVirgin(false); | 609 | setVirgin(false); |
605 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 610 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
606 | } | 611 | } |
607 | 612 | ||
608 | //US ENH : changed code to run with older MOC | 613 | //US ENH : changed code to run with older MOC |
609 | void PwM::editPwd_slot() | 614 | void PwM::editPwd_slot() |
610 | { | 615 | { |
611 | editPwd_slot(0,0,0); | 616 | editPwd_slot(0,0,0); |
612 | } | 617 | } |
613 | 618 | ||
614 | void PwM::editPwd_slot(const QString *category) | 619 | void PwM::editPwd_slot(const QString *category) |
615 | { | 620 | { |
616 | editPwd_slot(category, 0, 0); | 621 | editPwd_slot(category, 0, 0); |
617 | } | 622 | } |
618 | 623 | ||
619 | void PwM::editPwd_slot(const QString *category, const int *index, | 624 | void PwM::editPwd_slot(const QString *category, const int *index, |
620 | PwMDoc *_doc) | 625 | PwMDoc *_doc) |
621 | { | 626 | { |
622 | PwMDoc *doc; | 627 | PwMDoc *doc; |
623 | if (_doc) { | 628 | if (_doc) { |
624 | doc = _doc; | 629 | doc = _doc; |
625 | } else { | 630 | } else { |
626 | doc = curDoc(); | 631 | doc = curDoc(); |
627 | } | 632 | } |
628 | PWM_ASSERT(doc); | 633 | PWM_ASSERT(doc); |
629 | if (doc->isDocEmpty()) | 634 | if (doc->isDocEmpty()) |
630 | return; | 635 | return; |
631 | if (doc->isDeepLocked()) | 636 | if (doc->isDeepLocked()) |
632 | return; | 637 | return; |
633 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 638 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
634 | unsigned int curEntryIndex; | 639 | unsigned int curEntryIndex; |
635 | if (index) { | 640 | if (index) { |
636 | curEntryIndex = *index; | 641 | curEntryIndex = *index; |
637 | } else { | 642 | } else { |
638 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 643 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
639 | printDebug("couldn't get index. Maybe we have a binary entry here."); | 644 | printDebug("couldn't get index. Maybe we have a binary entry here."); |
640 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 645 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
641 | return; | 646 | return; |
642 | } | 647 | } |
643 | } | 648 | } |
644 | QString curCategory; | 649 | QString curCategory; |
645 | if (category) { | 650 | if (category) { |
646 | curCategory = *category; | 651 | curCategory = *category; |
647 | } else { | 652 | } else { |
648 | curCategory = view->getCurrentCategory(); | 653 | curCategory = view->getCurrentCategory(); |
649 | } | 654 | } |
650 | PwMDataItem currItem; | 655 | PwMDataItem currItem; |
651 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { | 656 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { |
652 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 657 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
653 | return; | 658 | return; |
654 | } | 659 | } |
655 | BUG_ON(currItem.binary); | 660 | BUG_ON(currItem.binary); |
656 | 661 | ||
657 | AddEntryWndImpl w; | 662 | AddEntryWndImpl w; |
658 | vector<string> catList; | 663 | vector<string> catList; |
659 | doc->getCategoryList(&catList); | 664 | doc->getCategoryList(&catList); |
660 | unsigned i, size = catList.size(); | 665 | unsigned i, size = catList.size(); |
661 | for (i = 0; i < size; ++i) { | 666 | for (i = 0; i < size; ++i) { |
662 | w.addCategory(catList[i].c_str()); | 667 | w.addCategory(catList[i].c_str()); |
663 | } | 668 | } |
664 | w.setCurrCategory(curCategory); | 669 | w.setCurrCategory(curCategory); |
665 | w.setDescription(currItem.desc.c_str()); | 670 | w.setDescription(currItem.desc.c_str()); |
666 | w.setUsername(currItem.name.c_str()); | 671 | w.setUsername(currItem.name.c_str()); |
667 | w.setPassword(currItem.pw.c_str()); | 672 | w.setPassword(currItem.pw.c_str()); |
668 | w.setUrl(currItem.url.c_str()); | 673 | w.setUrl(currItem.url.c_str()); |
669 | w.setLauncher(currItem.launcher.c_str()); | 674 | w.setLauncher(currItem.launcher.c_str()); |
670 | w.setComment(currItem.comment.c_str()); | 675 | w.setComment(currItem.comment.c_str()); |
671 | if (w.exec() == 1) { | 676 | if (w.exec() == 1) { |
672 | currItem.desc = w.getDescription().latin1(); | 677 | currItem.desc = w.getDescription().latin1(); |
673 | currItem.name = w.getUsername().latin1(); | 678 | currItem.name = w.getUsername().latin1(); |
674 | currItem.pw = w.getPassword().latin1(); | 679 | currItem.pw = w.getPassword().latin1(); |
675 | currItem.comment = w.getComment().latin1(); | 680 | currItem.comment = w.getComment().latin1(); |
676 | currItem.url = w.getUrl().latin1(); | 681 | currItem.url = w.getUrl().latin1(); |
677 | currItem.launcher = w.getLauncher().latin1(); | 682 | currItem.launcher = w.getLauncher().latin1(); |
678 | if (!doc->editEntry(curCategory, w.getCategory(), | 683 | if (!doc->editEntry(curCategory, w.getCategory(), |
679 | curEntryIndex, &currItem)) { | 684 | curEntryIndex, &currItem)) { |
680 | KMessageBox::error(this, | 685 | KMessageBox::error(this, |
681 | i18n("Couldn't edit the entry.\n" | 686 | i18n("Couldn't edit the entry.\n" |
682 | "Maybe you changed the category and " | 687 | "Maybe you changed the category and " |
683 | "this entry is already present in the new " | 688 | "this entry is already present in the new " |
684 | "category?"), | 689 | "category?"), |
685 | i18n("couldn't edit entry.")); | 690 | i18n("couldn't edit entry.")); |
686 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 691 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
687 | return; | 692 | return; |
688 | } | 693 | } |
689 | } | 694 | } |
690 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 695 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
691 | } | 696 | } |
692 | 697 | ||
693 | void PwM::deletePwd_slot() | 698 | void PwM::deletePwd_slot() |
694 | { | 699 | { |
695 | PWM_ASSERT(curDoc()); | 700 | PWM_ASSERT(curDoc()); |
696 | if (curDoc()->isDocEmpty()) | 701 | if (curDoc()->isDocEmpty()) |
697 | return; | 702 | return; |
698 | if (curDoc()->isDeepLocked()) | 703 | if (curDoc()->isDeepLocked()) |
699 | return; | 704 | return; |
700 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 705 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
701 | unsigned int curEntryIndex = 0; | 706 | unsigned int curEntryIndex = 0; |
702 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 707 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
703 | printDebug("couldn't get index"); | 708 | printDebug("couldn't get index"); |
704 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 709 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
705 | return; | 710 | return; |
706 | } | 711 | } |
707 | 712 | ||
708 | PwMDataItem currItem; | 713 | PwMDataItem currItem; |
709 | QString curCategory = view->getCurrentCategory(); | 714 | QString curCategory = view->getCurrentCategory(); |
710 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { | 715 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { |
711 | printDebug("couldn't get entry"); | 716 | printDebug("couldn't get entry"); |
712 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 717 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
713 | return; | 718 | return; |
714 | } | 719 | } |
715 | if (KMessageBox:: | 720 | if (KMessageBox:: |
716 | questionYesNo(this, | 721 | questionYesNo(this, |
717 | i18n | 722 | i18n |
718 | ("Do you really want to delete the selected entry") + | 723 | ("Do you really want to delete the selected entry") + |
719 | " \"" + QString(currItem.desc.c_str()) | 724 | " \"" + QString(currItem.desc.c_str()) |
720 | + "\" ?", i18n("delete?")) | 725 | + "\" ?", i18n("delete?")) |
721 | == KMessageBox::Yes) { | 726 | == KMessageBox::Yes) { |
722 | 727 | ||
723 | curDoc()->delEntry(curCategory, curEntryIndex); | 728 | curDoc()->delEntry(curCategory, curEntryIndex); |
724 | } | 729 | } |
725 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 730 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
726 | } | 731 | } |
727 | 732 | ||
728 | void PwM::changeMasterPwd_slot() | 733 | void PwM::changeMasterPwd_slot() |
729 | { | 734 | { |
730 | PWM_ASSERT(curDoc()); | 735 | PWM_ASSERT(curDoc()); |
731 | curDoc()->changeCurrentPw(); | 736 | curDoc()->changeCurrentPw(); |
732 | } | 737 | } |
733 | 738 | ||
734 | void PwM::lockWnd_slot() | 739 | void PwM::lockWnd_slot() |
735 | { | 740 | { |
736 | PWM_ASSERT(curDoc()); | 741 | PWM_ASSERT(curDoc()); |
737 | curDoc()->lockAll(true); | 742 | curDoc()->lockAll(true); |
738 | } | 743 | } |
739 | 744 | ||
740 | void PwM::deepLockWnd_slot() | 745 | void PwM::deepLockWnd_slot() |
741 | { | 746 | { |
742 | PWM_ASSERT(curDoc()); | 747 | PWM_ASSERT(curDoc()); |
743 | curDoc()->deepLock(); | 748 | curDoc()->deepLock(); |
744 | } | 749 | } |
745 | 750 | ||
746 | void PwM::unlockWnd_slot() | 751 | void PwM::unlockWnd_slot() |
747 | { | 752 | { |
748 | PWM_ASSERT(curDoc()); | 753 | PWM_ASSERT(curDoc()); |
749 | curDoc()->lockAll(false); | 754 | curDoc()->lockAll(false); |
750 | } | 755 | } |
751 | 756 | ||
752 | void PwM::config_slot() | 757 | void PwM::config_slot() |
753 | { | 758 | { |
754 | Configuration *conf = Configuration::obj(); | 759 | int oldStyle = conf()->confWndMainViewStyle(); |
755 | int oldStyle = conf->confWndMainViewStyle(); | 760 | #ifdef PWM_EMBEDDED |
761 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); | ||
762 | |||
763 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); | ||
764 | ConfigureDialog->addModule(pwmcfg ); | ||
756 | 765 | ||
766 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | ||
767 | ConfigureDialog->addModule(kdelibcfg ); | ||
768 | |||
769 | #ifndef DESKTOP_VERSION | ||
770 | ConfigureDialog->showMaximized(); | ||
771 | #endif | ||
772 | if ( ConfigureDialog->exec() ) | ||
773 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | ||
774 | delete ConfigureDialog; | ||
775 | |||
776 | #else //PWM_EMBEDDED | ||
757 | // display the configuration window (modal mode) | 777 | // display the configuration window (modal mode) |
758 | if (!conf->showConfWnd(this)) | 778 | if (!conf()->showConfWnd(this)) |
759 | return; | 779 | return; |
780 | #endif | ||
760 | 781 | ||
761 | int newStyle = conf->confWndMainViewStyle(); | 782 | int newStyle = conf()->confWndMainViewStyle(); |
762 | // reinitialize tray | 783 | // reinitialize tray |
763 | init->initTray(); | 784 | init->initTray(); |
764 | // reinitialize KWallet emulation | 785 | // reinitialize KWallet emulation |
765 | init->initKWalletEmu(); | 786 | init->initKWalletEmu(); |
766 | 787 | ||
767 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 788 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
768 | const vector<PwMDocList::listItem> *dl = _dl->getList(); | 789 | const vector<PwMDocList::listItem> *dl = _dl->getList(); |
769 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 790 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
770 | end = dl->end(); | 791 | end = dl->end(); |
771 | PwMDoc *doc; | 792 | PwMDoc *doc; |
772 | while (i != end) { | 793 | while (i != end) { |
773 | doc = (*i).doc; | 794 | doc = (*i).doc; |
774 | // unlock-without-mpw timeout | 795 | // unlock-without-mpw timeout |
775 | doc->timer()->start(DocTimer::id_mpwTimer); | 796 | doc->timer()->start(DocTimer::id_mpwTimer); |
776 | // auto-lock timeout | 797 | // auto-lock timeout |
777 | doc->timer()->start(DocTimer::id_autoLockTimer); | 798 | doc->timer()->start(DocTimer::id_autoLockTimer); |
778 | ++i; | 799 | ++i; |
779 | } | 800 | } |
780 | 801 | ||
781 | const QValueList<PwM *> *ml = init->mainWndList(); | 802 | const QValueList<PwM *> *ml = init->mainWndList(); |
782 | #ifndef PWM_EMBEDDED | 803 | #ifndef PWM_EMBEDDED |
783 | QValueList<PwM *>::const_iterator i2 = ml->begin(), | 804 | QValueList<PwM *>::const_iterator i2 = ml->begin(), |
784 | end2 = ml->end(); | 805 | end2 = ml->end(); |
785 | #else | 806 | #else |
786 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), | 807 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), |
787 | end2 = ml->end(); | 808 | end2 = ml->end(); |
788 | #endif | 809 | #endif |
789 | PwM *pwm; | 810 | PwM *pwm; |
790 | while (i2 != end2) { | 811 | while (i2 != end2) { |
791 | pwm = *i2; | 812 | pwm = *i2; |
792 | // reinitialize the window style. | 813 | // reinitialize the window style. |
793 | if (oldStyle != newStyle) | 814 | if (oldStyle != newStyle) |
794 | pwm->curView()->initStyle(newStyle); | 815 | pwm->curView()->initStyle(newStyle); |
795 | // set the new font | 816 | // set the new font |
796 | pwm->curView()->setFont(conf->confGlobEntryFont()); | 817 | pwm->curView()->setFont(conf()->confGlobEntryFont()); |
797 | ++i2; | 818 | ++i2; |
798 | } | 819 | } |
799 | } | 820 | } |
800 | 821 | ||
801 | void PwM::activateMpButton(bool activate) | 822 | void PwM::activateMpButton(bool activate) |
802 | { | 823 | { |
803 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); | 824 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); |
804 | } | 825 | } |
805 | 826 | ||
806 | void PwM::closeEvent(QCloseEvent *e) | 827 | void PwM::closeEvent(QCloseEvent *e) |
807 | { | 828 | { |
808 | e->accept(); | 829 | e->accept(); |
809 | } | 830 | } |
810 | 831 | ||
811 | void PwM::docClosed(PwMDoc *doc) | 832 | void PwM::docClosed(PwMDoc *doc) |
812 | { | 833 | { |
813 | PARAM_UNUSED(doc); | 834 | PARAM_UNUSED(doc); |
814 | PWM_ASSERT(doc == curDoc()); | 835 | PWM_ASSERT(doc == curDoc()); |
815 | close(); | 836 | close(); |
816 | } | 837 | } |
817 | 838 | ||
818 | void PwM::find_slot() | 839 | void PwM::find_slot() |
819 | { | 840 | { |
820 | PWM_ASSERT(curDoc()); | 841 | PWM_ASSERT(curDoc()); |
821 | if (curDoc()->isDocEmpty()) | 842 | if (curDoc()->isDocEmpty()) |
822 | return; | 843 | return; |
823 | if (curDoc()->isDeepLocked()) | 844 | if (curDoc()->isDeepLocked()) |
824 | return; | 845 | return; |
825 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 846 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
826 | FindWndImpl findWnd(view); | 847 | FindWndImpl findWnd(view); |
827 | findWnd.exec(); | 848 | findWnd.exec(); |
828 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 849 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
829 | } | 850 | } |
830 | 851 | ||
831 | void PwM::exportToText() | 852 | void PwM::exportToText() |
832 | { | 853 | { |
833 | PWM_ASSERT(curDoc()); | 854 | PWM_ASSERT(curDoc()); |
834 | if (curDoc()->isDocEmpty()) { | 855 | if (curDoc()->isDocEmpty()) { |
835 | KMessageBox::information(this, | 856 | KMessageBox::information(this, |
836 | i18n | 857 | i18n |
837 | ("Sorry, there's nothing to export.\n" | 858 | ("Sorry, there's nothing to export.\n" |
838 | "Please first add some passwords."), | 859 | "Please first add some passwords."), |
839 | i18n("nothing to do")); | 860 | i18n("nothing to do")); |
840 | return; | 861 | return; |
841 | } | 862 | } |
842 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 863 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
843 | QString fn(KFileDialog::getSaveFileName(QString::null, | 864 | QString fn(KFileDialog::getSaveFileName(QString::null, |
844 | i18n("*|plain-text file"), | 865 | i18n("*|plain-text file"), |
845 | this)); | 866 | this)); |
846 | if (fn == "") { | 867 | if (fn == "") { |
847 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 868 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
848 | return; | 869 | return; |
849 | } | 870 | } |
850 | 871 | ||
851 | PwMerror ret = curDoc()->exportToText(&fn); | 872 | PwMerror ret = curDoc()->exportToText(&fn); |
852 | if (ret != e_success) { | 873 | if (ret != e_success) { |
853 | KMessageBox::error(this, | 874 | KMessageBox::error(this, |
854 | i18n("Error: Couldn't write to file.\n" | 875 | i18n("Error: Couldn't write to file.\n" |
855 | "Please check if you have permission to write " | 876 | "Please check if you have permission to write " |
856 | "to the file in that directory."), | 877 | "to the file in that directory."), |
857 | i18n("error while writing")); | 878 | i18n("error while writing")); |
858 | } else | 879 | } else |
859 | showStatMsg(i18n("Successfully exported data.")); | 880 | showStatMsg(i18n("Successfully exported data.")); |
860 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 881 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
861 | } | 882 | } |
862 | 883 | ||
863 | bool PwM::importFromText() | 884 | bool PwM::importFromText() |
864 | { | 885 | { |
865 | if (!isVirgin()) { | 886 | if (!isVirgin()) { |
866 | if (KMessageBox::questionYesNo(this, | 887 | if (KMessageBox::questionYesNo(this, |
867 | i18n("Do you want to import the data " | 888 | i18n("Do you want to import the data " |
868 | "into the current document? (If you " | 889 | "into the current document? (If you " |
869 | "select \"no\", a new document will be " | 890 | "select \"no\", a new document will be " |
870 | "opened.)"), | 891 | "opened.)"), |
871 | i18n("import into this document?")) | 892 | i18n("import into this document?")) |
872 | == KMessageBox::No) { | 893 | == KMessageBox::No) { |
873 | // import the data to a new window. | 894 | // import the data to a new window. |
874 | PwM *newInstance = init->createMainWnd(); | 895 | PwM *newInstance = init->createMainWnd(); |
875 | bool ok = newInstance->importFromText(); | 896 | bool ok = newInstance->importFromText(); |
876 | if (!ok) { | 897 | if (!ok) { |
877 | newInstance->setForceQuit(true); | 898 | newInstance->setForceQuit(true); |
878 | delete_and_null(newInstance); | 899 | delete_and_null(newInstance); |
879 | } | 900 | } |
880 | return ok; | 901 | return ok; |
881 | } | 902 | } |
882 | } | 903 | } |
883 | 904 | ||
884 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 905 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
885 | PwMerror ret; | 906 | PwMerror ret; |
886 | QString path(KFileDialog::getOpenFileName(QString::null, | 907 | QString path(KFileDialog::getOpenFileName(QString::null, |
887 | i18n("*|PWM-exported text file"), | 908 | i18n("*|PWM-exported text file"), |
888 | this)); | 909 | this)); |
889 | if (path == "") | 910 | if (path == "") |
890 | goto cancelImport; | 911 | goto cancelImport; |
891 | 912 | ||
892 | ret = curDoc()->importFromText(&path, 0); | 913 | ret = curDoc()->importFromText(&path, 0); |
893 | if (ret == e_fileFormat) { | 914 | if (ret == e_fileFormat) { |
894 | KMessageBox::error(this, | 915 | KMessageBox::error(this, |
895 | i18n("Could not read file-format.\n" | 916 | i18n("Could not read file-format.\n" |
896 | "This seems to be _not_ a valid file " | 917 | "This seems to be _not_ a valid file " |
897 | "exported by PwM."), | 918 | "exported by PwM."), |
898 | i18n("invalid file-format")); | 919 | i18n("invalid file-format")); |
899 | goto cancelImport; | 920 | goto cancelImport; |
900 | } else if (ret == e_invalidArg) { | 921 | } else if (ret == e_invalidArg) { |
901 | BUG(); | 922 | BUG(); |
902 | goto cancelImport; | 923 | goto cancelImport; |
903 | } else if (ret != e_success) { | 924 | } else if (ret != e_success) { |
904 | KMessageBox::error(this, | 925 | KMessageBox::error(this, |
905 | i18n("Could not import file!\n" | 926 | i18n("Could not import file!\n" |
906 | "Do you have permission to read this file? " | 927 | "Do you have permission to read this file? " |
907 | "Do you have enough free memory?"), | 928 | "Do you have enough free memory?"), |
908 | i18n("import failed")); | 929 | i18n("import failed")); |
909 | goto cancelImport; | 930 | goto cancelImport; |
910 | } | 931 | } |
911 | setVirgin(false); | 932 | setVirgin(false); |
912 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 933 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
913 | return true; | 934 | return true; |
914 | 935 | ||
915 | cancelImport: | 936 | cancelImport: |
916 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 937 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
917 | return false; | 938 | return false; |
918 | } | 939 | } |
919 | 940 | ||
920 | void PwM::exportToGpasman() | 941 | void PwM::exportToGpasman() |
921 | { | 942 | { |
922 | PWM_ASSERT(curDoc()); | 943 | PWM_ASSERT(curDoc()); |
923 | if (curDoc()->isDocEmpty()) { | 944 | if (curDoc()->isDocEmpty()) { |
924 | KMessageBox::information(this, | 945 | KMessageBox::information(this, |
925 | i18n | 946 | i18n |
926 | ("Sorry, there's nothing to export.\n" | 947 | ("Sorry, there's nothing to export.\n" |
927 | "Please first add some passwords."), | 948 | "Please first add some passwords."), |
928 | i18n("nothing to do")); | 949 | i18n("nothing to do")); |
929 | return; | 950 | return; |
930 | } | 951 | } |
931 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 952 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
932 | QString fn(KFileDialog::getSaveFileName(QString::null, | 953 | QString fn(KFileDialog::getSaveFileName(QString::null, |
933 | i18n("*|Gpasman or Kpasman file"), | 954 | i18n("*|Gpasman or Kpasman file"), |
934 | this)); | 955 | this)); |
935 | if (fn == "") { | 956 | if (fn == "") { |
936 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 957 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
937 | return; | 958 | return; |
938 | } | 959 | } |
939 | 960 | ||
940 | PwMerror ret = curDoc()->exportToGpasman(&fn); | 961 | PwMerror ret = curDoc()->exportToGpasman(&fn); |
941 | if (ret != e_success) { | 962 | if (ret != e_success) { |
942 | if (ret == e_noPw) { | 963 | if (ret == e_noPw) { |
943 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 964 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
944 | return; | 965 | return; |
945 | } | 966 | } |
946 | KMessageBox::error(this, | 967 | KMessageBox::error(this, |
947 | i18n("Error: Couldn't write to file.\n" | 968 | i18n("Error: Couldn't write to file.\n" |
948 | "Please check if you have permission to write " | 969 | "Please check if you have permission to write " |
949 | "to the file in that directory."), | 970 | "to the file in that directory."), |
950 | i18n("error while writing")); | 971 | i18n("error while writing")); |
951 | } else | 972 | } else |
952 | showStatMsg(i18n("Successfully exported data.")); | 973 | showStatMsg(i18n("Successfully exported data.")); |
953 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 974 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
954 | } | 975 | } |
955 | 976 | ||
956 | void PwM::exportToKWallet() | 977 | void PwM::exportToKWallet() |
957 | { | 978 | { |
958 | #ifdef CONFIG_KWALLETIF | 979 | #ifdef CONFIG_KWALLETIF |
959 | if (!checkAndAskForKWalletEmu()) | 980 | if (!checkAndAskForKWalletEmu()) |
960 | return; | 981 | return; |
961 | PWM_ASSERT(curDoc()); | 982 | PWM_ASSERT(curDoc()); |
962 | if (curDoc()->isDocEmpty()) { | 983 | if (curDoc()->isDocEmpty()) { |
963 | KMessageBox::information(this, | 984 | KMessageBox::information(this, |
964 | i18n | 985 | i18n |
965 | ("Sorry, there's nothing to export.\n" | 986 | ("Sorry, there's nothing to export.\n" |
966 | "Please first add some passwords."), | 987 | "Please first add some passwords."), |
967 | i18n("nothing to do")); | 988 | i18n("nothing to do")); |
968 | init->initKWalletEmu(); | 989 | init->initKWalletEmu(); |
969 | return; | 990 | return; |
970 | } | 991 | } |
971 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 992 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
972 | KWalletIf walletIf(this); | 993 | KWalletIf walletIf(this); |
973 | if (walletIf.kwalletExport(curDoc())) { | 994 | if (walletIf.kwalletExport(curDoc())) { |
974 | KMessageBox::information(this, | 995 | KMessageBox::information(this, |
975 | i18n("Successfully exported the data of the current " | 996 | i18n("Successfully exported the data of the current " |
976 | "document to KWallet."), | 997 | "document to KWallet."), |
977 | i18n("Successfully exported data.")); | 998 | i18n("Successfully exported data.")); |
978 | showStatMsg(i18n("Successfully exported data.")); | 999 | showStatMsg(i18n("Successfully exported data.")); |
979 | } | 1000 | } |
980 | init->initKWalletEmu(); | 1001 | init->initKWalletEmu(); |
981 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1002 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
982 | #endif // CONFIG_KWALLETIF | 1003 | #endif // CONFIG_KWALLETIF |
983 | } | 1004 | } |
984 | 1005 | ||
985 | bool PwM::importFromGpasman() | 1006 | bool PwM::importFromGpasman() |
986 | { | 1007 | { |
987 | if (!isVirgin()) { | 1008 | if (!isVirgin()) { |
988 | if (KMessageBox::questionYesNo(this, | 1009 | if (KMessageBox::questionYesNo(this, |
989 | i18n("Do you want to import the data " | 1010 | i18n("Do you want to import the data " |
990 | "into the current document? (If you " | 1011 | "into the current document? (If you " |
991 | "select \"no\", a new document will be " | 1012 | "select \"no\", a new document will be " |
992 | "opened.)"), | 1013 | "opened.)"), |
993 | i18n("import into this document?")) | 1014 | i18n("import into this document?")) |
994 | == KMessageBox::No) { | 1015 | == KMessageBox::No) { |
995 | // import the data to a new window. | 1016 | // import the data to a new window. |
996 | PwM *newInstance = init->createMainWnd(); | 1017 | PwM *newInstance = init->createMainWnd(); |
997 | bool ok = newInstance->importFromGpasman(); | 1018 | bool ok = newInstance->importFromGpasman(); |
998 | if (!ok) { | 1019 | if (!ok) { |
999 | newInstance->setForceQuit(true); | 1020 | newInstance->setForceQuit(true); |
1000 | delete_and_null(newInstance); | 1021 | delete_and_null(newInstance); |
1001 | } | 1022 | } |
1002 | return ok; | 1023 | return ok; |
1003 | } | 1024 | } |
1004 | } | 1025 | } |
1005 | 1026 | ||
1006 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1027 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1007 | PwMerror ret; | 1028 | PwMerror ret; |
1008 | QString path(KFileDialog::getOpenFileName(QString::null, | 1029 | QString path(KFileDialog::getOpenFileName(QString::null, |
1009 | i18n("*|Gpasman or Kpasman file"), this)); | 1030 | i18n("*|Gpasman or Kpasman file"), this)); |
1010 | if (path == "") | 1031 | if (path == "") |
1011 | goto cancelImport; | 1032 | goto cancelImport; |
1012 | ret = curDoc()->importFromGpasman(&path); | 1033 | ret = curDoc()->importFromGpasman(&path); |
1013 | if (ret == e_wrongPw) { | 1034 | if (ret == e_wrongPw) { |
1014 | if (KMessageBox::questionYesNo(this, | 1035 | if (KMessageBox::questionYesNo(this, |
1015 | i18n | 1036 | i18n |
1016 | ("This is probably the wrong master-password" | 1037 | ("This is probably the wrong master-password" |
1017 | "you have typed in.\n" | 1038 | "you have typed in.\n" |
1018 | "There is no real way to determine the " | 1039 | "There is no real way to determine the " |
1019 | "correctness of the password in the Gpasman " | 1040 | "correctness of the password in the Gpasman " |
1020 | "file-format. But I think this " | 1041 | "file-format. But I think this " |
1021 | "password ist wrong.\n" | 1042 | "password ist wrong.\n" |
1022 | "Do you want to continue nevertheless?"), | 1043 | "Do you want to continue nevertheless?"), |
1023 | i18n("password error")) | 1044 | i18n("password error")) |
1024 | == KMessageBox::No) { | 1045 | == KMessageBox::No) { |
1025 | goto cancelImport; | 1046 | goto cancelImport; |
1026 | } | 1047 | } |
1027 | } else if (ret != e_success) { | 1048 | } else if (ret != e_success) { |
1028 | KMessageBox::error(this, | 1049 | KMessageBox::error(this, |
1029 | i18n("Could not import file!\n" | 1050 | i18n("Could not import file!\n" |
1030 | "Do you have permission to read this file?"), | 1051 | "Do you have permission to read this file?"), |
1031 | i18n("import failed")); | 1052 | i18n("import failed")); |
1032 | goto cancelImport; | 1053 | goto cancelImport; |
1033 | } | 1054 | } |
1034 | setVirgin(false); | 1055 | setVirgin(false); |
1035 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1056 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1036 | return true; | 1057 | return true; |
1037 | 1058 | ||
1038 | cancelImport: | 1059 | cancelImport: |
1039 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1060 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1040 | return false; | 1061 | return false; |
1041 | } | 1062 | } |
1042 | 1063 | ||
1043 | #ifdef CONFIG_KWALLETIF | 1064 | #ifdef CONFIG_KWALLETIF |
1044 | bool PwM::checkAndAskForKWalletEmu() | 1065 | bool PwM::checkAndAskForKWalletEmu() |
1045 | { | 1066 | { |
1046 | if (init->kwalletEmu()) { | 1067 | if (init->kwalletEmu()) { |
1047 | /* KWallet emulation is enabled. We can't import/export | 1068 | /* KWallet emulation is enabled. We can't import/export |
1048 | * data from/to it, while emulation is active. | 1069 | * data from/to it, while emulation is active. |
1049 | */ | 1070 | */ |
1050 | if (KMessageBox::questionYesNo(this, | 1071 | if (KMessageBox::questionYesNo(this, |
1051 | i18n("KWallet emulation is enabled.\n" | 1072 | i18n("KWallet emulation is enabled.\n" |
1052 | "You can't import or export data from/to " | 1073 | "You can't import or export data from/to " |
1053 | "the original KWallet, while the emulation " | 1074 | "the original KWallet, while the emulation " |
1054 | "is active.\n" | 1075 | "is active.\n" |
1055 | "Do you want to tempoarly disable the KWallet emulation?"), | 1076 | "Do you want to tempoarly disable the KWallet emulation?"), |
1056 | i18n("Tempoarly disable KWallet emulation?")) | 1077 | i18n("Tempoarly disable KWallet emulation?")) |
1057 | == KMessageBox::Yes) { | 1078 | == KMessageBox::Yes) { |
1058 | init->initKWalletEmu(true); | 1079 | init->initKWalletEmu(true); |
1059 | PWM_ASSERT(!init->kwalletEmu()); | 1080 | PWM_ASSERT(!init->kwalletEmu()); |
1060 | return true; | 1081 | return true; |
1061 | } | 1082 | } |
1062 | return false; | 1083 | return false; |
1063 | } | 1084 | } |
1064 | return true; | 1085 | return true; |
1065 | } | 1086 | } |
1066 | #endif // CONFIG_KWALLETIF | 1087 | #endif // CONFIG_KWALLETIF |
1067 | 1088 | ||
1068 | bool PwM::importKWallet() | 1089 | bool PwM::importKWallet() |
1069 | { | 1090 | { |
1070 | #ifdef CONFIG_KWALLETIF | 1091 | #ifdef CONFIG_KWALLETIF |
1071 | if (!checkAndAskForKWalletEmu()) | 1092 | if (!checkAndAskForKWalletEmu()) |
1072 | return false; | 1093 | return false; |
1073 | KWalletIf walletIf(this); | 1094 | KWalletIf walletIf(this); |
1074 | if (!isVirgin()) { | 1095 | if (!isVirgin()) { |
1075 | if (KMessageBox::questionYesNo(this, | 1096 | if (KMessageBox::questionYesNo(this, |
1076 | i18n("Do you want to import the data " | 1097 | i18n("Do you want to import the data " |
1077 | "into the current document? (If you " | 1098 | "into the current document? (If you " |
1078 | "select \"no\", a new document will be " | 1099 | "select \"no\", a new document will be " |
1079 | "opened.)"), | 1100 | "opened.)"), |
1080 | i18n("import into this document?")) | 1101 | i18n("import into this document?")) |
1081 | == KMessageBox::No) { | 1102 | == KMessageBox::No) { |
1082 | // import the data to a new window. | 1103 | // import the data to a new window. |
1083 | PwM *newInstance = init->createMainWnd(); | 1104 | PwM *newInstance = init->createMainWnd(); |
1084 | bool ok = newInstance->importKWallet(); | 1105 | bool ok = newInstance->importKWallet(); |
1085 | if (!ok) { | 1106 | if (!ok) { |
1086 | newInstance->setForceQuit(true); | 1107 | newInstance->setForceQuit(true); |
1087 | delete_and_null(newInstance); | 1108 | delete_and_null(newInstance); |
1088 | goto exit_fail; | 1109 | goto exit_fail; |
1089 | } else { | 1110 | } else { |
1090 | goto exit_ok; | 1111 | goto exit_ok; |
1091 | } | 1112 | } |
1092 | } | 1113 | } |
1093 | } | 1114 | } |
1094 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1115 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1095 | if (!walletIf.kwalletImport(curDoc())) { | 1116 | if (!walletIf.kwalletImport(curDoc())) { |
1096 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1117 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1097 | showStatMsg(i18n("KWallet import failed")); | 1118 | showStatMsg(i18n("KWallet import failed")); |
1098 | goto exit_fail; | 1119 | goto exit_fail; |
1099 | } | 1120 | } |
1100 | KMessageBox::information(this, | 1121 | KMessageBox::information(this, |
1101 | i18n("Successfully imported the KWallet data " | 1122 | i18n("Successfully imported the KWallet data " |
1102 | "into the current document."), | 1123 | "into the current document."), |
1103 | i18n("successfully imported")); | 1124 | i18n("successfully imported")); |
1104 | showStatMsg(i18n("successfully imported")); | 1125 | showStatMsg(i18n("successfully imported")); |
1105 | setVirgin(false); | 1126 | setVirgin(false); |
1106 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1127 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1107 | 1128 | ||
1108 | exit_ok: | 1129 | exit_ok: |
1109 | init->initKWalletEmu(); | 1130 | init->initKWalletEmu(); |
1110 | return true; | 1131 | return true; |
1111 | 1132 | ||
1112 | exit_fail: | 1133 | exit_fail: |
1113 | init->initKWalletEmu(); | 1134 | init->initKWalletEmu(); |
1114 | #endif // CONFIG_KWALLETIF | 1135 | #endif // CONFIG_KWALLETIF |
1115 | return false; | 1136 | return false; |
1116 | } | 1137 | } |
1117 | 1138 | ||
1118 | void PwM::print_slot() | 1139 | void PwM::print_slot() |
1119 | { | 1140 | { |
1120 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1141 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1121 | #ifndef PWM_EMBEDDED | 1142 | #ifndef PWM_EMBEDDED |
1122 | PwMPrint p(curDoc(), this); | 1143 | PwMPrint p(curDoc(), this); |
1123 | p.printNow(); | 1144 | p.printNow(); |
1124 | #else | 1145 | #else |
1125 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); | 1146 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); |
1126 | #endif | 1147 | #endif |
1127 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1148 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1128 | } | 1149 | } |
1129 | 1150 | ||
1130 | void PwM::genNewCard_slot() | 1151 | void PwM::genNewCard_slot() |
1131 | { | 1152 | { |
1132 | #ifdef CONFIG_KEYCARD | 1153 | #ifdef CONFIG_KEYCARD |
1133 | init->keycard()->genNewCard(); | 1154 | init->keycard()->genNewCard(); |
1134 | #endif | 1155 | #endif |
1135 | } | 1156 | } |
1136 | 1157 | ||
1137 | void PwM::eraseCard_slot() | 1158 | void PwM::eraseCard_slot() |
1138 | { | 1159 | { |
1139 | #ifdef CONFIG_KEYCARD | 1160 | #ifdef CONFIG_KEYCARD |
1140 | init->keycard()->eraseCard(); | 1161 | init->keycard()->eraseCard(); |
1141 | #endif | 1162 | #endif |
1142 | } | 1163 | } |
1143 | 1164 | ||
1144 | void PwM::readCardId_slot() | 1165 | void PwM::readCardId_slot() |
1145 | { | 1166 | { |
1146 | #ifdef CONFIG_KEYCARD | 1167 | #ifdef CONFIG_KEYCARD |
1147 | init->keycard()->displayKey(); | 1168 | init->keycard()->displayKey(); |
1148 | #endif | 1169 | #endif |
1149 | } | 1170 | } |
1150 | 1171 | ||
1151 | void PwM::makeCardBackup_slot() | 1172 | void PwM::makeCardBackup_slot() |
1152 | { | 1173 | { |
1153 | #ifdef CONFIG_KEYCARD | 1174 | #ifdef CONFIG_KEYCARD |
1154 | init->keycard()->makeBackupImage(); | 1175 | init->keycard()->makeBackupImage(); |
1155 | #endif | 1176 | #endif |
1156 | } | 1177 | } |
1157 | 1178 | ||
1158 | void PwM::replayCardBackup_slot() | 1179 | void PwM::replayCardBackup_slot() |
1159 | { | 1180 | { |
1160 | #ifdef CONFIG_KEYCARD | 1181 | #ifdef CONFIG_KEYCARD |
1161 | init->keycard()->replayBackupImage(); | 1182 | init->keycard()->replayBackupImage(); |
1162 | #endif | 1183 | #endif |
1163 | } | 1184 | } |
1164 | 1185 | ||
1165 | void PwM::execLauncher_slot() | 1186 | void PwM::execLauncher_slot() |
1166 | { | 1187 | { |
1167 | PWM_ASSERT(curDoc()); | 1188 | PWM_ASSERT(curDoc()); |
1168 | if (curDoc()->isDeepLocked()) | 1189 | if (curDoc()->isDeepLocked()) |
1169 | return; | 1190 | return; |
1170 | unsigned int curEntryIndex; | 1191 | unsigned int curEntryIndex; |
1171 | if (!view->getCurEntryIndex(&curEntryIndex)) | 1192 | if (!view->getCurEntryIndex(&curEntryIndex)) |
1172 | return; | 1193 | return; |
1173 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), | 1194 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), |
1174 | curEntryIndex); | 1195 | curEntryIndex); |
1175 | if (ret) | 1196 | if (ret) |
1176 | showStatMsg(i18n("Executed the \"Launcher\".")); | 1197 | showStatMsg(i18n("Executed the \"Launcher\".")); |
1177 | else | 1198 | else |
1178 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); | 1199 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); |
1179 | } | 1200 | } |
1180 | 1201 | ||
diff --git a/pwmanager/pwmanager/pwmanagerE.pro b/pwmanager/pwmanager/pwmanagerE.pro index 2cd69a5..5c29ea4 100644 --- a/pwmanager/pwmanager/pwmanagerE.pro +++ b/pwmanager/pwmanager/pwmanagerE.pro | |||
@@ -1,144 +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 |
6 | OBJECTS_DIR = obj/$(PLATFORM) | 6 | OBJECTS_DIR = obj/$(PLATFORM) |
7 | MOC_DIR = moc/$(PLATFORM) | 7 | MOC_DIR = moc/$(PLATFORM) |
8 | DESTDIR=$(QPEDIR)/bin | 8 | DESTDIR=$(QPEDIR)/bin |
9 | 9 | ||
10 | INCLUDEPATH += . ../../qtcompat ../../qtcompat/xml ../../microkde ../../microkde/kdecore ../../microkde/kdeui $(QPEDIR)/include | 10 | INCLUDEPATH += . ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include |
11 | DEFINES += PWM_EMBEDDED PWM_DEBUG | 11 | DEFINES += PWM_EMBEDDED PWM_DEBUG |
12 | LIBS += -lmicrokde | 12 | LIBS += -lmicrokde |
13 | LIBS += -lmicroqtcompat | 13 | LIBS += -lmicroqtcompat |
14 | LIBS += -lmicrokdepim | ||
14 | LIBS += -L$(QPEDIR)/lib | 15 | LIBS += -L$(QPEDIR)/lib |
15 | LIBS += -lqpe | 16 | LIBS += -lqpe |
16 | LIBS += -lbz2 | 17 | LIBS += -lbz2 |
17 | LIBS += $(QTOPIALIB) | 18 | LIBS += $(QTOPIALIB) |
18 | 19 | ||
19 | #INTERFACES = \ | 20 | #INTERFACES = \ |
20 | #addentrywnd.ui \ | 21 | #addentrywnd.ui \ |
21 | #configwnd.ui \ | 22 | #configwnd.ui \ |
22 | #findwnd.ui \ | 23 | #findwnd.ui \ |
23 | #getmasterpwwnd.ui \ | 24 | #getmasterpwwnd.ui \ |
24 | #pwgenwnd.ui \ | 25 | #pwgenwnd.ui \ |
25 | #setmasterpwwnd.ui \ | 26 | #setmasterpwwnd.ui \ |
26 | #subtbledit.ui | 27 | #subtbledit.ui |
27 | 28 | ||
28 | #INTERFACES = \ | 29 | #INTERFACES = \ |
29 | #subtbledit.ui \ | 30 | #subtbledit.ui \ |
30 | 31 | ||
31 | 32 | ||
32 | 33 | ||
33 | #HEADERS = \ | 34 | #HEADERS = \ |
35 | #configuration_31compat.h \ | ||
36 | #configuration.h \ | ||
37 | #configwnd.h \ | ||
38 | #configwndimpl.h \ | ||
34 | #selftest.h | 39 | #selftest.h |
35 | 40 | ||
36 | HEADERS = \ | 41 | HEADERS = \ |
37 | addentrywnd.h \ | 42 | addentrywnd.h \ |
38 | addentrywndimpl.h \ | 43 | addentrywndimpl.h \ |
39 | base64.h \ | 44 | base64.h \ |
40 | binentrygen.h \ | 45 | binentrygen.h \ |
41 | blowfish.h \ | 46 | blowfish.h \ |
42 | commentbox.h \ | 47 | commentbox.h \ |
43 | compiler.h \ | 48 | compiler.h \ |
44 | compressbzip2.h \ | 49 | compressbzip2.h \ |
45 | compressgzip.h \ | 50 | compressgzip.h \ |
46 | configuration_31compat.h \ | ||
47 | configuration.h \ | ||
48 | configwnd.h \ | ||
49 | configwndimpl.h \ | ||
50 | findwnd.h \ | 51 | findwnd.h \ |
51 | findwndimpl.h \ | 52 | findwndimpl.h \ |
52 | genpasswd.h \ | 53 | genpasswd.h \ |
53 | getkeycardwnd.h \ | 54 | getkeycardwnd.h \ |
54 | getmasterpwwnd.h \ | 55 | getmasterpwwnd.h \ |
55 | getmasterpwwndimpl.h \ | 56 | getmasterpwwndimpl.h \ |
56 | globalstuff.h \ | 57 | globalstuff.h \ |
57 | gpasmanfile.h \ | 58 | gpasmanfile.h \ |
58 | htmlgen.h \ | 59 | htmlgen.h \ |
59 | htmlparse.h \ | 60 | htmlparse.h \ |
60 | ipc.h \ | 61 | ipc.h \ |
61 | listobjselectwnd.h \ | 62 | listobjselectwnd.h \ |
62 | listviewpwm.h \ | 63 | listviewpwm.h \ |
63 | printtext.h \ | 64 | printtext.h \ |
64 | pwgenwnd.h \ | 65 | pwgenwnd.h \ |
65 | pwgenwndimpl.h \ | 66 | pwgenwndimpl.h \ |
66 | pwmdoc.h \ | 67 | pwmdoc.h \ |
67 | pwmdocui.h \ | 68 | pwmdocui.h \ |
68 | pwmexception.h \ | 69 | pwmexception.h \ |
69 | pwm.h \ | 70 | pwm.h \ |
70 | pwminit.h \ | 71 | pwminit.h \ |
72 | pwmprefs.h \ | ||
71 | pwmprint.h \ | 73 | pwmprint.h \ |
72 | pwmtray.h \ | 74 | pwmtray.h \ |
73 | pwmview.h \ | 75 | pwmview.h \ |
74 | pwmviewstyle_0.h \ | 76 | pwmviewstyle_0.h \ |
75 | pwmviewstyle_1.h \ | 77 | pwmviewstyle_1.h \ |
76 | pwmviewstyle.h \ | 78 | pwmviewstyle.h \ |
77 | randomizer.h \ | 79 | randomizer.h \ |
78 | rc2.h \ | 80 | rc2.h \ |
79 | rencatwnd.h \ | 81 | rencatwnd.h \ |
80 | serializer.h \ | 82 | serializer.h \ |
81 | setmasterpwwnd.h \ | 83 | setmasterpwwnd.h \ |
82 | setmasterpwwndimpl.h \ | 84 | setmasterpwwndimpl.h \ |
83 | sha1.h \ | 85 | sha1.h \ |
84 | subtbledit.h \ | 86 | subtbledit.h \ |
85 | subtbleditimpl.h \ | 87 | subtbleditimpl.h \ |
86 | waitwnd.h | 88 | waitwnd.h \ |
89 | kcmconfigs/kcmpwmconfig.h \ | ||
90 | kcmconfigs/pwmconfigwidget.h \ | ||
87 | 91 | ||
92 | #sources that need not be build | ||
88 | #SOURCES = \ | 93 | #SOURCES = \ |
89 | #advcommeditimpl.cpp \ | 94 | #advcommeditimpl.cpp \ |
95 | #configuration.cpp \ | ||
96 | #configwnd.cpp \ | ||
97 | #configwndimpl.cpp \ | ||
90 | #configuration_31compat.cpp \ | 98 | #configuration_31compat.cpp \ |
91 | #htmlparse.cpp \ | 99 | #htmlparse.cpp \ |
92 | #printtext.cpp \ | 100 | #printtext.cpp \ |
93 | #selftest.cpp \ | 101 | #selftest.cpp \ |
94 | #pwmprint.cpp \ | 102 | #pwmprint.cpp \ |
95 | #spinforsignal.cpp | 103 | #spinforsignal.cpp |
96 | 104 | ||
97 | SOURCES = \ | 105 | SOURCES = \ |
98 | addentrywnd.cpp \ | 106 | addentrywnd.cpp \ |
99 | addentrywndimpl.cpp \ | 107 | addentrywndimpl.cpp \ |
100 | base64.cpp \ | 108 | base64.cpp \ |
101 | binentrygen.cpp \ | 109 | binentrygen.cpp \ |
102 | blowfish.cpp \ | 110 | blowfish.cpp \ |
103 | commentbox.cpp \ | 111 | commentbox.cpp \ |
104 | compressbzip2.cpp \ | 112 | compressbzip2.cpp \ |
105 | compressgzip.cpp \ | 113 | compressgzip.cpp \ |
106 | configuration.cpp \ | ||
107 | configwnd.cpp \ | ||
108 | configwndimpl.cpp \ | ||
109 | findwnd.cpp \ | 114 | findwnd.cpp \ |
110 | findwndimpl.cpp \ | 115 | findwndimpl.cpp \ |
111 | genpasswd.cpp \ | 116 | genpasswd.cpp \ |
112 | getkeycardwnd.cpp \ | 117 | getkeycardwnd.cpp \ |
113 | getmasterpwwnd.cpp \ | 118 | getmasterpwwnd.cpp \ |
114 | getmasterpwwndimpl.cpp \ | 119 | getmasterpwwndimpl.cpp \ |
115 | globalstuff.cpp \ | 120 | globalstuff.cpp \ |
116 | gpasmanfile.cpp \ | 121 | gpasmanfile.cpp \ |
117 | htmlgen.cpp \ | 122 | htmlgen.cpp \ |
118 | ipc.cpp \ | 123 | ipc.cpp \ |
119 | listobjselectwnd.cpp \ | 124 | listobjselectwnd.cpp \ |
120 | listviewpwm.cpp \ | 125 | listviewpwm.cpp \ |
121 | main.cpp \ | 126 | main.cpp \ |
122 | pwgenwnd.cpp \ | 127 | pwgenwnd.cpp \ |
123 | pwgenwndimpl.cpp \ | 128 | pwgenwndimpl.cpp \ |
124 | pwm.cpp \ | 129 | pwm.cpp \ |
125 | pwmdoc.cpp \ | 130 | pwmdoc.cpp \ |
126 | pwmdocui.cpp \ | 131 | pwmdocui.cpp \ |
127 | pwmexception.cpp \ | 132 | pwmexception.cpp \ |
128 | pwminit.cpp \ | 133 | pwminit.cpp \ |
134 | pwmprefs.cpp \ | ||
129 | pwmtray.cpp \ | 135 | pwmtray.cpp \ |
130 | pwmview.cpp \ | 136 | pwmview.cpp \ |
131 | pwmviewstyle_0.cpp \ | 137 | pwmviewstyle_0.cpp \ |
132 | pwmviewstyle_1.cpp \ | 138 | pwmviewstyle_1.cpp \ |
133 | pwmviewstyle.cpp \ | 139 | pwmviewstyle.cpp \ |
134 | randomizer.cpp \ | 140 | randomizer.cpp \ |
135 | rc2.cpp \ | 141 | rc2.cpp \ |
136 | rencatwnd.cpp \ | 142 | rencatwnd.cpp \ |
137 | serializer.cpp \ | 143 | serializer.cpp \ |
138 | setmasterpwwnd.cpp \ | 144 | setmasterpwwnd.cpp \ |
139 | setmasterpwwndimpl.cpp \ | 145 | setmasterpwwndimpl.cpp \ |
140 | sha1.cpp \ | 146 | sha1.cpp \ |
141 | subtbledit.cpp \ | 147 | subtbledit.cpp \ |
142 | subtbleditimpl.cpp \ | 148 | subtbleditimpl.cpp \ |
143 | waitwnd.cpp \ | 149 | waitwnd.cpp \ |
150 | kcmconfigs/kcmpwmconfig.cpp \ | ||
151 | kcmconfigs/pwmconfigwidget.cpp \ | ||
152 | |||
144 | 153 | ||
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 04af360..9fe4809 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -1,417 +1,419 @@ | |||
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 2.0 of pwmanager | 14 | * This file is originaly based on version 2.0 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 "pwmdoc.h" | 20 | #include "pwmdoc.h" |
21 | #include "pwmview.h" | 21 | #include "pwmview.h" |
22 | #include "blowfish.h" | 22 | #include "blowfish.h" |
23 | #include "sha1.h" | 23 | #include "sha1.h" |
24 | #include "globalstuff.h" | 24 | #include "globalstuff.h" |
25 | #include "gpasmanfile.h" | 25 | #include "gpasmanfile.h" |
26 | #include "serializer.h" | 26 | #include "serializer.h" |
27 | #include "compressgzip.h" | 27 | #include "compressgzip.h" |
28 | #include "compressbzip2.h" | 28 | #include "compressbzip2.h" |
29 | #include "randomizer.h" | 29 | #include "randomizer.h" |
30 | #include "pwminit.h" | 30 | #include "pwminit.h" |
31 | #ifndef PWM_EMBEDDED | 31 | #ifndef PWM_EMBEDDED |
32 | //US #include "libgryptif.h" | 32 | //US #include "libgryptif.h" |
33 | #else | 33 | #else |
34 | #include "pwmprefs.h" | ||
35 | #include "kglobal.h" | ||
34 | #endif | 36 | #endif |
35 | 37 | ||
36 | #ifdef CONFIG_KWALLETIF | 38 | #ifdef CONFIG_KWALLETIF |
37 | # include "kwalletemu.h" | 39 | # include "kwalletemu.h" |
38 | #endif // CONFIG_KWALLETIF | 40 | #endif // CONFIG_KWALLETIF |
39 | 41 | ||
40 | #include <qdatetime.h> | 42 | #include <qdatetime.h> |
41 | #include <qsize.h> | 43 | #include <qsize.h> |
42 | #include <qfileinfo.h> | 44 | #include <qfileinfo.h> |
43 | #include <qfile.h> | 45 | #include <qfile.h> |
44 | 46 | ||
45 | #include <stdio.h> | 47 | #include <stdio.h> |
46 | #include <stdlib.h> | 48 | #include <stdlib.h> |
47 | #include <errno.h> | 49 | #include <errno.h> |
48 | #include <string.h> | 50 | #include <string.h> |
49 | #include <iostream> | 51 | #include <iostream> |
50 | #include <algorithm> | 52 | #include <algorithm> |
51 | #include <sys/types.h> | 53 | #include <sys/types.h> |
52 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
53 | #include <unistd.h> | 55 | #include <unistd.h> |
54 | #include <stdint.h> | 56 | #include <stdint.h> |
55 | 57 | ||
56 | //TODO: reset to its normal value. | 58 | //TODO: reset to its normal value. |
57 | #define META_CHECK_TIMER_INTERVAL10/*300*/ /* sek */ | 59 | #define META_CHECK_TIMER_INTERVAL10/*300*/ /* sek */ |
58 | 60 | ||
59 | using namespace std; | 61 | using namespace std; |
60 | 62 | ||
61 | 63 | ||
62 | void PwMDocList::add(PwMDoc *doc, const string &id) | 64 | void PwMDocList::add(PwMDoc *doc, const string &id) |
63 | { | 65 | { |
64 | #ifdef PWM_DEBUG | 66 | #ifdef PWM_DEBUG |
65 | // check for existance of object in debug mode only. | 67 | // check for existance of object in debug mode only. |
66 | vector<listItem>::iterator begin = docList.begin(), | 68 | vector<listItem>::iterator begin = docList.begin(), |
67 | end = docList.end(), | 69 | end = docList.end(), |
68 | i = begin; | 70 | i = begin; |
69 | while (i != end) { | 71 | while (i != end) { |
70 | if (i->doc == doc) { | 72 | if (i->doc == doc) { |
71 | BUG(); | 73 | BUG(); |
72 | return; | 74 | return; |
73 | } | 75 | } |
74 | ++i; | 76 | ++i; |
75 | } | 77 | } |
76 | #endif | 78 | #endif |
77 | listItem newItem; | 79 | listItem newItem; |
78 | newItem.doc = doc; | 80 | newItem.doc = doc; |
79 | newItem.docId = id; | 81 | newItem.docId = id; |
80 | docList.push_back(newItem); | 82 | docList.push_back(newItem); |
81 | } | 83 | } |
82 | 84 | ||
83 | void PwMDocList::edit(PwMDoc *doc, const string &newId) | 85 | void PwMDocList::edit(PwMDoc *doc, const string &newId) |
84 | { | 86 | { |
85 | vector<listItem>::iterator begin = docList.begin(), | 87 | vector<listItem>::iterator begin = docList.begin(), |
86 | end = docList.end(), | 88 | end = docList.end(), |
87 | i = begin; | 89 | i = begin; |
88 | while (i != end) { | 90 | while (i != end) { |
89 | if (i->doc == doc) { | 91 | if (i->doc == doc) { |
90 | i->docId = newId; | 92 | i->docId = newId; |
91 | return; | 93 | return; |
92 | } | 94 | } |
93 | ++i; | 95 | ++i; |
94 | } | 96 | } |
95 | } | 97 | } |
96 | 98 | ||
97 | void PwMDocList::del(PwMDoc *doc) | 99 | void PwMDocList::del(PwMDoc *doc) |
98 | { | 100 | { |
99 | vector<listItem>::iterator begin = docList.begin(), | 101 | vector<listItem>::iterator begin = docList.begin(), |
100 | end = docList.end(), | 102 | end = docList.end(), |
101 | i = begin; | 103 | i = begin; |
102 | while (i != end) { | 104 | while (i != end) { |
103 | if (i->doc == doc) { | 105 | if (i->doc == doc) { |
104 | docList.erase(i); | 106 | docList.erase(i); |
105 | return; | 107 | return; |
106 | } | 108 | } |
107 | ++i; | 109 | ++i; |
108 | } | 110 | } |
109 | } | 111 | } |
110 | 112 | ||
111 | bool PwMDocList::find(const string &id, listItem *ret) | 113 | bool PwMDocList::find(const string &id, listItem *ret) |
112 | { | 114 | { |
113 | vector<listItem>::iterator begin = docList.begin(), | 115 | vector<listItem>::iterator begin = docList.begin(), |
114 | end = docList.end(), | 116 | end = docList.end(), |
115 | i = begin; | 117 | i = begin; |
116 | while (i != end) { | 118 | while (i != end) { |
117 | if (i->docId == id) { | 119 | if (i->docId == id) { |
118 | if (ret) | 120 | if (ret) |
119 | *ret = *i; | 121 | *ret = *i; |
120 | return true; | 122 | return true; |
121 | } | 123 | } |
122 | ++i; | 124 | ++i; |
123 | } | 125 | } |
124 | return false; | 126 | return false; |
125 | } | 127 | } |
126 | 128 | ||
127 | 129 | ||
128 | 130 | ||
129 | DocTimer::DocTimer(PwMDoc *_doc) | 131 | DocTimer::DocTimer(PwMDoc *_doc) |
130 | : doc (_doc) | 132 | : doc (_doc) |
131 | , mpwLock (0) | 133 | , mpwLock (0) |
132 | , autoLockLock (0) | 134 | , autoLockLock (0) |
133 | , metaCheckLock (0) | 135 | , metaCheckLock (0) |
134 | { | 136 | { |
135 | mpwTimer = new QTimer; | 137 | mpwTimer = new QTimer; |
136 | autoLockTimer = new QTimer; | 138 | autoLockTimer = new QTimer; |
137 | metaCheckTimer = new QTimer; | 139 | metaCheckTimer = new QTimer; |
138 | connect(mpwTimer, SIGNAL(timeout()), | 140 | connect(mpwTimer, SIGNAL(timeout()), |
139 | this, SLOT(mpwTimeout())); | 141 | this, SLOT(mpwTimeout())); |
140 | connect(autoLockTimer, SIGNAL(timeout()), | 142 | connect(autoLockTimer, SIGNAL(timeout()), |
141 | this, SLOT(autoLockTimeout())); | 143 | this, SLOT(autoLockTimeout())); |
142 | connect(metaCheckTimer, SIGNAL(timeout()), | 144 | connect(metaCheckTimer, SIGNAL(timeout()), |
143 | this, SLOT(metaCheckTimeout())); | 145 | this, SLOT(metaCheckTimeout())); |
144 | } | 146 | } |
145 | 147 | ||
146 | DocTimer::~DocTimer() | 148 | DocTimer::~DocTimer() |
147 | { | 149 | { |
148 | delete mpwTimer; | 150 | delete mpwTimer; |
149 | delete autoLockTimer; | 151 | delete autoLockTimer; |
150 | delete metaCheckTimer; | 152 | delete metaCheckTimer; |
151 | } | 153 | } |
152 | 154 | ||
153 | void DocTimer::start(TimerIDs timer) | 155 | void DocTimer::start(TimerIDs timer) |
154 | { | 156 | { |
155 | switch (timer) { | 157 | switch (timer) { |
156 | case id_mpwTimer: | 158 | case id_mpwTimer: |
157 | if (mpwTimer->isActive()) | 159 | if (mpwTimer->isActive()) |
158 | mpwTimer->stop(); | 160 | mpwTimer->stop(); |
159 | doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); | 161 | doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); |
160 | mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true); | 162 | mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true); |
161 | break; | 163 | break; |
162 | case id_autoLockTimer: | 164 | case id_autoLockTimer: |
163 | if (autoLockTimer->isActive()) | 165 | if (autoLockTimer->isActive()) |
164 | autoLockTimer->stop(); | 166 | autoLockTimer->stop(); |
165 | if (conf()->confGlobLockTimeout() > 0) | 167 | if (conf()->confGlobLockTimeout() > 0) |
166 | autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true); | 168 | autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true); |
167 | break; | 169 | break; |
168 | case id_metaCheckTimer: | 170 | case id_metaCheckTimer: |
169 | if (metaCheckTimer->isActive()) | 171 | if (metaCheckTimer->isActive()) |
170 | metaCheckTimer->stop(); | 172 | metaCheckTimer->stop(); |
171 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); | 173 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); |
172 | break; | 174 | break; |
173 | } | 175 | } |
174 | } | 176 | } |
175 | 177 | ||
176 | void DocTimer::stop(TimerIDs timer) | 178 | void DocTimer::stop(TimerIDs timer) |
177 | { | 179 | { |
178 | switch (timer) { | 180 | switch (timer) { |
179 | case id_mpwTimer: | 181 | case id_mpwTimer: |
180 | mpwTimer->stop(); | 182 | mpwTimer->stop(); |
181 | break; | 183 | break; |
182 | case id_autoLockTimer: | 184 | case id_autoLockTimer: |
183 | autoLockTimer->stop(); | 185 | autoLockTimer->stop(); |
184 | break; | 186 | break; |
185 | case id_metaCheckTimer: | 187 | case id_metaCheckTimer: |
186 | metaCheckTimer->stop(); | 188 | metaCheckTimer->stop(); |
187 | break; | 189 | break; |
188 | } | 190 | } |
189 | } | 191 | } |
190 | 192 | ||
191 | void DocTimer::getLock(TimerIDs timer) | 193 | void DocTimer::getLock(TimerIDs timer) |
192 | { | 194 | { |
193 | switch (timer) { | 195 | switch (timer) { |
194 | case id_mpwTimer: | 196 | case id_mpwTimer: |
195 | ++mpwLock; | 197 | ++mpwLock; |
196 | break; | 198 | break; |
197 | case id_autoLockTimer: | 199 | case id_autoLockTimer: |
198 | ++autoLockLock; | 200 | ++autoLockLock; |
199 | break; | 201 | break; |
200 | case id_metaCheckTimer: | 202 | case id_metaCheckTimer: |
201 | ++metaCheckLock; | 203 | ++metaCheckLock; |
202 | break; | 204 | break; |
203 | } | 205 | } |
204 | } | 206 | } |
205 | 207 | ||
206 | void DocTimer::putLock(TimerIDs timer) | 208 | void DocTimer::putLock(TimerIDs timer) |
207 | { | 209 | { |
208 | switch (timer) { | 210 | switch (timer) { |
209 | case id_mpwTimer: | 211 | case id_mpwTimer: |
210 | if (mpwLock) | 212 | if (mpwLock) |
211 | --mpwLock; | 213 | --mpwLock; |
212 | break; | 214 | break; |
213 | case id_autoLockTimer: | 215 | case id_autoLockTimer: |
214 | if (autoLockLock) | 216 | if (autoLockLock) |
215 | --autoLockLock; | 217 | --autoLockLock; |
216 | break; | 218 | break; |
217 | case id_metaCheckTimer: | 219 | case id_metaCheckTimer: |
218 | if (metaCheckLock) | 220 | if (metaCheckLock) |
219 | --metaCheckLock; | 221 | --metaCheckLock; |
220 | break; | 222 | break; |
221 | } | 223 | } |
222 | } | 224 | } |
223 | 225 | ||
224 | void DocTimer::mpwTimeout() | 226 | void DocTimer::mpwTimeout() |
225 | { | 227 | { |
226 | if (mpwLock) { | 228 | if (mpwLock) { |
227 | mpwTimer->start(1000, true); | 229 | mpwTimer->start(1000, true); |
228 | return; | 230 | return; |
229 | } | 231 | } |
230 | doc->unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); | 232 | doc->unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); |
231 | } | 233 | } |
232 | 234 | ||
233 | void DocTimer::autoLockTimeout() | 235 | void DocTimer::autoLockTimeout() |
234 | { | 236 | { |
235 | if (autoLockLock) { | 237 | if (autoLockLock) { |
236 | autoLockTimer->start(1000, true); | 238 | autoLockTimer->start(1000, true); |
237 | return; | 239 | return; |
238 | } | 240 | } |
239 | if (conf()->confGlobAutoDeepLock() && | 241 | if (conf()->confGlobAutoDeepLock() && |
240 | doc->filename != QString::null && | 242 | doc->filename != QString::null && |
241 | doc->filename != "") { | 243 | doc->filename != "") { |
242 | doc->deepLock(true); | 244 | doc->deepLock(true); |
243 | } else { | 245 | } else { |
244 | doc->lockAll(true); | 246 | doc->lockAll(true); |
245 | } | 247 | } |
246 | } | 248 | } |
247 | 249 | ||
248 | void DocTimer::metaCheckTimeout() | 250 | void DocTimer::metaCheckTimeout() |
249 | { | 251 | { |
250 | if (metaCheckLock) { | 252 | if (metaCheckLock) { |
251 | // check again in one second. | 253 | // check again in one second. |
252 | metaCheckTimer->start(1000, true); | 254 | metaCheckTimer->start(1000, true); |
253 | return; | 255 | return; |
254 | } | 256 | } |
255 | if (doc->isDeepLocked()) { | 257 | if (doc->isDeepLocked()) { |
256 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); | 258 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); |
257 | return; | 259 | return; |
258 | } | 260 | } |
259 | if (doc->isDocEmpty()) { | 261 | if (doc->isDocEmpty()) { |
260 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); | 262 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); |
261 | return; | 263 | return; |
262 | } | 264 | } |
263 | #ifdef CONFIG_KWALLETIF | 265 | #ifdef CONFIG_KWALLETIF |
264 | KWalletEmu *kwlEmu = doc->init->kwalletEmu(); | 266 | KWalletEmu *kwlEmu = doc->init->kwalletEmu(); |
265 | if (kwlEmu) | 267 | if (kwlEmu) |
266 | kwlEmu->suspendDocSignals(); | 268 | kwlEmu->suspendDocSignals(); |
267 | #endif // CONFIG_KWALLETIF | 269 | #endif // CONFIG_KWALLETIF |
268 | /* We simply trigger all views to update their | 270 | /* We simply trigger all views to update their |
269 | * displayed values. This way they have a chance | 271 | * displayed values. This way they have a chance |
270 | * to get notified when some meta changes over time. | 272 | * to get notified when some meta changes over time. |
271 | * (for example an entry expired). | 273 | * (for example an entry expired). |
272 | * The _view_ is responsive for not updating its | 274 | * The _view_ is responsive for not updating its |
273 | * contents if nothing really changed! | 275 | * contents if nothing really changed! |
274 | */ | 276 | */ |
275 | emit doc->dataChanged(doc); | 277 | emit doc->dataChanged(doc); |
276 | #ifdef CONFIG_KWALLETIF | 278 | #ifdef CONFIG_KWALLETIF |
277 | if (kwlEmu) | 279 | if (kwlEmu) |
278 | kwlEmu->resumeDocSignals(); | 280 | kwlEmu->resumeDocSignals(); |
279 | #endif // CONFIG_KWALLETIF | 281 | #endif // CONFIG_KWALLETIF |
280 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); | 282 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); |
281 | } | 283 | } |
282 | 284 | ||
283 | 285 | ||
284 | 286 | ||
285 | PwMDocList PwMDoc::openDocList; | 287 | PwMDocList PwMDoc::openDocList; |
286 | unsigned int PwMDocList::unnamedDocCnt = 1; | 288 | unsigned int PwMDocList::unnamedDocCnt = 1; |
287 | 289 | ||
288 | PwMDoc::PwMDoc(QObject *parent, const char *name) | 290 | PwMDoc::PwMDoc(QObject *parent, const char *name) |
289 | : PwMDocUi(parent, name) | 291 | : PwMDocUi(parent, name) |
290 | , dataChangedLock (0) | 292 | , dataChangedLock (0) |
291 | { | 293 | { |
292 | deleted = false; | 294 | deleted = false; |
293 | unnamedNum = 0; | 295 | unnamedNum = 0; |
294 | getOpenDocList()->add(this, getTitle().latin1()); | 296 | getOpenDocList()->add(this, getTitle().latin1()); |
295 | curDocStat = 0; | 297 | curDocStat = 0; |
296 | setMaxNumEntries(); | 298 | setMaxNumEntries(); |
297 | _timer = new DocTimer(this); | 299 | _timer = new DocTimer(this); |
298 | timer()->start(DocTimer::id_mpwTimer); | 300 | timer()->start(DocTimer::id_mpwTimer); |
299 | timer()->start(DocTimer::id_autoLockTimer); | 301 | timer()->start(DocTimer::id_autoLockTimer); |
300 | timer()->start(DocTimer::id_metaCheckTimer); | 302 | timer()->start(DocTimer::id_metaCheckTimer); |
301 | addCategory(DEFAULT_CATEGORY, 0, false); | 303 | addCategory(DEFAULT_CATEGORY, 0, false); |
302 | listView = 0; | 304 | listView = 0; |
303 | emit docCreated(this); | 305 | emit docCreated(this); |
304 | } | 306 | } |
305 | 307 | ||
306 | PwMDoc::~PwMDoc() | 308 | PwMDoc::~PwMDoc() |
307 | { | 309 | { |
308 | emit docClosed(this); | 310 | emit docClosed(this); |
309 | getOpenDocList()->del(this); | 311 | getOpenDocList()->del(this); |
310 | delete _timer; | 312 | delete _timer; |
311 | } | 313 | } |
312 | 314 | ||
313 | PwMerror PwMDoc::saveDoc(char compress, const QString *file) | 315 | PwMerror PwMDoc::saveDoc(char compress, const QString *file) |
314 | { | 316 | { |
315 | PwMerror ret, e; | 317 | PwMerror ret, e; |
316 | if (!file) { | 318 | if (!file) { |
317 | if (filename == "") | 319 | if (filename == "") |
318 | return e_filename; | 320 | return e_filename; |
319 | } else { | 321 | } else { |
320 | if (*file == "" && filename == "") | 322 | if (*file == "" && filename == "") |
321 | return e_filename; | 323 | return e_filename; |
322 | if (*file != "") | 324 | if (*file != "") |
323 | filename = *file; | 325 | filename = *file; |
324 | } | 326 | } |
325 | 327 | ||
326 | bool wasDeepLocked = isDeepLocked(); | 328 | bool wasDeepLocked = isDeepLocked(); |
327 | if (wasDeepLocked) { | 329 | if (wasDeepLocked) { |
328 | if (deepLock(false) != e_success) | 330 | if (deepLock(false) != e_success) |
329 | return e_noPw; | 331 | return e_noPw; |
330 | } | 332 | } |
331 | 333 | ||
332 | if (!isPwAvailable()) { | 334 | if (!isPwAvailable()) { |
333 | /* password is not available. This means, the | 335 | /* password is not available. This means, the |
334 | * document wasn't saved, yet. | 336 | * document wasn't saved, yet. |
335 | */ | 337 | */ |
336 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); | 338 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); |
337 | QString pw(requestNewMpw(&useChipcard)); | 339 | QString pw(requestNewMpw(&useChipcard)); |
338 | if (pw != "") { | 340 | if (pw != "") { |
339 | currentPw = pw; | 341 | currentPw = pw; |
340 | } else { | 342 | } else { |
341 | return e_noPw; | 343 | return e_noPw; |
342 | } | 344 | } |
343 | if (useChipcard) { | 345 | if (useChipcard) { |
344 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); | 346 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); |
345 | } else { | 347 | } else { |
346 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); | 348 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); |
347 | } | 349 | } |
348 | } | 350 | } |
349 | #ifndef PWM_EMBEDDED | 351 | #ifndef PWM_EMBEDDED |
350 | int _cryptAlgo = conf()->confGlobCryptAlgo(); | 352 | int _cryptAlgo = conf()->confGlobCryptAlgo(); |
351 | int _hashAlgo = conf()->confGlobHashAlgo(); | 353 | int _hashAlgo = conf()->confGlobHashAlgo(); |
352 | #else | 354 | #else |
353 | int _cryptAlgo = PWM_CRYPT_BLOWFISH; | 355 | int _cryptAlgo = PWM_CRYPT_BLOWFISH; |
354 | int _hashAlgo = PWM_HASH_SHA1; | 356 | int _hashAlgo = PWM_HASH_SHA1; |
355 | #endif | 357 | #endif |
356 | 358 | ||
357 | // sanity check for the selected algorithms | 359 | // sanity check for the selected algorithms |
358 | if (_cryptAlgo < PWM_CRYPT_BLOWFISH || | 360 | if (_cryptAlgo < PWM_CRYPT_BLOWFISH || |
359 | _cryptAlgo > PWM_CRYPT_TWOFISH128) { | 361 | _cryptAlgo > PWM_CRYPT_TWOFISH128) { |
360 | printWarn("Invalid Crypto-Algorithm selected! " | 362 | printWarn("Invalid Crypto-Algorithm selected! " |
361 | "Config-file seems to be corrupt. " | 363 | "Config-file seems to be corrupt. " |
362 | "Falling back to Blowfish."); | 364 | "Falling back to Blowfish."); |
363 | _cryptAlgo = PWM_CRYPT_BLOWFISH; | 365 | _cryptAlgo = PWM_CRYPT_BLOWFISH; |
364 | } | 366 | } |
365 | if (_hashAlgo < PWM_HASH_SHA1 || | 367 | if (_hashAlgo < PWM_HASH_SHA1 || |
366 | _hashAlgo > PWM_HASH_TIGER) { | 368 | _hashAlgo > PWM_HASH_TIGER) { |
367 | printWarn("Invalid Hash-Algorithm selected! " | 369 | printWarn("Invalid Hash-Algorithm selected! " |
368 | "Config-file seems to be corrupt. " | 370 | "Config-file seems to be corrupt. " |
369 | "Falling back to SHA1."); | 371 | "Falling back to SHA1."); |
370 | _hashAlgo = PWM_HASH_SHA1; | 372 | _hashAlgo = PWM_HASH_SHA1; |
371 | } | 373 | } |
372 | char cryptAlgo = static_cast<char>(_cryptAlgo); | 374 | char cryptAlgo = static_cast<char>(_cryptAlgo); |
373 | char hashAlgo = static_cast<char>(_hashAlgo); | 375 | char hashAlgo = static_cast<char>(_hashAlgo); |
374 | 376 | ||
375 | if (conf()->confGlobMakeFileBackup()) { | 377 | if (conf()->confGlobMakeFileBackup()) { |
376 | if (!backupFile(filename)) | 378 | if (!backupFile(filename)) |
377 | return e_fileBackup; | 379 | return e_fileBackup; |
378 | } | 380 | } |
379 | QString tmpFileMoved(QString::null); | 381 | QString tmpFileMoved(QString::null); |
380 | if (QFile::exists(filename)) { | 382 | if (QFile::exists(filename)) { |
381 | /* Move the existing file to some tmp file. | 383 | /* Move the existing file to some tmp file. |
382 | * When saving file succeeds, delete tmp file. Otherwise | 384 | * When saving file succeeds, delete tmp file. Otherwise |
383 | * move tmp file back. See below. | 385 | * move tmp file back. See below. |
384 | */ | 386 | */ |
385 | Randomizer *rnd = Randomizer::obj(); | 387 | Randomizer *rnd = Randomizer::obj(); |
386 | char rnd_buf[5]; | 388 | char rnd_buf[5]; |
387 | sprintf(rnd_buf, "%X%X%X%X", rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF, | 389 | sprintf(rnd_buf, "%X%X%X%X", rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF, |
388 | rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF); | 390 | rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF); |
389 | tmpFileMoved = filename + "." + rnd_buf + ".mv"; | 391 | tmpFileMoved = filename + "." + rnd_buf + ".mv"; |
390 | if (!copyFile(filename, tmpFileMoved)) | 392 | if (!copyFile(filename, tmpFileMoved)) |
391 | return e_openFile; | 393 | return e_openFile; |
392 | if (!QFile::remove(filename)) { | 394 | if (!QFile::remove(filename)) { |
393 | printWarn(string("removing orig file ") | 395 | printWarn(string("removing orig file ") |
394 | + filename.latin1() | 396 | + filename.latin1() |
395 | + " failed!"); | 397 | + " failed!"); |
396 | } | 398 | } |
397 | } | 399 | } |
398 | QFile f(filename); | 400 | QFile f(filename); |
399 | string serialized; | 401 | string serialized; |
400 | if (!f.open(IO_ReadWrite)) { | 402 | if (!f.open(IO_ReadWrite)) { |
401 | ret = e_openFile; | 403 | ret = e_openFile; |
402 | goto out_moveback; | 404 | goto out_moveback; |
403 | } | 405 | } |
404 | e = writeFileHeader(hashAlgo, hashAlgo, | 406 | e = writeFileHeader(hashAlgo, hashAlgo, |
405 | cryptAlgo, compress, | 407 | cryptAlgo, compress, |
406 | ¤tPw, &f); | 408 | ¤tPw, &f); |
407 | if (e == e_hashNotImpl) { | 409 | if (e == e_hashNotImpl) { |
408 | printDebug("PwMDoc::saveDoc(): writeFileHeader() failed: e_hashNotImpl"); | 410 | printDebug("PwMDoc::saveDoc(): writeFileHeader() failed: e_hashNotImpl"); |
409 | f.close(); | 411 | f.close(); |
410 | ret = e_hashNotImpl; | 412 | ret = e_hashNotImpl; |
411 | goto out_moveback; | 413 | goto out_moveback; |
412 | } else if (e != e_success) { | 414 | } else if (e != e_success) { |
413 | printDebug("PwMDoc::saveDoc(): writeFileHeader() failed"); | 415 | printDebug("PwMDoc::saveDoc(): writeFileHeader() failed"); |
414 | f.close(); | 416 | f.close(); |
415 | ret = e_writeHeader; | 417 | ret = e_writeHeader; |
416 | goto out_moveback; | 418 | goto out_moveback; |
417 | } | 419 | } |
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index 9650d55..193247e 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h | |||
@@ -1,443 +1,443 @@ | |||
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 2.0 of pwmanager | 14 | * This file is originaly based on version 2.0 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 __PWMDOC_H | 20 | #ifndef __PWMDOC_H |
21 | #define __PWMDOC_H | 21 | #define __PWMDOC_H |
22 | 22 | ||
23 | #define PWM_FILE_VER (static_cast<char>(0x05)) | 23 | #define PWM_FILE_VER (static_cast<char>(0x05)) |
24 | 24 | ||
25 | #define PWM_HASH_SHA1 (static_cast<char>(0x01)) | 25 | #define PWM_HASH_SHA1 (static_cast<char>(0x01)) |
26 | #define PWM_HASH_SHA256 (static_cast<char>(0x02)) | 26 | #define PWM_HASH_SHA256 (static_cast<char>(0x02)) |
27 | #define PWM_HASH_SHA384 (static_cast<char>(0x03)) | 27 | #define PWM_HASH_SHA384 (static_cast<char>(0x03)) |
28 | #define PWM_HASH_SHA512 (static_cast<char>(0x04)) | 28 | #define PWM_HASH_SHA512 (static_cast<char>(0x04)) |
29 | #define PWM_HASH_MD5 (static_cast<char>(0x05)) | 29 | #define PWM_HASH_MD5 (static_cast<char>(0x05)) |
30 | #define PWM_HASH_RMD160 (static_cast<char>(0x06)) | 30 | #define PWM_HASH_RMD160 (static_cast<char>(0x06)) |
31 | #define PWM_HASH_TIGER (static_cast<char>(0x07)) | 31 | #define PWM_HASH_TIGER (static_cast<char>(0x07)) |
32 | 32 | ||
33 | #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) | 33 | #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) |
34 | #define PWM_CRYPT_AES128(static_cast<char>(0x02)) | 34 | #define PWM_CRYPT_AES128(static_cast<char>(0x02)) |
35 | #define PWM_CRYPT_AES192(static_cast<char>(0x03)) | 35 | #define PWM_CRYPT_AES192(static_cast<char>(0x03)) |
36 | #define PWM_CRYPT_AES256(static_cast<char>(0x04)) | 36 | #define PWM_CRYPT_AES256(static_cast<char>(0x04)) |
37 | #define PWM_CRYPT_3DES (static_cast<char>(0x05)) | 37 | #define PWM_CRYPT_3DES (static_cast<char>(0x05)) |
38 | #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) | 38 | #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) |
39 | #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) | 39 | #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) |
40 | 40 | ||
41 | #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) | 41 | #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) |
42 | #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) | 42 | #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) |
43 | #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) | 43 | #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) |
44 | 44 | ||
45 | #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) | 45 | #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) |
46 | #define FILE_ID_HEADER "PWM_PASSWORD_FILE" | 46 | #define FILE_ID_HEADER "PWM_PASSWORD_FILE" |
47 | 47 | ||
48 | 48 | ||
49 | #include "pwmexception.h" | 49 | #include "pwmexception.h" |
50 | #include "pwmdocui.h" | 50 | #include "pwmdocui.h" |
51 | #include "configuration.h" | ||
52 | 51 | ||
53 | #include <qobject.h> | 52 | #include <qobject.h> |
54 | #include <qtimer.h> | 53 | #include <qtimer.h> |
55 | #include <qdatetime.h> | 54 | #include <qdatetime.h> |
56 | 55 | ||
57 | #include <kprocess.h> | 56 | #include <kprocess.h> |
58 | 57 | ||
59 | #ifndef PWM_EMBEDDED | 58 | #ifndef PWM_EMBEDDED |
59 | #include "configuration.h" | ||
60 | #else | 60 | #else |
61 | #include <kapplication.h> | 61 | #include <kapplication.h> |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | #include <string> | 64 | #include <string> |
65 | #include <vector> | 65 | #include <vector> |
66 | #include <utility> | 66 | #include <utility> |
67 | 67 | ||
68 | using std::vector; | 68 | using std::vector; |
69 | using std::string; | 69 | using std::string; |
70 | using std::pair; | 70 | using std::pair; |
71 | 71 | ||
72 | /* used in findEntry() function */ | 72 | /* used in findEntry() function */ |
73 | #define SEARCH_IN_DESC (1) | 73 | #define SEARCH_IN_DESC (1) |
74 | #define SEARCH_IN_NAME (1 << 1) | 74 | #define SEARCH_IN_NAME (1 << 1) |
75 | #define SEARCH_IN_PW (1 << 2) | 75 | #define SEARCH_IN_PW (1 << 2) |
76 | #define SEARCH_IN_COMMENT(1 << 3) | 76 | #define SEARCH_IN_COMMENT(1 << 3) |
77 | #define SEARCH_IN_URL (1 << 4) | 77 | #define SEARCH_IN_URL (1 << 4) |
78 | #define SEARCH_IN_LAUNCHER(1 << 5) | 78 | #define SEARCH_IN_LAUNCHER(1 << 5) |
79 | #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ | 79 | #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ |
80 | SEARCH_IN_PW | SEARCH_IN_COMMENT| \ | 80 | SEARCH_IN_PW | SEARCH_IN_COMMENT| \ |
81 | SEARCH_IN_URL| SEARCH_IN_LAUNCHER) | 81 | SEARCH_IN_URL| SEARCH_IN_LAUNCHER) |
82 | 82 | ||
83 | /** document deeplocked. Data is out for lunch to disk */ | 83 | /** document deeplocked. Data is out for lunch to disk */ |
84 | #define DOC_STAT_DEEPLOCKED (1) | 84 | #define DOC_STAT_DEEPLOCKED (1) |
85 | /** encrypted document on disk is dirty. data has to go to disk. */ | 85 | /** encrypted document on disk is dirty. data has to go to disk. */ |
86 | #define DOC_STAT_DISK_DIRTY (1 << 1) | 86 | #define DOC_STAT_DISK_DIRTY (1 << 1) |
87 | /** we are using a chipcard to encrypt the data */ | 87 | /** we are using a chipcard to encrypt the data */ |
88 | #define DOC_STAT_USE_CHIPCARD (1 << 2) | 88 | #define DOC_STAT_USE_CHIPCARD (1 << 2) |
89 | /** use "currentPw" to unlock. (This flag is set/unset by a timer) */ | 89 | /** use "currentPw" to unlock. (This flag is set/unset by a timer) */ |
90 | #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) | 90 | #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) |
91 | 91 | ||
92 | class PwMDoc; | 92 | class PwMDoc; |
93 | class PwMView; | 93 | class PwMView; |
94 | class QFile; | 94 | class QFile; |
95 | 95 | ||
96 | /* meta data for a PwMDataItem */ | 96 | /* meta data for a PwMDataItem */ |
97 | struct PwMMetaData | 97 | struct PwMMetaData |
98 | { | 98 | { |
99 | PwMMetaData() | 99 | PwMMetaData() |
100 | : updateInt (0) | 100 | : updateInt (0) |
101 | { } | 101 | { } |
102 | /** creation date of the PwMDataItem to which | 102 | /** creation date of the PwMDataItem to which |
103 | * this meta data belongs. | 103 | * this meta data belongs. |
104 | */ | 104 | */ |
105 | QDateTimecreate; | 105 | QDateTimecreate; |
106 | /** becomes valid on this date */ | 106 | /** becomes valid on this date */ |
107 | QDateTimevalid; | 107 | QDateTimevalid; |
108 | /** expire date */ | 108 | /** expire date */ |
109 | QDateTimeexpire; | 109 | QDateTimeexpire; |
110 | /** update date (last updated at this date) */ | 110 | /** update date (last updated at this date) */ |
111 | QDateTimeupdate; | 111 | QDateTimeupdate; |
112 | /** update interval (in minutes). Time since the | 112 | /** update interval (in minutes). Time since the |
113 | * last update to remind the user to update the item. | 113 | * last update to remind the user to update the item. |
114 | * 0 disables. | 114 | * 0 disables. |
115 | */ | 115 | */ |
116 | unsigned long updateInt; | 116 | unsigned long updateInt; |
117 | 117 | ||
118 | //US ENH: enhancements of the filestructure | 118 | //US ENH: enhancements of the filestructure |
119 | /* each entry gets a unique id assigned */ | 119 | /* each entry gets a unique id assigned */ |
120 | QString uniqueid; | 120 | QString uniqueid; |
121 | 121 | ||
122 | 122 | ||
123 | void clear() | 123 | void clear() |
124 | { | 124 | { |
125 | create = QDateTime(); | 125 | create = QDateTime(); |
126 | expire = QDateTime(); | 126 | expire = QDateTime(); |
127 | update = QDateTime(); | 127 | update = QDateTime(); |
128 | updateInt = 0; | 128 | updateInt = 0; |
129 | uniqueid = KApplication::randomString(8); | 129 | uniqueid = KApplication::randomString(8); |
130 | } | 130 | } |
131 | inline bool isValid() const | 131 | inline bool isValid() const |
132 | { | 132 | { |
133 | if (valid.isNull()) | 133 | if (valid.isNull()) |
134 | return true; | 134 | return true; |
135 | return (valid < QDateTime::currentDateTime()); | 135 | return (valid < QDateTime::currentDateTime()); |
136 | } | 136 | } |
137 | inline bool isExpired() const | 137 | inline bool isExpired() const |
138 | { | 138 | { |
139 | if (expire.isNull()) | 139 | if (expire.isNull()) |
140 | return false; | 140 | return false; |
141 | return (expire < QDateTime::currentDateTime()); | 141 | return (expire < QDateTime::currentDateTime()); |
142 | } | 142 | } |
143 | inline bool isUpdateIntOver() const | 143 | inline bool isUpdateIntOver() const |
144 | { | 144 | { |
145 | if (updateInt == 0 || | 145 | if (updateInt == 0 || |
146 | update.isNull()) | 146 | update.isNull()) |
147 | return false; | 147 | return false; |
148 | QDateTime d(update); | 148 | QDateTime d(update); |
149 | return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); | 149 | return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); |
150 | } | 150 | } |
151 | }; | 151 | }; |
152 | 152 | ||
153 | struct PwMDataItem | 153 | struct PwMDataItem |
154 | { | 154 | { |
155 | PwMDataItem() | 155 | PwMDataItem() |
156 | : lockStat (true) | 156 | : lockStat (true) |
157 | , listViewPos (-1) | 157 | , listViewPos (-1) |
158 | , binary (false) | 158 | , binary (false) |
159 | , rev (0) | 159 | , rev (0) |
160 | { } | 160 | { } |
161 | 161 | ||
162 | /** password description */ | 162 | /** password description */ |
163 | stringdesc; | 163 | stringdesc; |
164 | /** user-name */ | 164 | /** user-name */ |
165 | stringname; | 165 | stringname; |
166 | /** the password itself */ | 166 | /** the password itself */ |
167 | stringpw; | 167 | stringpw; |
168 | /** some comment */ | 168 | /** some comment */ |
169 | stringcomment; | 169 | stringcomment; |
170 | /** an URL string */ | 170 | /** an URL string */ |
171 | stringurl; | 171 | stringurl; |
172 | /** launcher. Can be executed as a system() command */ | 172 | /** launcher. Can be executed as a system() command */ |
173 | stringlauncher; | 173 | stringlauncher; |
174 | /** locking status. If locked (true), pw is not emitted through getEntry() */ | 174 | /** locking status. If locked (true), pw is not emitted through getEntry() */ |
175 | boollockStat; | 175 | boollockStat; |
176 | /** position of this item in main "list-view" | 176 | /** position of this item in main "list-view" |
177 | * If -1, the position is not yet specified and should be appended to the list | 177 | * If -1, the position is not yet specified and should be appended to the list |
178 | */ | 178 | */ |
179 | intlistViewPos; | 179 | intlistViewPos; |
180 | /** does this entry contain binary data? */ | 180 | /** does this entry contain binary data? */ |
181 | bool binary; | 181 | bool binary; |
182 | /** meta data for this data item. */ | 182 | /** meta data for this data item. */ |
183 | PwMMetaData meta; | 183 | PwMMetaData meta; |
184 | /** data revision counter. This counter can be used | 184 | /** data revision counter. This counter can be used |
185 | * to easily, efficiently determine if this data item | 185 | * to easily, efficiently determine if this data item |
186 | * has changed since some time. | 186 | * has changed since some time. |
187 | * This counter is incremented on every update. | 187 | * This counter is incremented on every update. |
188 | */ | 188 | */ |
189 | unsigned int rev; | 189 | unsigned int rev; |
190 | 190 | ||
191 | void clear(bool clearMeta = true) | 191 | void clear(bool clearMeta = true) |
192 | { | 192 | { |
193 | /* NOTE: Don't use .clear() here to be | 193 | /* NOTE: Don't use .clear() here to be |
194 | * backward compatible with gcc-2 (Debian Woody) | 194 | * backward compatible with gcc-2 (Debian Woody) |
195 | */ | 195 | */ |
196 | desc = ""; | 196 | desc = ""; |
197 | name = ""; | 197 | name = ""; |
198 | pw = ""; | 198 | pw = ""; |
199 | comment = ""; | 199 | comment = ""; |
200 | url = ""; | 200 | url = ""; |
201 | launcher = ""; | 201 | launcher = ""; |
202 | lockStat = true; | 202 | lockStat = true; |
203 | listViewPos = -1; | 203 | listViewPos = -1; |
204 | binary = false; | 204 | binary = false; |
205 | if (clearMeta) | 205 | if (clearMeta) |
206 | meta.clear(); | 206 | meta.clear(); |
207 | } | 207 | } |
208 | }; | 208 | }; |
209 | 209 | ||
210 | struct PwMCategoryItem | 210 | struct PwMCategoryItem |
211 | { | 211 | { |
212 | /** all PwMDataItems (all passwords) within this category */ | 212 | /** all PwMDataItems (all passwords) within this category */ |
213 | vector<PwMDataItem>d; | 213 | vector<PwMDataItem>d; |
214 | /** category name/description */ | 214 | /** category name/description */ |
215 | string name; | 215 | string name; |
216 | 216 | ||
217 | void clear() | 217 | void clear() |
218 | { | 218 | { |
219 | d.clear(); | 219 | d.clear(); |
220 | name = ""; | 220 | name = ""; |
221 | } | 221 | } |
222 | }; | 222 | }; |
223 | 223 | ||
224 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ | 224 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ |
225 | class dta_lvp_greater | 225 | class dta_lvp_greater |
226 | { | 226 | { |
227 | public: | 227 | public: |
228 | bool operator() (const pair<unsigned int, unsigned int> &d1, | 228 | bool operator() (const pair<unsigned int, unsigned int> &d1, |
229 | const pair<unsigned int, unsigned int> &d2) | 229 | const pair<unsigned int, unsigned int> &d2) |
230 | { | 230 | { |
231 | return d1.second > d2.second; | 231 | return d1.second > d2.second; |
232 | } | 232 | } |
233 | }; | 233 | }; |
234 | 234 | ||
235 | /** list of PwMDoc documents and it's IDs */ | 235 | /** list of PwMDoc documents and it's IDs */ |
236 | class PwMDocList | 236 | class PwMDocList |
237 | { | 237 | { |
238 | public: | 238 | public: |
239 | struct listItem | 239 | struct listItem |
240 | { | 240 | { |
241 | /** document filename (known as ID, here) */ | 241 | /** document filename (known as ID, here) */ |
242 | string docId; | 242 | string docId; |
243 | /** pointer to the document class */ | 243 | /** pointer to the document class */ |
244 | PwMDoc *doc; | 244 | PwMDoc *doc; |
245 | }; | 245 | }; |
246 | 246 | ||
247 | PwMDocList() {} | 247 | PwMDocList() {} |
248 | 248 | ||
249 | /** add a new item to the list */ | 249 | /** add a new item to the list */ |
250 | void add(PwMDoc *doc, const string &id); | 250 | void add(PwMDoc *doc, const string &id); |
251 | /** changes the contents of an existing item */ | 251 | /** changes the contents of an existing item */ |
252 | void edit(PwMDoc *doc, const string &newId); | 252 | void edit(PwMDoc *doc, const string &newId); |
253 | /** remove the given item */ | 253 | /** remove the given item */ |
254 | void del(PwMDoc *doc); | 254 | void del(PwMDoc *doc); |
255 | /** get the item at index */ | 255 | /** get the item at index */ |
256 | listItem getAt(int index) | 256 | listItem getAt(int index) |
257 | { return docList[index]; } | 257 | { return docList[index]; } |
258 | /** find an entry with this id */ | 258 | /** find an entry with this id */ |
259 | bool find(const string &id, listItem *ret = 0); | 259 | bool find(const string &id, listItem *ret = 0); |
260 | /** returns a copy of the list */ | 260 | /** returns a copy of the list */ |
261 | const vector<listItem>* getList() const | 261 | const vector<listItem>* getList() const |
262 | { return &docList; } | 262 | { return &docList; } |
263 | 263 | ||
264 | 264 | ||
265 | /** returns a new unique number to extend the name of | 265 | /** returns a new unique number to extend the name of |
266 | * an unnamed document. | 266 | * an unnamed document. |
267 | */ | 267 | */ |
268 | static unsigned int getNewUnnamedNumber() | 268 | static unsigned int getNewUnnamedNumber() |
269 | { return unnamedDocCnt++; } | 269 | { return unnamedDocCnt++; } |
270 | 270 | ||
271 | protected: | 271 | protected: |
272 | /* Hm, I think we shouldn't really use a "list" here, should we? | 272 | /* Hm, I think we shouldn't really use a "list" here, should we? |
273 | * So I decided to actually use a vector. | 273 | * So I decided to actually use a vector. |
274 | */ | 274 | */ |
275 | vector<listItem> docList; | 275 | vector<listItem> docList; |
276 | /** This value is used to get a new number for yet unnamed | 276 | /** This value is used to get a new number for yet unnamed |
277 | * documents. It is incremented on every request. So it's | 277 | * documents. It is incremented on every request. So it's |
278 | * theoretically possible to overflow it, but... :) | 278 | * theoretically possible to overflow it, but... :) |
279 | */ | 279 | */ |
280 | static unsigned int unnamedDocCnt; | 280 | static unsigned int unnamedDocCnt; |
281 | }; | 281 | }; |
282 | 282 | ||
283 | /** implements timers for the document */ | 283 | /** implements timers for the document */ |
284 | class DocTimer : public QObject | 284 | class DocTimer : public QObject |
285 | { | 285 | { |
286 | Q_OBJECT | 286 | Q_OBJECT |
287 | public: | 287 | public: |
288 | enum TimerIDs | 288 | enum TimerIDs |
289 | { | 289 | { |
290 | id_mpwTimer, | 290 | id_mpwTimer, |
291 | id_autoLockTimer, | 291 | id_autoLockTimer, |
292 | id_metaCheckTimer | 292 | id_metaCheckTimer |
293 | }; | 293 | }; |
294 | 294 | ||
295 | public: | 295 | public: |
296 | DocTimer(PwMDoc *_doc); | 296 | DocTimer(PwMDoc *_doc); |
297 | ~DocTimer(); | 297 | ~DocTimer(); |
298 | 298 | ||
299 | /** start the timer */ | 299 | /** start the timer */ |
300 | void start(TimerIDs timer); | 300 | void start(TimerIDs timer); |
301 | /** stop the timer */ | 301 | /** stop the timer */ |
302 | void stop(TimerIDs timer); | 302 | void stop(TimerIDs timer); |
303 | /** get the lock for a timer. | 303 | /** get the lock for a timer. |
304 | * This lock is a recursive lock. When a lock is | 304 | * This lock is a recursive lock. When a lock is |
305 | * held, the timer will be stopped and timeout is | 305 | * held, the timer will be stopped and timeout is |
306 | * guaranteed to not happen | 306 | * guaranteed to not happen |
307 | */ | 307 | */ |
308 | void getLock(TimerIDs timer); | 308 | void getLock(TimerIDs timer); |
309 | /** put a recursive timer lock */ | 309 | /** put a recursive timer lock */ |
310 | void putLock(TimerIDs timer); | 310 | void putLock(TimerIDs timer); |
311 | 311 | ||
312 | protected slots: | 312 | protected slots: |
313 | /** timeout slot for the mpw timer */ | 313 | /** timeout slot for the mpw timer */ |
314 | void mpwTimeout(); | 314 | void mpwTimeout(); |
315 | /** timeout slot for the autoLock timer */ | 315 | /** timeout slot for the autoLock timer */ |
316 | void autoLockTimeout(); | 316 | void autoLockTimeout(); |
317 | /** timeout slot for the metaCheck timer */ | 317 | /** timeout slot for the metaCheck timer */ |
318 | void metaCheckTimeout(); | 318 | void metaCheckTimeout(); |
319 | 319 | ||
320 | protected: | 320 | protected: |
321 | /** pointer to the document associated with this timer. */ | 321 | /** pointer to the document associated with this timer. */ |
322 | PwMDoc *doc; | 322 | PwMDoc *doc; |
323 | /** timer object for mpw timer */ | 323 | /** timer object for mpw timer */ |
324 | QTimer *mpwTimer; | 324 | QTimer *mpwTimer; |
325 | /** timer object for the autoLock timer */ | 325 | /** timer object for the autoLock timer */ |
326 | QTimer *autoLockTimer; | 326 | QTimer *autoLockTimer; |
327 | /** timer object for the metaCheck timer */ | 327 | /** timer object for the metaCheck timer */ |
328 | QTimer *metaCheckTimer; | 328 | QTimer *metaCheckTimer; |
329 | /** lock counter for the mpw timer */ | 329 | /** lock counter for the mpw timer */ |
330 | unsigned int mpwLock; | 330 | unsigned int mpwLock; |
331 | /** lock counter for the autoLock timer */ | 331 | /** lock counter for the autoLock timer */ |
332 | unsigned int autoLockLock; | 332 | unsigned int autoLockLock; |
333 | /** lock counter for the metaCheck timer */ | 333 | /** lock counter for the metaCheck timer */ |
334 | unsigned int metaCheckLock; | 334 | unsigned int metaCheckLock; |
335 | }; | 335 | }; |
336 | 336 | ||
337 | /** Document class for PwM */ | 337 | /** Document class for PwM */ |
338 | class PwMDoc : public PwMDocUi | 338 | class PwMDoc : public PwMDocUi |
339 | { | 339 | { |
340 | Q_OBJECT | 340 | Q_OBJECT |
341 | friend class DocTimer; | 341 | friend class DocTimer; |
342 | 342 | ||
343 | public: | 343 | public: |
344 | /** construtor */ | 344 | /** construtor */ |
345 | PwMDoc(QObject* parent = 0, const char *name = 0); | 345 | PwMDoc(QObject* parent = 0, const char *name = 0); |
346 | /** destructor */ | 346 | /** destructor */ |
347 | ~PwMDoc(); | 347 | ~PwMDoc(); |
348 | 348 | ||
349 | /** returns a pointer to a list of all open documents */ | 349 | /** returns a pointer to a list of all open documents */ |
350 | static PwMDocList* getOpenDocList() | 350 | static PwMDocList* getOpenDocList() |
351 | { return &openDocList; } | 351 | { return &openDocList; } |
352 | 352 | ||
353 | /** flag document dirty. dta changed */ | 353 | /** flag document dirty. dta changed */ |
354 | void flagDirty() | 354 | void flagDirty() |
355 | { | 355 | { |
356 | setDocStatFlag(DOC_STAT_DISK_DIRTY); | 356 | setDocStatFlag(DOC_STAT_DISK_DIRTY); |
357 | emitDataChanged(this); | 357 | emitDataChanged(this); |
358 | } | 358 | } |
359 | /** modified? */ | 359 | /** modified? */ |
360 | bool isDirty() | 360 | bool isDirty() |
361 | { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } | 361 | { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } |
362 | /** save document to disk */ | 362 | /** save document to disk */ |
363 | PwMerror saveDoc(char compress, const QString *file = 0); | 363 | PwMerror saveDoc(char compress, const QString *file = 0); |
364 | /** read document from file. | 364 | /** read document from file. |
365 | * "openLocked is must be set to either of these values: | 365 | * "openLocked is must be set to either of these values: |
366 | * 0 == open with all entries unlocked | 366 | * 0 == open with all entries unlocked |
367 | * 1 == open with all entries locked | 367 | * 1 == open with all entries locked |
368 | * 2 == open deep-locked | 368 | * 2 == open deep-locked |
369 | */ | 369 | */ |
370 | PwMerror openDoc(const QString *file, int openLocked); | 370 | PwMerror openDoc(const QString *file, int openLocked); |
371 | /** export document to ascii-textfile */ | 371 | /** export document to ascii-textfile */ |
372 | PwMerror exportToText(const QString *file); | 372 | PwMerror exportToText(const QString *file); |
373 | /** export document to gpasman / kpasman file */ | 373 | /** export document to gpasman / kpasman file */ |
374 | PwMerror exportToGpasman(const QString *file); | 374 | PwMerror exportToGpasman(const QString *file); |
375 | /** import document from ascii-textfile */ | 375 | /** import document from ascii-textfile */ |
376 | PwMerror importFromText(const QString *file, int format = -1); | 376 | PwMerror importFromText(const QString *file, int format = -1); |
377 | /** import document from gpasman / kpasman file */ | 377 | /** import document from gpasman / kpasman file */ |
378 | PwMerror importFromGpasman(const QString *file); | 378 | PwMerror importFromGpasman(const QString *file); |
379 | /** add new entry */ | 379 | /** add new entry */ |
380 | PwMerror addEntry(const QString &category, PwMDataItem *d, | 380 | PwMerror addEntry(const QString &category, PwMDataItem *d, |
381 | bool dontFlagDirty = false, bool updateMeta = true); | 381 | bool dontFlagDirty = false, bool updateMeta = true); |
382 | /** add new category. This function doesn't flag the document dirty! */ | 382 | /** add new category. This function doesn't flag the document dirty! */ |
383 | PwMerror addCategory(const QString &category, unsigned int *categoryIndex, | 383 | PwMerror addCategory(const QString &category, unsigned int *categoryIndex, |
384 | bool checkIfExist = true); | 384 | bool checkIfExist = true); |
385 | /** rename an existing category */ | 385 | /** rename an existing category */ |
386 | bool renameCategory(const QString &category, const QString &newName); | 386 | bool renameCategory(const QString &category, const QString &newName); |
387 | /** rename an existing category */ | 387 | /** rename an existing category */ |
388 | bool renameCategory(unsigned int category, const QString &newName, | 388 | bool renameCategory(unsigned int category, const QString &newName, |
389 | bool dontFlagDirty = false); | 389 | bool dontFlagDirty = false); |
390 | /** delete an existing category */ | 390 | /** delete an existing category */ |
391 | bool delCategory(const QString &category); | 391 | bool delCategory(const QString &category); |
392 | /** delete an existing category */ | 392 | /** delete an existing category */ |
393 | bool delCategory(unsigned int category, bool dontFlagDirty = false); | 393 | bool delCategory(unsigned int category, bool dontFlagDirty = false); |
394 | /** returns a list of all category-names */ | 394 | /** returns a list of all category-names */ |
395 | void getCategoryList(vector<string> *list); | 395 | void getCategoryList(vector<string> *list); |
396 | /** returns a list of all category-names */ | 396 | /** returns a list of all category-names */ |
397 | void getCategoryList(QStringList *list); | 397 | void getCategoryList(QStringList *list); |
398 | /** returns a list of all entry-descs in the given category */ | 398 | /** returns a list of all entry-descs in the given category */ |
399 | void getEntryList(const QString &category, QStringList *list); | 399 | void getEntryList(const QString &category, QStringList *list); |
400 | /** returns a list of all entry-descs in the given category */ | 400 | /** returns a list of all entry-descs in the given category */ |
401 | void getEntryList(const QString &category, vector<string> *list); | 401 | void getEntryList(const QString &category, vector<string> *list); |
402 | /** returns a list of all entry-descs in the given category */ | 402 | /** returns a list of all entry-descs in the given category */ |
403 | void getEntryList(unsigned int category, vector<string> *list); | 403 | void getEntryList(unsigned int category, vector<string> *list); |
404 | /** returns a list of all entry-descs in the given category */ | 404 | /** returns a list of all entry-descs in the given category */ |
405 | void getEntryList(unsigned int category, QStringList *list); | 405 | void getEntryList(unsigned int category, QStringList *list); |
406 | /** delete entry */ | 406 | /** delete entry */ |
407 | bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); | 407 | bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); |
408 | /** delete entry */ | 408 | /** delete entry */ |
409 | bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); | 409 | bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); |
410 | /** edit entry */ | 410 | /** edit entry */ |
411 | bool editEntry(const QString &oldCategory, const QString &newCategory, | 411 | bool editEntry(const QString &oldCategory, const QString &newCategory, |
412 | unsigned int index, PwMDataItem *d, bool updateMeta = true); | 412 | unsigned int index, PwMDataItem *d, bool updateMeta = true); |
413 | /** edit entry */ | 413 | /** edit entry */ |
414 | bool editEntry(unsigned int oldCategory, const QString &newCategory, | 414 | bool editEntry(unsigned int oldCategory, const QString &newCategory, |
415 | unsigned int index, PwMDataItem *d, bool updateMeta = true); | 415 | unsigned int index, PwMDataItem *d, bool updateMeta = true); |
416 | /** finds the category with the "name" and return it's index */ | 416 | /** finds the category with the "name" and return it's index */ |
417 | bool findCategory(const QString &name, unsigned int *index); | 417 | bool findCategory(const QString &name, unsigned int *index); |
418 | /** search for an entry "find" and check while searching only for | 418 | /** search for an entry "find" and check while searching only for |
419 | * the data-fields specified by "searchIn". To set the "searchIn" | 419 | * the data-fields specified by "searchIn". To set the "searchIn" |
420 | * value, we may use one or more of the SEARCH_IN_* defines at | 420 | * value, we may use one or more of the SEARCH_IN_* defines at |
421 | * the top of this header-file. It returns the positions of all | 421 | * the top of this header-file. It returns the positions of all |
422 | * matched entries in "foundPositions". If "breakAfterFound" is true, | 422 | * matched entries in "foundPositions". If "breakAfterFound" is true, |
423 | * the function terminates after the first occurence of the entry | 423 | * the function terminates after the first occurence of the entry |
424 | * and doesn't go on searching. So foundPositions->size() is never | 424 | * and doesn't go on searching. So foundPositions->size() is never |
425 | * > 1 if breakAfterFound is true. | 425 | * > 1 if breakAfterFound is true. |
426 | */ | 426 | */ |
427 | void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, | 427 | void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, |
428 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, | 428 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, |
429 | bool caseSensitive = true, bool exactWordMatch = true, | 429 | bool caseSensitive = true, bool exactWordMatch = true, |
430 | bool sortByLvp = false); | 430 | bool sortByLvp = false); |
431 | /** see the above funtion. This function allows to set the category by name. */ | 431 | /** see the above funtion. This function allows to set the category by name. */ |
432 | void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, | 432 | void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, |
433 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, | 433 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, |
434 | bool caseSensitive = true, bool exactWordMatch = true, | 434 | bool caseSensitive = true, bool exactWordMatch = true, |
435 | bool sortByLvp = false); | 435 | bool sortByLvp = false); |
436 | /** returns number of entries */ | 436 | /** returns number of entries */ |
437 | unsigned int numEntries(const QString &category); | 437 | unsigned int numEntries(const QString &category); |
438 | unsigned int numEntries(unsigned int category) | 438 | unsigned int numEntries(unsigned int category) |
439 | { return dta[category].d.size(); } | 439 | { return dta[category].d.size(); } |
440 | /** returns number of categories */ | 440 | /** returns number of categories */ |
441 | unsigned int numCategories() | 441 | unsigned int numCategories() |
442 | { return dta.size(); } | 442 | { return dta.size(); } |
443 | /** returns the name of the category at "index" */ | 443 | /** returns the name of the category at "index" */ |
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp index b308b40..3993fa8 100644 --- a/pwmanager/pwmanager/pwmdocui.cpp +++ b/pwmanager/pwmanager/pwmdocui.cpp | |||
@@ -1,422 +1,423 @@ | |||
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 | #endif | 40 | #endif |
40 | 41 | ||
41 | 42 | ||
42 | #ifdef CONFIG_KEYCARD | 43 | #ifdef CONFIG_KEYCARD |
43 | # include "pwmkeycard.h" | 44 | # include "pwmkeycard.h" |
44 | #endif | 45 | #endif |
45 | 46 | ||
46 | 47 | ||
47 | PwMDocUi::PwMDocUi(QObject *parent, const char *name) | 48 | PwMDocUi::PwMDocUi(QObject *parent, const char *name) |
48 | : QObject(parent, name) | 49 | : QObject(parent, name) |
49 | { | 50 | { |
50 | currentView = 0; | 51 | currentView = 0; |
51 | keyCard = 0; | 52 | keyCard = 0; |
52 | } | 53 | } |
53 | 54 | ||
54 | PwMDocUi::~PwMDocUi() | 55 | PwMDocUi::~PwMDocUi() |
55 | { | 56 | { |
56 | } | 57 | } |
57 | 58 | ||
58 | QString PwMDocUi::requestMpw(bool chipcard) | 59 | QString PwMDocUi::requestMpw(bool chipcard) |
59 | { | 60 | { |
60 | QString pw; | 61 | QString pw; |
61 | 62 | ||
62 | if (chipcard) { | 63 | if (chipcard) { |
63 | #ifdef CONFIG_KEYCARD | 64 | #ifdef CONFIG_KEYCARD |
64 | PWM_ASSERT(keyCard); | 65 | PWM_ASSERT(keyCard); |
65 | uint32_t id; | 66 | uint32_t id; |
66 | string ret; | 67 | string ret; |
67 | SpinForSignal *spinner = keyCard->getSpinner(); | 68 | SpinForSignal *spinner = keyCard->getSpinner(); |
68 | connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), | 69 | connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), |
69 | spinner, SLOT(u32_str_slot(uint32_t, const string &))); | 70 | spinner, SLOT(u32_str_slot(uint32_t, const string &))); |
70 | keyCard->getKey(); | 71 | keyCard->getKey(); |
71 | spinner->spin(&id, &ret); | 72 | spinner->spin(&id, &ret); |
72 | disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), | 73 | disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), |
73 | spinner, SLOT(u32_str_slot(uint32_t, const string &))); | 74 | spinner, SLOT(u32_str_slot(uint32_t, const string &))); |
74 | if (ret == "") | 75 | if (ret == "") |
75 | return ""; | 76 | return ""; |
76 | pw = ret.c_str(); | 77 | pw = ret.c_str(); |
77 | #else // CONFIG_KEYCARD | 78 | #else // CONFIG_KEYCARD |
78 | no_keycard_support_msg_box(currentView); | 79 | no_keycard_support_msg_box(currentView); |
79 | #endif // CONFIG_KEYCARD | 80 | #endif // CONFIG_KEYCARD |
80 | } else { | 81 | } else { |
81 | GetMasterPwWndImpl pwWnd; | 82 | GetMasterPwWndImpl pwWnd; |
82 | #ifndef PWM_EMBEDDED | 83 | #ifndef PWM_EMBEDDED |
83 | KWin::setState(pwWnd.winId(), NET::StaysOnTop); | 84 | KWin::setState(pwWnd.winId(), NET::StaysOnTop); |
84 | #endif | 85 | #endif |
85 | if (pwWnd.exec() != 1) | 86 | if (pwWnd.exec() != 1) |
86 | return ""; | 87 | return ""; |
87 | pw = pwWnd.pwLineEdit->text(); | 88 | pw = pwWnd.pwLineEdit->text(); |
88 | } | 89 | } |
89 | 90 | ||
90 | return pw; | 91 | return pw; |
91 | } | 92 | } |
92 | 93 | ||
93 | QString PwMDocUi::requestNewMpw(bool *chipcard) | 94 | QString PwMDocUi::requestNewMpw(bool *chipcard) |
94 | { | 95 | { |
95 | QString pw; | 96 | QString pw; |
96 | SetMasterPwWndImpl pwWnd(currentView); | 97 | SetMasterPwWndImpl pwWnd(currentView); |
97 | pwWnd.setPwMKeyCard(keyCard); | 98 | pwWnd.setPwMKeyCard(keyCard); |
98 | #ifndef PWM_EMBEDDED | 99 | #ifndef PWM_EMBEDDED |
99 | if (!chipcard) { | 100 | if (!chipcard) { |
100 | pwWnd.mainTab->removePage(pwWnd.mainTab->page(1)); | 101 | pwWnd.mainTab->removePage(pwWnd.mainTab->page(1)); |
101 | } | 102 | } |
102 | #else | 103 | #else |
103 | qDebug("PwMDocUi::requestNewMpw must be implemented"); | 104 | qDebug("PwMDocUi::requestNewMpw must be implemented"); |
104 | #endif | 105 | #endif |
105 | 106 | ||
106 | if (pwWnd.exec() != 1) | 107 | if (pwWnd.exec() != 1) |
107 | return ""; | 108 | return ""; |
108 | pw = pwWnd.getPw(chipcard).c_str(); | 109 | pw = pwWnd.getPw(chipcard).c_str(); |
109 | 110 | ||
110 | return pw; | 111 | return pw; |
111 | } | 112 | } |
112 | 113 | ||
113 | QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard) | 114 | QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard) |
114 | { | 115 | { |
115 | QString pw(requestMpw(*chipcard)); | 116 | QString pw(requestMpw(*chipcard)); |
116 | if (pw == "") | 117 | if (pw == "") |
117 | return ""; | 118 | return ""; |
118 | if (pw != *currentPw) { | 119 | if (pw != *currentPw) { |
119 | wrongMpwMsgBox(*chipcard); | 120 | wrongMpwMsgBox(*chipcard); |
120 | return ""; | 121 | return ""; |
121 | } | 122 | } |
122 | 123 | ||
123 | pw = requestNewMpw(chipcard); | 124 | pw = requestNewMpw(chipcard); |
124 | if (pw == "") | 125 | if (pw == "") |
125 | return ""; | 126 | return ""; |
126 | return pw; | 127 | return pw; |
127 | } | 128 | } |
128 | 129 | ||
129 | void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix) | 130 | void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix) |
130 | { | 131 | { |
131 | QString msg; | 132 | QString msg; |
132 | if (prefix != "") { | 133 | if (prefix != "") { |
133 | msg += prefix; | 134 | msg += prefix; |
134 | msg += "\n"; | 135 | msg += "\n"; |
135 | } | 136 | } |
136 | 137 | ||
137 | if (chipcard) { | 138 | if (chipcard) { |
138 | msg += i18n("Wrong key-card!\n" | 139 | msg += i18n("Wrong key-card!\n" |
139 | "Please try again with the " | 140 | "Please try again with the " |
140 | "correct key-card."); | 141 | "correct key-card."); |
141 | } else { | 142 | } else { |
142 | msg += i18n("Wrong master-password!\n" | 143 | msg += i18n("Wrong master-password!\n" |
143 | "Please try again."); | 144 | "Please try again."); |
144 | } | 145 | } |
145 | 146 | ||
146 | if (postfix != "") { | 147 | if (postfix != "") { |
147 | msg += "\n"; | 148 | msg += "\n"; |
148 | msg += postfix; | 149 | msg += postfix; |
149 | } | 150 | } |
150 | KMessageBox::error(currentView, msg, | 151 | KMessageBox::error(currentView, msg, |
151 | (chipcard) ? (i18n("wrong chipcard")) | 152 | (chipcard) ? (i18n("wrong chipcard")) |
152 | : (i18n("password error"))); | 153 | : (i18n("password error"))); |
153 | } | 154 | } |
154 | 155 | ||
155 | void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix) | 156 | void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix) |
156 | { | 157 | { |
157 | QString msg; | 158 | QString msg; |
158 | if (prefix != "") { | 159 | if (prefix != "") { |
159 | msg += prefix; | 160 | msg += prefix; |
160 | msg += "\n"; | 161 | msg += "\n"; |
161 | } | 162 | } |
162 | 163 | ||
163 | if (chipcard) { | 164 | if (chipcard) { |
164 | msg += i18n("No key-card found!\n" | 165 | msg += i18n("No key-card found!\n" |
165 | "Please insert the " | 166 | "Please insert the " |
166 | "correct key-card."); | 167 | "correct key-card."); |
167 | } else { | 168 | } else { |
168 | msg += i18n("No master-password given!"); | 169 | msg += i18n("No master-password given!"); |
169 | } | 170 | } |
170 | 171 | ||
171 | if (postfix != "") { | 172 | if (postfix != "") { |
172 | msg += "\n"; | 173 | msg += "\n"; |
173 | msg += postfix; | 174 | msg += postfix; |
174 | } | 175 | } |
175 | KMessageBox::error(currentView, msg, | 176 | KMessageBox::error(currentView, msg, |
176 | (chipcard) ? (i18n("no chipcard")) | 177 | (chipcard) ? (i18n("no chipcard")) |
177 | : (i18n("password error"))); | 178 | : (i18n("password error"))); |
178 | } | 179 | } |
179 | 180 | ||
180 | void PwMDocUi::rootAlertMsgBox() | 181 | void PwMDocUi::rootAlertMsgBox() |
181 | { | 182 | { |
182 | KMessageBox::error(currentView, | 183 | KMessageBox::error(currentView, |
183 | i18n("This feature is not available, " | 184 | i18n("This feature is not available, " |
184 | "if you execute PwM with \"root\" " | 185 | "if you execute PwM with \"root\" " |
185 | "UID 0 privileges, for security reasons!"), | 186 | "UID 0 privileges, for security reasons!"), |
186 | i18n("not allowed as root!")); | 187 | i18n("not allowed as root!")); |
187 | } | 188 | } |
188 | 189 | ||
189 | void PwMDocUi::cantDeeplock_notSavedMsgBox() | 190 | void PwMDocUi::cantDeeplock_notSavedMsgBox() |
190 | { | 191 | { |
191 | KMessageBox::error(currentView, | 192 | KMessageBox::error(currentView, |
192 | i18n("Can't deep-lock, because the document " | 193 | i18n("Can't deep-lock, because the document " |
193 | "hasn't been saved, yet. Please save " | 194 | "hasn't been saved, yet. Please save " |
194 | "to a file and try again."), | 195 | "to a file and try again."), |
195 | i18n("not saved, yet")); | 196 | i18n("not saved, yet")); |
196 | } | 197 | } |
197 | 198 | ||
198 | void PwMDocUi::gpmPwLenErrMsgBox() | 199 | void PwMDocUi::gpmPwLenErrMsgBox() |
199 | { | 200 | { |
200 | KMessageBox::error(currentView, | 201 | KMessageBox::error(currentView, |
201 | i18n("GPasman does not support passwords " | 202 | i18n("GPasman does not support passwords " |
202 | "shorter than 4 characters! Please try " | 203 | "shorter than 4 characters! Please try " |
203 | "again with a longer password."), | 204 | "again with a longer password."), |
204 | i18n("password too short")); | 205 | i18n("password too short")); |
205 | } | 206 | } |
206 | 207 | ||
207 | int PwMDocUi::dirtyAskSave(const QString &docTitle) | 208 | int PwMDocUi::dirtyAskSave(const QString &docTitle) |
208 | { | 209 | { |
209 | int ret; | 210 | int ret; |
210 | #ifndef PWM_EMBEDDED | 211 | #ifndef PWM_EMBEDDED |
211 | ret = KMessageBox::questionYesNoCancel(currentView, | 212 | ret = KMessageBox::questionYesNoCancel(currentView, |
212 | i18n("The list \"") + | 213 | i18n("The list \"") + |
213 | docTitle + | 214 | docTitle + |
214 | i18n | 215 | i18n |
215 | ("\" has been modified.\n" | 216 | ("\" has been modified.\n" |
216 | "Do you want to save it?"), | 217 | "Do you want to save it?"), |
217 | i18n("save?")); | 218 | i18n("save?")); |
218 | if (ret == KMessageBox::Yes) { | 219 | if (ret == KMessageBox::Yes) { |
219 | return 0; | 220 | return 0; |
220 | } else if (ret == KMessageBox::No) { | 221 | } else if (ret == KMessageBox::No) { |
221 | return 1; | 222 | return 1; |
222 | } | 223 | } |
223 | #else | 224 | #else |
224 | ret = KMessageBox::warningYesNoCancel(currentView, | 225 | ret = KMessageBox::warningYesNoCancel(currentView, |
225 | i18n("The list \"") + | 226 | i18n("The list \"") + |
226 | docTitle + | 227 | docTitle + |
227 | i18n | 228 | i18n |
228 | ("\" has been modified.\n" | 229 | ("\" has been modified.\n" |
229 | "Do you want to save it?"), | 230 | "Do you want to save it?"), |
230 | i18n("save?")); | 231 | i18n("save?")); |
231 | if (ret == KMessageBox::Yes) { | 232 | if (ret == KMessageBox::Yes) { |
232 | return 0; | 233 | return 0; |
233 | } else if (ret == KMessageBox::No) { | 234 | } else if (ret == KMessageBox::No) { |
234 | return 1; | 235 | return 1; |
235 | } | 236 | } |
236 | 237 | ||
237 | #endif | 238 | #endif |
238 | 239 | ||
239 | // cancel | 240 | // cancel |
240 | return -1; | 241 | return -1; |
241 | } | 242 | } |
242 | 243 | ||
243 | bool PwMDocUi::saveDocUi(PwMDoc *doc) | 244 | bool PwMDocUi::saveDocUi(PwMDoc *doc) |
244 | { | 245 | { |
245 | PWM_ASSERT(doc); | 246 | PWM_ASSERT(doc); |
246 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 247 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
247 | if (doc->isDocEmpty()) { | 248 | if (doc->isDocEmpty()) { |
248 | KMessageBox::information(currentView, | 249 | KMessageBox::information(currentView, |
249 | i18n | 250 | i18n |
250 | ("Sorry, there's nothing to save.\n" | 251 | ("Sorry, there's nothing to save.\n" |
251 | "Please first add some passwords."), | 252 | "Please first add some passwords."), |
252 | i18n("nothing to do")); | 253 | i18n("nothing to do")); |
253 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 254 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
254 | return true; | 255 | return true; |
255 | } | 256 | } |
256 | PwMerror ret = doc->saveDoc(conf()->confGlobCompression()); | 257 | PwMerror ret = doc->saveDoc(conf()->confGlobCompression()); |
257 | if (ret == e_filename) { | 258 | if (ret == e_filename) { |
258 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 259 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
259 | return saveAsDocUi(doc); | 260 | return saveAsDocUi(doc); |
260 | } else if (ret == e_weakPw) { | 261 | } else if (ret == e_weakPw) { |
261 | KMessageBox::error(currentView, | 262 | KMessageBox::error(currentView, |
262 | i18n("Error: This is a weak password.\n" | 263 | i18n("Error: This is a weak password.\n" |
263 | "Please select another password."), | 264 | "Please select another password."), |
264 | i18n("weak password")); | 265 | i18n("weak password")); |
265 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 266 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
266 | return false; | 267 | return false; |
267 | } else if (ret == e_fileBackup) { | 268 | } else if (ret == e_fileBackup) { |
268 | KMessageBox::error(currentView, | 269 | KMessageBox::error(currentView, |
269 | i18n("Error: Couldn't make backup-file!"), | 270 | i18n("Error: Couldn't make backup-file!"), |
270 | i18n("backup failed")); | 271 | i18n("backup failed")); |
271 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 272 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
272 | return false; | 273 | return false; |
273 | } else if (ret != e_success) { | 274 | } else if (ret != e_success) { |
274 | KMessageBox::error(currentView, | 275 | KMessageBox::error(currentView, |
275 | i18n("Error: Couldn't write to file.\n" | 276 | i18n("Error: Couldn't write to file.\n" |
276 | "Please check if you have permission to " | 277 | "Please check if you have permission to " |
277 | "write to the file in that directory."), | 278 | "write to the file in that directory."), |
278 | i18n("error while writing")); | 279 | i18n("error while writing")); |
279 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 280 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
280 | return false; | 281 | return false; |
281 | } | 282 | } |
282 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 283 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
283 | return true; | 284 | return true; |
284 | } | 285 | } |
285 | 286 | ||
286 | bool PwMDocUi::saveAsDocUi(PwMDoc *doc) | 287 | bool PwMDocUi::saveAsDocUi(PwMDoc *doc) |
287 | { | 288 | { |
288 | PWM_ASSERT(doc); | 289 | PWM_ASSERT(doc); |
289 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 290 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
290 | if (doc->isDocEmpty()) { | 291 | if (doc->isDocEmpty()) { |
291 | KMessageBox::information(currentView, | 292 | KMessageBox::information(currentView, |
292 | i18n | 293 | i18n |
293 | ("Sorry, there's nothing to save.\n" | 294 | ("Sorry, there's nothing to save.\n" |
294 | "Please first add some passwords."), | 295 | "Please first add some passwords."), |
295 | i18n("nothing to do")); | 296 | i18n("nothing to do")); |
296 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 297 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
297 | return true; | 298 | return true; |
298 | } | 299 | } |
299 | #ifndef PWM_EMBEDDED | 300 | #ifndef PWM_EMBEDDED |
300 | QString fn(KFileDialog::getSaveFileName(QString::null, | 301 | QString fn(KFileDialog::getSaveFileName(QString::null, |
301 | i18n("*.pwm|PwManager Password file"), | 302 | i18n("*.pwm|PwManager Password file"), |
302 | currentView)); | 303 | currentView)); |
303 | #else | 304 | #else |
304 | QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" ); | 305 | QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" ); |
305 | fn = KFileDialog::getSaveFileName(fn, | 306 | fn = KFileDialog::getSaveFileName(fn, |
306 | i18n("password filename(*.pwm)"), | 307 | i18n("password filename(*.pwm)"), |
307 | currentView); | 308 | currentView); |
308 | 309 | ||
309 | #endif | 310 | #endif |
310 | if (fn == "") { | 311 | if (fn == "") { |
311 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 312 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
312 | return false; | 313 | return false; |
313 | } | 314 | } |
314 | if (fn.right(4) != ".pwm") | 315 | if (fn.right(4) != ".pwm") |
315 | fn += ".pwm"; | 316 | fn += ".pwm"; |
316 | 317 | ||
317 | PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn); | 318 | PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn); |
318 | if (ret != e_success) { | 319 | if (ret != e_success) { |
319 | KMessageBox::error(currentView, | 320 | KMessageBox::error(currentView, |
320 | i18n("Error: Couldn't write to file.\n" | 321 | i18n("Error: Couldn't write to file.\n" |
321 | "Please check if you have permission to " | 322 | "Please check if you have permission to " |
322 | "write to the file in that directory."), | 323 | "write to the file in that directory."), |
323 | i18n("error while writing")); | 324 | i18n("error while writing")); |
324 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 325 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
325 | return false; | 326 | return false; |
326 | } | 327 | } |
327 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 328 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
328 | return true; | 329 | return true; |
329 | } | 330 | } |
330 | 331 | ||
331 | bool PwMDocUi::openDocUi(PwMDoc *doc, | 332 | bool PwMDocUi::openDocUi(PwMDoc *doc, |
332 | QString filename, | 333 | QString filename, |
333 | bool openDeepLocked) | 334 | bool openDeepLocked) |
334 | { | 335 | { |
335 | if (filename.isEmpty()) | 336 | if (filename.isEmpty()) |
336 | { | 337 | { |
337 | #ifndef PWM_EMBEDDED | 338 | #ifndef PWM_EMBEDDED |
338 | filename = KFileDialog::getOpenFileName(QString::null, | 339 | filename = KFileDialog::getOpenFileName(QString::null, |
339 | i18n("*.pwm|PwManager Password file\n" | 340 | i18n("*.pwm|PwManager Password file\n" |
340 | "*|All files"), getCurrentView()); | 341 | "*|All files"), getCurrentView()); |
341 | #else | 342 | #else |
342 | filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm"); | 343 | filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm"); |
343 | filename = KFileDialog::getOpenFileName(filename, | 344 | filename = KFileDialog::getOpenFileName(filename, |
344 | i18n("password filename(*.pwm)"), getCurrentView()); | 345 | i18n("password filename(*.pwm)"), getCurrentView()); |
345 | #endif | 346 | #endif |
346 | } | 347 | } |
347 | if (filename.isEmpty()) | 348 | if (filename.isEmpty()) |
348 | goto cancelOpen; | 349 | goto cancelOpen; |
349 | PwMerror ret; | 350 | PwMerror ret; |
350 | while (true) { | 351 | while (true) { |
351 | int lockStat = -1; | 352 | int lockStat = -1; |
352 | if (openDeepLocked) { | 353 | if (openDeepLocked) { |
353 | lockStat = 2; | 354 | lockStat = 2; |
354 | } else { | 355 | } else { |
355 | if (conf()->confGlobUnlockOnOpen()) { | 356 | if (conf()->confGlobUnlockOnOpen()) { |
356 | lockStat = 0; | 357 | lockStat = 0; |
357 | } else { | 358 | } else { |
358 | lockStat = 1; | 359 | lockStat = 1; |
359 | } | 360 | } |
360 | } | 361 | } |
361 | ret = doc->openDoc(&filename, lockStat); | 362 | ret = doc->openDoc(&filename, lockStat); |
362 | if (ret != e_success) { | 363 | if (ret != e_success) { |
363 | if (ret == e_readFile || ret == e_openFile) { | 364 | if (ret == e_readFile || ret == e_openFile) { |
364 | KMessageBox::error(getCurrentView(), | 365 | KMessageBox::error(getCurrentView(), |
365 | i18n("Could not read file!") | 366 | i18n("Could not read file!") |
366 | + "\n" | 367 | + "\n" |
367 | + filename, | 368 | + filename, |
368 | i18n("file error")); | 369 | i18n("file error")); |
369 | goto cancelOpen; | 370 | goto cancelOpen; |
370 | } | 371 | } |
371 | if (ret == e_alreadyOpen) { | 372 | if (ret == e_alreadyOpen) { |
372 | KMessageBox::error(getCurrentView(), | 373 | KMessageBox::error(getCurrentView(), |
373 | i18n("This file is already open."), | 374 | i18n("This file is already open."), |
374 | i18n("already open")); | 375 | i18n("already open")); |
375 | goto cancelOpen; | 376 | goto cancelOpen; |
376 | } | 377 | } |
377 | if (ret == e_fileVer) { | 378 | if (ret == e_fileVer) { |
378 | KMessageBox::error(getCurrentView(), | 379 | KMessageBox::error(getCurrentView(), |
379 | i18n | 380 | i18n |
380 | ("File-version is not supported!\n" | 381 | ("File-version is not supported!\n" |
381 | "Did you create this file with an older or newer version of PwM?"), | 382 | "Did you create this file with an older or newer version of PwM?"), |
382 | i18n | 383 | i18n |
383 | ("incompatible version")); | 384 | ("incompatible version")); |
384 | goto cancelOpen; | 385 | goto cancelOpen; |
385 | } | 386 | } |
386 | if (ret == e_wrongPw) { | 387 | if (ret == e_wrongPw) { |
387 | continue; | 388 | continue; |
388 | } | 389 | } |
389 | if (ret == e_noPw) { | 390 | if (ret == e_noPw) { |
390 | goto cancelOpen; | 391 | goto cancelOpen; |
391 | } | 392 | } |
392 | if (ret == e_fileFormat) { | 393 | if (ret == e_fileFormat) { |
393 | KMessageBox::error(getCurrentView(), | 394 | KMessageBox::error(getCurrentView(), |
394 | i18n | 395 | i18n |
395 | ("Sorry, this file has not been recognized " | 396 | ("Sorry, this file has not been recognized " |
396 | "as a PwM Password file.\n" | 397 | "as a PwM Password file.\n" |
397 | "Probably you have selected the wrong file."), | 398 | "Probably you have selected the wrong file."), |
398 | i18n | 399 | i18n |
399 | ("no PwM password-file")); | 400 | ("no PwM password-file")); |
400 | goto cancelOpen; | 401 | goto cancelOpen; |
401 | } | 402 | } |
402 | if (ret == e_fileCorrupt) { | 403 | if (ret == e_fileCorrupt) { |
403 | KMessageBox::error(getCurrentView(), | 404 | KMessageBox::error(getCurrentView(), |
404 | i18n | 405 | i18n |
405 | ("File corrupt!\n" | 406 | ("File corrupt!\n" |
406 | "Maybe the media, you stored this file on, " | 407 | "Maybe the media, you stored this file on, " |
407 | "had bad sectors?"), | 408 | "had bad sectors?"), |
408 | i18n | 409 | i18n |
409 | ("checksum error")); | 410 | ("checksum error")); |
410 | goto cancelOpen; | 411 | goto cancelOpen; |
411 | } | 412 | } |
412 | } | 413 | } |
413 | break; | 414 | break; |
414 | } | 415 | } |
415 | return true; | 416 | return true; |
416 | 417 | ||
417 | cancelOpen: | 418 | cancelOpen: |
418 | return false; | 419 | return false; |
419 | } | 420 | } |
420 | 421 | ||
421 | QString PwMDocUi::string_defaultCategory() | 422 | QString PwMDocUi::string_defaultCategory() |
422 | { | 423 | { |
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp index 2f1aa4e..8946443 100644 --- a/pwmanager/pwmanager/pwminit.cpp +++ b/pwmanager/pwmanager/pwminit.cpp | |||
@@ -1,532 +1,549 @@ | |||
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 "pwminit.h" | 20 | #include "pwminit.h" |
21 | #include "configuration.h" | ||
22 | #include "randomizer.h" | 21 | #include "randomizer.h" |
23 | 22 | ||
24 | #ifndef PWM_EMBEDDED | 23 | #ifndef PWM_EMBEDDED |
25 | #include "selftest.h" | 24 | #include "selftest.h" |
25 | #include "configuration.h" | ||
26 | #else | ||
27 | #include "pwmprefs.h" | ||
26 | #endif | 28 | #endif |
27 | 29 | ||
28 | #include "pwm.h" | 30 | #include "pwm.h" |
29 | #include "pwmexception.h" | 31 | #include "pwmexception.h" |
30 | #include "pwmtray.h" | 32 | #include "pwmtray.h" |
31 | #include "pwmdoc.h" | 33 | #include "pwmdoc.h" |
32 | 34 | ||
33 | #ifdef CONFIG_KWALLETIF | 35 | #ifdef CONFIG_KWALLETIF |
34 | # include "kwalletemu.h" | 36 | # include "kwalletemu.h" |
35 | #endif // CONFIG_KWALLETIF | 37 | #endif // CONFIG_KWALLETIF |
36 | #ifdef CONFIG_KEYCARD | 38 | #ifdef CONFIG_KEYCARD |
37 | # include "pwmkeycard.h" | 39 | # include "pwmkeycard.h" |
38 | #endif // CONFIG_KEYCARD | 40 | #endif // CONFIG_KEYCARD |
39 | 41 | ||
40 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
41 | 43 | ||
42 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
43 | #ifndef PWM_EMBEDDED | 45 | #ifndef PWM_EMBEDDED |
44 | #include <kcmdlineargs.h> | 46 | #include <kcmdlineargs.h> |
45 | #include <kwin.h> | 47 | #include <kwin.h> |
46 | #include <dcopclient.h> | 48 | #include <dcopclient.h> |
47 | #endif | 49 | #endif |
48 | 50 | ||
49 | #include <kapplication.h> | 51 | #include <kapplication.h> |
50 | #include <kiconloader.h> | 52 | #include <kiconloader.h> |
51 | 53 | ||
52 | #include <signal.h> | 54 | #include <signal.h> |
53 | 55 | ||
54 | static PwMInit *sig_init_pointer; | 56 | static PwMInit *sig_init_pointer; |
55 | static NOREGPARM void sig_handler(int signum) | 57 | static NOREGPARM void sig_handler(int signum) |
56 | { | 58 | { |
57 | switch (signum) { | 59 | switch (signum) { |
58 | case SIGINT: | 60 | case SIGINT: |
59 | case SIGTERM: | 61 | case SIGTERM: |
60 | sig_init_pointer->shutdownApp(20 + signum); | 62 | sig_init_pointer->shutdownApp(20 + signum); |
61 | break; | 63 | break; |
62 | default: | 64 | default: |
63 | printDebug(string("unhandled signal ") | 65 | printDebug(string("unhandled signal ") |
64 | + tostr(signum)); | 66 | + tostr(signum)); |
65 | } | 67 | } |
66 | } | 68 | } |
67 | 69 | ||
68 | 70 | ||
69 | 71 | ||
70 | 72 | ||
71 | PwMInit::PwMInit(PwMApplication *_app) | 73 | PwMInit::PwMInit(PwMApplication *_app) |
72 | : runStatus (unknown) | 74 | : runStatus (unknown) |
73 | , _curWidget (0) | 75 | , _curWidget (0) |
74 | , _dcopClient (0) | 76 | , _dcopClient (0) |
75 | , _kwalletEmu (0) | 77 | , _kwalletEmu (0) |
76 | , _keycard (0) | 78 | , _keycard (0) |
77 | , _tray (0) | 79 | , _tray (0) |
78 | { | 80 | { |
79 | sig_init_pointer = this; | 81 | sig_init_pointer = this; |
80 | app = _app; | 82 | app = _app; |
81 | } | 83 | } |
82 | 84 | ||
83 | PwMInit::~PwMInit() | 85 | PwMInit::~PwMInit() |
84 | { | 86 | { |
85 | #ifndef PWM_EMBEDDED | 87 | #ifndef PWM_EMBEDDED |
86 | SelfTest::cancel(); | 88 | SelfTest::cancel(); |
87 | // close all open mainwnds | 89 | // close all open mainwnds |
88 | QValueList<PwM *>::iterator i = _mainWndList.begin(), | 90 | QValueList<PwM *>::iterator i = _mainWndList.begin(), |
89 | end = _mainWndList.end(); | 91 | end = _mainWndList.end(); |
90 | 92 | ||
91 | #else | 93 | #else |
92 | // close all open mainwnds | 94 | // close all open mainwnds |
93 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), | 95 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), |
94 | end = _mainWndList.end(); | 96 | end = _mainWndList.end(); |
95 | #endif | 97 | #endif |
96 | while (i != end) { | 98 | while (i != end) { |
97 | disconnect(*i, SIGNAL(closed(PwM *)), | 99 | disconnect(*i, SIGNAL(closed(PwM *)), |
98 | this, SLOT(mainWndClosed(PwM *))); | 100 | this, SLOT(mainWndClosed(PwM *))); |
99 | delete *i; | 101 | delete *i; |
100 | ++i; | 102 | ++i; |
101 | } | 103 | } |
102 | _mainWndList.clear(); | 104 | _mainWndList.clear(); |
103 | // close all remaining open documents | 105 | // close all remaining open documents |
104 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 106 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
105 | vector<PwMDocList::listItem> dl = *(_dl->getList()); | 107 | vector<PwMDocList::listItem> dl = *(_dl->getList()); |
106 | vector<PwMDocList::listItem>::iterator i2 = dl.begin(), | 108 | vector<PwMDocList::listItem>::iterator i2 = dl.begin(), |
107 | end2 = dl.end(); | 109 | end2 = dl.end(); |
108 | while (i2 != end2) { | 110 | while (i2 != end2) { |
109 | delete (*i2).doc; | 111 | delete (*i2).doc; |
110 | ++i2; | 112 | ++i2; |
111 | } | 113 | } |
112 | 114 | ||
113 | #ifdef CONFIG_KWALLETIF | 115 | #ifdef CONFIG_KWALLETIF |
114 | delete_ifnot_null(_kwalletEmu); | 116 | delete_ifnot_null(_kwalletEmu); |
115 | #endif // CONFIG_KWALLETIF | 117 | #endif // CONFIG_KWALLETIF |
116 | #ifdef CONFIG_KEYCARD | 118 | #ifdef CONFIG_KEYCARD |
117 | delete_ifnot_null(_keycard); | 119 | delete_ifnot_null(_keycard); |
118 | #endif // CONFIG_KEYCARD | 120 | #endif // CONFIG_KEYCARD |
119 | delete_ifnot_null(_tray); | 121 | delete_ifnot_null(_tray); |
120 | 122 | ||
121 | Randomizer::cleanup(); | 123 | Randomizer::cleanup(); |
124 | #ifndef PWM_EMBEDDED | ||
122 | Configuration::cleanup(); | 125 | Configuration::cleanup(); |
126 | #endif | ||
123 | } | 127 | } |
124 | 128 | ||
125 | void PwMInit::initializeApp() | 129 | void PwMInit::initializeApp() |
126 | { | 130 | { |
127 | PWM_ASSERT(runStatus == unknown); | 131 | PWM_ASSERT(runStatus == unknown); |
128 | runStatus = init; | 132 | runStatus = init; |
129 | initPosixSignalHandler(); | 133 | initPosixSignalHandler(); |
130 | Randomizer::init(); | 134 | Randomizer::init(); |
135 | #ifndef PWM_EMBEDDED | ||
131 | Configuration::init(); | 136 | Configuration::init(); |
137 | #endif | ||
132 | initDCOP(); | 138 | initDCOP(); |
133 | initKWalletEmu(); | 139 | initKWalletEmu(); |
134 | initKeycard(); | 140 | initKeycard(); |
135 | initTray(); | 141 | initTray(); |
136 | handleCmdLineArgs(); | 142 | handleCmdLineArgs(); |
137 | 143 | ||
138 | bool openDeeplocked = false; | 144 | bool openDeeplocked = false; |
139 | if (conf()->confGlobAutostartDeepLocked() || | 145 | if (conf()->confGlobAutostartDeepLocked() || |
140 | savedCmd.open_deeplocked) | 146 | savedCmd.open_deeplocked) |
141 | openDeeplocked = true; | 147 | openDeeplocked = true; |
142 | if (conf()->confWndAutoMinimizeOnStart() || | 148 | if (conf()->confWndAutoMinimizeOnStart() || |
143 | savedCmd.minToTray) { | 149 | savedCmd.minToTray) { |
144 | PwMDoc *newDoc = createDoc(); | 150 | PwMDoc *newDoc = createDoc(); |
145 | if (!newDoc->openDocUi(newDoc, | 151 | if (!newDoc->openDocUi(newDoc, |
146 | conf()->confGlobAutoStart(), | 152 | conf()->confGlobAutoStart(), |
147 | openDeeplocked)) { | 153 | openDeeplocked)) { |
148 | delete newDoc; | 154 | delete newDoc; |
155 | |||
156 | //US ENH for embedded devices: in the case of failure, open a document the default way | ||
157 | createMainWnd(conf()->confGlobAutoStart(), | ||
158 | openDeeplocked, | ||
159 | true, | ||
160 | 0, | ||
161 | savedCmd.minimized); | ||
162 | |||
163 | |||
164 | |||
165 | |||
149 | } | 166 | } |
150 | } else { | 167 | } else { |
151 | createMainWnd(conf()->confGlobAutoStart(), | 168 | createMainWnd(conf()->confGlobAutoStart(), |
152 | openDeeplocked, | 169 | openDeeplocked, |
153 | true, | 170 | true, |
154 | 0, | 171 | 0, |
155 | savedCmd.minimized); | 172 | savedCmd.minimized); |
156 | } | 173 | } |
157 | 174 | ||
158 | runStatus = running; | 175 | runStatus = running; |
159 | } | 176 | } |
160 | 177 | ||
161 | void PwMInit::shutdownApp(int exitStatus) | 178 | void PwMInit::shutdownApp(int exitStatus) |
162 | { | 179 | { |
163 | printDebug(string("PwMInit::shutdownApp(") | 180 | printDebug(string("PwMInit::shutdownApp(") |
164 | + tostr(exitStatus) + ") called."); | 181 | + tostr(exitStatus) + ") called."); |
165 | PWM_ASSERT((runStatus == running) || (runStatus == init)); | 182 | PWM_ASSERT((runStatus == running) || (runStatus == init)); |
166 | runStatus = shutdown; | 183 | runStatus = shutdown; |
167 | QApplication::exit(exitStatus); | 184 | QApplication::exit(exitStatus); |
168 | /* The destructor of PwMInit is called when control | 185 | /* The destructor of PwMInit is called when control |
169 | * leaves main() | 186 | * leaves main() |
170 | */ | 187 | */ |
171 | } | 188 | } |
172 | 189 | ||
173 | void PwMInit::initPosixSignalHandler() | 190 | void PwMInit::initPosixSignalHandler() |
174 | { | 191 | { |
175 | signal(SIGINT, sig_handler); | 192 | signal(SIGINT, sig_handler); |
176 | signal(SIGTERM, sig_handler); | 193 | signal(SIGTERM, sig_handler); |
177 | } | 194 | } |
178 | 195 | ||
179 | void PwMInit::initDCOP() | 196 | void PwMInit::initDCOP() |
180 | { | 197 | { |
181 | #ifndef PWM_EMBEDDED | 198 | #ifndef PWM_EMBEDDED |
182 | _dcopClient = app->dcopClient(); | 199 | _dcopClient = app->dcopClient(); |
183 | _dcopClient->setNotifications(true); | 200 | _dcopClient->setNotifications(true); |
184 | #endif | 201 | #endif |
185 | 202 | ||
186 | } | 203 | } |
187 | 204 | ||
188 | void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) | 205 | void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) |
189 | { | 206 | { |
190 | #ifdef CONFIG_KWALLETIF | 207 | #ifdef CONFIG_KWALLETIF |
191 | if (!conf()->confGlobKwalletEmu() || | 208 | if (!conf()->confGlobKwalletEmu() || |
192 | forceDisable) { | 209 | forceDisable) { |
193 | delete_ifnot_null(_kwalletEmu); | 210 | delete_ifnot_null(_kwalletEmu); |
194 | return; | 211 | return; |
195 | } | 212 | } |
196 | try { | 213 | try { |
197 | if (_kwalletEmu && forceReload) | 214 | if (_kwalletEmu && forceReload) |
198 | delete_and_null(_kwalletEmu); | 215 | delete_and_null(_kwalletEmu); |
199 | if (!_kwalletEmu) | 216 | if (!_kwalletEmu) |
200 | _kwalletEmu = new KWalletEmu(this); | 217 | _kwalletEmu = new KWalletEmu(this); |
201 | } catch (PwMException e) { | 218 | } catch (PwMException e) { |
202 | string errMsg("initializing KWallet emulation failed. ID: "); | 219 | string errMsg("initializing KWallet emulation failed. ID: "); |
203 | errMsg += tostr(static_cast<int>(e.getId())); | 220 | errMsg += tostr(static_cast<int>(e.getId())); |
204 | errMsg += " err-message: "; | 221 | errMsg += " err-message: "; |
205 | errMsg += e.getMessage(); | 222 | errMsg += e.getMessage(); |
206 | printWarn(errMsg); | 223 | printWarn(errMsg); |
207 | return; | 224 | return; |
208 | } | 225 | } |
209 | #else // CONFIG_KWALLETIF | 226 | #else // CONFIG_KWALLETIF |
210 | PARAM_UNUSED(forceDisable); | 227 | PARAM_UNUSED(forceDisable); |
211 | PARAM_UNUSED(forceReload); | 228 | PARAM_UNUSED(forceReload); |
212 | #endif // CONFIG_KWALLETIF | 229 | #endif // CONFIG_KWALLETIF |
213 | } | 230 | } |
214 | 231 | ||
215 | void PwMInit::initKeycard() | 232 | void PwMInit::initKeycard() |
216 | { | 233 | { |
217 | #ifdef CONFIG_KEYCARD | 234 | #ifdef CONFIG_KEYCARD |
218 | PWM_ASSERT(!_keycard); | 235 | PWM_ASSERT(!_keycard); |
219 | _keycard = new PwMKeyCard(this); | 236 | _keycard = new PwMKeyCard(this); |
220 | #endif // CONFIG_KEYCARD | 237 | #endif // CONFIG_KEYCARD |
221 | } | 238 | } |
222 | 239 | ||
223 | void PwMInit::initTray() | 240 | void PwMInit::initTray() |
224 | { | 241 | { |
225 | #ifdef PWM_EMBEDDED | 242 | #ifdef PWM_EMBEDDED |
226 | //US ENH : embedded version does not support a tray | 243 | //US ENH : embedded version does not support a tray |
227 | return; | 244 | return; |
228 | #endif | 245 | #endif |
229 | 246 | ||
230 | if (!conf()->confGlobTray()) { | 247 | if (!conf()->confGlobTray()) { |
231 | if (!_tray) | 248 | if (!_tray) |
232 | return; | 249 | return; |
233 | _tray->hide(); | 250 | _tray->hide(); |
234 | delete_and_null(_tray); | 251 | delete_and_null(_tray); |
235 | return; | 252 | return; |
236 | } | 253 | } |
237 | if (_tray) | 254 | if (_tray) |
238 | return; | 255 | return; |
239 | _tray = new PwMTray(this); | 256 | _tray = new PwMTray(this); |
240 | connect(_tray, SIGNAL(quitSelected()), | 257 | connect(_tray, SIGNAL(quitSelected()), |
241 | this, SLOT(removeTrayAndQuit())); | 258 | this, SLOT(removeTrayAndQuit())); |
242 | connect(_tray, SIGNAL(closed(PwMTray *)), | 259 | connect(_tray, SIGNAL(closed(PwMTray *)), |
243 | this, SLOT(trayIconClosed(PwMTray *))); | 260 | this, SLOT(trayIconClosed(PwMTray *))); |
244 | KIconLoader icons; | 261 | KIconLoader icons; |
245 | #ifndef PWM_EMBEDDED | 262 | #ifndef PWM_EMBEDDED |
246 | _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); | 263 | _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); |
247 | #endif | 264 | #endif |
248 | _tray->show(); | 265 | _tray->show(); |
249 | // connect the signals of all open documents. | 266 | // connect the signals of all open documents. |
250 | const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); | 267 | const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); |
251 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 268 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
252 | end = dl->end(); | 269 | end = dl->end(); |
253 | while (i != end) { | 270 | while (i != end) { |
254 | _tray->connectDocToTray((*i).doc); | 271 | _tray->connectDocToTray((*i).doc); |
255 | ++i; | 272 | ++i; |
256 | } | 273 | } |
257 | } | 274 | } |
258 | 275 | ||
259 | void PwMInit::removeTrayAndQuit() | 276 | void PwMInit::removeTrayAndQuit() |
260 | { | 277 | { |
261 | PWM_ASSERT(_tray); | 278 | PWM_ASSERT(_tray); |
262 | // _tray is deleted in ~PwMInit | 279 | // _tray is deleted in ~PwMInit |
263 | shutdownApp(0); | 280 | shutdownApp(0); |
264 | } | 281 | } |
265 | 282 | ||
266 | PwM * PwMInit::createMainWnd(const QString &loadFile, | 283 | PwM * PwMInit::createMainWnd(const QString &loadFile, |
267 | bool loadFileDeepLocked, | 284 | bool loadFileDeepLocked, |
268 | bool virginity, | 285 | bool virginity, |
269 | PwMDoc *doc, | 286 | PwMDoc *doc, |
270 | bool minimized) | 287 | bool minimized) |
271 | { | 288 | { |
272 | PwM *newWnd; | 289 | PwM *newWnd; |
273 | if (!doc) | 290 | if (!doc) |
274 | doc = createDoc(); | 291 | doc = createDoc(); |
275 | newWnd = new PwM(this, doc, virginity); | 292 | newWnd = new PwM(this, doc, virginity); |
276 | #ifndef PWM_EMBEDDED | 293 | #ifndef PWM_EMBEDDED |
277 | _mainWndList.push_back(newWnd); | 294 | _mainWndList.push_back(newWnd); |
278 | #else | 295 | #else |
279 | _mainWndList.append(newWnd); | 296 | _mainWndList.append(newWnd); |
280 | #endif | 297 | #endif |
281 | connect(newWnd, SIGNAL(closed(PwM *)), | 298 | connect(newWnd, SIGNAL(closed(PwM *)), |
282 | this, SLOT(mainWndClosed(PwM *))); | 299 | this, SLOT(mainWndClosed(PwM *))); |
283 | connect(newWnd, SIGNAL(gotFocus(PwM *)), | 300 | connect(newWnd, SIGNAL(gotFocus(PwM *)), |
284 | this, SLOT(setCurWidget(PwM *))); | 301 | this, SLOT(setCurWidget(PwM *))); |
285 | connect(newWnd, SIGNAL(lostFocus(PwM *)), | 302 | connect(newWnd, SIGNAL(lostFocus(PwM *)), |
286 | this, SLOT(resetCurWidget())); | 303 | this, SLOT(resetCurWidget())); |
287 | 304 | ||
288 | //US ENH | 305 | //US ENH |
289 | #ifndef PWM_EMBEDDED | 306 | #ifndef PWM_EMBEDDED |
290 | if (minimized) | 307 | if (minimized) |
291 | newWnd->showMinimized(); | 308 | newWnd->showMinimized(); |
292 | else | 309 | else |
293 | newWnd->show(); | 310 | newWnd->show(); |
294 | 311 | ||
295 | #else //PWM_EMBEDDED | 312 | #else //PWM_EMBEDDED |
296 | 313 | ||
297 | #ifndef DESKTOP_VERSION | 314 | #ifndef DESKTOP_VERSION |
298 | app->showMainWidget( newWnd ); | 315 | app->showMainWidget( newWnd ); |
299 | #else //DESKTOP_VERSION | 316 | #else //DESKTOP_VERSION |
300 | app->setMainWidget( newWnd ); | 317 | app->setMainWidget( newWnd ); |
301 | newWnd->resize (640, 480 ); | 318 | newWnd->resize (640, 480 ); |
302 | newWnd->show(); | 319 | newWnd->show(); |
303 | #endif //DESKTOP_VERSION | 320 | #endif //DESKTOP_VERSION |
304 | 321 | ||
305 | #endif //PWM_EMBEDDED | 322 | #endif //PWM_EMBEDDED |
306 | 323 | ||
307 | if (loadFile != QString::null && | 324 | if (loadFile != QString::null && |
308 | loadFile != "") { | 325 | loadFile != "") { |
309 | newWnd->openDoc(loadFile, loadFileDeepLocked); | 326 | newWnd->openDoc(loadFile, loadFileDeepLocked); |
310 | } | 327 | } |
311 | return newWnd; | 328 | return newWnd; |
312 | } | 329 | } |
313 | 330 | ||
314 | PwMDoc * PwMInit::createDoc() | 331 | PwMDoc * PwMInit::createDoc() |
315 | { | 332 | { |
316 | PwMDoc *doc = new PwMDoc(this); | 333 | PwMDoc *doc = new PwMDoc(this); |
317 | #ifdef CONFIG_KEYCARD | 334 | #ifdef CONFIG_KEYCARD |
318 | doc->setPwMKeyCard(keycard()); | 335 | doc->setPwMKeyCard(keycard()); |
319 | #endif | 336 | #endif |
320 | #ifdef CONFIG_KWALLETIF | 337 | #ifdef CONFIG_KWALLETIF |
321 | if (kwalletEmu()) | 338 | if (kwalletEmu()) |
322 | kwalletEmu()->connectDocSignals(doc); | 339 | kwalletEmu()->connectDocSignals(doc); |
323 | #endif | 340 | #endif |
324 | 341 | ||
325 | if (_tray) | 342 | if (_tray) |
326 | _tray->connectDocToTray(doc); | 343 | _tray->connectDocToTray(doc); |
327 | 344 | ||
328 | return doc; | 345 | return doc; |
329 | 346 | ||
330 | } | 347 | } |
331 | 348 | ||
332 | void PwMInit::mainWndClosed(PwM *wnd) | 349 | void PwMInit::mainWndClosed(PwM *wnd) |
333 | { | 350 | { |
334 | bool doMinimizeToTray = false; | 351 | bool doMinimizeToTray = false; |
335 | bool doDeleteDoc = false; | 352 | bool doDeleteDoc = false; |
336 | #ifndef PWM_EMBEDDED | 353 | #ifndef PWM_EMBEDDED |
337 | dcopClient()->suspend(); | 354 | dcopClient()->suspend(); |
338 | dcopClient()->setAcceptCalls(false); | 355 | dcopClient()->setAcceptCalls(false); |
339 | #endif | 356 | #endif |
340 | again: | 357 | again: |
341 | 358 | ||
342 | if (wnd->isForceMinimizeToTray()) { | 359 | if (wnd->isForceMinimizeToTray()) { |
343 | if (unlikely(!_tray)) { | 360 | if (unlikely(!_tray)) { |
344 | /* This should not happen! If we set forceMinimizeToTray , | 361 | /* This should not happen! If we set forceMinimizeToTray , |
345 | * we must be sure that _tray exists. | 362 | * we must be sure that _tray exists. |
346 | */ | 363 | */ |
347 | BUG(); | 364 | BUG(); |
348 | wnd->setForceMinimizeToTray(false); | 365 | wnd->setForceMinimizeToTray(false); |
349 | goto again; | 366 | goto again; |
350 | } | 367 | } |
351 | doMinimizeToTray = true; | 368 | doMinimizeToTray = true; |
352 | } else { | 369 | } else { |
353 | // Ask to minimize to tray. If not, delete doc. | 370 | // Ask to minimize to tray. If not, delete doc. |
354 | if (_tray && | 371 | if (_tray && |
355 | runStatus != shutdown && | 372 | runStatus != shutdown && |
356 | !wnd->isForceQuit() && | 373 | !wnd->isForceQuit() && |
357 | !wnd->curDoc()->isDeleted()) { | 374 | !wnd->curDoc()->isDeleted()) { |
358 | if (conf()->confWndClose()) | 375 | if (conf()->confWndClose()) |
359 | doDeleteDoc = true; | 376 | doDeleteDoc = true; |
360 | else | 377 | else |
361 | doMinimizeToTray = true; | 378 | doMinimizeToTray = true; |
362 | } else { | 379 | } else { |
363 | doDeleteDoc = true; | 380 | doDeleteDoc = true; |
364 | } | 381 | } |
365 | } | 382 | } |
366 | 383 | ||
367 | if (doMinimizeToTray) { | 384 | if (doMinimizeToTray) { |
368 | 385 | ||
369 | PWM_ASSERT(_tray); | 386 | PWM_ASSERT(_tray); |
370 | int mmlock = conf()->confGlobMinimizeLock(); | 387 | int mmlock = conf()->confGlobMinimizeLock(); |
371 | switch (mmlock) { | 388 | switch (mmlock) { |
372 | case 0: // don't lock anything | 389 | case 0: // don't lock anything |
373 | break; | 390 | break; |
374 | case 1: // normal lock | 391 | case 1: // normal lock |
375 | wnd->curDoc()->lockAll(true); | 392 | wnd->curDoc()->lockAll(true); |
376 | break; | 393 | break; |
377 | case 2: // deep-lock | 394 | case 2: // deep-lock |
378 | wnd->curDoc()->deepLock(); | 395 | wnd->curDoc()->deepLock(); |
379 | break; | 396 | break; |
380 | default: | 397 | default: |
381 | WARN(); | 398 | WARN(); |
382 | } | 399 | } |
383 | } else if (doDeleteDoc) { | 400 | } else if (doDeleteDoc) { |
384 | if (!wnd->curDoc()->tryDelete()) { | 401 | if (!wnd->curDoc()->tryDelete()) { |
385 | /* We failed deleting the doc, | 402 | /* We failed deleting the doc, |
386 | * so open a new window with it, again. | 403 | * so open a new window with it, again. |
387 | */ | 404 | */ |
388 | createMainWnd(QString::null, false, | 405 | createMainWnd(QString::null, false, |
389 | false, wnd->curDoc()); | 406 | false, wnd->curDoc()); |
390 | } | 407 | } |
391 | } | 408 | } |
392 | #ifndef PWM_EMBEDDED | 409 | #ifndef PWM_EMBEDDED |
393 | // find the closed window in the "mainWndList" and delete it. | 410 | // find the closed window in the "mainWndList" and delete it. |
394 | QValueList<PwM *>::iterator i = _mainWndList.begin(), | 411 | QValueList<PwM *>::iterator i = _mainWndList.begin(), |
395 | end = _mainWndList.end(); | 412 | end = _mainWndList.end(); |
396 | #else | 413 | #else |
397 | // find the closed window in the "mainWndList" and delete it. | 414 | // find the closed window in the "mainWndList" and delete it. |
398 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), | 415 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), |
399 | end = _mainWndList.end(); | 416 | end = _mainWndList.end(); |
400 | #endif | 417 | #endif |
401 | while (i != end) { | 418 | while (i != end) { |
402 | if (*i == wnd) { | 419 | if (*i == wnd) { |
403 | #ifndef PWM_EMBEDDED | 420 | #ifndef PWM_EMBEDDED |
404 | _mainWndList.erase(i); | 421 | _mainWndList.erase(i); |
405 | #else | 422 | #else |
406 | _mainWndList.remove(i); | 423 | _mainWndList.remove(i); |
407 | #endif | 424 | #endif |
408 | goto out_success; | 425 | goto out_success; |
409 | } | 426 | } |
410 | ++i; | 427 | ++i; |
411 | } | 428 | } |
412 | BUG(); | 429 | BUG(); |
413 | out_success: | 430 | out_success: |
414 | #ifndef PWM_EMBEDDED | 431 | #ifndef PWM_EMBEDDED |
415 | if (!_mainWndList.size()) | 432 | if (!_mainWndList.size()) |
416 | #else | 433 | #else |
417 | if (!_mainWndList.count()) | 434 | if (!_mainWndList.count()) |
418 | #endif | 435 | #endif |
419 | 436 | ||
420 | { | 437 | { |
421 | /* If there's no main window and no tray icon | 438 | /* If there's no main window and no tray icon |
422 | * left, we have no user interface, so we can | 439 | * left, we have no user interface, so we can |
423 | * shut down the application. | 440 | * shut down the application. |
424 | */ | 441 | */ |
425 | if (!_tray) { | 442 | if (!_tray) { |
426 | #ifndef PWM_EMBEDDED | 443 | #ifndef PWM_EMBEDDED |
427 | dcopClient()->setAcceptCalls(true); | 444 | dcopClient()->setAcceptCalls(true); |
428 | dcopClient()->resume(); | 445 | dcopClient()->resume(); |
429 | #endif | 446 | #endif |
430 | shutdownApp(0); | 447 | shutdownApp(0); |
431 | return; | 448 | return; |
432 | } | 449 | } |
433 | /* There is no widget left, so set | 450 | /* There is no widget left, so set |
434 | * _curWidget to 0 | 451 | * _curWidget to 0 |
435 | */ | 452 | */ |
436 | resetCurWidget(); | 453 | resetCurWidget(); |
437 | } | 454 | } |
438 | #ifndef PWM_EMBEDDED | 455 | #ifndef PWM_EMBEDDED |
439 | dcopClient()->setAcceptCalls(true); | 456 | dcopClient()->setAcceptCalls(true); |
440 | dcopClient()->resume(); | 457 | dcopClient()->resume(); |
441 | #endif | 458 | #endif |
442 | } | 459 | } |
443 | 460 | ||
444 | void PwMInit::trayIconClosed(PwMTray *tray) | 461 | void PwMInit::trayIconClosed(PwMTray *tray) |
445 | { | 462 | { |
446 | if (runStatus != running) | 463 | if (runStatus != running) |
447 | return; | 464 | return; |
448 | PARAM_UNUSED(tray); | 465 | PARAM_UNUSED(tray); |
449 | PWM_ASSERT(tray == _tray); | 466 | PWM_ASSERT(tray == _tray); |
450 | /* If there's no main wnd left we have to | 467 | /* If there's no main wnd left we have to |
451 | * shutdown the app (same as in mainWndClosed()) | 468 | * shutdown the app (same as in mainWndClosed()) |
452 | */ | 469 | */ |
453 | #ifndef PWM_EMBEDDED | 470 | #ifndef PWM_EMBEDDED |
454 | if (!_mainWndList.size()) | 471 | if (!_mainWndList.size()) |
455 | shutdownApp(0); | 472 | shutdownApp(0); |
456 | #else | 473 | #else |
457 | if (!_mainWndList.count()) | 474 | if (!_mainWndList.count()) |
458 | shutdownApp(0); | 475 | shutdownApp(0); |
459 | #endif | 476 | #endif |
460 | } | 477 | } |
461 | 478 | ||
462 | void PwMInit::handleCmdLineArgs(bool initial) | 479 | void PwMInit::handleCmdLineArgs(bool initial) |
463 | { | 480 | { |
464 | #ifndef PWM_EMBEDDED | 481 | #ifndef PWM_EMBEDDED |
465 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 482 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
466 | PWM_ASSERT(args); | 483 | PWM_ASSERT(args); |
467 | int i, numArgs = args->count(); | 484 | int i, numArgs = args->count(); |
468 | const char *curArg; | 485 | const char *curArg; |
469 | 486 | ||
470 | // read all cmdline options | 487 | // read all cmdline options |
471 | savedCmd.open_deeplocked = args->isSet("open-deeplocked"); | 488 | savedCmd.open_deeplocked = args->isSet("open-deeplocked"); |
472 | savedCmd.minimized = args->isSet("minimized"); | 489 | savedCmd.minimized = args->isSet("minimized"); |
473 | savedCmd.minToTray = args->isSet("mintray"); | 490 | savedCmd.minToTray = args->isSet("mintray"); |
474 | savedCmd.skipSelfTest = args->isSet("skip-self-test"); | 491 | savedCmd.skipSelfTest = args->isSet("skip-self-test"); |
475 | if (savedCmd.minimized && | 492 | if (savedCmd.minimized && |
476 | savedCmd.minToTray) { | 493 | savedCmd.minToTray) { |
477 | printInfo(i18n("Commandline option \"--minimized\" and " | 494 | printInfo(i18n("Commandline option \"--minimized\" and " |
478 | "\"--mintray\" selected. These are incompatible. " | 495 | "\"--mintray\" selected. These are incompatible. " |
479 | "\"--mintray\" will be selected.").latin1()); | 496 | "\"--mintray\" will be selected.").latin1()); |
480 | } | 497 | } |
481 | /* Iterate through all non-option arguments. | 498 | /* Iterate through all non-option arguments. |
482 | * Every non-option arg is a filename to open. | 499 | * Every non-option arg is a filename to open. |
483 | */ | 500 | */ |
484 | for (i = 0; i < numArgs; ++i) { | 501 | for (i = 0; i < numArgs; ++i) { |
485 | curArg = args->arg(i); | 502 | curArg = args->arg(i); |
486 | PWM_ASSERT(curArg); | 503 | PWM_ASSERT(curArg); |
487 | if (savedCmd.minToTray) { | 504 | if (savedCmd.minToTray) { |
488 | PwMDoc *newDoc = createDoc(); | 505 | PwMDoc *newDoc = createDoc(); |
489 | if (!newDoc->openDocUi(newDoc, | 506 | if (!newDoc->openDocUi(newDoc, |
490 | curArg, | 507 | curArg, |
491 | savedCmd.open_deeplocked)) { | 508 | savedCmd.open_deeplocked)) { |
492 | delete newDoc; | 509 | delete newDoc; |
493 | } | 510 | } |
494 | } else { | 511 | } else { |
495 | PwM *newInstance = createMainWnd(QString::null, | 512 | PwM *newInstance = createMainWnd(QString::null, |
496 | false, | 513 | false, |
497 | true, | 514 | true, |
498 | 0, | 515 | 0, |
499 | savedCmd.minimized); | 516 | savedCmd.minimized); |
500 | PwMDoc *newDoc = newInstance->openDoc(curArg, | 517 | PwMDoc *newDoc = newInstance->openDoc(curArg, |
501 | savedCmd.open_deeplocked); | 518 | savedCmd.open_deeplocked); |
502 | if (!newDoc) { | 519 | if (!newDoc) { |
503 | newInstance->setForceQuit(true); | 520 | newInstance->setForceQuit(true); |
504 | delete_and_null(newInstance); | 521 | delete_and_null(newInstance); |
505 | } | 522 | } |
506 | } | 523 | } |
507 | } | 524 | } |
508 | 525 | ||
509 | if (savedCmd.minToTray) { | 526 | if (savedCmd.minToTray) { |
510 | minimizeAllMainWnd(true); | 527 | minimizeAllMainWnd(true); |
511 | } else if (savedCmd.minimized) { | 528 | } else if (savedCmd.minimized) { |
512 | minimizeAllMainWnd(false); | 529 | minimizeAllMainWnd(false); |
513 | } | 530 | } |
514 | if (!savedCmd.skipSelfTest && initial) { | 531 | if (!savedCmd.skipSelfTest && initial) { |
515 | SelfTest::schedule(); | 532 | SelfTest::schedule(); |
516 | } | 533 | } |
517 | args->clear(); | 534 | args->clear(); |
518 | #endif | 535 | #endif |
519 | } | 536 | } |
520 | 537 | ||
521 | void PwMInit::minimizeAllMainWnd(bool toTray) | 538 | void PwMInit::minimizeAllMainWnd(bool toTray) |
522 | { | 539 | { |
523 | #ifndef PWM_EMBEDDED | 540 | #ifndef PWM_EMBEDDED |
524 | if (!_mainWndList.size()) | 541 | if (!_mainWndList.size()) |
525 | return; | 542 | return; |
526 | #else | 543 | #else |
527 | if (!_mainWndList.count()) | 544 | if (!_mainWndList.count()) |
528 | return; | 545 | return; |
529 | #endif | 546 | #endif |
530 | const QValueList<PwM *> *ml = mainWndList(); | 547 | const QValueList<PwM *> *ml = mainWndList(); |
531 | #ifndef PWM_EMBEDDED | 548 | #ifndef PWM_EMBEDDED |
532 | QValueList<PwM *>::const_iterator it = ml->begin(), | 549 | QValueList<PwM *>::const_iterator it = ml->begin(), |
diff --git a/pwmanager/pwmanager/pwmtray.cpp b/pwmanager/pwmanager/pwmtray.cpp index 0f286c1..fe074ca 100644 --- a/pwmanager/pwmanager/pwmtray.cpp +++ b/pwmanager/pwmanager/pwmtray.cpp | |||
@@ -1,412 +1,416 @@ | |||
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 | * Original implementation of the tray-tree * | 6 | * Original implementation of the tray-tree * |
7 | * (c) by Matt Scifo <mscifo@o1.com> * | 7 | * (c) by Matt Scifo <mscifo@o1.com> * |
8 | * * | 8 | * * |
9 | * This program is free software; you can redistribute it and/or modify * | 9 | * This program is free software; you can redistribute it and/or modify * |
10 | * it under the terms of the GNU General Public License version 2 * | 10 | * it under the terms of the GNU General Public License version 2 * |
11 | * as published by the Free Software Foundation. * | 11 | * as published by the Free Software Foundation. * |
12 | * * | 12 | * * |
13 | ***************************************************************************/ | 13 | ***************************************************************************/ |
14 | 14 | ||
15 | /*************************************************************************** | 15 | /*************************************************************************** |
16 | * copyright (C) 2004 by Ulf Schenk | 16 | * copyright (C) 2004 by Ulf Schenk |
17 | * This file is originaly based on version 1.0.1 of pwmanager | 17 | * This file is originaly based on version 1.0.1 of pwmanager |
18 | * and was modified to run on embedded devices that run microkde | 18 | * and was modified to run on embedded devices that run microkde |
19 | * | 19 | * |
20 | * $Id$ | 20 | * $Id$ |
21 | **************************************************************************/ | 21 | **************************************************************************/ |
22 | 22 | ||
23 | #include "pwmtray.h" | 23 | #include "pwmtray.h" |
24 | #include "pwmexception.h" | 24 | #include "pwmexception.h" |
25 | #include "pwm.h" | 25 | #include "pwm.h" |
26 | #include "pwmdoc.h" | 26 | #include "pwmdoc.h" |
27 | #include "pwminit.h" | 27 | #include "pwminit.h" |
28 | #ifndef PWM_EMBEDDED | ||
28 | #include "configuration.h" | 29 | #include "configuration.h" |
30 | #else | ||
31 | #include "pwmprefs.h" | ||
32 | #endif | ||
29 | 33 | ||
30 | #include <klocale.h> | 34 | #include <klocale.h> |
31 | 35 | ||
32 | 36 | ||
33 | void ActiveTreeItem::execIt() | 37 | void ActiveTreeItem::execIt() |
34 | { | 38 | { |
35 | #ifndef PWM_EMBEDDED | 39 | #ifndef PWM_EMBEDDED |
36 | unsigned int entr = static_cast<unsigned int>(entry); | 40 | unsigned int entr = static_cast<unsigned int>(entry); |
37 | unsigned int cat = static_cast<unsigned int>(category); | 41 | unsigned int cat = static_cast<unsigned int>(category); |
38 | #else | 42 | #else |
39 | unsigned int entr = (unsigned int)(entry); | 43 | unsigned int entr = (unsigned int)(entry); |
40 | unsigned int cat = (unsigned int)(category); | 44 | unsigned int cat = (unsigned int)(category); |
41 | #endif | 45 | #endif |
42 | switch (task) { | 46 | switch (task) { |
43 | case pwToClipboard: { | 47 | case pwToClipboard: { |
44 | PwMDataItem d; | 48 | PwMDataItem d; |
45 | doc->getDataChangedLock(); | 49 | doc->getDataChangedLock(); |
46 | bool wasLocked = doc->isLocked(cat, entr); | 50 | bool wasLocked = doc->isLocked(cat, entr); |
47 | doc->getEntry(cat, entr, &d, true); | 51 | doc->getEntry(cat, entr, &d, true); |
48 | if (wasLocked) | 52 | if (wasLocked) |
49 | doc->lockAt(cat, entr, true); | 53 | doc->lockAt(cat, entr, true); |
50 | doc->putDataChangedLock(); | 54 | doc->putDataChangedLock(); |
51 | PwM::copyToClipboard(d.pw.c_str()); | 55 | PwM::copyToClipboard(d.pw.c_str()); |
52 | break; | 56 | break; |
53 | } case nameToClipboard: { | 57 | } case nameToClipboard: { |
54 | PwMDataItem d; | 58 | PwMDataItem d; |
55 | doc->getEntry(cat, entr, &d); | 59 | doc->getEntry(cat, entr, &d); |
56 | PwM::copyToClipboard(d.name.c_str()); | 60 | PwM::copyToClipboard(d.name.c_str()); |
57 | break; | 61 | break; |
58 | } case descToClipboard: { | 62 | } case descToClipboard: { |
59 | PwMDataItem d; | 63 | PwMDataItem d; |
60 | doc->getEntry(cat, entr, &d); | 64 | doc->getEntry(cat, entr, &d); |
61 | PwM::copyToClipboard(d.desc.c_str()); | 65 | PwM::copyToClipboard(d.desc.c_str()); |
62 | break; | 66 | break; |
63 | } case urlToClipboard: { | 67 | } case urlToClipboard: { |
64 | PwMDataItem d; | 68 | PwMDataItem d; |
65 | doc->getEntry(cat, entr, &d); | 69 | doc->getEntry(cat, entr, &d); |
66 | PwM::copyToClipboard(d.url.c_str()); | 70 | PwM::copyToClipboard(d.url.c_str()); |
67 | break; | 71 | break; |
68 | } case launcherToClipboard: { | 72 | } case launcherToClipboard: { |
69 | PwMDataItem d; | 73 | PwMDataItem d; |
70 | doc->getEntry(cat, entr, &d); | 74 | doc->getEntry(cat, entr, &d); |
71 | PwM::copyToClipboard(d.launcher.c_str()); | 75 | PwM::copyToClipboard(d.launcher.c_str()); |
72 | break; | 76 | break; |
73 | } case commentToClipboard: { | 77 | } case commentToClipboard: { |
74 | PwMDataItem d; | 78 | PwMDataItem d; |
75 | doc->getEntry(cat, entr, &d); | 79 | doc->getEntry(cat, entr, &d); |
76 | PwM::copyToClipboard(d.comment.c_str()); | 80 | PwM::copyToClipboard(d.comment.c_str()); |
77 | break; | 81 | break; |
78 | } case execLauncher: { | 82 | } case execLauncher: { |
79 | doc->execLauncher(cat, entr); | 83 | doc->execLauncher(cat, entr); |
80 | break; | 84 | break; |
81 | } case goToURL: { | 85 | } case goToURL: { |
82 | doc->goToURL(cat, entr); | 86 | doc->goToURL(cat, entr); |
83 | break; | 87 | break; |
84 | } case openMainWnd: { | 88 | } case openMainWnd: { |
85 | // search if there is already an open window. | 89 | // search if there is already an open window. |
86 | const QValueList<PwM *> *wl = tray->init->mainWndList(); | 90 | const QValueList<PwM *> *wl = tray->init->mainWndList(); |
87 | #ifndef PWM_EMBEDDED | 91 | #ifndef PWM_EMBEDDED |
88 | QValueList<PwM *>::const_iterator i = wl->begin(), | 92 | QValueList<PwM *>::const_iterator i = wl->begin(), |
89 | end = wl->end(); | 93 | end = wl->end(); |
90 | #else | 94 | #else |
91 | QValueList<PwM *>::ConstIterator i = wl->begin(), | 95 | QValueList<PwM *>::ConstIterator i = wl->begin(), |
92 | end = wl->end(); | 96 | end = wl->end(); |
93 | #endif | 97 | #endif |
94 | PwM *wnd; | 98 | PwM *wnd; |
95 | while (i != end) { | 99 | while (i != end) { |
96 | wnd = *i; | 100 | wnd = *i; |
97 | if (wnd->curDoc() == doc) { | 101 | if (wnd->curDoc() == doc) { |
98 | // now bring this window to the foreground. | 102 | // now bring this window to the foreground. |
99 | if (!wnd->hasFocus()) { | 103 | if (!wnd->hasFocus()) { |
100 | wnd->hide(); | 104 | wnd->hide(); |
101 | wnd->showNormal(); | 105 | wnd->showNormal(); |
102 | wnd->setFocus(); | 106 | wnd->setFocus(); |
103 | } | 107 | } |
104 | return; | 108 | return; |
105 | } | 109 | } |
106 | ++i; | 110 | ++i; |
107 | } | 111 | } |
108 | // there is no open window, so open a new one. | 112 | // there is no open window, so open a new one. |
109 | tray->init->createMainWnd(QString::null, false, false, doc); | 113 | tray->init->createMainWnd(QString::null, false, false, doc); |
110 | break; | 114 | break; |
111 | } case closeDoc: { | 115 | } case closeDoc: { |
112 | doc->tryDelete(); | 116 | doc->tryDelete(); |
113 | break; | 117 | break; |
114 | } case lock: { | 118 | } case lock: { |
115 | doc->lockAll(true); | 119 | doc->lockAll(true); |
116 | break; | 120 | break; |
117 | } case deepLock: { | 121 | } case deepLock: { |
118 | doc->deepLock(); | 122 | doc->deepLock(); |
119 | break; | 123 | break; |
120 | } case unlock: { | 124 | } case unlock: { |
121 | doc->lockAll(false); | 125 | doc->lockAll(false); |
122 | break; | 126 | break; |
123 | } default: { | 127 | } default: { |
124 | BUG(); | 128 | BUG(); |
125 | } | 129 | } |
126 | } | 130 | } |
127 | } | 131 | } |
128 | 132 | ||
129 | 133 | ||
130 | 134 | ||
131 | #ifndef PWM_EMBEDDED | 135 | #ifndef PWM_EMBEDDED |
132 | PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) | 136 | PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) |
133 | : KSystemTray(parent, name) | 137 | : KSystemTray(parent, name) |
134 | #else | 138 | #else |
135 | PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) | 139 | PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) |
136 | : QWidget(parent, name) | 140 | : QWidget(parent, name) |
137 | #endif | 141 | #endif |
138 | { | 142 | { |
139 | init = _init; | 143 | init = _init; |
140 | buildMain(); | 144 | buildMain(); |
141 | } | 145 | } |
142 | 146 | ||
143 | PwMTray::~PwMTray() | 147 | PwMTray::~PwMTray() |
144 | { | 148 | { |
145 | emit closed(this); | 149 | emit closed(this); |
146 | } | 150 | } |
147 | 151 | ||
148 | //US ENH for embedded tray class | 152 | //US ENH for embedded tray class |
149 | KPopupMenu* PwMTray::contextMenu() | 153 | KPopupMenu* PwMTray::contextMenu() |
150 | { | 154 | { |
151 | if (m_ctxMenu == 0) | 155 | if (m_ctxMenu == 0) |
152 | { | 156 | { |
153 | m_ctxMenu = new KPopupMenu(); | 157 | m_ctxMenu = new KPopupMenu(); |
154 | } | 158 | } |
155 | 159 | ||
156 | return m_ctxMenu; | 160 | return m_ctxMenu; |
157 | } | 161 | } |
158 | 162 | ||
159 | 163 | ||
160 | void PwMTray::buildMain() | 164 | void PwMTray::buildMain() |
161 | { | 165 | { |
162 | KPopupMenu *ctxMenu = contextMenu(); | 166 | KPopupMenu *ctxMenu = contextMenu(); |
163 | 167 | ||
164 | ctxMenu->insertSeparator(); | 168 | ctxMenu->insertSeparator(); |
165 | ctxMenu->insertItem(i18n("&New main window..."), this, | 169 | ctxMenu->insertItem(i18n("&New main window..."), this, |
166 | SLOT(newMainWnd())); | 170 | SLOT(newMainWnd())); |
167 | ctxMenu->insertItem(i18n("&Open file..."), this, | 171 | ctxMenu->insertItem(i18n("&Open file..."), this, |
168 | SLOT(openDoc())); | 172 | SLOT(openDoc())); |
169 | ctxMenu->insertSeparator(); | 173 | ctxMenu->insertSeparator(); |
170 | ctxMenu->insertItem(i18n("&Remove from tray"), this, | 174 | ctxMenu->insertItem(i18n("&Remove from tray"), this, |
171 | SLOT(undock())); | 175 | SLOT(undock())); |
172 | } | 176 | } |
173 | 177 | ||
174 | void PwMTray::insertActiveTreeItem(KPopupMenu *insertIn, const QString &text, | 178 | void PwMTray::insertActiveTreeItem(KPopupMenu *insertIn, const QString &text, |
175 | ActiveTreeItem::Task task, PwMDoc *doc, | 179 | ActiveTreeItem::Task task, PwMDoc *doc, |
176 | int docCategory, int docEntry, | 180 | int docCategory, int docEntry, |
177 | QValueList<int> *activeItemsList) | 181 | QValueList<int> *activeItemsList) |
178 | { | 182 | { |
179 | ActiveTreeItem *activeItem; | 183 | ActiveTreeItem *activeItem; |
180 | int id; | 184 | int id; |
181 | 185 | ||
182 | activeItem = new ActiveTreeItem(text, insertIn->font(), task, | 186 | activeItem = new ActiveTreeItem(text, insertIn->font(), task, |
183 | doc, docCategory, docEntry, | 187 | doc, docCategory, docEntry, |
184 | this); | 188 | this); |
185 | id = insertIn->insertItem(activeItem); | 189 | id = insertIn->insertItem(activeItem); |
186 | insertIn->connectItem(id, activeItem, SLOT(execIt())); | 190 | insertIn->connectItem(id, activeItem, SLOT(execIt())); |
187 | #ifndef PWM_EMBEDDED | 191 | #ifndef PWM_EMBEDDED |
188 | activeItemsList->push_back(id); | 192 | activeItemsList->push_back(id); |
189 | #else | 193 | #else |
190 | activeItemsList->append(id); | 194 | activeItemsList->append(id); |
191 | #endif | 195 | #endif |
192 | } | 196 | } |
193 | 197 | ||
194 | void PwMTray::rebuildTree(KPopupMenu *popup, PwMDoc *doc, | 198 | void PwMTray::rebuildTree(KPopupMenu *popup, PwMDoc *doc, |
195 | QValueList<int> *activeItems) | 199 | QValueList<int> *activeItems) |
196 | { | 200 | { |
197 | PWM_ASSERT(doc); | 201 | PWM_ASSERT(doc); |
198 | PWM_ASSERT(popup); | 202 | PWM_ASSERT(popup); |
199 | activeItems->clear(); | 203 | activeItems->clear(); |
200 | popup->clear(); | 204 | popup->clear(); |
201 | #ifndef PWM_EMBEDDED | 205 | #ifndef PWM_EMBEDDED |
202 | popup->insertTitle(i18n("Categories:")); | 206 | popup->insertTitle(i18n("Categories:")); |
203 | #endif | 207 | #endif |
204 | vector<string> catList; | 208 | vector<string> catList; |
205 | vector<string> entrList; | 209 | vector<string> entrList; |
206 | doc->getCategoryList(&catList); | 210 | doc->getCategoryList(&catList); |
207 | KPopupMenu *newCatMenu; | 211 | KPopupMenu *newCatMenu; |
208 | KPopupMenu *newEntrMenu; | 212 | KPopupMenu *newEntrMenu; |
209 | int i, size = catList.size(); | 213 | int i, size = catList.size(); |
210 | int j, entries; | 214 | int j, entries; |
211 | for (i = 0; i < size; ++i) { | 215 | for (i = 0; i < size; ++i) { |
212 | newCatMenu = new KPopupMenu(popup); | 216 | newCatMenu = new KPopupMenu(popup); |
213 | popup->insertItem(catList[i].c_str(), newCatMenu); | 217 | popup->insertItem(catList[i].c_str(), newCatMenu); |
214 | doc->getEntryList(i, &entrList); | 218 | doc->getEntryList(i, &entrList); |
215 | 219 | ||
216 | entries = entrList.size(); | 220 | entries = entrList.size(); |
217 | for (j = 0; j < entries; ++j) { | 221 | for (j = 0; j < entries; ++j) { |
218 | newEntrMenu = new KPopupMenu(newCatMenu); | 222 | newEntrMenu = new KPopupMenu(newCatMenu); |
219 | newCatMenu->insertItem(entrList[j].c_str(), newEntrMenu); | 223 | newCatMenu->insertItem(entrList[j].c_str(), newEntrMenu); |
220 | 224 | ||
221 | if (doc->isBinEntry(i, j)) { | 225 | if (doc->isBinEntry(i, j)) { |
222 | /* This is a binary entry. Don't insert the usual | 226 | /* This is a binary entry. Don't insert the usual |
223 | * menu items. | 227 | * menu items. |
224 | */ | 228 | */ |
225 | #ifndef PWM_EMBEDDED | 229 | #ifndef PWM_EMBEDDED |
226 | newEntrMenu->insertTitle(i18n("This is a binary entry.\n" | 230 | newEntrMenu->insertTitle(i18n("This is a binary entry.\n" |
227 | "It is not a normal password-entry, as it contains " | 231 | "It is not a normal password-entry, as it contains " |
228 | "binary data, which PwManager can't display here.")); | 232 | "binary data, which PwManager can't display here.")); |
229 | #endif | 233 | #endif |
230 | continue; | 234 | continue; |
231 | } | 235 | } |
232 | 236 | ||
233 | insertActiveTreeItem(newEntrMenu, | 237 | insertActiveTreeItem(newEntrMenu, |
234 | i18n("copy password to clipboard"), | 238 | i18n("copy password to clipboard"), |
235 | ActiveTreeItem::pwToClipboard, doc, i, j, | 239 | ActiveTreeItem::pwToClipboard, doc, i, j, |
236 | activeItems); | 240 | activeItems); |
237 | 241 | ||
238 | insertActiveTreeItem(newEntrMenu, | 242 | insertActiveTreeItem(newEntrMenu, |
239 | i18n("copy username to clipboard"), | 243 | i18n("copy username to clipboard"), |
240 | ActiveTreeItem::nameToClipboard, doc, i, j, | 244 | ActiveTreeItem::nameToClipboard, doc, i, j, |
241 | activeItems); | 245 | activeItems); |
242 | 246 | ||
243 | insertActiveTreeItem(newEntrMenu, | 247 | insertActiveTreeItem(newEntrMenu, |
244 | i18n("copy description to clipboard"), | 248 | i18n("copy description to clipboard"), |
245 | ActiveTreeItem::descToClipboard, doc, i, j, | 249 | ActiveTreeItem::descToClipboard, doc, i, j, |
246 | activeItems); | 250 | activeItems); |
247 | 251 | ||
248 | insertActiveTreeItem(newEntrMenu, | 252 | insertActiveTreeItem(newEntrMenu, |
249 | i18n("copy url to clipboard"), | 253 | i18n("copy url to clipboard"), |
250 | ActiveTreeItem::urlToClipboard, doc, i, j, | 254 | ActiveTreeItem::urlToClipboard, doc, i, j, |
251 | activeItems); | 255 | activeItems); |
252 | 256 | ||
253 | insertActiveTreeItem(newEntrMenu, | 257 | insertActiveTreeItem(newEntrMenu, |
254 | i18n("copy launcher to clipboard"), | 258 | i18n("copy launcher to clipboard"), |
255 | ActiveTreeItem::launcherToClipboard, doc, i, j, | 259 | ActiveTreeItem::launcherToClipboard, doc, i, j, |
256 | activeItems); | 260 | activeItems); |
257 | 261 | ||
258 | insertActiveTreeItem(newEntrMenu, | 262 | insertActiveTreeItem(newEntrMenu, |
259 | i18n("copy comment to clipboard"), | 263 | i18n("copy comment to clipboard"), |
260 | ActiveTreeItem::commentToClipboard, doc, i, j, | 264 | ActiveTreeItem::commentToClipboard, doc, i, j, |
261 | activeItems); | 265 | activeItems); |
262 | 266 | ||
263 | newEntrMenu->insertSeparator(); | 267 | newEntrMenu->insertSeparator(); |
264 | 268 | ||
265 | insertActiveTreeItem(newEntrMenu, | 269 | insertActiveTreeItem(newEntrMenu, |
266 | i18n("Execute \"Launcher\""), | 270 | i18n("Execute \"Launcher\""), |
267 | ActiveTreeItem::execLauncher, doc, i, j, | 271 | ActiveTreeItem::execLauncher, doc, i, j, |
268 | activeItems); | 272 | activeItems); |
269 | 273 | ||
270 | insertActiveTreeItem(newEntrMenu, | 274 | insertActiveTreeItem(newEntrMenu, |
271 | i18n("Go to \"URL\""), | 275 | i18n("Go to \"URL\""), |
272 | ActiveTreeItem::goToURL, doc, i, j, | 276 | ActiveTreeItem::goToURL, doc, i, j, |
273 | activeItems); | 277 | activeItems); |
274 | } | 278 | } |
275 | } | 279 | } |
276 | insertMainWndCtrl(popup, doc); | 280 | insertMainWndCtrl(popup, doc); |
277 | } | 281 | } |
278 | 282 | ||
279 | void PwMTray::insertMainWndCtrl(KPopupMenu *menu, PwMDoc *doc) | 283 | void PwMTray::insertMainWndCtrl(KPopupMenu *menu, PwMDoc *doc) |
280 | { | 284 | { |
281 | ActiveTreeItem *activeItem; | 285 | ActiveTreeItem *activeItem; |
282 | int id; | 286 | int id; |
283 | 287 | ||
284 | #ifndef PWM_EMBEDDED | 288 | #ifndef PWM_EMBEDDED |
285 | menu->insertTitle(i18n("Manager:")); | 289 | menu->insertTitle(i18n("Manager:")); |
286 | #endif | 290 | #endif |
287 | activeItem = new ActiveTreeItem(i18n("&Open main manager window ..."), | 291 | activeItem = new ActiveTreeItem(i18n("&Open main manager window ..."), |
288 | menu->font(), ActiveTreeItem::openMainWnd, | 292 | menu->font(), ActiveTreeItem::openMainWnd, |
289 | doc, 0, 0, this); | 293 | doc, 0, 0, this); |
290 | id = menu->insertItem(activeItem); | 294 | id = menu->insertItem(activeItem); |
291 | menu->connectItem(id, activeItem, SLOT(execIt())); | 295 | menu->connectItem(id, activeItem, SLOT(execIt())); |
292 | 296 | ||
293 | activeItem = new ActiveTreeItem(i18n("&Close this document ..."), | 297 | activeItem = new ActiveTreeItem(i18n("&Close this document ..."), |
294 | menu->font(), ActiveTreeItem::closeDoc, | 298 | menu->font(), ActiveTreeItem::closeDoc, |
295 | doc, 0, 0, this); | 299 | doc, 0, 0, this); |
296 | id = menu->insertItem(activeItem); | 300 | id = menu->insertItem(activeItem); |
297 | menu->connectItem(id, activeItem, SLOT(execIt())); | 301 | menu->connectItem(id, activeItem, SLOT(execIt())); |
298 | 302 | ||
299 | menu->insertSeparator(); | 303 | menu->insertSeparator(); |
300 | 304 | ||
301 | activeItem = new ActiveTreeItem(i18n("&Lock all entries"), | 305 | activeItem = new ActiveTreeItem(i18n("&Lock all entries"), |
302 | menu->font(), ActiveTreeItem::lock, | 306 | menu->font(), ActiveTreeItem::lock, |
303 | doc, 0, 0, this); | 307 | doc, 0, 0, this); |
304 | id = menu->insertItem(activeItem); | 308 | id = menu->insertItem(activeItem); |
305 | menu->connectItem(id, activeItem, SLOT(execIt())); | 309 | menu->connectItem(id, activeItem, SLOT(execIt())); |
306 | 310 | ||
307 | activeItem = new ActiveTreeItem(i18n("&Deep-lock all entries"), | 311 | activeItem = new ActiveTreeItem(i18n("&Deep-lock all entries"), |
308 | menu->font(), ActiveTreeItem::deepLock, | 312 | menu->font(), ActiveTreeItem::deepLock, |
309 | doc, 0, 0, this); | 313 | doc, 0, 0, this); |
310 | id = menu->insertItem(activeItem); | 314 | id = menu->insertItem(activeItem); |
311 | menu->connectItem(id, activeItem, SLOT(execIt())); | 315 | menu->connectItem(id, activeItem, SLOT(execIt())); |
312 | 316 | ||
313 | activeItem = new ActiveTreeItem(i18n("&Unlock all entries"), | 317 | activeItem = new ActiveTreeItem(i18n("&Unlock all entries"), |
314 | menu->font(), ActiveTreeItem::unlock, | 318 | menu->font(), ActiveTreeItem::unlock, |
315 | doc, 0, 0, this); | 319 | doc, 0, 0, this); |
316 | id = menu->insertItem(activeItem); | 320 | id = menu->insertItem(activeItem); |
317 | menu->connectItem(id, activeItem, SLOT(execIt())); | 321 | menu->connectItem(id, activeItem, SLOT(execIt())); |
318 | } | 322 | } |
319 | 323 | ||
320 | void PwMTray::updateTree(PwMDoc *document) | 324 | void PwMTray::updateTree(PwMDoc *document) |
321 | { | 325 | { |
322 | PWM_ASSERT(document); | 326 | PWM_ASSERT(document); |
323 | KPopupMenu *treeEntry; | 327 | KPopupMenu *treeEntry; |
324 | int treeItemNum = -1; | 328 | int treeItemNum = -1; |
325 | int id = findTreeEntry(document, &treeEntry, &treeItemNum); | 329 | int id = findTreeEntry(document, &treeEntry, &treeItemNum); |
326 | if (id == -1) { | 330 | if (id == -1) { |
327 | // tree-entry doesn't exist, yet. | 331 | // tree-entry doesn't exist, yet. |
328 | id = insertTreeEntry(document, &treeEntry); | 332 | id = insertTreeEntry(document, &treeEntry); |
329 | } | 333 | } |
330 | if (treeItemNum != -1) { | 334 | if (treeItemNum != -1) { |
331 | // delete all *old* active items | 335 | // delete all *old* active items |
332 | KPopupMenu *ctxMenu = contextMenu(); | 336 | KPopupMenu *ctxMenu = contextMenu(); |
333 | QValueList<int> *oldItems = &tree[treeItemNum].activeItems; | 337 | QValueList<int> *oldItems = &tree[treeItemNum].activeItems; |
334 | #ifndef PWM_EMBEDDED | 338 | #ifndef PWM_EMBEDDED |
335 | QValueList<int>::iterator i = oldItems->begin(); | 339 | QValueList<int>::iterator i = oldItems->begin(); |
336 | #else | 340 | #else |
337 | QValueList<int>::Iterator i = oldItems->begin(); | 341 | QValueList<int>::Iterator i = oldItems->begin(); |
338 | #endif | 342 | #endif |
339 | while (i != oldItems->end()) { | 343 | while (i != oldItems->end()) { |
340 | ctxMenu->removeItem(*i); | 344 | ctxMenu->removeItem(*i); |
341 | ++i; | 345 | ++i; |
342 | } | 346 | } |
343 | oldItems->clear(); | 347 | oldItems->clear(); |
344 | ctxMenu->changeItem(id, document->getTitle()); | 348 | ctxMenu->changeItem(id, document->getTitle()); |
345 | } | 349 | } |
346 | 350 | ||
347 | treeItem newTreeItem; | 351 | treeItem newTreeItem; |
348 | if (document->isDeepLocked()) { | 352 | if (document->isDeepLocked()) { |
349 | treeEntry->clear(); | 353 | treeEntry->clear(); |
350 | #ifndef PWM_EMBEDDED | 354 | #ifndef PWM_EMBEDDED |
351 | treeEntry->insertTitle(i18n("Categories:")); | 355 | treeEntry->insertTitle(i18n("Categories:")); |
352 | #endif | 356 | #endif |
353 | QString msg(IS_DEEPLOCKED_SHORTMSG); | 357 | QString msg(IS_DEEPLOCKED_SHORTMSG); |
354 | msg += " "; | 358 | msg += " "; |
355 | msg += i18n("(Click here to unlock)"); | 359 | msg += i18n("(Click here to unlock)"); |
356 | treeEntry->insertItem(msg, document, | 360 | treeEntry->insertItem(msg, document, |
357 | SLOT(_deepUnlock())); | 361 | SLOT(_deepUnlock())); |
358 | insertMainWndCtrl(treeEntry, document); | 362 | insertMainWndCtrl(treeEntry, document); |
359 | } else { | 363 | } else { |
360 | rebuildTree(treeEntry, document, &newTreeItem.activeItems); | 364 | rebuildTree(treeEntry, document, &newTreeItem.activeItems); |
361 | } | 365 | } |
362 | newTreeItem.menuId = id; | 366 | newTreeItem.menuId = id; |
363 | newTreeItem.doc = document; | 367 | newTreeItem.doc = document; |
364 | newTreeItem.menu = treeEntry; | 368 | newTreeItem.menu = treeEntry; |
365 | if (treeItemNum == -1) { | 369 | if (treeItemNum == -1) { |
366 | #ifndef PWM_EMBEDDED | 370 | #ifndef PWM_EMBEDDED |
367 | tree.push_back(newTreeItem); | 371 | tree.push_back(newTreeItem); |
368 | #else | 372 | #else |
369 | tree.append(newTreeItem); | 373 | tree.append(newTreeItem); |
370 | #endif | 374 | #endif |
371 | } else { | 375 | } else { |
372 | tree[treeItemNum] = newTreeItem; | 376 | tree[treeItemNum] = newTreeItem; |
373 | } | 377 | } |
374 | } | 378 | } |
375 | 379 | ||
376 | void PwMTray::closeTreeEntry(PwMDoc *document) | 380 | void PwMTray::closeTreeEntry(PwMDoc *document) |
377 | { | 381 | { |
378 | KPopupMenu *menu; | 382 | KPopupMenu *menu; |
379 | int treeItem; | 383 | int treeItem; |
380 | int id = findTreeEntry(document, &menu, &treeItem); | 384 | int id = findTreeEntry(document, &menu, &treeItem); |
381 | if (id != -1) { | 385 | if (id != -1) { |
382 | removeTreeEntry(id, treeItem, &menu); | 386 | removeTreeEntry(id, treeItem, &menu); |
383 | } | 387 | } |
384 | } | 388 | } |
385 | 389 | ||
386 | int PwMTray::findTreeEntry(PwMDoc *doc, KPopupMenu **menu, int *treeItem) | 390 | int PwMTray::findTreeEntry(PwMDoc *doc, KPopupMenu **menu, int *treeItem) |
387 | { | 391 | { |
388 | PWM_ASSERT(doc); | 392 | PWM_ASSERT(doc); |
389 | #ifndef PWM_EMBEDDED | 393 | #ifndef PWM_EMBEDDED |
390 | int i, count = tree.size(); | 394 | int i, count = tree.size(); |
391 | #else | 395 | #else |
392 | int i, count = tree.count(); | 396 | int i, count = tree.count(); |
393 | #endif | 397 | #endif |
394 | for (i = 0; i < count; ++i) { | 398 | for (i = 0; i < count; ++i) { |
395 | if (tree[i].doc == doc) { | 399 | if (tree[i].doc == doc) { |
396 | if (menu) | 400 | if (menu) |
397 | *menu = tree[i].menu; | 401 | *menu = tree[i].menu; |
398 | if (treeItem) | 402 | if (treeItem) |
399 | *treeItem = i; | 403 | *treeItem = i; |
400 | return tree[i].menuId; | 404 | return tree[i].menuId; |
401 | } | 405 | } |
402 | } | 406 | } |
403 | if (menu) | 407 | if (menu) |
404 | *menu = 0; | 408 | *menu = 0; |
405 | if (treeItem) | 409 | if (treeItem) |
406 | *treeItem = -1; | 410 | *treeItem = -1; |
407 | return -1; | 411 | return -1; |
408 | } | 412 | } |
409 | 413 | ||
410 | int PwMTray::insertTreeEntry(PwMDoc *doc, KPopupMenu **popup) | 414 | int PwMTray::insertTreeEntry(PwMDoc *doc, KPopupMenu **popup) |
411 | { | 415 | { |
412 | PWM_ASSERT(doc); | 416 | PWM_ASSERT(doc); |
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp index c09fbf5..58c2fca 100644 --- a/pwmanager/pwmanager/pwmview.cpp +++ b/pwmanager/pwmanager/pwmview.cpp | |||
@@ -1,409 +1,413 @@ | |||
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 "pwmview.h" | 20 | #include "pwmview.h" |
21 | #include "pwmexception.h" | 21 | #include "pwmexception.h" |
22 | #include "globalstuff.h" | 22 | #include "globalstuff.h" |
23 | #include "pwm.h" | 23 | #include "pwm.h" |
24 | #include "rencatwnd.h" | 24 | #include "rencatwnd.h" |
25 | #ifndef PWM_EMBEDDED | ||
25 | #include "configuration.h" | 26 | #include "configuration.h" |
27 | #else | ||
28 | #include "pwmprefs.h" | ||
29 | #endif | ||
26 | #include "commentbox.h" | 30 | #include "commentbox.h" |
27 | 31 | ||
28 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
29 | #include <klocale.h> | 33 | #include <klocale.h> |
30 | 34 | ||
31 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
32 | #include <qpoint.h> | 36 | #include <qpoint.h> |
33 | #include <qapplication.h> | 37 | #include <qapplication.h> |
34 | 38 | ||
35 | #define COLUMN_DESC 0 | 39 | #define COLUMN_DESC 0 |
36 | #define COLUMN_NAME 1 | 40 | #define COLUMN_NAME 1 |
37 | #define COLUMN_PW 2 | 41 | #define COLUMN_PW 2 |
38 | #define COLUMN_URL 3 | 42 | #define COLUMN_URL 3 |
39 | #define COLUMN_LAUNCHER 4 | 43 | #define COLUMN_LAUNCHER 4 |
40 | 44 | ||
41 | 45 | ||
42 | PwMView::PwMView(PwM *_mainClass, | 46 | PwMView::PwMView(PwM *_mainClass, |
43 | QWidget *parent, PwMDoc *_doc, | 47 | QWidget *parent, PwMDoc *_doc, |
44 | const char *name) | 48 | const char *name) |
45 | : PwMViewStyle(parent, name) | 49 | : PwMViewStyle(parent, name) |
46 | { | 50 | { |
47 | PWM_ASSERT(_mainClass); | 51 | PWM_ASSERT(_mainClass); |
48 | PWM_ASSERT(parent); | 52 | PWM_ASSERT(parent); |
49 | PWM_ASSERT(_doc); | 53 | PWM_ASSERT(_doc); |
50 | setView(this); | 54 | setView(this); |
51 | doc = _doc; | 55 | doc = _doc; |
52 | doc->setListViewPointer(this); | 56 | doc->setListViewPointer(this); |
53 | mainClass = _mainClass; | 57 | mainClass = _mainClass; |
54 | resize(_mainClass->size()); | 58 | resize(_mainClass->size()); |
55 | initStyle(conf()->confWndMainViewStyle()); | 59 | initStyle(conf()->confWndMainViewStyle()); |
56 | initCtxMenu(); | 60 | initCtxMenu(); |
57 | doc->setCurrentView(this); | 61 | doc->setCurrentView(this); |
58 | connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); | 62 | connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); |
59 | } | 63 | } |
60 | 64 | ||
61 | PwMView::~PwMView() | 65 | PwMView::~PwMView() |
62 | { | 66 | { |
63 | } | 67 | } |
64 | 68 | ||
65 | void PwMView::initCtxMenu() | 69 | void PwMView::initCtxMenu() |
66 | { | 70 | { |
67 | ctxMenu = new QPopupMenu(this); | 71 | ctxMenu = new QPopupMenu(this); |
68 | ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); | 72 | ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); |
69 | ctxMenu->insertSeparator(); | 73 | ctxMenu->insertSeparator(); |
70 | ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); | 74 | ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); |
71 | ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); | 75 | ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); |
72 | ctxMenu->insertSeparator(); | 76 | ctxMenu->insertSeparator(); |
73 | ctxMenu->insertItem(i18n("copy password to clipboard"), | 77 | ctxMenu->insertItem(i18n("copy password to clipboard"), |
74 | this, SLOT(copyPwToClip())); | 78 | this, SLOT(copyPwToClip())); |
75 | ctxMenu->insertItem(i18n("copy username to clipboard"), | 79 | ctxMenu->insertItem(i18n("copy username to clipboard"), |
76 | this, SLOT(copyNameToClip())); | 80 | this, SLOT(copyNameToClip())); |
77 | ctxMenu->insertItem(i18n("copy description to clipboard"), | 81 | ctxMenu->insertItem(i18n("copy description to clipboard"), |
78 | this, SLOT(copyDescToClip())); | 82 | this, SLOT(copyDescToClip())); |
79 | ctxMenu->insertItem(i18n("copy url to clipboard"), | 83 | ctxMenu->insertItem(i18n("copy url to clipboard"), |
80 | this, SLOT(copyUrlToClip())); | 84 | this, SLOT(copyUrlToClip())); |
81 | ctxMenu->insertItem(i18n("copy launcher to clipboard"), | 85 | ctxMenu->insertItem(i18n("copy launcher to clipboard"), |
82 | this, SLOT(copyLauncherToClip())); | 86 | this, SLOT(copyLauncherToClip())); |
83 | ctxMenu->insertItem(i18n("copy comment to clipboard"), | 87 | ctxMenu->insertItem(i18n("copy comment to clipboard"), |
84 | this, SLOT(copyCommentToClip())); | 88 | this, SLOT(copyCommentToClip())); |
85 | ctxMenu->insertSeparator(); | 89 | ctxMenu->insertSeparator(); |
86 | ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, | 90 | ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, |
87 | SLOT(execLauncher_slot())); | 91 | SLOT(execLauncher_slot())); |
88 | ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, | 92 | ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, |
89 | SLOT(goToURL_slot())); | 93 | SLOT(goToURL_slot())); |
90 | } | 94 | } |
91 | 95 | ||
92 | void PwMView::resizeEvent(QResizeEvent *) | 96 | void PwMView::resizeEvent(QResizeEvent *) |
93 | { | 97 | { |
94 | resizeView(size()); | 98 | resizeView(size()); |
95 | } | 99 | } |
96 | 100 | ||
97 | void PwMView::refreshCommentTextEdit(QListViewItem *curItem) | 101 | void PwMView::refreshCommentTextEdit(QListViewItem *curItem) |
98 | { | 102 | { |
99 | PWM_ASSERT(commentBox); | 103 | PWM_ASSERT(commentBox); |
100 | if (!curItem) | 104 | if (!curItem) |
101 | return; | 105 | return; |
102 | string comment; | 106 | string comment; |
103 | PwMerror ret; | 107 | PwMerror ret; |
104 | ret = document()->getCommentByLvp(getCurrentCategory(), | 108 | ret = document()->getCommentByLvp(getCurrentCategory(), |
105 | lv->childCount() - lv->itemIndex(curItem) - 1, | 109 | lv->childCount() - lv->itemIndex(curItem) - 1, |
106 | &comment); | 110 | &comment); |
107 | if (ret == e_binEntry) { | 111 | if (ret == e_binEntry) { |
108 | commentBox->setContent(i18n("This is a binary entry.\n" | 112 | commentBox->setContent(i18n("This is a binary entry.\n" |
109 | "It is not a normal password-entry, as it contains " | 113 | "It is not a normal password-entry, as it contains " |
110 | "binary data, which PwManager can't display here.")); | 114 | "binary data, which PwManager can't display here.")); |
111 | } else if (ret == e_normalEntry) { | 115 | } else if (ret == e_normalEntry) { |
112 | commentBox->setContent(comment.c_str()); | 116 | commentBox->setContent(comment.c_str()); |
113 | } else { | 117 | } else { |
114 | BUG(); | 118 | BUG(); |
115 | return; | 119 | return; |
116 | } | 120 | } |
117 | lv->ensureItemVisible(curItem); | 121 | lv->ensureItemVisible(curItem); |
118 | } | 122 | } |
119 | 123 | ||
120 | void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) | 124 | void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) |
121 | { | 125 | { |
122 | refreshCommentTextEdit(lv->currentItem()); | 126 | refreshCommentTextEdit(lv->currentItem()); |
123 | } | 127 | } |
124 | 128 | ||
125 | bool PwMView::getCurEntryIndex(unsigned int *index) | 129 | bool PwMView::getCurEntryIndex(unsigned int *index) |
126 | { | 130 | { |
127 | QListViewItem *current = lv->currentItem(); | 131 | QListViewItem *current = lv->currentItem(); |
128 | if (!current) | 132 | if (!current) |
129 | return false; | 133 | return false; |
130 | return getDocEntryIndex(index, current); | 134 | return getDocEntryIndex(index, current); |
131 | } | 135 | } |
132 | 136 | ||
133 | bool PwMView::getDocEntryIndex(unsigned int *index, | 137 | bool PwMView::getDocEntryIndex(unsigned int *index, |
134 | const QListViewItem *item) | 138 | const QListViewItem *item) |
135 | { | 139 | { |
136 | vector<unsigned int> foundPositions; | 140 | vector<unsigned int> foundPositions; |
137 | PwMDataItem curItem; | 141 | PwMDataItem curItem; |
138 | curItem.desc = item->text(COLUMN_DESC).latin1(); | 142 | curItem.desc = item->text(COLUMN_DESC).latin1(); |
139 | curItem.name = item->text(COLUMN_NAME).latin1(); | 143 | curItem.name = item->text(COLUMN_NAME).latin1(); |
140 | document()->getCommentByLvp(getCurrentCategory(), | 144 | document()->getCommentByLvp(getCurrentCategory(), |
141 | lv->childCount() - lv->itemIndex(item) - 1, | 145 | lv->childCount() - lv->itemIndex(item) - 1, |
142 | &curItem.comment); | 146 | &curItem.comment); |
143 | curItem.url = item->text(COLUMN_URL).latin1(); | 147 | curItem.url = item->text(COLUMN_URL).latin1(); |
144 | curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); | 148 | curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); |
145 | document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | | 149 | document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | |
146 | SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | | 150 | SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | |
147 | SEARCH_IN_LAUNCHER, | 151 | SEARCH_IN_LAUNCHER, |
148 | &foundPositions, true); | 152 | &foundPositions, true); |
149 | if (foundPositions.size()) { | 153 | if (foundPositions.size()) { |
150 | *index = foundPositions[0]; | 154 | *index = foundPositions[0]; |
151 | return true; | 155 | return true; |
152 | } | 156 | } |
153 | 157 | ||
154 | return false; | 158 | return false; |
155 | } | 159 | } |
156 | 160 | ||
157 | void PwMView::handleToggle(QListViewItem *item) | 161 | void PwMView::handleToggle(QListViewItem *item) |
158 | { | 162 | { |
159 | PWM_ASSERT(doc); | 163 | PWM_ASSERT(doc); |
160 | if (!item) | 164 | if (!item) |
161 | return; | 165 | return; |
162 | QCheckListItem *clItem = (QCheckListItem *)item; | 166 | QCheckListItem *clItem = (QCheckListItem *)item; |
163 | QString curCat(getCurrentCategory()); | 167 | QString curCat(getCurrentCategory()); |
164 | 168 | ||
165 | // find document position of this entry. | 169 | // find document position of this entry. |
166 | unsigned int curEntryDocIndex; | 170 | unsigned int curEntryDocIndex; |
167 | if (!getDocEntryIndex(&curEntryDocIndex, item)) | 171 | if (!getDocEntryIndex(&curEntryDocIndex, item)) |
168 | return; | 172 | return; |
169 | 173 | ||
170 | // hack to refresh the comment, if only one item is present | 174 | // hack to refresh the comment, if only one item is present |
171 | if (lv->childCount() == 1) | 175 | if (lv->childCount() == 1) |
172 | refreshCommentTextEdit(lv->currentItem()); | 176 | refreshCommentTextEdit(lv->currentItem()); |
173 | 177 | ||
174 | if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn()) | 178 | if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn()) |
175 | return; // this is just a click somewhere on the entry | 179 | return; // this is just a click somewhere on the entry |
176 | if (doc->isDeepLocked()) { | 180 | if (doc->isDeepLocked()) { |
177 | PwMerror ret; | 181 | PwMerror ret; |
178 | ret = doc->deepLock(false); | 182 | ret = doc->deepLock(false); |
179 | if (ret != e_success) | 183 | if (ret != e_success) |
180 | clItem->setOn(false); | 184 | clItem->setOn(false); |
181 | return; | 185 | return; |
182 | } | 186 | } |
183 | doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); | 187 | doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); |
184 | } | 188 | } |
185 | 189 | ||
186 | void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) | 190 | void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) |
187 | { | 191 | { |
188 | if (!item) | 192 | if (!item) |
189 | return; | 193 | return; |
190 | ctxMenu->move(point); | 194 | ctxMenu->move(point); |
191 | /* don't use ctxMenu->exec() here, as it generates race conditions | 195 | /* don't use ctxMenu->exec() here, as it generates race conditions |
192 | * with the card interface code. Believe it or not. :) | 196 | * with the card interface code. Believe it or not. :) |
193 | */ | 197 | */ |
194 | ctxMenu->show(); | 198 | ctxMenu->show(); |
195 | } | 199 | } |
196 | 200 | ||
197 | void PwMView::updateCategories() | 201 | void PwMView::updateCategories() |
198 | { | 202 | { |
199 | QString oldSel(getCurrentCategory()); | 203 | QString oldSel(getCurrentCategory()); |
200 | delAllCategories(); | 204 | delAllCategories(); |
201 | QStringList catList; | 205 | QStringList catList; |
202 | document()->getCategoryList(&catList); | 206 | document()->getCategoryList(&catList); |
203 | catList.sort(); | 207 | catList.sort(); |
204 | #ifndef PWM_EMBEDDED | 208 | #ifndef PWM_EMBEDDED |
205 | QStringList::iterator i = catList.begin(), | 209 | QStringList::iterator i = catList.begin(), |
206 | end = catList.end(); | 210 | end = catList.end(); |
207 | #else | 211 | #else |
208 | QStringList::Iterator i = catList.begin(), | 212 | QStringList::Iterator i = catList.begin(), |
209 | end = catList.end(); | 213 | end = catList.end(); |
210 | #endif | 214 | #endif |
211 | while (i != end) { | 215 | while (i != end) { |
212 | addCategory(*i); | 216 | addCategory(*i); |
213 | ++i; | 217 | ++i; |
214 | } | 218 | } |
215 | selectCategory(oldSel); | 219 | selectCategory(oldSel); |
216 | } | 220 | } |
217 | 221 | ||
218 | void PwMView::shiftToView() | 222 | void PwMView::shiftToView() |
219 | { | 223 | { |
220 | int cX = lv->contentsX(); | 224 | int cX = lv->contentsX(); |
221 | int cY = lv->contentsY(); | 225 | int cY = lv->contentsY(); |
222 | commentBox->clear(); | 226 | commentBox->clear(); |
223 | 227 | ||
224 | unsigned int catDocIndex; | 228 | unsigned int catDocIndex; |
225 | if (unlikely( | 229 | if (unlikely( |
226 | !(document()->findCategory(getCurrentCategory(), | 230 | !(document()->findCategory(getCurrentCategory(), |
227 | &catDocIndex)))) { | 231 | &catDocIndex)))) { |
228 | BUG(); | 232 | BUG(); |
229 | } | 233 | } |
230 | 234 | ||
231 | // ensure all listViewPos are set | 235 | // ensure all listViewPos are set |
232 | doc->ensureLvp(); | 236 | doc->ensureLvp(); |
233 | 237 | ||
234 | // clear all tmp-data vectors | 238 | // clear all tmp-data vectors |
235 | unsigned int i, entries = doc->numEntries(catDocIndex); | 239 | unsigned int i, entries = doc->numEntries(catDocIndex); |
236 | if (entries) { | 240 | if (entries) { |
237 | mainClass->setVirgin(false); | 241 | mainClass->setVirgin(false); |
238 | } | 242 | } |
239 | vector<PwMDataItem> tmpSorted; | 243 | vector<PwMDataItem> tmpSorted; |
240 | PwMDataItem currItem; | 244 | PwMDataItem currItem; |
241 | currItem.clear(); | 245 | currItem.clear(); |
242 | tmpSorted.insert(tmpSorted.begin(), entries, currItem); | 246 | tmpSorted.insert(tmpSorted.begin(), entries, currItem); |
243 | 247 | ||
244 | // Sort items and store them in tempoary tmpSorted. | 248 | // Sort items and store them in tempoary tmpSorted. |
245 | for (i = 0; i < entries; ++i) { | 249 | for (i = 0; i < entries; ++i) { |
246 | doc->getEntry(catDocIndex, i, &currItem); | 250 | doc->getEntry(catDocIndex, i, &currItem); |
247 | tmpSorted[currItem.listViewPos] = currItem; | 251 | tmpSorted[currItem.listViewPos] = currItem; |
248 | } | 252 | } |
249 | 253 | ||
250 | // shift tempoary data to ListView. | 254 | // shift tempoary data to ListView. |
251 | tmpDisableSort(); | 255 | tmpDisableSort(); |
252 | lv->clear(); | 256 | lv->clear(); |
253 | QCheckListItem *newItem; | 257 | QCheckListItem *newItem; |
254 | vector<PwMDataItem>::iterator it = tmpSorted.begin(), | 258 | vector<PwMDataItem>::iterator it = tmpSorted.begin(), |
255 | end = tmpSorted.end(); | 259 | end = tmpSorted.end(); |
256 | while (it != end) { | 260 | while (it != end) { |
257 | newItem = new ListViewItemPwM(lv); | 261 | newItem = new ListViewItemPwM(lv); |
258 | newItem->setText(COLUMN_DESC, (*it).desc.c_str()); | 262 | newItem->setText(COLUMN_DESC, (*it).desc.c_str()); |
259 | if ((*it).binary) { | 263 | if ((*it).binary) { |
260 | newItem->setText(COLUMN_NAME, ""); | 264 | newItem->setText(COLUMN_NAME, ""); |
261 | newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>")); | 265 | newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>")); |
262 | newItem->setText(COLUMN_URL, ""); | 266 | newItem->setText(COLUMN_URL, ""); |
263 | newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); | 267 | newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); |
264 | } else { | 268 | } else { |
265 | newItem->setText(COLUMN_NAME, (*it).name.c_str()); | 269 | newItem->setText(COLUMN_NAME, (*it).name.c_str()); |
266 | if ((*it).lockStat) { | 270 | if ((*it).lockStat) { |
267 | newItem->setText(COLUMN_PW, QString((*it).pw.c_str()) | 271 | newItem->setText(COLUMN_PW, QString((*it).pw.c_str()) |
268 | + " " | 272 | + " " |
269 | + i18n("To unlock click the icon on the left.")); | 273 | + i18n("To unlock click the icon on the left.")); |
270 | } else { | 274 | } else { |
271 | newItem->setText(COLUMN_PW, (*it).pw.c_str()); | 275 | newItem->setText(COLUMN_PW, (*it).pw.c_str()); |
272 | } | 276 | } |
273 | newItem->setText(COLUMN_URL, (*it).url.c_str()); | 277 | newItem->setText(COLUMN_URL, (*it).url.c_str()); |
274 | newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); | 278 | newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); |
275 | } | 279 | } |
276 | newItem->setOn(!((*it).lockStat)); | 280 | newItem->setOn(!((*it).lockStat)); |
277 | lv->insertItem(newItem); | 281 | lv->insertItem(newItem); |
278 | ++it; | 282 | ++it; |
279 | } | 283 | } |
280 | tmpReEnableSort(); | 284 | tmpReEnableSort(); |
281 | 285 | ||
282 | if (cY || cX) | 286 | if (cY || cX) |
283 | lv->setContentsPos(cX, cY); | 287 | lv->setContentsPos(cX, cY); |
284 | } | 288 | } |
285 | 289 | ||
286 | void PwMView::reorgLp() | 290 | void PwMView::reorgLp() |
287 | { | 291 | { |
288 | if (!lv->childCount()) | 292 | if (!lv->childCount()) |
289 | return; | 293 | return; |
290 | PWM_ASSERT(doc); | 294 | PWM_ASSERT(doc); |
291 | PWM_ASSERT(!doc->isDocEmpty()); | 295 | PWM_ASSERT(!doc->isDocEmpty()); |
292 | QListViewItem *currItem; | 296 | QListViewItem *currItem; |
293 | vector<unsigned int> foundPos; | 297 | vector<unsigned int> foundPos; |
294 | /* This searchIn _should_ be: | 298 | /* This searchIn _should_ be: |
295 | *const unsigned int searchIn = SEARCH_IN_DESC; | 299 | *const unsigned int searchIn = SEARCH_IN_DESC; |
296 | * But we want backward compatibility (see comment in PwMDoc::addEntry()). | 300 | * But we want backward compatibility (see comment in PwMDoc::addEntry()). |
297 | * So we need to search again, if we don't find the entry. (see below) | 301 | * So we need to search again, if we don't find the entry. (see below) |
298 | */ | 302 | */ |
299 | const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | | 303 | const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | |
300 | SEARCH_IN_URL | SEARCH_IN_LAUNCHER; | 304 | SEARCH_IN_URL | SEARCH_IN_LAUNCHER; |
301 | QString curCat(getCurrentCategory()); | 305 | QString curCat(getCurrentCategory()); |
302 | PwMDataItem findThis; | 306 | PwMDataItem findThis; |
303 | unsigned int i, cnt = lv->childCount(); | 307 | unsigned int i, cnt = lv->childCount(); |
304 | for (i = 0; i < cnt; ++i) { | 308 | for (i = 0; i < cnt; ++i) { |
305 | currItem = lv->itemAtIndex(i); | 309 | currItem = lv->itemAtIndex(i); |
306 | findThis.desc = currItem->text(COLUMN_DESC).latin1(); | 310 | findThis.desc = currItem->text(COLUMN_DESC).latin1(); |
307 | findThis.name = currItem->text(COLUMN_NAME).latin1(); | 311 | findThis.name = currItem->text(COLUMN_NAME).latin1(); |
308 | findThis.url = currItem->text(COLUMN_URL).latin1(); | 312 | findThis.url = currItem->text(COLUMN_URL).latin1(); |
309 | findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1(); | 313 | findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1(); |
310 | doc->findEntry(curCat, findThis, searchIn, | 314 | doc->findEntry(curCat, findThis, searchIn, |
311 | &foundPos, true); | 315 | &foundPos, true); |
312 | if (!foundPos.size()) { | 316 | if (!foundPos.size()) { |
313 | /* Did not find the entry. We seem to have a binary | 317 | /* Did not find the entry. We seem to have a binary |
314 | * entry here (pray for it!). So search again with | 318 | * entry here (pray for it!). So search again with |
315 | * the "correct" searchIn flags. | 319 | * the "correct" searchIn flags. |
316 | */ | 320 | */ |
317 | const unsigned int searchIn2 = SEARCH_IN_DESC; | 321 | const unsigned int searchIn2 = SEARCH_IN_DESC; |
318 | doc->findEntry(curCat, findThis, searchIn2, | 322 | doc->findEntry(curCat, findThis, searchIn2, |
319 | &foundPos, true); | 323 | &foundPos, true); |
320 | if (unlikely(!foundPos.size())) { | 324 | if (unlikely(!foundPos.size())) { |
321 | BUG(); | 325 | BUG(); |
322 | continue; | 326 | continue; |
323 | } | 327 | } |
324 | /* We assert that it's a binary entry, now. | 328 | /* We assert that it's a binary entry, now. |
325 | * No chance to efficiently verify it here. | 329 | * No chance to efficiently verify it here. |
326 | */ | 330 | */ |
327 | } | 331 | } |
328 | doc->setListViewPos(curCat, foundPos[0], cnt - i - 1); | 332 | doc->setListViewPos(curCat, foundPos[0], cnt - i - 1); |
329 | } | 333 | } |
330 | } | 334 | } |
331 | 335 | ||
332 | void PwMView::selAt(int index) | 336 | void PwMView::selAt(int index) |
333 | { | 337 | { |
334 | QListViewItem *item = lv->itemAtIndex(index); | 338 | QListViewItem *item = lv->itemAtIndex(index); |
335 | if (!item) | 339 | if (!item) |
336 | return; | 340 | return; |
337 | lv->setCurrentItem(item); | 341 | lv->setCurrentItem(item); |
338 | lv->ensureItemVisible(item); | 342 | lv->ensureItemVisible(item); |
339 | } | 343 | } |
340 | 344 | ||
341 | void PwMView::renCatButton_slot() | 345 | void PwMView::renCatButton_slot() |
342 | { | 346 | { |
343 | if (doc->isDeepLocked()) | 347 | if (doc->isDeepLocked()) |
344 | return; | 348 | return; |
345 | RenCatWnd wnd(this); | 349 | RenCatWnd wnd(this); |
346 | if (wnd.exec() == 1) { | 350 | if (wnd.exec() == 1) { |
347 | QString newName(wnd.getNewName()); | 351 | QString newName(wnd.getNewName()); |
348 | if (newName == "") | 352 | if (newName == "") |
349 | return; | 353 | return; |
350 | document()->renameCategory(getCurrentCategory(), | 354 | document()->renameCategory(getCurrentCategory(), |
351 | newName); | 355 | newName); |
352 | } | 356 | } |
353 | } | 357 | } |
354 | 358 | ||
355 | void PwMView::delCatButton_slot() | 359 | void PwMView::delCatButton_slot() |
356 | { | 360 | { |
357 | if (doc->isDeepLocked()) | 361 | if (doc->isDeepLocked()) |
358 | return; | 362 | return; |
359 | if (numCategories() <= 1) { | 363 | if (numCategories() <= 1) { |
360 | mainClass->showStatMsg(i18n("Can't remove the last category.")); | 364 | mainClass->showStatMsg(i18n("Can't remove the last category.")); |
361 | return; | 365 | return; |
362 | } | 366 | } |
363 | if (KMessageBox::questionYesNo(this, | 367 | if (KMessageBox::questionYesNo(this, |
364 | i18n("Do you really want to " | 368 | i18n("Do you really want to " |
365 | "delete the selected " | 369 | "delete the selected " |
366 | "category? All password-" | 370 | "category? All password-" |
367 | "entries will be lost in " | 371 | "entries will be lost in " |
368 | "this category!"), | 372 | "this category!"), |
369 | i18n("Delete category?")) | 373 | i18n("Delete category?")) |
370 | == KMessageBox::No) { | 374 | == KMessageBox::No) { |
371 | return; | 375 | return; |
372 | } | 376 | } |
373 | document()->delCategory(getCurrentCategory()); | 377 | document()->delCategory(getCurrentCategory()); |
374 | } | 378 | } |
375 | 379 | ||
376 | void PwMView::copyPwToClip() | 380 | void PwMView::copyPwToClip() |
377 | { | 381 | { |
378 | if (doc->isDeepLocked()) | 382 | if (doc->isDeepLocked()) |
379 | return; | 383 | return; |
380 | unsigned int curIndex = 0; | 384 | unsigned int curIndex = 0; |
381 | if (!getCurEntryIndex(&curIndex)) | 385 | if (!getCurEntryIndex(&curIndex)) |
382 | return; | 386 | return; |
383 | PwMDataItem d; | 387 | PwMDataItem d; |
384 | document()->getDataChangedLock(); | 388 | document()->getDataChangedLock(); |
385 | document()->getEntry(getCurrentCategory(), curIndex, &d, true); | 389 | document()->getEntry(getCurrentCategory(), curIndex, &d, true); |
386 | document()->putDataChangedLock(); | 390 | document()->putDataChangedLock(); |
387 | PwM::copyToClipboard(d.pw.c_str()); | 391 | PwM::copyToClipboard(d.pw.c_str()); |
388 | } | 392 | } |
389 | 393 | ||
390 | void PwMView::copyNameToClip() | 394 | void PwMView::copyNameToClip() |
391 | { | 395 | { |
392 | if (doc->isDeepLocked()) | 396 | if (doc->isDeepLocked()) |
393 | return; | 397 | return; |
394 | unsigned int curIndex = 0; | 398 | unsigned int curIndex = 0; |
395 | if (!getCurEntryIndex(&curIndex)) | 399 | if (!getCurEntryIndex(&curIndex)) |
396 | return; | 400 | return; |
397 | PwMDataItem d; | 401 | PwMDataItem d; |
398 | document()->getEntry(getCurrentCategory(), curIndex, &d); | 402 | document()->getEntry(getCurrentCategory(), curIndex, &d); |
399 | PwM::copyToClipboard(d.name.c_str()); | 403 | PwM::copyToClipboard(d.name.c_str()); |
400 | } | 404 | } |
401 | 405 | ||
402 | void PwMView::copyDescToClip() | 406 | void PwMView::copyDescToClip() |
403 | { | 407 | { |
404 | if (doc->isDeepLocked()) | 408 | if (doc->isDeepLocked()) |
405 | return; | 409 | return; |
406 | unsigned int curIndex = 0; | 410 | unsigned int curIndex = 0; |
407 | if (!getCurEntryIndex(&curIndex)) | 411 | if (!getCurEntryIndex(&curIndex)) |
408 | return; | 412 | return; |
409 | PwMDataItem d; | 413 | PwMDataItem d; |
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp index 65e442d..f29ef6c 100644 --- a/pwmanager/pwmanager/serializer.cpp +++ b/pwmanager/pwmanager/serializer.cpp | |||
@@ -1,408 +1,409 @@ | |||
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 <klocale.h> | 26 | #include <klocale.h> |
26 | #endif | 27 | #endif |
27 | 28 | ||
28 | /* enable/disable serializer debugging (0/1) */ | 29 | /* enable/disable serializer debugging (0/1) */ |
29 | #define SERIALIZER_DEBUG0 | 30 | #define SERIALIZER_DEBUG0 |
30 | /* use the old xml tags for writing (0/1) */ | 31 | /* use the old xml tags for writing (0/1) */ |
31 | #define USE_OLD_TAGS 0 | 32 | #define USE_OLD_TAGS 0 |
32 | /* write a CDATA section (0/1) */ | 33 | /* write a CDATA section (0/1) */ |
33 | #define WRITE_CDATA_SEC 0 | 34 | #define WRITE_CDATA_SEC 0 |
34 | 35 | ||
35 | 36 | ||
36 | #define META_CREATE_DATE"c" | 37 | #define META_CREATE_DATE"c" |
37 | #define META_VALID_DATE "v" | 38 | #define META_VALID_DATE "v" |
38 | #define META_EXPIRE_DATE"e" | 39 | #define META_EXPIRE_DATE"e" |
39 | #define META_UPDATE_DATE"u" | 40 | #define META_UPDATE_DATE"u" |
40 | #define META_UPDATE_INT "i" | 41 | #define META_UPDATE_INT "i" |
41 | //US ENH : uniqueid | 42 | //US ENH : uniqueid |
42 | #define META_UNIQUEID "n" | 43 | #define META_UNIQUEID "n" |
43 | 44 | ||
44 | /* This is compatibility stuff. | 45 | /* This is compatibility stuff. |
45 | * The names of the entries have changed and here are the | 46 | * The names of the entries have changed and here are the |
46 | * new and old ones | 47 | * new and old ones |
47 | */ | 48 | */ |
48 | #define ROOT_MAGIC_OLD "PwM-xml-dat" | 49 | #define ROOT_MAGIC_OLD "PwM-xml-dat" |
49 | #define VER_STR_OLD "ver" | 50 | #define VER_STR_OLD "ver" |
50 | #define COMPAT_VER_OLD "0x02" | 51 | #define COMPAT_VER_OLD "0x02" |
51 | #define CAT_ROOT_OLD "categories" | 52 | #define CAT_ROOT_OLD "categories" |
52 | #define CAT_PREFIX_OLD "cat_" | 53 | #define CAT_PREFIX_OLD "cat_" |
53 | #define CAT_NAME_OLD "name" | 54 | #define CAT_NAME_OLD "name" |
54 | #define ENTRY_PREFIX_OLD"entry_" | 55 | #define ENTRY_PREFIX_OLD"entry_" |
55 | #define ENTRY_DESC_OLD "desc" | 56 | #define ENTRY_DESC_OLD "desc" |
56 | #define ENTRY_NAME_OLD "name" | 57 | #define ENTRY_NAME_OLD "name" |
57 | #define ENTRY_PW_OLD "pw" | 58 | #define ENTRY_PW_OLD "pw" |
58 | #define ENTRY_COMMENT_OLD"comment" | 59 | #define ENTRY_COMMENT_OLD"comment" |
59 | #define ENTRY_URL_OLD "url" | 60 | #define ENTRY_URL_OLD "url" |
60 | #define ENTRY_LAUNCHER_OLD"launcher" | 61 | #define ENTRY_LAUNCHER_OLD"launcher" |
61 | #define ENTRY_LVP_OLD "listViewPos" | 62 | #define ENTRY_LVP_OLD "listViewPos" |
62 | #define ENTRY_BIN_OLD "b" | 63 | #define ENTRY_BIN_OLD "b" |
63 | #define ENTRY_META_OLD "m" | 64 | #define ENTRY_META_OLD "m" |
64 | 65 | ||
65 | #define ROOT_MAGIC_NEW "P" | 66 | #define ROOT_MAGIC_NEW "P" |
66 | #define VER_STR_NEW "v" | 67 | #define VER_STR_NEW "v" |
67 | #define COMPAT_VER_NEW "2" | 68 | #define COMPAT_VER_NEW "2" |
68 | #define CAT_ROOT_NEW "c" | 69 | #define CAT_ROOT_NEW "c" |
69 | #define CAT_PREFIX_NEW "c" | 70 | #define CAT_PREFIX_NEW "c" |
70 | #define CAT_NAME_NEW "n" | 71 | #define CAT_NAME_NEW "n" |
71 | #define ENTRY_PREFIX_NEW"e" | 72 | #define ENTRY_PREFIX_NEW"e" |
72 | #define ENTRY_DESC_NEW "d" | 73 | #define ENTRY_DESC_NEW "d" |
73 | #define ENTRY_NAME_NEW "n" | 74 | #define ENTRY_NAME_NEW "n" |
74 | #define ENTRY_PW_NEW "p" | 75 | #define ENTRY_PW_NEW "p" |
75 | #define ENTRY_COMMENT_NEW"c" | 76 | #define ENTRY_COMMENT_NEW"c" |
76 | #define ENTRY_URL_NEW "u" | 77 | #define ENTRY_URL_NEW "u" |
77 | #define ENTRY_LAUNCHER_NEW"l" | 78 | #define ENTRY_LAUNCHER_NEW"l" |
78 | #define ENTRY_LVP_NEW "v" | 79 | #define ENTRY_LVP_NEW "v" |
79 | #define ENTRY_BIN_NEW ENTRY_BIN_OLD | 80 | #define ENTRY_BIN_NEW ENTRY_BIN_OLD |
80 | #define ENTRY_META_NEW ENTRY_META_OLD | 81 | #define ENTRY_META_NEW ENTRY_META_OLD |
81 | 82 | ||
82 | #if USE_OLD_TAGS != 0 | 83 | #if USE_OLD_TAGS != 0 |
83 | # define ROOT_MAGIC_WR ROOT_MAGIC_OLD | 84 | # define ROOT_MAGIC_WR ROOT_MAGIC_OLD |
84 | # define VER_STR_WR VER_STR_OLD | 85 | # define VER_STR_WR VER_STR_OLD |
85 | # define COMPAT_VER_WR COMPAT_VER_OLD | 86 | # define COMPAT_VER_WR COMPAT_VER_OLD |
86 | # define CAT_ROOT_WR CAT_ROOT_OLD | 87 | # define CAT_ROOT_WR CAT_ROOT_OLD |
87 | # define CAT_PREFIX_WR CAT_PREFIX_OLD | 88 | # define CAT_PREFIX_WR CAT_PREFIX_OLD |
88 | # define CAT_NAME_WR CAT_NAME_OLD | 89 | # define CAT_NAME_WR CAT_NAME_OLD |
89 | # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD | 90 | # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD |
90 | # define ENTRY_DESC_WR ENTRY_DESC_OLD | 91 | # define ENTRY_DESC_WR ENTRY_DESC_OLD |
91 | # define ENTRY_NAME_WR ENTRY_NAME_OLD | 92 | # define ENTRY_NAME_WR ENTRY_NAME_OLD |
92 | # define ENTRY_PW_WR ENTRY_PW_OLD | 93 | # define ENTRY_PW_WR ENTRY_PW_OLD |
93 | # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD | 94 | # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD |
94 | # define ENTRY_URL_WR ENTRY_URL_OLD | 95 | # define ENTRY_URL_WR ENTRY_URL_OLD |
95 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD | 96 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD |
96 | # define ENTRY_LVP_WR ENTRY_LVP_OLD | 97 | # define ENTRY_LVP_WR ENTRY_LVP_OLD |
97 | # define ENTRY_BIN_WR ENTRY_BIN_OLD | 98 | # define ENTRY_BIN_WR ENTRY_BIN_OLD |
98 | # define ENTRY_META_WR ENTRY_META_OLD | 99 | # define ENTRY_META_WR ENTRY_META_OLD |
99 | #else | 100 | #else |
100 | # define ROOT_MAGIC_WR ROOT_MAGIC_NEW | 101 | # define ROOT_MAGIC_WR ROOT_MAGIC_NEW |
101 | # define VER_STR_WR VER_STR_NEW | 102 | # define VER_STR_WR VER_STR_NEW |
102 | # define COMPAT_VER_WR COMPAT_VER_NEW | 103 | # define COMPAT_VER_WR COMPAT_VER_NEW |
103 | # define CAT_ROOT_WR CAT_ROOT_NEW | 104 | # define CAT_ROOT_WR CAT_ROOT_NEW |
104 | # define CAT_PREFIX_WR CAT_PREFIX_NEW | 105 | # define CAT_PREFIX_WR CAT_PREFIX_NEW |
105 | # define CAT_NAME_WR CAT_NAME_NEW | 106 | # define CAT_NAME_WR CAT_NAME_NEW |
106 | # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW | 107 | # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW |
107 | # define ENTRY_DESC_WR ENTRY_DESC_NEW | 108 | # define ENTRY_DESC_WR ENTRY_DESC_NEW |
108 | # define ENTRY_NAME_WR ENTRY_NAME_NEW | 109 | # define ENTRY_NAME_WR ENTRY_NAME_NEW |
109 | # define ENTRY_PW_WR ENTRY_PW_NEW | 110 | # define ENTRY_PW_WR ENTRY_PW_NEW |
110 | # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW | 111 | # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW |
111 | # define ENTRY_URL_WR ENTRY_URL_NEW | 112 | # define ENTRY_URL_WR ENTRY_URL_NEW |
112 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW | 113 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW |
113 | # define ENTRY_LVP_WR ENTRY_LVP_NEW | 114 | # define ENTRY_LVP_WR ENTRY_LVP_NEW |
114 | # define ENTRY_BIN_WR ENTRY_BIN_NEW | 115 | # define ENTRY_BIN_WR ENTRY_BIN_NEW |
115 | # define ENTRY_META_WR ENTRY_META_NEW | 116 | # define ENTRY_META_WR ENTRY_META_NEW |
116 | #endif | 117 | #endif |
117 | 118 | ||
118 | 119 | ||
119 | Serializer::Serializer() | 120 | Serializer::Serializer() |
120 | { | 121 | { |
121 | defaultLockStat = true; | 122 | defaultLockStat = true; |
122 | domDoc = new QDomDocument; | 123 | domDoc = new QDomDocument; |
123 | } | 124 | } |
124 | 125 | ||
125 | Serializer::Serializer(const QCString &buffer) | 126 | Serializer::Serializer(const QCString &buffer) |
126 | { | 127 | { |
127 | defaultLockStat = true; | 128 | defaultLockStat = true; |
128 | domDoc = new QDomDocument; | 129 | domDoc = new QDomDocument; |
129 | if (!parseXml(buffer)) { | 130 | if (!parseXml(buffer)) { |
130 | delete domDoc; | 131 | delete domDoc; |
131 | #ifndef PWM_EMBEDDED | 132 | #ifndef PWM_EMBEDDED |
132 | throw PwMException(PwMException::EX_PARSE); | 133 | throw PwMException(PwMException::EX_PARSE); |
133 | #else | 134 | #else |
134 | qDebug("Serializer::Serializer : Parse Exception "); | 135 | qDebug("Serializer::Serializer : Parse Exception "); |
135 | #endif | 136 | #endif |
136 | } | 137 | } |
137 | } | 138 | } |
138 | 139 | ||
139 | Serializer::~Serializer() | 140 | Serializer::~Serializer() |
140 | { | 141 | { |
141 | delete_ifnot_null(domDoc); | 142 | delete_ifnot_null(domDoc); |
142 | } | 143 | } |
143 | 144 | ||
144 | void Serializer::clear() | 145 | void Serializer::clear() |
145 | { | 146 | { |
146 | delete_ifnot_null(domDoc); | 147 | delete_ifnot_null(domDoc); |
147 | domDoc = new QDomDocument; | 148 | domDoc = new QDomDocument; |
148 | } | 149 | } |
149 | 150 | ||
150 | bool Serializer::parseXml(const QCString &buffer) | 151 | bool Serializer::parseXml(const QCString &buffer) |
151 | { | 152 | { |
152 | PWM_ASSERT(domDoc); | 153 | PWM_ASSERT(domDoc); |
153 | #ifndef PWM_EMBEDDED | 154 | #ifndef PWM_EMBEDDED |
154 | if (!domDoc->setContent(buffer, true)) | 155 | if (!domDoc->setContent(buffer, true)) |
155 | return false; | 156 | return false; |
156 | #else | 157 | #else |
157 | if (!domDoc->setContent(buffer)) | 158 | if (!domDoc->setContent(buffer)) |
158 | return false; | 159 | return false; |
159 | #endif | 160 | #endif |
160 | if (!checkValid()) | 161 | if (!checkValid()) |
161 | return false; | 162 | return false; |
162 | return true; | 163 | return true; |
163 | } | 164 | } |
164 | 165 | ||
165 | QCString Serializer::getXml() | 166 | QCString Serializer::getXml() |
166 | { | 167 | { |
167 | PWM_ASSERT(domDoc); | 168 | PWM_ASSERT(domDoc); |
168 | 169 | ||
169 | #ifndef PWM_EMBEDDED | 170 | #ifndef PWM_EMBEDDED |
170 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 | 171 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 |
171 | QCString tmp(domDoc->toCString(8)); | 172 | QCString tmp(domDoc->toCString(8)); |
172 | printDebug("<BEGIN Serializer::getXml() dump>\n"); | 173 | printDebug("<BEGIN Serializer::getXml() dump>\n"); |
173 | cout << tmp << endl; | 174 | cout << tmp << endl; |
174 | printDebug("<END Serializer::getXml() dump>"); | 175 | printDebug("<END Serializer::getXml() dump>"); |
175 | #endif // DEBUG | 176 | #endif // DEBUG |
176 | 177 | ||
177 | QCString ret(domDoc->toCString(0)); | 178 | QCString ret(domDoc->toCString(0)); |
178 | ret.replace('\n', ""); | 179 | ret.replace('\n', ""); |
179 | return ret; | 180 | return ret; |
180 | #else | 181 | #else |
181 | 182 | ||
182 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 | 183 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 |
183 | QCString tmp(" " + domDoc->toCString()); | 184 | QCString tmp(" " + domDoc->toCString()); |
184 | printDebug("<BEGIN Serializer::getXml() dump>\n"); | 185 | printDebug("<BEGIN Serializer::getXml() dump>\n"); |
185 | cout << tmp << endl; | 186 | cout << tmp << endl; |
186 | printDebug("<END Serializer::getXml() dump>"); | 187 | printDebug("<END Serializer::getXml() dump>"); |
187 | #endif // DEBUG | 188 | #endif // DEBUG |
188 | 189 | ||
189 | QCString ret(domDoc->toCString()); | 190 | QCString ret(domDoc->toCString()); |
190 | ret.replace(QRegExp("\n"), ""); | 191 | ret.replace(QRegExp("\n"), ""); |
191 | return ret; | 192 | return ret; |
192 | 193 | ||
193 | #endif | 194 | #endif |
194 | } | 195 | } |
195 | 196 | ||
196 | bool Serializer::serialize(const vector<PwMCategoryItem> &dta) | 197 | bool Serializer::serialize(const vector<PwMCategoryItem> &dta) |
197 | { | 198 | { |
198 | PWM_ASSERT(domDoc); | 199 | PWM_ASSERT(domDoc); |
199 | QDomElement root(genNewRoot()); | 200 | QDomElement root(genNewRoot()); |
200 | QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); | 201 | QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); |
201 | root.appendChild(catNode); | 202 | root.appendChild(catNode); |
202 | if (!addCategories(&catNode, dta)) | 203 | if (!addCategories(&catNode, dta)) |
203 | return false; | 204 | return false; |
204 | return true; | 205 | return true; |
205 | } | 206 | } |
206 | 207 | ||
207 | bool Serializer::deSerialize(vector<PwMCategoryItem> *dta) | 208 | bool Serializer::deSerialize(vector<PwMCategoryItem> *dta) |
208 | { | 209 | { |
209 | PWM_ASSERT(domDoc); | 210 | PWM_ASSERT(domDoc); |
210 | PWM_ASSERT(dta); | 211 | PWM_ASSERT(dta); |
211 | QDomElement root(domDoc->documentElement()); | 212 | QDomElement root(domDoc->documentElement()); |
212 | QDomNode n; | 213 | QDomNode n; |
213 | 214 | ||
214 | dta->clear(); | 215 | dta->clear(); |
215 | for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { | 216 | for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { |
216 | // find <categories> ... </categories> | 217 | // find <categories> ... </categories> |
217 | // <c> ... </c> | 218 | // <c> ... </c> |
218 | if (n.nodeName() == CAT_ROOT_NEW || | 219 | if (n.nodeName() == CAT_ROOT_NEW || |
219 | n.nodeName() == CAT_ROOT_OLD) { | 220 | n.nodeName() == CAT_ROOT_OLD) { |
220 | if (!readCategories(n, dta)) { | 221 | if (!readCategories(n, dta)) { |
221 | return false; | 222 | return false; |
222 | } | 223 | } |
223 | 224 | ||
224 | /* NOTE: We can stop processing here, as we | 225 | /* NOTE: We can stop processing here, as we |
225 | * don't have more nodes in root, yet. | 226 | * don't have more nodes in root, yet. |
226 | */ | 227 | */ |
227 | return true; | 228 | return true; |
228 | } | 229 | } |
229 | } | 230 | } |
230 | return false; | 231 | return false; |
231 | } | 232 | } |
232 | 233 | ||
233 | bool Serializer::readCategories(const QDomNode &n, | 234 | bool Serializer::readCategories(const QDomNode &n, |
234 | vector<PwMCategoryItem> *dta) | 235 | vector<PwMCategoryItem> *dta) |
235 | { | 236 | { |
236 | QDomNodeList nl(n.childNodes()); | 237 | QDomNodeList nl(n.childNodes()); |
237 | QDomNode cur; | 238 | QDomNode cur; |
238 | QString name; | 239 | QString name; |
239 | unsigned int numCat = nl.count(), i; | 240 | unsigned int numCat = nl.count(), i; |
240 | PwMCategoryItem curCat; | 241 | PwMCategoryItem curCat; |
241 | vector<PwMDataItem> curEntr; | 242 | vector<PwMDataItem> curEntr; |
242 | 243 | ||
243 | if (!numCat) { | 244 | if (!numCat) { |
244 | printDebug("Serializer::readCategories(): empty"); | 245 | printDebug("Serializer::readCategories(): empty"); |
245 | return false; | 246 | return false; |
246 | } | 247 | } |
247 | for (i = 0; i < numCat; ++i) { | 248 | for (i = 0; i < numCat; ++i) { |
248 | cur = nl.item(i); | 249 | cur = nl.item(i); |
249 | if (cur.nodeName().left(1) == CAT_PREFIX_NEW || | 250 | if (cur.nodeName().left(1) == CAT_PREFIX_NEW || |
250 | cur.nodeName().left(4) == CAT_PREFIX_OLD) { | 251 | cur.nodeName().left(4) == CAT_PREFIX_OLD) { |
251 | name = cur.toElement().attribute(CAT_NAME_NEW); | 252 | name = cur.toElement().attribute(CAT_NAME_NEW); |
252 | if (name == QString::null) | 253 | if (name == QString::null) |
253 | name = cur.toElement().attribute(CAT_NAME_OLD); | 254 | name = cur.toElement().attribute(CAT_NAME_OLD); |
254 | PWM_ASSERT(name != QString::null); | 255 | PWM_ASSERT(name != QString::null); |
255 | PWM_ASSERT(name != ""); | 256 | PWM_ASSERT(name != ""); |
256 | curCat.clear(); | 257 | curCat.clear(); |
257 | curCat.name = name.latin1(); | 258 | curCat.name = name.latin1(); |
258 | if (!readEntries(cur, &curEntr)) { | 259 | if (!readEntries(cur, &curEntr)) { |
259 | dta->clear(); | 260 | dta->clear(); |
260 | return false; | 261 | return false; |
261 | } | 262 | } |
262 | curCat.d = curEntr; | 263 | curCat.d = curEntr; |
263 | dta->push_back(curCat); | 264 | dta->push_back(curCat); |
264 | } else { | 265 | } else { |
265 | printDebug("Serializer::readCategories(): uh? not a category?"); | 266 | printDebug("Serializer::readCategories(): uh? not a category?"); |
266 | } | 267 | } |
267 | } | 268 | } |
268 | return true; | 269 | return true; |
269 | } | 270 | } |
270 | 271 | ||
271 | bool Serializer::readEntries(const QDomNode &n, | 272 | bool Serializer::readEntries(const QDomNode &n, |
272 | vector<PwMDataItem> *dta) | 273 | vector<PwMDataItem> *dta) |
273 | { | 274 | { |
274 | QDomNodeList nl(n.childNodes()); | 275 | QDomNodeList nl(n.childNodes()); |
275 | QDomNode cur; | 276 | QDomNode cur; |
276 | unsigned int numEntr = nl.count(), i; | 277 | unsigned int numEntr = nl.count(), i; |
277 | PwMDataItem curEntr; | 278 | PwMDataItem curEntr; |
278 | 279 | ||
279 | dta->clear(); | 280 | dta->clear(); |
280 | for (i = 0; i < numEntr; ++i) { | 281 | for (i = 0; i < numEntr; ++i) { |
281 | cur = nl.item(i); | 282 | cur = nl.item(i); |
282 | if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW || | 283 | if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW || |
283 | cur.nodeName().left(6) == ENTRY_PREFIX_OLD) { | 284 | cur.nodeName().left(6) == ENTRY_PREFIX_OLD) { |
284 | if (!extractEntry(cur, &curEntr)) { | 285 | if (!extractEntry(cur, &curEntr)) { |
285 | return false; | 286 | return false; |
286 | } | 287 | } |
287 | dta->push_back(curEntr); | 288 | dta->push_back(curEntr); |
288 | } else { | 289 | } else { |
289 | printDebug("Serializer::readEntries(): hm? not an entry?"); | 290 | printDebug("Serializer::readEntries(): hm? not an entry?"); |
290 | } | 291 | } |
291 | } | 292 | } |
292 | return true; | 293 | return true; |
293 | } | 294 | } |
294 | 295 | ||
295 | bool Serializer::extractEntry(const QDomNode &n, | 296 | bool Serializer::extractEntry(const QDomNode &n, |
296 | PwMDataItem *dta) | 297 | PwMDataItem *dta) |
297 | { | 298 | { |
298 | QDomNodeList nl(n.childNodes()); | 299 | QDomNodeList nl(n.childNodes()); |
299 | QDomNode cur, cdata; | 300 | QDomNode cur, cdata; |
300 | unsigned int cnt = nl.count(), i; | 301 | unsigned int cnt = nl.count(), i; |
301 | QString name, text; | 302 | QString name, text; |
302 | 303 | ||
303 | if (!cnt) { | 304 | if (!cnt) { |
304 | printDebug("Serializer::extractEntry(): empty"); | 305 | printDebug("Serializer::extractEntry(): empty"); |
305 | return false; | 306 | return false; |
306 | } | 307 | } |
307 | dta->clear(); | 308 | dta->clear(); |
308 | for (i = 0; i < cnt; ++i) { | 309 | for (i = 0; i < cnt; ++i) { |
309 | cur = nl.item(i); | 310 | cur = nl.item(i); |
310 | name = cur.nodeName(); | 311 | name = cur.nodeName(); |
311 | cdata = cur.firstChild(); | 312 | cdata = cur.firstChild(); |
312 | if (unlikely(cdata.isCDATASection())) { | 313 | if (unlikely(cdata.isCDATASection())) { |
313 | text = cdata.toCDATASection().data(); | 314 | text = cdata.toCDATASection().data(); |
314 | } else if (likely(cur.isElement())) { | 315 | } else if (likely(cur.isElement())) { |
315 | text = cur.toElement().text(); | 316 | text = cur.toElement().text(); |
316 | } else { | 317 | } else { |
317 | printDebug("Serializer::extractEntry(): neither CDATA nor element."); | 318 | printDebug("Serializer::extractEntry(): neither CDATA nor element."); |
318 | return false; | 319 | return false; |
319 | } | 320 | } |
320 | if (text == " ") | 321 | if (text == " ") |
321 | text = ""; // for backward compatibility. | 322 | text = ""; // for backward compatibility. |
322 | if (name == ENTRY_DESC_NEW || | 323 | if (name == ENTRY_DESC_NEW || |
323 | name == ENTRY_DESC_OLD) { | 324 | name == ENTRY_DESC_OLD) { |
324 | dta->desc = unescapeEntryData(text).latin1(); | 325 | dta->desc = unescapeEntryData(text).latin1(); |
325 | } else if (name == ENTRY_NAME_NEW || | 326 | } else if (name == ENTRY_NAME_NEW || |
326 | name == ENTRY_NAME_OLD) { | 327 | name == ENTRY_NAME_OLD) { |
327 | dta->name = unescapeEntryData(text).latin1(); | 328 | dta->name = unescapeEntryData(text).latin1(); |
328 | } else if (name == ENTRY_PW_NEW || | 329 | } else if (name == ENTRY_PW_NEW || |
329 | name == ENTRY_PW_OLD) { | 330 | name == ENTRY_PW_OLD) { |
330 | dta->pw = unescapeEntryData(text).latin1(); | 331 | dta->pw = unescapeEntryData(text).latin1(); |
331 | } else if (name == ENTRY_COMMENT_NEW || | 332 | } else if (name == ENTRY_COMMENT_NEW || |
332 | name == ENTRY_COMMENT_OLD) { | 333 | name == ENTRY_COMMENT_OLD) { |
333 | dta->comment = unescapeEntryData(text).latin1(); | 334 | dta->comment = unescapeEntryData(text).latin1(); |
334 | } else if (name == ENTRY_URL_NEW || | 335 | } else if (name == ENTRY_URL_NEW || |
335 | name == ENTRY_URL_OLD) { | 336 | name == ENTRY_URL_OLD) { |
336 | dta->url = unescapeEntryData(text).latin1(); | 337 | dta->url = unescapeEntryData(text).latin1(); |
337 | } else if (name == ENTRY_LAUNCHER_NEW || | 338 | } else if (name == ENTRY_LAUNCHER_NEW || |
338 | name == ENTRY_LAUNCHER_OLD) { | 339 | name == ENTRY_LAUNCHER_OLD) { |
339 | dta->launcher = unescapeEntryData(text).latin1(); | 340 | dta->launcher = unescapeEntryData(text).latin1(); |
340 | } else if (name == ENTRY_LVP_NEW || | 341 | } else if (name == ENTRY_LVP_NEW || |
341 | name == ENTRY_LVP_OLD) { | 342 | name == ENTRY_LVP_OLD) { |
342 | dta->listViewPos = strtol(text.latin1(), 0, 10); | 343 | dta->listViewPos = strtol(text.latin1(), 0, 10); |
343 | } else if (name == ENTRY_BIN_NEW) { | 344 | } else if (name == ENTRY_BIN_NEW) { |
344 | // ENTRY_BIN_NEW == ENTRY_BIN_OLD | 345 | // ENTRY_BIN_NEW == ENTRY_BIN_OLD |
345 | if (text == "0") { | 346 | if (text == "0") { |
346 | dta->binary = false; | 347 | dta->binary = false; |
347 | } else { | 348 | } else { |
348 | dta->binary = true; | 349 | dta->binary = true; |
349 | } | 350 | } |
350 | } else if (name == ENTRY_META_NEW) { | 351 | } else if (name == ENTRY_META_NEW) { |
351 | // ENTRY_META_NEW == ENTRY_META_OLD | 352 | // ENTRY_META_NEW == ENTRY_META_OLD |
352 | if (!extractMeta(cur, &dta->meta)) | 353 | if (!extractMeta(cur, &dta->meta)) |
353 | return false; | 354 | return false; |
354 | } else { | 355 | } else { |
355 | printDebug(string("Serializer::extractEntry(): invalid: ") | 356 | printDebug(string("Serializer::extractEntry(): invalid: ") |
356 | + name.latin1()); | 357 | + name.latin1()); |
357 | } | 358 | } |
358 | } | 359 | } |
359 | dta->lockStat = defaultLockStat; | 360 | dta->lockStat = defaultLockStat; |
360 | return true; | 361 | return true; |
361 | } | 362 | } |
362 | 363 | ||
363 | bool Serializer::extractMeta(const QDomNode &n, | 364 | bool Serializer::extractMeta(const QDomNode &n, |
364 | PwMMetaData *dta) | 365 | PwMMetaData *dta) |
365 | { | 366 | { |
366 | QDomNode cur(n.firstChild()); | 367 | QDomNode cur(n.firstChild()); |
367 | QString name, val; | 368 | QString name, val; |
368 | while (!cur.isNull()) { | 369 | while (!cur.isNull()) { |
369 | name = cur.nodeName(); | 370 | name = cur.nodeName(); |
370 | val = cur.toElement().text(); | 371 | val = cur.toElement().text(); |
371 | if (val == "") { | 372 | if (val == "") { |
372 | cur = cur.nextSibling(); | 373 | cur = cur.nextSibling(); |
373 | continue; | 374 | continue; |
374 | } | 375 | } |
375 | #ifndef PWM_EMBEDDED | 376 | #ifndef PWM_EMBEDDED |
376 | if (name == META_CREATE_DATE) { | 377 | if (name == META_CREATE_DATE) { |
377 | dta->create = QDateTime::fromString(val, Qt::ISODate); | 378 | dta->create = QDateTime::fromString(val, Qt::ISODate); |
378 | } else if (name == META_VALID_DATE) { | 379 | } else if (name == META_VALID_DATE) { |
379 | dta->valid = QDateTime::fromString(val, Qt::ISODate); | 380 | dta->valid = QDateTime::fromString(val, Qt::ISODate); |
380 | } else if (name == META_EXPIRE_DATE) { | 381 | } else if (name == META_EXPIRE_DATE) { |
381 | dta->expire = QDateTime::fromString(val, Qt::ISODate); | 382 | dta->expire = QDateTime::fromString(val, Qt::ISODate); |
382 | } else if (name == META_UPDATE_DATE) { | 383 | } else if (name == META_UPDATE_DATE) { |
383 | dta->update = QDateTime::fromString(val, Qt::ISODate); | 384 | dta->update = QDateTime::fromString(val, Qt::ISODate); |
384 | } else if (name == META_UPDATE_INT) { | 385 | } else if (name == META_UPDATE_INT) { |
385 | dta->updateInt = strtoul(val.latin1(), 0, 10); | 386 | dta->updateInt = strtoul(val.latin1(), 0, 10); |
386 | } else if (name == META_UNIQUEID) { | 387 | } else if (name == META_UNIQUEID) { |
387 | dta->uniqueid = unescapeEntryData(val).latin1(); | 388 | dta->uniqueid = unescapeEntryData(val).latin1(); |
388 | } else { | 389 | } else { |
389 | printDebug(string("extractMeta(): invalid: ") | 390 | printDebug(string("extractMeta(): invalid: ") |
390 | + name.latin1()); | 391 | + name.latin1()); |
391 | } | 392 | } |
392 | #else | 393 | #else |
393 | 394 | ||
394 | QDateTime m_dt; | 395 | QDateTime m_dt; |
395 | 396 | ||
396 | if ((name == META_CREATE_DATE) || | 397 | if ((name == META_CREATE_DATE) || |
397 | (name == META_VALID_DATE) || | 398 | (name == META_VALID_DATE) || |
398 | (name == META_EXPIRE_DATE) || | 399 | (name == META_EXPIRE_DATE) || |
399 | (name == META_UPDATE_DATE)) | 400 | (name == META_UPDATE_DATE)) |
400 | { | 401 | { |
401 | int pos = val.find("T"); | 402 | int pos = val.find("T"); |
402 | QString date = val.left(pos); | 403 | QString date = val.left(pos); |
403 | QString time = val.mid(pos+1); | 404 | QString time = val.mid(pos+1); |
404 | qDebug("Serializer::extractMeta : date=%s ,time=%s",date.latin1(), time.latin1() ); | 405 | qDebug("Serializer::extractMeta : date=%s ,time=%s",date.latin1(), time.latin1() ); |
405 | bool ok1, ok2; | 406 | bool ok1, ok2; |
406 | 407 | ||
407 | QDate m_date = KGlobal::locale()->readDate(date, &ok1); | 408 | QDate m_date = KGlobal::locale()->readDate(date, &ok1); |
408 | QTime m_time = KGlobal::locale()->readTime(time, &ok2); | 409 | QTime m_time = KGlobal::locale()->readTime(time, &ok2); |