author | drw <drw> | 2004-02-23 17:12:28 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-23 17:12:28 (UTC) |
commit | 2f11aa15eeb70dd8826523597adb8947fdffbaa7 (patch) (unidiff) | |
tree | acc6ceb27c67437734e94b39b06835edac5d5bad | |
parent | 20b0e62e6c23cdaed9a30d6fad73431edc60be53 (diff) | |
download | opie-2f11aa15eeb70dd8826523597adb8947fdffbaa7.zip opie-2f11aa15eeb70dd8826523597adb8947fdffbaa7.tar.gz opie-2f11aa15eeb70dd8826523597adb8947fdffbaa7.tar.bz2 |
ZSafe: libopie->libopie2
-rw-r--r-- | noncore/apps/zsafe/config.in | 2 | ||||
-rw-r--r-- | noncore/apps/zsafe/opie-zsafe.control | 2 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 989 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.pro | 16 |
4 files changed, 506 insertions, 503 deletions
diff --git a/noncore/apps/zsafe/config.in b/noncore/apps/zsafe/config.in index 4b1e968..6e321f3 100644 --- a/noncore/apps/zsafe/config.in +++ b/noncore/apps/zsafe/config.in | |||
@@ -1,5 +1,5 @@ | |||
1 | config ZSAFE | 1 | config ZSAFE |
2 | boolean "zsafe (Zaurus Password Manager)" | 2 | boolean "zsafe (Zaurus Password Manager)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI |
5 | 5 | ||
diff --git a/noncore/apps/zsafe/opie-zsafe.control b/noncore/apps/zsafe/opie-zsafe.control index b58a987..6288fac 100644 --- a/noncore/apps/zsafe/opie-zsafe.control +++ b/noncore/apps/zsafe/opie-zsafe.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-zsafe | 1 | Package: opie-zsafe |
2 | Files: bin/zsafe apps/Applications/zsafe.desktop pics/zsafe/*.png | 2 | Files: bin/zsafe apps/Applications/zsafe.desktop pics/zsafe/*.png |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Version: $QPE_VERSION$EXTRAVERSION | 5 | Version: $QPE_VERSION$EXTRAVERSION |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal, libopieui2 |
8 | Maintainer: Carsten Schneider <zcarsten@gmx.net> | 8 | Maintainer: Carsten Schneider <zcarsten@gmx.net> |
9 | Description: This is a password manager program for Opie. | 9 | Description: This is a password manager program for Opie. |
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index bdd2aed..f43a206 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -15,33 +15,36 @@ | |||
15 | ** Windows Desktop: -DDESKTOP -DWIN32 | 15 | ** Windows Desktop: -DDESKTOP -DWIN32 |
16 | ** | 16 | ** |
17 | ** for japanese version additional use: -DJPATCH_HDE | 17 | ** for japanese version additional use: -DJPATCH_HDE |
18 | ** | 18 | ** |
19 | ****************************************************************************/ | 19 | ****************************************************************************/ |
20 | #include "zsafe.h" | 20 | #include "zsafe.h" |
21 | #include "newdialog.h" | 21 | #include "newdialog.h" |
22 | #include "searchdialog.h" | 22 | #include "searchdialog.h" |
23 | #include "categorydialog.h" | 23 | #include "categorydialog.h" |
24 | #include "passworddialog.h" | 24 | #include "passworddialog.h" |
25 | #include "infoform.h" | 25 | #include "infoform.h" |
26 | #include "zlistview.h" | 26 | #include "zlistview.h" |
27 | #include "shadedlistitem.h" | 27 | #include "shadedlistitem.h" |
28 | 28 | ||
29 | #ifndef DESKTOP | 29 | #ifndef DESKTOP |
30 | #ifndef NO_OPIE | 30 | #ifndef NO_OPIE |
31 | #include <opie/ofiledialog.h> | 31 | #include <opie2/ofiledialog.h> |
32 | |||
33 | using Opie::OFileDialog; | ||
34 | using Opie::OFileSelector; | ||
32 | #else | 35 | #else |
33 | #include "scqtfileedit.h" | 36 | #include "scqtfileedit.h" |
34 | #endif | 37 | #endif |
35 | #endif | 38 | #endif |
36 | 39 | ||
37 | #include <qclipboard.h> | 40 | #include <qclipboard.h> |
38 | 41 | ||
39 | #include <stdio.h> | 42 | #include <stdio.h> |
40 | 43 | ||
41 | #include <sys/types.h> | 44 | #include <sys/types.h> |
42 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
43 | #include <fcntl.h> | 46 | #include <fcntl.h> |
44 | #include <stdlib.h> | 47 | #include <stdlib.h> |
45 | #ifndef WIN32 | 48 | #ifndef WIN32 |
46 | #include <unistd.h> | 49 | #include <unistd.h> |
47 | #endif | 50 | #endif |
@@ -121,33 +124,33 @@ const QString APP_KEY=""; | |||
121 | #include "pics/zsafe/cut.xpm" | 124 | #include "pics/zsafe/cut.xpm" |
122 | #include "pics/zsafe/edit.xpm" | 125 | #include "pics/zsafe/edit.xpm" |
123 | #include "pics/zsafe/editdelete.xpm" | 126 | #include "pics/zsafe/editdelete.xpm" |
124 | #include "pics/zsafe/find.xpm" | 127 | #include "pics/zsafe/find.xpm" |
125 | #include "pics/zsafe/folder_open.xpm" | 128 | #include "pics/zsafe/folder_open.xpm" |
126 | #include "pics/zsafe/help_icon.xpm" | 129 | #include "pics/zsafe/help_icon.xpm" |
127 | #include "pics/zsafe/new.xpm" | 130 | #include "pics/zsafe/new.xpm" |
128 | #include "pics/zsafe/paste.xpm" | 131 | #include "pics/zsafe/paste.xpm" |
129 | #include "pics/zsafe/quit_icon.xpm" | 132 | #include "pics/zsafe/quit_icon.xpm" |
130 | #include "pics/zsafe/save.xpm" | 133 | #include "pics/zsafe/save.xpm" |
131 | #include "pics/zsafe/trash.xpm" | 134 | #include "pics/zsafe/trash.xpm" |
132 | #include "pics/zsafe/expand.xpm" | 135 | #include "pics/zsafe/expand.xpm" |
133 | #include "pics/zsafe/export.xpm" | 136 | #include "pics/zsafe/export.xpm" |
134 | #include "pics/zsafe/import.xpm" | 137 | #include "pics/zsafe/import.xpm" |
135 | #include "pics/zsafe/zsafe.xpm" | 138 | #include "pics/zsafe/zsafe.xpm" |
136 | 139 | ||
137 | static const char* const bank_cards_data[] = { | 140 | static const char* const bank_cards_data[] = { |
138 | "14 14 16 1", | 141 | "14 14 16 1", |
139 | ". c None", | 142 | ". c None", |
140 | "# c #000000", | 143 | "# c #000000", |
141 | "b c #0000de", | 144 | "b c #0000de", |
142 | "a c #0000e6", | 145 | "a c #0000e6", |
143 | "j c #41de83", | 146 | "j c #41de83", |
144 | "k c #4acecd", | 147 | "k c #4acecd", |
145 | "h c #4aced5", | 148 | "h c #4aced5", |
146 | "g c #5a40cd", | 149 | "g c #5a40cd", |
147 | "d c #5a44d5", | 150 | "d c #5a44d5", |
148 | "l c #9440d5", | 151 | "l c #9440d5", |
149 | "m c #b4ce4a", | 152 | "m c #b4ce4a", |
150 | "n c #cd4883", | 153 | "n c #cd4883", |
151 | "e c #d5ae10", | 154 | "e c #d5ae10", |
152 | "f c #de3ce6", | 155 | "f c #de3ce6", |
153 | "i c #e640e6", | 156 | "i c #e640e6", |
@@ -155,33 +158,33 @@ static const char* const bank_cards_data[] = { | |||
155 | "..............", | 158 | "..............", |
156 | ".###########..", | 159 | ".###########..", |
157 | ".#ababababa#..", | 160 | ".#ababababa#..", |
158 | ".#babbbabbb#..", | 161 | ".#babbbabbb#..", |
159 | ".#ccccccccc#..", | 162 | ".#ccccccccc#..", |
160 | ".#cdcefcghc#..", | 163 | ".#cdcefcghc#..", |
161 | ".#ccccccccc#..", | 164 | ".#ccccccccc#..", |
162 | ".#cicjkclic#..", | 165 | ".#cicjkclic#..", |
163 | ".#ccccccccc#..", | 166 | ".#ccccccccc#..", |
164 | ".#cmchlcnec#..", | 167 | ".#cmchlcnec#..", |
165 | ".#ccccccccc#..", | 168 | ".#ccccccccc#..", |
166 | ".###########..", | 169 | ".###########..", |
167 | "..............", | 170 | "..............", |
168 | ".............."}; | 171 | ".............."}; |
169 | 172 | ||
170 | 173 | ||
171 | static const char* const passwords_data[] = { | 174 | static const char* const passwords_data[] = { |
172 | "16 16 20 1", | 175 | "16 16 20 1", |
173 | ". c None", | 176 | ". c None", |
174 | "# c #000000", | 177 | "# c #000000", |
175 | "r c #000083", | 178 | "r c #000083", |
176 | "p c #0000c5", | 179 | "p c #0000c5", |
177 | "q c #0000ff", | 180 | "q c #0000ff", |
178 | "n c #008100", | 181 | "n c #008100", |
179 | "l c #00c200", | 182 | "l c #00c200", |
180 | "m c #00ff00", | 183 | "m c #00ff00", |
181 | "j c #838100", | 184 | "j c #838100", |
182 | "a c #c55900", | 185 | "a c #c55900", |
183 | "h c #c5c200", | 186 | "h c #c5c200", |
184 | "o c #c5c2ff", | 187 | "o c #c5c2ff", |
185 | "k c #c5ffc5", | 188 | "k c #c5ffc5", |
186 | "f c #ff0000", | 189 | "f c #ff0000", |
187 | "d c #ff8100", | 190 | "d c #ff8100", |
@@ -194,57 +197,57 @@ static const char* const passwords_data[] = { | |||
194 | "...........#abb#", | 197 | "...........#abb#", |
195 | "..........#cbab#", | 198 | "..........#cbab#", |
196 | ".........#cbdd#.", | 199 | ".........#cbdd#.", |
197 | "######..#cbdd#..", | 200 | "######..#cbdd#..", |
198 | "#eeff#..#add#...", | 201 | "#eeff#..#add#...", |
199 | "#eeff#######....", | 202 | "#eeff#######....", |
200 | "#ccdbdd#........", | 203 | "#ccdbdd#........", |
201 | "#dddbdd###......", | 204 | "#dddbdd###......", |
202 | "#gghihhjj#......", | 205 | "#gghihhjj#......", |
203 | "#hhhihhjj###....", | 206 | "#hhhihhjj###....", |
204 | "#kklmllnnnn#....", | 207 | "#kklmllnnnn#....", |
205 | "#lllmllnnnn#....", | 208 | "#lllmllnnnn#....", |
206 | "#oopqpprprr#....", | 209 | "#oopqpprprr#....", |
207 | "#oopqpprprr#....", | 210 | "#oopqpprprr#....", |
208 | "############...."}; | 211 | "############...."}; |
209 | 212 | ||
210 | static const char* const software_data[] = { | 213 | static const char* const software_data[] = { |
211 | "16 16 5 1", | 214 | "16 16 5 1", |
212 | ". c None", | 215 | ". c None", |
213 | "# c #000000", | 216 | "# c #000000", |
214 | "b c #838183", | 217 | "b c #838183", |
215 | "c c #c5ffff", | 218 | "c c #c5ffff", |
216 | "a c #ffffff", | 219 | "a c #ffffff", |
217 | "................", | 220 | "................", |
218 | ".##############.", | 221 | ".##############.", |
219 | "#aaaaaaaaaaaaaa#", | 222 | "#aaaaaaaaaaaaaa#", |
220 | "#abbbbbbbbbbbbb#", | 223 | "#abbbbbbbbbbbbb#", |
221 | "#ab##########ab#", | 224 | "#ab##########ab#", |
222 | "#ab#c########ab#", | 225 | "#ab#c########ab#", |
223 | "#ab#c#c######ab#", | 226 | "#ab#c#c######ab#", |
224 | "#ab##########ab#", | 227 | "#ab##########ab#", |
225 | "#ab##########ab#", | 228 | "#ab##########ab#", |
226 | "#ab##########ab#", | 229 | "#ab##########ab#", |
227 | "#ab##########ab#", | 230 | "#ab##########ab#", |
228 | "#ab##########ab#", | 231 | "#ab##########ab#", |
229 | "#aaaaaaaaaaaaab#", | 232 | "#aaaaaaaaaaaaab#", |
230 | "#bbbbbbbbbbbbbb#", | 233 | "#bbbbbbbbbbbbbb#", |
231 | ".##############.", | 234 | ".##############.", |
232 | "................"}; | 235 | "................"}; |
233 | 236 | ||
234 | static const char* const general_data[] = { | 237 | static const char* const general_data[] = { |
235 | "14 14 98 2", | 238 | "14 14 98 2", |
236 | "Qt c None", | 239 | "Qt c None", |
237 | ".k c #000000", | 240 | ".k c #000000", |
238 | "#x c #080808", | 241 | "#x c #080808", |
239 | "#F c #101008", | 242 | "#F c #101008", |
240 | "#q c #101010", | 243 | "#q c #101010", |
241 | "#i c #101410", | 244 | "#i c #101410", |
242 | "## c #101810", | 245 | "## c #101810", |
243 | ".m c #181818", | 246 | ".m c #181818", |
244 | ".3 c #181c18", | 247 | ".3 c #181c18", |
245 | ".I c #182018", | 248 | ".I c #182018", |
246 | ".T c #202420", | 249 | ".T c #202420", |
247 | "#D c #202820", | 250 | "#D c #202820", |
248 | "#y c #292c29", | 251 | "#y c #292c29", |
249 | ".c c #293029", | 252 | ".c c #293029", |
250 | ".d c #313031", | 253 | ".d c #313031", |
@@ -366,63 +369,63 @@ static const char* const general_data[] = { | |||
366 | #ifdef DESKTOP | 369 | #ifdef DESKTOP |
367 | #ifndef WIN32 | 370 | #ifndef WIN32 |
368 | conf = new QSettings (); | 371 | conf = new QSettings (); |
369 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 372 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
370 | #else | 373 | #else |
371 | conf = new QSettings (cfgFile); | 374 | conf = new QSettings (cfgFile); |
372 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 375 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
373 | #endif | 376 | #endif |
374 | #else | 377 | #else |
375 | conf = new Config (cfgFile, Config::File); | 378 | conf = new Config (cfgFile, Config::File); |
376 | conf->setGroup ("zsafe"); | 379 | conf->setGroup ("zsafe"); |
377 | #endif | 380 | #endif |
378 | } | 381 | } |
379 | } | 382 | } |
380 | 383 | ||
381 | 384 | ||
382 | /* | 385 | /* |
383 | * Constructs a ZSafe which is a child of 'parent', with the | 386 | * Constructs a ZSafe which is a child of 'parent', with the |
384 | * name 'name' and widget flags set to 'f' | 387 | * name 'name' and widget flags set to 'f' |
385 | * | 388 | * |
386 | * The dialog will by default be modeless, unless you set 'modal' to | 389 | * The dialog will by default be modeless, unless you set 'modal' to |
387 | * TRUE to construct a modal dialog. | 390 | * TRUE to construct a modal dialog. |
388 | */ | 391 | */ |
389 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | 392 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) |
390 | : QDialog( parent, name, modal, fl ), | 393 | : QDialog( parent, name, modal, fl ), |
391 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) | 394 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) |
392 | { | 395 | { |
393 | IsCut = false; | 396 | IsCut = false; |
394 | IsCopy = false; | 397 | IsCopy = false; |
395 | modified = false; | 398 | modified = false; |
396 | 399 | ||
397 | // set the config file | 400 | // set the config file |
398 | cfgFile=QDir::homeDirPath(); | 401 | cfgFile=QDir::homeDirPath(); |
399 | cfgFile += "/.zsafe.cfg"; | 402 | cfgFile += "/.zsafe.cfg"; |
400 | // set the icon path | 403 | // set the icon path |
401 | #ifdef NO_OPIE | 404 | #ifdef NO_OPIE |
402 | QString qpedir ((const char *)getenv("QPEDIR")); | 405 | QString qpedir ((const char *)getenv("QPEDIR")); |
403 | #else | 406 | #else |
404 | QString qpedir ((const char *)getenv("OPIEDIR")); | 407 | QString qpedir ((const char *)getenv("OPIEDIR")); |
405 | #endif | 408 | #endif |
406 | 409 | ||
407 | #ifdef DESKTOP | 410 | #ifdef DESKTOP |
408 | iconPath = QDir::homeDirPath() + "/pics/"; | 411 | iconPath = QDir::homeDirPath() + "/pics/"; |
409 | #else | 412 | #else |
410 | if (qpedir.isEmpty()) | 413 | if (qpedir.isEmpty()) |
411 | iconPath = "/home/QtPalmtop/pics/"; | 414 | iconPath = "/home/QtPalmtop/pics/"; |
412 | else | 415 | else |
413 | iconPath = qpedir + "/pics/"; | 416 | iconPath = qpedir + "/pics/"; |
414 | #endif | 417 | #endif |
415 | 418 | ||
416 | // create a zsafe configuration object | 419 | // create a zsafe configuration object |
417 | #ifdef DESKTOP | 420 | #ifdef DESKTOP |
418 | #ifndef WIN32 | 421 | #ifndef WIN32 |
419 | conf = new QSettings (); | 422 | conf = new QSettings (); |
420 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 423 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
421 | #else | 424 | #else |
422 | conf = new QSettings (cfgFile); | 425 | conf = new QSettings (cfgFile); |
423 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 426 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
424 | #endif | 427 | #endif |
425 | #else | 428 | #else |
426 | conf = new Config (cfgFile, Config::File); | 429 | conf = new Config (cfgFile, Config::File); |
427 | conf->setGroup ("zsafePrefs"); | 430 | conf->setGroup ("zsafePrefs"); |
428 | #endif | 431 | #endif |
@@ -445,39 +448,39 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
445 | QPixmap folder_open_img((const char**) folder_open_xpm); | 448 | QPixmap folder_open_img((const char**) folder_open_xpm); |
446 | QPixmap help_icon_img((const char**) help_icon_xpm); | 449 | QPixmap help_icon_img((const char**) help_icon_xpm); |
447 | QPixmap new_img((const char**) new_xpm); | 450 | QPixmap new_img((const char**) new_xpm); |
448 | QPixmap paste_img((const char**) paste_xpm); | 451 | QPixmap paste_img((const char**) paste_xpm); |
449 | QPixmap quit_icon_img((const char**) quit_icon_xpm); | 452 | QPixmap quit_icon_img((const char**) quit_icon_xpm); |
450 | QPixmap save_img((const char**) save_xpm); | 453 | QPixmap save_img((const char**) save_xpm); |
451 | QPixmap trash_img((const char**) trash_xpm); | 454 | QPixmap trash_img((const char**) trash_xpm); |
452 | QPixmap expand_img((const char**) expand_xpm); | 455 | QPixmap expand_img((const char**) expand_xpm); |
453 | QPixmap export_img((const char**) export_xpm); | 456 | QPixmap export_img((const char**) export_xpm); |
454 | QPixmap import_img((const char**) import_xpm); | 457 | QPixmap import_img((const char**) import_xpm); |
455 | 458 | ||
456 | QPixmap bank_cards( ( const char** ) bank_cards_data ); | 459 | QPixmap bank_cards( ( const char** ) bank_cards_data ); |
457 | QPixmap passwords( ( const char** ) passwords_data ); | 460 | QPixmap passwords( ( const char** ) passwords_data ); |
458 | QPixmap software( ( const char** ) software_data ); | 461 | QPixmap software( ( const char** ) software_data ); |
459 | QPixmap general( ( const char** ) general_data ); | 462 | QPixmap general( ( const char** ) general_data ); |
460 | if ( !name ) | 463 | if ( !name ) |
461 | setName( "ZSafe" ); | 464 | setName( "ZSafe" ); |
462 | 465 | ||
463 | #ifdef DESKTOP | 466 | #ifdef DESKTOP |
464 | #ifdef WIN32 | 467 | #ifdef WIN32 |
465 | setGeometry(100, 150, DeskW, DeskH-30 ); | 468 | setGeometry(100, 150, DeskW, DeskH-30 ); |
466 | #else | 469 | #else |
467 | resize( DeskW, DeskH-30 ); | 470 | resize( DeskW, DeskH-30 ); |
468 | #endif | 471 | #endif |
469 | 472 | ||
470 | #else | 473 | #else |
471 | 474 | ||
472 | #ifdef JPATCH_HDE | 475 | #ifdef JPATCH_HDE |
473 | int DeskS; | 476 | int DeskS; |
474 | if(DeskW > DeskH) | 477 | if(DeskW > DeskH) |
475 | { | 478 | { |
476 | DeskS = DeskW; | 479 | DeskS = DeskW; |
477 | } | 480 | } |
478 | else | 481 | else |
479 | { | 482 | { |
480 | DeskS = DeskH; | 483 | DeskS = DeskH; |
481 | } | 484 | } |
482 | resize( DeskW, DeskH ); | 485 | resize( DeskW, DeskH ); |
483 | setMinimumSize( QSize( DeskS, DeskS ) ); | 486 | setMinimumSize( QSize( DeskS, DeskS ) ); |
@@ -485,66 +488,66 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
485 | #else | 488 | #else |
486 | resize( DeskW, DeskH-30 ); | 489 | resize( DeskW, DeskH-30 ); |
487 | #endif | 490 | #endif |
488 | 491 | ||
489 | #endif | 492 | #endif |
490 | // setCaption( tr( "ZSafe" ) ); | 493 | // setCaption( tr( "ZSafe" ) ); |
491 | 494 | ||
492 | filename = conf->readEntry(APP_KEY+"document"); | 495 | filename = conf->readEntry(APP_KEY+"document"); |
493 | if (filename.isEmpty() || filename.isNull()) | 496 | if (filename.isEmpty() || filename.isNull()) |
494 | { | 497 | { |
495 | 498 | ||
496 | // check if the directory application exists, if not | 499 | // check if the directory application exists, if not |
497 | // create it | 500 | // create it |
498 | // #ifndef WIN32 | 501 | // #ifndef WIN32 |
499 | // QString d1("Documents/application"); | 502 | // QString d1("Documents/application"); |
500 | // #else | 503 | // #else |
501 | QString d1(QDir::homeDirPath() + "/Documents/application"); | 504 | QString d1(QDir::homeDirPath() + "/Documents/application"); |
502 | // #endif | 505 | // #endif |
503 | QDir pd1(d1); | 506 | QDir pd1(d1); |
504 | if (!pd1.exists()) | 507 | if (!pd1.exists()) |
505 | { | 508 | { |
506 | QDir pd1("Documents"); | 509 | QDir pd1("Documents"); |
507 | if (!pd1.mkdir("application", FALSE)) | 510 | if (!pd1.mkdir("application", FALSE)) |
508 | { | 511 | { |
509 | QMessageBox::critical( 0, tr("ZSafe"), | 512 | QMessageBox::critical( 0, tr("ZSafe"), |
510 | #ifdef JPATCH_HDE | 513 | #ifdef JPATCH_HDE |
511 | tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit.")); | 514 | tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit.")); |
512 | #else | 515 | #else |
513 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1)); | 516 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1)); |
514 | #endif | 517 | #endif |
515 | exitZs (1); | 518 | exitZs (1); |
516 | } | 519 | } |
517 | } | 520 | } |
518 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); | 521 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); |
519 | QDir pd2(d2); | 522 | QDir pd2(d2); |
520 | if (!pd2.exists()) | 523 | if (!pd2.exists()) |
521 | { | 524 | { |
522 | QDir pd2(QDir::homeDirPath() + "Documents/application"); | 525 | QDir pd2(QDir::homeDirPath() + "Documents/application"); |
523 | if (!pd2.mkdir("zsafe", FALSE)) | 526 | if (!pd2.mkdir("zsafe", FALSE)) |
524 | { | 527 | { |
525 | QMessageBox::critical( 0, tr("ZSafe"), | 528 | QMessageBox::critical( 0, tr("ZSafe"), |
526 | #ifdef JPATCH_HDE | 529 | #ifdef JPATCH_HDE |
527 | tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit.")); | 530 | tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit.")); |
528 | #else | 531 | #else |
529 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2)); | 532 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2)); |
530 | #endif | 533 | #endif |
531 | exitZs (1); | 534 | exitZs (1); |
532 | } | 535 | } |
533 | } | 536 | } |
534 | 537 | ||
535 | 538 | ||
536 | // set the default filename | 539 | // set the default filename |
537 | filename=d2 + "/passwords.zsf"; | 540 | filename=d2 + "/passwords.zsf"; |
538 | 541 | ||
539 | // save the current filename to the config file | 542 | // save the current filename to the config file |
540 | conf->writeEntry(APP_KEY+"document", filename); | 543 | conf->writeEntry(APP_KEY+"document", filename); |
541 | saveConf(); | 544 | saveConf(); |
542 | } | 545 | } |
543 | 546 | ||
544 | //if (filename == "INVALIDPWD") | 547 | //if (filename == "INVALIDPWD") |
545 | //filename = ""; | 548 | //filename = ""; |
546 | 549 | ||
547 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 550 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
548 | #ifdef WIN32 | 551 | #ifdef WIN32 |
549 | this->setCaption("Qt ZSafe: " + ti); | 552 | this->setCaption("Qt ZSafe: " + ti); |
550 | #else | 553 | #else |
@@ -563,119 +566,119 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
563 | 566 | ||
564 | // add a menu bar | 567 | // add a menu bar |
565 | QMenuBar *menu = new QMenuBar( this ); | 568 | QMenuBar *menu = new QMenuBar( this ); |
566 | 569 | ||
567 | // add file menu | 570 | // add file menu |
568 | // QPopupMenu *file = new QPopupMenu( this ); | 571 | // QPopupMenu *file = new QPopupMenu( this ); |
569 | file = new QPopupMenu( this ); | 572 | file = new QPopupMenu( this ); |
570 | 573 | ||
571 | // #ifdef DESKTOP | 574 | // #ifdef DESKTOP |
572 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); | 575 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); |
573 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); | 576 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); |
574 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); | 577 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); |
575 | file->insertSeparator(); | 578 | file->insertSeparator(); |
576 | // #endif | 579 | // #endif |
577 | 580 | ||
578 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); | 581 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); |
579 | file->insertItem( save_img, tr("S&ave document with new Password"), this, | 582 | file->insertItem( save_img, tr("S&ave document with new Password"), this, |
580 | SLOT(saveDocumentWithPwd()) ); | 583 | SLOT(saveDocumentWithPwd()) ); |
581 | file->insertSeparator(); | 584 | file->insertSeparator(); |
582 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); | 585 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); |
583 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); | 586 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); |
584 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); | 587 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); |
585 | file->insertSeparator(); | 588 | file->insertSeparator(); |
586 | file->insertItem( expand_img, tr("&Open entries expanded"), this, | 589 | file->insertItem( expand_img, tr("&Open entries expanded"), this, |
587 | SLOT(setExpandFlag()), 0, 'o'); | 590 | SLOT(setExpandFlag()), 0, 'o'); |
588 | file->setItemChecked('o', expandTree); | 591 | file->setItemChecked('o', expandTree); |
589 | file->insertSeparator(); | 592 | file->insertSeparator(); |
590 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); | 593 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); |
591 | menu->insertItem( tr("&File"), file ); | 594 | menu->insertItem( tr("&File"), file ); |
592 | 595 | ||
593 | QPopupMenu *cat = new QPopupMenu( this ); | 596 | QPopupMenu *cat = new QPopupMenu( this ); |
594 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); | 597 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); |
595 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); | 598 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); |
596 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); | 599 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); |
597 | menu->insertItem( tr("&Category"), cat ); | 600 | menu->insertItem( tr("&Category"), cat ); |
598 | 601 | ||
599 | QPopupMenu *it = new QPopupMenu( this ); | 602 | QPopupMenu *it = new QPopupMenu( this ); |
600 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); | 603 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); |
601 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); | 604 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); |
602 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); | 605 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); |
603 | it->insertSeparator(); | 606 | it->insertSeparator(); |
604 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); | 607 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); |
605 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); | 608 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); |
606 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); | 609 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); |
607 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); | 610 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); |
608 | menu->insertItem( tr("&Entry"), it ); | 611 | menu->insertItem( tr("&Entry"), it ); |
609 | 612 | ||
610 | QPopupMenu *help = new QPopupMenu( this ); | 613 | QPopupMenu *help = new QPopupMenu( this ); |
611 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); | 614 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); |
612 | menu->insertItem( tr("&Help"), help ); | 615 | menu->insertItem( tr("&Help"), help ); |
613 | 616 | ||
614 | // toolbar icons | 617 | // toolbar icons |
615 | 618 | ||
616 | New = new QToolButton( menu, "New" ); | 619 | New = new QToolButton( menu, "New" ); |
617 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); | 620 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); |
618 | New->setMouseTracking( TRUE ); | 621 | New->setMouseTracking( TRUE ); |
619 | New->setText( tr( "" ) ); | 622 | New->setText( tr( "" ) ); |
620 | New->setPixmap( new_img ); | 623 | New->setPixmap( new_img ); |
621 | QToolTip::add( New, tr( "New entry" ) ); | 624 | QToolTip::add( New, tr( "New entry" ) ); |
622 | 625 | ||
623 | Edit = new QToolButton( menu, "Edit" ); | 626 | Edit = new QToolButton( menu, "Edit" ); |
624 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); | 627 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); |
625 | Edit->setText( tr( "" ) ); | 628 | Edit->setText( tr( "" ) ); |
626 | Edit->setPixmap( edit_img ); | 629 | Edit->setPixmap( edit_img ); |
627 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); | 630 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); |
628 | 631 | ||
629 | Delete = new QToolButton( menu, "Delete" ); | 632 | Delete = new QToolButton( menu, "Delete" ); |
630 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 633 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
631 | Delete->setText( tr( "" ) ); | 634 | Delete->setText( tr( "" ) ); |
632 | Delete->setPixmap( trash_img ); | 635 | Delete->setPixmap( trash_img ); |
633 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); | 636 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); |
634 | 637 | ||
635 | Find = new QToolButton( menu, "Find" ); | 638 | Find = new QToolButton( menu, "Find" ); |
636 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); | 639 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); |
637 | Find->setText( tr( "" ) ); | 640 | Find->setText( tr( "" ) ); |
638 | Find->setPixmap( find_img ); | 641 | Find->setPixmap( find_img ); |
639 | QToolTip::add( Find, tr( "Find entry" ) ); | 642 | QToolTip::add( Find, tr( "Find entry" ) ); |
640 | 643 | ||
641 | /* | 644 | /* |
642 | QBoxLayout * h = new QHBoxLayout( this ); | 645 | QBoxLayout * h = new QHBoxLayout( this ); |
643 | h->addWidget (menu); | 646 | h->addWidget (menu); |
644 | h->addWidget (New); | 647 | h->addWidget (New); |
645 | h->addWidget (Edit); | 648 | h->addWidget (Edit); |
646 | h->addWidget (Delete); | 649 | h->addWidget (Delete); |
647 | h->addWidget (Find); | 650 | h->addWidget (Find); |
648 | */ | 651 | */ |
649 | 652 | ||
650 | ListView = new ZListView( this, "ListView" ); | 653 | ListView = new ZListView( this, "ListView" ); |
651 | ListView->addColumn( tr( "Name" ) ); | 654 | ListView->addColumn( tr( "Name" ) ); |
652 | ListView->addColumn( tr( "Field 2" ) ); | 655 | ListView->addColumn( tr( "Field 2" ) ); |
653 | ListView->addColumn( tr( "Field 3" ) ); | 656 | ListView->addColumn( tr( "Field 3" ) ); |
654 | ListView->addColumn( tr( "Comment" ) ); | 657 | ListView->addColumn( tr( "Comment" ) ); |
655 | ListView->addColumn( tr( "Field 4" ) ); | 658 | ListView->addColumn( tr( "Field 4" ) ); |
656 | ListView->addColumn( tr( "Field 5" ) ); | 659 | ListView->addColumn( tr( "Field 5" ) ); |
657 | ListView->setAllColumnsShowFocus(TRUE); | 660 | ListView->setAllColumnsShowFocus(TRUE); |
658 | 661 | ||
659 | #ifdef DESKTOP | 662 | #ifdef DESKTOP |
660 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 663 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
661 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); | 664 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); |
662 | #else | 665 | #else |
663 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 666 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
664 | // ListView->setGeometry( QRect( 0, 22, | 667 | // ListView->setGeometry( QRect( 0, 22, |
665 | // this->width(), this->height() - 30 ) ); | 668 | // this->width(), this->height() - 30 ) ); |
666 | // ListView->setMaximumSize( QSize( 440, 290 ) ); | 669 | // ListView->setMaximumSize( QSize( 440, 290 ) ); |
667 | #endif | 670 | #endif |
668 | ListView->setVScrollBarMode( QListView::Auto ); | 671 | ListView->setVScrollBarMode( QListView::Auto ); |
669 | 672 | ||
670 | QBoxLayout * l = new QVBoxLayout( this ); | 673 | QBoxLayout * l = new QVBoxLayout( this ); |
671 | l->addWidget (menu); | 674 | l->addWidget (menu); |
672 | l->addWidget (ListView); | 675 | l->addWidget (ListView); |
673 | 676 | ||
674 | #ifndef DESKTOP | 677 | #ifndef DESKTOP |
675 | // start a timer (100 ms) to load the default document | 678 | // start a timer (100 ms) to load the default document |
676 | docuTimer.start( 100, true ); | 679 | docuTimer.start( 100, true ); |
677 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); | 680 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); |
678 | raiseFlag = true; | 681 | raiseFlag = true; |
679 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); | 682 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); |
680 | #else | 683 | #else |
681 | // open the default document | 684 | // open the default document |
@@ -688,198 +691,198 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
688 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); | 691 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); |
689 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); | 692 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); |
690 | // signals and slots connections for QListView | 693 | // signals and slots connections for QListView |
691 | connect( ListView, SIGNAL( selectionChanged( QListViewItem* ) ), | 694 | connect( ListView, SIGNAL( selectionChanged( QListViewItem* ) ), |
692 | this, SLOT( listViewSelected( QListViewItem* ) ) ); | 695 | this, SLOT( listViewSelected( QListViewItem* ) ) ); |
693 | connect( ListView, SIGNAL( doubleClicked( QListViewItem* ) ), | 696 | connect( ListView, SIGNAL( doubleClicked( QListViewItem* ) ), |
694 | this, SLOT( showInfo( QListViewItem* ) ) ); | 697 | this, SLOT( showInfo( QListViewItem* ) ) ); |
695 | connect( ListView, SIGNAL( returnPressed( QListViewItem* ) ), | 698 | connect( ListView, SIGNAL( returnPressed( QListViewItem* ) ), |
696 | this, SLOT( showInfo( QListViewItem* ) ) ); | 699 | this, SLOT( showInfo( QListViewItem* ) ) ); |
697 | 700 | ||
698 | } | 701 | } |
699 | 702 | ||
700 | const QColor *ZSafe::evenRowColor = &Qt::white; | 703 | const QColor *ZSafe::evenRowColor = &Qt::white; |
701 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; | 704 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; |
702 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); | 705 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); |
703 | 706 | ||
704 | /* | 707 | /* |
705 | * Destroys the object and frees any allocated resources | 708 | * Destroys the object and frees any allocated resources |
706 | */ | 709 | */ |
707 | ZSafe::~ZSafe() | 710 | ZSafe::~ZSafe() |
708 | { | 711 | { |
709 | // no need to delete child widgets, Qt does it all for us | 712 | // no need to delete child widgets, Qt does it all for us |
710 | quitMe(); | 713 | quitMe(); |
711 | } | 714 | } |
712 | 715 | ||
713 | // load the default document | 716 | // load the default document |
714 | void ZSafe::slotLoadDocu() | 717 | void ZSafe::slotLoadDocu() |
715 | { | 718 | { |
716 | openDocument (filename); | 719 | openDocument (filename); |
717 | } | 720 | } |
718 | 721 | ||
719 | void ZSafe::deletePwd() | 722 | void ZSafe::deletePwd() |
720 | { | 723 | { |
721 | 724 | ||
722 | if (!selectedItem) | 725 | if (!selectedItem) |
723 | return; | 726 | return; |
724 | if (!isCategory(selectedItem)) | 727 | if (!isCategory(selectedItem)) |
725 | { | 728 | { |
726 | switch( QMessageBox::information( this, tr("ZSafe"), | 729 | switch( QMessageBox::information( this, tr("ZSafe"), |
727 | tr("Do you want to delete?"), | 730 | tr("Do you want to delete?"), |
728 | tr("&Delete"), tr("D&on't Delete"), | 731 | tr("&Delete"), tr("D&on't Delete"), |
729 | 0 // Enter == button 0 | 732 | 0 // Enter == button 0 |
730 | ) ) { // Escape == button 2 | 733 | ) ) { // Escape == button 2 |
731 | case 0: // Delete clicked, Alt-S or Enter pressed. | 734 | case 0: // Delete clicked, Alt-S or Enter pressed. |
732 | // Delete | 735 | // Delete |
733 | modified = true; | 736 | modified = true; |
734 | selectedItem->parent()->takeItem(selectedItem); | 737 | selectedItem->parent()->takeItem(selectedItem); |
735 | selectedItem = NULL; | 738 | selectedItem = NULL; |
736 | break; | 739 | break; |
737 | case 1: // Don't delete | 740 | case 1: // Don't delete |
738 | break; | 741 | break; |
739 | } | 742 | } |
740 | } | 743 | } |
741 | else | 744 | else |
742 | { | 745 | { |
743 | delCategory(); | 746 | delCategory(); |
744 | } | 747 | } |
745 | } | 748 | } |
746 | 749 | ||
747 | void ZSafe::editPwd() | 750 | void ZSafe::editPwd() |
748 | { | 751 | { |
749 | if (!selectedItem) | 752 | if (!selectedItem) |
750 | return; | 753 | return; |
751 | if (!isCategory(selectedItem)) | 754 | if (!isCategory(selectedItem)) |
752 | { | 755 | { |
753 | // open the 'New Entry' dialog | 756 | // open the 'New Entry' dialog |
754 | NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); | 757 | NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); |
755 | #ifdef WIN32 | 758 | #ifdef WIN32 |
756 | dialog->setCaption ("Qt " + tr("Edit Entry")); | 759 | dialog->setCaption ("Qt " + tr("Edit Entry")); |
757 | dialog->setGeometry(200, 250, 220, 310 ); | 760 | dialog->setGeometry(200, 250, 220, 310 ); |
758 | #endif | 761 | #endif |
759 | 762 | ||
760 | // set the labels | 763 | // set the labels |
761 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 764 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
762 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 765 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
763 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 766 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
764 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 767 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
765 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 768 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
766 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 769 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
767 | 770 | ||
768 | // set the fields | 771 | // set the fields |
769 | dialog->NameField->setText(selectedItem->text (0)); | 772 | dialog->NameField->setText(selectedItem->text (0)); |
770 | dialog->UsernameField->setText(selectedItem->text (1)); | 773 | dialog->UsernameField->setText(selectedItem->text (1)); |
771 | dialog->PasswordField->setText(selectedItem->text (2)); | 774 | dialog->PasswordField->setText(selectedItem->text (2)); |
772 | QString comment = selectedItem->text (3); | 775 | QString comment = selectedItem->text (3); |
773 | comment.replace (QRegExp("<br>"), "\n"); | 776 | comment.replace (QRegExp("<br>"), "\n"); |
774 | dialog->Field5->setText(selectedItem->text (4)); | 777 | dialog->Field5->setText(selectedItem->text (4)); |
775 | dialog->Field6->setText(selectedItem->text (5)); | 778 | dialog->Field6->setText(selectedItem->text (5)); |
776 | dialog->CommentField->insertLine(comment); | 779 | dialog->CommentField->insertLine(comment); |
777 | dialog->CommentField->setCursorPosition(0,0); | 780 | dialog->CommentField->setCursorPosition(0,0); |
778 | 781 | ||
779 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 782 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); |
780 | 783 | ||
781 | #ifdef DESKTOP | 784 | #ifdef DESKTOP |
782 | result = Accepted; | 785 | result = Accepted; |
783 | #endif | 786 | #endif |
784 | if (result == Accepted) | 787 | if (result == Accepted) |
785 | { | 788 | { |
786 | modified = true; | 789 | modified = true; |
787 | // edit the selected item | 790 | // edit the selected item |
788 | QString name = dialog->NameField->text(); | 791 | QString name = dialog->NameField->text(); |
789 | selectedItem->setText (0, tr (name)); | 792 | selectedItem->setText (0, tr (name)); |
790 | QString user = dialog->UsernameField->text(); | 793 | QString user = dialog->UsernameField->text(); |
791 | selectedItem->setText (1, tr (user)); | 794 | selectedItem->setText (1, tr (user)); |
792 | QString pwd = dialog->PasswordField->text(); | 795 | QString pwd = dialog->PasswordField->text(); |
793 | selectedItem->setText (2, tr (pwd)); | 796 | selectedItem->setText (2, tr (pwd)); |
794 | QString comment = dialog->CommentField->text(); | 797 | QString comment = dialog->CommentField->text(); |
795 | comment.replace (QRegExp("\n"), "<br>"); | 798 | comment.replace (QRegExp("\n"), "<br>"); |
796 | selectedItem->setText (3, tr (comment)); | 799 | selectedItem->setText (3, tr (comment)); |
797 | QString f5 = dialog->Field5->text(); | 800 | QString f5 = dialog->Field5->text(); |
798 | selectedItem->setText (4, tr (f5)); | 801 | selectedItem->setText (4, tr (f5)); |
799 | QString f6 = dialog->Field6->text(); | 802 | QString f6 = dialog->Field6->text(); |
800 | selectedItem->setText (5, tr (f6)); | 803 | selectedItem->setText (5, tr (f6)); |
801 | } | 804 | } |
802 | 805 | ||
803 | delete dialog; | 806 | delete dialog; |
804 | } | 807 | } |
805 | else | 808 | else |
806 | { | 809 | { |
807 | editCategory(); | 810 | editCategory(); |
808 | } | 811 | } |
809 | } | 812 | } |
810 | 813 | ||
811 | void ZSafe::newPwd() | 814 | void ZSafe::newPwd() |
812 | { | 815 | { |
813 | if (!selectedItem) | 816 | if (!selectedItem) |
814 | return; | 817 | return; |
815 | 818 | ||
816 | if (!isCategory(selectedItem)) | 819 | if (!isCategory(selectedItem)) |
817 | selectedItem = selectedItem->parent(); | 820 | selectedItem = selectedItem->parent(); |
818 | 821 | ||
819 | if (isCategory(selectedItem)) | 822 | if (isCategory(selectedItem)) |
820 | { | 823 | { |
821 | QString cat = selectedItem->text(0); | 824 | QString cat = selectedItem->text(0); |
822 | 825 | ||
823 | // open the 'New Entry' dialog | 826 | // open the 'New Entry' dialog |
824 | NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE); | 827 | NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE); |
825 | #ifdef WIN32 | 828 | #ifdef WIN32 |
826 | dialog->setCaption ("Qt " + tr("New Entry")); | 829 | dialog->setCaption ("Qt " + tr("New Entry")); |
827 | dialog->setGeometry(200, 250, 220, 310 ); | 830 | dialog->setGeometry(200, 250, 220, 310 ); |
828 | #endif | 831 | #endif |
829 | // set the labels | 832 | // set the labels |
830 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 833 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
831 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 834 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
832 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 835 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
833 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 836 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
834 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 837 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
835 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 838 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
836 | retype: | 839 | retype: |
837 | 840 | ||
838 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 841 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); |
839 | #ifdef DESKTOP | 842 | #ifdef DESKTOP |
840 | result = Accepted; | 843 | result = Accepted; |
841 | #endif | 844 | #endif |
842 | 845 | ||
843 | if (result == Accepted) | 846 | if (result == Accepted) |
844 | { | 847 | { |
845 | 848 | ||
846 | QString name = dialog->NameField->text(); | 849 | QString name = dialog->NameField->text(); |
847 | if (cat == name) | 850 | if (cat == name) |
848 | { | 851 | { |
849 | QMessageBox::critical( 0, tr("ZSafe"), | 852 | QMessageBox::critical( 0, tr("ZSafe"), |
850 | tr("Entry name must be different\nfrom the category name.") ); | 853 | tr("Entry name must be different\nfrom the category name.") ); |
851 | goto retype; // it's not a good programming style :-) | 854 | goto retype; // it's not a good programming style :-) |
852 | } | 855 | } |
853 | 856 | ||
854 | modified = true; | 857 | modified = true; |
855 | // add the new item | 858 | // add the new item |
856 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 859 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
857 | i->setOpen (TRUE); | 860 | i->setOpen (TRUE); |
858 | 861 | ||
859 | i->setText (0, tr (name)); | 862 | i->setText (0, tr (name)); |
860 | QString user = dialog->UsernameField->text(); | 863 | QString user = dialog->UsernameField->text(); |
861 | i->setText (1, tr (user)); | 864 | i->setText (1, tr (user)); |
862 | QString pwd = dialog->PasswordField->text(); | 865 | QString pwd = dialog->PasswordField->text(); |
863 | i->setText (2, tr (pwd)); | 866 | i->setText (2, tr (pwd)); |
864 | QString comment = dialog->CommentField->text(); | 867 | QString comment = dialog->CommentField->text(); |
865 | comment.replace (QRegExp("\n"), "<br>"); | 868 | comment.replace (QRegExp("\n"), "<br>"); |
866 | i->setText (3, tr (comment)); | 869 | i->setText (3, tr (comment)); |
867 | QString f5 = dialog->Field5->text(); | 870 | QString f5 = dialog->Field5->text(); |
868 | i->setText (4, tr (f5)); | 871 | i->setText (4, tr (f5)); |
869 | QString f6 = dialog->Field6->text(); | 872 | QString f6 = dialog->Field6->text(); |
870 | i->setText (5, tr (f6)); | 873 | i->setText (5, tr (f6)); |
871 | } | 874 | } |
872 | 875 | ||
873 | delete dialog; | 876 | delete dialog; |
874 | } | 877 | } |
875 | } | 878 | } |
876 | 879 | ||
877 | void ZSafe::findPwd() | 880 | void ZSafe::findPwd() |
878 | { | 881 | { |
879 | 882 | ||
880 | // open the 'Search' dialog | 883 | // open the 'Search' dialog |
881 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); | 884 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); |
882 | #ifdef WIN32 | 885 | #ifdef WIN32 |
883 | dialog->setCaption ("Qt " + tr("Search")); | 886 | dialog->setCaption ("Qt " + tr("Search")); |
884 | #endif | 887 | #endif |
885 | 888 | ||
@@ -939,46 +942,46 @@ void ZSafe::findPwd() | |||
939 | { | 942 | { |
940 | // set search at the beginning if a new name is given | 943 | // set search at the beginning if a new name is given |
941 | lastSearchedCategory = NULL; | 944 | lastSearchedCategory = NULL; |
942 | lastSearchedItem = NULL; | 945 | lastSearchedItem = NULL; |
943 | } | 946 | } |
944 | lastSearchedComment = comment; | 947 | lastSearchedComment = comment; |
945 | 948 | ||
946 | ListView->clearSelection(); | 949 | ListView->clearSelection(); |
947 | 950 | ||
948 | bool found=FALSE; | 951 | bool found=FALSE; |
949 | // step through all categories | 952 | // step through all categories |
950 | QListViewItem *i; | 953 | QListViewItem *i; |
951 | if (lastSearchedCategory) | 954 | if (lastSearchedCategory) |
952 | i = lastSearchedCategory; | 955 | i = lastSearchedCategory; |
953 | else | 956 | else |
954 | i = ListView->firstChild(); | 957 | i = ListView->firstChild(); |
955 | for (; | 958 | for (; |
956 | i != NULL; | 959 | i != NULL; |
957 | i = i->nextSibling()) | 960 | i = i->nextSibling()) |
958 | { | 961 | { |
959 | qWarning (i->text(0)); | 962 | qWarning (i->text(0)); |
960 | i->setSelected(FALSE); | 963 | i->setSelected(FALSE); |
961 | 964 | ||
962 | // step through all subitems | 965 | // step through all subitems |
963 | QListViewItem *si; | 966 | QListViewItem *si; |
964 | if (lastSearchedItem) | 967 | if (lastSearchedItem) |
965 | si = lastSearchedItem; | 968 | si = lastSearchedItem; |
966 | else | 969 | else |
967 | si = i->firstChild(); | 970 | si = i->firstChild(); |
968 | // for (si = i->firstChild(); | 971 | // for (si = i->firstChild(); |
969 | for (; | 972 | for (; |
970 | si != NULL; | 973 | si != NULL; |
971 | si = si->nextSibling()) | 974 | si = si->nextSibling()) |
972 | { | 975 | { |
973 | qWarning (si->text(0)); | 976 | qWarning (si->text(0)); |
974 | if (si->isSelected()) | 977 | if (si->isSelected()) |
975 | si->setSelected(FALSE); | 978 | si->setSelected(FALSE); |
976 | // ListView->repaintItem(si); | 979 | // ListView->repaintItem(si); |
977 | 980 | ||
978 | bool n=TRUE; | 981 | bool n=TRUE; |
979 | bool u=TRUE; | 982 | bool u=TRUE; |
980 | bool c=TRUE; | 983 | bool c=TRUE; |
981 | if (!name.isEmpty()) | 984 | if (!name.isEmpty()) |
982 | n = (si->text(0)).contains (name, FALSE); | 985 | n = (si->text(0)).contains (name, FALSE); |
983 | if (!username.isEmpty()) | 986 | if (!username.isEmpty()) |
984 | u = (si->text(1)).contains (username, FALSE); | 987 | u = (si->text(1)).contains (username, FALSE); |
@@ -1005,35 +1008,35 @@ void ZSafe::findPwd() | |||
1005 | lastSearchedItem = NULL; // END | 1008 | lastSearchedItem = NULL; // END |
1006 | } | 1009 | } |
1007 | 1010 | ||
1008 | found = TRUE; | 1011 | found = TRUE; |
1009 | delete dialog; | 1012 | delete dialog; |
1010 | update(); | 1013 | update(); |
1011 | return; | 1014 | return; |
1012 | } | 1015 | } |
1013 | } | 1016 | } |
1014 | lastSearchedCategory = i->nextSibling(); | 1017 | lastSearchedCategory = i->nextSibling(); |
1015 | lastSearchedItem = NULL; | 1018 | lastSearchedItem = NULL; |
1016 | } | 1019 | } |
1017 | lastSearchedCategory = NULL; | 1020 | lastSearchedCategory = NULL; |
1018 | lastSearchedItem = NULL; | 1021 | lastSearchedItem = NULL; |
1019 | delete dialog; | 1022 | delete dialog; |
1020 | update(); | 1023 | update(); |
1021 | QMessageBox::information( this, tr("ZSafe"), | 1024 | QMessageBox::information( this, tr("ZSafe"), |
1022 | tr("Entry not found"), tr("&OK"), 0); | 1025 | tr("Entry not found"), tr("&OK"), 0); |
1023 | 1026 | ||
1024 | } | 1027 | } |
1025 | 1028 | ||
1026 | QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) | 1029 | QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) |
1027 | { | 1030 | { |
1028 | QString category; | 1031 | QString category; |
1029 | if (_item) | 1032 | if (_item) |
1030 | { | 1033 | { |
1031 | if (isCategory(_item)) | 1034 | if (isCategory(_item)) |
1032 | { | 1035 | { |
1033 | category = _item->text(0); | 1036 | category = _item->text(0); |
1034 | } | 1037 | } |
1035 | else | 1038 | else |
1036 | { | 1039 | { |
1037 | QListViewItem *cat = _item->parent(); | 1040 | QListViewItem *cat = _item->parent(); |
1038 | category = cat->text(0); | 1041 | category = cat->text(0); |
1039 | } | 1042 | } |
@@ -1063,50 +1066,50 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) | |||
1063 | conf->setGroup ("zsafe"); | 1066 | conf->setGroup ("zsafe"); |
1064 | #endif | 1067 | #endif |
1065 | return label; | 1068 | return label; |
1066 | } | 1069 | } |
1067 | 1070 | ||
1068 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) | 1071 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) |
1069 | { | 1072 | { |
1070 | QString app_key = APP_KEY; | 1073 | QString app_key = APP_KEY; |
1071 | #ifndef DESKTOP | 1074 | #ifndef DESKTOP |
1072 | conf->setGroup ("fieldDefs"); | 1075 | conf->setGroup ("fieldDefs"); |
1073 | #else | 1076 | #else |
1074 | #ifndef WIN32 | 1077 | #ifndef WIN32 |
1075 | app_key += "/fieldDefs/"; | 1078 | app_key += "/fieldDefs/"; |
1076 | #endif | 1079 | #endif |
1077 | #endif | 1080 | #endif |
1078 | // #ifndef WIN32 | 1081 | // #ifndef WIN32 |
1079 | QString label = conf->readEntry(app_key+category+"-field"+field, | 1082 | QString label = conf->readEntry(app_key+category+"-field"+field, |
1080 | def); | 1083 | def); |
1081 | // #else | 1084 | // #else |
1082 | // QString label(def); | 1085 | // QString label(def); |
1083 | // #endif | 1086 | // #endif |
1084 | #ifndef DESKTOP | 1087 | #ifndef DESKTOP |
1085 | conf->setGroup ("zsafe"); | 1088 | conf->setGroup ("zsafe"); |
1086 | #endif | 1089 | #endif |
1087 | return label; | 1090 | return label; |
1088 | } | 1091 | } |
1089 | 1092 | ||
1090 | void ZSafe::showInfo( QListViewItem *_item) | 1093 | void ZSafe::showInfo( QListViewItem *_item) |
1091 | { | 1094 | { |
1092 | if (!_item) | 1095 | if (!_item) |
1093 | return; | 1096 | return; |
1094 | if (selectedItem != NULL) | 1097 | if (selectedItem != NULL) |
1095 | selectedItem->setSelected(FALSE); | 1098 | selectedItem->setSelected(FALSE); |
1096 | 1099 | ||
1097 | selectedItem = _item; | 1100 | selectedItem = _item; |
1098 | selectedItem->setSelected(TRUE); | 1101 | selectedItem->setSelected(TRUE); |
1099 | 1102 | ||
1100 | if (!isCategory(_item)) | 1103 | if (!isCategory(_item)) |
1101 | { | 1104 | { |
1102 | /* | 1105 | /* |
1103 | QString label=selectedItem->text(0); | 1106 | QString label=selectedItem->text(0); |
1104 | label+="\n"; | 1107 | label+="\n"; |
1105 | label+=selectedItem->text(1); | 1108 | label+=selectedItem->text(1); |
1106 | label+="\n"; | 1109 | label+="\n"; |
1107 | label+=selectedItem->text(2); | 1110 | label+=selectedItem->text(2); |
1108 | label+="\n"; | 1111 | label+="\n"; |
1109 | label+=selectedItem->text(3); | 1112 | label+=selectedItem->text(3); |
1110 | */ | 1113 | */ |
1111 | 1114 | ||
1112 | QString text; | 1115 | QString text; |
@@ -1225,118 +1228,118 @@ bool ZSafe::isCategory(QListViewItem *_item) | |||
1225 | void ZSafe::removeAsciiFile() | 1228 | void ZSafe::removeAsciiFile() |
1226 | { | 1229 | { |
1227 | // QString fn = filename + ".txt"; | 1230 | // QString fn = filename + ".txt"; |
1228 | // open the file dialog | 1231 | // open the file dialog |
1229 | #ifndef DESKTOP | 1232 | #ifndef DESKTOP |
1230 | #ifndef NO_OPIE | 1233 | #ifndef NO_OPIE |
1231 | QMap<QString, QStringList> mimeTypes; | 1234 | QMap<QString, QStringList> mimeTypes; |
1232 | mimeTypes.insert(tr("All"), QStringList() ); | 1235 | mimeTypes.insert(tr("All"), QStringList() ); |
1233 | mimeTypes.insert(tr("Text"), "text/*" ); | 1236 | mimeTypes.insert(tr("Text"), "text/*" ); |
1234 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 1237 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
1235 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1238 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1236 | QString::null, | 1239 | QString::null, |
1237 | mimeTypes, | 1240 | mimeTypes, |
1238 | this, | 1241 | this, |
1239 | tr ("Remove text file")); | 1242 | tr ("Remove text file")); |
1240 | #else | 1243 | #else |
1241 | QString fn = ScQtFileEdit::getOpenFileName(this, | 1244 | QString fn = ScQtFileEdit::getOpenFileName(this, |
1242 | tr ("Remove text file"), | 1245 | tr ("Remove text file"), |
1243 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1246 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1244 | "*.txt"); | 1247 | "*.txt"); |
1245 | #endif | 1248 | #endif |
1246 | #else | 1249 | #else |
1247 | QString fn = QFileDialog::getOpenFileName( | 1250 | QString fn = QFileDialog::getOpenFileName( |
1248 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1251 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1249 | "ZSafe (*.txt)", | 1252 | "ZSafe (*.txt)", |
1250 | this, | 1253 | this, |
1251 | "ZSafe File Dialog" | 1254 | "ZSafe File Dialog" |
1252 | "Choose a text file" ); | 1255 | "Choose a text file" ); |
1253 | #endif | 1256 | #endif |
1254 | 1257 | ||
1255 | if (fn && fn.length() > 0 ) | 1258 | if (fn && fn.length() > 0 ) |
1256 | { | 1259 | { |
1257 | QFile f( fn ); | 1260 | QFile f( fn ); |
1258 | if ( !f.remove() ) | 1261 | if ( !f.remove() ) |
1259 | { | 1262 | { |
1260 | qWarning( QString("Could not remove file %1").arg(fn), | 1263 | qWarning( QString("Could not remove file %1").arg(fn), |
1261 | 2000 ); | 1264 | 2000 ); |
1262 | QMessageBox::critical( 0, tr("ZSafe"), | 1265 | QMessageBox::critical( 0, tr("ZSafe"), |
1263 | tr("Could not remove text file.") ); | 1266 | tr("Could not remove text file.") ); |
1264 | return; | 1267 | return; |
1265 | } | 1268 | } |
1266 | } | 1269 | } |
1267 | } | 1270 | } |
1268 | 1271 | ||
1269 | void ZSafe::writeAllEntries() | 1272 | void ZSafe::writeAllEntries() |
1270 | { | 1273 | { |
1271 | if (filename.isEmpty()) | 1274 | if (filename.isEmpty()) |
1272 | { | 1275 | { |
1273 | QMessageBox::critical( 0, tr("ZSafe"), | 1276 | QMessageBox::critical( 0, tr("ZSafe"), |
1274 | tr("No document defined.\nYou have to create a new document")); | 1277 | tr("No document defined.\nYou have to create a new document")); |
1275 | return; | 1278 | return; |
1276 | } | 1279 | } |
1277 | 1280 | ||
1278 | // open the file dialog | 1281 | // open the file dialog |
1279 | #ifndef DESKTOP | 1282 | #ifndef DESKTOP |
1280 | #ifndef NO_OPIE | 1283 | #ifndef NO_OPIE |
1281 | QMap<QString, QStringList> mimeTypes; | 1284 | QMap<QString, QStringList> mimeTypes; |
1282 | mimeTypes.insert(tr("All"), QStringList() ); | 1285 | mimeTypes.insert(tr("All"), QStringList() ); |
1283 | mimeTypes.insert(tr("Text"), "text/*" ); | 1286 | mimeTypes.insert(tr("Text"), "text/*" ); |
1284 | QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 1287 | QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
1285 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1288 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1286 | QString::null, | 1289 | QString::null, |
1287 | mimeTypes, | 1290 | mimeTypes, |
1288 | this, | 1291 | this, |
1289 | tr ("Export text file")); | 1292 | tr ("Export text file")); |
1290 | #else | 1293 | #else |
1291 | QString fn = ScQtFileEdit::getSaveAsFileName(this, | 1294 | QString fn = ScQtFileEdit::getSaveAsFileName(this, |
1292 | tr ("Export text file"), | 1295 | tr ("Export text file"), |
1293 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1296 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1294 | "*.txt"); | 1297 | "*.txt"); |
1295 | #endif | 1298 | #endif |
1296 | #else | 1299 | #else |
1297 | QString fn = QFileDialog::getSaveFileName( | 1300 | QString fn = QFileDialog::getSaveFileName( |
1298 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1301 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1299 | "ZSafe (*.txt)", | 1302 | "ZSafe (*.txt)", |
1300 | this, | 1303 | this, |
1301 | "ZSafe File Dialog" | 1304 | "ZSafe File Dialog" |
1302 | "Choose a text file" ); | 1305 | "Choose a text file" ); |
1303 | #endif | 1306 | #endif |
1304 | 1307 | ||
1305 | // open the new document | 1308 | // open the new document |
1306 | if (fn && fn.length() > 0 ) | 1309 | if (fn && fn.length() > 0 ) |
1307 | { | 1310 | { |
1308 | QFile f( fn ); | 1311 | QFile f( fn ); |
1309 | if ( !f.open( IO_WriteOnly ) ) { | 1312 | if ( !f.open( IO_WriteOnly ) ) { |
1310 | qWarning( QString("Could not write to file %1").arg(fn), | 1313 | qWarning( QString("Could not write to file %1").arg(fn), |
1311 | 2000 ); | 1314 | 2000 ); |
1312 | QMessageBox::critical( 0, "ZSafe", | 1315 | QMessageBox::critical( 0, "ZSafe", |
1313 | QString("Could not export to text file.") ); | 1316 | QString("Could not export to text file.") ); |
1314 | return; | 1317 | return; |
1315 | } | 1318 | } |
1316 | QTextStream t( &f ); | 1319 | QTextStream t( &f ); |
1317 | 1320 | ||
1318 | QListViewItem *i; | 1321 | QListViewItem *i; |
1319 | // step through all categories | 1322 | // step through all categories |
1320 | for (i = ListView->firstChild(); | 1323 | for (i = ListView->firstChild(); |
1321 | i != NULL; | 1324 | i != NULL; |
1322 | i = i->nextSibling()) | 1325 | i = i->nextSibling()) |
1323 | { | 1326 | { |
1324 | // step through all subitems | 1327 | // step through all subitems |
1325 | QListViewItem *si; | 1328 | QListViewItem *si; |
1326 | for (si = i->firstChild(); | 1329 | for (si = i->firstChild(); |
1327 | si != NULL; | 1330 | si != NULL; |
1328 | si = si->nextSibling()) | 1331 | si = si->nextSibling()) |
1329 | { | 1332 | { |
1330 | QString oneEntry; | 1333 | QString oneEntry; |
1331 | oneEntry += "\""; | 1334 | oneEntry += "\""; |
1332 | oneEntry += i->text(0); | 1335 | oneEntry += i->text(0); |
1333 | oneEntry += "\";"; | 1336 | oneEntry += "\";"; |
1334 | oneEntry += "\""; | 1337 | oneEntry += "\""; |
1335 | oneEntry += si->text(0); | 1338 | oneEntry += si->text(0); |
1336 | oneEntry += "\";"; | 1339 | oneEntry += "\";"; |
1337 | oneEntry += "\""; | 1340 | oneEntry += "\""; |
1338 | oneEntry += si->text(1); | 1341 | oneEntry += si->text(1); |
1339 | oneEntry += "\";"; | 1342 | oneEntry += "\";"; |
1340 | oneEntry += "\""; | 1343 | oneEntry += "\""; |
1341 | oneEntry += si->text(2); | 1344 | oneEntry += si->text(2); |
1342 | oneEntry += "\";"; | 1345 | oneEntry += "\";"; |
@@ -1370,40 +1373,40 @@ void ZSafe::readAllEntries() | |||
1370 | return; | 1373 | return; |
1371 | } | 1374 | } |
1372 | 1375 | ||
1373 | // open the file dialog | 1376 | // open the file dialog |
1374 | #ifndef DESKTOP | 1377 | #ifndef DESKTOP |
1375 | #ifndef NO_OPIE | 1378 | #ifndef NO_OPIE |
1376 | QMap<QString, QStringList> mimeTypes; | 1379 | QMap<QString, QStringList> mimeTypes; |
1377 | mimeTypes.insert(tr("All"), QStringList() ); | 1380 | mimeTypes.insert(tr("All"), QStringList() ); |
1378 | mimeTypes.insert(tr("Text"), "text/*" ); | 1381 | mimeTypes.insert(tr("Text"), "text/*" ); |
1379 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 1382 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
1380 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1383 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1381 | QString::null, | 1384 | QString::null, |
1382 | mimeTypes, | 1385 | mimeTypes, |
1383 | this, | 1386 | this, |
1384 | tr ("Import text file")); | 1387 | tr ("Import text file")); |
1385 | #else | 1388 | #else |
1386 | QString fn = ScQtFileEdit::getOpenFileName(this, | 1389 | QString fn = ScQtFileEdit::getOpenFileName(this, |
1387 | tr ("Import text file"), | 1390 | tr ("Import text file"), |
1388 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1391 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1389 | "*.txt"); | 1392 | "*.txt"); |
1390 | #endif | 1393 | #endif |
1391 | #else | 1394 | #else |
1392 | QString fn = QFileDialog::getOpenFileName( | 1395 | QString fn = QFileDialog::getOpenFileName( |
1393 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1396 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1394 | "ZSafe (*.txt)", | 1397 | "ZSafe (*.txt)", |
1395 | this, | 1398 | this, |
1396 | "ZSafe File Dialog" | 1399 | "ZSafe File Dialog" |
1397 | "Choose a text file" ); | 1400 | "Choose a text file" ); |
1398 | #endif | 1401 | #endif |
1399 | 1402 | ||
1400 | if (fn && fn.length() > 0 ) | 1403 | if (fn && fn.length() > 0 ) |
1401 | { | 1404 | { |
1402 | QFile f( fn ); | 1405 | QFile f( fn ); |
1403 | if ( !f.open( IO_ReadOnly ) ) | 1406 | if ( !f.open( IO_ReadOnly ) ) |
1404 | { | 1407 | { |
1405 | qWarning( QString("Could not read file %1").arg(fn), | 1408 | qWarning( QString("Could not read file %1").arg(fn), |
1406 | 2000 ); | 1409 | 2000 ); |
1407 | QMessageBox::critical( 0, "ZSafe", | 1410 | QMessageBox::critical( 0, "ZSafe", |
1408 | QString("Could not import text file.") ); | 1411 | QString("Could not import text file.") ); |
1409 | return; | 1412 | return; |
@@ -1422,46 +1425,46 @@ void ZSafe::readAllEntries() | |||
1422 | // step through all subitems | 1425 | // step through all subitems |
1423 | QListViewItem *si; | 1426 | QListViewItem *si; |
1424 | for (si = i->firstChild(); | 1427 | for (si = i->firstChild(); |
1425 | si != NULL; ) | 1428 | si != NULL; ) |
1426 | // si = si->nextSibling()) | 1429 | // si = si->nextSibling()) |
1427 | { | 1430 | { |
1428 | QListViewItem *_si = si; | 1431 | QListViewItem *_si = si; |
1429 | si = si->nextSibling(); | 1432 | si = si->nextSibling(); |
1430 | i->takeItem(_si); // remove from view list | 1433 | i->takeItem(_si); // remove from view list |
1431 | if (_si) delete _si; | 1434 | if (_si) delete _si; |
1432 | } | 1435 | } |
1433 | } | 1436 | } |
1434 | 1437 | ||
1435 | qWarning ("ReadAllEntries(): "); | 1438 | qWarning ("ReadAllEntries(): "); |
1436 | 1439 | ||
1437 | QTextStream t(&f); | 1440 | QTextStream t(&f); |
1438 | while ( !t.eof() ) | 1441 | while ( !t.eof() ) |
1439 | { | 1442 | { |
1440 | QString s = t.readLine(); | 1443 | QString s = t.readLine(); |
1441 | s.replace (QRegExp("\";\""), "\"|\""); | 1444 | s.replace (QRegExp("\";\""), "\"|\""); |
1442 | // char buffer[1024]; | 1445 | // char buffer[1024]; |
1443 | #ifndef WIN32 | 1446 | #ifndef WIN32 |
1444 | char buffer[s.length()+1]; | 1447 | char buffer[s.length()+1]; |
1445 | #else | 1448 | #else |
1446 | char buffer[4048]; | 1449 | char buffer[4048]; |
1447 | #endif | 1450 | #endif |
1448 | 1451 | ||
1449 | 1452 | ||
1450 | /* modify QString -> QCString::utf8 */ | 1453 | /* modify QString -> QCString::utf8 */ |
1451 | 1454 | ||
1452 | strcpy (buffer, s.utf8()); | 1455 | strcpy (buffer, s.utf8()); |
1453 | 1456 | ||
1454 | QString name; | 1457 | QString name; |
1455 | QString user; | 1458 | QString user; |
1456 | QString password; | 1459 | QString password; |
1457 | QString comment; | 1460 | QString comment; |
1458 | QString field5=""; | 1461 | QString field5=""; |
1459 | QString field6=""; | 1462 | QString field6=""; |
1460 | 1463 | ||
1461 | // separete the entries | 1464 | // separete the entries |
1462 | char *i = strtok (buffer, "|"); | 1465 | char *i = strtok (buffer, "|"); |
1463 | QString category(QString::fromUtf8(&i[1])); | 1466 | QString category(QString::fromUtf8(&i[1])); |
1464 | category.truncate(category.length() -1); | 1467 | category.truncate(category.length() -1); |
1465 | 1468 | ||
1466 | int idx=0; | 1469 | int idx=0; |
1467 | while ((i = strtok (NULL, "|")) != NULL) | 1470 | while ((i = strtok (NULL, "|")) != NULL) |
@@ -1486,33 +1489,33 @@ void ZSafe::readAllEntries() | |||
1486 | case 3: | 1489 | case 3: |
1487 | // comment | 1490 | // comment |
1488 | comment = QString::fromUtf8(&i[1]); | 1491 | comment = QString::fromUtf8(&i[1]); |
1489 | comment.truncate(comment.length() -1); | 1492 | comment.truncate(comment.length() -1); |
1490 | break; | 1493 | break; |
1491 | case 4: | 1494 | case 4: |
1492 | // field5 | 1495 | // field5 |
1493 | field5 = QString::fromUtf8(&i[1]); | 1496 | field5 = QString::fromUtf8(&i[1]); |
1494 | field5.truncate(field5.length() -1); | 1497 | field5.truncate(field5.length() -1); |
1495 | break; | 1498 | break; |
1496 | case 5: | 1499 | case 5: |
1497 | // field6 | 1500 | // field6 |
1498 | field6 = QString::fromUtf8(&i[1]); | 1501 | field6 = QString::fromUtf8(&i[1]); |
1499 | field6.truncate(field6.length() -1); | 1502 | field6.truncate(field6.length() -1); |
1500 | break; | 1503 | break; |
1501 | } | 1504 | } |
1502 | idx++; | 1505 | idx++; |
1503 | } | 1506 | } |
1504 | 1507 | ||
1505 | Category *cat= categories.find (category); | 1508 | Category *cat= categories.find (category); |
1506 | if (cat) | 1509 | if (cat) |
1507 | { | 1510 | { |
1508 | // use the existend item | 1511 | // use the existend item |
1509 | QListViewItem *catItem = cat->getListItem(); | 1512 | QListViewItem *catItem = cat->getListItem(); |
1510 | if (catItem) | 1513 | if (catItem) |
1511 | { | 1514 | { |
1512 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1515 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
1513 | item->setText( 0, tr( name ) ); | 1516 | item->setText( 0, tr( name ) ); |
1514 | item->setText( 1, tr( user ) ); | 1517 | item->setText( 1, tr( user ) ); |
1515 | item->setText( 2, tr( password ) ); | 1518 | item->setText( 2, tr( password ) ); |
1516 | item->setText( 3, tr( comment ) ); | 1519 | item->setText( 3, tr( comment ) ); |
1517 | item->setText( 4, tr( field5 ) ); | 1520 | item->setText( 4, tr( field5 ) ); |
1518 | item->setText( 5, tr( field6 ) ); | 1521 | item->setText( 5, tr( field6 ) ); |
@@ -1580,39 +1583,39 @@ void ZSafe::readAllEntries() | |||
1580 | void ZSafe::writeAllEntries() | 1583 | void ZSafe::writeAllEntries() |
1581 | { | 1584 | { |
1582 | // open the file for writing | 1585 | // open the file for writing |
1583 | QString fn = filename + ".txt"; | 1586 | QString fn = filename + ".txt"; |
1584 | QFile f( fn ); | 1587 | QFile f( fn ); |
1585 | if ( !f.open( IO_WriteOnly ) ) { | 1588 | if ( !f.open( IO_WriteOnly ) ) { |
1586 | qWarning( QString("Could not write to file %1").arg(fn), | 1589 | qWarning( QString("Could not write to file %1").arg(fn), |
1587 | 2000 ); | 1590 | 2000 ); |
1588 | QMessageBox::critical( 0, tr("ZSafe"), | 1591 | QMessageBox::critical( 0, tr("ZSafe"), |
1589 | tr("Could not export to text file.") ); | 1592 | tr("Could not export to text file.") ); |
1590 | return; | 1593 | return; |
1591 | } | 1594 | } |
1592 | QTextStream t( &f ); | 1595 | QTextStream t( &f ); |
1593 | 1596 | ||
1594 | QListViewItem *i; | 1597 | QListViewItem *i; |
1595 | // step through all categories | 1598 | // step through all categories |
1596 | for (i = ListView->firstChild(); | 1599 | for (i = ListView->firstChild(); |
1597 | i != NULL; | 1600 | i != NULL; |
1598 | i = i->nextSibling()) | 1601 | i = i->nextSibling()) |
1599 | { | 1602 | { |
1600 | // step through all subitems | 1603 | // step through all subitems |
1601 | QListViewItem *si; | 1604 | QListViewItem *si; |
1602 | for (si = i->firstChild(); | 1605 | for (si = i->firstChild(); |
1603 | si != NULL; | 1606 | si != NULL; |
1604 | si = si->nextSibling()) | 1607 | si = si->nextSibling()) |
1605 | { | 1608 | { |
1606 | QString oneEntry; | 1609 | QString oneEntry; |
1607 | oneEntry += "\""; | 1610 | oneEntry += "\""; |
1608 | oneEntry += i->text(0); | 1611 | oneEntry += i->text(0); |
1609 | oneEntry += "\";"; | 1612 | oneEntry += "\";"; |
1610 | oneEntry += "\""; | 1613 | oneEntry += "\""; |
1611 | oneEntry += si->text(0); | 1614 | oneEntry += si->text(0); |
1612 | oneEntry += "\";"; | 1615 | oneEntry += "\";"; |
1613 | oneEntry += "\""; | 1616 | oneEntry += "\""; |
1614 | oneEntry += si->text(1); | 1617 | oneEntry += si->text(1); |
1615 | oneEntry += "\";"; | 1618 | oneEntry += "\";"; |
1616 | oneEntry += "\""; | 1619 | oneEntry += "\""; |
1617 | oneEntry += si->text(2); | 1620 | oneEntry += si->text(2); |
1618 | oneEntry += "\";"; | 1621 | oneEntry += "\";"; |
@@ -1657,40 +1660,40 @@ void ZSafe::readAllEntries() | |||
1657 | // step through all subitems | 1660 | // step through all subitems |
1658 | QListViewItem *si; | 1661 | QListViewItem *si; |
1659 | for (si = i->firstChild(); | 1662 | for (si = i->firstChild(); |
1660 | si != NULL; ) | 1663 | si != NULL; ) |
1661 | // si = si->nextSibling()) | 1664 | // si = si->nextSibling()) |
1662 | { | 1665 | { |
1663 | QListViewItem *_si = si; | 1666 | QListViewItem *_si = si; |
1664 | si = si->nextSibling(); | 1667 | si = si->nextSibling(); |
1665 | i->takeItem(_si); // remove from view list | 1668 | i->takeItem(_si); // remove from view list |
1666 | if (_si) delete _si; | 1669 | if (_si) delete _si; |
1667 | } | 1670 | } |
1668 | } | 1671 | } |
1669 | 1672 | ||
1670 | qWarning ("ReadAllEntries(): "); | 1673 | qWarning ("ReadAllEntries(): "); |
1671 | 1674 | ||
1672 | QTextStream t(&f); | 1675 | QTextStream t(&f); |
1673 | while ( !t.eof() ) | 1676 | while ( !t.eof() ) |
1674 | { | 1677 | { |
1675 | QString s = t.readLine(); | 1678 | QString s = t.readLine(); |
1676 | s.replace (QRegExp("\";\""), "\"|\""); | 1679 | s.replace (QRegExp("\";\""), "\"|\""); |
1677 | // char buffer[1024]; | 1680 | // char buffer[1024]; |
1678 | int len=s.length()+1; | 1681 | int len=s.length()+1; |
1679 | #ifdef WIN32 | 1682 | #ifdef WIN32 |
1680 | char buffer[512]; | 1683 | char buffer[512]; |
1681 | #else | 1684 | #else |
1682 | char buffer[len]; | 1685 | char buffer[len]; |
1683 | #endif | 1686 | #endif |
1684 | strcpy (buffer, s); | 1687 | strcpy (buffer, s); |
1685 | 1688 | ||
1686 | QString name; | 1689 | QString name; |
1687 | QString user; | 1690 | QString user; |
1688 | QString password; | 1691 | QString password; |
1689 | QString comment; | 1692 | QString comment; |
1690 | 1693 | ||
1691 | // separete the entries | 1694 | // separete the entries |
1692 | char *i = strtok (buffer, "|"); | 1695 | char *i = strtok (buffer, "|"); |
1693 | QString category(&i[1]); | 1696 | QString category(&i[1]); |
1694 | category.truncate(category.length() -1); | 1697 | category.truncate(category.length() -1); |
1695 | 1698 | ||
1696 | int idx=0; | 1699 | int idx=0; |
@@ -1706,33 +1709,33 @@ void ZSafe::readAllEntries() | |||
1706 | case 1: | 1709 | case 1: |
1707 | // user | 1710 | // user |
1708 | user = &i[1]; | 1711 | user = &i[1]; |
1709 | user.truncate(user.length() -1); | 1712 | user.truncate(user.length() -1); |
1710 | break; | 1713 | break; |
1711 | case 2: | 1714 | case 2: |
1712 | // password | 1715 | // password |
1713 | password = &i[1]; | 1716 | password = &i[1]; |
1714 | password.truncate(password.length() -1); | 1717 | password.truncate(password.length() -1); |
1715 | break; | 1718 | break; |
1716 | case 3: | 1719 | case 3: |
1717 | // comment | 1720 | // comment |
1718 | comment = &i[1]; | 1721 | comment = &i[1]; |
1719 | comment.truncate(comment.length() -1); | 1722 | comment.truncate(comment.length() -1); |
1720 | break; | 1723 | break; |
1721 | } | 1724 | } |
1722 | idx++; | 1725 | idx++; |
1723 | } | 1726 | } |
1724 | 1727 | ||
1725 | Category *cat= categories.find (category); | 1728 | Category *cat= categories.find (category); |
1726 | if (cat) | 1729 | if (cat) |
1727 | { | 1730 | { |
1728 | // use the existend item | 1731 | // use the existend item |
1729 | QListViewItem *catItem = cat->getListItem(); | 1732 | QListViewItem *catItem = cat->getListItem(); |
1730 | if (catItem) | 1733 | if (catItem) |
1731 | { | 1734 | { |
1732 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1735 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
1733 | item->setText( 0, tr( name ) ); | 1736 | item->setText( 0, tr( name ) ); |
1734 | item->setText( 1, tr( user ) ); | 1737 | item->setText( 1, tr( user ) ); |
1735 | item->setText( 2, tr( password ) ); | 1738 | item->setText( 2, tr( password ) ); |
1736 | item->setText( 3, tr( comment ) ); | 1739 | item->setText( 3, tr( comment ) ); |
1737 | 1740 | ||
1738 | catItem->setOpen( TRUE ); | 1741 | catItem->setOpen( TRUE ); |
@@ -1819,127 +1822,127 @@ void ZSafe::resume(int) | |||
1819 | } | 1822 | } |
1820 | 1823 | ||
1821 | // ask for password and read again | 1824 | // ask for password and read again |
1822 | openDocument(filename); | 1825 | openDocument(filename); |
1823 | } | 1826 | } |
1824 | 1827 | ||
1825 | //--------------------------------------------- | 1828 | //--------------------------------------------- |
1826 | 1829 | ||
1827 | 1830 | ||
1828 | bool ZSafe::openDocument(const char* _filename, const char* ) | 1831 | bool ZSafe::openDocument(const char* _filename, const char* ) |
1829 | { | 1832 | { |
1830 | int retval; | 1833 | int retval; |
1831 | char* entry[FIELD_SIZE]; | 1834 | char* entry[FIELD_SIZE]; |
1832 | // #ifndef WIN32 | 1835 | // #ifndef WIN32 |
1833 | int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); | 1836 | int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); |
1834 | // #else | 1837 | // #else |
1835 | // int validationFlag = 1; | 1838 | // int validationFlag = 1; |
1836 | // #endif | 1839 | // #endif |
1837 | 1840 | ||
1838 | int pwdOk = 0; | 1841 | int pwdOk = 0; |
1839 | int numberOfTries = 3; | 1842 | int numberOfTries = 3; |
1840 | for (int i=0; i < numberOfTries; i++) | 1843 | for (int i=0; i < numberOfTries; i++) |
1841 | { | 1844 | { |
1842 | QFile f(_filename); | 1845 | QFile f(_filename); |
1843 | if (f.exists()) | 1846 | if (f.exists()) |
1844 | { | 1847 | { |
1845 | // ask with a dialog for the password | 1848 | // ask with a dialog for the password |
1846 | if (m_password.isEmpty()) | 1849 | if (m_password.isEmpty()) |
1847 | getDocPassword(tr("Enter Password")); | 1850 | getDocPassword(tr("Enter Password")); |
1848 | if (m_password.isEmpty() && validationFlag == 0) | 1851 | if (m_password.isEmpty() && validationFlag == 0) |
1849 | { | 1852 | { |
1850 | qWarning ("Wrong password"); | 1853 | qWarning ("Wrong password"); |
1851 | QMessageBox::critical( 0, tr("ZSafe"), | 1854 | QMessageBox::critical( 0, tr("ZSafe"), |
1852 | tr("Wrong password.\n\nZSafe will now exit.") ); | 1855 | tr("Wrong password.\n\nZSafe will now exit.") ); |
1853 | exitZs (1); | 1856 | exitZs (1); |
1854 | } | 1857 | } |
1855 | 1858 | ||
1856 | retval = loadInit(_filename, m_password); | 1859 | retval = loadInit(_filename, m_password); |
1857 | if (retval != PWERR_GOOD) | 1860 | if (retval != PWERR_GOOD) |
1858 | { | 1861 | { |
1859 | qWarning ("Error loading Document"); | 1862 | qWarning ("Error loading Document"); |
1860 | return false; | 1863 | return false; |
1861 | } | 1864 | } |
1862 | } | 1865 | } |
1863 | else | 1866 | else |
1864 | { | 1867 | { |
1865 | #ifdef WIN32 | 1868 | #ifdef WIN32 |
1866 | this->setCaption("Qt ZSafe"); | 1869 | this->setCaption("Qt ZSafe"); |
1867 | #else | 1870 | #else |
1868 | this->setCaption("ZSafe"); | 1871 | this->setCaption("ZSafe"); |
1869 | #endif | 1872 | #endif |
1870 | filename = ""; | 1873 | filename = ""; |
1871 | return false; | 1874 | return false; |
1872 | } | 1875 | } |
1873 | 1876 | ||
1874 | 1877 | ||
1875 | // load the validation entry | 1878 | // load the validation entry |
1876 | if (validationFlag == 0) | 1879 | if (validationFlag == 0) |
1877 | { | 1880 | { |
1878 | pwdOk = 1; | 1881 | pwdOk = 1; |
1879 | break; | 1882 | break; |
1880 | } | 1883 | } |
1881 | 1884 | ||
1882 | retval = loadEntry(entry); | 1885 | retval = loadEntry(entry); |
1883 | if (retval == 1 && | 1886 | if (retval == 1 && |
1884 | !strcmp (entry[0], "ZSAFECATEGORY") && | 1887 | !strcmp (entry[0], "ZSAFECATEGORY") && |
1885 | !strcmp (entry[1], "name") && | 1888 | !strcmp (entry[1], "name") && |
1886 | !strcmp (entry[2], "username") && | 1889 | !strcmp (entry[2], "username") && |
1887 | !strcmp (entry[3], "password") && | 1890 | !strcmp (entry[3], "password") && |
1888 | !strcmp (entry[4], "comment") ) | 1891 | !strcmp (entry[4], "comment") ) |
1889 | { | 1892 | { |
1890 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1893 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1891 | pwdOk = 1; | 1894 | pwdOk = 1; |
1892 | break; | 1895 | break; |
1893 | } | 1896 | } |
1894 | else | 1897 | else |
1895 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1898 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1896 | fclose (fd); | 1899 | fclose (fd); |
1897 | m_password = ""; | 1900 | m_password = ""; |
1898 | 1901 | ||
1899 | if (i < numberOfTries - 1) | 1902 | if (i < numberOfTries - 1) |
1900 | { | 1903 | { |
1901 | switch( QMessageBox::warning( this, tr("ZSafe"), | 1904 | switch( QMessageBox::warning( this, tr("ZSafe"), |
1902 | tr("Wrong password.\nEnter again?"), | 1905 | tr("Wrong password.\nEnter again?"), |
1903 | tr("&Yes"), tr("&No."), | 1906 | tr("&Yes"), tr("&No."), |
1904 | 0 | 1907 | 0 |
1905 | ) ) | 1908 | ) ) |
1906 | { | 1909 | { |
1907 | case 1: // No | 1910 | case 1: // No |
1908 | exitZs (1); | 1911 | exitZs (1); |
1909 | break; | 1912 | break; |
1910 | case 0: // Yes | 1913 | case 0: // Yes |
1911 | continue; | 1914 | continue; |
1912 | } | 1915 | } |
1913 | } | 1916 | } |
1914 | } | 1917 | } |
1915 | if (pwdOk == 0) | 1918 | if (pwdOk == 0) |
1916 | { | 1919 | { |
1917 | // unset the document entry | 1920 | // unset the document entry |
1918 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); | 1921 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); |
1919 | if (conf) | 1922 | if (conf) |
1920 | delete conf; | 1923 | delete conf; |
1921 | 1924 | ||
1922 | exitZs (1); | 1925 | exitZs (1); |
1923 | } | 1926 | } |
1924 | 1927 | ||
1925 | 1928 | ||
1926 | retval = loadEntry(entry); | 1929 | retval = loadEntry(entry); |
1927 | 1930 | ||
1928 | int numberOfEntries=0; | 1931 | int numberOfEntries=0; |
1929 | while (retval == 1) { | 1932 | while (retval == 1) { |
1930 | 1933 | ||
1931 | QString category( QString::fromUtf8(entry[0]) ); | 1934 | QString category( QString::fromUtf8(entry[0]) ); |
1932 | QString name( QString::fromUtf8(entry[1]) ); | 1935 | QString name( QString::fromUtf8(entry[1]) ); |
1933 | QString user( QString::fromUtf8(entry[2]) ); | 1936 | QString user( QString::fromUtf8(entry[2]) ); |
1934 | QString password( QString::fromUtf8(entry[3]) ); | 1937 | QString password( QString::fromUtf8(entry[3]) ); |
1935 | QString comment( QString::fromUtf8(entry[4]) ); | 1938 | QString comment( QString::fromUtf8(entry[4]) ); |
1936 | QString field5( QString::fromUtf8(entry[5]) ); | 1939 | QString field5( QString::fromUtf8(entry[5]) ); |
1937 | QString field6( QString::fromUtf8(entry[6]) ); | 1940 | QString field6( QString::fromUtf8(entry[6]) ); |
1938 | // add the subitems to the categories | 1941 | // add the subitems to the categories |
1939 | 1942 | ||
1940 | Category *cat= categories.find (category); | 1943 | Category *cat= categories.find (category); |
1941 | if (cat) | 1944 | if (cat) |
1942 | { | 1945 | { |
1943 | // use the existend item | 1946 | // use the existend item |
1944 | QListViewItem *catItem = cat->getListItem(); | 1947 | QListViewItem *catItem = cat->getListItem(); |
1945 | if (catItem) | 1948 | if (catItem) |
@@ -1995,280 +1998,280 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1995 | c1->setIconName (icon); | 1998 | c1->setIconName (icon); |
1996 | c1->setIcon (*pix); | 1999 | c1->setIcon (*pix); |
1997 | isIconAv = true; | 2000 | isIconAv = true; |
1998 | } | 2001 | } |
1999 | } | 2002 | } |
2000 | if (!isIconAv) | 2003 | if (!isIconAv) |
2001 | { | 2004 | { |
2002 | c1->setIcon (*getPredefinedIcon(category)); | 2005 | c1->setIcon (*getPredefinedIcon(category)); |
2003 | } | 2006 | } |
2004 | 2007 | ||
2005 | c1->setListItem (catI); | 2008 | c1->setListItem (catI); |
2006 | c1->initListItem(); | 2009 | c1->initListItem(); |
2007 | categories.insert (c1->getCategoryName(), c1); | 2010 | categories.insert (c1->getCategoryName(), c1); |
2008 | numberOfEntries++; | 2011 | numberOfEntries++; |
2009 | } | 2012 | } |
2010 | 2013 | ||
2011 | for (int count = 0; count < FIELD_SIZE; count++) { | 2014 | for (int count = 0; count < FIELD_SIZE; count++) { |
2012 | free(entry[count]); | 2015 | free(entry[count]); |
2013 | } | 2016 | } |
2014 | retval = loadEntry(entry); | 2017 | retval = loadEntry(entry); |
2015 | if (retval == 2) { | 2018 | if (retval == 2) { |
2016 | // m_parent->slotStatusHelpMsg("Last entry loaded"); | 2019 | // m_parent->slotStatusHelpMsg("Last entry loaded"); |
2017 | } | 2020 | } |
2018 | } // end while | 2021 | } // end while |
2019 | 2022 | ||
2020 | if (numberOfEntries == 0) | 2023 | if (numberOfEntries == 0) |
2021 | { | 2024 | { |
2022 | 2025 | ||
2023 | switch( QMessageBox::warning( this, tr("ZSafe"), | 2026 | switch( QMessageBox::warning( this, tr("ZSafe"), |
2024 | tr("Empty document or\nwrong password.\nContinue?"), | 2027 | tr("Empty document or\nwrong password.\nContinue?"), |
2025 | tr("&No"), tr("&Yes."), | 2028 | tr("&No"), tr("&Yes."), |
2026 | 0 | 2029 | 0 |
2027 | ) ) { | 2030 | ) ) { |
2028 | case 0: // No | 2031 | case 0: // No |
2029 | retval = loadFinalize(); | 2032 | retval = loadFinalize(); |
2030 | exitZs (1); | 2033 | exitZs (1); |
2031 | break; | 2034 | break; |
2032 | case 1: // Yes | 2035 | case 1: // Yes |
2033 | break; | 2036 | break; |
2034 | } | 2037 | } |
2035 | } | 2038 | } |
2036 | 2039 | ||
2037 | retval = loadFinalize(); | 2040 | retval = loadFinalize(); |
2038 | 2041 | ||
2039 | return true; | 2042 | return true; |
2040 | } | 2043 | } |
2041 | 2044 | ||
2042 | int ZSafe::loadInit(const char* _filename, const char *password) | 2045 | int ZSafe::loadInit(const char* _filename, const char *password) |
2043 | { | 2046 | { |
2044 | unsigned int j = 0; | 2047 | unsigned int j = 0; |
2045 | unsigned int keylength=0; | 2048 | unsigned int keylength=0; |
2046 | int count=0, count2=0, count3=0; | 2049 | int count=0, count2=0, count3=0; |
2047 | unsigned char charbuf[8]; | 2050 | unsigned char charbuf[8]; |
2048 | unsigned short ciphertext[4]; | 2051 | unsigned short ciphertext[4]; |
2049 | char key[128]; | 2052 | char key[128]; |
2050 | Krc2* krc2 = new Krc2(); | 2053 | Krc2* krc2 = new Krc2(); |
2051 | 2054 | ||
2052 | fd = fopen (_filename, "rb"); | 2055 | fd = fopen (_filename, "rb"); |
2053 | 2056 | ||
2054 | QFileInfo f (_filename); | 2057 | QFileInfo f (_filename); |
2055 | load_buffer_length = f.size(); | 2058 | load_buffer_length = f.size(); |
2056 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; | 2059 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; |
2057 | 2060 | ||
2058 | if (fd == NULL) | 2061 | if (fd == NULL) |
2059 | return PWERR_OPEN; | 2062 | return PWERR_OPEN; |
2060 | 2063 | ||
2061 | buffer = (char *)malloc(load_buffer_length); | 2064 | buffer = (char *)malloc(load_buffer_length); |
2062 | for (j = 0; password[j] != '\0'; j++) { | 2065 | for (j = 0; password[j] != '\0'; j++) { |
2063 | key[j] = password[j]; | 2066 | key[j] = password[j]; |
2064 | } | 2067 | } |
2065 | keylength = j; | 2068 | keylength = j; |
2066 | krc2->rc2_expandkey (key, keylength, 128); | 2069 | krc2->rc2_expandkey (key, keylength, 128); |
2067 | 2070 | ||
2068 | #ifndef WIN32 | 2071 | #ifndef WIN32 |
2069 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); | 2072 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); |
2070 | #else | 2073 | #else |
2071 | printf ("LoadInit() read1"); | 2074 | printf ("LoadInit() read1"); |
2072 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 2075 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
2073 | #endif | 2076 | #endif |
2074 | 2077 | ||
2075 | if (size < 8) | 2078 | if (size < 8) |
2076 | return PWERR_DATA; | 2079 | return PWERR_DATA; |
2077 | 2080 | ||
2078 | for (count = 0; count < 4; count++) { | 2081 | for (count = 0; count < 4; count++) { |
2079 | count2 = count << 1; | 2082 | count2 = count << 1; |
2080 | iv[count] = charbuf[count2] << 8; | 2083 | iv[count] = charbuf[count2] << 8; |
2081 | iv[count] += charbuf[count2 + 1]; | 2084 | iv[count] += charbuf[count2 + 1]; |
2082 | } | 2085 | } |
2083 | 2086 | ||
2084 | size = 0; | 2087 | size = 0; |
2085 | bufferIndex = 0; | 2088 | bufferIndex = 0; |
2086 | #ifndef WIN32 | 2089 | #ifndef WIN32 |
2087 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { | 2090 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { |
2088 | while (count < 8) { | 2091 | while (count < 8) { |
2089 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); | 2092 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); |
2090 | #else | 2093 | #else |
2091 | printf ("LoadInit() read2"); | 2094 | printf ("LoadInit() read2"); |
2092 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { | 2095 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { |
2093 | while (count < 8) { | 2096 | while (count < 8) { |
2094 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 2097 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
2095 | #endif | 2098 | #endif |
2096 | if (count2 == 0) { | 2099 | if (count2 == 0) { |
2097 | return PWERR_DATA; | 2100 | return PWERR_DATA; |
2098 | } | 2101 | } |
2099 | count += count2; | 2102 | count += count2; |
2100 | } /* while (count < 8) */ | 2103 | } /* while (count < 8) */ |
2101 | 2104 | ||
2102 | size += 8; | 2105 | size += 8; |
2103 | for (count2 = 0; count2 < 8; count2 += 2) { | 2106 | for (count2 = 0; count2 < 8; count2 += 2) { |
2104 | count3 = count2 >> 1; | 2107 | count3 = count2 >> 1; |
2105 | ciphertext[count3] = charbuf[count2] << 8; | 2108 | ciphertext[count3] = charbuf[count2] << 8; |
2106 | ciphertext[count3] += charbuf[count2 + 1]; | 2109 | ciphertext[count3] += charbuf[count2 + 1]; |
2107 | 2110 | ||
2108 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; | 2111 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; |
2109 | iv[count3] = plaintext[count3]; | 2112 | iv[count3] = plaintext[count3]; |
2110 | } /* for (count2) */ | 2113 | } /* for (count2) */ |
2111 | 2114 | ||
2112 | krc2->rc2_decrypt (plaintext); | 2115 | krc2->rc2_decrypt (plaintext); |
2113 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); | 2116 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); |
2114 | bufferIndex += 8; | 2117 | bufferIndex += 8; |
2115 | buffer[bufferIndex + 1] = '\0'; | 2118 | buffer[bufferIndex + 1] = '\0'; |
2116 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ | 2119 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ |
2117 | size -= buffer[size - 1]; | 2120 | size -= buffer[size - 1]; |
2118 | lastcount = 0; | 2121 | lastcount = 0; |
2119 | 2122 | ||
2120 | /* This will point to the starting index */ | 2123 | /* This will point to the starting index */ |
2121 | bufferIndex = 0; | 2124 | bufferIndex = 0; |
2122 | return PWERR_GOOD; | 2125 | return PWERR_GOOD; |
2123 | } | 2126 | } |
2124 | 2127 | ||
2125 | int ZSafe::loadEntry(char *entry[FIELD_SIZE]) | 2128 | int ZSafe::loadEntry(char *entry[FIELD_SIZE]) |
2126 | { | 2129 | { |
2127 | /* Strip off PKCS 5 padding | 2130 | /* Strip off PKCS 5 padding |
2128 | * Should check to make sure it's good here | 2131 | * Should check to make sure it's good here |
2129 | */ | 2132 | */ |
2130 | int count, count1=0; | 2133 | int count, count1=0; |
2131 | 2134 | ||
2132 | for (count = lastcount; count < size; count++) { | 2135 | for (count = lastcount; count < size; count++) { |
2133 | if ((unsigned char) (buffer[count]) == 255) { | 2136 | if ((unsigned char) (buffer[count]) == 255) { |
2134 | if (buffer[bufferIndex] == '\0') { | 2137 | if (buffer[bufferIndex] == '\0') { |
2135 | bufferIndex++; | 2138 | bufferIndex++; |
2136 | } | 2139 | } |
2137 | entry[count1] = (char *) malloc (count - bufferIndex + 1); | 2140 | entry[count1] = (char *) malloc (count - bufferIndex + 1); |
2138 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); | 2141 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); |
2139 | entry[count1][count - bufferIndex] = '\0'; | 2142 | entry[count1][count - bufferIndex] = '\0'; |
2140 | count++; | 2143 | count++; |
2141 | bufferIndex = count; | 2144 | bufferIndex = count; |
2142 | count1++; | 2145 | count1++; |
2143 | if (count1 == FIELD_SIZE) { | 2146 | if (count1 == FIELD_SIZE) { |
2144 | lastcount = count; | 2147 | lastcount = count; |
2145 | return 1; | 2148 | return 1; |
2146 | } | 2149 | } |
2147 | } /* if ((unsigned char) (buffer[count]) == 255) */ | 2150 | } /* if ((unsigned char) (buffer[count]) == 255) */ |
2148 | } /* for (count = 0; count < size; count++) */ | 2151 | } /* for (count = 0; count < size; count++) */ |
2149 | 2152 | ||
2150 | return 2; | 2153 | return 2; |
2151 | } | 2154 | } |
2152 | 2155 | ||
2153 | int ZSafe::loadFinalize(void) | 2156 | int ZSafe::loadFinalize(void) |
2154 | { | 2157 | { |
2155 | fclose (fd); | 2158 | fclose (fd); |
2156 | if (buffer) free(buffer); | 2159 | if (buffer) free(buffer); |
2157 | return PWERR_GOOD; | 2160 | return PWERR_GOOD; |
2158 | } | 2161 | } |
2159 | 2162 | ||
2160 | bool ZSafe::saveDocument(const char* _filename, | 2163 | bool ZSafe::saveDocument(const char* _filename, |
2161 | bool withPwd, | 2164 | bool withPwd, |
2162 | const char* ) | 2165 | const char* ) |
2163 | { | 2166 | { |
2164 | if (filename.isEmpty()) | 2167 | if (filename.isEmpty()) |
2165 | { | 2168 | { |
2166 | QMessageBox::critical( 0, tr("ZSafe"), | 2169 | QMessageBox::critical( 0, tr("ZSafe"), |
2167 | tr("No document defined.\nYou have to create a new document")); | 2170 | tr("No document defined.\nYou have to create a new document")); |
2168 | return false; | 2171 | return false; |
2169 | } | 2172 | } |
2170 | 2173 | ||
2171 | // if (m_password.isEmpty()) | 2174 | // if (m_password.isEmpty()) |
2172 | // withPwd = true; // the document must be saved with a valid password | 2175 | // withPwd = true; // the document must be saved with a valid password |
2173 | if (withPwd) | 2176 | if (withPwd) |
2174 | { | 2177 | { |
2175 | bool pwdOk = FALSE; | 2178 | bool pwdOk = FALSE; |
2176 | while (!pwdOk) | 2179 | while (!pwdOk) |
2177 | { | 2180 | { |
2178 | getDocPassword(tr("Enter Password")); | 2181 | getDocPassword(tr("Enter Password")); |
2179 | if (m_password.isEmpty()) | 2182 | if (m_password.isEmpty()) |
2180 | { | 2183 | { |
2181 | 2184 | ||
2182 | QMessageBox::critical( 0, tr("ZSafe"), | 2185 | QMessageBox::critical( 0, tr("ZSafe"), |
2183 | tr("Password is empty.\nPlease enter again.")); | 2186 | tr("Password is empty.\nPlease enter again.")); |
2184 | continue; | 2187 | continue; |
2185 | } | 2188 | } |
2186 | 2189 | ||
2187 | QString firstPasswd = m_password; | 2190 | QString firstPasswd = m_password; |
2188 | 2191 | ||
2189 | getDocPassword(tr("Reenter Password")); | 2192 | getDocPassword(tr("Reenter Password")); |
2190 | if (m_password.isEmpty()) | 2193 | if (m_password.isEmpty()) |
2191 | { | 2194 | { |
2192 | QMessageBox::critical( 0, tr("ZSafe"), | 2195 | QMessageBox::critical( 0, tr("ZSafe"), |
2193 | tr("Password is empty.\nPlease enter again.")); | 2196 | tr("Password is empty.\nPlease enter again.")); |
2194 | continue; | 2197 | continue; |
2195 | } | 2198 | } |
2196 | if (firstPasswd != m_password) | 2199 | if (firstPasswd != m_password) |
2197 | { | 2200 | { |
2198 | 2201 | ||
2199 | QMessageBox::critical( 0, tr("ZSafe"), | 2202 | QMessageBox::critical( 0, tr("ZSafe"), |
2200 | tr("Passwords must be identical.\nPlease enter again.")); | 2203 | tr("Passwords must be identical.\nPlease enter again.")); |
2201 | continue; | 2204 | continue; |
2202 | } | 2205 | } |
2203 | pwdOk = TRUE; | 2206 | pwdOk = TRUE; |
2204 | modified = false; | 2207 | modified = false; |
2205 | } | 2208 | } |
2206 | } | 2209 | } |
2207 | else if (modified) | 2210 | else if (modified) |
2208 | { | 2211 | { |
2209 | QString fns(_filename); | 2212 | QString fns(_filename); |
2210 | fns = fns.right (fns.length() - fns.findRev ('/') - 1); | 2213 | fns = fns.right (fns.length() - fns.findRev ('/') - 1); |
2211 | switch( QMessageBox::information( this, tr("ZSafe"), | 2214 | switch( QMessageBox::information( this, tr("ZSafe"), |
2212 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), | 2215 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), |
2213 | tr("&Save"), | 2216 | tr("&Save"), |
2214 | tr("&Don't Save"), | 2217 | tr("&Don't Save"), |
2215 | 0 // Enter == button 0 | 2218 | 0 // Enter == button 0 |
2216 | ) ) | 2219 | ) ) |
2217 | { // Escape == button 2 | 2220 | { // Escape == button 2 |
2218 | case 0: // Save clicked, Alt-S or Enter pressed. | 2221 | case 0: // Save clicked, Alt-S or Enter pressed. |
2219 | modified = false; | 2222 | modified = false; |
2220 | break; | 2223 | break; |
2221 | case 1: // Don't Save clicked or Alt-D pressed | 2224 | case 1: // Don't Save clicked or Alt-D pressed |
2222 | modified = false; | 2225 | modified = false; |
2223 | return true; | 2226 | return true; |
2224 | } | 2227 | } |
2225 | } | 2228 | } |
2226 | modified = false; | 2229 | modified = false; |
2227 | 2230 | ||
2228 | if (m_password.isEmpty()) | 2231 | if (m_password.isEmpty()) |
2229 | return false; | 2232 | return false; |
2230 | 2233 | ||
2231 | int retval = saveInit(_filename, m_password); | 2234 | int retval = saveInit(_filename, m_password); |
2232 | // int retval = saveInit(_filename, "test"); | 2235 | // int retval = saveInit(_filename, "test"); |
2233 | if (retval != PWERR_GOOD) { | 2236 | if (retval != PWERR_GOOD) { |
2234 | return false; | 2237 | return false; |
2235 | } | 2238 | } |
2236 | 2239 | ||
2237 | char* entry[FIELD_SIZE]; | 2240 | char* entry[FIELD_SIZE]; |
2238 | 2241 | ||
2239 | // save the validation entry | 2242 | // save the validation entry |
2240 | { | 2243 | { |
2241 | int i=0; | 2244 | int i=0; |
2242 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); | 2245 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); |
2243 | strcpy(entry[i++], "ZSAFECATEGORY"); | 2246 | strcpy(entry[i++], "ZSAFECATEGORY"); |
2244 | entry[i] = (char*)malloc(strlen("name")+1); | 2247 | entry[i] = (char*)malloc(strlen("name")+1); |
2245 | strcpy(entry[i++], "name"); | 2248 | strcpy(entry[i++], "name"); |
2246 | entry[i] = (char*)malloc(strlen("username")+1); | 2249 | entry[i] = (char*)malloc(strlen("username")+1); |
2247 | strcpy(entry[i++], "username"); | 2250 | strcpy(entry[i++], "username"); |
2248 | entry[i] = (char*)malloc(strlen("password")+1); | 2251 | entry[i] = (char*)malloc(strlen("password")+1); |
2249 | strcpy(entry[i++], "password"); | 2252 | strcpy(entry[i++], "password"); |
2250 | entry[i] = (char*)malloc(strlen("comment")+1); | 2253 | entry[i] = (char*)malloc(strlen("comment")+1); |
2251 | strcpy(entry[i++], "comment"); | 2254 | strcpy(entry[i++], "comment"); |
2252 | 2255 | ||
2253 | entry[i] = (char*)malloc(strlen("field5")+1); | 2256 | entry[i] = (char*)malloc(strlen("field5")+1); |
2254 | strcpy(entry[i++], "field5"); | 2257 | strcpy(entry[i++], "field5"); |
2255 | entry[i] = (char*)malloc(strlen("field6")+1); | 2258 | entry[i] = (char*)malloc(strlen("field6")+1); |
2256 | strcpy(entry[i++], "field6"); | 2259 | strcpy(entry[i++], "field6"); |
2257 | 2260 | ||
2258 | retval = saveEntry(entry); | 2261 | retval = saveEntry(entry); |
2259 | for (int z=0; z<i; z++) free(entry[z]); | 2262 | for (int z=0; z<i; z++) free(entry[z]); |
2260 | if (retval == PWERR_DATA) { | 2263 | if (retval == PWERR_DATA) { |
2261 | qWarning("1: Error writing file, contents not saved"); | 2264 | qWarning("1: Error writing file, contents not saved"); |
2262 | saveFinalize(); | 2265 | saveFinalize(); |
2263 | return false; | 2266 | return false; |
2264 | } | 2267 | } |
2265 | // #ifndef WIN32 | 2268 | // #ifndef WIN32 |
2266 | conf->writeEntry(APP_KEY+"valzsafe", 1); | 2269 | conf->writeEntry(APP_KEY+"valzsafe", 1); |
2267 | // #endif | 2270 | // #endif |
2268 | saveConf(); | 2271 | saveConf(); |
2269 | } | 2272 | } |
2270 | 2273 | ||
2271 | QListViewItem *i; | 2274 | QListViewItem *i; |
2272 | // step through all categories | 2275 | // step through all categories |
2273 | for (i = ListView->firstChild(); | 2276 | for (i = ListView->firstChild(); |
2274 | i != NULL; | 2277 | i != NULL; |
@@ -2283,56 +2286,56 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2283 | int j=0; | 2286 | int j=0; |
2284 | entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); | 2287 | entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); |
2285 | strcpy(entry[j++], i->text(0).utf8()); | 2288 | strcpy(entry[j++], i->text(0).utf8()); |
2286 | entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); | 2289 | entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); |
2287 | strcpy(entry[j++], si->text(0).utf8()); | 2290 | strcpy(entry[j++], si->text(0).utf8()); |
2288 | entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); | 2291 | entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); |
2289 | strcpy(entry[j++], si->text(1).utf8()); | 2292 | strcpy(entry[j++], si->text(1).utf8()); |
2290 | entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); | 2293 | entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); |
2291 | strcpy(entry[j++], si->text(2).utf8()); | 2294 | strcpy(entry[j++], si->text(2).utf8()); |
2292 | entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); | 2295 | entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); |
2293 | strcpy(entry[j++], si->text(3).utf8()); | 2296 | strcpy(entry[j++], si->text(3).utf8()); |
2294 | entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); | 2297 | entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); |
2295 | strcpy(entry[j++], si->text(4).utf8()); | 2298 | strcpy(entry[j++], si->text(4).utf8()); |
2296 | entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); | 2299 | entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); |
2297 | strcpy(entry[j++], si->text(5).utf8()); | 2300 | strcpy(entry[j++], si->text(5).utf8()); |
2298 | 2301 | ||
2299 | retval = saveEntry(entry); | 2302 | retval = saveEntry(entry); |
2300 | for (int z=0; z<j; z++) | 2303 | for (int z=0; z<j; z++) |
2301 | { | 2304 | { |
2302 | free(entry[z]); | 2305 | free(entry[z]); |
2303 | } | 2306 | } |
2304 | if (retval == PWERR_DATA) { | 2307 | if (retval == PWERR_DATA) { |
2305 | qWarning("1: Error writing file, contents not saved"); | 2308 | qWarning("1: Error writing file, contents not saved"); |
2306 | saveFinalize(); | 2309 | saveFinalize(); |
2307 | return false; | 2310 | return false; |
2308 | } | 2311 | } |
2309 | 2312 | ||
2310 | } | 2313 | } |
2311 | } | 2314 | } |
2312 | 2315 | ||
2313 | if (saveFinalize() == PWERR_DATA) { | 2316 | if (saveFinalize() == PWERR_DATA) { |
2314 | qWarning("2: Error writing file, contents not saved"); | 2317 | qWarning("2: Error writing file, contents not saved"); |
2315 | return false; | 2318 | return false; |
2316 | } else { | 2319 | } else { |
2317 | #ifndef DESKTOP | 2320 | #ifndef DESKTOP |
2318 | Global::statusMessage (tr("Password file saved.")); | 2321 | Global::statusMessage (tr("Password file saved.")); |
2319 | #endif | 2322 | #endif |
2320 | modified = false; | 2323 | modified = false; |
2321 | return true; | 2324 | return true; |
2322 | } | 2325 | } |
2323 | } | 2326 | } |
2324 | 2327 | ||
2325 | PasswordForm *newPwdDialog; | 2328 | PasswordForm *newPwdDialog; |
2326 | bool newPwdDialogResult = false; | 2329 | bool newPwdDialogResult = false; |
2327 | void ZSafe::setPasswordDialogDone() | 2330 | void ZSafe::setPasswordDialogDone() |
2328 | { | 2331 | { |
2329 | newPwdDialogResult = true; | 2332 | newPwdDialogResult = true; |
2330 | newPwdDialog->close(); | 2333 | newPwdDialog->close(); |
2331 | } | 2334 | } |
2332 | 2335 | ||
2333 | void ZSafe::getDocPassword(QString title) | 2336 | void ZSafe::getDocPassword(QString title) |
2334 | { | 2337 | { |
2335 | qWarning ("getDocPassword"); | 2338 | qWarning ("getDocPassword"); |
2336 | // open the 'Password' dialog | 2339 | // open the 'Password' dialog |
2337 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); | 2340 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); |
2338 | newPwdDialog = dialog; | 2341 | newPwdDialog = dialog; |
@@ -2357,192 +2360,192 @@ qWarning ("getDocPassword"); | |||
2357 | result = Accepted; | 2360 | result = Accepted; |
2358 | #endif | 2361 | #endif |
2359 | 2362 | ||
2360 | QString password; | 2363 | QString password; |
2361 | if (result == Accepted || newPwdDialogResult) | 2364 | if (result == Accepted || newPwdDialogResult) |
2362 | { | 2365 | { |
2363 | m_password = dialog->PasswordField->text(); | 2366 | m_password = dialog->PasswordField->text(); |
2364 | } | 2367 | } |
2365 | else | 2368 | else |
2366 | { | 2369 | { |
2367 | exitZs (1); | 2370 | exitZs (1); |
2368 | } | 2371 | } |
2369 | } | 2372 | } |
2370 | 2373 | ||
2371 | int ZSafe::saveInit(const char *_filename, const char *password) | 2374 | int ZSafe::saveInit(const char *_filename, const char *password) |
2372 | { | 2375 | { |
2373 | char key[128]; | 2376 | char key[128]; |
2374 | unsigned int j = 0; | 2377 | unsigned int j = 0; |
2375 | unsigned int keylength; | 2378 | unsigned int keylength; |
2376 | // int val; | 2379 | // int val; |
2377 | int count2; | 2380 | int count2; |
2378 | Krc2* krc2 = new Krc2(); | 2381 | Krc2* krc2 = new Krc2(); |
2379 | 2382 | ||
2380 | /* first we should check the permissions of the filename */ | 2383 | /* first we should check the permissions of the filename */ |
2381 | /* | 2384 | /* |
2382 | if (QFile::exists(_filename)) { | 2385 | if (QFile::exists(_filename)) { |
2383 | val = checkFile(_filename); | 2386 | val = checkFile(_filename); |
2384 | if (val != PWERR_GOOD) | 2387 | if (val != PWERR_GOOD) |
2385 | return val; | 2388 | return val; |
2386 | } else | 2389 | } else |
2387 | { | 2390 | { |
2388 | val = creat (_filename, (S_IRUSR | S_IWUSR)); | 2391 | val = creat (_filename, (S_IRUSR | S_IWUSR)); |
2389 | if (val == -1) | 2392 | if (val == -1) |
2390 | return PWERR_OPEN; | 2393 | return PWERR_OPEN; |
2391 | else | 2394 | else |
2392 | close(val); | 2395 | close(val); |
2393 | } | 2396 | } |
2394 | */ | 2397 | */ |
2395 | QFileInfo f (_filename); | 2398 | QFileInfo f (_filename); |
2396 | save_buffer_length = f.size(); | 2399 | save_buffer_length = f.size(); |
2397 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; | 2400 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; |
2398 | 2401 | ||
2399 | fd = fopen (_filename, "wb"); | 2402 | fd = fopen (_filename, "wb"); |
2400 | if (fd == NULL) | 2403 | if (fd == NULL) |
2401 | return PWERR_OPEN; | 2404 | return PWERR_OPEN; |
2402 | 2405 | ||
2403 | buffer = (char*)malloc(save_buffer_length); | 2406 | buffer = (char*)malloc(save_buffer_length); |
2404 | 2407 | ||
2405 | /* make the key ready */ | 2408 | /* make the key ready */ |
2406 | for (j = 0; password[j] != '\0'; j++) { | 2409 | for (j = 0; password[j] != '\0'; j++) { |
2407 | key[j] = password[j]; | 2410 | key[j] = password[j]; |
2408 | } | 2411 | } |
2409 | keylength = j; | 2412 | keylength = j; |
2410 | krc2->rc2_expandkey (key, keylength, 128); | 2413 | krc2->rc2_expandkey (key, keylength, 128); |
2411 | 2414 | ||
2412 | /* First, we make the IV */ | 2415 | /* First, we make the IV */ |
2413 | for (count2 = 0; count2 < 4; count2++) { | 2416 | for (count2 = 0; count2 < 4; count2++) { |
2414 | iv[count2] = rand (); | 2417 | iv[count2] = rand (); |
2415 | putc ((unsigned char) (iv[count2] >> 8), fd); | 2418 | putc ((unsigned char) (iv[count2] >> 8), fd); |
2416 | putc ((unsigned char) (iv[count2] & 0xff), fd); | 2419 | putc ((unsigned char) (iv[count2] & 0xff), fd); |
2417 | } | 2420 | } |
2418 | 2421 | ||
2419 | bufferIndex = 0; | 2422 | bufferIndex = 0; |
2420 | return PWERR_GOOD; | 2423 | return PWERR_GOOD; |
2421 | } | 2424 | } |
2422 | 2425 | ||
2423 | 2426 | ||
2424 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) | 2427 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) |
2425 | { | 2428 | { |
2426 | char *text1; | 2429 | char *text1; |
2427 | int count2, count3; | 2430 | int count2, count3; |
2428 | unsigned short ciphertext[4]; | 2431 | unsigned short ciphertext[4]; |
2429 | Krc2* krc2 = new Krc2(); | 2432 | Krc2* krc2 = new Krc2(); |
2430 | 2433 | ||
2431 | buffer = (char*)memset(buffer, '\0', save_buffer_length); | 2434 | buffer = (char*)memset(buffer, '\0', save_buffer_length); |
2432 | 2435 | ||
2433 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { | 2436 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { |
2434 | text1 = entry[count2]; | 2437 | text1 = entry[count2]; |
2435 | if (strlen (text1) == 0) { | 2438 | if (strlen (text1) == 0) { |
2436 | strncat(buffer, " ", strlen(" ")); | 2439 | strncat(buffer, " ", strlen(" ")); |
2437 | } else { | 2440 | } else { |
2438 | strncat(buffer, text1, strlen(text1)); | 2441 | strncat(buffer, text1, strlen(text1)); |
2439 | } | 2442 | } |
2440 | /* Use 255 as the marker. \n is too tough to test for */ | 2443 | /* Use 255 as the marker. \n is too tough to test for */ |
2441 | buffer[strlen (buffer)] = 255; | 2444 | buffer[strlen (buffer)] = 255; |
2442 | } /*for (count2 = 0; count2 < 5; count2++)*/ | 2445 | } /*for (count2 = 0; count2 < 5; count2++)*/ |
2443 | count2 = 0; | 2446 | count2 = 0; |
2444 | /* I'm using CBC mode and encrypting the data straight from top down. | 2447 | /* I'm using CBC mode and encrypting the data straight from top down. |
2445 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. | 2448 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. |
2446 | * PKCS 5 padding (explained at the code section | 2449 | * PKCS 5 padding (explained at the code section |
2447 | */ | 2450 | */ |
2448 | while (count2 < (int)strlen (buffer)) { | 2451 | while (count2 < (int)strlen (buffer)) { |
2449 | #ifndef WORDS_BIGENDIAN | 2452 | #ifndef WORDS_BIGENDIAN |
2450 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; | 2453 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; |
2451 | plaintext[bufferIndex] += buffer[count2] & 0xff; | 2454 | plaintext[bufferIndex] += buffer[count2] & 0xff; |
2452 | #endif | 2455 | #endif |
2453 | #ifdef WORDS_BIGENDIAN | 2456 | #ifdef WORDS_BIGENDIAN |
2454 | plaintext[bufferIndex] = buffer[count2] << 8; | 2457 | plaintext[bufferIndex] = buffer[count2] << 8; |
2455 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; | 2458 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; |
2456 | #endif | 2459 | #endif |
2457 | bufferIndex++; | 2460 | bufferIndex++; |
2458 | if (bufferIndex == 4) { | 2461 | if (bufferIndex == 4) { |
2459 | krc2->rc2_encrypt (plaintext); | 2462 | krc2->rc2_encrypt (plaintext); |
2460 | 2463 | ||
2461 | for (count3 = 0; count3 < 4; count3++) { | 2464 | for (count3 = 0; count3 < 4; count3++) { |
2462 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; | 2465 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; |
2463 | 2466 | ||
2464 | /* Now store the ciphertext as the iv */ | 2467 | /* Now store the ciphertext as the iv */ |
2465 | iv[count3] = plaintext[count3]; | 2468 | iv[count3] = plaintext[count3]; |
2466 | 2469 | ||
2467 | /* reset the buffer index */ | 2470 | /* reset the buffer index */ |
2468 | bufferIndex = 0; | 2471 | bufferIndex = 0; |
2469 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; | 2472 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; |
2470 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; | 2473 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; |
2471 | } /*for (count3 = 0; count3 < 5; count3++)*/ | 2474 | } /*for (count3 = 0; count3 < 5; count3++)*/ |
2472 | } /*if (bufferIndex == 5)*/ | 2475 | } /*if (bufferIndex == 5)*/ |
2473 | /* increment a short, not a byte */ | 2476 | /* increment a short, not a byte */ |
2474 | count2 += 2; | 2477 | count2 += 2; |
2475 | } /*while (count2 < strlen (buffer))*/ | 2478 | } /*while (count2 < strlen (buffer))*/ |
2476 | int ret = PWERR_GOOD; | 2479 | int ret = PWERR_GOOD; |
2477 | return ret; | 2480 | return ret; |
2478 | } | 2481 | } |
2479 | 2482 | ||
2480 | int ZSafe::saveFinalize(void) | 2483 | int ZSafe::saveFinalize(void) |
2481 | { | 2484 | { |
2482 | int count1, retval = PWERR_GOOD; | 2485 | int count1, retval = PWERR_GOOD; |
2483 | unsigned short ciphertext[4]; | 2486 | unsigned short ciphertext[4]; |
2484 | Krc2* krc2 = new Krc2(); | 2487 | Krc2* krc2 = new Krc2(); |
2485 | 2488 | ||
2486 | /* Tack on the PKCS 5 padding | 2489 | /* Tack on the PKCS 5 padding |
2487 | * How it works is we fill up the last n bytes with the value n | 2490 | * How it works is we fill up the last n bytes with the value n |
2488 | * | 2491 | * |
2489 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left | 2492 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left |
2490 | * over, leaving us 3 short, so we fill it in with 3's. | 2493 | * over, leaving us 3 short, so we fill it in with 3's. |
2491 | * | 2494 | * |
2492 | * If we come out even, we fill it with 8 8s | 2495 | * If we come out even, we fill it with 8 8s |
2493 | * | 2496 | * |
2494 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. | 2497 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. |
2495 | * so, half everything | 2498 | * so, half everything |
2496 | */ | 2499 | */ |
2497 | for (count1 = bufferIndex; count1 < 4; count1++) { | 2500 | for (count1 = bufferIndex; count1 < 4; count1++) { |
2498 | plaintext[count1] = (4 - bufferIndex); | 2501 | plaintext[count1] = (4 - bufferIndex); |
2499 | } | 2502 | } |
2500 | krc2->rc2_encrypt (plaintext); | 2503 | krc2->rc2_encrypt (plaintext); |
2501 | for (count1 = 0; count1 < 4; count1++) { | 2504 | for (count1 = 0; count1 < 4; count1++) { |
2502 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; | 2505 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; |
2503 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; | 2506 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; |
2504 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; | 2507 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; |
2505 | } | 2508 | } |
2506 | 2509 | ||
2507 | fclose (fd); | 2510 | fclose (fd); |
2508 | free(buffer); | 2511 | free(buffer); |
2509 | return retval; | 2512 | return retval; |
2510 | } | 2513 | } |
2511 | 2514 | ||
2512 | void ZSafe::quitMe () | 2515 | void ZSafe::quitMe () |
2513 | { | 2516 | { |
2514 | qWarning ("QUIT..."); | 2517 | qWarning ("QUIT..."); |
2515 | 2518 | ||
2516 | if (modified) | 2519 | if (modified) |
2517 | { | 2520 | { |
2518 | switch( QMessageBox::information( this, tr("ZSafe"), | 2521 | switch( QMessageBox::information( this, tr("ZSafe"), |
2519 | tr("Do you want to save\nbefore exiting?"), | 2522 | tr("Do you want to save\nbefore exiting?"), |
2520 | tr("&Save"), | 2523 | tr("&Save"), |
2521 | tr("S&ave with\nnew\npassword"), | 2524 | tr("S&ave with\nnew\npassword"), |
2522 | tr("&Don't Save"), | 2525 | tr("&Don't Save"), |
2523 | 0 // Enter == button 0 | 2526 | 0 // Enter == button 0 |
2524 | ) ) | 2527 | ) ) |
2525 | { // Escape == button 2 | 2528 | { // Escape == button 2 |
2526 | case 0: // Save clicked, Alt-S or Enter pressed. | 2529 | case 0: // Save clicked, Alt-S or Enter pressed. |
2527 | // save | 2530 | // save |
2528 | modified = false; | 2531 | modified = false; |
2529 | saveDocument(filename, FALSE); | 2532 | saveDocument(filename, FALSE); |
2530 | exitZs (1); | 2533 | exitZs (1); |
2531 | break; | 2534 | break; |
2532 | case 1: // | 2535 | case 1: // |
2533 | // Save with new password | 2536 | // Save with new password |
2534 | modified = false; | 2537 | modified = false; |
2535 | saveDocument(filename, TRUE); | 2538 | saveDocument(filename, TRUE); |
2536 | exitZs (1); | 2539 | exitZs (1); |
2537 | break; | 2540 | break; |
2538 | case 2: // Don't Save clicked or Alt-D pressed | 2541 | case 2: // Don't Save clicked or Alt-D pressed |
2539 | // don't save but exitZs | 2542 | // don't save but exitZs |
2540 | exitZs (1); | 2543 | exitZs (1); |
2541 | break; | 2544 | break; |
2542 | } | 2545 | } |
2543 | } | 2546 | } |
2544 | exitZs (1); | 2547 | exitZs (1); |
2545 | 2548 | ||
2546 | } | 2549 | } |
2547 | 2550 | ||
2548 | void ZSafe::categoryFieldActivated( const QString& category) | 2551 | void ZSafe::categoryFieldActivated( const QString& category) |
@@ -2563,150 +2566,150 @@ void ZSafe::addCategory() | |||
2563 | { | 2566 | { |
2564 | // open the 'Category' dialog | 2567 | // open the 'Category' dialog |
2565 | bool initIcons = false; | 2568 | bool initIcons = false; |
2566 | // open the 'Category' dialog | 2569 | // open the 'Category' dialog |
2567 | CategoryDialog *dialog; | 2570 | CategoryDialog *dialog; |
2568 | if (categoryDialog) | 2571 | if (categoryDialog) |
2569 | { | 2572 | { |
2570 | dialog = categoryDialog; | 2573 | dialog = categoryDialog; |
2571 | } | 2574 | } |
2572 | else | 2575 | else |
2573 | { | 2576 | { |
2574 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2577 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2575 | #ifdef WIN32 | 2578 | #ifdef WIN32 |
2576 | categoryDialog->setCaption ("Qt " + tr("Category")); | 2579 | categoryDialog->setCaption ("Qt " + tr("Category")); |
2577 | #endif | 2580 | #endif |
2578 | dialog = categoryDialog; | 2581 | dialog = categoryDialog; |
2579 | connect( dialog->CategoryField, | 2582 | connect( dialog->CategoryField, |
2580 | SIGNAL( activated ( const QString &)), | 2583 | SIGNAL( activated ( const QString &)), |
2581 | this, SLOT( categoryFieldActivated( const QString & ) ) ); | 2584 | this, SLOT( categoryFieldActivated( const QString & ) ) ); |
2582 | initIcons = true; | 2585 | initIcons = true; |
2583 | } | 2586 | } |
2584 | 2587 | ||
2585 | #ifdef DESKTOP | 2588 | #ifdef DESKTOP |
2586 | #ifndef WIN32 | 2589 | #ifndef WIN32 |
2587 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 2590 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
2588 | #else | 2591 | #else |
2589 | // read all categories from the config file and store | 2592 | // read all categories from the config file and store |
2590 | // into a list | 2593 | // into a list |
2591 | QFile f (cfgFile); | 2594 | QFile f (cfgFile); |
2592 | QStringList list; | 2595 | QStringList list; |
2593 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2596 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2594 | QTextStream t( &f ); // use a text stream | 2597 | QTextStream t( &f ); // use a text stream |
2595 | QString s; | 2598 | QString s; |
2596 | int n = 1; | 2599 | int n = 1; |
2597 | while ( !t.eof() ) { // until end of file... | 2600 | while ( !t.eof() ) { // until end of file... |
2598 | s = t.readLine(); // line of text excluding '\n' | 2601 | s = t.readLine(); // line of text excluding '\n' |
2599 | list.append(s); | 2602 | list.append(s); |
2600 | } | 2603 | } |
2601 | f.close(); | 2604 | f.close(); |
2602 | } | 2605 | } |
2603 | #endif | 2606 | #endif |
2604 | #else | 2607 | #else |
2605 | // read all categories from the config file and store | 2608 | // read all categories from the config file and store |
2606 | // into a list | 2609 | // into a list |
2607 | QFile f (cfgFile); | 2610 | QFile f (cfgFile); |
2608 | QStringList list; | 2611 | QStringList list; |
2609 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2612 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2610 | QTextStream t( &f ); // use a text stream | 2613 | QTextStream t( &f ); // use a text stream |
2611 | QString s; | 2614 | QString s; |
2612 | while ( !t.eof() ) { // until end of file... | 2615 | while ( !t.eof() ) { // until end of file... |
2613 | s = t.readLine(); // line of text excluding '\n' | 2616 | s = t.readLine(); // line of text excluding '\n' |
2614 | list.append(s); | 2617 | list.append(s); |
2615 | } | 2618 | } |
2616 | f.close(); | 2619 | f.close(); |
2617 | } | 2620 | } |
2618 | #endif | 2621 | #endif |
2619 | QStringList::Iterator it = list.begin(); | 2622 | QStringList::Iterator it = list.begin(); |
2620 | QString categ; | 2623 | QString categ; |
2621 | QString firstCategory; | 2624 | QString firstCategory; |
2622 | dialog->CategoryField->clear(); // remove all items | 2625 | dialog->CategoryField->clear(); // remove all items |
2623 | while( it != list.end() ) | 2626 | while( it != list.end() ) |
2624 | { | 2627 | { |
2625 | QString *cat = new QString (*it); | 2628 | QString *cat = new QString (*it); |
2626 | if (cat->contains("-field1", FALSE)) | 2629 | if (cat->contains("-field1", FALSE)) |
2627 | { | 2630 | { |
2628 | #ifdef DESKTOP | 2631 | #ifdef DESKTOP |
2629 | #ifndef WIN32 | 2632 | #ifndef WIN32 |
2630 | categ = cat->section ("-field1", 0, 0); | 2633 | categ = cat->section ("-field1", 0, 0); |
2631 | #else | 2634 | #else |
2632 | int pos = cat->find ("-field1"); | 2635 | int pos = cat->find ("-field1"); |
2633 | categ = cat->left (pos); | 2636 | categ = cat->left (pos); |
2634 | #endif | 2637 | #endif |
2635 | #else | 2638 | #else |
2636 | int pos = cat->find ("-field1"); | 2639 | int pos = cat->find ("-field1"); |
2637 | cat->truncate(pos); | 2640 | cat->truncate(pos); |
2638 | categ = *cat; | 2641 | categ = *cat; |
2639 | #endif | 2642 | #endif |
2640 | if (!categ.isEmpty()) | 2643 | if (!categ.isEmpty()) |
2641 | { | 2644 | { |
2642 | dialog->CategoryField->insertItem (categ, -1); | 2645 | dialog->CategoryField->insertItem (categ, -1); |
2643 | if (firstCategory.isEmpty()) | 2646 | if (firstCategory.isEmpty()) |
2644 | firstCategory = categ; | 2647 | firstCategory = categ; |
2645 | } | 2648 | } |
2646 | } | 2649 | } |
2647 | ++it; | 2650 | ++it; |
2648 | } | 2651 | } |
2649 | 2652 | ||
2650 | 2653 | ||
2651 | if (firstCategory.isEmpty()) | 2654 | if (firstCategory.isEmpty()) |
2652 | setCategoryDialogFields(dialog); | 2655 | setCategoryDialogFields(dialog); |
2653 | else | 2656 | else |
2654 | setCategoryDialogFields(dialog, firstCategory); | 2657 | setCategoryDialogFields(dialog, firstCategory); |
2655 | 2658 | ||
2656 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); | 2659 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); |
2657 | 2660 | ||
2658 | if (initIcons) | 2661 | if (initIcons) |
2659 | { | 2662 | { |
2660 | Wait waitDialog(this, tr("Wait dialog")); | 2663 | Wait waitDialog(this, tr("Wait dialog")); |
2661 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2664 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
2662 | waitDialog.show(); | 2665 | waitDialog.show(); |
2663 | qApp->processEvents(); | 2666 | qApp->processEvents(); |
2664 | 2667 | ||
2665 | #ifdef DESKTOP | 2668 | #ifdef DESKTOP |
2666 | QDir d(iconPath); | 2669 | QDir d(iconPath); |
2667 | #else | 2670 | #else |
2668 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2671 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2669 | #endif | 2672 | #endif |
2670 | d.setFilter( QDir::Files); | 2673 | d.setFilter( QDir::Files); |
2671 | 2674 | ||
2672 | const QFileInfoList *list = d.entryInfoList(); | 2675 | const QFileInfoList *list = d.entryInfoList(); |
2673 | QFileInfoListIterator it( *list ); // create list iterator | 2676 | QFileInfoListIterator it( *list ); // create list iterator |
2674 | QFileInfo *fi; // pointer for traversing | 2677 | QFileInfo *fi; // pointer for traversing |
2675 | 2678 | ||
2676 | dialog->IconField->insertItem("predefined"); | 2679 | dialog->IconField->insertItem("predefined"); |
2677 | while ( (fi=it.current()) ) { // for each file... | 2680 | while ( (fi=it.current()) ) { // for each file... |
2678 | QString fileName = fi->fileName(); | 2681 | QString fileName = fi->fileName(); |
2679 | if(fileName.right(4) == ".png"){ | 2682 | if(fileName.right(4) == ".png"){ |
2680 | fileName = fileName.mid(0,fileName.length()-4); | 2683 | fileName = fileName.mid(0,fileName.length()-4); |
2681 | #ifdef DESKTOP | 2684 | #ifdef DESKTOP |
2682 | QPixmap imageOfFile; | 2685 | QPixmap imageOfFile; |
2683 | imageOfFile.load(iconPath + fi->fileName()); | 2686 | imageOfFile.load(iconPath + fi->fileName()); |
2684 | #else | 2687 | #else |
2685 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2688 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
2686 | #endif | 2689 | #endif |
2687 | QImage foo = imageOfFile.convertToImage(); | 2690 | QImage foo = imageOfFile.convertToImage(); |
2688 | foo = foo.smoothScale(16,16); | 2691 | foo = foo.smoothScale(16,16); |
2689 | imageOfFile.convertFromImage(foo); | 2692 | imageOfFile.convertFromImage(foo); |
2690 | dialog->IconField->insertItem(imageOfFile,fileName); | 2693 | dialog->IconField->insertItem(imageOfFile,fileName); |
2691 | } | 2694 | } |
2692 | ++it; | 2695 | ++it; |
2693 | } | 2696 | } |
2694 | waitDialog.hide(); | 2697 | waitDialog.hide(); |
2695 | } | 2698 | } |
2696 | 2699 | ||
2697 | #ifndef WIN32 | 2700 | #ifndef WIN32 |
2698 | dialog->show(); | 2701 | dialog->show(); |
2699 | #endif | 2702 | #endif |
2700 | #ifndef DESKTOP | 2703 | #ifndef DESKTOP |
2701 | // dialog->move (20, 100); | 2704 | // dialog->move (20, 100); |
2702 | #endif | 2705 | #endif |
2703 | DialogCode result = (DialogCode) dialog->exec(); | 2706 | DialogCode result = (DialogCode) dialog->exec(); |
2704 | #ifdef DESKTOP | 2707 | #ifdef DESKTOP |
2705 | result = Accepted; | 2708 | result = Accepted; |
2706 | #endif | 2709 | #endif |
2707 | 2710 | ||
2708 | QString category; | 2711 | QString category; |
2709 | QString icon; | 2712 | QString icon; |
2710 | QString fullIconPath; | 2713 | QString fullIconPath; |
2711 | QPixmap *pix; | 2714 | QPixmap *pix; |
2712 | if (result == Accepted) | 2715 | if (result == Accepted) |
@@ -2714,33 +2717,33 @@ void ZSafe::addCategory() | |||
2714 | modified = true; | 2717 | modified = true; |
2715 | category = dialog->CategoryField->currentText(); | 2718 | category = dialog->CategoryField->currentText(); |
2716 | icon = dialog->IconField->currentText()+".png"; | 2719 | icon = dialog->IconField->currentText()+".png"; |
2717 | 2720 | ||
2718 | qWarning (category); | 2721 | qWarning (category); |
2719 | 2722 | ||
2720 | QListViewItem *li = new ShadedListItem( 1, ListView ); | 2723 | QListViewItem *li = new ShadedListItem( 1, ListView ); |
2721 | Category *c1 = new Category(); | 2724 | Category *c1 = new Category(); |
2722 | c1->setCategoryName(category); | 2725 | c1->setCategoryName(category); |
2723 | 2726 | ||
2724 | // if (!icon.isEmpty() && !icon.isNull()) | 2727 | // if (!icon.isEmpty() && !icon.isNull()) |
2725 | if (icon != "predefined.png") | 2728 | if (icon != "predefined.png") |
2726 | { | 2729 | { |
2727 | // build the full path | 2730 | // build the full path |
2728 | fullIconPath = iconPath + icon; | 2731 | fullIconPath = iconPath + icon; |
2729 | pix = new QPixmap (fullIconPath); | 2732 | pix = new QPixmap (fullIconPath); |
2730 | // pix->resize(14, 14); | 2733 | // pix->resize(14, 14); |
2731 | if (pix) | 2734 | if (pix) |
2732 | { | 2735 | { |
2733 | // save the full pixmap name into the config file | 2736 | // save the full pixmap name into the config file |
2734 | // #ifndef WIN32 | 2737 | // #ifndef WIN32 |
2735 | conf->writeEntry(APP_KEY+category, icon); | 2738 | conf->writeEntry(APP_KEY+category, icon); |
2736 | // #endif | 2739 | // #endif |
2737 | saveConf(); | 2740 | saveConf(); |
2738 | QImage img = pix->convertToImage(); | 2741 | QImage img = pix->convertToImage(); |
2739 | pix->convertFromImage(img.smoothScale(14,14)); | 2742 | pix->convertFromImage(img.smoothScale(14,14)); |
2740 | c1->setIcon (*pix); | 2743 | c1->setIcon (*pix); |
2741 | c1->setIconName(icon); | 2744 | c1->setIconName(icon); |
2742 | } | 2745 | } |
2743 | else | 2746 | else |
2744 | { | 2747 | { |
2745 | QPixmap folder( ( const char** ) general_data ); | 2748 | QPixmap folder( ( const char** ) general_data ); |
2746 | c1->setIcon (folder); | 2749 | c1->setIcon (folder); |
@@ -2763,33 +2766,33 @@ void ZSafe::addCategory() | |||
2763 | dialog->hide(); | 2766 | dialog->hide(); |
2764 | return; | 2767 | return; |
2765 | } | 2768 | } |
2766 | 2769 | ||
2767 | } | 2770 | } |
2768 | 2771 | ||
2769 | } | 2772 | } |
2770 | 2773 | ||
2771 | void ZSafe::delCategory() | 2774 | void ZSafe::delCategory() |
2772 | { | 2775 | { |
2773 | if (!selectedItem) | 2776 | if (!selectedItem) |
2774 | return; | 2777 | return; |
2775 | if (isCategory(selectedItem)) | 2778 | if (isCategory(selectedItem)) |
2776 | { | 2779 | { |
2777 | switch( QMessageBox::information( this, tr("ZSafe"), | 2780 | switch( QMessageBox::information( this, tr("ZSafe"), |
2778 | tr("Do you want to delete?"), | 2781 | tr("Do you want to delete?"), |
2779 | tr("&Delete"), tr("D&on't Delete"), | 2782 | tr("&Delete"), tr("D&on't Delete"), |
2780 | 0 // Enter == button 0 | 2783 | 0 // Enter == button 0 |
2781 | ) ) { // Escape == button 2 | 2784 | ) ) { // Escape == button 2 |
2782 | case 0: // Delete clicked, Alt-S or Enter pressed. | 2785 | case 0: // Delete clicked, Alt-S or Enter pressed. |
2783 | // Delete from the category list | 2786 | // Delete from the category list |
2784 | modified = true; | 2787 | modified = true; |
2785 | categories.remove (selectedItem->text(0)); | 2788 | categories.remove (selectedItem->text(0)); |
2786 | // #ifndef WIN32 | 2789 | // #ifndef WIN32 |
2787 | conf->removeEntry (selectedItem->text(0)); | 2790 | conf->removeEntry (selectedItem->text(0)); |
2788 | // #endif | 2791 | // #endif |
2789 | saveConf(); | 2792 | saveConf(); |
2790 | 2793 | ||
2791 | // Delete the selected item and all subitems | 2794 | // Delete the selected item and all subitems |
2792 | // step through all subitems | 2795 | // step through all subitems |
2793 | QListViewItem *si; | 2796 | QListViewItem *si; |
2794 | for (si = selectedItem->firstChild(); | 2797 | for (si = selectedItem->firstChild(); |
2795 | si != NULL; ) | 2798 | si != NULL; ) |
@@ -2804,150 +2807,150 @@ void ZSafe::delCategory() | |||
2804 | 2807 | ||
2805 | selectedItem = NULL; | 2808 | selectedItem = NULL; |
2806 | break; | 2809 | break; |
2807 | case 1: // Don't delete | 2810 | case 1: // Don't delete |
2808 | break; | 2811 | break; |
2809 | } | 2812 | } |
2810 | 2813 | ||
2811 | } | 2814 | } |
2812 | } | 2815 | } |
2813 | 2816 | ||
2814 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | 2817 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) |
2815 | { | 2818 | { |
2816 | if (!dialog) | 2819 | if (!dialog) |
2817 | return; | 2820 | return; |
2818 | 2821 | ||
2819 | QString icon; | 2822 | QString icon; |
2820 | if (selectedItem) | 2823 | if (selectedItem) |
2821 | { | 2824 | { |
2822 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 2825 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
2823 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 2826 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
2824 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 2827 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
2825 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 2828 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
2826 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); | 2829 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); |
2827 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); | 2830 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); |
2828 | 2831 | ||
2829 | Category *cat= categories.find (selectedItem->text(0)); | 2832 | Category *cat= categories.find (selectedItem->text(0)); |
2830 | if (cat) | 2833 | if (cat) |
2831 | { | 2834 | { |
2832 | icon = cat->getIconName(); | 2835 | icon = cat->getIconName(); |
2833 | } | 2836 | } |
2834 | else | 2837 | else |
2835 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); | 2838 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); |
2836 | } | 2839 | } |
2837 | else | 2840 | else |
2838 | { | 2841 | { |
2839 | dialog->Field1->setText(tr("Name")); | 2842 | dialog->Field1->setText(tr("Name")); |
2840 | dialog->Field2->setText(tr("Username")); | 2843 | dialog->Field2->setText(tr("Username")); |
2841 | dialog->Field3->setText(tr("Password")); | 2844 | dialog->Field3->setText(tr("Password")); |
2842 | dialog->Field4->setText(tr("Comment")); | 2845 | dialog->Field4->setText(tr("Comment")); |
2843 | dialog->Field5->setText(tr("Field 4")); | 2846 | dialog->Field5->setText(tr("Field 4")); |
2844 | dialog->Field6->setText(tr("Field 5")); | 2847 | dialog->Field6->setText(tr("Field 5")); |
2845 | } | 2848 | } |
2846 | 2849 | ||
2847 | #ifdef DESKTOP | 2850 | #ifdef DESKTOP |
2848 | QDir d(iconPath); | 2851 | QDir d(iconPath); |
2849 | #else | 2852 | #else |
2850 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2853 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2851 | #endif | 2854 | #endif |
2852 | d.setFilter( QDir::Files); | 2855 | d.setFilter( QDir::Files); |
2853 | 2856 | ||
2854 | const QFileInfoList *list = d.entryInfoList(); | 2857 | const QFileInfoList *list = d.entryInfoList(); |
2855 | int i=0; | 2858 | int i=0; |
2856 | QFileInfoListIterator it( *list ); // create list iterator | 2859 | QFileInfoListIterator it( *list ); // create list iterator |
2857 | QFileInfo *fi; // pointer for traversing | 2860 | QFileInfo *fi; // pointer for traversing |
2858 | if (icon.isEmpty() || icon.isNull()) | 2861 | if (icon.isEmpty() || icon.isNull()) |
2859 | { | 2862 | { |
2860 | dialog->IconField->setCurrentItem(0); | 2863 | dialog->IconField->setCurrentItem(0); |
2861 | } | 2864 | } |
2862 | else | 2865 | else |
2863 | { | 2866 | { |
2864 | while ( (fi=it.current()) ) | 2867 | while ( (fi=it.current()) ) |
2865 | { // for each file... | 2868 | { // for each file... |
2866 | QString fileName = fi->fileName(); | 2869 | QString fileName = fi->fileName(); |
2867 | if(fileName.right(4) == ".png") | 2870 | if(fileName.right(4) == ".png") |
2868 | { | 2871 | { |
2869 | fileName = fileName.mid(0,fileName.length()-4); | 2872 | fileName = fileName.mid(0,fileName.length()-4); |
2870 | 2873 | ||
2871 | if(fileName+".png"==icon) | 2874 | if(fileName+".png"==icon) |
2872 | { | 2875 | { |
2873 | dialog->IconField->setCurrentItem(i+1); | 2876 | dialog->IconField->setCurrentItem(i+1); |
2874 | break; | 2877 | break; |
2875 | } | 2878 | } |
2876 | ++i; | 2879 | ++i; |
2877 | } | 2880 | } |
2878 | ++it; | 2881 | ++it; |
2879 | } | 2882 | } |
2880 | } | 2883 | } |
2881 | } | 2884 | } |
2882 | 2885 | ||
2883 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | 2886 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) |
2884 | { | 2887 | { |
2885 | if (!dialog) | 2888 | if (!dialog) |
2886 | return; | 2889 | return; |
2887 | 2890 | ||
2888 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); | 2891 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); |
2889 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); | 2892 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); |
2890 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); | 2893 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); |
2891 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); | 2894 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); |
2892 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); | 2895 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); |
2893 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); | 2896 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); |
2894 | 2897 | ||
2895 | QString icon; | 2898 | QString icon; |
2896 | Category *cat= categories.find (category); | 2899 | Category *cat= categories.find (category); |
2897 | if (cat) | 2900 | if (cat) |
2898 | { | 2901 | { |
2899 | icon = cat->getIconName(); | 2902 | icon = cat->getIconName(); |
2900 | } | 2903 | } |
2901 | else | 2904 | else |
2902 | icon = conf->readEntry(APP_KEY+category); | 2905 | icon = conf->readEntry(APP_KEY+category); |
2903 | 2906 | ||
2904 | #ifdef DESKTOP | 2907 | #ifdef DESKTOP |
2905 | QDir d(iconPath); | 2908 | QDir d(iconPath); |
2906 | #else | 2909 | #else |
2907 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2910 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2908 | #endif | 2911 | #endif |
2909 | d.setFilter( QDir::Files); | 2912 | d.setFilter( QDir::Files); |
2910 | 2913 | ||
2911 | const QFileInfoList *list = d.entryInfoList(); | 2914 | const QFileInfoList *list = d.entryInfoList(); |
2912 | int i=0; | 2915 | int i=0; |
2913 | QFileInfoListIterator it( *list ); // create list iterator | 2916 | QFileInfoListIterator it( *list ); // create list iterator |
2914 | QFileInfo *fi; // pointer for traversing | 2917 | QFileInfo *fi; // pointer for traversing |
2915 | if (icon.isEmpty() || icon.isNull()) | 2918 | if (icon.isEmpty() || icon.isNull()) |
2916 | { | 2919 | { |
2917 | dialog->IconField->setCurrentItem(0); | 2920 | dialog->IconField->setCurrentItem(0); |
2918 | } | 2921 | } |
2919 | else | 2922 | else |
2920 | { | 2923 | { |
2921 | while ( (fi=it.current()) ) | 2924 | while ( (fi=it.current()) ) |
2922 | { // for each file... | 2925 | { // for each file... |
2923 | QString fileName = fi->fileName(); | 2926 | QString fileName = fi->fileName(); |
2924 | if(fileName.right(4) == ".png") | 2927 | if(fileName.right(4) == ".png") |
2925 | { | 2928 | { |
2926 | fileName = fileName.mid(0,fileName.length()-4); | 2929 | fileName = fileName.mid(0,fileName.length()-4); |
2927 | 2930 | ||
2928 | if(fileName+".png"==icon) | 2931 | if(fileName+".png"==icon) |
2929 | { | 2932 | { |
2930 | dialog->IconField->setCurrentItem(i+1); | 2933 | dialog->IconField->setCurrentItem(i+1); |
2931 | break; | 2934 | break; |
2932 | } | 2935 | } |
2933 | ++i; | 2936 | ++i; |
2934 | } | 2937 | } |
2935 | ++it; | 2938 | ++it; |
2936 | } | 2939 | } |
2937 | } | 2940 | } |
2938 | } | 2941 | } |
2939 | 2942 | ||
2940 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) | 2943 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) |
2941 | { | 2944 | { |
2942 | QString app_key = APP_KEY; | 2945 | QString app_key = APP_KEY; |
2943 | #ifndef DESKTOP | 2946 | #ifndef DESKTOP |
2944 | conf->setGroup ("fieldDefs"); | 2947 | conf->setGroup ("fieldDefs"); |
2945 | #else | 2948 | #else |
2946 | #ifndef WIN32 | 2949 | #ifndef WIN32 |
2947 | app_key += "/fieldDefs/"; | 2950 | app_key += "/fieldDefs/"; |
2948 | #endif | 2951 | #endif |
2949 | #endif | 2952 | #endif |
2950 | QString category = dialog->CategoryField->currentText(); | 2953 | QString category = dialog->CategoryField->currentText(); |
2951 | // #ifndef WIN32 | 2954 | // #ifndef WIN32 |
2952 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); | 2955 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); |
2953 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); | 2956 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); |
@@ -2970,33 +2973,33 @@ void ZSafe::editCategory() | |||
2970 | { | 2973 | { |
2971 | QString category = selectedItem->text(0); | 2974 | QString category = selectedItem->text(0); |
2972 | bool initIcons = false; | 2975 | bool initIcons = false; |
2973 | // open the 'Category' dialog | 2976 | // open the 'Category' dialog |
2974 | CategoryDialog *dialog; | 2977 | CategoryDialog *dialog; |
2975 | if (categoryDialog) | 2978 | if (categoryDialog) |
2976 | { | 2979 | { |
2977 | dialog = categoryDialog; | 2980 | dialog = categoryDialog; |
2978 | } | 2981 | } |
2979 | else | 2982 | else |
2980 | { | 2983 | { |
2981 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2984 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2982 | #ifdef WIN32 | 2985 | #ifdef WIN32 |
2983 | categoryDialog->setCaption ("Qt " + tr("Category")); | 2986 | categoryDialog->setCaption ("Qt " + tr("Category")); |
2984 | #endif | 2987 | #endif |
2985 | dialog = categoryDialog; | 2988 | dialog = categoryDialog; |
2986 | connect( dialog->CategoryField, | 2989 | connect( dialog->CategoryField, |
2987 | SIGNAL( activated ( const QString &)), | 2990 | SIGNAL( activated ( const QString &)), |
2988 | this, SLOT( categoryFieldActivated( const QString & ) ) ); | 2991 | this, SLOT( categoryFieldActivated( const QString & ) ) ); |
2989 | initIcons = true; | 2992 | initIcons = true; |
2990 | } | 2993 | } |
2991 | setCategoryDialogFields(dialog); | 2994 | setCategoryDialogFields(dialog); |
2992 | 2995 | ||
2993 | #ifdef DESKTOP | 2996 | #ifdef DESKTOP |
2994 | #ifndef WIN32 | 2997 | #ifndef WIN32 |
2995 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 2998 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
2996 | #else | 2999 | #else |
2997 | // read all categories from the config file and store | 3000 | // read all categories from the config file and store |
2998 | // into a list | 3001 | // into a list |
2999 | QFile f (cfgFile); | 3002 | QFile f (cfgFile); |
3000 | QStringList list; | 3003 | QStringList list; |
3001 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 3004 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3002 | QTextStream t( &f ); // use a text stream | 3005 | QTextStream t( &f ); // use a text stream |
@@ -3016,43 +3019,43 @@ void ZSafe::editCategory() | |||
3016 | QStringList list; | 3019 | QStringList list; |
3017 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 3020 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3018 | QTextStream t( &f ); // use a text stream | 3021 | QTextStream t( &f ); // use a text stream |
3019 | QString s; | 3022 | QString s; |
3020 | while ( !t.eof() ) { // until end of file... | 3023 | while ( !t.eof() ) { // until end of file... |
3021 | s = t.readLine(); // line of text excluding '\n' | 3024 | s = t.readLine(); // line of text excluding '\n' |
3022 | list.append(s); | 3025 | list.append(s); |
3023 | } | 3026 | } |
3024 | f.close(); | 3027 | f.close(); |
3025 | } | 3028 | } |
3026 | #endif | 3029 | #endif |
3027 | QStringList::Iterator it = list.begin(); | 3030 | QStringList::Iterator it = list.begin(); |
3028 | QString categ; | 3031 | QString categ; |
3029 | dialog->CategoryField->clear(); // remove all items | 3032 | dialog->CategoryField->clear(); // remove all items |
3030 | int i=0; | 3033 | int i=0; |
3031 | bool foundCategory = false; | 3034 | bool foundCategory = false; |
3032 | while( it != list.end() ) | 3035 | while( it != list.end() ) |
3033 | { | 3036 | { |
3034 | QString *cat = new QString (*it); | 3037 | QString *cat = new QString (*it); |
3035 | if (cat->contains("-field1", FALSE)) | 3038 | if (cat->contains("-field1", FALSE)) |
3036 | { | 3039 | { |
3037 | #ifdef DESKTOP | 3040 | #ifdef DESKTOP |
3038 | #ifndef WIN32 | 3041 | #ifndef WIN32 |
3039 | categ = cat->section ("-field1", 0, 0); | 3042 | categ = cat->section ("-field1", 0, 0); |
3040 | #else | 3043 | #else |
3041 | int pos = cat->find ("-field1"); | 3044 | int pos = cat->find ("-field1"); |
3042 | categ = cat->left (pos); | 3045 | categ = cat->left (pos); |
3043 | #endif | 3046 | #endif |
3044 | #else | 3047 | #else |
3045 | int pos = cat->find ("-field1"); | 3048 | int pos = cat->find ("-field1"); |
3046 | cat->truncate(pos); | 3049 | cat->truncate(pos); |
3047 | categ = *cat; | 3050 | categ = *cat; |
3048 | #endif | 3051 | #endif |
3049 | if (!categ.isEmpty()) | 3052 | if (!categ.isEmpty()) |
3050 | { | 3053 | { |
3051 | dialog->CategoryField->insertItem (categ, i); | 3054 | dialog->CategoryField->insertItem (categ, i); |
3052 | if (category.compare(categ) == 0) | 3055 | if (category.compare(categ) == 0) |
3053 | { | 3056 | { |
3054 | dialog->CategoryField->setCurrentItem(i); | 3057 | dialog->CategoryField->setCurrentItem(i); |
3055 | foundCategory = true; | 3058 | foundCategory = true; |
3056 | } | 3059 | } |
3057 | i++; | 3060 | i++; |
3058 | } | 3061 | } |
@@ -3062,116 +3065,116 @@ void ZSafe::editCategory() | |||
3062 | if (!foundCategory) | 3065 | if (!foundCategory) |
3063 | { | 3066 | { |
3064 | dialog->CategoryField->insertItem (category, i); | 3067 | dialog->CategoryField->insertItem (category, i); |
3065 | dialog->CategoryField->setCurrentItem(i); | 3068 | dialog->CategoryField->setCurrentItem(i); |
3066 | } | 3069 | } |
3067 | 3070 | ||
3068 | QString icon; | 3071 | QString icon; |
3069 | Category *cat= categories.find (selectedItem->text(0)); | 3072 | Category *cat= categories.find (selectedItem->text(0)); |
3070 | if (cat) | 3073 | if (cat) |
3071 | { | 3074 | { |
3072 | icon = cat->getIconName(); | 3075 | icon = cat->getIconName(); |
3073 | } | 3076 | } |
3074 | 3077 | ||
3075 | if (initIcons) | 3078 | if (initIcons) |
3076 | { | 3079 | { |
3077 | 3080 | ||
3078 | Wait waitDialog(this, tr("Wait dialog")); | 3081 | Wait waitDialog(this, tr("Wait dialog")); |
3079 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 3082 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
3080 | waitDialog.show(); | 3083 | waitDialog.show(); |
3081 | qApp->processEvents(); | 3084 | qApp->processEvents(); |
3082 | 3085 | ||
3083 | #ifdef DESKTOP | 3086 | #ifdef DESKTOP |
3084 | QDir d(iconPath); | 3087 | QDir d(iconPath); |
3085 | #else | 3088 | #else |
3086 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3089 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
3087 | #endif | 3090 | #endif |
3088 | d.setFilter( QDir::Files); | 3091 | d.setFilter( QDir::Files); |
3089 | 3092 | ||
3090 | const QFileInfoList *list = d.entryInfoList(); | 3093 | const QFileInfoList *list = d.entryInfoList(); |
3091 | int i=0; | 3094 | int i=0; |
3092 | QFileInfoListIterator it( *list ); // create list iterator | 3095 | QFileInfoListIterator it( *list ); // create list iterator |
3093 | QFileInfo *fi; // pointer for traversing | 3096 | QFileInfo *fi; // pointer for traversing |
3094 | if (icon.isEmpty() || icon.isNull()) | 3097 | if (icon.isEmpty() || icon.isNull()) |
3095 | { | 3098 | { |
3096 | dialog->IconField->setCurrentItem(0); | 3099 | dialog->IconField->setCurrentItem(0); |
3097 | } | 3100 | } |
3098 | 3101 | ||
3099 | dialog->IconField->insertItem("predefined"); | 3102 | dialog->IconField->insertItem("predefined"); |
3100 | while ( (fi=it.current()) ) { // for each file... | 3103 | while ( (fi=it.current()) ) { // for each file... |
3101 | QString fileName = fi->fileName(); | 3104 | QString fileName = fi->fileName(); |
3102 | if(fileName.right(4) == ".png") | 3105 | if(fileName.right(4) == ".png") |
3103 | { | 3106 | { |
3104 | fileName = fileName.mid(0,fileName.length()-4); | 3107 | fileName = fileName.mid(0,fileName.length()-4); |
3105 | #ifdef DESKTOP | 3108 | #ifdef DESKTOP |
3106 | QPixmap imageOfFile; | 3109 | QPixmap imageOfFile; |
3107 | imageOfFile.load(iconPath + fi->fileName()); | 3110 | imageOfFile.load(iconPath + fi->fileName()); |
3108 | #else | 3111 | #else |
3109 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 3112 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
3110 | #endif | 3113 | #endif |
3111 | QImage foo = imageOfFile.convertToImage(); | 3114 | QImage foo = imageOfFile.convertToImage(); |
3112 | foo = foo.smoothScale(16,16); | 3115 | foo = foo.smoothScale(16,16); |
3113 | imageOfFile.convertFromImage(foo); | 3116 | imageOfFile.convertFromImage(foo); |
3114 | dialog->IconField->insertItem(imageOfFile,fileName); | 3117 | dialog->IconField->insertItem(imageOfFile,fileName); |
3115 | if(fileName+".png"==icon) | 3118 | if(fileName+".png"==icon) |
3116 | dialog->IconField->setCurrentItem(i+1); | 3119 | dialog->IconField->setCurrentItem(i+1); |
3117 | ++i; | 3120 | ++i; |
3118 | } | 3121 | } |
3119 | ++it; | 3122 | ++it; |
3120 | } | 3123 | } |
3121 | waitDialog.hide(); | 3124 | waitDialog.hide(); |
3122 | } | 3125 | } |
3123 | else | 3126 | else |
3124 | { | 3127 | { |
3125 | #ifdef DESKTOP | 3128 | #ifdef DESKTOP |
3126 | // QDir d(QDir::homeDirPath() + "/pics/"); | 3129 | // QDir d(QDir::homeDirPath() + "/pics/"); |
3127 | QDir d(iconPath); | 3130 | QDir d(iconPath); |
3128 | #else | 3131 | #else |
3129 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3132 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
3130 | #endif | 3133 | #endif |
3131 | d.setFilter( QDir::Files); | 3134 | d.setFilter( QDir::Files); |
3132 | 3135 | ||
3133 | const QFileInfoList *list = d.entryInfoList(); | 3136 | const QFileInfoList *list = d.entryInfoList(); |
3134 | int i=0; | 3137 | int i=0; |
3135 | QFileInfoListIterator it( *list ); // create list iterator | 3138 | QFileInfoListIterator it( *list ); // create list iterator |
3136 | QFileInfo *fi; // pointer for traversing | 3139 | QFileInfo *fi; // pointer for traversing |
3137 | if (icon.isEmpty() || icon.isNull()) | 3140 | if (icon.isEmpty() || icon.isNull()) |
3138 | { | 3141 | { |
3139 | dialog->IconField->setCurrentItem(0); | 3142 | dialog->IconField->setCurrentItem(0); |
3140 | } | 3143 | } |
3141 | else | 3144 | else |
3142 | { | 3145 | { |
3143 | 3146 | ||
3144 | while ( (fi=it.current()) ) | 3147 | while ( (fi=it.current()) ) |
3145 | { // for each file... | 3148 | { // for each file... |
3146 | QString fileName = fi->fileName(); | 3149 | QString fileName = fi->fileName(); |
3147 | if(fileName.right(4) == ".png") | 3150 | if(fileName.right(4) == ".png") |
3148 | { | 3151 | { |
3149 | fileName = fileName.mid(0,fileName.length()-4); | 3152 | fileName = fileName.mid(0,fileName.length()-4); |
3150 | 3153 | ||
3151 | 3154 | ||
3152 | if(fileName+".png"==icon) | 3155 | if(fileName+".png"==icon) |
3153 | { | 3156 | { |
3154 | dialog->IconField->setCurrentItem(i+1); | 3157 | dialog->IconField->setCurrentItem(i+1); |
3155 | break; | 3158 | break; |
3156 | } | 3159 | } |
3157 | ++i; | 3160 | ++i; |
3158 | } | 3161 | } |
3159 | ++it; | 3162 | ++it; |
3160 | } | 3163 | } |
3161 | } | 3164 | } |
3162 | } | 3165 | } |
3163 | 3166 | ||
3164 | // dialog->show(); | 3167 | // dialog->show(); |
3165 | #ifndef DESKTOP | 3168 | #ifndef DESKTOP |
3166 | // dialog->move (20, 100); | 3169 | // dialog->move (20, 100); |
3167 | #endif | 3170 | #endif |
3168 | DialogCode result = (DialogCode) dialog->exec(); | 3171 | DialogCode result = (DialogCode) dialog->exec(); |
3169 | #ifdef DESKTOP | 3172 | #ifdef DESKTOP |
3170 | result = Accepted; | 3173 | result = Accepted; |
3171 | #endif | 3174 | #endif |
3172 | 3175 | ||
3173 | QString fullIconPath; | 3176 | QString fullIconPath; |
3174 | QPixmap *pix; | 3177 | QPixmap *pix; |
3175 | if (result == Accepted) | 3178 | if (result == Accepted) |
3176 | { | 3179 | { |
3177 | modified = true; | 3180 | modified = true; |
@@ -3317,40 +3320,40 @@ void ZSafe::pasteItem() | |||
3317 | void ZSafe::newDocument() | 3320 | void ZSafe::newDocument() |
3318 | { | 3321 | { |
3319 | 3322 | ||
3320 | // open the file dialog | 3323 | // open the file dialog |
3321 | #ifndef DESKTOP | 3324 | #ifndef DESKTOP |
3322 | #ifndef NO_OPIE | 3325 | #ifndef NO_OPIE |
3323 | QMap<QString, QStringList> mimeTypes; | 3326 | QMap<QString, QStringList> mimeTypes; |
3324 | mimeTypes.insert(tr("All"), QStringList() ); | 3327 | mimeTypes.insert(tr("All"), QStringList() ); |
3325 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3328 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3326 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 3329 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
3327 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3330 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3328 | QString::null, | 3331 | QString::null, |
3329 | mimeTypes, | 3332 | mimeTypes, |
3330 | this, | 3333 | this, |
3331 | tr ("Create new ZSafe document")); | 3334 | tr ("Create new ZSafe document")); |
3332 | #else | 3335 | #else |
3333 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3336 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3334 | tr ("Create new ZSafe document"), | 3337 | tr ("Create new ZSafe document"), |
3335 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3338 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3336 | "*.zsf"); | 3339 | "*.zsf"); |
3337 | #endif | 3340 | #endif |
3338 | #else | 3341 | #else |
3339 | QString newFile = QFileDialog::getSaveFileName( | 3342 | QString newFile = QFileDialog::getSaveFileName( |
3340 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3343 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3341 | "ZSafe (*.zsf)", | 3344 | "ZSafe (*.zsf)", |
3342 | this, | 3345 | this, |
3343 | "ZSafe File Dialog" | 3346 | "ZSafe File Dialog" |
3344 | "Choose a ZSafe file" ); | 3347 | "Choose a ZSafe file" ); |
3345 | #endif | 3348 | #endif |
3346 | 3349 | ||
3347 | // open the new document | 3350 | // open the new document |
3348 | if (newFile && newFile.length() > 0 ) | 3351 | if (newFile && newFile.length() > 0 ) |
3349 | { | 3352 | { |
3350 | // save the previous opened document | 3353 | // save the previous opened document |
3351 | if (!filename.isEmpty()) | 3354 | if (!filename.isEmpty()) |
3352 | saveDocument(filename, FALSE); | 3355 | saveDocument(filename, FALSE); |
3353 | 3356 | ||
3354 | modified = true; | 3357 | modified = true; |
3355 | 3358 | ||
3356 | // clear the password list | 3359 | // clear the password list |
@@ -3382,63 +3385,63 @@ void ZSafe::newDocument() | |||
3382 | selectedItem = NULL; | 3385 | selectedItem = NULL; |
3383 | 3386 | ||
3384 | filename = newFile; | 3387 | filename = newFile; |
3385 | 3388 | ||
3386 | // save the current filename to the config file | 3389 | // save the current filename to the config file |
3387 | conf->writeEntry(APP_KEY+"document", filename); | 3390 | conf->writeEntry(APP_KEY+"document", filename); |
3388 | saveConf(); | 3391 | saveConf(); |
3389 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3392 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3390 | #ifdef WIN32 | 3393 | #ifdef WIN32 |
3391 | this->setCaption("Qt ZSafe: " + ti); | 3394 | this->setCaption("Qt ZSafe: " + ti); |
3392 | #else | 3395 | #else |
3393 | this->setCaption("ZSafe: " + ti); | 3396 | this->setCaption("ZSafe: " + ti); |
3394 | #endif | 3397 | #endif |
3395 | 3398 | ||
3396 | // openDocument(filename); | 3399 | // openDocument(filename); |
3397 | 3400 | ||
3398 | QMessageBox::information( this, tr("ZSafe"), | 3401 | QMessageBox::information( this, tr("ZSafe"), |
3399 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3402 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3400 | 3403 | ||
3401 | saveDocumentWithPwd(); | 3404 | saveDocumentWithPwd(); |
3402 | } | 3405 | } |
3403 | } | 3406 | } |
3404 | 3407 | ||
3405 | void ZSafe::loadDocument() | 3408 | void ZSafe::loadDocument() |
3406 | { | 3409 | { |
3407 | 3410 | ||
3408 | // open the file dialog | 3411 | // open the file dialog |
3409 | #ifndef DESKTOP | 3412 | #ifndef DESKTOP |
3410 | #ifndef NO_OPIE | 3413 | #ifndef NO_OPIE |
3411 | QMap<QString, QStringList> mimeTypes; | 3414 | QMap<QString, QStringList> mimeTypes; |
3412 | mimeTypes.insert(tr("All"), QStringList() ); | 3415 | mimeTypes.insert(tr("All"), QStringList() ); |
3413 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3416 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3414 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 3417 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
3415 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3418 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3416 | QString::null, | 3419 | QString::null, |
3417 | mimeTypes, | 3420 | mimeTypes, |
3418 | this, | 3421 | this, |
3419 | tr ("Open ZSafe document")); | 3422 | tr ("Open ZSafe document")); |
3420 | #else | 3423 | #else |
3421 | QString newFile = ScQtFileEdit::getOpenFileName(this, | 3424 | QString newFile = ScQtFileEdit::getOpenFileName(this, |
3422 | tr ("Open ZSafe document"), | 3425 | tr ("Open ZSafe document"), |
3423 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3426 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3424 | "*.zsf"); | 3427 | "*.zsf"); |
3425 | #endif | 3428 | #endif |
3426 | #else | 3429 | #else |
3427 | QString newFile = QFileDialog::getOpenFileName( | 3430 | QString newFile = QFileDialog::getOpenFileName( |
3428 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3431 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3429 | "ZSafe (*.zsf)", | 3432 | "ZSafe (*.zsf)", |
3430 | this, | 3433 | this, |
3431 | "ZSafe File Dialog" | 3434 | "ZSafe File Dialog" |
3432 | "Choose a ZSafe file" ); | 3435 | "Choose a ZSafe file" ); |
3433 | #endif | 3436 | #endif |
3434 | 3437 | ||
3435 | // open the new document | 3438 | // open the new document |
3436 | if (newFile && newFile.length() > 0 ) | 3439 | if (newFile && newFile.length() > 0 ) |
3437 | { | 3440 | { |
3438 | // save the previous opened document | 3441 | // save the previous opened document |
3439 | if (!filename.isEmpty()) | 3442 | if (!filename.isEmpty()) |
3440 | saveDocument(filename, FALSE); | 3443 | saveDocument(filename, FALSE); |
3441 | 3444 | ||
3442 | // clear the password list | 3445 | // clear the password list |
3443 | QListViewItem *i; | 3446 | QListViewItem *i; |
3444 | QListViewItem *c = NULL; | 3447 | QListViewItem *c = NULL; |
@@ -3483,68 +3486,68 @@ void ZSafe::loadDocument() | |||
3483 | 3486 | ||
3484 | void ZSafe::saveDocumentAs() | 3487 | void ZSafe::saveDocumentAs() |
3485 | { | 3488 | { |
3486 | 3489 | ||
3487 | #ifndef DESKTOP | 3490 | #ifndef DESKTOP |
3488 | #ifndef NO_OPIE | 3491 | #ifndef NO_OPIE |
3489 | QMap<QString, QStringList> mimeTypes; | 3492 | QMap<QString, QStringList> mimeTypes; |
3490 | mimeTypes.insert(tr("All"), QStringList() ); | 3493 | mimeTypes.insert(tr("All"), QStringList() ); |
3491 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3494 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3492 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 3495 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
3493 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3496 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3494 | QString::null, | 3497 | QString::null, |
3495 | mimeTypes, | 3498 | mimeTypes, |
3496 | this, | 3499 | this, |
3497 | tr ("Save ZSafe document as..")); | 3500 | tr ("Save ZSafe document as..")); |
3498 | #else | 3501 | #else |
3499 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3502 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3500 | tr ("Save ZSafe document as.."), | 3503 | tr ("Save ZSafe document as.."), |
3501 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3504 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3502 | "*.zsf"); | 3505 | "*.zsf"); |
3503 | #endif | 3506 | #endif |
3504 | #else | 3507 | #else |
3505 | // open the file dialog | 3508 | // open the file dialog |
3506 | QString newFile = QFileDialog::getSaveFileName( | 3509 | QString newFile = QFileDialog::getSaveFileName( |
3507 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3510 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3508 | "ZSafe (*.zsf)", | 3511 | "ZSafe (*.zsf)", |
3509 | this, | 3512 | this, |
3510 | "ZSafe File Dialog" | 3513 | "ZSafe File Dialog" |
3511 | "Choose a ZSafe file" ); | 3514 | "Choose a ZSafe file" ); |
3512 | #endif | 3515 | #endif |
3513 | 3516 | ||
3514 | // open the new document | 3517 | // open the new document |
3515 | if (newFile && newFile.length() > 0 ) | 3518 | if (newFile && newFile.length() > 0 ) |
3516 | { | 3519 | { |
3517 | // save the previous opened document | 3520 | // save the previous opened document |
3518 | if (!filename.isEmpty()) | 3521 | if (!filename.isEmpty()) |
3519 | saveDocument(filename, FALSE); | 3522 | saveDocument(filename, FALSE); |
3520 | 3523 | ||
3521 | selectedItem = NULL; | 3524 | selectedItem = NULL; |
3522 | filename = newFile; | 3525 | filename = newFile; |
3523 | 3526 | ||
3524 | // save the current filename to the config file | 3527 | // save the current filename to the config file |
3525 | conf->writeEntry(APP_KEY+"document", filename); | 3528 | conf->writeEntry(APP_KEY+"document", filename); |
3526 | saveConf(); | 3529 | saveConf(); |
3527 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3530 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3528 | #ifdef WIN32 | 3531 | #ifdef WIN32 |
3529 | this->setCaption("Qt ZSafe: " + ti); | 3532 | this->setCaption("Qt ZSafe: " + ti); |
3530 | #else | 3533 | #else |
3531 | this->setCaption("ZSafe: " + ti); | 3534 | this->setCaption("ZSafe: " + ti); |
3532 | #endif | 3535 | #endif |
3533 | 3536 | ||
3534 | QMessageBox::information( this, tr("ZSafe"), | 3537 | QMessageBox::information( this, tr("ZSafe"), |
3535 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3538 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3536 | 3539 | ||
3537 | saveDocumentWithPwd(); | 3540 | saveDocumentWithPwd(); |
3538 | } | 3541 | } |
3539 | } | 3542 | } |
3540 | 3543 | ||
3541 | void ZSafe::saveDocumentWithoutPwd() | 3544 | void ZSafe::saveDocumentWithoutPwd() |
3542 | { | 3545 | { |
3543 | saveDocument(filename, FALSE); | 3546 | saveDocument(filename, FALSE); |
3544 | } | 3547 | } |
3545 | 3548 | ||
3546 | void ZSafe::saveDocumentWithPwd() | 3549 | void ZSafe::saveDocumentWithPwd() |
3547 | { | 3550 | { |
3548 | saveDocument(filename, TRUE); | 3551 | saveDocument(filename, TRUE); |
3549 | } | 3552 | } |
3550 | 3553 | ||
@@ -3609,51 +3612,51 @@ void ZSafe::setExpandFlag() | |||
3609 | // #endif | 3612 | // #endif |
3610 | saveConf(); | 3613 | saveConf(); |
3611 | 3614 | ||
3612 | } | 3615 | } |
3613 | 3616 | ||
3614 | void ZSafe::paintEvent( QPaintEvent * ) | 3617 | void ZSafe::paintEvent( QPaintEvent * ) |
3615 | { | 3618 | { |
3616 | if (raiseFlag) | 3619 | if (raiseFlag) |
3617 | { | 3620 | { |
3618 | raiseFlag = false; | 3621 | raiseFlag = false; |
3619 | raiseTimer.start (1, true); | 3622 | raiseTimer.start (1, true); |
3620 | if (infoForm->isVisible()) | 3623 | if (infoForm->isVisible()) |
3621 | infoForm->raise(); | 3624 | infoForm->raise(); |
3622 | } | 3625 | } |
3623 | } | 3626 | } |
3624 | 3627 | ||
3625 | void ZSafe::resizeEvent ( QResizeEvent * ) | 3628 | void ZSafe::resizeEvent ( QResizeEvent * ) |
3626 | { | 3629 | { |
3627 | // qWarning ("resizeEvent"); | 3630 | // qWarning ("resizeEvent"); |
3628 | #ifndef DESKTOP | 3631 | #ifndef DESKTOP |
3629 | DeskW = appl->desktop()->width(); | 3632 | DeskW = appl->desktop()->width(); |
3630 | DeskH = appl->desktop()->height(); | 3633 | DeskH = appl->desktop()->height(); |
3631 | #else | 3634 | #else |
3632 | DeskW = this->width(); | 3635 | DeskW = this->width(); |
3633 | DeskH = this->height(); | 3636 | DeskH = this->height(); |
3634 | #endif | 3637 | #endif |
3635 | 3638 | ||
3636 | if (New) | 3639 | if (New) |
3637 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); | 3640 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); |
3638 | if (Edit) | 3641 | if (Edit) |
3639 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); | 3642 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); |
3640 | if (Delete) | 3643 | if (Delete) |
3641 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 3644 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
3642 | if (Find) | 3645 | if (Find) |
3643 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); | 3646 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); |
3644 | } | 3647 | } |
3645 | 3648 | ||
3646 | void ZSafe::slotRaiseTimer() | 3649 | void ZSafe::slotRaiseTimer() |
3647 | { | 3650 | { |
3648 | if (infoForm->isVisible()) | 3651 | if (infoForm->isVisible()) |
3649 | infoForm->raise(); | 3652 | infoForm->raise(); |
3650 | raiseFlag = true; | 3653 | raiseFlag = true; |
3651 | } | 3654 | } |
3652 | 3655 | ||
3653 | QPixmap * ZSafe::getPredefinedIcon(QString category) | 3656 | QPixmap * ZSafe::getPredefinedIcon(QString category) |
3654 | { | 3657 | { |
3655 | QPixmap *pm; | 3658 | QPixmap *pm; |
3656 | if (category == "Bank cards") | 3659 | if (category == "Bank cards") |
3657 | pm = new QPixmap((const char**)bank_cards_data); | 3660 | pm = new QPixmap((const char**)bank_cards_data); |
3658 | else if (category == "Passwords") | 3661 | else if (category == "Passwords") |
3659 | pm = new QPixmap((const char**)passwords_data); | 3662 | pm = new QPixmap((const char**)passwords_data); |
@@ -3709,23 +3712,23 @@ void ZSafe::setDocument(const QString& fileref) | |||
3709 | // step through all subitems | 3712 | // step through all subitems |
3710 | QListViewItem *si; | 3713 | QListViewItem *si; |
3711 | for (si = i->firstChild(); | 3714 | for (si = i->firstChild(); |
3712 | si != NULL; ) | 3715 | si != NULL; ) |
3713 | { | 3716 | { |
3714 | QListViewItem *_si = si; | 3717 | QListViewItem *_si = si; |
3715 | si = si->nextSibling(); | 3718 | si = si->nextSibling(); |
3716 | i->takeItem(_si); // remove from view list | 3719 | i->takeItem(_si); // remove from view list |
3717 | if (_si) delete _si; | 3720 | if (_si) delete _si; |
3718 | } | 3721 | } |
3719 | } | 3722 | } |
3720 | if (c) delete c; // delete the previous category | 3723 | if (c) delete c; // delete the previous category |
3721 | categories.clear(); | 3724 | categories.clear(); |
3722 | 3725 | ||
3723 | m_password = ""; | 3726 | m_password = ""; |
3724 | selectedItem = NULL; | 3727 | selectedItem = NULL; |
3725 | 3728 | ||
3726 | openDocument(filename); | 3729 | openDocument(filename); |
3727 | #endif | 3730 | #endif |
3728 | } | 3731 | } |
3729 | 3732 | ||
3730 | 3733 | ||
3731 | 3734 | ||
diff --git a/noncore/apps/zsafe/zsafe.pro b/noncore/apps/zsafe/zsafe.pro index 65bcb79..1e8e4ac 100644 --- a/noncore/apps/zsafe/zsafe.pro +++ b/noncore/apps/zsafe/zsafe.pro | |||
@@ -1,17 +1,17 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = zsafe.h krc2.h category.h categorylist.h zlistview.h \ | 4 | HEADERS = zsafe.h krc2.h category.h categorylist.h zlistview.h \ |
5 | scqtfiledlg.h | 5 | scqtfiledlg.h |
6 | SOURCES = main.cpp zsafe.cpp krc2.cpp category.cpp \ | 6 | SOURCES = main.cpp zsafe.cpp krc2.cpp category.cpp \ |
7 | categorylist.cpp zlistview.cpp shadedlistitem.cpp\ | 7 | categorylist.cpp zlistview.cpp shadedlistitem.cpp\ |
8 | scqtfileedit.cpp scqtfileedit.moc.cpp \ | 8 | scqtfileedit.cpp scqtfileedit.moc.cpp \ |
9 | scqtfiledlg.cpp | 9 | scqtfiledlg.cpp |
10 | INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui infoform.ui wait.ui | 10 | INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui infoform.ui wait.ui |
11 | INCLUDEPATH+= $(OPIEDIR)/include | 11 | INCLUDEPATH += $(OPIEDIR)/include |
12 | DEPENDPATH+= $(OPIEDIR)/include | 12 | DEPENDPATH += $(OPIEDIR)/include |
13 | LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopie | 13 | LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopieui2 |
14 | TARGET = zsafe | 14 | TARGET = zsafe |
15 | 15 | ||
16 | include ( $(OPIEDIR)/include.pro ) | 16 | include ( $(OPIEDIR)/include.pro ) |
17 | 17 | ||