author | mickeyl <mickeyl> | 2004-05-26 16:17:16 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-26 16:17:16 (UTC) |
commit | 9a79c3bb271234396696dc54ee52f2a0c2a461d6 (patch) (unidiff) | |
tree | feedc8e51e45f24fbfe376dd18523c14a1c30433 | |
parent | 2b7ebd326a7e6456471bb973b14b4ad7affb9a9d (diff) | |
download | opie-9a79c3bb271234396696dc54ee52f2a0c2a461d6.zip opie-9a79c3bb271234396696dc54ee52f2a0c2a461d6.tar.gz opie-9a79c3bb271234396696dc54ee52f2a0c2a461d6.tar.bz2 |
BUGFIX: Fixed ZSafe not starting up (Bug #1324)
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 59 |
2 files changed, 16 insertions, 44 deletions
@@ -1,47 +1,48 @@ | |||
1 | 2004-??-??The Opie Team <opie@handhelds.org> | 1 | 2004-??-??The Opie Team <opie@handhelds.org> |
2 | 2 | ||
3 | * Fixed ZSafe not starting up (Bug #1324) (mickeyl) | ||
3 | * Fixed Drawpad initialization (Bug #1314) (mickeyl) | 4 | * Fixed Drawpad initialization (Bug #1314) (mickeyl) |
4 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) | 5 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) |
5 | * Added Conversion tool for pim-data (eilers) | 6 | * Added Conversion tool for pim-data (eilers) |
6 | * Modifcation of the PIM API for providing generic use of OPimRecords. (eilers) | 7 | * Modifcation of the PIM API for providing generic use of OPimRecords. (eilers) |
7 | 8 | ||
8 | 2004-25-04The Opie Team <opie@handhelds.org> | 9 | 2004-25-04The Opie Team <opie@handhelds.org> |
9 | 10 | ||
10 | * Released as Version 1.1.3 (devel) | 11 | * Released as Version 1.1.3 (devel) |
11 | * Introduced first implementation of SQL-Support using SQLite (eilers) | 12 | * Introduced first implementation of SQL-Support using SQLite (eilers) |
12 | * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) | 13 | * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) |
13 | * Added a real system graffiti character set (brad) | 14 | * Added a real system graffiti character set (brad) |
14 | * Added Generic Keyconfig Widget (zecke) | 15 | * Added Generic Keyconfig Widget (zecke) |
15 | * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) | 16 | * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) |
16 | * Added new Bible reader app - opie-dagger (drw) | 17 | * Added new Bible reader app - opie-dagger (drw) |
17 | * Added a new Image Viewer. Work is ongoing (zecke,alwin) | 18 | * Added a new Image Viewer. Work is ongoing (zecke,alwin) |
18 | * Added namespace usage in libopie2 and everywhere (zecke,alwin) | 19 | * Added namespace usage in libopie2 and everywhere (zecke,alwin) |
19 | * Enabled the possibility to pass command line arguments to applications (mickeyl) | 20 | * Enabled the possibility to pass command line arguments to applications (mickeyl) |
20 | * Added an about applet showing some credits and information about Opie (mickeyl) | 21 | * Added an about applet showing some credits and information about Opie (mickeyl) |
21 | * Added benchmarking functionality to sysinfo (mickeyl) | 22 | * Added benchmarking functionality to sysinfo (mickeyl) |
22 | * Added applet and configuration application for switching hardware keyboard layouts (alwin) | 23 | * Added applet and configuration application for switching hardware keyboard layouts (alwin) |
23 | * Ported applications from libopie1 to libopie2* (drw,ar,alwin) | 24 | * Ported applications from libopie1 to libopie2* (drw,ar,alwin) |
24 | * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) | 25 | * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) |
25 | * Clean-up of package information in control files (drw) | 26 | * Clean-up of package information in control files (drw) |
26 | * Repaired mediummount which was broken since integrating the quicklauncher (alwin) | 27 | * Repaired mediummount which was broken since integrating the quicklauncher (alwin) |
27 | * Improved big-screen support (zecke,ar) | 28 | * Improved big-screen support (zecke,ar) |
28 | * Improved multikeyboard support, added keyboard layout switching applet (mouse) | 29 | * Improved multikeyboard support, added keyboard layout switching applet (mouse) |
29 | * Added a new mail client based on libetpan (harlekin,alwin,jgf) | 30 | * Added a new mail client based on libetpan (harlekin,alwin,jgf) |
30 | * Added new package manager - opie-packagemanager (drw) | 31 | * Added new package manager - opie-packagemanager (drw) |
31 | * Improved light-n-power for C7x0 (mickeyl) | 32 | * Improved light-n-power for C7x0 (mickeyl) |
32 | * Added automatic rotation support for C7x0 (treke) | 33 | * Added automatic rotation support for C7x0 (treke) |
33 | * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) | 34 | * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) |
34 | * Added scanning the wireless network neighbourhood to networksettings (mickeyl) | 35 | * Added scanning the wireless network neighbourhood to networksettings (mickeyl) |
35 | 36 | ||
36 | 2003-11-29The Opie Team <opie@handhelds.org> | 37 | 2003-11-29The Opie Team <opie@handhelds.org> |
37 | 38 | ||
38 | * Released as Version 1.0.3 | 39 | * Released as Version 1.0.3 |
39 | * Improved i18n (various contributors) | 40 | * Improved i18n (various contributors) |
40 | * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) | 41 | * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) |
41 | * Made the Documents Tab optional (mickeyl) | 42 | * Made the Documents Tab optional (mickeyl) |
42 | * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) | 43 | * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) |
43 | 44 | ||
44 | 2003-08-04The Opie Team <opie@handhelds.org> | 45 | 2003-08-04The Opie Team <opie@handhelds.org> |
45 | 46 | ||
46 | * Released as Version 1.0.0 | 47 | * Released as Version 1.0.0 |
47 | * Including a PPP module for easy dial up (tille,harlekin,zecke) | 48 | * Including a PPP module for easy dial up (tille,harlekin,zecke) |
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index bf8f7f4..6ff05ac 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -106,821 +106,792 @@ extern QPEApplication *appl; | |||
106 | #endif | 106 | #endif |
107 | 107 | ||
108 | 108 | ||
109 | #ifdef DESKTOP | 109 | #ifdef DESKTOP |
110 | #ifndef WIN32 | 110 | #ifndef WIN32 |
111 | const QString APP_KEY="/.zsafe/"; | 111 | const QString APP_KEY="/.zsafe/"; |
112 | #else | 112 | #else |
113 | const QString APP_KEY=""; | 113 | const QString APP_KEY=""; |
114 | #endif | 114 | #endif |
115 | #else | 115 | #else |
116 | const QString APP_KEY=""; | 116 | const QString APP_KEY=""; |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | // include xmp images | 119 | // include xmp images |
120 | #include "pics/zsafe/copy.xpm" | 120 | #include "pics/zsafe/copy.xpm" |
121 | #include "pics/zsafe/cut.xpm" | 121 | #include "pics/zsafe/cut.xpm" |
122 | #include "pics/zsafe/edit.xpm" | 122 | #include "pics/zsafe/edit.xpm" |
123 | #include "pics/zsafe/editdelete.xpm" | 123 | #include "pics/zsafe/editdelete.xpm" |
124 | #include "pics/zsafe/find.xpm" | 124 | #include "pics/zsafe/find.xpm" |
125 | #include "pics/zsafe/folder_open.xpm" | 125 | #include "pics/zsafe/folder_open.xpm" |
126 | #include "pics/zsafe/help_icon.xpm" | 126 | #include "pics/zsafe/help_icon.xpm" |
127 | #include "pics/zsafe/new.xpm" | 127 | #include "pics/zsafe/new.xpm" |
128 | #include "pics/zsafe/paste.xpm" | 128 | #include "pics/zsafe/paste.xpm" |
129 | #include "pics/zsafe/quit_icon.xpm" | 129 | #include "pics/zsafe/quit_icon.xpm" |
130 | #include "pics/zsafe/save.xpm" | 130 | #include "pics/zsafe/save.xpm" |
131 | #include "pics/zsafe/trash.xpm" | 131 | #include "pics/zsafe/trash.xpm" |
132 | #include "pics/zsafe/expand.xpm" | 132 | #include "pics/zsafe/expand.xpm" |
133 | #include "pics/zsafe/export.xpm" | 133 | #include "pics/zsafe/export.xpm" |
134 | #include "pics/zsafe/import.xpm" | 134 | #include "pics/zsafe/import.xpm" |
135 | #include "pics/zsafe/zsafe.xpm" | 135 | #include "pics/zsafe/zsafe.xpm" |
136 | 136 | ||
137 | static const char* const bank_cards_data[] = { | 137 | static const char* const bank_cards_data[] = { |
138 | "14 14 16 1", | 138 | "14 14 16 1", |
139 | ". c None", | 139 | ". c None", |
140 | "# c #000000", | 140 | "# c #000000", |
141 | "b c #0000de", | 141 | "b c #0000de", |
142 | "a c #0000e6", | 142 | "a c #0000e6", |
143 | "j c #41de83", | 143 | "j c #41de83", |
144 | "k c #4acecd", | 144 | "k c #4acecd", |
145 | "h c #4aced5", | 145 | "h c #4aced5", |
146 | "g c #5a40cd", | 146 | "g c #5a40cd", |
147 | "d c #5a44d5", | 147 | "d c #5a44d5", |
148 | "l c #9440d5", | 148 | "l c #9440d5", |
149 | "m c #b4ce4a", | 149 | "m c #b4ce4a", |
150 | "n c #cd4883", | 150 | "n c #cd4883", |
151 | "e c #d5ae10", | 151 | "e c #d5ae10", |
152 | "f c #de3ce6", | 152 | "f c #de3ce6", |
153 | "i c #e640e6", | 153 | "i c #e640e6", |
154 | "c c #ffffff", | 154 | "c c #ffffff", |
155 | "..............", | 155 | "..............", |
156 | ".###########..", | 156 | ".###########..", |
157 | ".#ababababa#..", | 157 | ".#ababababa#..", |
158 | ".#babbbabbb#..", | 158 | ".#babbbabbb#..", |
159 | ".#ccccccccc#..", | 159 | ".#ccccccccc#..", |
160 | ".#cdcefcghc#..", | 160 | ".#cdcefcghc#..", |
161 | ".#ccccccccc#..", | 161 | ".#ccccccccc#..", |
162 | ".#cicjkclic#..", | 162 | ".#cicjkclic#..", |
163 | ".#ccccccccc#..", | 163 | ".#ccccccccc#..", |
164 | ".#cmchlcnec#..", | 164 | ".#cmchlcnec#..", |
165 | ".#ccccccccc#..", | 165 | ".#ccccccccc#..", |
166 | ".###########..", | 166 | ".###########..", |
167 | "..............", | 167 | "..............", |
168 | ".............."}; | 168 | ".............."}; |
169 | 169 | ||
170 | 170 | ||
171 | static const char* const passwords_data[] = { | 171 | static const char* const passwords_data[] = { |
172 | "16 16 20 1", | 172 | "16 16 20 1", |
173 | ". c None", | 173 | ". c None", |
174 | "# c #000000", | 174 | "# c #000000", |
175 | "r c #000083", | 175 | "r c #000083", |
176 | "p c #0000c5", | 176 | "p c #0000c5", |
177 | "q c #0000ff", | 177 | "q c #0000ff", |
178 | "n c #008100", | 178 | "n c #008100", |
179 | "l c #00c200", | 179 | "l c #00c200", |
180 | "m c #00ff00", | 180 | "m c #00ff00", |
181 | "j c #838100", | 181 | "j c #838100", |
182 | "a c #c55900", | 182 | "a c #c55900", |
183 | "h c #c5c200", | 183 | "h c #c5c200", |
184 | "o c #c5c2ff", | 184 | "o c #c5c2ff", |
185 | "k c #c5ffc5", | 185 | "k c #c5ffc5", |
186 | "f c #ff0000", | 186 | "f c #ff0000", |
187 | "d c #ff8100", | 187 | "d c #ff8100", |
188 | "b c #ffaa5a", | 188 | "b c #ffaa5a", |
189 | "e c #ffc2c5", | 189 | "e c #ffc2c5", |
190 | "c c #ffdeac", | 190 | "c c #ffdeac", |
191 | "i c #ffff00", | 191 | "i c #ffff00", |
192 | "g c #ffffc5", | 192 | "g c #ffffc5", |
193 | "............###.", | 193 | "............###.", |
194 | "...........#abb#", | 194 | "...........#abb#", |
195 | "..........#cbab#", | 195 | "..........#cbab#", |
196 | ".........#cbdd#.", | 196 | ".........#cbdd#.", |
197 | "######..#cbdd#..", | 197 | "######..#cbdd#..", |
198 | "#eeff#..#add#...", | 198 | "#eeff#..#add#...", |
199 | "#eeff#######....", | 199 | "#eeff#######....", |
200 | "#ccdbdd#........", | 200 | "#ccdbdd#........", |
201 | "#dddbdd###......", | 201 | "#dddbdd###......", |
202 | "#gghihhjj#......", | 202 | "#gghihhjj#......", |
203 | "#hhhihhjj###....", | 203 | "#hhhihhjj###....", |
204 | "#kklmllnnnn#....", | 204 | "#kklmllnnnn#....", |
205 | "#lllmllnnnn#....", | 205 | "#lllmllnnnn#....", |
206 | "#oopqpprprr#....", | 206 | "#oopqpprprr#....", |
207 | "#oopqpprprr#....", | 207 | "#oopqpprprr#....", |
208 | "############...."}; | 208 | "############...."}; |
209 | 209 | ||
210 | static const char* const software_data[] = { | 210 | static const char* const software_data[] = { |
211 | "16 16 5 1", | 211 | "16 16 5 1", |
212 | ". c None", | 212 | ". c None", |
213 | "# c #000000", | 213 | "# c #000000", |
214 | "b c #838183", | 214 | "b c #838183", |
215 | "c c #c5ffff", | 215 | "c c #c5ffff", |
216 | "a c #ffffff", | 216 | "a c #ffffff", |
217 | "................", | 217 | "................", |
218 | ".##############.", | 218 | ".##############.", |
219 | "#aaaaaaaaaaaaaa#", | 219 | "#aaaaaaaaaaaaaa#", |
220 | "#abbbbbbbbbbbbb#", | 220 | "#abbbbbbbbbbbbb#", |
221 | "#ab##########ab#", | 221 | "#ab##########ab#", |
222 | "#ab#c########ab#", | 222 | "#ab#c########ab#", |
223 | "#ab#c#c######ab#", | 223 | "#ab#c#c######ab#", |
224 | "#ab##########ab#", | 224 | "#ab##########ab#", |
225 | "#ab##########ab#", | 225 | "#ab##########ab#", |
226 | "#ab##########ab#", | 226 | "#ab##########ab#", |
227 | "#ab##########ab#", | 227 | "#ab##########ab#", |
228 | "#ab##########ab#", | 228 | "#ab##########ab#", |
229 | "#aaaaaaaaaaaaab#", | 229 | "#aaaaaaaaaaaaab#", |
230 | "#bbbbbbbbbbbbbb#", | 230 | "#bbbbbbbbbbbbbb#", |
231 | ".##############.", | 231 | ".##############.", |
232 | "................"}; | 232 | "................"}; |
233 | 233 | ||
234 | static const char* const general_data[] = { | 234 | static const char* const general_data[] = { |
235 | "14 14 98 2", | 235 | "14 14 98 2", |
236 | "Qt c None", | 236 | "Qt c None", |
237 | ".k c #000000", | 237 | ".k c #000000", |
238 | "#x c #080808", | 238 | "#x c #080808", |
239 | "#F c #101008", | 239 | "#F c #101008", |
240 | "#q c #101010", | 240 | "#q c #101010", |
241 | "#i c #101410", | 241 | "#i c #101410", |
242 | "## c #101810", | 242 | "## c #101810", |
243 | ".m c #181818", | 243 | ".m c #181818", |
244 | ".3 c #181c18", | 244 | ".3 c #181c18", |
245 | ".I c #182018", | 245 | ".I c #182018", |
246 | ".T c #202420", | 246 | ".T c #202420", |
247 | "#D c #202820", | 247 | "#D c #202820", |
248 | "#y c #292c29", | 248 | "#y c #292c29", |
249 | ".c c #293029", | 249 | ".c c #293029", |
250 | ".d c #313031", | 250 | ".d c #313031", |
251 | "#E c #313429", | 251 | "#E c #313429", |
252 | "#r c #313831", | 252 | "#r c #313831", |
253 | ".j c #393c31", | 253 | ".j c #393c31", |
254 | "#j c #394039", | 254 | "#j c #394039", |
255 | "#C c #414841", | 255 | "#C c #414841", |
256 | ".w c #4a554a", | 256 | ".w c #4a554a", |
257 | ".a c #4a594a", | 257 | ".a c #4a594a", |
258 | ".# c #525052", | 258 | ".# c #525052", |
259 | ".l c #52594a", | 259 | ".l c #52594a", |
260 | "#f c #525952", | 260 | "#f c #525952", |
261 | "#v c #525d52", | 261 | "#v c #525d52", |
262 | ".O c #5a4c4a", | 262 | ".O c #5a4c4a", |
263 | ".9 c #5a595a", | 263 | ".9 c #5a595a", |
264 | ".A c #5a5d52", | 264 | ".A c #5a5d52", |
265 | ".B c #624c52", | 265 | ".B c #624c52", |
266 | ".0 c #625552", | 266 | ".0 c #625552", |
267 | "#o c #626562", | 267 | "#o c #626562", |
268 | ".R c #626962", | 268 | ".R c #626962", |
269 | "#. c #626d5a", | 269 | "#. c #626d5a", |
270 | "#p c #626d62", | 270 | "#p c #626d62", |
271 | ".2 c #627162", | 271 | ".2 c #627162", |
272 | "#h c #6a6d62", | 272 | "#h c #6a6d62", |
273 | "#z c #6a7562", | 273 | "#z c #6a7562", |
274 | "#w c #6a756a", | 274 | "#w c #6a756a", |
275 | ".C c #73656a", | 275 | ".C c #73656a", |
276 | ".P c #73696a", | 276 | ".P c #73696a", |
277 | "#a c #737d6a", | 277 | "#a c #737d6a", |
278 | ".U c #738573", | 278 | ".U c #738573", |
279 | ".E c #7b817b", | 279 | ".E c #7b817b", |
280 | "#B c #7b857b", | 280 | "#B c #7b857b", |
281 | "#s c #7b897b", | 281 | "#s c #7b897b", |
282 | "#n c #7b917b", | 282 | "#n c #7b917b", |
283 | ".b c #838d83", | 283 | ".b c #838d83", |
284 | ".7 c #839583", | 284 | ".7 c #839583", |
285 | ".n c #8b7d7b", | 285 | ".n c #8b7d7b", |
286 | "#g c #8b8583", | 286 | "#g c #8b8583", |
287 | ".g c #8b858b", | 287 | ".g c #8b858b", |
288 | ".r c #8b898b", | 288 | ".r c #8b898b", |
289 | ".s c #8b8d8b", | 289 | ".s c #8b8d8b", |
290 | ".i c #8b9183", | 290 | ".i c #8b9183", |
291 | ".8 c #8b918b", | 291 | ".8 c #8b918b", |
292 | "#A c #8b9d8b", | 292 | "#A c #8b9d8b", |
293 | ".S c #8ba183", | 293 | ".S c #8ba183", |
294 | ".Z c #94918b", | 294 | ".Z c #94918b", |
295 | ".N c #949994", | 295 | ".N c #949994", |
296 | ".F c #949d94", | 296 | ".F c #949d94", |
297 | ".x c #94a18b", | 297 | ".x c #94a18b", |
298 | ".v c #94a194", | 298 | ".v c #94a194", |
299 | ".Y c #94aa94", | 299 | ".Y c #94aa94", |
300 | ".h c #9c999c", | 300 | ".h c #9c999c", |
301 | ".Q c #9ca19c", | 301 | ".Q c #9ca19c", |
302 | "#u c #9ca59c", | 302 | "#u c #9ca59c", |
303 | ".H c #9caa9c", | 303 | ".H c #9caa9c", |
304 | "#e c #9cb29c", | 304 | "#e c #9cb29c", |
305 | "#m c #a4b29c", | 305 | "#m c #a4b29c", |
306 | "#t c #a4b2a4", | 306 | "#t c #a4b2a4", |
307 | ".M c #a4b69c", | 307 | ".M c #a4b69c", |
308 | "#l c #a4b6a4", | 308 | "#l c #a4b6a4", |
309 | ".z c #a4baa4", | 309 | ".z c #a4baa4", |
310 | ".f c #aca5ac", | 310 | ".f c #aca5ac", |
311 | ".q c #acaaac", | 311 | ".q c #acaaac", |
312 | "#d c #acbeac", | 312 | "#d c #acbeac", |
313 | ".6 c #acc2ac", | 313 | ".6 c #acc2ac", |
314 | ".o c #b4b2b4", | 314 | ".o c #b4b2b4", |
315 | ".t c #b4beb4", | 315 | ".t c #b4beb4", |
316 | "#k c #b4c2ac", | 316 | "#k c #b4c2ac", |
317 | ".5 c #b4cab4", | 317 | ".5 c #b4cab4", |
318 | ".D c #bdb6bd", | 318 | ".D c #bdb6bd", |
319 | ".G c #bdc6b4", | 319 | ".G c #bdc6b4", |
320 | "#c c #bdceb4", | 320 | "#c c #bdceb4", |
321 | ".X c #bdd2bd", | 321 | ".X c #bdd2bd", |
322 | ".4 c #bdd6bd", | 322 | ".4 c #bdd6bd", |
323 | ".1 c #c5bec5", | 323 | ".1 c #c5bec5", |
324 | ".e c #c5c2c5", | 324 | ".e c #c5c2c5", |
325 | ".u c #c5cac5", | 325 | ".u c #c5cac5", |
326 | "#b c #c5d6c5", | 326 | "#b c #c5d6c5", |
327 | ".J c #c5dec5", | 327 | ".J c #c5dec5", |
328 | ".p c #cdcacd", | 328 | ".p c #cdcacd", |
329 | ".W c #cddecd", | 329 | ".W c #cddecd", |
330 | ".L c #cde2cd", | 330 | ".L c #cde2cd", |
331 | ".K c #d5eacd", | 331 | ".K c #d5eacd", |
332 | ".V c #d5ead5", | 332 | ".V c #d5ead5", |
333 | ".y c #d5eed5", | 333 | ".y c #d5eed5", |
334 | "QtQtQtQtQtQtQtQtQtQtQtQtQtQt", | 334 | "QtQtQtQtQtQtQtQtQtQtQtQtQtQt", |
335 | "QtQtQt.#.a.b.cQtQtQtQtQtQtQt", | 335 | "QtQtQt.#.a.b.cQtQtQtQtQtQtQt", |
336 | "QtQt.d.e.f.g.h.i.c.j.dQt.kQt", | 336 | "QtQt.d.e.f.g.h.i.c.j.dQt.kQt", |
337 | ".a.l.m.n.o.p.q.r.s.t.u.v.wQt", | 337 | ".a.l.m.n.o.p.q.r.s.t.u.v.wQt", |
338 | ".x.y.z.A.B.C.D.p.q.E.F.G.H.I", | 338 | ".x.y.z.A.B.C.D.p.q.E.F.G.H.I", |
339 | ".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", | 339 | ".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", |
340 | "Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", | 340 | "Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", |
341 | "Qt.3.X.W.4.X.5.6.7.8.9.s#.##", | 341 | "Qt.3.X.W.4.X.5.6.7.8.9.s#.##", |
342 | "QtQt#a.X#b#c.5.6#d#e#f#g#h#i", | 342 | "QtQt#a.X#b#c.5.6#d#e#f#g#h#i", |
343 | "QtQtQt#j.7#k.6#d#l#m#n#o#p#q", | 343 | "QtQtQt#j.7#k.6#d#l#m#n#o#p#q", |
344 | "QtQtQtQt.k#r#s#m#t.H#u#v#w#x", | 344 | "QtQtQtQt.k#r#s#m#t.H#u#v#w#x", |
345 | "QtQtQtQtQtQt.k#y#z.v#A#B#C#x", | 345 | "QtQtQtQtQtQt.k#y#z.v#A#B#C#x", |
346 | "QtQtQtQtQtQtQtQt.k#D.w#s#E.k", | 346 | "QtQtQtQtQtQtQtQt.k#D.w#s#E.k", |
347 | "QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; | 347 | "QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; |
348 | 348 | ||
349 | // exit ZSafe and clear the clipboard for security reasons | 349 | // exit ZSafe and clear the clipboard for security reasons |
350 | void ZSafe::exitZs (int ec) | 350 | void ZSafe::exitZs (int ec) |
351 | { | 351 | { |
352 | QClipboard *cb = QApplication::clipboard(); | 352 | QClipboard *cb = QApplication::clipboard(); |
353 | cb->clear(); | 353 | cb->clear(); |
354 | 354 | ||
355 | exit (ec); | 355 | exit (ec); |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | // save the configuration into the file | 359 | // save the configuration into the file |
360 | void ZSafe::saveConf () | 360 | void ZSafe::saveConf () |
361 | { | 361 | { |
362 | if (conf) | 362 | if (conf) |
363 | { | 363 | { |
364 | delete conf; | 364 | delete conf; |
365 | 365 | ||
366 | #ifdef DESKTOP | 366 | #ifdef DESKTOP |
367 | #ifndef WIN32 | 367 | #ifndef WIN32 |
368 | conf = new QSettings (); | 368 | conf = new QSettings (); |
369 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 369 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
370 | #else | 370 | #else |
371 | conf = new QSettings (cfgFile); | 371 | conf = new QSettings (cfgFile); |
372 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 372 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
373 | #endif | 373 | #endif |
374 | #else | 374 | #else |
375 | conf = new Config (cfgFile, Config::File); | 375 | conf = new Config (cfgFile, Config::File); |
376 | conf->setGroup ("zsafe"); | 376 | conf->setGroup ("zsafe"); |
377 | #endif | 377 | #endif |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | /* | 382 | /* |
383 | * Constructs a ZSafe which is a child of 'parent', with the | 383 | * Constructs a ZSafe which is a child of 'parent', with the |
384 | * name 'name' and widget flags set to 'f' | 384 | * name 'name' and widget flags set to 'f' |
385 | * | 385 | * |
386 | * The dialog will by default be modeless, unless you set 'modal' to | 386 | * The dialog will by default be modeless, unless you set 'modal' to |
387 | * TRUE to construct a modal dialog. | 387 | * TRUE to construct a modal dialog. |
388 | */ | 388 | */ |
389 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | 389 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) |
390 | : QDialog( parent, name, modal, fl ), | 390 | : QDialog( parent, name, modal, fl ), |
391 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) | 391 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) |
392 | { | 392 | { |
393 | IsCut = false; | 393 | IsCut = false; |
394 | IsCopy = false; | 394 | IsCopy = false; |
395 | modified = false; | 395 | modified = false; |
396 | 396 | ||
397 | // set the config file | 397 | // set the config file |
398 | cfgFile=QDir::homeDirPath(); | 398 | cfgFile=QDir::homeDirPath(); |
399 | cfgFile += "/.zsafe.cfg"; | 399 | cfgFile += "/.zsafe.cfg"; |
400 | // set the icon path | 400 | // set the icon path |
401 | #ifdef NO_OPIE | 401 | #ifdef NO_OPIE |
402 | QString qpedir ((const char *)getenv("QPEDIR")); | 402 | QString qpedir ((const char *)getenv("QPEDIR")); |
403 | #else | 403 | #else |
404 | QString qpedir ((const char *)getenv("OPIEDIR")); | 404 | QString qpedir ((const char *)getenv("OPIEDIR")); |
405 | #endif | 405 | #endif |
406 | 406 | ||
407 | #ifdef DESKTOP | 407 | #ifdef DESKTOP |
408 | iconPath = QDir::homeDirPath() + "/pics/"; | 408 | iconPath = QDir::homeDirPath() + "/pics/"; |
409 | #else | 409 | #else |
410 | if (qpedir.isEmpty()) | 410 | if (qpedir.isEmpty()) |
411 | iconPath = "/home/QtPalmtop/pics/"; | 411 | iconPath = "/home/QtPalmtop/pics/"; |
412 | else | 412 | else |
413 | iconPath = qpedir + "/pics/"; | 413 | iconPath = qpedir + "/pics/"; |
414 | #endif | 414 | #endif |
415 | 415 | ||
416 | // create a zsafe configuration object | 416 | // create a zsafe configuration object |
417 | #ifdef DESKTOP | 417 | #ifdef DESKTOP |
418 | #ifndef WIN32 | 418 | #ifndef WIN32 |
419 | conf = new QSettings (); | 419 | conf = new QSettings (); |
420 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 420 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
421 | #else | 421 | #else |
422 | conf = new QSettings (cfgFile); | 422 | conf = new QSettings (cfgFile); |
423 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 423 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
424 | #endif | 424 | #endif |
425 | #else | 425 | #else |
426 | conf = new Config (cfgFile, Config::File); | 426 | conf = new Config (cfgFile, Config::File); |
427 | conf->setGroup ("zsafePrefs"); | 427 | conf->setGroup ("zsafePrefs"); |
428 | #endif | 428 | #endif |
429 | #ifdef DESKTOP | 429 | #ifdef DESKTOP |
430 | // #ifndef WIN32 | 430 | // #ifndef WIN32 |
431 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); | 431 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); |
432 | // #endif | 432 | // #endif |
433 | #else | 433 | #else |
434 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); | 434 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); |
435 | #endif | 435 | #endif |
436 | #ifndef DESKTOP | 436 | #ifndef DESKTOP |
437 | conf->setGroup ("zsafe"); | 437 | conf->setGroup ("zsafe"); |
438 | #endif | 438 | #endif |
439 | 439 | ||
440 | QPixmap copy_img((const char**) copy_xpm); | 440 | QPixmap copy_img((const char**) copy_xpm); |
441 | QPixmap cut_img((const char**) cut_xpm); | 441 | QPixmap cut_img((const char**) cut_xpm); |
442 | QPixmap edit_img((const char**) edit_xpm); | 442 | QPixmap edit_img((const char**) edit_xpm); |
443 | QPixmap editdelete_img((const char**) editdelete_xpm); | 443 | QPixmap editdelete_img((const char**) editdelete_xpm); |
444 | QPixmap find_img((const char**) find_xpm); | 444 | QPixmap find_img((const char**) find_xpm); |
445 | QPixmap folder_open_img((const char**) folder_open_xpm); | 445 | QPixmap folder_open_img((const char**) folder_open_xpm); |
446 | QPixmap help_icon_img((const char**) help_icon_xpm); | 446 | QPixmap help_icon_img((const char**) help_icon_xpm); |
447 | QPixmap new_img((const char**) new_xpm); | 447 | QPixmap new_img((const char**) new_xpm); |
448 | QPixmap paste_img((const char**) paste_xpm); | 448 | QPixmap paste_img((const char**) paste_xpm); |
449 | QPixmap quit_icon_img((const char**) quit_icon_xpm); | 449 | QPixmap quit_icon_img((const char**) quit_icon_xpm); |
450 | QPixmap save_img((const char**) save_xpm); | 450 | QPixmap save_img((const char**) save_xpm); |
451 | QPixmap trash_img((const char**) trash_xpm); | 451 | QPixmap trash_img((const char**) trash_xpm); |
452 | QPixmap expand_img((const char**) expand_xpm); | 452 | QPixmap expand_img((const char**) expand_xpm); |
453 | QPixmap export_img((const char**) export_xpm); | 453 | QPixmap export_img((const char**) export_xpm); |
454 | QPixmap import_img((const char**) import_xpm); | 454 | QPixmap import_img((const char**) import_xpm); |
455 | 455 | ||
456 | QPixmap bank_cards( ( const char** ) bank_cards_data ); | 456 | QPixmap bank_cards( ( const char** ) bank_cards_data ); |
457 | QPixmap passwords( ( const char** ) passwords_data ); | 457 | QPixmap passwords( ( const char** ) passwords_data ); |
458 | QPixmap software( ( const char** ) software_data ); | 458 | QPixmap software( ( const char** ) software_data ); |
459 | QPixmap general( ( const char** ) general_data ); | 459 | QPixmap general( ( const char** ) general_data ); |
460 | if ( !name ) | 460 | if ( !name ) |
461 | setName( "ZSafe" ); | 461 | setName( "ZSafe" ); |
462 | 462 | ||
463 | #ifdef DESKTOP | 463 | #ifdef DESKTOP |
464 | #ifdef WIN32 | 464 | #ifdef WIN32 |
465 | setGeometry(100, 150, DeskW, DeskH-30 ); | 465 | setGeometry(100, 150, DeskW, DeskH-30 ); |
466 | #else | 466 | #else |
467 | resize( DeskW, DeskH-30 ); | 467 | resize( DeskW, DeskH-30 ); |
468 | #endif | 468 | #endif |
469 | 469 | ||
470 | #else | 470 | #else |
471 | 471 | ||
472 | #ifdef JPATCH_HDE | 472 | #ifdef JPATCH_HDE |
473 | int DeskS; | 473 | int DeskS; |
474 | if(DeskW > DeskH) | 474 | if(DeskW > DeskH) |
475 | { | 475 | { |
476 | DeskS = DeskW; | 476 | DeskS = DeskW; |
477 | } | 477 | } |
478 | else | 478 | else |
479 | { | 479 | { |
480 | DeskS = DeskH; | 480 | DeskS = DeskH; |
481 | } | 481 | } |
482 | resize( DeskW, DeskH ); | 482 | resize( DeskW, DeskH ); |
483 | setMinimumSize( QSize( DeskS, DeskS ) ); | 483 | setMinimumSize( QSize( DeskS, DeskS ) ); |
484 | setMaximumSize( QSize( DeskS, DeskS ) ); | 484 | setMaximumSize( QSize( DeskS, DeskS ) ); |
485 | #else | 485 | #else |
486 | resize( DeskW, DeskH-30 ); | 486 | resize( DeskW, DeskH-30 ); |
487 | #endif | 487 | #endif |
488 | 488 | ||
489 | #endif | 489 | #endif |
490 | // setCaption( tr( "ZSafe" ) ); | 490 | setCaption( tr( "ZSafe" ) ); |
491 | 491 | QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; | |
492 | filename = conf->readEntry(APP_KEY+"document"); | 492 | QString filename = conf->readEntry(APP_KEY+"document"); |
493 | if (filename.isEmpty() || filename.isNull()) | 493 | if (filename.isEmpty() || filename.isNull()) |
494 | { | 494 | { |
495 | 495 | if ( !QDir( zsafeAppDirPath ).exists() ) | |
496 | // check if the directory application exists, if not | ||
497 | // create it | ||
498 | // #ifndef WIN32 | ||
499 | // QString d1("Documents/application"); | ||
500 | // #else | ||
501 | QString d1(QDir::homeDirPath() + "/Documents/application"); | ||
502 | // #endif | ||
503 | QDir pd1(d1); | ||
504 | if (!pd1.exists()) | ||
505 | { | ||
506 | QDir pd1("Documents"); | ||
507 | if (!pd1.mkdir("application", FALSE)) | ||
508 | { | 496 | { |
509 | QMessageBox::critical( 0, tr("ZSafe"), | 497 | //FIXME: Pending someone to look into why QDir.mkdir does not work as expected |
510 | #ifdef JPATCH_HDE | 498 | QString cmdline = QString().sprintf( "mkdir -p %s", (const char*) zsafeAppDirPath ); |
511 | tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit.")); | 499 | ::system( cmdline ); |
512 | #else | ||
513 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1)); | ||
514 | #endif | ||
515 | exitZs (1); | ||
516 | } | 500 | } |
517 | } | 501 | if ( !QDir( zsafeAppDirPath ).exists() ) |
518 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); | ||
519 | QDir pd2(d2); | ||
520 | if (!pd2.exists()) | ||
521 | { | ||
522 | QDir pd2(QDir::homeDirPath() + "Documents/application"); | ||
523 | if (!pd2.mkdir("zsafe", FALSE)) | ||
524 | { | 502 | { |
525 | QMessageBox::critical( 0, tr("ZSafe"), | 503 | QMessageBox::critical( 0, "ZSafe", tr("Can't create application data directory.\nZSafe will now exit.")); |
526 | #ifdef JPATCH_HDE | 504 | exitZs (1); |
527 | tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit.")); | ||
528 | #else | ||
529 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2)); | ||
530 | #endif | ||
531 | exitZs (1); | ||
532 | } | 505 | } |
533 | } | 506 | } |
534 | 507 | ||
535 | |||
536 | // set the default filename | 508 | // set the default filename |
537 | filename=d2 + "/passwords.zsf"; | 509 | filename = zsafeAppDirPath + "/passwords.zsf"; |
538 | 510 | ||
539 | // save the current filename to the config file | 511 | // save the current filename to the config file |
540 | conf->writeEntry(APP_KEY+"document", filename); | 512 | conf->writeEntry(APP_KEY+"document", filename); |
541 | saveConf(); | 513 | saveConf(); |
542 | } | ||
543 | 514 | ||
544 | //if (filename == "INVALIDPWD") | 515 | //if (filename == "INVALIDPWD") |
545 | //filename = ""; | 516 | //filename = ""; |
546 | 517 | ||
547 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 518 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
548 | #ifdef WIN32 | 519 | #ifdef WIN32 |
549 | this->setCaption("Qt ZSafe: " + ti); | 520 | this->setCaption("Qt ZSafe: " + ti); |
550 | #else | 521 | #else |
551 | this->setCaption("ZSafe: " + ti); | 522 | this->setCaption("ZSafe: " + ti); |
552 | #endif | 523 | #endif |
553 | 524 | ||
554 | selectedItem = NULL; | 525 | selectedItem = NULL; |
555 | lastSearchedCategory = NULL; | 526 | lastSearchedCategory = NULL; |
556 | lastSearchedItem = NULL; | 527 | lastSearchedItem = NULL; |
557 | lastSearchedName = ""; | 528 | lastSearchedName = ""; |
558 | lastSearchedUsername = ""; | 529 | lastSearchedUsername = ""; |
559 | lastSearchedComment = ""; | 530 | lastSearchedComment = ""; |
560 | 531 | ||
561 | infoForm = new InfoForm(); | 532 | infoForm = new InfoForm(); |
562 | categoryDialog = NULL; | 533 | categoryDialog = NULL; |
563 | 534 | ||
564 | // add a menu bar | 535 | // add a menu bar |
565 | QMenuBar *menu = new QMenuBar( this ); | 536 | QMenuBar *menu = new QMenuBar( this ); |
566 | 537 | ||
567 | // add file menu | 538 | // add file menu |
568 | // QPopupMenu *file = new QPopupMenu( this ); | 539 | // QPopupMenu *file = new QPopupMenu( this ); |
569 | file = new QPopupMenu( this ); | 540 | file = new QPopupMenu( this ); |
570 | 541 | ||
571 | // #ifdef DESKTOP | 542 | // #ifdef DESKTOP |
572 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); | 543 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); |
573 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); | 544 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); |
574 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); | 545 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); |
575 | file->insertSeparator(); | 546 | file->insertSeparator(); |
576 | // #endif | 547 | // #endif |
577 | 548 | ||
578 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); | 549 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); |
579 | file->insertItem( save_img, tr("S&ave document with new Password"), this, | 550 | file->insertItem( save_img, tr("S&ave document with new Password"), this, |
580 | SLOT(saveDocumentWithPwd()) ); | 551 | SLOT(saveDocumentWithPwd()) ); |
581 | file->insertSeparator(); | 552 | file->insertSeparator(); |
582 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); | 553 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); |
583 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); | 554 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); |
584 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); | 555 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); |
585 | file->insertSeparator(); | 556 | file->insertSeparator(); |
586 | file->insertItem( expand_img, tr("&Open entries expanded"), this, | 557 | file->insertItem( expand_img, tr("&Open entries expanded"), this, |
587 | SLOT(setExpandFlag()), 0, 'o'); | 558 | SLOT(setExpandFlag()), 0, 'o'); |
588 | file->setItemChecked('o', expandTree); | 559 | file->setItemChecked('o', expandTree); |
589 | file->insertSeparator(); | 560 | file->insertSeparator(); |
590 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); | 561 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); |
591 | menu->insertItem( tr("&File"), file ); | 562 | menu->insertItem( tr("&File"), file ); |
592 | 563 | ||
593 | QPopupMenu *cat = new QPopupMenu( this ); | 564 | QPopupMenu *cat = new QPopupMenu( this ); |
594 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); | 565 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); |
595 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); | 566 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); |
596 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); | 567 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); |
597 | menu->insertItem( tr("&Category"), cat ); | 568 | menu->insertItem( tr("&Category"), cat ); |
598 | 569 | ||
599 | QPopupMenu *it = new QPopupMenu( this ); | 570 | QPopupMenu *it = new QPopupMenu( this ); |
600 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); | 571 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); |
601 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); | 572 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); |
602 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); | 573 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); |
603 | it->insertSeparator(); | 574 | it->insertSeparator(); |
604 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); | 575 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); |
605 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); | 576 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); |
606 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); | 577 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); |
607 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); | 578 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); |
608 | menu->insertItem( tr("&Entry"), it ); | 579 | menu->insertItem( tr("&Entry"), it ); |
609 | 580 | ||
610 | QPopupMenu *help = new QPopupMenu( this ); | 581 | QPopupMenu *help = new QPopupMenu( this ); |
611 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); | 582 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); |
612 | menu->insertItem( tr("&Help"), help ); | 583 | menu->insertItem( tr("&Help"), help ); |
613 | 584 | ||
614 | // toolbar icons | 585 | // toolbar icons |
615 | 586 | ||
616 | New = new QToolButton( menu, "New" ); | 587 | New = new QToolButton( menu, "New" ); |
617 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); | 588 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); |
618 | New->setMouseTracking( TRUE ); | 589 | New->setMouseTracking( TRUE ); |
619 | New->setText( tr( "" ) ); | 590 | New->setText( tr( "" ) ); |
620 | New->setPixmap( new_img ); | 591 | New->setPixmap( new_img ); |
621 | QToolTip::add( New, tr( "New entry" ) ); | 592 | QToolTip::add( New, tr( "New entry" ) ); |
622 | 593 | ||
623 | Edit = new QToolButton( menu, "Edit" ); | 594 | Edit = new QToolButton( menu, "Edit" ); |
624 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); | 595 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); |
625 | Edit->setText( tr( "" ) ); | 596 | Edit->setText( tr( "" ) ); |
626 | Edit->setPixmap( edit_img ); | 597 | Edit->setPixmap( edit_img ); |
627 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); | 598 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); |
628 | 599 | ||
629 | Delete = new QToolButton( menu, "Delete" ); | 600 | Delete = new QToolButton( menu, "Delete" ); |
630 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 601 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
631 | Delete->setText( tr( "" ) ); | 602 | Delete->setText( tr( "" ) ); |
632 | Delete->setPixmap( trash_img ); | 603 | Delete->setPixmap( trash_img ); |
633 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); | 604 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); |
634 | 605 | ||
635 | Find = new QToolButton( menu, "Find" ); | 606 | Find = new QToolButton( menu, "Find" ); |
636 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); | 607 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); |
637 | Find->setText( tr( "" ) ); | 608 | Find->setText( tr( "" ) ); |
638 | Find->setPixmap( find_img ); | 609 | Find->setPixmap( find_img ); |
639 | QToolTip::add( Find, tr( "Find entry" ) ); | 610 | QToolTip::add( Find, tr( "Find entry" ) ); |
640 | 611 | ||
641 | /* | 612 | /* |
642 | QBoxLayout * h = new QHBoxLayout( this ); | 613 | QBoxLayout * h = new QHBoxLayout( this ); |
643 | h->addWidget (menu); | 614 | h->addWidget (menu); |
644 | h->addWidget (New); | 615 | h->addWidget (New); |
645 | h->addWidget (Edit); | 616 | h->addWidget (Edit); |
646 | h->addWidget (Delete); | 617 | h->addWidget (Delete); |
647 | h->addWidget (Find); | 618 | h->addWidget (Find); |
648 | */ | 619 | */ |
649 | 620 | ||
650 | ListView = new ZListView( this, "ListView" ); | 621 | ListView = new ZListView( this, "ListView" ); |
651 | ListView->addColumn( tr( "Name" ) ); | 622 | ListView->addColumn( tr( "Name" ) ); |
652 | ListView->addColumn( tr( "Field 2" ) ); | 623 | ListView->addColumn( tr( "Field 2" ) ); |
653 | ListView->addColumn( tr( "Field 3" ) ); | 624 | ListView->addColumn( tr( "Field 3" ) ); |
654 | ListView->addColumn( tr( "Comment" ) ); | 625 | ListView->addColumn( tr( "Comment" ) ); |
655 | ListView->addColumn( tr( "Field 4" ) ); | 626 | ListView->addColumn( tr( "Field 4" ) ); |
656 | ListView->addColumn( tr( "Field 5" ) ); | 627 | ListView->addColumn( tr( "Field 5" ) ); |
657 | ListView->setAllColumnsShowFocus(TRUE); | 628 | ListView->setAllColumnsShowFocus(TRUE); |
658 | 629 | ||
659 | #ifdef DESKTOP | 630 | #ifdef DESKTOP |
660 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 631 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
661 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); | 632 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); |
662 | #else | 633 | #else |
663 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 634 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
664 | // ListView->setGeometry( QRect( 0, 22, | 635 | // ListView->setGeometry( QRect( 0, 22, |
665 | // this->width(), this->height() - 30 ) ); | 636 | // this->width(), this->height() - 30 ) ); |
666 | // ListView->setMaximumSize( QSize( 440, 290 ) ); | 637 | // ListView->setMaximumSize( QSize( 440, 290 ) ); |
667 | #endif | 638 | #endif |
668 | ListView->setVScrollBarMode( QListView::Auto ); | 639 | ListView->setVScrollBarMode( QListView::Auto ); |
669 | 640 | ||
670 | QBoxLayout * l = new QVBoxLayout( this ); | 641 | QBoxLayout * l = new QVBoxLayout( this ); |
671 | l->addWidget (menu); | 642 | l->addWidget (menu); |
672 | l->addWidget (ListView); | 643 | l->addWidget (ListView); |
673 | 644 | ||
674 | #ifndef DESKTOP | 645 | #ifndef DESKTOP |
675 | // start a timer (100 ms) to load the default document | 646 | // start a timer (100 ms) to load the default document |
676 | docuTimer.start( 100, true ); | 647 | docuTimer.start( 100, true ); |
677 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); | 648 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); |
678 | raiseFlag = true; | 649 | raiseFlag = true; |
679 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); | 650 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); |
680 | #else | 651 | #else |
681 | // open the default document | 652 | // open the default document |
682 | openDocument(filename); | 653 | openDocument(filename); |
683 | #endif | 654 | #endif |
684 | 655 | ||
685 | // signals and slots connections for QTollButton | 656 | // signals and slots connections for QTollButton |
686 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); | 657 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); |
687 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); | 658 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); |
688 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); | 659 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); |
689 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); | 660 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); |
690 | // signals and slots connections for QListView | 661 | // signals and slots connections for QListView |
691 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), | 662 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), |
692 | this, SLOT( listViewSelected(QListViewItem*) ) ); | 663 | this, SLOT( listViewSelected(QListViewItem*) ) ); |
693 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), | 664 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), |
694 | this, SLOT( showInfo(QListViewItem*) ) ); | 665 | this, SLOT( showInfo(QListViewItem*) ) ); |
695 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), | 666 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), |
696 | this, SLOT( showInfo(QListViewItem*) ) ); | 667 | this, SLOT( showInfo(QListViewItem*) ) ); |
697 | 668 | ||
698 | } | 669 | } |
699 | 670 | ||
700 | const QColor *ZSafe::evenRowColor = &Qt::white; | 671 | const QColor *ZSafe::evenRowColor = &Qt::white; |
701 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; | 672 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; |
702 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); | 673 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); |
703 | 674 | ||
704 | /* | 675 | /* |
705 | * Destroys the object and frees any allocated resources | 676 | * Destroys the object and frees any allocated resources |
706 | */ | 677 | */ |
707 | ZSafe::~ZSafe() | 678 | ZSafe::~ZSafe() |
708 | { | 679 | { |
709 | // no need to delete child widgets, Qt does it all for us | 680 | // no need to delete child widgets, Qt does it all for us |
710 | quitMe(); | 681 | quitMe(); |
711 | } | 682 | } |
712 | 683 | ||
713 | // load the default document | 684 | // load the default document |
714 | void ZSafe::slotLoadDocu() | 685 | void ZSafe::slotLoadDocu() |
715 | { | 686 | { |
716 | openDocument (filename); | 687 | openDocument (filename); |
717 | } | 688 | } |
718 | 689 | ||
719 | void ZSafe::deletePwd() | 690 | void ZSafe::deletePwd() |
720 | { | 691 | { |
721 | 692 | ||
722 | if (!selectedItem) | 693 | if (!selectedItem) |
723 | return; | 694 | return; |
724 | if (!isCategory(selectedItem)) | 695 | if (!isCategory(selectedItem)) |
725 | { | 696 | { |
726 | switch( QMessageBox::information( this, tr("ZSafe"), | 697 | switch( QMessageBox::information( this, tr("ZSafe"), |
727 | tr("Do you want to delete?"), | 698 | tr("Do you want to delete?"), |
728 | tr("&Delete"), tr("D&on't Delete"), | 699 | tr("&Delete"), tr("D&on't Delete"), |
729 | 0 // Enter == button 0 | 700 | 0 // Enter == button 0 |
730 | ) ) { // Escape == button 2 | 701 | ) ) { // Escape == button 2 |
731 | case 0: // Delete clicked, Alt-S or Enter pressed. | 702 | case 0: // Delete clicked, Alt-S or Enter pressed. |
732 | // Delete | 703 | // Delete |
733 | modified = true; | 704 | modified = true; |
734 | selectedItem->parent()->takeItem(selectedItem); | 705 | selectedItem->parent()->takeItem(selectedItem); |
735 | selectedItem = NULL; | 706 | selectedItem = NULL; |
736 | break; | 707 | break; |
737 | case 1: // Don't delete | 708 | case 1: // Don't delete |
738 | break; | 709 | break; |
739 | } | 710 | } |
740 | } | 711 | } |
741 | else | 712 | else |
742 | { | 713 | { |
743 | delCategory(); | 714 | delCategory(); |
744 | } | 715 | } |
745 | } | 716 | } |
746 | 717 | ||
747 | void ZSafe::editPwd() | 718 | void ZSafe::editPwd() |
748 | { | 719 | { |
749 | if (!selectedItem) | 720 | if (!selectedItem) |
750 | return; | 721 | return; |
751 | if (!isCategory(selectedItem)) | 722 | if (!isCategory(selectedItem)) |
752 | { | 723 | { |
753 | // open the 'New Entry' dialog | 724 | // open the 'New Entry' dialog |
754 | NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); | 725 | NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); |
755 | #ifdef WIN32 | 726 | #ifdef WIN32 |
756 | dialog->setCaption ("Qt " + tr("Edit Entry")); | 727 | dialog->setCaption ("Qt " + tr("Edit Entry")); |
757 | dialog->setGeometry(200, 250, 220, 310 ); | 728 | dialog->setGeometry(200, 250, 220, 310 ); |
758 | #endif | 729 | #endif |
759 | 730 | ||
760 | // set the labels | 731 | // set the labels |
761 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 732 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
762 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 733 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
763 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 734 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
764 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 735 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
765 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 736 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
766 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 737 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
767 | 738 | ||
768 | // set the fields | 739 | // set the fields |
769 | dialog->NameField->setText(selectedItem->text (0)); | 740 | dialog->NameField->setText(selectedItem->text (0)); |
770 | dialog->UsernameField->setText(selectedItem->text (1)); | 741 | dialog->UsernameField->setText(selectedItem->text (1)); |
771 | dialog->PasswordField->setText(selectedItem->text (2)); | 742 | dialog->PasswordField->setText(selectedItem->text (2)); |
772 | QString comment = selectedItem->text (3); | 743 | QString comment = selectedItem->text (3); |
773 | comment.replace (QRegExp("<br>"), "\n"); | 744 | comment.replace (QRegExp("<br>"), "\n"); |
774 | dialog->Field5->setText(selectedItem->text (4)); | 745 | dialog->Field5->setText(selectedItem->text (4)); |
775 | dialog->Field6->setText(selectedItem->text (5)); | 746 | dialog->Field6->setText(selectedItem->text (5)); |
776 | dialog->CommentField->insertLine(comment); | 747 | dialog->CommentField->insertLine(comment); |
777 | dialog->CommentField->setCursorPosition(0,0); | 748 | dialog->CommentField->setCursorPosition(0,0); |
778 | 749 | ||
779 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 750 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); |
780 | 751 | ||
781 | #ifdef DESKTOP | 752 | #ifdef DESKTOP |
782 | result = Accepted; | 753 | result = Accepted; |
783 | #endif | 754 | #endif |
784 | if (result == Accepted) | 755 | if (result == Accepted) |
785 | { | 756 | { |
786 | modified = true; | 757 | modified = true; |
787 | // edit the selected item | 758 | // edit the selected item |
788 | QString name = dialog->NameField->text(); | 759 | QString name = dialog->NameField->text(); |
789 | selectedItem->setText (0, tr (name)); | 760 | selectedItem->setText (0, tr (name)); |
790 | QString user = dialog->UsernameField->text(); | 761 | QString user = dialog->UsernameField->text(); |
791 | selectedItem->setText (1, tr (user)); | 762 | selectedItem->setText (1, tr (user)); |
792 | QString pwd = dialog->PasswordField->text(); | 763 | QString pwd = dialog->PasswordField->text(); |
793 | selectedItem->setText (2, tr (pwd)); | 764 | selectedItem->setText (2, tr (pwd)); |
794 | QString comment = dialog->CommentField->text(); | 765 | QString comment = dialog->CommentField->text(); |
795 | comment.replace (QRegExp("\n"), "<br>"); | 766 | comment.replace (QRegExp("\n"), "<br>"); |
796 | selectedItem->setText (3, tr (comment)); | 767 | selectedItem->setText (3, tr (comment)); |
797 | QString f5 = dialog->Field5->text(); | 768 | QString f5 = dialog->Field5->text(); |
798 | selectedItem->setText (4, tr (f5)); | 769 | selectedItem->setText (4, tr (f5)); |
799 | QString f6 = dialog->Field6->text(); | 770 | QString f6 = dialog->Field6->text(); |
800 | selectedItem->setText (5, tr (f6)); | 771 | selectedItem->setText (5, tr (f6)); |
801 | } | 772 | } |
802 | 773 | ||
803 | delete dialog; | 774 | delete dialog; |
804 | } | 775 | } |
805 | else | 776 | else |
806 | { | 777 | { |
807 | editCategory(); | 778 | editCategory(); |
808 | } | 779 | } |
809 | } | 780 | } |
810 | 781 | ||
811 | void ZSafe::newPwd() | 782 | void ZSafe::newPwd() |
812 | { | 783 | { |
813 | if (!selectedItem) | 784 | if (!selectedItem) |
814 | return; | 785 | return; |
815 | 786 | ||
816 | if (!isCategory(selectedItem)) | 787 | if (!isCategory(selectedItem)) |
817 | selectedItem = selectedItem->parent(); | 788 | selectedItem = selectedItem->parent(); |
818 | 789 | ||
819 | if (isCategory(selectedItem)) | 790 | if (isCategory(selectedItem)) |
820 | { | 791 | { |
821 | QString cat = selectedItem->text(0); | 792 | QString cat = selectedItem->text(0); |
822 | 793 | ||
823 | // open the 'New Entry' dialog | 794 | // open the 'New Entry' dialog |
824 | NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE); | 795 | NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE); |
825 | #ifdef WIN32 | 796 | #ifdef WIN32 |
826 | dialog->setCaption ("Qt " + tr("New Entry")); | 797 | dialog->setCaption ("Qt " + tr("New Entry")); |
827 | dialog->setGeometry(200, 250, 220, 310 ); | 798 | dialog->setGeometry(200, 250, 220, 310 ); |
828 | #endif | 799 | #endif |
829 | // set the labels | 800 | // set the labels |
830 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 801 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
831 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 802 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
832 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 803 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
833 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 804 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
834 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 805 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
835 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 806 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
836 | retype: | 807 | retype: |
837 | 808 | ||
838 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 809 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); |
839 | #ifdef DESKTOP | 810 | #ifdef DESKTOP |
840 | result = Accepted; | 811 | result = Accepted; |
841 | #endif | 812 | #endif |
842 | 813 | ||
843 | if (result == Accepted) | 814 | if (result == Accepted) |
844 | { | 815 | { |
845 | 816 | ||
846 | QString name = dialog->NameField->text(); | 817 | QString name = dialog->NameField->text(); |
847 | if (cat == name) | 818 | if (cat == name) |
848 | { | 819 | { |
849 | QMessageBox::critical( 0, tr("ZSafe"), | 820 | QMessageBox::critical( 0, tr("ZSafe"), |
850 | tr("Entry name must be different\nfrom the category name.") ); | 821 | tr("Entry name must be different\nfrom the category name.") ); |
851 | goto retype; // it's not a good programming style :-) | 822 | goto retype; // it's not a good programming style :-) |
852 | } | 823 | } |
853 | 824 | ||
854 | modified = true; | 825 | modified = true; |
855 | // add the new item | 826 | // add the new item |
856 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 827 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
857 | i->setOpen (TRUE); | 828 | i->setOpen (TRUE); |
858 | 829 | ||
859 | i->setText (0, tr (name)); | 830 | i->setText (0, tr (name)); |
860 | QString user = dialog->UsernameField->text(); | 831 | QString user = dialog->UsernameField->text(); |
861 | i->setText (1, tr (user)); | 832 | i->setText (1, tr (user)); |
862 | QString pwd = dialog->PasswordField->text(); | 833 | QString pwd = dialog->PasswordField->text(); |
863 | i->setText (2, tr (pwd)); | 834 | i->setText (2, tr (pwd)); |
864 | QString comment = dialog->CommentField->text(); | 835 | QString comment = dialog->CommentField->text(); |
865 | comment.replace (QRegExp("\n"), "<br>"); | 836 | comment.replace (QRegExp("\n"), "<br>"); |
866 | i->setText (3, tr (comment)); | 837 | i->setText (3, tr (comment)); |
867 | QString f5 = dialog->Field5->text(); | 838 | QString f5 = dialog->Field5->text(); |
868 | i->setText (4, tr (f5)); | 839 | i->setText (4, tr (f5)); |
869 | QString f6 = dialog->Field6->text(); | 840 | QString f6 = dialog->Field6->text(); |
870 | i->setText (5, tr (f6)); | 841 | i->setText (5, tr (f6)); |
871 | } | 842 | } |
872 | 843 | ||
873 | delete dialog; | 844 | delete dialog; |
874 | } | 845 | } |
875 | } | 846 | } |
876 | 847 | ||
877 | void ZSafe::findPwd() | 848 | void ZSafe::findPwd() |
878 | { | 849 | { |
879 | 850 | ||
880 | // open the 'Search' dialog | 851 | // open the 'Search' dialog |
881 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); | 852 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); |
882 | #ifdef WIN32 | 853 | #ifdef WIN32 |
883 | dialog->setCaption ("Qt " + tr("Search")); | 854 | dialog->setCaption ("Qt " + tr("Search")); |
884 | #endif | 855 | #endif |
885 | 856 | ||
886 | #ifdef DESKTOP | 857 | #ifdef DESKTOP |
887 | #endif | 858 | #endif |
888 | if (lastSearchedName) | 859 | if (lastSearchedName) |
889 | dialog->NameField->setText(lastSearchedName); | 860 | dialog->NameField->setText(lastSearchedName); |
890 | else | 861 | else |
891 | dialog->NameField->setText(""); | 862 | dialog->NameField->setText(""); |
892 | if (lastSearchedUsername) | 863 | if (lastSearchedUsername) |
893 | dialog->UsernameField->setText(lastSearchedUsername); | 864 | dialog->UsernameField->setText(lastSearchedUsername); |
894 | else | 865 | else |
895 | dialog->UsernameField->setText(""); | 866 | dialog->UsernameField->setText(""); |
896 | if (lastSearchedComment) | 867 | if (lastSearchedComment) |
897 | dialog->CommentField->setText(lastSearchedComment); | 868 | dialog->CommentField->setText(lastSearchedComment); |
898 | else | 869 | else |
899 | dialog->CommentField->setText(""); | 870 | dialog->CommentField->setText(""); |
900 | DialogCode result = (DialogCode) dialog->exec(); | 871 | DialogCode result = (DialogCode) dialog->exec(); |
901 | #ifdef DESKTOP | 872 | #ifdef DESKTOP |
902 | result = Accepted; | 873 | result = Accepted; |
903 | #endif | 874 | #endif |
904 | 875 | ||
905 | QString name; | 876 | QString name; |
906 | QString username; | 877 | QString username; |
907 | QString comment; | 878 | QString comment; |
908 | if (result == Accepted) | 879 | if (result == Accepted) |
909 | { | 880 | { |
910 | name = dialog->NameField->text(); | 881 | name = dialog->NameField->text(); |
911 | username = dialog->UsernameField->text(); | 882 | username = dialog->UsernameField->text(); |
912 | comment = dialog->CommentField->text(); | 883 | comment = dialog->CommentField->text(); |
913 | qWarning (name); | 884 | qWarning (name); |
914 | } | 885 | } |
915 | else | 886 | else |
916 | { | 887 | { |
917 | delete dialog; | 888 | delete dialog; |
918 | return; | 889 | return; |
919 | } | 890 | } |
920 | 891 | ||
921 | if (!name.isEmpty() && name != lastSearchedName || | 892 | if (!name.isEmpty() && name != lastSearchedName || |
922 | lastSearchedName.isEmpty() && !name.isEmpty()) | 893 | lastSearchedName.isEmpty() && !name.isEmpty()) |
923 | { | 894 | { |
924 | // set search at the beginning if a new name is given | 895 | // set search at the beginning if a new name is given |
925 | lastSearchedCategory = NULL; | 896 | lastSearchedCategory = NULL; |
926 | lastSearchedItem = NULL; | 897 | lastSearchedItem = NULL; |
@@ -1875,822 +1846,822 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1875 | // load the validation entry | 1846 | // load the validation entry |
1876 | if (validationFlag == 0) | 1847 | if (validationFlag == 0) |
1877 | { | 1848 | { |
1878 | pwdOk = 1; | 1849 | pwdOk = 1; |
1879 | break; | 1850 | break; |
1880 | } | 1851 | } |
1881 | 1852 | ||
1882 | retval = loadEntry(entry); | 1853 | retval = loadEntry(entry); |
1883 | if (retval == 1 && | 1854 | if (retval == 1 && |
1884 | !strcmp (entry[0], "ZSAFECATEGORY") && | 1855 | !strcmp (entry[0], "ZSAFECATEGORY") && |
1885 | !strcmp (entry[1], "name") && | 1856 | !strcmp (entry[1], "name") && |
1886 | !strcmp (entry[2], "username") && | 1857 | !strcmp (entry[2], "username") && |
1887 | !strcmp (entry[3], "password") && | 1858 | !strcmp (entry[3], "password") && |
1888 | !strcmp (entry[4], "comment") ) | 1859 | !strcmp (entry[4], "comment") ) |
1889 | { | 1860 | { |
1890 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1861 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1891 | pwdOk = 1; | 1862 | pwdOk = 1; |
1892 | break; | 1863 | break; |
1893 | } | 1864 | } |
1894 | else | 1865 | else |
1895 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1866 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1896 | fclose (fd); | 1867 | fclose (fd); |
1897 | m_password = ""; | 1868 | m_password = ""; |
1898 | 1869 | ||
1899 | if (i < numberOfTries - 1) | 1870 | if (i < numberOfTries - 1) |
1900 | { | 1871 | { |
1901 | switch( QMessageBox::warning( this, tr("ZSafe"), | 1872 | switch( QMessageBox::warning( this, tr("ZSafe"), |
1902 | tr("Wrong password.\nEnter again?"), | 1873 | tr("Wrong password.\nEnter again?"), |
1903 | tr("&Yes"), tr("&No."), | 1874 | tr("&Yes"), tr("&No."), |
1904 | 0 | 1875 | 0 |
1905 | ) ) | 1876 | ) ) |
1906 | { | 1877 | { |
1907 | case 1: // No | 1878 | case 1: // No |
1908 | exitZs (1); | 1879 | exitZs (1); |
1909 | break; | 1880 | break; |
1910 | case 0: // Yes | 1881 | case 0: // Yes |
1911 | continue; | 1882 | continue; |
1912 | } | 1883 | } |
1913 | } | 1884 | } |
1914 | } | 1885 | } |
1915 | if (pwdOk == 0) | 1886 | if (pwdOk == 0) |
1916 | { | 1887 | { |
1917 | // unset the document entry | 1888 | // unset the document entry |
1918 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); | 1889 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); |
1919 | if (conf) | 1890 | if (conf) |
1920 | delete conf; | 1891 | delete conf; |
1921 | 1892 | ||
1922 | exitZs (1); | 1893 | exitZs (1); |
1923 | } | 1894 | } |
1924 | 1895 | ||
1925 | 1896 | ||
1926 | retval = loadEntry(entry); | 1897 | retval = loadEntry(entry); |
1927 | 1898 | ||
1928 | int numberOfEntries=0; | 1899 | int numberOfEntries=0; |
1929 | while (retval == 1) { | 1900 | while (retval == 1) { |
1930 | 1901 | ||
1931 | QString category( QString::fromUtf8(entry[0]) ); | 1902 | QString category( QString::fromUtf8(entry[0]) ); |
1932 | QString name( QString::fromUtf8(entry[1]) ); | 1903 | QString name( QString::fromUtf8(entry[1]) ); |
1933 | QString user( QString::fromUtf8(entry[2]) ); | 1904 | QString user( QString::fromUtf8(entry[2]) ); |
1934 | QString password( QString::fromUtf8(entry[3]) ); | 1905 | QString password( QString::fromUtf8(entry[3]) ); |
1935 | QString comment( QString::fromUtf8(entry[4]) ); | 1906 | QString comment( QString::fromUtf8(entry[4]) ); |
1936 | QString field5( QString::fromUtf8(entry[5]) ); | 1907 | QString field5( QString::fromUtf8(entry[5]) ); |
1937 | QString field6( QString::fromUtf8(entry[6]) ); | 1908 | QString field6( QString::fromUtf8(entry[6]) ); |
1938 | // add the subitems to the categories | 1909 | // add the subitems to the categories |
1939 | 1910 | ||
1940 | Category *cat= categories.find (category); | 1911 | Category *cat= categories.find (category); |
1941 | if (cat) | 1912 | if (cat) |
1942 | { | 1913 | { |
1943 | // use the existend item | 1914 | // use the existend item |
1944 | QListViewItem *catItem = cat->getListItem(); | 1915 | QListViewItem *catItem = cat->getListItem(); |
1945 | if (catItem) | 1916 | if (catItem) |
1946 | { | 1917 | { |
1947 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1918 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
1948 | item->setText( 0, tr( name ) ); | 1919 | item->setText( 0, tr( name ) ); |
1949 | item->setText( 1, tr( user ) ); | 1920 | item->setText( 1, tr( user ) ); |
1950 | item->setText( 2, tr( password ) ); | 1921 | item->setText( 2, tr( password ) ); |
1951 | item->setText( 3, tr( comment ) ); | 1922 | item->setText( 3, tr( comment ) ); |
1952 | item->setText( 4, tr( field5 ) ); | 1923 | item->setText( 4, tr( field5 ) ); |
1953 | item->setText( 5, tr( field6 ) ); | 1924 | item->setText( 5, tr( field6 ) ); |
1954 | 1925 | ||
1955 | if (expandTree) | 1926 | if (expandTree) |
1956 | catItem->setOpen( TRUE ); | 1927 | catItem->setOpen( TRUE ); |
1957 | numberOfEntries++; | 1928 | numberOfEntries++; |
1958 | } | 1929 | } |
1959 | } | 1930 | } |
1960 | else | 1931 | else |
1961 | { | 1932 | { |
1962 | QListViewItem *catI = new ShadedListItem( 1, ListView ); | 1933 | QListViewItem *catI = new ShadedListItem( 1, ListView ); |
1963 | // create and insert a new item | 1934 | // create and insert a new item |
1964 | QListViewItem * item = new ShadedListItem( 0, catI ); | 1935 | QListViewItem * item = new ShadedListItem( 0, catI ); |
1965 | 1936 | ||
1966 | item->setText( 0, tr( name ) ); | 1937 | item->setText( 0, tr( name ) ); |
1967 | item->setText( 1, tr( user ) ); | 1938 | item->setText( 1, tr( user ) ); |
1968 | item->setText( 2, tr( password ) ); | 1939 | item->setText( 2, tr( password ) ); |
1969 | item->setText( 3, tr( comment ) ); | 1940 | item->setText( 3, tr( comment ) ); |
1970 | item->setText( 4, tr( field5 ) ); | 1941 | item->setText( 4, tr( field5 ) ); |
1971 | item->setText( 5, tr( field6 ) ); | 1942 | item->setText( 5, tr( field6 ) ); |
1972 | 1943 | ||
1973 | if (expandTree) | 1944 | if (expandTree) |
1974 | catI->setOpen( TRUE ); | 1945 | catI->setOpen( TRUE ); |
1975 | 1946 | ||
1976 | Category *c1 = new Category(); | 1947 | Category *c1 = new Category(); |
1977 | c1->setCategoryName(category); | 1948 | c1->setCategoryName(category); |
1978 | 1949 | ||
1979 | QString icon; | 1950 | QString icon; |
1980 | QString fullIconPath; | 1951 | QString fullIconPath; |
1981 | QPixmap *pix; | 1952 | QPixmap *pix; |
1982 | // #ifndef WIN32 | 1953 | // #ifndef WIN32 |
1983 | icon = conf->readEntry(APP_KEY+category); | 1954 | icon = conf->readEntry(APP_KEY+category); |
1984 | // #endif | 1955 | // #endif |
1985 | bool isIconAv = false; | 1956 | bool isIconAv = false; |
1986 | if (!icon.isEmpty() && !icon.isNull()) | 1957 | if (!icon.isEmpty() && !icon.isNull()) |
1987 | { | 1958 | { |
1988 | // build the full path | 1959 | // build the full path |
1989 | fullIconPath = iconPath + icon; | 1960 | fullIconPath = iconPath + icon; |
1990 | pix = new QPixmap (fullIconPath); | 1961 | pix = new QPixmap (fullIconPath); |
1991 | if (pix) | 1962 | if (pix) |
1992 | { | 1963 | { |
1993 | QImage img = pix->convertToImage(); | 1964 | QImage img = pix->convertToImage(); |
1994 | pix->convertFromImage(img.smoothScale(14,14)); | 1965 | pix->convertFromImage(img.smoothScale(14,14)); |
1995 | c1->setIconName (icon); | 1966 | c1->setIconName (icon); |
1996 | c1->setIcon (*pix); | 1967 | c1->setIcon (*pix); |
1997 | isIconAv = true; | 1968 | isIconAv = true; |
1998 | } | 1969 | } |
1999 | } | 1970 | } |
2000 | if (!isIconAv) | 1971 | if (!isIconAv) |
2001 | { | 1972 | { |
2002 | c1->setIcon (*getPredefinedIcon(category)); | 1973 | c1->setIcon (*getPredefinedIcon(category)); |
2003 | } | 1974 | } |
2004 | 1975 | ||
2005 | c1->setListItem (catI); | 1976 | c1->setListItem (catI); |
2006 | c1->initListItem(); | 1977 | c1->initListItem(); |
2007 | categories.insert (c1->getCategoryName(), c1); | 1978 | categories.insert (c1->getCategoryName(), c1); |
2008 | numberOfEntries++; | 1979 | numberOfEntries++; |
2009 | } | 1980 | } |
2010 | 1981 | ||
2011 | for (int count = 0; count < FIELD_SIZE; count++) { | 1982 | for (int count = 0; count < FIELD_SIZE; count++) { |
2012 | free(entry[count]); | 1983 | free(entry[count]); |
2013 | } | 1984 | } |
2014 | retval = loadEntry(entry); | 1985 | retval = loadEntry(entry); |
2015 | if (retval == 2) { | 1986 | if (retval == 2) { |
2016 | // m_parent->slotStatusHelpMsg("Last entry loaded"); | 1987 | // m_parent->slotStatusHelpMsg("Last entry loaded"); |
2017 | } | 1988 | } |
2018 | } // end while | 1989 | } // end while |
2019 | 1990 | ||
2020 | if (numberOfEntries == 0) | 1991 | if (numberOfEntries == 0) |
2021 | { | 1992 | { |
2022 | 1993 | ||
2023 | switch( QMessageBox::warning( this, tr("ZSafe"), | 1994 | switch( QMessageBox::warning( this, tr("ZSafe"), |
2024 | tr("Empty document or\nwrong password.\nContinue?"), | 1995 | tr("Empty document or\nwrong password.\nContinue?"), |
2025 | tr("&No"), tr("&Yes."), | 1996 | tr("&No"), tr("&Yes."), |
2026 | 0 | 1997 | 0 |
2027 | ) ) { | 1998 | ) ) { |
2028 | case 0: // No | 1999 | case 0: // No |
2029 | retval = loadFinalize(); | 2000 | retval = loadFinalize(); |
2030 | exitZs (1); | 2001 | exitZs (1); |
2031 | break; | 2002 | break; |
2032 | case 1: // Yes | 2003 | case 1: // Yes |
2033 | break; | 2004 | break; |
2034 | } | 2005 | } |
2035 | } | 2006 | } |
2036 | 2007 | ||
2037 | retval = loadFinalize(); | 2008 | retval = loadFinalize(); |
2038 | 2009 | ||
2039 | return true; | 2010 | return true; |
2040 | } | 2011 | } |
2041 | 2012 | ||
2042 | int ZSafe::loadInit(const char* _filename, const char *password) | 2013 | int ZSafe::loadInit(const char* _filename, const char *password) |
2043 | { | 2014 | { |
2044 | unsigned int j = 0; | 2015 | unsigned int j = 0; |
2045 | unsigned int keylength=0; | 2016 | unsigned int keylength=0; |
2046 | int count=0, count2=0, count3=0; | 2017 | int count=0, count2=0, count3=0; |
2047 | unsigned char charbuf[8]; | 2018 | unsigned char charbuf[8]; |
2048 | unsigned short ciphertext[4]; | 2019 | unsigned short ciphertext[4]; |
2049 | char key[128]; | 2020 | char key[128]; |
2050 | Krc2* krc2 = new Krc2(); | 2021 | Krc2* krc2 = new Krc2(); |
2051 | 2022 | ||
2052 | fd = fopen (_filename, "rb"); | 2023 | fd = fopen (_filename, "rb"); |
2053 | 2024 | ||
2054 | QFileInfo f (_filename); | 2025 | QFileInfo f (_filename); |
2055 | load_buffer_length = f.size(); | 2026 | load_buffer_length = f.size(); |
2056 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; | 2027 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; |
2057 | 2028 | ||
2058 | if (fd == NULL) | 2029 | if (fd == NULL) |
2059 | return PWERR_OPEN; | 2030 | return PWERR_OPEN; |
2060 | 2031 | ||
2061 | buffer = (char *)malloc(load_buffer_length); | 2032 | buffer = (char *)malloc(load_buffer_length); |
2062 | for (j = 0; password[j] != '\0'; j++) { | 2033 | for (j = 0; password[j] != '\0'; j++) { |
2063 | key[j] = password[j]; | 2034 | key[j] = password[j]; |
2064 | } | 2035 | } |
2065 | keylength = j; | 2036 | keylength = j; |
2066 | krc2->rc2_expandkey (key, keylength, 128); | 2037 | krc2->rc2_expandkey (key, keylength, 128); |
2067 | 2038 | ||
2068 | #ifndef WIN32 | 2039 | #ifndef WIN32 |
2069 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); | 2040 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); |
2070 | #else | 2041 | #else |
2071 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 2042 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
2072 | #endif | 2043 | #endif |
2073 | 2044 | ||
2074 | if (size < 8) | 2045 | if (size < 8) |
2075 | return PWERR_DATA; | 2046 | return PWERR_DATA; |
2076 | 2047 | ||
2077 | for (count = 0; count < 4; count++) { | 2048 | for (count = 0; count < 4; count++) { |
2078 | count2 = count << 1; | 2049 | count2 = count << 1; |
2079 | iv[count] = charbuf[count2] << 8; | 2050 | iv[count] = charbuf[count2] << 8; |
2080 | iv[count] += charbuf[count2 + 1]; | 2051 | iv[count] += charbuf[count2 + 1]; |
2081 | } | 2052 | } |
2082 | 2053 | ||
2083 | size = 0; | 2054 | size = 0; |
2084 | bufferIndex = 0; | 2055 | bufferIndex = 0; |
2085 | #ifndef WIN32 | 2056 | #ifndef WIN32 |
2086 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { | 2057 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { |
2087 | while (count < 8) { | 2058 | while (count < 8) { |
2088 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); | 2059 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); |
2089 | #else | 2060 | #else |
2090 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { | 2061 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { |
2091 | while (count < 8) { | 2062 | while (count < 8) { |
2092 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 2063 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
2093 | #endif | 2064 | #endif |
2094 | if (count2 == 0) { | 2065 | if (count2 == 0) { |
2095 | return PWERR_DATA; | 2066 | return PWERR_DATA; |
2096 | } | 2067 | } |
2097 | count += count2; | 2068 | count += count2; |
2098 | } /* while (count < 8) */ | 2069 | } /* while (count < 8) */ |
2099 | 2070 | ||
2100 | size += 8; | 2071 | size += 8; |
2101 | for (count2 = 0; count2 < 8; count2 += 2) { | 2072 | for (count2 = 0; count2 < 8; count2 += 2) { |
2102 | count3 = count2 >> 1; | 2073 | count3 = count2 >> 1; |
2103 | ciphertext[count3] = charbuf[count2] << 8; | 2074 | ciphertext[count3] = charbuf[count2] << 8; |
2104 | ciphertext[count3] += charbuf[count2 + 1]; | 2075 | ciphertext[count3] += charbuf[count2 + 1]; |
2105 | 2076 | ||
2106 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; | 2077 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; |
2107 | iv[count3] = plaintext[count3]; | 2078 | iv[count3] = plaintext[count3]; |
2108 | } /* for (count2) */ | 2079 | } /* for (count2) */ |
2109 | 2080 | ||
2110 | krc2->rc2_decrypt (plaintext); | 2081 | krc2->rc2_decrypt (plaintext); |
2111 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); | 2082 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); |
2112 | bufferIndex += 8; | 2083 | bufferIndex += 8; |
2113 | buffer[bufferIndex + 1] = '\0'; | 2084 | buffer[bufferIndex + 1] = '\0'; |
2114 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ | 2085 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ |
2115 | size -= buffer[size - 1]; | 2086 | size -= buffer[size - 1]; |
2116 | lastcount = 0; | 2087 | lastcount = 0; |
2117 | 2088 | ||
2118 | /* This will point to the starting index */ | 2089 | /* This will point to the starting index */ |
2119 | bufferIndex = 0; | 2090 | bufferIndex = 0; |
2120 | return PWERR_GOOD; | 2091 | return PWERR_GOOD; |
2121 | } | 2092 | } |
2122 | 2093 | ||
2123 | int ZSafe::loadEntry(char *entry[FIELD_SIZE]) | 2094 | int ZSafe::loadEntry(char *entry[FIELD_SIZE]) |
2124 | { | 2095 | { |
2125 | /* Strip off PKCS 5 padding | 2096 | /* Strip off PKCS 5 padding |
2126 | * Should check to make sure it's good here | 2097 | * Should check to make sure it's good here |
2127 | */ | 2098 | */ |
2128 | int count, count1=0; | 2099 | int count, count1=0; |
2129 | 2100 | ||
2130 | for (count = lastcount; count < size; count++) { | 2101 | for (count = lastcount; count < size; count++) { |
2131 | if ((unsigned char) (buffer[count]) == 255) { | 2102 | if ((unsigned char) (buffer[count]) == 255) { |
2132 | if (buffer[bufferIndex] == '\0') { | 2103 | if (buffer[bufferIndex] == '\0') { |
2133 | bufferIndex++; | 2104 | bufferIndex++; |
2134 | } | 2105 | } |
2135 | entry[count1] = (char *) malloc (count - bufferIndex + 1); | 2106 | entry[count1] = (char *) malloc (count - bufferIndex + 1); |
2136 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); | 2107 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); |
2137 | entry[count1][count - bufferIndex] = '\0'; | 2108 | entry[count1][count - bufferIndex] = '\0'; |
2138 | count++; | 2109 | count++; |
2139 | bufferIndex = count; | 2110 | bufferIndex = count; |
2140 | count1++; | 2111 | count1++; |
2141 | if (count1 == FIELD_SIZE) { | 2112 | if (count1 == FIELD_SIZE) { |
2142 | lastcount = count; | 2113 | lastcount = count; |
2143 | return 1; | 2114 | return 1; |
2144 | } | 2115 | } |
2145 | } /* if ((unsigned char) (buffer[count]) == 255) */ | 2116 | } /* if ((unsigned char) (buffer[count]) == 255) */ |
2146 | } /* for (count = 0; count < size; count++) */ | 2117 | } /* for (count = 0; count < size; count++) */ |
2147 | 2118 | ||
2148 | return 2; | 2119 | return 2; |
2149 | } | 2120 | } |
2150 | 2121 | ||
2151 | int ZSafe::loadFinalize(void) | 2122 | int ZSafe::loadFinalize(void) |
2152 | { | 2123 | { |
2153 | fclose (fd); | 2124 | fclose (fd); |
2154 | if (buffer) free(buffer); | 2125 | if (buffer) free(buffer); |
2155 | return PWERR_GOOD; | 2126 | return PWERR_GOOD; |
2156 | } | 2127 | } |
2157 | 2128 | ||
2158 | bool ZSafe::saveDocument(const char* _filename, | 2129 | bool ZSafe::saveDocument(const char* _filename, |
2159 | bool withPwd, | 2130 | bool withPwd, |
2160 | const char* ) | 2131 | const char* ) |
2161 | { | 2132 | { |
2162 | if (filename.isEmpty()) | 2133 | if (filename.isEmpty()) |
2163 | { | 2134 | { |
2164 | QMessageBox::critical( 0, tr("ZSafe"), | 2135 | QMessageBox::critical( 0, tr("ZSafe"), |
2165 | tr("No document defined.\nYou have to create a new document")); | 2136 | tr("No document defined.\nYou have to create a new document")); |
2166 | return false; | 2137 | return false; |
2167 | } | 2138 | } |
2168 | 2139 | ||
2169 | // if (m_password.isEmpty()) | 2140 | // if (m_password.isEmpty()) |
2170 | // withPwd = true; // the document must be saved with a valid password | 2141 | // withPwd = true; // the document must be saved with a valid password |
2171 | if (withPwd) | 2142 | if (withPwd) |
2172 | { | 2143 | { |
2173 | bool pwdOk = FALSE; | 2144 | bool pwdOk = FALSE; |
2174 | while (!pwdOk) | 2145 | while (!pwdOk) |
2175 | { | 2146 | { |
2176 | getDocPassword(tr("Enter Password")); | 2147 | getDocPassword(tr("Enter Password")); |
2177 | if (m_password.isEmpty()) | 2148 | if (m_password.isEmpty()) |
2178 | { | 2149 | { |
2179 | 2150 | ||
2180 | QMessageBox::critical( 0, tr("ZSafe"), | 2151 | QMessageBox::critical( 0, tr("ZSafe"), |
2181 | tr("Password is empty.\nPlease enter again.")); | 2152 | tr("Password is empty.\nPlease enter again.")); |
2182 | continue; | 2153 | continue; |
2183 | } | 2154 | } |
2184 | 2155 | ||
2185 | QString firstPasswd = m_password; | 2156 | QString firstPasswd = m_password; |
2186 | 2157 | ||
2187 | getDocPassword(tr("Reenter Password")); | 2158 | getDocPassword(tr("Reenter Password")); |
2188 | if (m_password.isEmpty()) | 2159 | if (m_password.isEmpty()) |
2189 | { | 2160 | { |
2190 | QMessageBox::critical( 0, tr("ZSafe"), | 2161 | QMessageBox::critical( 0, tr("ZSafe"), |
2191 | tr("Password is empty.\nPlease enter again.")); | 2162 | tr("Password is empty.\nPlease enter again.")); |
2192 | continue; | 2163 | continue; |
2193 | } | 2164 | } |
2194 | if (firstPasswd != m_password) | 2165 | if (firstPasswd != m_password) |
2195 | { | 2166 | { |
2196 | 2167 | ||
2197 | QMessageBox::critical( 0, tr("ZSafe"), | 2168 | QMessageBox::critical( 0, tr("ZSafe"), |
2198 | tr("Passwords must be identical.\nPlease enter again.")); | 2169 | tr("Passwords must be identical.\nPlease enter again.")); |
2199 | continue; | 2170 | continue; |
2200 | } | 2171 | } |
2201 | pwdOk = TRUE; | 2172 | pwdOk = TRUE; |
2202 | modified = false; | 2173 | modified = false; |
2203 | } | 2174 | } |
2204 | } | 2175 | } |
2205 | else if (modified) | 2176 | else if (modified) |
2206 | { | 2177 | { |
2207 | QString fns(_filename); | 2178 | QString fns(_filename); |
2208 | fns = fns.right (fns.length() - fns.findRev ('/') - 1); | 2179 | fns = fns.right (fns.length() - fns.findRev ('/') - 1); |
2209 | switch( QMessageBox::information( this, tr("ZSafe"), | 2180 | switch( QMessageBox::information( this, tr("ZSafe"), |
2210 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), | 2181 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), |
2211 | tr("&Save"), | 2182 | tr("&Save"), |
2212 | tr("&Don't Save"), | 2183 | tr("&Don't Save"), |
2213 | 0 // Enter == button 0 | 2184 | 0 // Enter == button 0 |
2214 | ) ) | 2185 | ) ) |
2215 | { // Escape == button 2 | 2186 | { // Escape == button 2 |
2216 | case 0: // Save clicked, Alt-S or Enter pressed. | 2187 | case 0: // Save clicked, Alt-S or Enter pressed. |
2217 | modified = false; | 2188 | modified = false; |
2218 | break; | 2189 | break; |
2219 | case 1: // Don't Save clicked or Alt-D pressed | 2190 | case 1: // Don't Save clicked or Alt-D pressed |
2220 | modified = false; | 2191 | modified = false; |
2221 | return true; | 2192 | return true; |
2222 | } | 2193 | } |
2223 | } | 2194 | } |
2224 | modified = false; | 2195 | modified = false; |
2225 | 2196 | ||
2226 | if (m_password.isEmpty()) | 2197 | if (m_password.isEmpty()) |
2227 | return false; | 2198 | return false; |
2228 | 2199 | ||
2229 | int retval = saveInit(_filename, m_password); | 2200 | int retval = saveInit(_filename, m_password); |
2230 | // int retval = saveInit(_filename, "test"); | 2201 | // int retval = saveInit(_filename, "test"); |
2231 | if (retval != PWERR_GOOD) { | 2202 | if (retval != PWERR_GOOD) { |
2232 | return false; | 2203 | return false; |
2233 | } | 2204 | } |
2234 | 2205 | ||
2235 | char* entry[FIELD_SIZE]; | 2206 | char* entry[FIELD_SIZE]; |
2236 | 2207 | ||
2237 | // save the validation entry | 2208 | // save the validation entry |
2238 | { | 2209 | { |
2239 | int i=0; | 2210 | int i=0; |
2240 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); | 2211 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); |
2241 | strcpy(entry[i++], "ZSAFECATEGORY"); | 2212 | strcpy(entry[i++], "ZSAFECATEGORY"); |
2242 | entry[i] = (char*)malloc(strlen("name")+1); | 2213 | entry[i] = (char*)malloc(strlen("name")+1); |
2243 | strcpy(entry[i++], "name"); | 2214 | strcpy(entry[i++], "name"); |
2244 | entry[i] = (char*)malloc(strlen("username")+1); | 2215 | entry[i] = (char*)malloc(strlen("username")+1); |
2245 | strcpy(entry[i++], "username"); | 2216 | strcpy(entry[i++], "username"); |
2246 | entry[i] = (char*)malloc(strlen("password")+1); | 2217 | entry[i] = (char*)malloc(strlen("password")+1); |
2247 | strcpy(entry[i++], "password"); | 2218 | strcpy(entry[i++], "password"); |
2248 | entry[i] = (char*)malloc(strlen("comment")+1); | 2219 | entry[i] = (char*)malloc(strlen("comment")+1); |
2249 | strcpy(entry[i++], "comment"); | 2220 | strcpy(entry[i++], "comment"); |
2250 | 2221 | ||
2251 | entry[i] = (char*)malloc(strlen("field5")+1); | 2222 | entry[i] = (char*)malloc(strlen("field5")+1); |
2252 | strcpy(entry[i++], "field5"); | 2223 | strcpy(entry[i++], "field5"); |
2253 | entry[i] = (char*)malloc(strlen("field6")+1); | 2224 | entry[i] = (char*)malloc(strlen("field6")+1); |
2254 | strcpy(entry[i++], "field6"); | 2225 | strcpy(entry[i++], "field6"); |
2255 | 2226 | ||
2256 | retval = saveEntry(entry); | 2227 | retval = saveEntry(entry); |
2257 | for (int z=0; z<i; z++) free(entry[z]); | 2228 | for (int z=0; z<i; z++) free(entry[z]); |
2258 | if (retval == PWERR_DATA) { | 2229 | if (retval == PWERR_DATA) { |
2259 | owarn << "1: Error writing file, contents not saved" << oendl; | 2230 | owarn << "1: Error writing file, contents not saved" << oendl; |
2260 | saveFinalize(); | 2231 | saveFinalize(); |
2261 | return false; | 2232 | return false; |
2262 | } | 2233 | } |
2263 | // #ifndef WIN32 | 2234 | // #ifndef WIN32 |
2264 | conf->writeEntry(APP_KEY+"valzsafe", 1); | 2235 | conf->writeEntry(APP_KEY+"valzsafe", 1); |
2265 | // #endif | 2236 | // #endif |
2266 | saveConf(); | 2237 | saveConf(); |
2267 | } | 2238 | } |
2268 | 2239 | ||
2269 | QListViewItem *i; | 2240 | QListViewItem *i; |
2270 | // step through all categories | 2241 | // step through all categories |
2271 | for (i = ListView->firstChild(); | 2242 | for (i = ListView->firstChild(); |
2272 | i != NULL; | 2243 | i != NULL; |
2273 | i = i->nextSibling()) | 2244 | i = i->nextSibling()) |
2274 | { | 2245 | { |
2275 | // step through all subitems | 2246 | // step through all subitems |
2276 | QListViewItem *si; | 2247 | QListViewItem *si; |
2277 | for (si = i->firstChild(); | 2248 | for (si = i->firstChild(); |
2278 | si != NULL; | 2249 | si != NULL; |
2279 | si = si->nextSibling()) | 2250 | si = si->nextSibling()) |
2280 | { | 2251 | { |
2281 | int j=0; | 2252 | int j=0; |
2282 | entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); | 2253 | entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); |
2283 | strcpy(entry[j++], i->text(0).utf8()); | 2254 | strcpy(entry[j++], i->text(0).utf8()); |
2284 | entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); | 2255 | entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); |
2285 | strcpy(entry[j++], si->text(0).utf8()); | 2256 | strcpy(entry[j++], si->text(0).utf8()); |
2286 | entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); | 2257 | entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); |
2287 | strcpy(entry[j++], si->text(1).utf8()); | 2258 | strcpy(entry[j++], si->text(1).utf8()); |
2288 | entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); | 2259 | entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); |
2289 | strcpy(entry[j++], si->text(2).utf8()); | 2260 | strcpy(entry[j++], si->text(2).utf8()); |
2290 | entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); | 2261 | entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); |
2291 | strcpy(entry[j++], si->text(3).utf8()); | 2262 | strcpy(entry[j++], si->text(3).utf8()); |
2292 | entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); | 2263 | entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); |
2293 | strcpy(entry[j++], si->text(4).utf8()); | 2264 | strcpy(entry[j++], si->text(4).utf8()); |
2294 | entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); | 2265 | entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); |
2295 | strcpy(entry[j++], si->text(5).utf8()); | 2266 | strcpy(entry[j++], si->text(5).utf8()); |
2296 | 2267 | ||
2297 | retval = saveEntry(entry); | 2268 | retval = saveEntry(entry); |
2298 | for (int z=0; z<j; z++) | 2269 | for (int z=0; z<j; z++) |
2299 | { | 2270 | { |
2300 | free(entry[z]); | 2271 | free(entry[z]); |
2301 | } | 2272 | } |
2302 | if (retval == PWERR_DATA) { | 2273 | if (retval == PWERR_DATA) { |
2303 | owarn << "1: Error writing file, contents not saved" << oendl; | 2274 | owarn << "1: Error writing file, contents not saved" << oendl; |
2304 | saveFinalize(); | 2275 | saveFinalize(); |
2305 | return false; | 2276 | return false; |
2306 | } | 2277 | } |
2307 | 2278 | ||
2308 | } | 2279 | } |
2309 | } | 2280 | } |
2310 | 2281 | ||
2311 | if (saveFinalize() == PWERR_DATA) { | 2282 | if (saveFinalize() == PWERR_DATA) { |
2312 | owarn << "2: Error writing file, contents not saved" << oendl; | 2283 | owarn << "2: Error writing file, contents not saved" << oendl; |
2313 | return false; | 2284 | return false; |
2314 | } else { | 2285 | } else { |
2315 | #ifndef DESKTOP | 2286 | #ifndef DESKTOP |
2316 | Global::statusMessage (tr("Password file saved.")); | 2287 | Global::statusMessage (tr("Password file saved.")); |
2317 | #endif | 2288 | #endif |
2318 | modified = false; | 2289 | modified = false; |
2319 | return true; | 2290 | return true; |
2320 | } | 2291 | } |
2321 | } | 2292 | } |
2322 | 2293 | ||
2323 | PasswordForm *newPwdDialog; | 2294 | PasswordForm *newPwdDialog; |
2324 | bool newPwdDialogResult = false; | 2295 | bool newPwdDialogResult = false; |
2325 | void ZSafe::setPasswordDialogDone() | 2296 | void ZSafe::setPasswordDialogDone() |
2326 | { | 2297 | { |
2327 | newPwdDialogResult = true; | 2298 | newPwdDialogResult = true; |
2328 | newPwdDialog->close(); | 2299 | newPwdDialog->close(); |
2329 | } | 2300 | } |
2330 | 2301 | ||
2331 | void ZSafe::getDocPassword(QString title) | 2302 | void ZSafe::getDocPassword(QString title) |
2332 | { | 2303 | { |
2333 | qWarning ("getDocPassword"); | 2304 | qWarning ("getDocPassword"); |
2334 | // open the 'Password' dialog | 2305 | // open the 'Password' dialog |
2335 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); | 2306 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); |
2336 | newPwdDialog = dialog; | 2307 | newPwdDialog = dialog; |
2337 | newPwdDialogResult = false; | 2308 | newPwdDialogResult = false; |
2338 | 2309 | ||
2339 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), | 2310 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), |
2340 | this, SLOT( setPasswordDialogDone() ) ); | 2311 | this, SLOT( setPasswordDialogDone() ) ); |
2341 | 2312 | ||
2342 | // CS: !!! | 2313 | // CS: !!! |
2343 | // int pos = filename.findRev ('/'); | 2314 | // int pos = filename.findRev ('/'); |
2344 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 2315 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
2345 | #ifdef WIN32 | 2316 | #ifdef WIN32 |
2346 | dialog->setCaption("Qt " + ti); | 2317 | dialog->setCaption("Qt " + ti); |
2347 | #else | 2318 | #else |
2348 | dialog->setCaption(ti); | 2319 | dialog->setCaption(ti); |
2349 | #endif | 2320 | #endif |
2350 | // dialog->setCaption(title); | 2321 | // dialog->setCaption(title); |
2351 | 2322 | ||
2352 | dialog->PasswordField->setFocus(); | 2323 | dialog->PasswordField->setFocus(); |
2353 | DialogCode result = (DialogCode) dialog->exec(); | 2324 | DialogCode result = (DialogCode) dialog->exec(); |
2354 | #ifdef DESKTOP | 2325 | #ifdef DESKTOP |
2355 | result = Accepted; | 2326 | result = Accepted; |
2356 | #endif | 2327 | #endif |
2357 | 2328 | ||
2358 | QString password; | 2329 | QString password; |
2359 | if (result == Accepted || newPwdDialogResult) | 2330 | if (result == Accepted || newPwdDialogResult) |
2360 | { | 2331 | { |
2361 | m_password = dialog->PasswordField->text(); | 2332 | m_password = dialog->PasswordField->text(); |
2362 | } | 2333 | } |
2363 | else | 2334 | else |
2364 | { | 2335 | { |
2365 | exitZs (1); | 2336 | exitZs (1); |
2366 | } | 2337 | } |
2367 | } | 2338 | } |
2368 | 2339 | ||
2369 | int ZSafe::saveInit(const char *_filename, const char *password) | 2340 | int ZSafe::saveInit(const char *_filename, const char *password) |
2370 | { | 2341 | { |
2371 | char key[128]; | 2342 | char key[128]; |
2372 | unsigned int j = 0; | 2343 | unsigned int j = 0; |
2373 | unsigned int keylength; | 2344 | unsigned int keylength; |
2374 | // int val; | 2345 | // int val; |
2375 | int count2; | 2346 | int count2; |
2376 | Krc2* krc2 = new Krc2(); | 2347 | Krc2* krc2 = new Krc2(); |
2377 | 2348 | ||
2378 | /* first we should check the permissions of the filename */ | 2349 | /* first we should check the permissions of the filename */ |
2379 | /* | 2350 | /* |
2380 | if (QFile::exists(_filename)) { | 2351 | if (QFile::exists(_filename)) { |
2381 | val = checkFile(_filename); | 2352 | val = checkFile(_filename); |
2382 | if (val != PWERR_GOOD) | 2353 | if (val != PWERR_GOOD) |
2383 | return val; | 2354 | return val; |
2384 | } else | 2355 | } else |
2385 | { | 2356 | { |
2386 | val = creat (_filename, (S_IRUSR | S_IWUSR)); | 2357 | val = creat (_filename, (S_IRUSR | S_IWUSR)); |
2387 | if (val == -1) | 2358 | if (val == -1) |
2388 | return PWERR_OPEN; | 2359 | return PWERR_OPEN; |
2389 | else | 2360 | else |
2390 | close(val); | 2361 | close(val); |
2391 | } | 2362 | } |
2392 | */ | 2363 | */ |
2393 | QFileInfo f (_filename); | 2364 | QFileInfo f (_filename); |
2394 | save_buffer_length = f.size(); | 2365 | save_buffer_length = f.size(); |
2395 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; | 2366 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; |
2396 | 2367 | ||
2397 | fd = fopen (_filename, "wb"); | 2368 | fd = fopen (_filename, "wb"); |
2398 | if (fd == NULL) | 2369 | if (fd == NULL) |
2399 | return PWERR_OPEN; | 2370 | return PWERR_OPEN; |
2400 | 2371 | ||
2401 | buffer = (char*)malloc(save_buffer_length); | 2372 | buffer = (char*)malloc(save_buffer_length); |
2402 | 2373 | ||
2403 | /* make the key ready */ | 2374 | /* make the key ready */ |
2404 | for (j = 0; password[j] != '\0'; j++) { | 2375 | for (j = 0; password[j] != '\0'; j++) { |
2405 | key[j] = password[j]; | 2376 | key[j] = password[j]; |
2406 | } | 2377 | } |
2407 | keylength = j; | 2378 | keylength = j; |
2408 | krc2->rc2_expandkey (key, keylength, 128); | 2379 | krc2->rc2_expandkey (key, keylength, 128); |
2409 | 2380 | ||
2410 | /* First, we make the IV */ | 2381 | /* First, we make the IV */ |
2411 | for (count2 = 0; count2 < 4; count2++) { | 2382 | for (count2 = 0; count2 < 4; count2++) { |
2412 | iv[count2] = rand (); | 2383 | iv[count2] = rand (); |
2413 | putc ((unsigned char) (iv[count2] >> 8), fd); | 2384 | putc ((unsigned char) (iv[count2] >> 8), fd); |
2414 | putc ((unsigned char) (iv[count2] & 0xff), fd); | 2385 | putc ((unsigned char) (iv[count2] & 0xff), fd); |
2415 | } | 2386 | } |
2416 | 2387 | ||
2417 | bufferIndex = 0; | 2388 | bufferIndex = 0; |
2418 | return PWERR_GOOD; | 2389 | return PWERR_GOOD; |
2419 | } | 2390 | } |
2420 | 2391 | ||
2421 | 2392 | ||
2422 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) | 2393 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) |
2423 | { | 2394 | { |
2424 | char *text1; | 2395 | char *text1; |
2425 | int count2, count3; | 2396 | int count2, count3; |
2426 | unsigned short ciphertext[4]; | 2397 | unsigned short ciphertext[4]; |
2427 | Krc2* krc2 = new Krc2(); | 2398 | Krc2* krc2 = new Krc2(); |
2428 | 2399 | ||
2429 | buffer = (char*)memset(buffer, '\0', save_buffer_length); | 2400 | buffer = (char*)memset(buffer, '\0', save_buffer_length); |
2430 | 2401 | ||
2431 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { | 2402 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { |
2432 | text1 = entry[count2]; | 2403 | text1 = entry[count2]; |
2433 | if (strlen (text1) == 0) { | 2404 | if (strlen (text1) == 0) { |
2434 | strncat(buffer, " ", strlen(" ")); | 2405 | strncat(buffer, " ", strlen(" ")); |
2435 | } else { | 2406 | } else { |
2436 | strncat(buffer, text1, strlen(text1)); | 2407 | strncat(buffer, text1, strlen(text1)); |
2437 | } | 2408 | } |
2438 | /* Use 255 as the marker. \n is too tough to test for */ | 2409 | /* Use 255 as the marker. \n is too tough to test for */ |
2439 | buffer[strlen (buffer)] = 255; | 2410 | buffer[strlen (buffer)] = 255; |
2440 | } /*for (count2 = 0; count2 < 5; count2++)*/ | 2411 | } /*for (count2 = 0; count2 < 5; count2++)*/ |
2441 | count2 = 0; | 2412 | count2 = 0; |
2442 | /* I'm using CBC mode and encrypting the data straight from top down. | 2413 | /* I'm using CBC mode and encrypting the data straight from top down. |
2443 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. | 2414 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. |
2444 | * PKCS 5 padding (explained at the code section | 2415 | * PKCS 5 padding (explained at the code section |
2445 | */ | 2416 | */ |
2446 | while (count2 < (int)strlen (buffer)) { | 2417 | while (count2 < (int)strlen (buffer)) { |
2447 | #ifndef WORDS_BIGENDIAN | 2418 | #ifndef WORDS_BIGENDIAN |
2448 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; | 2419 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; |
2449 | plaintext[bufferIndex] += buffer[count2] & 0xff; | 2420 | plaintext[bufferIndex] += buffer[count2] & 0xff; |
2450 | #endif | 2421 | #endif |
2451 | #ifdef WORDS_BIGENDIAN | 2422 | #ifdef WORDS_BIGENDIAN |
2452 | plaintext[bufferIndex] = buffer[count2] << 8; | 2423 | plaintext[bufferIndex] = buffer[count2] << 8; |
2453 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; | 2424 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; |
2454 | #endif | 2425 | #endif |
2455 | bufferIndex++; | 2426 | bufferIndex++; |
2456 | if (bufferIndex == 4) { | 2427 | if (bufferIndex == 4) { |
2457 | krc2->rc2_encrypt (plaintext); | 2428 | krc2->rc2_encrypt (plaintext); |
2458 | 2429 | ||
2459 | for (count3 = 0; count3 < 4; count3++) { | 2430 | for (count3 = 0; count3 < 4; count3++) { |
2460 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; | 2431 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; |
2461 | 2432 | ||
2462 | /* Now store the ciphertext as the iv */ | 2433 | /* Now store the ciphertext as the iv */ |
2463 | iv[count3] = plaintext[count3]; | 2434 | iv[count3] = plaintext[count3]; |
2464 | 2435 | ||
2465 | /* reset the buffer index */ | 2436 | /* reset the buffer index */ |
2466 | bufferIndex = 0; | 2437 | bufferIndex = 0; |
2467 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; | 2438 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; |
2468 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; | 2439 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; |
2469 | } /*for (count3 = 0; count3 < 5; count3++)*/ | 2440 | } /*for (count3 = 0; count3 < 5; count3++)*/ |
2470 | } /*if (bufferIndex == 5)*/ | 2441 | } /*if (bufferIndex == 5)*/ |
2471 | /* increment a short, not a byte */ | 2442 | /* increment a short, not a byte */ |
2472 | count2 += 2; | 2443 | count2 += 2; |
2473 | } /*while (count2 < strlen (buffer))*/ | 2444 | } /*while (count2 < strlen (buffer))*/ |
2474 | int ret = PWERR_GOOD; | 2445 | int ret = PWERR_GOOD; |
2475 | return ret; | 2446 | return ret; |
2476 | } | 2447 | } |
2477 | 2448 | ||
2478 | int ZSafe::saveFinalize(void) | 2449 | int ZSafe::saveFinalize(void) |
2479 | { | 2450 | { |
2480 | int count1, retval = PWERR_GOOD; | 2451 | int count1, retval = PWERR_GOOD; |
2481 | unsigned short ciphertext[4]; | 2452 | unsigned short ciphertext[4]; |
2482 | Krc2* krc2 = new Krc2(); | 2453 | Krc2* krc2 = new Krc2(); |
2483 | 2454 | ||
2484 | /* Tack on the PKCS 5 padding | 2455 | /* Tack on the PKCS 5 padding |
2485 | * How it works is we fill up the last n bytes with the value n | 2456 | * How it works is we fill up the last n bytes with the value n |
2486 | * | 2457 | * |
2487 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left | 2458 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left |
2488 | * over, leaving us 3 short, so we fill it in with 3's. | 2459 | * over, leaving us 3 short, so we fill it in with 3's. |
2489 | * | 2460 | * |
2490 | * If we come out even, we fill it with 8 8s | 2461 | * If we come out even, we fill it with 8 8s |
2491 | * | 2462 | * |
2492 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. | 2463 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. |
2493 | * so, half everything | 2464 | * so, half everything |
2494 | */ | 2465 | */ |
2495 | for (count1 = bufferIndex; count1 < 4; count1++) { | 2466 | for (count1 = bufferIndex; count1 < 4; count1++) { |
2496 | plaintext[count1] = (4 - bufferIndex); | 2467 | plaintext[count1] = (4 - bufferIndex); |
2497 | } | 2468 | } |
2498 | krc2->rc2_encrypt (plaintext); | 2469 | krc2->rc2_encrypt (plaintext); |
2499 | for (count1 = 0; count1 < 4; count1++) { | 2470 | for (count1 = 0; count1 < 4; count1++) { |
2500 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; | 2471 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; |
2501 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; | 2472 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; |
2502 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; | 2473 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; |
2503 | } | 2474 | } |
2504 | 2475 | ||
2505 | fclose (fd); | 2476 | fclose (fd); |
2506 | free(buffer); | 2477 | free(buffer); |
2507 | return retval; | 2478 | return retval; |
2508 | } | 2479 | } |
2509 | 2480 | ||
2510 | void ZSafe::quitMe () | 2481 | void ZSafe::quitMe () |
2511 | { | 2482 | { |
2512 | qWarning ("QUIT..."); | 2483 | qWarning ("QUIT..."); |
2513 | 2484 | ||
2514 | if (modified) | 2485 | if (modified) |
2515 | { | 2486 | { |
2516 | switch( QMessageBox::information( this, tr("ZSafe"), | 2487 | switch( QMessageBox::information( this, tr("ZSafe"), |
2517 | tr("Do you want to save\nbefore exiting?"), | 2488 | tr("Do you want to save\nbefore exiting?"), |
2518 | tr("&Save"), | 2489 | tr("&Save"), |
2519 | tr("S&ave with\nnew\npassword"), | 2490 | tr("S&ave with\nnew\npassword"), |
2520 | tr("&Don't Save"), | 2491 | tr("&Don't Save"), |
2521 | 0 // Enter == button 0 | 2492 | 0 // Enter == button 0 |
2522 | ) ) | 2493 | ) ) |
2523 | { // Escape == button 2 | 2494 | { // Escape == button 2 |
2524 | case 0: // Save clicked, Alt-S or Enter pressed. | 2495 | case 0: // Save clicked, Alt-S or Enter pressed. |
2525 | // save | 2496 | // save |
2526 | modified = false; | 2497 | modified = false; |
2527 | saveDocument(filename, FALSE); | 2498 | saveDocument(filename, FALSE); |
2528 | exitZs (1); | 2499 | exitZs (1); |
2529 | break; | 2500 | break; |
2530 | case 1: // | 2501 | case 1: // |
2531 | // Save with new password | 2502 | // Save with new password |
2532 | modified = false; | 2503 | modified = false; |
2533 | saveDocument(filename, TRUE); | 2504 | saveDocument(filename, TRUE); |
2534 | exitZs (1); | 2505 | exitZs (1); |
2535 | break; | 2506 | break; |
2536 | case 2: // Don't Save clicked or Alt-D pressed | 2507 | case 2: // Don't Save clicked or Alt-D pressed |
2537 | // don't save but exitZs | 2508 | // don't save but exitZs |
2538 | exitZs (1); | 2509 | exitZs (1); |
2539 | break; | 2510 | break; |
2540 | } | 2511 | } |
2541 | } | 2512 | } |
2542 | exitZs (1); | 2513 | exitZs (1); |
2543 | 2514 | ||
2544 | } | 2515 | } |
2545 | 2516 | ||
2546 | void ZSafe::categoryFieldActivated( const QString& category) | 2517 | void ZSafe::categoryFieldActivated( const QString& category) |
2547 | { | 2518 | { |
2548 | if (categoryDialog) | 2519 | if (categoryDialog) |
2549 | setCategoryDialogFields(categoryDialog, category); | 2520 | setCategoryDialogFields(categoryDialog, category); |
2550 | } | 2521 | } |
2551 | 2522 | ||
2552 | void ZSafe::addCategory() | 2523 | void ZSafe::addCategory() |
2553 | { | 2524 | { |
2554 | if (filename.isEmpty()) | 2525 | if (filename.isEmpty()) |
2555 | { | 2526 | { |
2556 | QMessageBox::critical( 0, tr("ZSafe"), | 2527 | QMessageBox::critical( 0, tr("ZSafe"), |
2557 | tr("No document defined.\nYou have to create a new document")); | 2528 | tr("No document defined.\nYou have to create a new document")); |
2558 | return; | 2529 | return; |
2559 | } | 2530 | } |
2560 | else | 2531 | else |
2561 | { | 2532 | { |
2562 | // open the 'Category' dialog | 2533 | // open the 'Category' dialog |
2563 | bool initIcons = false; | 2534 | bool initIcons = false; |
2564 | // open the 'Category' dialog | 2535 | // open the 'Category' dialog |
2565 | CategoryDialog *dialog; | 2536 | CategoryDialog *dialog; |
2566 | if (categoryDialog) | 2537 | if (categoryDialog) |
2567 | { | 2538 | { |
2568 | dialog = categoryDialog; | 2539 | dialog = categoryDialog; |
2569 | } | 2540 | } |
2570 | else | 2541 | else |
2571 | { | 2542 | { |
2572 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2543 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2573 | #ifdef WIN32 | 2544 | #ifdef WIN32 |
2574 | categoryDialog->setCaption ("Qt " + tr("Category")); | 2545 | categoryDialog->setCaption ("Qt " + tr("Category")); |
2575 | #endif | 2546 | #endif |
2576 | dialog = categoryDialog; | 2547 | dialog = categoryDialog; |
2577 | connect( dialog->CategoryField, | 2548 | connect( dialog->CategoryField, |
2578 | SIGNAL( activated(const QString&)), | 2549 | SIGNAL( activated(const QString&)), |
2579 | this, SLOT( categoryFieldActivated(const QString&) ) ); | 2550 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
2580 | initIcons = true; | 2551 | initIcons = true; |
2581 | } | 2552 | } |
2582 | 2553 | ||
2583 | #ifdef DESKTOP | 2554 | #ifdef DESKTOP |
2584 | #ifndef WIN32 | 2555 | #ifndef WIN32 |
2585 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 2556 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
2586 | #else | 2557 | #else |
2587 | // read all categories from the config file and store | 2558 | // read all categories from the config file and store |
2588 | // into a list | 2559 | // into a list |
2589 | QFile f (cfgFile); | 2560 | QFile f (cfgFile); |
2590 | QStringList list; | 2561 | QStringList list; |
2591 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2562 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2592 | QTextStream t( &f ); // use a text stream | 2563 | QTextStream t( &f ); // use a text stream |
2593 | QString s; | 2564 | QString s; |
2594 | int n = 1; | 2565 | int n = 1; |
2595 | while ( !t.eof() ) { // until end of file... | 2566 | while ( !t.eof() ) { // until end of file... |
2596 | s = t.readLine(); // line of text excluding '\n' | 2567 | s = t.readLine(); // line of text excluding '\n' |
2597 | list.append(s); | 2568 | list.append(s); |
2598 | } | 2569 | } |
2599 | f.close(); | 2570 | f.close(); |
2600 | } | 2571 | } |
2601 | #endif | 2572 | #endif |
2602 | #else | 2573 | #else |
2603 | // read all categories from the config file and store | 2574 | // read all categories from the config file and store |
2604 | // into a list | 2575 | // into a list |
2605 | QFile f (cfgFile); | 2576 | QFile f (cfgFile); |
2606 | QStringList list; | 2577 | QStringList list; |
2607 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2578 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2608 | QTextStream t( &f ); // use a text stream | 2579 | QTextStream t( &f ); // use a text stream |
2609 | QString s; | 2580 | QString s; |
2610 | while ( !t.eof() ) { // until end of file... | 2581 | while ( !t.eof() ) { // until end of file... |
2611 | s = t.readLine(); // line of text excluding '\n' | 2582 | s = t.readLine(); // line of text excluding '\n' |
2612 | list.append(s); | 2583 | list.append(s); |
2613 | } | 2584 | } |
2614 | f.close(); | 2585 | f.close(); |
2615 | } | 2586 | } |
2616 | #endif | 2587 | #endif |
2617 | QStringList::Iterator it = list.begin(); | 2588 | QStringList::Iterator it = list.begin(); |
2618 | QString categ; | 2589 | QString categ; |
2619 | QString firstCategory; | 2590 | QString firstCategory; |
2620 | dialog->CategoryField->clear(); // remove all items | 2591 | dialog->CategoryField->clear(); // remove all items |
2621 | while( it != list.end() ) | 2592 | while( it != list.end() ) |
2622 | { | 2593 | { |
2623 | QString *cat = new QString (*it); | 2594 | QString *cat = new QString (*it); |
2624 | if (cat->contains("-field1", FALSE)) | 2595 | if (cat->contains("-field1", FALSE)) |
2625 | { | 2596 | { |
2626 | #ifdef DESKTOP | 2597 | #ifdef DESKTOP |
2627 | #ifndef WIN32 | 2598 | #ifndef WIN32 |
2628 | categ = cat->section ("-field1", 0, 0); | 2599 | categ = cat->section ("-field1", 0, 0); |
2629 | #else | 2600 | #else |
2630 | int pos = cat->find ("-field1"); | 2601 | int pos = cat->find ("-field1"); |
2631 | categ = cat->left (pos); | 2602 | categ = cat->left (pos); |
2632 | #endif | 2603 | #endif |
2633 | #else | 2604 | #else |
2634 | int pos = cat->find ("-field1"); | 2605 | int pos = cat->find ("-field1"); |
2635 | cat->truncate(pos); | 2606 | cat->truncate(pos); |
2636 | categ = *cat; | 2607 | categ = *cat; |
2637 | #endif | 2608 | #endif |
2638 | if (!categ.isEmpty()) | 2609 | if (!categ.isEmpty()) |
2639 | { | 2610 | { |
2640 | dialog->CategoryField->insertItem (categ, -1); | 2611 | dialog->CategoryField->insertItem (categ, -1); |
2641 | if (firstCategory.isEmpty()) | 2612 | if (firstCategory.isEmpty()) |
2642 | firstCategory = categ; | 2613 | firstCategory = categ; |
2643 | } | 2614 | } |
2644 | } | 2615 | } |
2645 | ++it; | 2616 | ++it; |
2646 | } | 2617 | } |
2647 | 2618 | ||
2648 | 2619 | ||
2649 | if (firstCategory.isEmpty()) | 2620 | if (firstCategory.isEmpty()) |
2650 | setCategoryDialogFields(dialog); | 2621 | setCategoryDialogFields(dialog); |
2651 | else | 2622 | else |
2652 | setCategoryDialogFields(dialog, firstCategory); | 2623 | setCategoryDialogFields(dialog, firstCategory); |
2653 | 2624 | ||
2654 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); | 2625 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); |
2655 | 2626 | ||
2656 | if (initIcons) | 2627 | if (initIcons) |
2657 | { | 2628 | { |
2658 | Wait waitDialog(this, tr("Wait dialog")); | 2629 | Wait waitDialog(this, tr("Wait dialog")); |
2659 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2630 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
2660 | waitDialog.show(); | 2631 | waitDialog.show(); |
2661 | qApp->processEvents(); | 2632 | qApp->processEvents(); |
2662 | 2633 | ||
2663 | #ifdef DESKTOP | 2634 | #ifdef DESKTOP |
2664 | QDir d(iconPath); | 2635 | QDir d(iconPath); |
2665 | #else | 2636 | #else |
2666 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2637 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2667 | #endif | 2638 | #endif |
2668 | d.setFilter( QDir::Files); | 2639 | d.setFilter( QDir::Files); |
2669 | 2640 | ||
2670 | const QFileInfoList *list = d.entryInfoList(); | 2641 | const QFileInfoList *list = d.entryInfoList(); |
2671 | QFileInfoListIterator it( *list ); // create list iterator | 2642 | QFileInfoListIterator it( *list ); // create list iterator |
2672 | QFileInfo *fi; // pointer for traversing | 2643 | QFileInfo *fi; // pointer for traversing |
2673 | 2644 | ||
2674 | dialog->IconField->insertItem("predefined"); | 2645 | dialog->IconField->insertItem("predefined"); |
2675 | while ( (fi=it.current()) ) { // for each file... | 2646 | while ( (fi=it.current()) ) { // for each file... |
2676 | QString fileName = fi->fileName(); | 2647 | QString fileName = fi->fileName(); |
2677 | if(fileName.right(4) == ".png"){ | 2648 | if(fileName.right(4) == ".png"){ |
2678 | fileName = fileName.mid(0,fileName.length()-4); | 2649 | fileName = fileName.mid(0,fileName.length()-4); |
2679 | #ifdef DESKTOP | 2650 | #ifdef DESKTOP |
2680 | QPixmap imageOfFile; | 2651 | QPixmap imageOfFile; |
2681 | imageOfFile.load(iconPath + fi->fileName()); | 2652 | imageOfFile.load(iconPath + fi->fileName()); |
2682 | #else | 2653 | #else |
2683 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2654 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
2684 | #endif | 2655 | #endif |
2685 | QImage foo = imageOfFile.convertToImage(); | 2656 | QImage foo = imageOfFile.convertToImage(); |
2686 | foo = foo.smoothScale(16,16); | 2657 | foo = foo.smoothScale(16,16); |
2687 | imageOfFile.convertFromImage(foo); | 2658 | imageOfFile.convertFromImage(foo); |
2688 | dialog->IconField->insertItem(imageOfFile,fileName); | 2659 | dialog->IconField->insertItem(imageOfFile,fileName); |
2689 | } | 2660 | } |
2690 | ++it; | 2661 | ++it; |
2691 | } | 2662 | } |
2692 | waitDialog.hide(); | 2663 | waitDialog.hide(); |
2693 | } | 2664 | } |
2694 | 2665 | ||
2695 | #ifndef WIN32 | 2666 | #ifndef WIN32 |
2696 | dialog->show(); | 2667 | dialog->show(); |
@@ -2806,769 +2777,769 @@ void ZSafe::delCategory() | |||
2806 | break; | 2777 | break; |
2807 | } | 2778 | } |
2808 | 2779 | ||
2809 | } | 2780 | } |
2810 | } | 2781 | } |
2811 | 2782 | ||
2812 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | 2783 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) |
2813 | { | 2784 | { |
2814 | if (!dialog) | 2785 | if (!dialog) |
2815 | return; | 2786 | return; |
2816 | 2787 | ||
2817 | QString icon; | 2788 | QString icon; |
2818 | if (selectedItem) | 2789 | if (selectedItem) |
2819 | { | 2790 | { |
2820 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 2791 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
2821 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 2792 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
2822 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 2793 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
2823 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 2794 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
2824 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); | 2795 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); |
2825 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); | 2796 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); |
2826 | 2797 | ||
2827 | Category *cat= categories.find (selectedItem->text(0)); | 2798 | Category *cat= categories.find (selectedItem->text(0)); |
2828 | if (cat) | 2799 | if (cat) |
2829 | { | 2800 | { |
2830 | icon = cat->getIconName(); | 2801 | icon = cat->getIconName(); |
2831 | } | 2802 | } |
2832 | else | 2803 | else |
2833 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); | 2804 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); |
2834 | } | 2805 | } |
2835 | else | 2806 | else |
2836 | { | 2807 | { |
2837 | dialog->Field1->setText(tr("Name")); | 2808 | dialog->Field1->setText(tr("Name")); |
2838 | dialog->Field2->setText(tr("Username")); | 2809 | dialog->Field2->setText(tr("Username")); |
2839 | dialog->Field3->setText(tr("Password")); | 2810 | dialog->Field3->setText(tr("Password")); |
2840 | dialog->Field4->setText(tr("Comment")); | 2811 | dialog->Field4->setText(tr("Comment")); |
2841 | dialog->Field5->setText(tr("Field 4")); | 2812 | dialog->Field5->setText(tr("Field 4")); |
2842 | dialog->Field6->setText(tr("Field 5")); | 2813 | dialog->Field6->setText(tr("Field 5")); |
2843 | } | 2814 | } |
2844 | 2815 | ||
2845 | #ifdef DESKTOP | 2816 | #ifdef DESKTOP |
2846 | QDir d(iconPath); | 2817 | QDir d(iconPath); |
2847 | #else | 2818 | #else |
2848 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2819 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2849 | #endif | 2820 | #endif |
2850 | d.setFilter( QDir::Files); | 2821 | d.setFilter( QDir::Files); |
2851 | 2822 | ||
2852 | const QFileInfoList *list = d.entryInfoList(); | 2823 | const QFileInfoList *list = d.entryInfoList(); |
2853 | int i=0; | 2824 | int i=0; |
2854 | QFileInfoListIterator it( *list ); // create list iterator | 2825 | QFileInfoListIterator it( *list ); // create list iterator |
2855 | QFileInfo *fi; // pointer for traversing | 2826 | QFileInfo *fi; // pointer for traversing |
2856 | if (icon.isEmpty() || icon.isNull()) | 2827 | if (icon.isEmpty() || icon.isNull()) |
2857 | { | 2828 | { |
2858 | dialog->IconField->setCurrentItem(0); | 2829 | dialog->IconField->setCurrentItem(0); |
2859 | } | 2830 | } |
2860 | else | 2831 | else |
2861 | { | 2832 | { |
2862 | while ( (fi=it.current()) ) | 2833 | while ( (fi=it.current()) ) |
2863 | { // for each file... | 2834 | { // for each file... |
2864 | QString fileName = fi->fileName(); | 2835 | QString fileName = fi->fileName(); |
2865 | if(fileName.right(4) == ".png") | 2836 | if(fileName.right(4) == ".png") |
2866 | { | 2837 | { |
2867 | fileName = fileName.mid(0,fileName.length()-4); | 2838 | fileName = fileName.mid(0,fileName.length()-4); |
2868 | 2839 | ||
2869 | if(fileName+".png"==icon) | 2840 | if(fileName+".png"==icon) |
2870 | { | 2841 | { |
2871 | dialog->IconField->setCurrentItem(i+1); | 2842 | dialog->IconField->setCurrentItem(i+1); |
2872 | break; | 2843 | break; |
2873 | } | 2844 | } |
2874 | ++i; | 2845 | ++i; |
2875 | } | 2846 | } |
2876 | ++it; | 2847 | ++it; |
2877 | } | 2848 | } |
2878 | } | 2849 | } |
2879 | } | 2850 | } |
2880 | 2851 | ||
2881 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | 2852 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) |
2882 | { | 2853 | { |
2883 | if (!dialog) | 2854 | if (!dialog) |
2884 | return; | 2855 | return; |
2885 | 2856 | ||
2886 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); | 2857 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); |
2887 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); | 2858 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); |
2888 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); | 2859 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); |
2889 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); | 2860 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); |
2890 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); | 2861 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); |
2891 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); | 2862 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); |
2892 | 2863 | ||
2893 | QString icon; | 2864 | QString icon; |
2894 | Category *cat= categories.find (category); | 2865 | Category *cat= categories.find (category); |
2895 | if (cat) | 2866 | if (cat) |
2896 | { | 2867 | { |
2897 | icon = cat->getIconName(); | 2868 | icon = cat->getIconName(); |
2898 | } | 2869 | } |
2899 | else | 2870 | else |
2900 | icon = conf->readEntry(APP_KEY+category); | 2871 | icon = conf->readEntry(APP_KEY+category); |
2901 | 2872 | ||
2902 | #ifdef DESKTOP | 2873 | #ifdef DESKTOP |
2903 | QDir d(iconPath); | 2874 | QDir d(iconPath); |
2904 | #else | 2875 | #else |
2905 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2876 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2906 | #endif | 2877 | #endif |
2907 | d.setFilter( QDir::Files); | 2878 | d.setFilter( QDir::Files); |
2908 | 2879 | ||
2909 | const QFileInfoList *list = d.entryInfoList(); | 2880 | const QFileInfoList *list = d.entryInfoList(); |
2910 | int i=0; | 2881 | int i=0; |
2911 | QFileInfoListIterator it( *list ); // create list iterator | 2882 | QFileInfoListIterator it( *list ); // create list iterator |
2912 | QFileInfo *fi; // pointer for traversing | 2883 | QFileInfo *fi; // pointer for traversing |
2913 | if (icon.isEmpty() || icon.isNull()) | 2884 | if (icon.isEmpty() || icon.isNull()) |
2914 | { | 2885 | { |
2915 | dialog->IconField->setCurrentItem(0); | 2886 | dialog->IconField->setCurrentItem(0); |
2916 | } | 2887 | } |
2917 | else | 2888 | else |
2918 | { | 2889 | { |
2919 | while ( (fi=it.current()) ) | 2890 | while ( (fi=it.current()) ) |
2920 | { // for each file... | 2891 | { // for each file... |
2921 | QString fileName = fi->fileName(); | 2892 | QString fileName = fi->fileName(); |
2922 | if(fileName.right(4) == ".png") | 2893 | if(fileName.right(4) == ".png") |
2923 | { | 2894 | { |
2924 | fileName = fileName.mid(0,fileName.length()-4); | 2895 | fileName = fileName.mid(0,fileName.length()-4); |
2925 | 2896 | ||
2926 | if(fileName+".png"==icon) | 2897 | if(fileName+".png"==icon) |
2927 | { | 2898 | { |
2928 | dialog->IconField->setCurrentItem(i+1); | 2899 | dialog->IconField->setCurrentItem(i+1); |
2929 | break; | 2900 | break; |
2930 | } | 2901 | } |
2931 | ++i; | 2902 | ++i; |
2932 | } | 2903 | } |
2933 | ++it; | 2904 | ++it; |
2934 | } | 2905 | } |
2935 | } | 2906 | } |
2936 | } | 2907 | } |
2937 | 2908 | ||
2938 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) | 2909 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) |
2939 | { | 2910 | { |
2940 | QString app_key = APP_KEY; | 2911 | QString app_key = APP_KEY; |
2941 | #ifndef DESKTOP | 2912 | #ifndef DESKTOP |
2942 | conf->setGroup ("fieldDefs"); | 2913 | conf->setGroup ("fieldDefs"); |
2943 | #else | 2914 | #else |
2944 | #ifndef WIN32 | 2915 | #ifndef WIN32 |
2945 | app_key += "/fieldDefs/"; | 2916 | app_key += "/fieldDefs/"; |
2946 | #endif | 2917 | #endif |
2947 | #endif | 2918 | #endif |
2948 | QString category = dialog->CategoryField->currentText(); | 2919 | QString category = dialog->CategoryField->currentText(); |
2949 | // #ifndef WIN32 | 2920 | // #ifndef WIN32 |
2950 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); | 2921 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); |
2951 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); | 2922 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); |
2952 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); | 2923 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); |
2953 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); | 2924 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); |
2954 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); | 2925 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); |
2955 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); | 2926 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); |
2956 | // #endif | 2927 | // #endif |
2957 | saveConf(); | 2928 | saveConf(); |
2958 | #ifndef DESKTOP | 2929 | #ifndef DESKTOP |
2959 | conf->setGroup ("zsafe"); | 2930 | conf->setGroup ("zsafe"); |
2960 | #endif | 2931 | #endif |
2961 | } | 2932 | } |
2962 | 2933 | ||
2963 | void ZSafe::editCategory() | 2934 | void ZSafe::editCategory() |
2964 | { | 2935 | { |
2965 | if (!selectedItem) | 2936 | if (!selectedItem) |
2966 | return; | 2937 | return; |
2967 | if (isCategory(selectedItem)) | 2938 | if (isCategory(selectedItem)) |
2968 | { | 2939 | { |
2969 | QString category = selectedItem->text(0); | 2940 | QString category = selectedItem->text(0); |
2970 | bool initIcons = false; | 2941 | bool initIcons = false; |
2971 | // open the 'Category' dialog | 2942 | // open the 'Category' dialog |
2972 | CategoryDialog *dialog; | 2943 | CategoryDialog *dialog; |
2973 | if (categoryDialog) | 2944 | if (categoryDialog) |
2974 | { | 2945 | { |
2975 | dialog = categoryDialog; | 2946 | dialog = categoryDialog; |
2976 | } | 2947 | } |
2977 | else | 2948 | else |
2978 | { | 2949 | { |
2979 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2950 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2980 | #ifdef WIN32 | 2951 | #ifdef WIN32 |
2981 | categoryDialog->setCaption ("Qt " + tr("Category")); | 2952 | categoryDialog->setCaption ("Qt " + tr("Category")); |
2982 | #endif | 2953 | #endif |
2983 | dialog = categoryDialog; | 2954 | dialog = categoryDialog; |
2984 | connect( dialog->CategoryField, | 2955 | connect( dialog->CategoryField, |
2985 | SIGNAL( activated(const QString&)), | 2956 | SIGNAL( activated(const QString&)), |
2986 | this, SLOT( categoryFieldActivated(const QString&) ) ); | 2957 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
2987 | initIcons = true; | 2958 | initIcons = true; |
2988 | } | 2959 | } |
2989 | setCategoryDialogFields(dialog); | 2960 | setCategoryDialogFields(dialog); |
2990 | 2961 | ||
2991 | #ifdef DESKTOP | 2962 | #ifdef DESKTOP |
2992 | #ifndef WIN32 | 2963 | #ifndef WIN32 |
2993 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 2964 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
2994 | #else | 2965 | #else |
2995 | // read all categories from the config file and store | 2966 | // read all categories from the config file and store |
2996 | // into a list | 2967 | // into a list |
2997 | QFile f (cfgFile); | 2968 | QFile f (cfgFile); |
2998 | QStringList list; | 2969 | QStringList list; |
2999 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2970 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3000 | QTextStream t( &f ); // use a text stream | 2971 | QTextStream t( &f ); // use a text stream |
3001 | QString s; | 2972 | QString s; |
3002 | int n = 1; | 2973 | int n = 1; |
3003 | while ( !t.eof() ) { // until end of file... | 2974 | while ( !t.eof() ) { // until end of file... |
3004 | s = t.readLine(); // line of text excluding '\n' | 2975 | s = t.readLine(); // line of text excluding '\n' |
3005 | list.append(s); | 2976 | list.append(s); |
3006 | } | 2977 | } |
3007 | f.close(); | 2978 | f.close(); |
3008 | } | 2979 | } |
3009 | #endif | 2980 | #endif |
3010 | #else | 2981 | #else |
3011 | // read all categories from the config file and store | 2982 | // read all categories from the config file and store |
3012 | // into a list | 2983 | // into a list |
3013 | QFile f (cfgFile); | 2984 | QFile f (cfgFile); |
3014 | QStringList list; | 2985 | QStringList list; |
3015 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2986 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3016 | QTextStream t( &f ); // use a text stream | 2987 | QTextStream t( &f ); // use a text stream |
3017 | QString s; | 2988 | QString s; |
3018 | while ( !t.eof() ) { // until end of file... | 2989 | while ( !t.eof() ) { // until end of file... |
3019 | s = t.readLine(); // line of text excluding '\n' | 2990 | s = t.readLine(); // line of text excluding '\n' |
3020 | list.append(s); | 2991 | list.append(s); |
3021 | } | 2992 | } |
3022 | f.close(); | 2993 | f.close(); |
3023 | } | 2994 | } |
3024 | #endif | 2995 | #endif |
3025 | QStringList::Iterator it = list.begin(); | 2996 | QStringList::Iterator it = list.begin(); |
3026 | QString categ; | 2997 | QString categ; |
3027 | dialog->CategoryField->clear(); // remove all items | 2998 | dialog->CategoryField->clear(); // remove all items |
3028 | int i=0; | 2999 | int i=0; |
3029 | bool foundCategory = false; | 3000 | bool foundCategory = false; |
3030 | while( it != list.end() ) | 3001 | while( it != list.end() ) |
3031 | { | 3002 | { |
3032 | QString *cat = new QString (*it); | 3003 | QString *cat = new QString (*it); |
3033 | if (cat->contains("-field1", FALSE)) | 3004 | if (cat->contains("-field1", FALSE)) |
3034 | { | 3005 | { |
3035 | #ifdef DESKTOP | 3006 | #ifdef DESKTOP |
3036 | #ifndef WIN32 | 3007 | #ifndef WIN32 |
3037 | categ = cat->section ("-field1", 0, 0); | 3008 | categ = cat->section ("-field1", 0, 0); |
3038 | #else | 3009 | #else |
3039 | int pos = cat->find ("-field1"); | 3010 | int pos = cat->find ("-field1"); |
3040 | categ = cat->left (pos); | 3011 | categ = cat->left (pos); |
3041 | #endif | 3012 | #endif |
3042 | #else | 3013 | #else |
3043 | int pos = cat->find ("-field1"); | 3014 | int pos = cat->find ("-field1"); |
3044 | cat->truncate(pos); | 3015 | cat->truncate(pos); |
3045 | categ = *cat; | 3016 | categ = *cat; |
3046 | #endif | 3017 | #endif |
3047 | if (!categ.isEmpty()) | 3018 | if (!categ.isEmpty()) |
3048 | { | 3019 | { |
3049 | dialog->CategoryField->insertItem (categ, i); | 3020 | dialog->CategoryField->insertItem (categ, i); |
3050 | if (category.compare(categ) == 0) | 3021 | if (category.compare(categ) == 0) |
3051 | { | 3022 | { |
3052 | dialog->CategoryField->setCurrentItem(i); | 3023 | dialog->CategoryField->setCurrentItem(i); |
3053 | foundCategory = true; | 3024 | foundCategory = true; |
3054 | } | 3025 | } |
3055 | i++; | 3026 | i++; |
3056 | } | 3027 | } |
3057 | } | 3028 | } |
3058 | ++it; | 3029 | ++it; |
3059 | } | 3030 | } |
3060 | if (!foundCategory) | 3031 | if (!foundCategory) |
3061 | { | 3032 | { |
3062 | dialog->CategoryField->insertItem (category, i); | 3033 | dialog->CategoryField->insertItem (category, i); |
3063 | dialog->CategoryField->setCurrentItem(i); | 3034 | dialog->CategoryField->setCurrentItem(i); |
3064 | } | 3035 | } |
3065 | 3036 | ||
3066 | QString icon; | 3037 | QString icon; |
3067 | Category *cat= categories.find (selectedItem->text(0)); | 3038 | Category *cat= categories.find (selectedItem->text(0)); |
3068 | if (cat) | 3039 | if (cat) |
3069 | { | 3040 | { |
3070 | icon = cat->getIconName(); | 3041 | icon = cat->getIconName(); |
3071 | } | 3042 | } |
3072 | 3043 | ||
3073 | if (initIcons) | 3044 | if (initIcons) |
3074 | { | 3045 | { |
3075 | 3046 | ||
3076 | Wait waitDialog(this, tr("Wait dialog")); | 3047 | Wait waitDialog(this, tr("Wait dialog")); |
3077 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 3048 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
3078 | waitDialog.show(); | 3049 | waitDialog.show(); |
3079 | qApp->processEvents(); | 3050 | qApp->processEvents(); |
3080 | 3051 | ||
3081 | #ifdef DESKTOP | 3052 | #ifdef DESKTOP |
3082 | QDir d(iconPath); | 3053 | QDir d(iconPath); |
3083 | #else | 3054 | #else |
3084 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3055 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
3085 | #endif | 3056 | #endif |
3086 | d.setFilter( QDir::Files); | 3057 | d.setFilter( QDir::Files); |
3087 | 3058 | ||
3088 | const QFileInfoList *list = d.entryInfoList(); | 3059 | const QFileInfoList *list = d.entryInfoList(); |
3089 | int i=0; | 3060 | int i=0; |
3090 | QFileInfoListIterator it( *list ); // create list iterator | 3061 | QFileInfoListIterator it( *list ); // create list iterator |
3091 | QFileInfo *fi; // pointer for traversing | 3062 | QFileInfo *fi; // pointer for traversing |
3092 | if (icon.isEmpty() || icon.isNull()) | 3063 | if (icon.isEmpty() || icon.isNull()) |
3093 | { | 3064 | { |
3094 | dialog->IconField->setCurrentItem(0); | 3065 | dialog->IconField->setCurrentItem(0); |
3095 | } | 3066 | } |
3096 | 3067 | ||
3097 | dialog->IconField->insertItem("predefined"); | 3068 | dialog->IconField->insertItem("predefined"); |
3098 | while ( (fi=it.current()) ) { // for each file... | 3069 | while ( (fi=it.current()) ) { // for each file... |
3099 | QString fileName = fi->fileName(); | 3070 | QString fileName = fi->fileName(); |
3100 | if(fileName.right(4) == ".png") | 3071 | if(fileName.right(4) == ".png") |
3101 | { | 3072 | { |
3102 | fileName = fileName.mid(0,fileName.length()-4); | 3073 | fileName = fileName.mid(0,fileName.length()-4); |
3103 | #ifdef DESKTOP | 3074 | #ifdef DESKTOP |
3104 | QPixmap imageOfFile; | 3075 | QPixmap imageOfFile; |
3105 | imageOfFile.load(iconPath + fi->fileName()); | 3076 | imageOfFile.load(iconPath + fi->fileName()); |
3106 | #else | 3077 | #else |
3107 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 3078 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
3108 | #endif | 3079 | #endif |
3109 | QImage foo = imageOfFile.convertToImage(); | 3080 | QImage foo = imageOfFile.convertToImage(); |
3110 | foo = foo.smoothScale(16,16); | 3081 | foo = foo.smoothScale(16,16); |
3111 | imageOfFile.convertFromImage(foo); | 3082 | imageOfFile.convertFromImage(foo); |
3112 | dialog->IconField->insertItem(imageOfFile,fileName); | 3083 | dialog->IconField->insertItem(imageOfFile,fileName); |
3113 | if(fileName+".png"==icon) | 3084 | if(fileName+".png"==icon) |
3114 | dialog->IconField->setCurrentItem(i+1); | 3085 | dialog->IconField->setCurrentItem(i+1); |
3115 | ++i; | 3086 | ++i; |
3116 | } | 3087 | } |
3117 | ++it; | 3088 | ++it; |
3118 | } | 3089 | } |
3119 | waitDialog.hide(); | 3090 | waitDialog.hide(); |
3120 | } | 3091 | } |
3121 | else | 3092 | else |
3122 | { | 3093 | { |
3123 | #ifdef DESKTOP | 3094 | #ifdef DESKTOP |
3124 | // QDir d(QDir::homeDirPath() + "/pics/"); | 3095 | // QDir d(QDir::homeDirPath() + "/pics/"); |
3125 | QDir d(iconPath); | 3096 | QDir d(iconPath); |
3126 | #else | 3097 | #else |
3127 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3098 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
3128 | #endif | 3099 | #endif |
3129 | d.setFilter( QDir::Files); | 3100 | d.setFilter( QDir::Files); |
3130 | 3101 | ||
3131 | const QFileInfoList *list = d.entryInfoList(); | 3102 | const QFileInfoList *list = d.entryInfoList(); |
3132 | int i=0; | 3103 | int i=0; |
3133 | QFileInfoListIterator it( *list ); // create list iterator | 3104 | QFileInfoListIterator it( *list ); // create list iterator |
3134 | QFileInfo *fi; // pointer for traversing | 3105 | QFileInfo *fi; // pointer for traversing |
3135 | if (icon.isEmpty() || icon.isNull()) | 3106 | if (icon.isEmpty() || icon.isNull()) |
3136 | { | 3107 | { |
3137 | dialog->IconField->setCurrentItem(0); | 3108 | dialog->IconField->setCurrentItem(0); |
3138 | } | 3109 | } |
3139 | else | 3110 | else |
3140 | { | 3111 | { |
3141 | 3112 | ||
3142 | while ( (fi=it.current()) ) | 3113 | while ( (fi=it.current()) ) |
3143 | { // for each file... | 3114 | { // for each file... |
3144 | QString fileName = fi->fileName(); | 3115 | QString fileName = fi->fileName(); |
3145 | if(fileName.right(4) == ".png") | 3116 | if(fileName.right(4) == ".png") |
3146 | { | 3117 | { |
3147 | fileName = fileName.mid(0,fileName.length()-4); | 3118 | fileName = fileName.mid(0,fileName.length()-4); |
3148 | 3119 | ||
3149 | 3120 | ||
3150 | if(fileName+".png"==icon) | 3121 | if(fileName+".png"==icon) |
3151 | { | 3122 | { |
3152 | dialog->IconField->setCurrentItem(i+1); | 3123 | dialog->IconField->setCurrentItem(i+1); |
3153 | break; | 3124 | break; |
3154 | } | 3125 | } |
3155 | ++i; | 3126 | ++i; |
3156 | } | 3127 | } |
3157 | ++it; | 3128 | ++it; |
3158 | } | 3129 | } |
3159 | } | 3130 | } |
3160 | } | 3131 | } |
3161 | 3132 | ||
3162 | // dialog->show(); | 3133 | // dialog->show(); |
3163 | #ifndef DESKTOP | 3134 | #ifndef DESKTOP |
3164 | // dialog->move (20, 100); | 3135 | // dialog->move (20, 100); |
3165 | #endif | 3136 | #endif |
3166 | DialogCode result = (DialogCode) dialog->exec(); | 3137 | DialogCode result = (DialogCode) dialog->exec(); |
3167 | #ifdef DESKTOP | 3138 | #ifdef DESKTOP |
3168 | result = Accepted; | 3139 | result = Accepted; |
3169 | #endif | 3140 | #endif |
3170 | 3141 | ||
3171 | QString fullIconPath; | 3142 | QString fullIconPath; |
3172 | QPixmap *pix; | 3143 | QPixmap *pix; |
3173 | if (result == Accepted) | 3144 | if (result == Accepted) |
3174 | { | 3145 | { |
3175 | modified = true; | 3146 | modified = true; |
3176 | if (category != dialog->CategoryField->currentText()) | 3147 | if (category != dialog->CategoryField->currentText()) |
3177 | { | 3148 | { |
3178 | categories.remove (category); | 3149 | categories.remove (category); |
3179 | // #ifndef WIN32 | 3150 | // #ifndef WIN32 |
3180 | conf->removeEntry(category); | 3151 | conf->removeEntry(category); |
3181 | // #endif | 3152 | // #endif |
3182 | saveConf(); | 3153 | saveConf(); |
3183 | } | 3154 | } |
3184 | 3155 | ||
3185 | category = dialog->CategoryField->currentText(); | 3156 | category = dialog->CategoryField->currentText(); |
3186 | icon = dialog->IconField->currentText()+".png"; | 3157 | icon = dialog->IconField->currentText()+".png"; |
3187 | 3158 | ||
3188 | if (cat) | 3159 | if (cat) |
3189 | { | 3160 | { |
3190 | owarn << "Category found" << oendl; | 3161 | owarn << "Category found" << oendl; |
3191 | 3162 | ||
3192 | // if (!icon.isEmpty() && !icon.isNull()) | 3163 | // if (!icon.isEmpty() && !icon.isNull()) |
3193 | if (icon != "predefined.png") | 3164 | if (icon != "predefined.png") |
3194 | { | 3165 | { |
3195 | // build the full path | 3166 | // build the full path |
3196 | fullIconPath = iconPath + icon; | 3167 | fullIconPath = iconPath + icon; |
3197 | pix = new QPixmap (fullIconPath); | 3168 | pix = new QPixmap (fullIconPath); |
3198 | if (pix) | 3169 | if (pix) |
3199 | { | 3170 | { |
3200 | // save the full pixmap name into the config file | 3171 | // save the full pixmap name into the config file |
3201 | // #ifndef WIN32 | 3172 | // #ifndef WIN32 |
3202 | conf->writeEntry(APP_KEY+category, icon); | 3173 | conf->writeEntry(APP_KEY+category, icon); |
3203 | // #endif | 3174 | // #endif |
3204 | saveConf(); | 3175 | saveConf(); |
3205 | QImage img = pix->convertToImage(); | 3176 | QImage img = pix->convertToImage(); |
3206 | pix->convertFromImage(img.smoothScale(14,14)); | 3177 | pix->convertFromImage(img.smoothScale(14,14)); |
3207 | cat->setIconName (icon); | 3178 | cat->setIconName (icon); |
3208 | cat->setIcon (*pix); | 3179 | cat->setIcon (*pix); |
3209 | } | 3180 | } |
3210 | } | 3181 | } |
3211 | else | 3182 | else |
3212 | { | 3183 | { |
3213 | // #ifndef WIN32 | 3184 | // #ifndef WIN32 |
3214 | conf->removeEntry (category); | 3185 | conf->removeEntry (category); |
3215 | // #endif | 3186 | // #endif |
3216 | saveConf(); | 3187 | saveConf(); |
3217 | cat->setIcon (*getPredefinedIcon(category)); | 3188 | cat->setIcon (*getPredefinedIcon(category)); |
3218 | } | 3189 | } |
3219 | 3190 | ||
3220 | // change the category name of the selected category | 3191 | // change the category name of the selected category |
3221 | QListViewItem *catItem = cat->getListItem(); | 3192 | QListViewItem *catItem = cat->getListItem(); |
3222 | if (catItem) | 3193 | if (catItem) |
3223 | { | 3194 | { |
3224 | qWarning (category); | 3195 | qWarning (category); |
3225 | catItem->setText( 0, tr( category ) ); | 3196 | catItem->setText( 0, tr( category ) ); |
3226 | cat->setCategoryName (tr(category)); | 3197 | cat->setCategoryName (tr(category)); |
3227 | 3198 | ||
3228 | cat->initListItem(); | 3199 | cat->initListItem(); |
3229 | categories.insert (category, cat); | 3200 | categories.insert (category, cat); |
3230 | } | 3201 | } |
3231 | } | 3202 | } |
3232 | saveCategoryDialogFields(dialog); | 3203 | saveCategoryDialogFields(dialog); |
3233 | } | 3204 | } |
3234 | else | 3205 | else |
3235 | { | 3206 | { |
3236 | // delete dialog; | 3207 | // delete dialog; |
3237 | dialog->hide(); | 3208 | dialog->hide(); |
3238 | return; | 3209 | return; |
3239 | } | 3210 | } |
3240 | 3211 | ||
3241 | } | 3212 | } |
3242 | } | 3213 | } |
3243 | 3214 | ||
3244 | void ZSafe::cutItem() | 3215 | void ZSafe::cutItem() |
3245 | { | 3216 | { |
3246 | if (!selectedItem) | 3217 | if (!selectedItem) |
3247 | return; | 3218 | return; |
3248 | if (!isCategory(selectedItem)) | 3219 | if (!isCategory(selectedItem)) |
3249 | { | 3220 | { |
3250 | IsCut = true; | 3221 | IsCut = true; |
3251 | copiedItem = selectedItem; | 3222 | copiedItem = selectedItem; |
3252 | } | 3223 | } |
3253 | } | 3224 | } |
3254 | 3225 | ||
3255 | void ZSafe::copyItem() | 3226 | void ZSafe::copyItem() |
3256 | { | 3227 | { |
3257 | if (!selectedItem) | 3228 | if (!selectedItem) |
3258 | return; | 3229 | return; |
3259 | if (!isCategory(selectedItem)) | 3230 | if (!isCategory(selectedItem)) |
3260 | { | 3231 | { |
3261 | IsCopy = true; | 3232 | IsCopy = true; |
3262 | copiedItem = selectedItem; | 3233 | copiedItem = selectedItem; |
3263 | } | 3234 | } |
3264 | } | 3235 | } |
3265 | 3236 | ||
3266 | // paste item into category | 3237 | // paste item into category |
3267 | void ZSafe::pasteItem() | 3238 | void ZSafe::pasteItem() |
3268 | { | 3239 | { |
3269 | if (!selectedItem) | 3240 | if (!selectedItem) |
3270 | return; | 3241 | return; |
3271 | if (isCategory(selectedItem)) | 3242 | if (isCategory(selectedItem)) |
3272 | { | 3243 | { |
3273 | modified = true; | 3244 | modified = true; |
3274 | if (IsCut) | 3245 | if (IsCut) |
3275 | { | 3246 | { |
3276 | if (copiedItem) | 3247 | if (copiedItem) |
3277 | { | 3248 | { |
3278 | // add the new item | 3249 | // add the new item |
3279 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 3250 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
3280 | // i->setOpen (TRUE); | 3251 | // i->setOpen (TRUE); |
3281 | i->setText (0, copiedItem->text(0)); | 3252 | i->setText (0, copiedItem->text(0)); |
3282 | i->setText (1, copiedItem->text(1)); | 3253 | i->setText (1, copiedItem->text(1)); |
3283 | i->setText (2, copiedItem->text(2)); | 3254 | i->setText (2, copiedItem->text(2)); |
3284 | i->setText (3, copiedItem->text(3)); | 3255 | i->setText (3, copiedItem->text(3)); |
3285 | i->setText (4, copiedItem->text(4)); | 3256 | i->setText (4, copiedItem->text(4)); |
3286 | i->setText (5, copiedItem->text(5)); | 3257 | i->setText (5, copiedItem->text(5)); |
3287 | selectedItem->setOpen( TRUE ); | 3258 | selectedItem->setOpen( TRUE ); |
3288 | 3259 | ||
3289 | // remove the cutted item | 3260 | // remove the cutted item |
3290 | copiedItem->parent()->takeItem(copiedItem); | 3261 | copiedItem->parent()->takeItem(copiedItem); |
3291 | selectedItem = NULL; | 3262 | selectedItem = NULL; |
3292 | } | 3263 | } |
3293 | } | 3264 | } |
3294 | else if (IsCopy) | 3265 | else if (IsCopy) |
3295 | { | 3266 | { |
3296 | if (copiedItem) | 3267 | if (copiedItem) |
3297 | { | 3268 | { |
3298 | // add the new item | 3269 | // add the new item |
3299 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 3270 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
3300 | // i->setOpen (TRUE); | 3271 | // i->setOpen (TRUE); |
3301 | i->setText (0, copiedItem->text(0)); | 3272 | i->setText (0, copiedItem->text(0)); |
3302 | i->setText (1, copiedItem->text(1)); | 3273 | i->setText (1, copiedItem->text(1)); |
3303 | i->setText (2, copiedItem->text(2)); | 3274 | i->setText (2, copiedItem->text(2)); |
3304 | i->setText (3, copiedItem->text(3)); | 3275 | i->setText (3, copiedItem->text(3)); |
3305 | i->setText (4, copiedItem->text(4)); | 3276 | i->setText (4, copiedItem->text(4)); |
3306 | i->setText (5, copiedItem->text(5)); | 3277 | i->setText (5, copiedItem->text(5)); |
3307 | selectedItem->setOpen( TRUE ); | 3278 | selectedItem->setOpen( TRUE ); |
3308 | } | 3279 | } |
3309 | } | 3280 | } |
3310 | } | 3281 | } |
3311 | IsCut = false; | 3282 | IsCut = false; |
3312 | IsCopy = false; | 3283 | IsCopy = false; |
3313 | } | 3284 | } |
3314 | 3285 | ||
3315 | void ZSafe::newDocument() | 3286 | void ZSafe::newDocument() |
3316 | { | 3287 | { |
3317 | 3288 | ||
3318 | // open the file dialog | 3289 | // open the file dialog |
3319 | #ifndef DESKTOP | 3290 | #ifndef DESKTOP |
3320 | #ifndef NO_OPIE | 3291 | #ifndef NO_OPIE |
3321 | QMap<QString, QStringList> mimeTypes; | 3292 | QMap<QString, QStringList> mimeTypes; |
3322 | mimeTypes.insert(tr("All"), QStringList() ); | 3293 | mimeTypes.insert(tr("All"), QStringList() ); |
3323 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3294 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3324 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 3295 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
3325 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3296 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3326 | QString::null, | 3297 | QString::null, |
3327 | mimeTypes, | 3298 | mimeTypes, |
3328 | this, | 3299 | this, |
3329 | tr ("Create new ZSafe document")); | 3300 | tr ("Create new ZSafe document")); |
3330 | #else | 3301 | #else |
3331 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3302 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3332 | tr ("Create new ZSafe document"), | 3303 | tr ("Create new ZSafe document"), |
3333 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3304 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3334 | "*.zsf"); | 3305 | "*.zsf"); |
3335 | #endif | 3306 | #endif |
3336 | #else | 3307 | #else |
3337 | QString newFile = QFileDialog::getSaveFileName( | 3308 | QString newFile = QFileDialog::getSaveFileName( |
3338 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3309 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3339 | "ZSafe (*.zsf)", | 3310 | "ZSafe (*.zsf)", |
3340 | this, | 3311 | this, |
3341 | "ZSafe File Dialog" | 3312 | "ZSafe File Dialog" |
3342 | "Choose a ZSafe file" ); | 3313 | "Choose a ZSafe file" ); |
3343 | #endif | 3314 | #endif |
3344 | 3315 | ||
3345 | // open the new document | 3316 | // open the new document |
3346 | if (newFile && newFile.length() > 0 ) | 3317 | if (newFile && newFile.length() > 0 ) |
3347 | { | 3318 | { |
3348 | // save the previous opened document | 3319 | // save the previous opened document |
3349 | if (!filename.isEmpty()) | 3320 | if (!filename.isEmpty()) |
3350 | saveDocument(filename, FALSE); | 3321 | saveDocument(filename, FALSE); |
3351 | 3322 | ||
3352 | modified = true; | 3323 | modified = true; |
3353 | 3324 | ||
3354 | // clear the password list | 3325 | // clear the password list |
3355 | QListViewItem *i; | 3326 | QListViewItem *i; |
3356 | QListViewItem *c = NULL; | 3327 | QListViewItem *c = NULL; |
3357 | // step through all categories | 3328 | // step through all categories |
3358 | for (i = ListView->firstChild(); | 3329 | for (i = ListView->firstChild(); |
3359 | i != NULL; | 3330 | i != NULL; |
3360 | i = i->nextSibling()) | 3331 | i = i->nextSibling()) |
3361 | { | 3332 | { |
3362 | if (c) delete c; // delete the previous category | 3333 | if (c) delete c; // delete the previous category |
3363 | 3334 | ||
3364 | c = i; | 3335 | c = i; |
3365 | // step through all subitems | 3336 | // step through all subitems |
3366 | QListViewItem *si; | 3337 | QListViewItem *si; |
3367 | for (si = i->firstChild(); | 3338 | for (si = i->firstChild(); |
3368 | si != NULL; ) | 3339 | si != NULL; ) |
3369 | { | 3340 | { |
3370 | QListViewItem *_si = si; | 3341 | QListViewItem *_si = si; |
3371 | si = si->nextSibling(); | 3342 | si = si->nextSibling(); |
3372 | i->takeItem(_si); // remove from view list | 3343 | i->takeItem(_si); // remove from view list |
3373 | if (_si) delete _si; | 3344 | if (_si) delete _si; |
3374 | } | 3345 | } |
3375 | } | 3346 | } |
3376 | if (c) delete c; // delete the previous category | 3347 | if (c) delete c; // delete the previous category |
3377 | categories.clear(); | 3348 | categories.clear(); |
3378 | 3349 | ||
3379 | // m_password = ""; | 3350 | // m_password = ""; |
3380 | selectedItem = NULL; | 3351 | selectedItem = NULL; |
3381 | 3352 | ||
3382 | filename = newFile; | 3353 | filename = newFile; |
3383 | 3354 | ||
3384 | // save the current filename to the config file | 3355 | // save the current filename to the config file |
3385 | conf->writeEntry(APP_KEY+"document", filename); | 3356 | conf->writeEntry(APP_KEY+"document", filename); |
3386 | saveConf(); | 3357 | saveConf(); |
3387 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3358 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3388 | #ifdef WIN32 | 3359 | #ifdef WIN32 |
3389 | this->setCaption("Qt ZSafe: " + ti); | 3360 | this->setCaption("Qt ZSafe: " + ti); |
3390 | #else | 3361 | #else |
3391 | this->setCaption("ZSafe: " + ti); | 3362 | this->setCaption("ZSafe: " + ti); |
3392 | #endif | 3363 | #endif |
3393 | 3364 | ||
3394 | // openDocument(filename); | 3365 | // openDocument(filename); |
3395 | 3366 | ||
3396 | QMessageBox::information( this, tr("ZSafe"), | 3367 | QMessageBox::information( this, tr("ZSafe"), |
3397 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3368 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3398 | 3369 | ||
3399 | saveDocumentWithPwd(); | 3370 | saveDocumentWithPwd(); |
3400 | } | 3371 | } |
3401 | } | 3372 | } |
3402 | 3373 | ||
3403 | void ZSafe::loadDocument() | 3374 | void ZSafe::loadDocument() |
3404 | { | 3375 | { |
3405 | 3376 | ||
3406 | // open the file dialog | 3377 | // open the file dialog |
3407 | #ifndef DESKTOP | 3378 | #ifndef DESKTOP |
3408 | #ifndef NO_OPIE | 3379 | #ifndef NO_OPIE |
3409 | QMap<QString, QStringList> mimeTypes; | 3380 | QMap<QString, QStringList> mimeTypes; |
3410 | mimeTypes.insert(tr("All"), QStringList() ); | 3381 | mimeTypes.insert(tr("All"), QStringList() ); |
3411 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3382 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3412 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 3383 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
3413 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3384 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3414 | QString::null, | 3385 | QString::null, |
3415 | mimeTypes, | 3386 | mimeTypes, |
3416 | this, | 3387 | this, |
3417 | tr ("Open ZSafe document")); | 3388 | tr ("Open ZSafe document")); |
3418 | #else | 3389 | #else |
3419 | QString newFile = ScQtFileEdit::getOpenFileName(this, | 3390 | QString newFile = ScQtFileEdit::getOpenFileName(this, |
3420 | tr ("Open ZSafe document"), | 3391 | tr ("Open ZSafe document"), |
3421 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3392 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3422 | "*.zsf"); | 3393 | "*.zsf"); |
3423 | #endif | 3394 | #endif |
3424 | #else | 3395 | #else |
3425 | QString newFile = QFileDialog::getOpenFileName( | 3396 | QString newFile = QFileDialog::getOpenFileName( |
3426 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3397 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3427 | "ZSafe (*.zsf)", | 3398 | "ZSafe (*.zsf)", |
3428 | this, | 3399 | this, |
3429 | "ZSafe File Dialog" | 3400 | "ZSafe File Dialog" |
3430 | "Choose a ZSafe file" ); | 3401 | "Choose a ZSafe file" ); |
3431 | #endif | 3402 | #endif |
3432 | 3403 | ||
3433 | // open the new document | 3404 | // open the new document |
3434 | if (newFile && newFile.length() > 0 ) | 3405 | if (newFile && newFile.length() > 0 ) |
3435 | { | 3406 | { |
3436 | // save the previous opened document | 3407 | // save the previous opened document |
3437 | if (!filename.isEmpty()) | 3408 | if (!filename.isEmpty()) |
3438 | saveDocument(filename, FALSE); | 3409 | saveDocument(filename, FALSE); |
3439 | 3410 | ||
3440 | // clear the password list | 3411 | // clear the password list |
3441 | QListViewItem *i; | 3412 | QListViewItem *i; |
3442 | QListViewItem *c = NULL; | 3413 | QListViewItem *c = NULL; |
3443 | // step through all categories | 3414 | // step through all categories |
3444 | for (i = ListView->firstChild(); | 3415 | for (i = ListView->firstChild(); |
3445 | i != NULL; | 3416 | i != NULL; |
3446 | i = i->nextSibling()) | 3417 | i = i->nextSibling()) |
3447 | { | 3418 | { |
3448 | if (c) delete c; // delete the previous category | 3419 | if (c) delete c; // delete the previous category |
3449 | 3420 | ||
3450 | c = i; | 3421 | c = i; |
3451 | // step through all subitems | 3422 | // step through all subitems |
3452 | QListViewItem *si; | 3423 | QListViewItem *si; |
3453 | for (si = i->firstChild(); | 3424 | for (si = i->firstChild(); |
3454 | si != NULL; ) | 3425 | si != NULL; ) |
3455 | { | 3426 | { |
3456 | QListViewItem *_si = si; | 3427 | QListViewItem *_si = si; |
3457 | si = si->nextSibling(); | 3428 | si = si->nextSibling(); |
3458 | i->takeItem(_si); // remove from view list | 3429 | i->takeItem(_si); // remove from view list |
3459 | if (_si) delete _si; | 3430 | if (_si) delete _si; |
3460 | } | 3431 | } |
3461 | } | 3432 | } |
3462 | if (c) delete c; // delete the previous category | 3433 | if (c) delete c; // delete the previous category |
3463 | categories.clear(); | 3434 | categories.clear(); |
3464 | m_password = ""; | 3435 | m_password = ""; |
3465 | selectedItem = NULL; | 3436 | selectedItem = NULL; |
3466 | filename = newFile; | 3437 | filename = newFile; |
3467 | 3438 | ||
3468 | // save the current filename to the config file | 3439 | // save the current filename to the config file |
3469 | conf->writeEntry(APP_KEY+"document", filename); | 3440 | conf->writeEntry(APP_KEY+"document", filename); |
3470 | saveConf(); | 3441 | saveConf(); |
3471 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3442 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3472 | #ifdef WIN32 | 3443 | #ifdef WIN32 |
3473 | this->setCaption("Qt ZSafe: " + ti); | 3444 | this->setCaption("Qt ZSafe: " + ti); |
3474 | #else | 3445 | #else |
3475 | this->setCaption("ZSafe: " + ti); | 3446 | this->setCaption("ZSafe: " + ti); |
3476 | #endif | 3447 | #endif |
3477 | 3448 | ||
3478 | openDocument(filename); | 3449 | openDocument(filename); |
3479 | } | 3450 | } |
3480 | } | 3451 | } |
3481 | 3452 | ||
3482 | void ZSafe::saveDocumentAs() | 3453 | void ZSafe::saveDocumentAs() |
3483 | { | 3454 | { |
3484 | 3455 | ||
3485 | #ifndef DESKTOP | 3456 | #ifndef DESKTOP |
3486 | #ifndef NO_OPIE | 3457 | #ifndef NO_OPIE |
3487 | QMap<QString, QStringList> mimeTypes; | 3458 | QMap<QString, QStringList> mimeTypes; |
3488 | mimeTypes.insert(tr("All"), QStringList() ); | 3459 | mimeTypes.insert(tr("All"), QStringList() ); |
3489 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3460 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3490 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 3461 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
3491 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3462 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3492 | QString::null, | 3463 | QString::null, |
3493 | mimeTypes, | 3464 | mimeTypes, |
3494 | this, | 3465 | this, |
3495 | tr ("Save ZSafe document as..")); | 3466 | tr ("Save ZSafe document as..")); |
3496 | #else | 3467 | #else |
3497 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3468 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3498 | tr ("Save ZSafe document as.."), | 3469 | tr ("Save ZSafe document as.."), |
3499 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3470 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3500 | "*.zsf"); | 3471 | "*.zsf"); |
3501 | #endif | 3472 | #endif |
3502 | #else | 3473 | #else |
3503 | // open the file dialog | 3474 | // open the file dialog |
3504 | QString newFile = QFileDialog::getSaveFileName( | 3475 | QString newFile = QFileDialog::getSaveFileName( |
3505 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3476 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3506 | "ZSafe (*.zsf)", | 3477 | "ZSafe (*.zsf)", |
3507 | this, | 3478 | this, |
3508 | "ZSafe File Dialog" | 3479 | "ZSafe File Dialog" |
3509 | "Choose a ZSafe file" ); | 3480 | "Choose a ZSafe file" ); |
3510 | #endif | 3481 | #endif |
3511 | 3482 | ||
3512 | // open the new document | 3483 | // open the new document |
3513 | if (newFile && newFile.length() > 0 ) | 3484 | if (newFile && newFile.length() > 0 ) |
3514 | { | 3485 | { |
3515 | // save the previous opened document | 3486 | // save the previous opened document |
3516 | if (!filename.isEmpty()) | 3487 | if (!filename.isEmpty()) |
3517 | saveDocument(filename, FALSE); | 3488 | saveDocument(filename, FALSE); |
3518 | 3489 | ||
3519 | selectedItem = NULL; | 3490 | selectedItem = NULL; |
3520 | filename = newFile; | 3491 | filename = newFile; |
3521 | 3492 | ||
3522 | // save the current filename to the config file | 3493 | // save the current filename to the config file |
3523 | conf->writeEntry(APP_KEY+"document", filename); | 3494 | conf->writeEntry(APP_KEY+"document", filename); |
3524 | saveConf(); | 3495 | saveConf(); |
3525 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3496 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3526 | #ifdef WIN32 | 3497 | #ifdef WIN32 |
3527 | this->setCaption("Qt ZSafe: " + ti); | 3498 | this->setCaption("Qt ZSafe: " + ti); |
3528 | #else | 3499 | #else |
3529 | this->setCaption("ZSafe: " + ti); | 3500 | this->setCaption("ZSafe: " + ti); |
3530 | #endif | 3501 | #endif |
3531 | 3502 | ||
3532 | QMessageBox::information( this, tr("ZSafe"), | 3503 | QMessageBox::information( this, tr("ZSafe"), |
3533 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3504 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3534 | 3505 | ||
3535 | saveDocumentWithPwd(); | 3506 | saveDocumentWithPwd(); |
3536 | } | 3507 | } |
3537 | } | 3508 | } |
3538 | 3509 | ||
3539 | void ZSafe::saveDocumentWithoutPwd() | 3510 | void ZSafe::saveDocumentWithoutPwd() |
3540 | { | 3511 | { |
3541 | saveDocument(filename, FALSE); | 3512 | saveDocument(filename, FALSE); |
3542 | } | 3513 | } |
3543 | 3514 | ||
3544 | void ZSafe::saveDocumentWithPwd() | 3515 | void ZSafe::saveDocumentWithPwd() |
3545 | { | 3516 | { |
3546 | saveDocument(filename, TRUE); | 3517 | saveDocument(filename, TRUE); |
3547 | } | 3518 | } |
3548 | 3519 | ||
3549 | void ZSafe::about() | 3520 | void ZSafe::about() |
3550 | { | 3521 | { |
3551 | QString info; | 3522 | QString info; |
3552 | #ifdef JPATCH_HDE | 3523 | #ifdef JPATCH_HDE |
3553 | info = "<html><body><div align=""center"">"; | 3524 | info = "<html><body><div align=""center"">"; |
3554 | info += "<b>"; | 3525 | info += "<b>"; |
3555 | info += tr("Zaurus Password Manager<br>"); | 3526 | info += tr("Zaurus Password Manager<br>"); |
3556 | info += tr("ZSafe version 2.1.2-jv01b<br>"); | 3527 | info += tr("ZSafe version 2.1.2-jv01b<br>"); |
3557 | info += "</b>"; | 3528 | info += "</b>"; |
3558 | info += tr("by Carsten Schneider<br>"); | 3529 | info += tr("by Carsten Schneider<br>"); |
3559 | info += "zcarsten@gmx.net<br>"; | 3530 | info += "zcarsten@gmx.net<br>"; |
3560 | info += "http://z-soft.z-portal.info/zsafe"; | 3531 | info += "http://z-soft.z-portal.info/zsafe"; |
3561 | info += "<br>"; | 3532 | info += "<br>"; |
3562 | info += tr("Translations by Robert Ernst<br>"); | 3533 | info += tr("Translations by Robert Ernst<br>"); |
3563 | info += "robert.ernst@linux-solutions.at<br>"; | 3534 | info += "robert.ernst@linux-solutions.at<br>"; |
3564 | 3535 | ||
3565 | info += "<br><br>"; | 3536 | info += "<br><br>"; |
3566 | info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>"); | 3537 | info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>"); |
3567 | info += "HADECO R&D<br>"; | 3538 | info += "HADECO R&D<br>"; |
3568 | info += "r&d@hadeco.co.jp<br>"; | 3539 | info += "r&d@hadeco.co.jp<br>"; |
3569 | info += "http://www.hadeco.co.jp/r&d/<br>"; | 3540 | info += "http://www.hadeco.co.jp/r&d/<br>"; |
3570 | info += "<br></div>"; | 3541 | info += "<br></div>"; |
3571 | info += "</body></html>"; | 3542 | info += "</body></html>"; |
3572 | #else | 3543 | #else |
3573 | info = "<html><body><div align=""center"">"; | 3544 | info = "<html><body><div align=""center"">"; |
3574 | info += "<b>"; | 3545 | info += "<b>"; |