summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-05-26 16:17:16 (UTC)
committer mickeyl <mickeyl>2004-05-26 16:17:16 (UTC)
commit9a79c3bb271234396696dc54ee52f2a0c2a461d6 (patch) (unidiff)
treefeedc8e51e45f24fbfe376dd18523c14a1c30433
parent2b7ebd326a7e6456471bb973b14b4ad7affb9a9d (diff)
downloadopie-9a79c3bb271234396696dc54ee52f2a0c2a461d6.zip
opie-9a79c3bb271234396696dc54ee52f2a0c2a461d6.tar.gz
opie-9a79c3bb271234396696dc54ee52f2a0c2a461d6.tar.bz2
BUGFIX: Fixed ZSafe not starting up (Bug #1324)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ChangeLog1
-rw-r--r--noncore/apps/zsafe/zsafe.cpp59
2 files changed, 16 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index de27eb5..c8da96a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,47 +1,48 @@
1 2004-??-??The Opie Team <opie@handhelds.org> 1 2004-??-??The Opie Team <opie@handhelds.org>
2 2
3 * Fixed ZSafe not starting up (Bug #1324) (mickeyl)
3 * Fixed Drawpad initialization (Bug #1314) (mickeyl) 4 * Fixed Drawpad initialization (Bug #1314) (mickeyl)
4 * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) 5 * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle)
5 * Added Conversion tool for pim-data (eilers) 6 * Added Conversion tool for pim-data (eilers)
6 * Modifcation of the PIM API for providing generic use of OPimRecords. (eilers) 7 * Modifcation of the PIM API for providing generic use of OPimRecords. (eilers)
7 8
8 2004-25-04The Opie Team <opie@handhelds.org> 9 2004-25-04The Opie Team <opie@handhelds.org>
9 10
10 * Released as Version 1.1.3 (devel) 11 * Released as Version 1.1.3 (devel)
11 * Introduced first implementation of SQL-Support using SQLite (eilers) 12 * Introduced first implementation of SQL-Support using SQLite (eilers)
12 * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) 13 * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp)
13 * Added a real system graffiti character set (brad) 14 * Added a real system graffiti character set (brad)
14 * Added Generic Keyconfig Widget (zecke) 15 * Added Generic Keyconfig Widget (zecke)
15 * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) 16 * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke)
16 * Added new Bible reader app - opie-dagger (drw) 17 * Added new Bible reader app - opie-dagger (drw)
17 * Added a new Image Viewer. Work is ongoing (zecke,alwin) 18 * Added a new Image Viewer. Work is ongoing (zecke,alwin)
18 * Added namespace usage in libopie2 and everywhere (zecke,alwin) 19 * Added namespace usage in libopie2 and everywhere (zecke,alwin)
19 * Enabled the possibility to pass command line arguments to applications (mickeyl) 20 * Enabled the possibility to pass command line arguments to applications (mickeyl)
20 * Added an about applet showing some credits and information about Opie (mickeyl) 21 * Added an about applet showing some credits and information about Opie (mickeyl)
21 * Added benchmarking functionality to sysinfo (mickeyl) 22 * Added benchmarking functionality to sysinfo (mickeyl)
22 * Added applet and configuration application for switching hardware keyboard layouts (alwin) 23 * Added applet and configuration application for switching hardware keyboard layouts (alwin)
23 * Ported applications from libopie1 to libopie2* (drw,ar,alwin) 24 * Ported applications from libopie1 to libopie2* (drw,ar,alwin)
24 * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) 25 * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe)
25 * Clean-up of package information in control files (drw) 26 * Clean-up of package information in control files (drw)
26 * Repaired mediummount which was broken since integrating the quicklauncher (alwin) 27 * Repaired mediummount which was broken since integrating the quicklauncher (alwin)
27 * Improved big-screen support (zecke,ar) 28 * Improved big-screen support (zecke,ar)
28 * Improved multikeyboard support, added keyboard layout switching applet (mouse) 29 * Improved multikeyboard support, added keyboard layout switching applet (mouse)
29 * Added a new mail client based on libetpan (harlekin,alwin,jgf) 30 * Added a new mail client based on libetpan (harlekin,alwin,jgf)
30 * Added new package manager - opie-packagemanager (drw) 31 * Added new package manager - opie-packagemanager (drw)
31 * Improved light-n-power for C7x0 (mickeyl) 32 * Improved light-n-power for C7x0 (mickeyl)
32 * Added automatic rotation support for C7x0 (treke) 33 * Added automatic rotation support for C7x0 (treke)
33 * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) 34 * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl)
34 * Added scanning the wireless network neighbourhood to networksettings (mickeyl) 35 * Added scanning the wireless network neighbourhood to networksettings (mickeyl)
35 36
36 2003-11-29The Opie Team <opie@handhelds.org> 37 2003-11-29The Opie Team <opie@handhelds.org>
37 38
38 * Released as Version 1.0.3 39 * Released as Version 1.0.3
39 * Improved i18n (various contributors) 40 * Improved i18n (various contributors)
40 * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) 41 * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin)
41 * Made the Documents Tab optional (mickeyl) 42 * Made the Documents Tab optional (mickeyl)
42 * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) 43 * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken)
43 44
44 2003-08-04The Opie Team <opie@handhelds.org> 45 2003-08-04The Opie Team <opie@handhelds.org>
45 46
46 * Released as Version 1.0.0 47 * Released as Version 1.0.0
47 * Including a PPP module for easy dial up (tille,harlekin,zecke) 48 * Including a PPP module for easy dial up (tille,harlekin,zecke)
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index bf8f7f4..6ff05ac 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -362,309 +362,280 @@ static const char* const general_data[] = {
362 if (conf) 362 if (conf)
363 { 363 {
364 delete conf; 364 delete conf;
365 365
366#ifdef DESKTOP 366#ifdef DESKTOP
367#ifndef WIN32 367#ifndef WIN32
368 conf = new QSettings (); 368 conf = new QSettings ();
369 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); 369 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
370#else 370#else
371 conf = new QSettings (cfgFile); 371 conf = new QSettings (cfgFile);
372 conf->insertSearchPath (QSettings::Unix, cfgFile); 372 conf->insertSearchPath (QSettings::Unix, cfgFile);
373#endif 373#endif
374#else 374#else
375 conf = new Config (cfgFile, Config::File); 375 conf = new Config (cfgFile, Config::File);
376 conf->setGroup ("zsafe"); 376 conf->setGroup ("zsafe");
377#endif 377#endif
378 } 378 }
379 } 379 }
380 380
381 381
382/* 382/*
383 * Constructs a ZSafe which is a child of 'parent', with the 383 * Constructs a ZSafe which is a child of 'parent', with the
384 * name 'name' and widget flags set to 'f' 384 * name 'name' and widget flags set to 'f'
385 * 385 *
386 * The dialog will by default be modeless, unless you set 'modal' to 386 * The dialog will by default be modeless, unless you set 'modal' to
387 * TRUE to construct a modal dialog. 387 * TRUE to construct a modal dialog.
388 */ 388 */
389ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) 389ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
390 : QDialog( parent, name, modal, fl ), 390 : QDialog( parent, name, modal, fl ),
391 Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) 391 Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l)
392{ 392{
393 IsCut = false; 393 IsCut = false;
394 IsCopy = false; 394 IsCopy = false;
395 modified = false; 395 modified = false;
396 396
397 // set the config file 397 // set the config file
398 cfgFile=QDir::homeDirPath(); 398 cfgFile=QDir::homeDirPath();
399 cfgFile += "/.zsafe.cfg"; 399 cfgFile += "/.zsafe.cfg";
400 // set the icon path 400 // set the icon path
401#ifdef NO_OPIE 401#ifdef NO_OPIE
402 QString qpedir ((const char *)getenv("QPEDIR")); 402 QString qpedir ((const char *)getenv("QPEDIR"));
403#else 403#else
404 QString qpedir ((const char *)getenv("OPIEDIR")); 404 QString qpedir ((const char *)getenv("OPIEDIR"));
405#endif 405#endif
406 406
407#ifdef DESKTOP 407#ifdef DESKTOP
408 iconPath = QDir::homeDirPath() + "/pics/"; 408 iconPath = QDir::homeDirPath() + "/pics/";
409#else 409#else
410 if (qpedir.isEmpty()) 410 if (qpedir.isEmpty())
411 iconPath = "/home/QtPalmtop/pics/"; 411 iconPath = "/home/QtPalmtop/pics/";
412 else 412 else
413 iconPath = qpedir + "/pics/"; 413 iconPath = qpedir + "/pics/";
414#endif 414#endif
415 415
416 // create a zsafe configuration object 416 // create a zsafe configuration object
417#ifdef DESKTOP 417#ifdef DESKTOP
418#ifndef WIN32 418#ifndef WIN32
419 conf = new QSettings (); 419 conf = new QSettings ();
420 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); 420 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
421#else 421#else
422 conf = new QSettings (cfgFile); 422 conf = new QSettings (cfgFile);
423 conf->insertSearchPath (QSettings::Unix, cfgFile); 423 conf->insertSearchPath (QSettings::Unix, cfgFile);
424#endif 424#endif
425#else 425#else
426 conf = new Config (cfgFile, Config::File); 426 conf = new Config (cfgFile, Config::File);
427 conf->setGroup ("zsafePrefs"); 427 conf->setGroup ("zsafePrefs");
428#endif 428#endif
429#ifdef DESKTOP 429#ifdef DESKTOP
430// #ifndef WIN32 430// #ifndef WIN32
431 expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); 431 expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false);
432// #endif 432// #endif
433#else 433#else
434 expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); 434 expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0);
435#endif 435#endif
436#ifndef DESKTOP 436#ifndef DESKTOP
437 conf->setGroup ("zsafe"); 437 conf->setGroup ("zsafe");
438#endif 438#endif
439 439
440 QPixmap copy_img((const char**) copy_xpm); 440 QPixmap copy_img((const char**) copy_xpm);
441 QPixmap cut_img((const char**) cut_xpm); 441 QPixmap cut_img((const char**) cut_xpm);
442 QPixmap edit_img((const char**) edit_xpm); 442 QPixmap edit_img((const char**) edit_xpm);
443 QPixmap editdelete_img((const char**) editdelete_xpm); 443 QPixmap editdelete_img((const char**) editdelete_xpm);
444 QPixmap find_img((const char**) find_xpm); 444 QPixmap find_img((const char**) find_xpm);
445 QPixmap folder_open_img((const char**) folder_open_xpm); 445 QPixmap folder_open_img((const char**) folder_open_xpm);
446 QPixmap help_icon_img((const char**) help_icon_xpm); 446 QPixmap help_icon_img((const char**) help_icon_xpm);
447 QPixmap new_img((const char**) new_xpm); 447 QPixmap new_img((const char**) new_xpm);
448 QPixmap paste_img((const char**) paste_xpm); 448 QPixmap paste_img((const char**) paste_xpm);
449 QPixmap quit_icon_img((const char**) quit_icon_xpm); 449 QPixmap quit_icon_img((const char**) quit_icon_xpm);
450 QPixmap save_img((const char**) save_xpm); 450 QPixmap save_img((const char**) save_xpm);
451 QPixmap trash_img((const char**) trash_xpm); 451 QPixmap trash_img((const char**) trash_xpm);
452 QPixmap expand_img((const char**) expand_xpm); 452 QPixmap expand_img((const char**) expand_xpm);
453 QPixmap export_img((const char**) export_xpm); 453 QPixmap export_img((const char**) export_xpm);
454 QPixmap import_img((const char**) import_xpm); 454 QPixmap import_img((const char**) import_xpm);
455 455
456 QPixmap bank_cards( ( const char** ) bank_cards_data ); 456 QPixmap bank_cards( ( const char** ) bank_cards_data );
457 QPixmap passwords( ( const char** ) passwords_data ); 457 QPixmap passwords( ( const char** ) passwords_data );
458 QPixmap software( ( const char** ) software_data ); 458 QPixmap software( ( const char** ) software_data );
459 QPixmap general( ( const char** ) general_data ); 459 QPixmap general( ( const char** ) general_data );
460 if ( !name ) 460 if ( !name )
461 setName( "ZSafe" ); 461 setName( "ZSafe" );
462 462
463#ifdef DESKTOP 463#ifdef DESKTOP
464#ifdef WIN32 464#ifdef WIN32
465 setGeometry(100, 150, DeskW, DeskH-30 ); 465 setGeometry(100, 150, DeskW, DeskH-30 );
466#else 466#else
467 resize( DeskW, DeskH-30 ); 467 resize( DeskW, DeskH-30 );
468#endif 468#endif
469 469
470#else 470#else
471 471
472#ifdef JPATCH_HDE 472#ifdef JPATCH_HDE
473 int DeskS; 473 int DeskS;
474 if(DeskW > DeskH) 474 if(DeskW > DeskH)
475 { 475 {
476 DeskS = DeskW; 476 DeskS = DeskW;
477 } 477 }
478 else 478 else
479 { 479 {
480 DeskS = DeskH; 480 DeskS = DeskH;
481 } 481 }
482 resize( DeskW, DeskH ); 482 resize( DeskW, DeskH );
483 setMinimumSize( QSize( DeskS, DeskS ) ); 483 setMinimumSize( QSize( DeskS, DeskS ) );
484 setMaximumSize( QSize( DeskS, DeskS ) ); 484 setMaximumSize( QSize( DeskS, DeskS ) );
485#else 485#else
486 resize( DeskW, DeskH-30 ); 486 resize( DeskW, DeskH-30 );
487#endif 487#endif
488 488
489#endif 489#endif
490 // setCaption( tr( "ZSafe" ) ); 490 setCaption( tr( "ZSafe" ) );
491 491 QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe";
492 filename = conf->readEntry(APP_KEY+"document"); 492 QString filename = conf->readEntry(APP_KEY+"document");
493 if (filename.isEmpty() || filename.isNull()) 493 if (filename.isEmpty() || filename.isNull())
494 { 494 {
495 495 if ( !QDir( zsafeAppDirPath ).exists() )
496 // check if the directory application exists, if not
497 // create it
498// #ifndef WIN32
499 // QString d1("Documents/application");
500// #else
501 QString d1(QDir::homeDirPath() + "/Documents/application");
502// #endif
503 QDir pd1(d1);
504 if (!pd1.exists())
505 {
506 QDir pd1("Documents");
507 if (!pd1.mkdir("application", FALSE))
508 { 496 {
509 QMessageBox::critical( 0, tr("ZSafe"), 497 //FIXME: Pending someone to look into why QDir.mkdir does not work as expected
510#ifdef JPATCH_HDE 498 QString cmdline = QString().sprintf( "mkdir -p %s", (const char*) zsafeAppDirPath );
511 tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit.")); 499 ::system( cmdline );
512#else
513 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1));
514#endif
515 exitZs (1);
516 } 500 }
517 } 501 if ( !QDir( zsafeAppDirPath ).exists() )
518 QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
519 QDir pd2(d2);
520 if (!pd2.exists())
521 {
522 QDir pd2(QDir::homeDirPath() + "Documents/application");
523 if (!pd2.mkdir("zsafe", FALSE))
524 { 502 {
525 QMessageBox::critical( 0, tr("ZSafe"), 503 QMessageBox::critical( 0, "ZSafe", tr("Can't create application data directory.\nZSafe will now exit."));
526#ifdef JPATCH_HDE 504 exitZs (1);
527 tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit."));
528#else
529 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2));
530#endif
531 exitZs (1);
532 } 505 }
533 } 506 }
534 507
535
536 // set the default filename 508 // set the default filename
537 filename=d2 + "/passwords.zsf"; 509 filename = zsafeAppDirPath + "/passwords.zsf";
538 510
539 // save the current filename to the config file 511 // save the current filename to the config file
540 conf->writeEntry(APP_KEY+"document", filename); 512 conf->writeEntry(APP_KEY+"document", filename);
541 saveConf(); 513 saveConf();
542 }
543 514
544 //if (filename == "INVALIDPWD") 515 //if (filename == "INVALIDPWD")
545 //filename = ""; 516 //filename = "";
546 517
547 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 518 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
548#ifdef WIN32 519#ifdef WIN32
549 this->setCaption("Qt ZSafe: " + ti); 520 this->setCaption("Qt ZSafe: " + ti);
550#else 521#else
551 this->setCaption("ZSafe: " + ti); 522 this->setCaption("ZSafe: " + ti);
552#endif 523#endif
553 524
554 selectedItem = NULL; 525 selectedItem = NULL;
555 lastSearchedCategory = NULL; 526 lastSearchedCategory = NULL;
556 lastSearchedItem = NULL; 527 lastSearchedItem = NULL;
557 lastSearchedName = ""; 528 lastSearchedName = "";
558 lastSearchedUsername = ""; 529 lastSearchedUsername = "";
559 lastSearchedComment = ""; 530 lastSearchedComment = "";
560 531
561 infoForm = new InfoForm(); 532 infoForm = new InfoForm();
562 categoryDialog = NULL; 533 categoryDialog = NULL;
563 534
564 // add a menu bar 535 // add a menu bar
565 QMenuBar *menu = new QMenuBar( this ); 536 QMenuBar *menu = new QMenuBar( this );
566 537
567 // add file menu 538 // add file menu
568 // QPopupMenu *file = new QPopupMenu( this ); 539 // QPopupMenu *file = new QPopupMenu( this );
569 file = new QPopupMenu( this ); 540 file = new QPopupMenu( this );
570 541
571// #ifdef DESKTOP 542// #ifdef DESKTOP
572 file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); 543 file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) );
573 file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); 544 file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) );
574 file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); 545 file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) );
575 file->insertSeparator(); 546 file->insertSeparator();
576// #endif 547// #endif
577 548
578 file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); 549 file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) );
579 file->insertItem( save_img, tr("S&ave document with new Password"), this, 550 file->insertItem( save_img, tr("S&ave document with new Password"), this,
580 SLOT(saveDocumentWithPwd()) ); 551 SLOT(saveDocumentWithPwd()) );
581 file->insertSeparator(); 552 file->insertSeparator();
582 file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); 553 file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) );
583 file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); 554 file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) );
584 file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); 555 file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) );
585 file->insertSeparator(); 556 file->insertSeparator();
586 file->insertItem( expand_img, tr("&Open entries expanded"), this, 557 file->insertItem( expand_img, tr("&Open entries expanded"), this,
587 SLOT(setExpandFlag()), 0, 'o'); 558 SLOT(setExpandFlag()), 0, 'o');
588 file->setItemChecked('o', expandTree); 559 file->setItemChecked('o', expandTree);
589 file->insertSeparator(); 560 file->insertSeparator();
590 file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); 561 file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) );
591 menu->insertItem( tr("&File"), file ); 562 menu->insertItem( tr("&File"), file );
592 563
593 QPopupMenu *cat = new QPopupMenu( this ); 564 QPopupMenu *cat = new QPopupMenu( this );
594 cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); 565 cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) );
595 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); 566 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) );
596 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); 567 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) );
597 menu->insertItem( tr("&Category"), cat ); 568 menu->insertItem( tr("&Category"), cat );
598 569
599 QPopupMenu *it = new QPopupMenu( this ); 570 QPopupMenu *it = new QPopupMenu( this );
600 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); 571 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) );
601 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); 572 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) );
602 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); 573 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) );
603 it->insertSeparator(); 574 it->insertSeparator();
604 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); 575 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) );
605 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); 576 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) );
606 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); 577 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) );
607 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); 578 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) );
608 menu->insertItem( tr("&Entry"), it ); 579 menu->insertItem( tr("&Entry"), it );
609 580
610 QPopupMenu *help = new QPopupMenu( this ); 581 QPopupMenu *help = new QPopupMenu( this );
611 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); 582 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) );
612 menu->insertItem( tr("&Help"), help ); 583 menu->insertItem( tr("&Help"), help );
613 584
614 // toolbar icons 585 // toolbar icons
615 586
616 New = new QToolButton( menu, "New" ); 587 New = new QToolButton( menu, "New" );
617 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); 588 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) );
618 New->setMouseTracking( TRUE ); 589 New->setMouseTracking( TRUE );
619 New->setText( tr( "" ) ); 590 New->setText( tr( "" ) );
620 New->setPixmap( new_img ); 591 New->setPixmap( new_img );
621 QToolTip::add( New, tr( "New entry" ) ); 592 QToolTip::add( New, tr( "New entry" ) );
622 593
623 Edit = new QToolButton( menu, "Edit" ); 594 Edit = new QToolButton( menu, "Edit" );
624 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); 595 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) );
625 Edit->setText( tr( "" ) ); 596 Edit->setText( tr( "" ) );
626 Edit->setPixmap( edit_img ); 597 Edit->setPixmap( edit_img );
627 QToolTip::add( Edit, tr( "Edit category or entry" ) ); 598 QToolTip::add( Edit, tr( "Edit category or entry" ) );
628 599
629 Delete = new QToolButton( menu, "Delete" ); 600 Delete = new QToolButton( menu, "Delete" );
630 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); 601 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
631 Delete->setText( tr( "" ) ); 602 Delete->setText( tr( "" ) );
632 Delete->setPixmap( trash_img ); 603 Delete->setPixmap( trash_img );
633 QToolTip::add( Delete, tr( "Delete category or entry" ) ); 604 QToolTip::add( Delete, tr( "Delete category or entry" ) );
634 605
635 Find = new QToolButton( menu, "Find" ); 606 Find = new QToolButton( menu, "Find" );
636 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); 607 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) );
637 Find->setText( tr( "" ) ); 608 Find->setText( tr( "" ) );
638 Find->setPixmap( find_img ); 609 Find->setPixmap( find_img );
639 QToolTip::add( Find, tr( "Find entry" ) ); 610 QToolTip::add( Find, tr( "Find entry" ) );
640 611
641/* 612/*
642 QBoxLayout * h = new QHBoxLayout( this ); 613 QBoxLayout * h = new QHBoxLayout( this );
643 h->addWidget (menu); 614 h->addWidget (menu);
644 h->addWidget (New); 615 h->addWidget (New);
645 h->addWidget (Edit); 616 h->addWidget (Edit);
646 h->addWidget (Delete); 617 h->addWidget (Delete);
647 h->addWidget (Find); 618 h->addWidget (Find);
648*/ 619*/
649 620
650 ListView = new ZListView( this, "ListView" ); 621 ListView = new ZListView( this, "ListView" );
651 ListView->addColumn( tr( "Name" ) ); 622 ListView->addColumn( tr( "Name" ) );
652 ListView->addColumn( tr( "Field 2" ) ); 623 ListView->addColumn( tr( "Field 2" ) );
653 ListView->addColumn( tr( "Field 3" ) ); 624 ListView->addColumn( tr( "Field 3" ) );
654 ListView->addColumn( tr( "Comment" ) ); 625 ListView->addColumn( tr( "Comment" ) );
655 ListView->addColumn( tr( "Field 4" ) ); 626 ListView->addColumn( tr( "Field 4" ) );
656 ListView->addColumn( tr( "Field 5" ) ); 627 ListView->addColumn( tr( "Field 5" ) );
657 ListView->setAllColumnsShowFocus(TRUE); 628 ListView->setAllColumnsShowFocus(TRUE);
658 629
659#ifdef DESKTOP 630#ifdef DESKTOP
660 ListView->setResizePolicy(QScrollView::AutoOneFit); 631 ListView->setResizePolicy(QScrollView::AutoOneFit);
661 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); 632 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) );
662#else 633#else
663 ListView->setResizePolicy(QScrollView::AutoOneFit); 634 ListView->setResizePolicy(QScrollView::AutoOneFit);
664 // ListView->setGeometry( QRect( 0, 22, 635 // ListView->setGeometry( QRect( 0, 22,
665 // this->width(), this->height() - 30 ) ); 636 // this->width(), this->height() - 30 ) );
666 // ListView->setMaximumSize( QSize( 440, 290 ) ); 637 // ListView->setMaximumSize( QSize( 440, 290 ) );
667#endif 638#endif
668 ListView->setVScrollBarMode( QListView::Auto ); 639 ListView->setVScrollBarMode( QListView::Auto );
669 640
670 QBoxLayout * l = new QVBoxLayout( this ); 641 QBoxLayout * l = new QVBoxLayout( this );
@@ -2131,310 +2102,310 @@ int ZSafe::loadEntry(char *entry[FIELD_SIZE])
2131 if ((unsigned char) (buffer[count]) == 255) { 2102 if ((unsigned char) (buffer[count]) == 255) {
2132 if (buffer[bufferIndex] == '\0') { 2103 if (buffer[bufferIndex] == '\0') {
2133 bufferIndex++; 2104 bufferIndex++;
2134 } 2105 }
2135 entry[count1] = (char *) malloc (count - bufferIndex + 1); 2106 entry[count1] = (char *) malloc (count - bufferIndex + 1);
2136 memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); 2107 memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex);
2137 entry[count1][count - bufferIndex] = '\0'; 2108 entry[count1][count - bufferIndex] = '\0';
2138 count++; 2109 count++;
2139 bufferIndex = count; 2110 bufferIndex = count;
2140 count1++; 2111 count1++;
2141 if (count1 == FIELD_SIZE) { 2112 if (count1 == FIELD_SIZE) {
2142 lastcount = count; 2113 lastcount = count;
2143 return 1; 2114 return 1;
2144 } 2115 }
2145 } /* if ((unsigned char) (buffer[count]) == 255) */ 2116 } /* if ((unsigned char) (buffer[count]) == 255) */
2146 } /* for (count = 0; count < size; count++) */ 2117 } /* for (count = 0; count < size; count++) */
2147 2118
2148 return 2; 2119 return 2;
2149} 2120}
2150 2121
2151int ZSafe::loadFinalize(void) 2122int ZSafe::loadFinalize(void)
2152{ 2123{
2153 fclose (fd); 2124 fclose (fd);
2154 if (buffer) free(buffer); 2125 if (buffer) free(buffer);
2155 return PWERR_GOOD; 2126 return PWERR_GOOD;
2156} 2127}
2157 2128
2158bool ZSafe::saveDocument(const char* _filename, 2129bool ZSafe::saveDocument(const char* _filename,
2159 bool withPwd, 2130 bool withPwd,
2160 const char* ) 2131 const char* )
2161{ 2132{
2162 if (filename.isEmpty()) 2133 if (filename.isEmpty())
2163 { 2134 {
2164 QMessageBox::critical( 0, tr("ZSafe"), 2135 QMessageBox::critical( 0, tr("ZSafe"),
2165 tr("No document defined.\nYou have to create a new document")); 2136 tr("No document defined.\nYou have to create a new document"));
2166 return false; 2137 return false;
2167 } 2138 }
2168 2139
2169 // if (m_password.isEmpty()) 2140 // if (m_password.isEmpty())
2170 // withPwd = true; // the document must be saved with a valid password 2141 // withPwd = true; // the document must be saved with a valid password
2171 if (withPwd) 2142 if (withPwd)
2172 { 2143 {
2173 bool pwdOk = FALSE; 2144 bool pwdOk = FALSE;
2174 while (!pwdOk) 2145 while (!pwdOk)
2175 { 2146 {
2176 getDocPassword(tr("Enter Password")); 2147 getDocPassword(tr("Enter Password"));
2177 if (m_password.isEmpty()) 2148 if (m_password.isEmpty())
2178 { 2149 {
2179 2150
2180 QMessageBox::critical( 0, tr("ZSafe"), 2151 QMessageBox::critical( 0, tr("ZSafe"),
2181 tr("Password is empty.\nPlease enter again.")); 2152 tr("Password is empty.\nPlease enter again."));
2182 continue; 2153 continue;
2183 } 2154 }
2184 2155
2185 QString firstPasswd = m_password; 2156 QString firstPasswd = m_password;
2186 2157
2187 getDocPassword(tr("Reenter Password")); 2158 getDocPassword(tr("Reenter Password"));
2188 if (m_password.isEmpty()) 2159 if (m_password.isEmpty())
2189 { 2160 {
2190 QMessageBox::critical( 0, tr("ZSafe"), 2161 QMessageBox::critical( 0, tr("ZSafe"),
2191 tr("Password is empty.\nPlease enter again.")); 2162 tr("Password is empty.\nPlease enter again."));
2192 continue; 2163 continue;
2193 } 2164 }
2194 if (firstPasswd != m_password) 2165 if (firstPasswd != m_password)
2195 { 2166 {
2196 2167
2197 QMessageBox::critical( 0, tr("ZSafe"), 2168 QMessageBox::critical( 0, tr("ZSafe"),
2198 tr("Passwords must be identical.\nPlease enter again.")); 2169 tr("Passwords must be identical.\nPlease enter again."));
2199 continue; 2170 continue;
2200 } 2171 }
2201 pwdOk = TRUE; 2172 pwdOk = TRUE;
2202 modified = false; 2173 modified = false;
2203 } 2174 }
2204 } 2175 }
2205 else if (modified) 2176 else if (modified)
2206 { 2177 {
2207 QString fns(_filename); 2178 QString fns(_filename);
2208 fns = fns.right (fns.length() - fns.findRev ('/') - 1); 2179 fns = fns.right (fns.length() - fns.findRev ('/') - 1);
2209 switch( QMessageBox::information( this, tr("ZSafe"), 2180 switch( QMessageBox::information( this, tr("ZSafe"),
2210 tr("Do you want to save ") + fns + tr("\nbefore continuing?"), 2181 tr("Do you want to save ") + fns + tr("\nbefore continuing?"),
2211 tr("&Save"), 2182 tr("&Save"),
2212 tr("&Don't Save"), 2183 tr("&Don't Save"),
2213 0 // Enter == button 0 2184 0 // Enter == button 0
2214 ) ) 2185 ) )
2215 { // Escape == button 2 2186 { // Escape == button 2
2216 case 0: // Save clicked, Alt-S or Enter pressed. 2187 case 0: // Save clicked, Alt-S or Enter pressed.
2217 modified = false; 2188 modified = false;
2218 break; 2189 break;
2219 case 1: // Don't Save clicked or Alt-D pressed 2190 case 1: // Don't Save clicked or Alt-D pressed
2220 modified = false; 2191 modified = false;
2221 return true; 2192 return true;
2222 } 2193 }
2223 } 2194 }
2224 modified = false; 2195 modified = false;
2225 2196
2226 if (m_password.isEmpty()) 2197 if (m_password.isEmpty())
2227 return false; 2198 return false;
2228 2199
2229 int retval = saveInit(_filename, m_password); 2200 int retval = saveInit(_filename, m_password);
2230 // int retval = saveInit(_filename, "test"); 2201 // int retval = saveInit(_filename, "test");
2231 if (retval != PWERR_GOOD) { 2202 if (retval != PWERR_GOOD) {
2232 return false; 2203 return false;
2233 } 2204 }
2234 2205
2235 char* entry[FIELD_SIZE]; 2206 char* entry[FIELD_SIZE];
2236 2207
2237 // save the validation entry 2208 // save the validation entry
2238 { 2209 {
2239 int i=0; 2210 int i=0;
2240 entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); 2211 entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1);
2241 strcpy(entry[i++], "ZSAFECATEGORY"); 2212 strcpy(entry[i++], "ZSAFECATEGORY");
2242 entry[i] = (char*)malloc(strlen("name")+1); 2213 entry[i] = (char*)malloc(strlen("name")+1);
2243 strcpy(entry[i++], "name"); 2214 strcpy(entry[i++], "name");
2244 entry[i] = (char*)malloc(strlen("username")+1); 2215 entry[i] = (char*)malloc(strlen("username")+1);
2245 strcpy(entry[i++], "username"); 2216 strcpy(entry[i++], "username");
2246 entry[i] = (char*)malloc(strlen("password")+1); 2217 entry[i] = (char*)malloc(strlen("password")+1);
2247 strcpy(entry[i++], "password"); 2218 strcpy(entry[i++], "password");
2248 entry[i] = (char*)malloc(strlen("comment")+1); 2219 entry[i] = (char*)malloc(strlen("comment")+1);
2249 strcpy(entry[i++], "comment"); 2220 strcpy(entry[i++], "comment");
2250 2221
2251 entry[i] = (char*)malloc(strlen("field5")+1); 2222 entry[i] = (char*)malloc(strlen("field5")+1);
2252 strcpy(entry[i++], "field5"); 2223 strcpy(entry[i++], "field5");
2253 entry[i] = (char*)malloc(strlen("field6")+1); 2224 entry[i] = (char*)malloc(strlen("field6")+1);
2254 strcpy(entry[i++], "field6"); 2225 strcpy(entry[i++], "field6");
2255 2226
2256 retval = saveEntry(entry); 2227 retval = saveEntry(entry);
2257 for (int z=0; z<i; z++) free(entry[z]); 2228 for (int z=0; z<i; z++) free(entry[z]);
2258 if (retval == PWERR_DATA) { 2229 if (retval == PWERR_DATA) {
2259 owarn << "1: Error writing file, contents not saved" << oendl; 2230 owarn << "1: Error writing file, contents not saved" << oendl;
2260 saveFinalize(); 2231 saveFinalize();
2261 return false; 2232 return false;
2262 } 2233 }
2263// #ifndef WIN32 2234// #ifndef WIN32
2264 conf->writeEntry(APP_KEY+"valzsafe", 1); 2235 conf->writeEntry(APP_KEY+"valzsafe", 1);
2265// #endif 2236// #endif
2266 saveConf(); 2237 saveConf();
2267 } 2238 }
2268 2239
2269 QListViewItem *i; 2240 QListViewItem *i;
2270 // step through all categories 2241 // step through all categories
2271 for (i = ListView->firstChild(); 2242 for (i = ListView->firstChild();
2272 i != NULL; 2243 i != NULL;
2273 i = i->nextSibling()) 2244 i = i->nextSibling())
2274 { 2245 {
2275 // step through all subitems 2246 // step through all subitems
2276 QListViewItem *si; 2247 QListViewItem *si;
2277 for (si = i->firstChild(); 2248 for (si = i->firstChild();
2278 si != NULL; 2249 si != NULL;
2279 si = si->nextSibling()) 2250 si = si->nextSibling())
2280 { 2251 {
2281 int j=0; 2252 int j=0;
2282 entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); 2253 entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1);
2283 strcpy(entry[j++], i->text(0).utf8()); 2254 strcpy(entry[j++], i->text(0).utf8());
2284 entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); 2255 entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1);
2285 strcpy(entry[j++], si->text(0).utf8()); 2256 strcpy(entry[j++], si->text(0).utf8());
2286 entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); 2257 entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1);
2287 strcpy(entry[j++], si->text(1).utf8()); 2258 strcpy(entry[j++], si->text(1).utf8());
2288 entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); 2259 entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1);
2289 strcpy(entry[j++], si->text(2).utf8()); 2260 strcpy(entry[j++], si->text(2).utf8());
2290 entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); 2261 entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1);
2291 strcpy(entry[j++], si->text(3).utf8()); 2262 strcpy(entry[j++], si->text(3).utf8());
2292 entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); 2263 entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1);
2293 strcpy(entry[j++], si->text(4).utf8()); 2264 strcpy(entry[j++], si->text(4).utf8());
2294 entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); 2265 entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1);
2295 strcpy(entry[j++], si->text(5).utf8()); 2266 strcpy(entry[j++], si->text(5).utf8());
2296 2267
2297 retval = saveEntry(entry); 2268 retval = saveEntry(entry);
2298 for (int z=0; z<j; z++) 2269 for (int z=0; z<j; z++)
2299 { 2270 {
2300 free(entry[z]); 2271 free(entry[z]);
2301 } 2272 }
2302 if (retval == PWERR_DATA) { 2273 if (retval == PWERR_DATA) {
2303 owarn << "1: Error writing file, contents not saved" << oendl; 2274 owarn << "1: Error writing file, contents not saved" << oendl;
2304 saveFinalize(); 2275 saveFinalize();
2305 return false; 2276 return false;
2306 } 2277 }
2307 2278
2308 } 2279 }
2309 } 2280 }
2310 2281
2311 if (saveFinalize() == PWERR_DATA) { 2282 if (saveFinalize() == PWERR_DATA) {
2312 owarn << "2: Error writing file, contents not saved" << oendl; 2283 owarn << "2: Error writing file, contents not saved" << oendl;
2313 return false; 2284 return false;
2314 } else { 2285 } else {
2315#ifndef DESKTOP 2286#ifndef DESKTOP
2316 Global::statusMessage (tr("Password file saved.")); 2287 Global::statusMessage (tr("Password file saved."));
2317#endif 2288#endif
2318 modified = false; 2289 modified = false;
2319 return true; 2290 return true;
2320 } 2291 }
2321} 2292}
2322 2293
2323PasswordForm *newPwdDialog; 2294PasswordForm *newPwdDialog;
2324bool newPwdDialogResult = false; 2295bool newPwdDialogResult = false;
2325void ZSafe::setPasswordDialogDone() 2296void ZSafe::setPasswordDialogDone()
2326{ 2297{
2327 newPwdDialogResult = true; 2298 newPwdDialogResult = true;
2328 newPwdDialog->close(); 2299 newPwdDialog->close();
2329} 2300}
2330 2301
2331void ZSafe::getDocPassword(QString title) 2302void ZSafe::getDocPassword(QString title)
2332{ 2303{
2333qWarning ("getDocPassword"); 2304qWarning ("getDocPassword");
2334 // open the 'Password' dialog 2305 // open the 'Password' dialog
2335 PasswordForm *dialog = new PasswordForm(this, title, TRUE); 2306 PasswordForm *dialog = new PasswordForm(this, title, TRUE);
2336 newPwdDialog = dialog; 2307 newPwdDialog = dialog;
2337 newPwdDialogResult = false; 2308 newPwdDialogResult = false;
2338 2309
2339 connect( dialog->PasswordField, SIGNAL( returnPressed() ), 2310 connect( dialog->PasswordField, SIGNAL( returnPressed() ),
2340 this, SLOT( setPasswordDialogDone() ) ); 2311 this, SLOT( setPasswordDialogDone() ) );
2341 2312
2342 // CS: !!! 2313 // CS: !!!
2343 // int pos = filename.findRev ('/'); 2314 // int pos = filename.findRev ('/');
2344 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 2315 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
2345#ifdef WIN32 2316#ifdef WIN32
2346 dialog->setCaption("Qt " + ti); 2317 dialog->setCaption("Qt " + ti);
2347#else 2318#else
2348 dialog->setCaption(ti); 2319 dialog->setCaption(ti);
2349#endif 2320#endif
2350 // dialog->setCaption(title); 2321 // dialog->setCaption(title);
2351 2322
2352 dialog->PasswordField->setFocus(); 2323 dialog->PasswordField->setFocus();
2353 DialogCode result = (DialogCode) dialog->exec(); 2324 DialogCode result = (DialogCode) dialog->exec();
2354#ifdef DESKTOP 2325#ifdef DESKTOP
2355 result = Accepted; 2326 result = Accepted;
2356#endif 2327#endif
2357 2328
2358 QString password; 2329 QString password;
2359 if (result == Accepted || newPwdDialogResult) 2330 if (result == Accepted || newPwdDialogResult)
2360 { 2331 {
2361 m_password = dialog->PasswordField->text(); 2332 m_password = dialog->PasswordField->text();
2362 } 2333 }
2363 else 2334 else
2364 { 2335 {
2365 exitZs (1); 2336 exitZs (1);
2366 } 2337 }
2367} 2338}
2368 2339
2369int ZSafe::saveInit(const char *_filename, const char *password) 2340int ZSafe::saveInit(const char *_filename, const char *password)
2370{ 2341{
2371 char key[128]; 2342 char key[128];
2372 unsigned int j = 0; 2343 unsigned int j = 0;
2373 unsigned int keylength; 2344 unsigned int keylength;
2374 // int val; 2345 // int val;
2375 int count2; 2346 int count2;
2376 Krc2* krc2 = new Krc2(); 2347 Krc2* krc2 = new Krc2();
2377 2348
2378 /* first we should check the permissions of the filename */ 2349 /* first we should check the permissions of the filename */
2379/* 2350/*
2380 if (QFile::exists(_filename)) { 2351 if (QFile::exists(_filename)) {
2381 val = checkFile(_filename); 2352 val = checkFile(_filename);
2382 if (val != PWERR_GOOD) 2353 if (val != PWERR_GOOD)
2383 return val; 2354 return val;
2384 } else 2355 } else
2385 { 2356 {
2386 val = creat (_filename, (S_IRUSR | S_IWUSR)); 2357 val = creat (_filename, (S_IRUSR | S_IWUSR));
2387 if (val == -1) 2358 if (val == -1)
2388 return PWERR_OPEN; 2359 return PWERR_OPEN;
2389 else 2360 else
2390 close(val); 2361 close(val);
2391 } 2362 }
2392*/ 2363*/
2393 QFileInfo f (_filename); 2364 QFileInfo f (_filename);
2394 save_buffer_length = f.size(); 2365 save_buffer_length = f.size();
2395 save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; 2366 save_buffer_length = ((save_buffer_length / 1024)+1) * 1024;
2396 2367
2397 fd = fopen (_filename, "wb"); 2368 fd = fopen (_filename, "wb");
2398 if (fd == NULL) 2369 if (fd == NULL)
2399 return PWERR_OPEN; 2370 return PWERR_OPEN;
2400 2371
2401 buffer = (char*)malloc(save_buffer_length); 2372 buffer = (char*)malloc(save_buffer_length);
2402 2373
2403 /* make the key ready */ 2374 /* make the key ready */
2404 for (j = 0; password[j] != '\0'; j++) { 2375 for (j = 0; password[j] != '\0'; j++) {
2405 key[j] = password[j]; 2376 key[j] = password[j];
2406 } 2377 }
2407 keylength = j; 2378 keylength = j;
2408 krc2->rc2_expandkey (key, keylength, 128); 2379 krc2->rc2_expandkey (key, keylength, 128);
2409 2380
2410 /* First, we make the IV */ 2381 /* First, we make the IV */
2411 for (count2 = 0; count2 < 4; count2++) { 2382 for (count2 = 0; count2 < 4; count2++) {
2412 iv[count2] = rand (); 2383 iv[count2] = rand ();
2413 putc ((unsigned char) (iv[count2] >> 8), fd); 2384 putc ((unsigned char) (iv[count2] >> 8), fd);
2414 putc ((unsigned char) (iv[count2] & 0xff), fd); 2385 putc ((unsigned char) (iv[count2] & 0xff), fd);
2415 } 2386 }
2416 2387
2417 bufferIndex = 0; 2388 bufferIndex = 0;
2418 return PWERR_GOOD; 2389 return PWERR_GOOD;
2419} 2390}
2420 2391
2421 2392
2422int ZSafe::saveEntry(char *entry[FIELD_SIZE]) 2393int ZSafe::saveEntry(char *entry[FIELD_SIZE])
2423{ 2394{
2424 char *text1; 2395 char *text1;
2425 int count2, count3; 2396 int count2, count3;
2426 unsigned short ciphertext[4]; 2397 unsigned short ciphertext[4];
2427 Krc2* krc2 = new Krc2(); 2398 Krc2* krc2 = new Krc2();
2428 2399
2429 buffer = (char*)memset(buffer, '\0', save_buffer_length); 2400 buffer = (char*)memset(buffer, '\0', save_buffer_length);
2430 2401
2431 for (count2 = 0; count2 < FIELD_SIZE; count2++) { 2402 for (count2 = 0; count2 < FIELD_SIZE; count2++) {
2432 text1 = entry[count2]; 2403 text1 = entry[count2];
2433 if (strlen (text1) == 0) { 2404 if (strlen (text1) == 0) {
2434 strncat(buffer, " ", strlen(" ")); 2405 strncat(buffer, " ", strlen(" "));
2435 } else { 2406 } else {
2436 strncat(buffer, text1, strlen(text1)); 2407 strncat(buffer, text1, strlen(text1));
2437 } 2408 }
2438 /* Use 255 as the marker. \n is too tough to test for */ 2409 /* Use 255 as the marker. \n is too tough to test for */
2439 buffer[strlen (buffer)] = 255; 2410 buffer[strlen (buffer)] = 255;
2440 } /*for (count2 = 0; count2 < 5; count2++)*/ 2411 } /*for (count2 = 0; count2 < 5; count2++)*/
@@ -3062,257 +3033,257 @@ void ZSafe::editCategory()
3062 dialog->CategoryField->insertItem (category, i); 3033 dialog->CategoryField->insertItem (category, i);
3063 dialog->CategoryField->setCurrentItem(i); 3034 dialog->CategoryField->setCurrentItem(i);
3064 } 3035 }
3065 3036
3066 QString icon; 3037 QString icon;
3067 Category *cat= categories.find (selectedItem->text(0)); 3038 Category *cat= categories.find (selectedItem->text(0));
3068 if (cat) 3039 if (cat)
3069 { 3040 {
3070 icon = cat->getIconName(); 3041 icon = cat->getIconName();
3071 } 3042 }
3072 3043
3073 if (initIcons) 3044 if (initIcons)
3074 { 3045 {
3075 3046
3076 Wait waitDialog(this, tr("Wait dialog")); 3047 Wait waitDialog(this, tr("Wait dialog"));
3077 waitDialog.waitLabel->setText(tr("Gathering icons...")); 3048 waitDialog.waitLabel->setText(tr("Gathering icons..."));
3078 waitDialog.show(); 3049 waitDialog.show();
3079 qApp->processEvents(); 3050 qApp->processEvents();
3080 3051
3081#ifdef DESKTOP 3052#ifdef DESKTOP
3082 QDir d(iconPath); 3053 QDir d(iconPath);
3083#else 3054#else
3084 QDir d(QPEApplication::qpeDir() + "/pics/"); 3055 QDir d(QPEApplication::qpeDir() + "/pics/");
3085#endif 3056#endif
3086 d.setFilter( QDir::Files); 3057 d.setFilter( QDir::Files);
3087 3058
3088 const QFileInfoList *list = d.entryInfoList(); 3059 const QFileInfoList *list = d.entryInfoList();
3089 int i=0; 3060 int i=0;
3090 QFileInfoListIterator it( *list ); // create list iterator 3061 QFileInfoListIterator it( *list ); // create list iterator
3091 QFileInfo *fi; // pointer for traversing 3062 QFileInfo *fi; // pointer for traversing
3092 if (icon.isEmpty() || icon.isNull()) 3063 if (icon.isEmpty() || icon.isNull())
3093 { 3064 {
3094 dialog->IconField->setCurrentItem(0); 3065 dialog->IconField->setCurrentItem(0);
3095 } 3066 }
3096 3067
3097 dialog->IconField->insertItem("predefined"); 3068 dialog->IconField->insertItem("predefined");
3098 while ( (fi=it.current()) ) { // for each file... 3069 while ( (fi=it.current()) ) { // for each file...
3099 QString fileName = fi->fileName(); 3070 QString fileName = fi->fileName();
3100 if(fileName.right(4) == ".png") 3071 if(fileName.right(4) == ".png")
3101 { 3072 {
3102 fileName = fileName.mid(0,fileName.length()-4); 3073 fileName = fileName.mid(0,fileName.length()-4);
3103#ifdef DESKTOP 3074#ifdef DESKTOP
3104 QPixmap imageOfFile; 3075 QPixmap imageOfFile;
3105 imageOfFile.load(iconPath + fi->fileName()); 3076 imageOfFile.load(iconPath + fi->fileName());
3106#else 3077#else
3107 QPixmap imageOfFile(Resource::loadPixmap(fileName)); 3078 QPixmap imageOfFile(Resource::loadPixmap(fileName));
3108#endif 3079#endif
3109 QImage foo = imageOfFile.convertToImage(); 3080 QImage foo = imageOfFile.convertToImage();
3110 foo = foo.smoothScale(16,16); 3081 foo = foo.smoothScale(16,16);
3111 imageOfFile.convertFromImage(foo); 3082 imageOfFile.convertFromImage(foo);
3112 dialog->IconField->insertItem(imageOfFile,fileName); 3083 dialog->IconField->insertItem(imageOfFile,fileName);
3113 if(fileName+".png"==icon) 3084 if(fileName+".png"==icon)
3114 dialog->IconField->setCurrentItem(i+1); 3085 dialog->IconField->setCurrentItem(i+1);
3115 ++i; 3086 ++i;
3116 } 3087 }
3117 ++it; 3088 ++it;
3118 } 3089 }
3119 waitDialog.hide(); 3090 waitDialog.hide();
3120 } 3091 }
3121 else 3092 else
3122 { 3093 {
3123#ifdef DESKTOP 3094#ifdef DESKTOP
3124 // QDir d(QDir::homeDirPath() + "/pics/"); 3095 // QDir d(QDir::homeDirPath() + "/pics/");
3125 QDir d(iconPath); 3096 QDir d(iconPath);
3126#else 3097#else
3127 QDir d(QPEApplication::qpeDir() + "/pics/"); 3098 QDir d(QPEApplication::qpeDir() + "/pics/");
3128#endif 3099#endif
3129 d.setFilter( QDir::Files); 3100 d.setFilter( QDir::Files);
3130 3101
3131 const QFileInfoList *list = d.entryInfoList(); 3102 const QFileInfoList *list = d.entryInfoList();
3132 int i=0; 3103 int i=0;
3133 QFileInfoListIterator it( *list ); // create list iterator 3104 QFileInfoListIterator it( *list ); // create list iterator
3134 QFileInfo *fi; // pointer for traversing 3105 QFileInfo *fi; // pointer for traversing
3135 if (icon.isEmpty() || icon.isNull()) 3106 if (icon.isEmpty() || icon.isNull())
3136 { 3107 {
3137 dialog->IconField->setCurrentItem(0); 3108 dialog->IconField->setCurrentItem(0);
3138 } 3109 }
3139 else 3110 else
3140 { 3111 {
3141 3112
3142 while ( (fi=it.current()) ) 3113 while ( (fi=it.current()) )
3143 { // for each file... 3114 { // for each file...
3144 QString fileName = fi->fileName(); 3115 QString fileName = fi->fileName();
3145 if(fileName.right(4) == ".png") 3116 if(fileName.right(4) == ".png")
3146 { 3117 {
3147 fileName = fileName.mid(0,fileName.length()-4); 3118 fileName = fileName.mid(0,fileName.length()-4);
3148 3119
3149 3120
3150 if(fileName+".png"==icon) 3121 if(fileName+".png"==icon)
3151 { 3122 {
3152 dialog->IconField->setCurrentItem(i+1); 3123 dialog->IconField->setCurrentItem(i+1);
3153 break; 3124 break;
3154 } 3125 }
3155 ++i; 3126 ++i;
3156 } 3127 }
3157 ++it; 3128 ++it;
3158 } 3129 }
3159 } 3130 }
3160 } 3131 }
3161 3132
3162 // dialog->show(); 3133 // dialog->show();
3163#ifndef DESKTOP 3134#ifndef DESKTOP
3164 // dialog->move (20, 100); 3135 // dialog->move (20, 100);
3165#endif 3136#endif
3166 DialogCode result = (DialogCode) dialog->exec(); 3137 DialogCode result = (DialogCode) dialog->exec();
3167#ifdef DESKTOP 3138#ifdef DESKTOP
3168 result = Accepted; 3139 result = Accepted;
3169#endif 3140#endif
3170 3141
3171 QString fullIconPath; 3142 QString fullIconPath;
3172 QPixmap *pix; 3143 QPixmap *pix;
3173 if (result == Accepted) 3144 if (result == Accepted)
3174 { 3145 {
3175 modified = true; 3146 modified = true;
3176 if (category != dialog->CategoryField->currentText()) 3147 if (category != dialog->CategoryField->currentText())
3177 { 3148 {
3178 categories.remove (category); 3149 categories.remove (category);
3179// #ifndef WIN32 3150// #ifndef WIN32
3180 conf->removeEntry(category); 3151 conf->removeEntry(category);
3181// #endif 3152// #endif
3182 saveConf(); 3153 saveConf();
3183 } 3154 }
3184 3155
3185 category = dialog->CategoryField->currentText(); 3156 category = dialog->CategoryField->currentText();
3186 icon = dialog->IconField->currentText()+".png"; 3157 icon = dialog->IconField->currentText()+".png";
3187 3158
3188 if (cat) 3159 if (cat)
3189 { 3160 {
3190 owarn << "Category found" << oendl; 3161 owarn << "Category found" << oendl;
3191 3162
3192 // if (!icon.isEmpty() && !icon.isNull()) 3163 // if (!icon.isEmpty() && !icon.isNull())
3193 if (icon != "predefined.png") 3164 if (icon != "predefined.png")
3194 { 3165 {
3195 // build the full path 3166 // build the full path
3196 fullIconPath = iconPath + icon; 3167 fullIconPath = iconPath + icon;
3197 pix = new QPixmap (fullIconPath); 3168 pix = new QPixmap (fullIconPath);
3198 if (pix) 3169 if (pix)
3199 { 3170 {
3200 // save the full pixmap name into the config file 3171 // save the full pixmap name into the config file
3201// #ifndef WIN32 3172// #ifndef WIN32
3202 conf->writeEntry(APP_KEY+category, icon); 3173 conf->writeEntry(APP_KEY+category, icon);
3203// #endif 3174// #endif
3204 saveConf(); 3175 saveConf();
3205 QImage img = pix->convertToImage(); 3176 QImage img = pix->convertToImage();
3206 pix->convertFromImage(img.smoothScale(14,14)); 3177 pix->convertFromImage(img.smoothScale(14,14));
3207 cat->setIconName (icon); 3178 cat->setIconName (icon);
3208 cat->setIcon (*pix); 3179 cat->setIcon (*pix);
3209 } 3180 }
3210 } 3181 }
3211 else 3182 else
3212 { 3183 {
3213// #ifndef WIN32 3184// #ifndef WIN32
3214 conf->removeEntry (category); 3185 conf->removeEntry (category);
3215// #endif 3186// #endif
3216 saveConf(); 3187 saveConf();
3217 cat->setIcon (*getPredefinedIcon(category)); 3188 cat->setIcon (*getPredefinedIcon(category));
3218 } 3189 }
3219 3190
3220 // change the category name of the selected category 3191 // change the category name of the selected category
3221 QListViewItem *catItem = cat->getListItem(); 3192 QListViewItem *catItem = cat->getListItem();
3222 if (catItem) 3193 if (catItem)
3223 { 3194 {
3224 qWarning (category); 3195 qWarning (category);
3225 catItem->setText( 0, tr( category ) ); 3196 catItem->setText( 0, tr( category ) );
3226 cat->setCategoryName (tr(category)); 3197 cat->setCategoryName (tr(category));
3227 3198
3228 cat->initListItem(); 3199 cat->initListItem();
3229 categories.insert (category, cat); 3200 categories.insert (category, cat);
3230 } 3201 }
3231 } 3202 }
3232 saveCategoryDialogFields(dialog); 3203 saveCategoryDialogFields(dialog);
3233 } 3204 }
3234 else 3205 else
3235 { 3206 {
3236 // delete dialog; 3207 // delete dialog;
3237 dialog->hide(); 3208 dialog->hide();
3238 return; 3209 return;
3239 } 3210 }
3240 3211
3241 } 3212 }
3242} 3213}
3243 3214
3244void ZSafe::cutItem() 3215void ZSafe::cutItem()
3245{ 3216{
3246 if (!selectedItem) 3217 if (!selectedItem)
3247 return; 3218 return;
3248 if (!isCategory(selectedItem)) 3219 if (!isCategory(selectedItem))
3249 { 3220 {
3250 IsCut = true; 3221 IsCut = true;
3251 copiedItem = selectedItem; 3222 copiedItem = selectedItem;
3252 } 3223 }
3253} 3224}
3254 3225
3255void ZSafe::copyItem() 3226void ZSafe::copyItem()
3256{ 3227{
3257 if (!selectedItem) 3228 if (!selectedItem)
3258 return; 3229 return;
3259 if (!isCategory(selectedItem)) 3230 if (!isCategory(selectedItem))
3260 { 3231 {
3261 IsCopy = true; 3232 IsCopy = true;
3262 copiedItem = selectedItem; 3233 copiedItem = selectedItem;
3263 } 3234 }
3264} 3235}
3265 3236
3266// paste item into category 3237// paste item into category
3267void ZSafe::pasteItem() 3238void ZSafe::pasteItem()
3268{ 3239{
3269 if (!selectedItem) 3240 if (!selectedItem)
3270 return; 3241 return;
3271 if (isCategory(selectedItem)) 3242 if (isCategory(selectedItem))
3272 { 3243 {
3273 modified = true; 3244 modified = true;
3274 if (IsCut) 3245 if (IsCut)
3275 { 3246 {
3276 if (copiedItem) 3247 if (copiedItem)
3277 { 3248 {
3278 // add the new item 3249 // add the new item
3279 QListViewItem *i = new ShadedListItem (0, selectedItem); 3250 QListViewItem *i = new ShadedListItem (0, selectedItem);
3280 // i->setOpen (TRUE); 3251 // i->setOpen (TRUE);
3281 i->setText (0, copiedItem->text(0)); 3252 i->setText (0, copiedItem->text(0));
3282 i->setText (1, copiedItem->text(1)); 3253 i->setText (1, copiedItem->text(1));
3283 i->setText (2, copiedItem->text(2)); 3254 i->setText (2, copiedItem->text(2));
3284 i->setText (3, copiedItem->text(3)); 3255 i->setText (3, copiedItem->text(3));
3285 i->setText (4, copiedItem->text(4)); 3256 i->setText (4, copiedItem->text(4));
3286 i->setText (5, copiedItem->text(5)); 3257 i->setText (5, copiedItem->text(5));
3287 selectedItem->setOpen( TRUE ); 3258 selectedItem->setOpen( TRUE );
3288 3259
3289 // remove the cutted item 3260 // remove the cutted item
3290 copiedItem->parent()->takeItem(copiedItem); 3261 copiedItem->parent()->takeItem(copiedItem);
3291 selectedItem = NULL; 3262 selectedItem = NULL;
3292 } 3263 }
3293 } 3264 }
3294 else if (IsCopy) 3265 else if (IsCopy)
3295 { 3266 {
3296 if (copiedItem) 3267 if (copiedItem)
3297 { 3268 {
3298 // add the new item 3269 // add the new item
3299 QListViewItem *i = new ShadedListItem (0, selectedItem); 3270 QListViewItem *i = new ShadedListItem (0, selectedItem);
3300 // i->setOpen (TRUE); 3271 // i->setOpen (TRUE);
3301 i->setText (0, copiedItem->text(0)); 3272 i->setText (0, copiedItem->text(0));
3302 i->setText (1, copiedItem->text(1)); 3273 i->setText (1, copiedItem->text(1));
3303 i->setText (2, copiedItem->text(2)); 3274 i->setText (2, copiedItem->text(2));
3304 i->setText (3, copiedItem->text(3)); 3275 i->setText (3, copiedItem->text(3));
3305 i->setText (4, copiedItem->text(4)); 3276 i->setText (4, copiedItem->text(4));
3306 i->setText (5, copiedItem->text(5)); 3277 i->setText (5, copiedItem->text(5));
3307 selectedItem->setOpen( TRUE ); 3278 selectedItem->setOpen( TRUE );
3308 } 3279 }
3309 } 3280 }
3310 } 3281 }
3311 IsCut = false; 3282 IsCut = false;
3312 IsCopy = false; 3283 IsCopy = false;
3313} 3284}
3314 3285
3315void ZSafe::newDocument() 3286void ZSafe::newDocument()
3316{ 3287{
3317 3288
3318 // open the file dialog 3289 // open the file dialog