summaryrefslogtreecommitdiff
authorzcarsten <zcarsten>2003-08-13 16:54:10 (UTC)
committer zcarsten <zcarsten>2003-08-13 16:54:10 (UTC)
commit7bb7c8f7f2af7854e3d50f07a8ff33ee3462c194 (patch) (unidiff)
tree06c6127d5a89ba75f127c709c3aaa46dcb38853e
parent1b22b22d6e50b46f3ea04b5a1cfc3dc9bfd8a78a (diff)
downloadopie-7bb7c8f7f2af7854e3d50f07a8ff33ee3462c194.zip
opie-7bb7c8f7f2af7854e3d50f07a8ff33ee3462c194.tar.gz
opie-7bb7c8f7f2af7854e3d50f07a8ff33ee3462c194.tar.bz2
japanese support added (see defines JPATCH_HDE)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/categorylist.cpp6
-rw-r--r--noncore/apps/zsafe/categorylist.h6
-rw-r--r--noncore/apps/zsafe/zsafe.cpp201
3 files changed, 171 insertions, 42 deletions
diff --git a/noncore/apps/zsafe/categorylist.cpp b/noncore/apps/zsafe/categorylist.cpp
index 2fa59d2..c5e8d66 100644
--- a/noncore/apps/zsafe/categorylist.cpp
+++ b/noncore/apps/zsafe/categorylist.cpp
@@ -1,35 +1,35 @@
1/* C implementation of RC2 encryption algorithm, as described in RFC2268 */ 1/* C implementation of RC2 encryption algorithm, as described in RFC2268 */
2/* By Matthew Palmer <mjp16@uow.edu.au> */ 2/* By Matthew Palmer <mjp16@uow.edu.au> */
3/* $Id$ */ 3/* $Id$ */
4 4
5#include "categorylist.h" 5#include "categorylist.h"
6 6
7CategoryList::CategoryList() 7CategoryList::CategoryList()
8{ 8{
9} 9}
10 10
11CategoryList::~CategoryList() 11CategoryList::~CategoryList()
12{ 12{
13} 13}
14 14
15void CategoryList::insert (QString key, Category *category) 15void CategoryList::insert (QString key, Category *category)
16{ 16{
17 categoryList.insert ((const char *) key, category); 17 categoryList.insert (key, category);
18} 18}
19 19
20Category *CategoryList::find (QString key) 20Category *CategoryList::find (QString key)
21{ 21{
22 return categoryList.find ((const char *) key); 22 return categoryList.find (key);
23} 23}
24 24
25void CategoryList::remove (QString key) 25void CategoryList::remove (QString key)
26{ 26{
27 categoryList.remove ((const char *) key); 27 categoryList.remove (key);
28} 28}
29 29
30void CategoryList::clear() 30void CategoryList::clear()
31{ 31{
32 categoryList.clear(); 32 categoryList.clear();
33} 33}
34 34
35 35
diff --git a/noncore/apps/zsafe/categorylist.h b/noncore/apps/zsafe/categorylist.h
index 96cf389..fc1c0a2 100644
--- a/noncore/apps/zsafe/categorylist.h
+++ b/noncore/apps/zsafe/categorylist.h
@@ -1,32 +1,34 @@
1/* 1/*
2** $Id$ 2** $Id$
3*/ 3*/
4#ifndef _CATEGORY_LIST_H_ 4#ifndef _CATEGORY_LIST_H_
5#define _CATEGORY_LIST_H_ 5#define _CATEGORY_LIST_H_
6 6
7#include <qstring.h> 7#include <qstring.h>
8#include <qasciidict.h> 8
9#include <qdict.h>
10
9#include "category.h" 11#include "category.h"
10 12
11// list of Category 13// list of Category
12 14
13class CategoryList 15class CategoryList
14{ 16{
15public: 17public:
16 CategoryList(); 18 CategoryList();
17 ~CategoryList(); 19 ~CategoryList();
18 20
19 void insert (QString key, Category *category); 21 void insert (QString key, Category *category);
20 Category *find (QString key); 22 Category *find (QString key);
21 void remove (QString key); 23 void remove (QString key);
22 void clear(); 24 void clear();
23 25
24 QAsciiDict<Category> categoryList; 26 QDict<Category> categoryList;
25 27
26private: 28private:
27 29
28}; 30};
29#endif // _CATEGORY_LIST_H_ 31#endif // _CATEGORY_LIST_H_
30 32
31 33
32 34
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index 9341425..d55624b 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -1,64 +1,66 @@
1/**************************************************************************** 1/****************************************************************************
2** 2**
3** Created: Sat Apr 6 17:57:45 2002 3** Created: Sat Apr 6 17:57:45 2002
4** 4**
5** Author: Carsten Schneider <CarstenSchneider@t-online.de> 5** Author: Carsten Schneider <CarstenSchneider@t-online.de>
6** 6**
7** $Id$ 7** $Id$
8** 8**
9** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html 9** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html
10** 10**
11** Compile Flags: 11** Compile Flags:
12** Zaurus arm : -DNO_OPIE 12** Zaurus arm : -DNO_OPIE
13** Zaurus Opie arm: none 13** Zaurus Opie arm: none
14** Linux Desktop : -DDESKTOP 14** Linux Desktop : -DDESKTOP
15** Windows Desktop: -DDESKTOP -DWIN32 15** Windows Desktop: -DDESKTOP -DWIN32
16** 16**
17** for japanese version additional use: -DJPATCH_HDE
18**
17****************************************************************************/ 19****************************************************************************/
18#include "zsafe.h" 20#include "zsafe.h"
19#include "newdialog.h" 21#include "newdialog.h"
20#include "searchdialog.h" 22#include "searchdialog.h"
21#include "categorydialog.h" 23#include "categorydialog.h"
22#include "passworddialog.h" 24#include "passworddialog.h"
23#include "infoform.h" 25#include "infoform.h"
24#include "zlistview.h" 26#include "zlistview.h"
25#include "shadedlistitem.h" 27#include "shadedlistitem.h"
26 28
27#ifndef DESKTOP 29#ifndef DESKTOP
28#ifndef NO_OPIE 30#ifndef NO_OPIE
29#include <opie/ofiledialog.h> 31#include <opie/ofiledialog.h>
30#else 32#else
31#include "scqtfileedit.h" 33#include "scqtfileedit.h"
32#endif 34#endif
33#endif 35#endif
34 36
35#include <qclipboard.h> 37#include <qclipboard.h>
36 38
37#include <stdio.h> 39#include <stdio.h>
38 40
39#include <sys/types.h> 41#include <sys/types.h>
40#include <sys/stat.h> 42#include <sys/stat.h>
41#include <fcntl.h> 43#include <fcntl.h>
42#include <stdlib.h> 44#include <stdlib.h>
43#ifndef WIN32 45#ifndef WIN32
44#include <unistd.h> 46#include <unistd.h>
45#endif 47#endif
46#include <string.h> 48#include <string.h>
47#include <errno.h> 49#include <errno.h>
48 50
49#include <qmenubar.h> 51#include <qmenubar.h>
50#include <qpopupmenu.h> 52#include <qpopupmenu.h>
51 53
52#ifdef DESKTOP 54#ifdef DESKTOP
53#include <qfiledialog.h> 55#include <qfiledialog.h>
54#ifndef WIN32 56#ifndef WIN32
55#include <qsettings.h> 57#include <qsettings.h>
56#else 58#else
57#include "qsettings.h" 59#include "qsettings.h"
58#endif 60#endif
59#include <qapplication.h> 61#include <qapplication.h>
60#else 62#else
61#include <qfile.h> 63#include <qfile.h>
62#include <qpe/fileselector.h> 64#include <qpe/fileselector.h>
63#include <qpe/global.h> 65#include <qpe/global.h>
64#include <qpe/qpeapplication.h> 66#include <qpe/qpeapplication.h>
@@ -409,103 +411,116 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
409#else 411#else
410 conf = new QSettings (cfgFile); 412 conf = new QSettings (cfgFile);
411 conf->insertSearchPath (QSettings::Unix, cfgFile); 413 conf->insertSearchPath (QSettings::Unix, cfgFile);
412#endif 414#endif
413#else 415#else
414 conf = new Config (cfgFile, Config::File); 416 conf = new Config (cfgFile, Config::File);
415 conf->setGroup ("zsafePrefs"); 417 conf->setGroup ("zsafePrefs");
416#endif 418#endif
417#ifdef DESKTOP 419#ifdef DESKTOP
418// #ifndef WIN32 420// #ifndef WIN32
419 expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); 421 expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false);
420// #endif 422// #endif
421#else 423#else
422 expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); 424 expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0);
423#endif 425#endif
424#ifndef DESKTOP 426#ifndef DESKTOP
425 conf->setGroup ("zsafe"); 427 conf->setGroup ("zsafe");
426#endif 428#endif
427 429
428 QPixmap copy_img((const char**) copy_xpm); 430 QPixmap copy_img((const char**) copy_xpm);
429 QPixmap cut_img((const char**) cut_xpm); 431 QPixmap cut_img((const char**) cut_xpm);
430 QPixmap edit_img((const char**) edit_xpm); 432 QPixmap edit_img((const char**) edit_xpm);
431 QPixmap editdelete_img((const char**) editdelete_xpm); 433 QPixmap editdelete_img((const char**) editdelete_xpm);
432 QPixmap find_img((const char**) find_xpm); 434 QPixmap find_img((const char**) find_xpm);
433 QPixmap folder_open_img((const char**) folder_open_xpm); 435 QPixmap folder_open_img((const char**) folder_open_xpm);
434 QPixmap help_icon_img((const char**) help_icon_xpm); 436 QPixmap help_icon_img((const char**) help_icon_xpm);
435 QPixmap new_img((const char**) new_xpm); 437 QPixmap new_img((const char**) new_xpm);
436 QPixmap paste_img((const char**) paste_xpm); 438 QPixmap paste_img((const char**) paste_xpm);
437 QPixmap quit_icon_img((const char**) quit_icon_xpm); 439 QPixmap quit_icon_img((const char**) quit_icon_xpm);
438 QPixmap save_img((const char**) save_xpm); 440 QPixmap save_img((const char**) save_xpm);
439 QPixmap trash_img((const char**) trash_xpm); 441 QPixmap trash_img((const char**) trash_xpm);
440 QPixmap expand_img((const char**) expand_xpm); 442 QPixmap expand_img((const char**) expand_xpm);
441 QPixmap export_img((const char**) export_xpm); 443 QPixmap export_img((const char**) export_xpm);
442 QPixmap import_img((const char**) import_xpm); 444 QPixmap import_img((const char**) import_xpm);
443 445
444 QPixmap bank_cards( ( const char** ) bank_cards_data ); 446 QPixmap bank_cards( ( const char** ) bank_cards_data );
445 QPixmap passwords( ( const char** ) passwords_data ); 447 QPixmap passwords( ( const char** ) passwords_data );
446 QPixmap software( ( const char** ) software_data ); 448 QPixmap software( ( const char** ) software_data );
447 QPixmap general( ( const char** ) general_data ); 449 QPixmap general( ( const char** ) general_data );
448 if ( !name ) 450 if ( !name )
449 setName( "ZSafe" ); 451 setName( "ZSafe" );
450 452
451#ifdef DESKTOP 453#ifdef DESKTOP
452#ifdef WIN32 454#ifdef WIN32
453 setGeometry(100, 150, DeskW, DeskH-30 ); 455 setGeometry(100, 150, DeskW, DeskH-30 );
454#else 456#else
455 resize( DeskW, DeskH-30 ); 457 resize( DeskW, DeskH-30 );
456#endif 458#endif
457 // setMinimumSize( QSize( DeskW, DeskH-30 ) ); 459
458 // setMaximumSize( QSize( DeskW, DeskH-30 ) );
459#else 460#else
460 resize( DeskW, DeskH-30 ); 461
461 // setMinimumSize( QSize( DeskW, DeskH-30 ) ); 462#ifdef JPATCH_HDE
462 // setMaximumSize( QSize( 440, 290 ) ); 463 int DeskS;
463 // setMaximumSize( QSize( DeskW+400, DeskH+200 ) ); 464 if(DeskW > DeskH)
465 {
466 DeskS = DeskW;
467 }
468 else
469 {
470 DeskS = DeskH;
471 }
472 resize( DeskW, DeskH );
473 setMinimumSize( QSize( DeskS, DeskS ) );
474 setMaximumSize( QSize( DeskS, DeskS ) );
475#else
476 resize( DeskW, DeskH-30 );
477#endif
478
464#endif 479#endif
465 // setCaption( tr( "ZSafe" ) ); 480 // setCaption( tr( "ZSafe" ) );
466 481
467 filename = conf->readEntry(APP_KEY+"document"); 482 filename = conf->readEntry(APP_KEY+"document");
468 if (filename.isEmpty() || filename.isNull()) 483 if (filename.isEmpty() || filename.isNull())
469 { 484 {
470 485
471 // check if the directory application exists, if not 486 // check if the directory application exists, if not
472 // create it 487 // create it
473// #ifndef WIN32 488// #ifndef WIN32
474 // QString d1("Documents/application"); 489 // QString d1("Documents/application");
475// #else 490// #else
476 QString d1(QDir::homeDirPath() + "/Documents/application"); 491 QString d1(QDir::homeDirPath() + "/Documents/application");
477// #endif 492// #endif
478 QDir pd1(d1); 493 QDir pd1(d1);
479 if (!pd1.exists()) 494 if (!pd1.exists())
480 { 495 {
481 QDir pd1("Documents"); 496 QDir pd1("Documents");
482 if (!pd1.mkdir("application", FALSE)) 497 if (!pd1.mkdir("application", FALSE))
483 { 498 {
484 QMessageBox::critical( 0, tr("ZSafe"), 499 QMessageBox::critical( 0, tr("ZSafe"),
485 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1)); 500 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1));
486 exitZs (1); 501 exitZs (1);
487 } 502 }
488 } 503 }
489// #ifndef WIN32 504// #ifndef WIN32
490 // QString d2("Documents/application/zsafe"); 505 // QString d2("Documents/application/zsafe");
491// #else 506// #else
492 QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); 507 QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
493// #endif 508// #endif
494 QDir pd2(d2); 509 QDir pd2(d2);
495 if (!pd2.exists()) 510 if (!pd2.exists())
496 { 511 {
497 QDir pd2("Documents/application"); 512 QDir pd2("Documents/application");
498 if (!pd2.mkdir("zsafe", FALSE)) 513 if (!pd2.mkdir("zsafe", FALSE))
499 { 514 {
500 QMessageBox::critical( 0, tr("ZSafe"), 515 QMessageBox::critical( 0, tr("ZSafe"),
501 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2)); 516 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2));
502 exitZs (1); 517 exitZs (1);
503 } 518 }
504 } 519 }
505 520
506 521
507 // set the default filename 522 // set the default filename
508 filename=d2 + "/passwords.zsf"; 523 filename=d2 + "/passwords.zsf";
509 524
510 // save the current filename to the config file 525 // save the current filename to the config file
511 conf->writeEntry(APP_KEY+"document", filename); 526 conf->writeEntry(APP_KEY+"document", filename);
@@ -715,187 +730,219 @@ void ZSafe::deletePwd()
715 } 730 }
716} 731}
717 732
718void ZSafe::editPwd() 733void ZSafe::editPwd()
719{ 734{
720 if (!selectedItem) 735 if (!selectedItem)
721 return; 736 return;
722 if (!isCategory(selectedItem)) 737 if (!isCategory(selectedItem))
723 { 738 {
724 // open the 'New Entry' dialog 739 // open the 'New Entry' dialog
725 NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); 740 NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE);
726#ifdef WIN32 741#ifdef WIN32
727 dialog->setCaption ("Qt " + tr("Edit Entry")); 742 dialog->setCaption ("Qt " + tr("Edit Entry"));
728 dialog->setGeometry(200, 250, 220, 310 ); 743 dialog->setGeometry(200, 250, 220, 310 );
729#endif 744#endif
730 745
731 // set the labels 746 // set the labels
732 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); 747 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
733 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); 748 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
734 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); 749 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
735 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); 750 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
736 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); 751 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
737 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); 752 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
738 753
739 // set the fields 754 // set the fields
740 dialog->NameField->setText(selectedItem->text (0)); 755 dialog->NameField->setText(selectedItem->text (0));
741 dialog->UsernameField->setText(selectedItem->text (1)); 756 dialog->UsernameField->setText(selectedItem->text (1));
742 dialog->PasswordField->setText(selectedItem->text (2)); 757 dialog->PasswordField->setText(selectedItem->text (2));
743 QString comment = selectedItem->text (3); 758 QString comment = selectedItem->text (3);
744 comment.replace (QRegExp("<br>"), "\n"); 759 comment.replace (QRegExp("<br>"), "\n");
745 dialog->Field5->setText(selectedItem->text (4)); 760 dialog->Field5->setText(selectedItem->text (4));
746 dialog->Field6->setText(selectedItem->text (5)); 761 dialog->Field6->setText(selectedItem->text (5));
747 dialog->CommentField->insertLine(comment); 762 dialog->CommentField->insertLine(comment);
748 dialog->CommentField->setCursorPosition(0,0); 763 dialog->CommentField->setCursorPosition(0,0);
749#ifdef DESKTOP 764#ifdef DESKTOP
750#ifndef WIN32 765#ifndef WIN32
751 dialog->show(); 766 dialog->show();
752#endif 767#endif
753#else 768#else
754 dialog->showMaximized(); 769 dialog->showMaximized();
755#endif 770#endif
756 DialogCode result = (DialogCode) dialog->exec(); 771 DialogCode result = (DialogCode) dialog->exec();
757 772
758#ifdef DESKTOP 773#ifdef DESKTOP
759 result = Accepted; 774 result = Accepted;
760#endif 775#endif
761 if (result == Accepted) 776 if (result == Accepted)
762 { 777 {
778#ifdef JPATCH_HDE
779 // edit the selected item
780 QString name = dialog->NameField->text();
781 selectedItem->setText (0, name);
782 QString user = dialog->UsernameField->text();
783 selectedItem->setText (1, user);
784 QString pwd = dialog->PasswordField->text();
785 selectedItem->setText (2, pwd);
786 QString comment = dialog->CommentField->text();
787 comment.replace (QRegExp("\n"), "<br>");
788 selectedItem->setText (3, comment);
789 QString f5 = dialog->Field5->text();
790 selectedItem->setText (4, f5);
791 QString f6 = dialog->Field6->text();
792 selectedItem->setText (5, f6);
793#else
763 modified = true; 794 modified = true;
764 // edit the selected item 795 // edit the selected item
765 QString name = dialog->NameField->text(); 796 QString name = dialog->NameField->text();
766 selectedItem->setText (0, tr (name)); 797 selectedItem->setText (0, tr (name));
767 QString user = dialog->UsernameField->text(); 798 QString user = dialog->UsernameField->text();
768 selectedItem->setText (1, tr (user)); 799 selectedItem->setText (1, tr (user));
769 QString pwd = dialog->PasswordField->text(); 800 QString pwd = dialog->PasswordField->text();
770 selectedItem->setText (2, tr (pwd)); 801 selectedItem->setText (2, tr (pwd));
771 QString comment = dialog->CommentField->text(); 802 QString comment = dialog->CommentField->text();
772 comment.replace (QRegExp("\n"), "<br>"); 803 comment.replace (QRegExp("\n"), "<br>");
773 selectedItem->setText (3, tr (comment)); 804 selectedItem->setText (3, tr (comment));
774 QString f5 = dialog->Field5->text(); 805 QString f5 = dialog->Field5->text();
775 selectedItem->setText (4, tr (f5)); 806 selectedItem->setText (4, tr (f5));
776 QString f6 = dialog->Field6->text(); 807 QString f6 = dialog->Field6->text();
777 selectedItem->setText (5, tr (f6)); 808 selectedItem->setText (5, tr (f6));
809#endif
778 } 810 }
779 811
780 delete dialog; 812 delete dialog;
781 } 813 }
782 else 814 else
783 { 815 {
784 editCategory(); 816 editCategory();
785 } 817 }
786} 818}
787 819
788void ZSafe::newPwd() 820void ZSafe::newPwd()
789{ 821{
790 if (!selectedItem) 822 if (!selectedItem)
791 return; 823 return;
792 824
793 if (!isCategory(selectedItem)) 825 if (!isCategory(selectedItem))
794 selectedItem = selectedItem->parent(); 826 selectedItem = selectedItem->parent();
795 827
796 if (isCategory(selectedItem)) 828 if (isCategory(selectedItem))
797 { 829 {
798 QString cat = selectedItem->text(0); 830 QString cat = selectedItem->text(0);
799 831
800 // open the 'New Entry' dialog 832 // open the 'New Entry' dialog
801 NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE); 833 NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE);
802#ifdef WIN32 834#ifdef WIN32
803 dialog->setCaption ("Qt " + tr("New Entry")); 835 dialog->setCaption ("Qt " + tr("New Entry"));
804 dialog->setGeometry(200, 250, 220, 310 ); 836 dialog->setGeometry(200, 250, 220, 310 );
805#endif 837#endif
806 // set the labels 838 // set the labels
807 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); 839 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
808 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); 840 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
809 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); 841 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
810 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); 842 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
811 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); 843 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
812 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); 844 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
813retype: 845retype:
814#ifdef DESKTOP 846#ifdef DESKTOP
815#ifndef WIN32 847#ifndef WIN32
816 dialog->show(); 848 dialog->show();
817#endif 849#endif
818#else 850#else
819 dialog->showMaximized(); 851 dialog->showMaximized();
820#endif 852#endif
821 DialogCode result = (DialogCode) dialog->exec(); 853 DialogCode result = (DialogCode) dialog->exec();
822#ifdef DESKTOP 854#ifdef DESKTOP
823 result = Accepted; 855 result = Accepted;
824#endif 856#endif
825 857
826 if (result == Accepted) 858 if (result == Accepted)
827 { 859 {
828 860
829 QString name = dialog->NameField->text(); 861 QString name = dialog->NameField->text();
830 if (cat == name) 862 if (cat == name)
831 { 863 {
832 QMessageBox::critical( 0, tr("ZSafe"), 864 QMessageBox::critical( 0, tr("ZSafe"),
833 tr("Entry name must be different\nfrom the category name.") ); 865 tr("Entry name must be different\nfrom the category name.") );
834 goto retype; // it's not a good programming style :-) 866 goto retype; // it's not a good programming style :-)
835 } 867 }
836 868
837 modified = true; 869 modified = true;
838 // add the new item 870 // add the new item
839 QListViewItem *i = new ShadedListItem (0, selectedItem); 871 QListViewItem *i = new ShadedListItem (0, selectedItem);
840 i->setOpen (TRUE); 872 i->setOpen (TRUE);
841 873
874#ifdef JPATCH_HDE
875 i->setText (0, name);
876 QString user = dialog->UsernameField->text();
877 i->setText (1, user);
878 QString pwd = dialog->PasswordField->text();
879 i->setText (2, pwd);
880 QString comment = dialog->CommentField->text();
881 comment.replace (QRegExp("\n"), "<br>");
882 i->setText (3, comment);
883 QString f5 = dialog->Field5->text();
884 i->setText (4, f5);
885 QString f6 = dialog->Field6->text();
886 i->setText (5, f6);
887#else
842 i->setText (0, tr (name)); 888 i->setText (0, tr (name));
843 QString user = dialog->UsernameField->text(); 889 QString user = dialog->UsernameField->text();
844 i->setText (1, tr (user)); 890 i->setText (1, tr (user));
845 QString pwd = dialog->PasswordField->text(); 891 QString pwd = dialog->PasswordField->text();
846 i->setText (2, tr (pwd)); 892 i->setText (2, tr (pwd));
847 QString comment = dialog->CommentField->text(); 893 QString comment = dialog->CommentField->text();
848 comment.replace (QRegExp("\n"), "<br>"); 894 comment.replace (QRegExp("\n"), "<br>");
849 i->setText (3, tr (comment)); 895 i->setText (3, tr (comment));
850 QString f5 = dialog->Field5->text(); 896 QString f5 = dialog->Field5->text();
851 i->setText (4, tr (f5)); 897 i->setText (4, tr (f5));
852 QString f6 = dialog->Field6->text(); 898 QString f6 = dialog->Field6->text();
853 i->setText (5, tr (f6)); 899 i->setText (5, tr (f6));
900#endif
854 } 901 }
855 902
856 delete dialog; 903 delete dialog;
857 } 904 }
858} 905}
859 906
860void ZSafe::findPwd() 907void ZSafe::findPwd()
861{ 908{
862 909
863 // open the 'Search' dialog 910 // open the 'Search' dialog
864 SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); 911 SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE);
865#ifdef WIN32 912#ifdef WIN32
866 dialog->setCaption ("Qt " + tr("Search")); 913 dialog->setCaption ("Qt " + tr("Search"));
867#endif 914#endif
868 915
869#ifdef DESKTOP 916#ifdef DESKTOP
870#endif 917#endif
871 if (lastSearchedName) 918 if (lastSearchedName)
872 dialog->NameField->setText(lastSearchedName); 919 dialog->NameField->setText(lastSearchedName);
873 else 920 else
874 dialog->NameField->setText(""); 921 dialog->NameField->setText("");
875 if (lastSearchedUsername) 922 if (lastSearchedUsername)
876 dialog->UsernameField->setText(lastSearchedUsername); 923 dialog->UsernameField->setText(lastSearchedUsername);
877 else 924 else
878 dialog->UsernameField->setText(""); 925 dialog->UsernameField->setText("");
879 if (lastSearchedComment) 926 if (lastSearchedComment)
880 dialog->CommentField->setText(lastSearchedComment); 927 dialog->CommentField->setText(lastSearchedComment);
881 else 928 else
882 dialog->CommentField->setText(""); 929 dialog->CommentField->setText("");
883 DialogCode result = (DialogCode) dialog->exec(); 930 DialogCode result = (DialogCode) dialog->exec();
884#ifdef DESKTOP 931#ifdef DESKTOP
885 result = Accepted; 932 result = Accepted;
886#endif 933#endif
887 934
888 QString name; 935 QString name;
889 QString username; 936 QString username;
890 QString comment; 937 QString comment;
891 if (result == Accepted) 938 if (result == Accepted)
892 { 939 {
893 name = dialog->NameField->text(); 940 name = dialog->NameField->text();
894 username = dialog->UsernameField->text(); 941 username = dialog->UsernameField->text();
895 comment = dialog->CommentField->text(); 942 comment = dialog->CommentField->text();
896 qWarning (name); 943 qWarning (name);
897 } 944 }
898 else 945 else
899 { 946 {
900 delete dialog; 947 delete dialog;
901 return; 948 return;
@@ -1159,97 +1206,97 @@ void ZSafe::showInfo( QListViewItem *_item)
1159 1206
1160 infoForm->InfoText->setText(text); 1207 infoForm->InfoText->setText(text);
1161 infoForm->hide(); 1208 infoForm->hide();
1162#ifdef DESKTOP 1209#ifdef DESKTOP
1163 infoForm->show(); 1210 infoForm->show();
1164#else 1211#else
1165 infoForm->showMaximized(); 1212 infoForm->showMaximized();
1166#endif 1213#endif
1167 1214
1168 } 1215 }
1169} 1216}
1170 1217
1171void ZSafe::listViewSelected( QListViewItem *_item) 1218void ZSafe::listViewSelected( QListViewItem *_item)
1172{ 1219{
1173 if (!_item) 1220 if (!_item)
1174 return; 1221 return;
1175 if (selectedItem != NULL) 1222 if (selectedItem != NULL)
1176 selectedItem->setSelected(FALSE); 1223 selectedItem->setSelected(FALSE);
1177 1224
1178 selectedItem = _item; 1225 selectedItem = _item;
1179 1226
1180#ifndef DESKTOP 1227#ifndef DESKTOP
1181 // set the column text dependent on the selected item 1228 // set the column text dependent on the selected item
1182 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); 1229 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
1183 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); 1230 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
1184 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); 1231 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
1185 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); 1232 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
1186 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); 1233 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
1187 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); 1234 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
1188#endif 1235#endif
1189#ifdef WIN32 1236#ifdef WIN32
1190 // set the column text dependent on the selected item 1237 // set the column text dependent on the selected item
1191 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); 1238 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
1192 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); 1239 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
1193 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); 1240 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
1194 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); 1241 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
1195 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); 1242 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
1196 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); 1243 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
1197#endif 1244#endif
1198 1245
1199} 1246}
1200 1247
1201bool ZSafe::isCategory(QListViewItem *_item) 1248bool ZSafe::isCategory(QListViewItem *_item)
1202{ 1249{
1203 if (_item == NULL) 1250 if (_item == NULL)
1204 return FALSE; 1251 return FALSE;
1205 1252
1206 QString categoryName = _item->text (0); 1253 QString categoryName = _item->text (0);
1207 if (categories.find ((const char *)categoryName)) 1254 if (categories.find (categoryName))
1208 return TRUE; 1255 return TRUE;
1209 else 1256 else
1210 return FALSE; 1257 return FALSE;
1211} 1258}
1212 1259
1213void ZSafe::removeAsciiFile() 1260void ZSafe::removeAsciiFile()
1214{ 1261{
1215 // QString fn = filename + ".txt"; 1262 // QString fn = filename + ".txt";
1216 // open the file dialog 1263 // open the file dialog
1217#ifndef DESKTOP 1264#ifndef DESKTOP
1218#ifndef NO_OPIE 1265#ifndef NO_OPIE
1219 QMap<QString, QStringList> mimeTypes; 1266 QMap<QString, QStringList> mimeTypes;
1220 mimeTypes.insert(tr("All"), QStringList() ); 1267 mimeTypes.insert(tr("All"), QStringList() );
1221 mimeTypes.insert(tr("Text"), "text/*" ); 1268 mimeTypes.insert(tr("Text"), "text/*" );
1222 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 1269 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
1223 QDir::homeDirPath() + "/Documents/application/zsafe", 1270 QDir::homeDirPath() + "/Documents/application/zsafe",
1224 QString::null, 1271 QString::null,
1225 mimeTypes, 1272 mimeTypes,
1226 this, 1273 this,
1227 tr ("Remove text file")); 1274 tr ("Remove text file"));
1228#else 1275#else
1229 QString fn = ScQtFileEdit::getOpenFileName(this, 1276 QString fn = ScQtFileEdit::getOpenFileName(this,
1230 tr ("Remove text file"), 1277 tr ("Remove text file"),
1231 QDir::homeDirPath() + "/Documents/application/zsafe", 1278 QDir::homeDirPath() + "/Documents/application/zsafe",
1232 "*.txt"); 1279 "*.txt");
1233#endif 1280#endif
1234#else 1281#else
1235 QString fn = QFileDialog::getOpenFileName( 1282 QString fn = QFileDialog::getOpenFileName(
1236 QDir::homeDirPath() + "/Documents/application/zsafe", 1283 QDir::homeDirPath() + "/Documents/application/zsafe",
1237 "ZSafe (*.txt)", 1284 "ZSafe (*.txt)",
1238 this, 1285 this,
1239 "ZSafe File Dialog" 1286 "ZSafe File Dialog"
1240 "Choose a text file" ); 1287 "Choose a text file" );
1241#endif 1288#endif
1242 1289
1243 if (fn && fn.length() > 0 ) 1290 if (fn && fn.length() > 0 )
1244 { 1291 {
1245 QFile f( fn ); 1292 QFile f( fn );
1246 if ( !f.remove() ) 1293 if ( !f.remove() )
1247 { 1294 {
1248 qWarning( QString("Could not remove file %1").arg(fn), 1295 qWarning( QString("Could not remove file %1").arg(fn),
1249 2000 ); 1296 2000 );
1250 QMessageBox::critical( 0, tr("ZSafe"), 1297 QMessageBox::critical( 0, tr("ZSafe"),
1251 tr("Could not remove text file.") ); 1298 tr("Could not remove text file.") );
1252 return; 1299 return;
1253 } 1300 }
1254 } 1301 }
1255} 1302}
@@ -1388,177 +1435,199 @@ void ZSafe::readAllEntries()
1388 if (fn && fn.length() > 0 ) 1435 if (fn && fn.length() > 0 )
1389 { 1436 {
1390 QFile f( fn ); 1437 QFile f( fn );
1391 if ( !f.open( IO_ReadOnly ) ) 1438 if ( !f.open( IO_ReadOnly ) )
1392 { 1439 {
1393 qWarning( QString("Could not read file %1").arg(fn), 1440 qWarning( QString("Could not read file %1").arg(fn),
1394 2000 ); 1441 2000 );
1395 QMessageBox::critical( 0, "ZSafe", 1442 QMessageBox::critical( 0, "ZSafe",
1396 QString("Could not import text file.") ); 1443 QString("Could not import text file.") );
1397 return; 1444 return;
1398 } 1445 }
1399 1446
1400 modified = true; 1447 modified = true;
1401 1448
1402 // clear the password list 1449 // clear the password list
1403 selectedItem = NULL; 1450 selectedItem = NULL;
1404 QListViewItem *i; 1451 QListViewItem *i;
1405 // step through all categories 1452 // step through all categories
1406 for (i = ListView->firstChild(); 1453 for (i = ListView->firstChild();
1407 i != NULL; 1454 i != NULL;
1408 i = i->nextSibling()) 1455 i = i->nextSibling())
1409 { 1456 {
1410 // step through all subitems 1457 // step through all subitems
1411 QListViewItem *si; 1458 QListViewItem *si;
1412 for (si = i->firstChild(); 1459 for (si = i->firstChild();
1413 si != NULL; ) 1460 si != NULL; )
1414 // si = si->nextSibling()) 1461 // si = si->nextSibling())
1415 { 1462 {
1416 QListViewItem *_si = si; 1463 QListViewItem *_si = si;
1417 si = si->nextSibling(); 1464 si = si->nextSibling();
1418 i->takeItem(_si); // remove from view list 1465 i->takeItem(_si); // remove from view list
1419 if (_si) delete _si; 1466 if (_si) delete _si;
1420 } 1467 }
1421 } 1468 }
1422 1469
1423 qWarning ("ReadAllEntries(): "); 1470 qWarning ("ReadAllEntries(): ");
1424 1471
1425 QTextStream t(&f); 1472 QTextStream t(&f);
1426 while ( !t.eof() ) 1473 while ( !t.eof() )
1427 { 1474 {
1428 QString s = t.readLine(); 1475 QString s = t.readLine();
1429 s.replace (QRegExp("\";\""), "\"|\""); 1476 s.replace (QRegExp("\";\""), "\"|\"");
1430 // char buffer[1024]; 1477 // char buffer[1024];
1431#ifndef WIN32 1478#ifndef WIN32
1432 char buffer[s.length()+1]; 1479 char buffer[s.length()+1];
1433#else 1480#else
1434 char buffer[4048]; 1481 char buffer[4048];
1435#endif 1482#endif
1436 strcpy (buffer, s); 1483
1484
1485 /* modify QString -> QCString::utf8 */
1486
1487 strcpy (buffer, s.utf8());
1437 1488
1438 QString name; 1489 QString name;
1439 QString user; 1490 QString user;
1440 QString password; 1491 QString password;
1441 QString comment; 1492 QString comment;
1442 QString field5=""; 1493 QString field5="";
1443 QString field6=""; 1494 QString field6="";
1444 1495
1445 // separete the entries 1496 // separete the entries
1446 char *i = strtok (buffer, "|"); 1497 char *i = strtok (buffer, "|");
1447 QString category(&i[1]); 1498 QString category(QString::fromUtf8(&i[1]));
1448 category.truncate(category.length() -1); 1499 category.truncate(category.length() -1);
1449 1500
1450 int idx=0; 1501 int idx=0;
1451 while ((i = strtok (NULL, "|")) != NULL) 1502 while ((i = strtok (NULL, "|")) != NULL)
1452 { 1503 {
1453 switch (idx) 1504 switch (idx)
1454 { 1505 {
1455 case 0: 1506 case 0:
1456 name = &i[1]; 1507 name = QString::fromUtf8(&i[1]);
1457 name.truncate(name.length() -1); 1508 name.truncate(name.length() -1);
1458 // name 1509 // name
1459 break; 1510 break;
1460 case 1: 1511 case 1:
1461 // user 1512 // user
1462 user = &i[1]; 1513 user = QString::fromUtf8(&i[1]);
1463 user.truncate(user.length() -1); 1514 user.truncate(user.length() -1);
1464 break; 1515 break;
1465 case 2: 1516 case 2:
1466 // password 1517 // password
1467 password = &i[1]; 1518 password = QString::fromUtf8(&i[1]);
1468 password.truncate(password.length() -1); 1519 password.truncate(password.length() -1);
1469 break; 1520 break;
1470 case 3: 1521 case 3:
1471 // comment 1522 // comment
1472 comment = &i[1]; 1523 comment = QString::fromUtf8(&i[1]);
1473 comment.truncate(comment.length() -1); 1524 comment.truncate(comment.length() -1);
1474 break; 1525 break;
1475 case 4: 1526 case 4:
1476 // field5 1527 // field5
1477 field5 = &i[1]; 1528 field5 = QString::fromUtf8(&i[1]);
1478 field5.truncate(field5.length() -1); 1529 field5.truncate(field5.length() -1);
1479 break; 1530 break;
1480 case 5: 1531 case 5:
1481 // field6 1532 // field6
1482 field6 = &i[1]; 1533 field6 = QString::fromUtf8(&i[1]);
1483 field6.truncate(field6.length() -1); 1534 field6.truncate(field6.length() -1);
1484 break; 1535 break;
1485 } 1536 }
1486 idx++; 1537 idx++;
1487 } 1538 }
1488 1539
1489 Category *cat= categories.find (category); 1540 Category *cat= categories.find (category);
1490 if (cat) 1541 if (cat)
1491 { 1542 {
1492 // use the existend item 1543 // use the existend item
1493 QListViewItem *catItem = cat->getListItem(); 1544 QListViewItem *catItem = cat->getListItem();
1494 if (catItem) 1545 if (catItem)
1495 { 1546 {
1496 QListViewItem * item = new ShadedListItem( 0, catItem ); 1547 QListViewItem * item = new ShadedListItem( 0, catItem );
1548#ifdef JPATCH_HDE
1549 item->setText( 0, name );
1550 item->setText( 1, user );
1551 item->setText( 2, password );
1552 item->setText( 3, comment );
1553 item->setText( 4, field5 );
1554 item->setText( 5, field6 );
1555#else
1497 item->setText( 0, tr( name ) ); 1556 item->setText( 0, tr( name ) );
1498 item->setText( 1, tr( user ) ); 1557 item->setText( 1, tr( user ) );
1499 item->setText( 2, tr( password ) ); 1558 item->setText( 2, tr( password ) );
1500 item->setText( 3, tr( comment ) ); 1559 item->setText( 3, tr( comment ) );
1501 item->setText( 4, tr( field5 ) ); 1560 item->setText( 4, tr( field5 ) );
1502 item->setText( 5, tr( field6 ) ); 1561 item->setText( 5, tr( field6 ) );
1503 catItem->setOpen( TRUE ); 1562 catItem->setOpen( TRUE );
1563#endif
1504 } 1564 }
1505 } 1565 }
1506 else 1566 else
1507 { 1567 {
1508 QListViewItem *catI = new ShadedListItem( 1, ListView ); 1568 QListViewItem *catI = new ShadedListItem( 1, ListView );
1509 // create and insert a new item 1569 // create and insert a new item
1510 QListViewItem * item = new ShadedListItem( 0, catI ); 1570 QListViewItem * item = new ShadedListItem( 0, catI );
1571#ifdef JPATCH_HDE
1572 item->setText( 0, name );
1573 item->setText( 1, user );
1574 item->setText( 2, password );
1575 item->setText( 3, comment );
1576 item->setText( 4, field5 );
1577 item->setText( 5, field6 );
1578#else
1511 item->setText( 0, tr( name ) ); 1579 item->setText( 0, tr( name ) );
1512 item->setText( 1, tr( user ) ); 1580 item->setText( 1, tr( user ) );
1513 item->setText( 2, tr( password ) ); 1581 item->setText( 2, tr( password ) );
1514 item->setText( 3, tr( comment ) ); 1582 item->setText( 3, tr( comment ) );
1515 item->setText( 4, tr( field5 ) ); 1583 item->setText( 4, tr( field5 ) );
1516 item->setText( 5, tr( field6 ) ); 1584 item->setText( 5, tr( field6 ) );
1585#endif
1517 catI->setOpen( TRUE ); 1586 catI->setOpen( TRUE );
1518 1587
1519 Category *c1 = new Category(); 1588 Category *c1 = new Category();
1520 c1->setCategoryName(category); 1589 c1->setCategoryName(category);
1521 1590
1522 QString icon; 1591 QString icon;
1523 QString fullIconPath; 1592 QString fullIconPath;
1524 QPixmap *pix; 1593 QPixmap *pix;
1525// #ifndef WIN32 1594// #ifndef WIN32
1526 icon = conf->readEntry(APP_KEY+category); 1595 icon = conf->readEntry(APP_KEY+category);
1527// #endif 1596// #endif
1528 bool isIconAv = false; 1597 bool isIconAv = false;
1529 if (!icon.isEmpty() && !icon.isNull()) 1598 if (!icon.isEmpty() && !icon.isNull())
1530 { 1599 {
1531 // build the full path 1600 // build the full path
1532 fullIconPath = iconPath + icon; 1601 fullIconPath = iconPath + icon;
1533 pix = new QPixmap (fullIconPath); 1602 pix = new QPixmap (fullIconPath);
1534 if (pix) 1603 if (pix)
1535 { 1604 {
1536 QImage img = pix->convertToImage(); 1605 QImage img = pix->convertToImage();
1537 pix->convertFromImage(img.smoothScale(14,14)); 1606 pix->convertFromImage(img.smoothScale(14,14));
1538 c1->setIconName (icon); 1607 c1->setIconName (icon);
1539 c1->setIcon (*pix); 1608 c1->setIcon (*pix);
1540 isIconAv = true; 1609 isIconAv = true;
1541 } 1610 }
1542 } 1611 }
1543 if (!isIconAv) 1612 if (!isIconAv)
1544 { 1613 {
1545 c1->setIcon (*getPredefinedIcon(category)); 1614 c1->setIcon (*getPredefinedIcon(category));
1546 } 1615 }
1547 c1->setListItem (catI); 1616 c1->setListItem (catI);
1548 c1->initListItem(); 1617 c1->initListItem();
1549 categories.insert (c1->getCategoryName(), c1); 1618 categories.insert (c1->getCategoryName(), c1);
1550 } 1619 }
1551 1620
1552 } 1621 }
1553 f.close(); 1622 f.close();
1554 1623
1555 } 1624 }
1556 else 1625 else
1557 { 1626 {
1558 } 1627 }
1559 1628
1560} 1629}
1561 1630
1562#ifdef UNUSED 1631#ifdef UNUSED
1563void ZSafe::writeAllEntries() 1632void ZSafe::writeAllEntries()
1564{ 1633{
@@ -1668,112 +1737,126 @@ void ZSafe::readAllEntries()
1668 1737
1669 QString name; 1738 QString name;
1670 QString user; 1739 QString user;
1671 QString password; 1740 QString password;
1672 QString comment; 1741 QString comment;
1673 1742
1674 // separete the entries 1743 // separete the entries
1675 char *i = strtok (buffer, "|"); 1744 char *i = strtok (buffer, "|");
1676 QString category(&i[1]); 1745 QString category(&i[1]);
1677 category.truncate(category.length() -1); 1746 category.truncate(category.length() -1);
1678 1747
1679 int idx=0; 1748 int idx=0;
1680 while (i = strtok (NULL, "|")) 1749 while (i = strtok (NULL, "|"))
1681 { 1750 {
1682 switch (idx) 1751 switch (idx)
1683 { 1752 {
1684 case 0: 1753 case 0:
1685 name = &i[1]; 1754 name = &i[1];
1686 name.truncate(name.length() -1); 1755 name.truncate(name.length() -1);
1687 // name 1756 // name
1688 break; 1757 break;
1689 case 1: 1758 case 1:
1690 // user 1759 // user
1691 user = &i[1]; 1760 user = &i[1];
1692 user.truncate(user.length() -1); 1761 user.truncate(user.length() -1);
1693 break; 1762 break;
1694 case 2: 1763 case 2:
1695 // password 1764 // password
1696 password = &i[1]; 1765 password = &i[1];
1697 password.truncate(password.length() -1); 1766 password.truncate(password.length() -1);
1698 break; 1767 break;
1699 case 3: 1768 case 3:
1700 // comment 1769 // comment
1701 comment = &i[1]; 1770 comment = &i[1];
1702 comment.truncate(comment.length() -1); 1771 comment.truncate(comment.length() -1);
1703 break; 1772 break;
1704 } 1773 }
1705 idx++; 1774 idx++;
1706 } 1775 }
1707 1776
1708 Category *cat= categories.find (category); 1777 Category *cat= categories.find (category);
1709 if (cat) 1778 if (cat)
1710 { 1779 {
1711 // use the existend item 1780 // use the existend item
1712 QListViewItem *catItem = cat->getListItem(); 1781 QListViewItem *catItem = cat->getListItem();
1713 if (catItem) 1782 if (catItem)
1714 { 1783 {
1715 QListViewItem * item = new ShadedListItem( 0, catItem ); 1784 QListViewItem * item = new ShadedListItem( 0, catItem );
1785#ifdef JPATCH_HDE
1786 item->setText( 0, name );
1787 item->setText( 1, user );
1788 item->setText( 2, password );
1789 item->setText( 3, comment );
1790#else
1716 item->setText( 0, tr( name ) ); 1791 item->setText( 0, tr( name ) );
1717 item->setText( 1, tr( user ) ); 1792 item->setText( 1, tr( user ) );
1718 item->setText( 2, tr( password ) ); 1793 item->setText( 2, tr( password ) );
1719 item->setText( 3, tr( comment ) ); 1794 item->setText( 3, tr( comment ) );
1795#endif
1720 catItem->setOpen( TRUE ); 1796 catItem->setOpen( TRUE );
1721 } 1797 }
1722 } 1798 }
1723 else 1799 else
1724 { 1800 {
1725 QListViewItem *catI = new ShadedListItem( 1, ListView ); 1801 QListViewItem *catI = new ShadedListItem( 1, ListView );
1726 // create and insert a new item 1802 // create and insert a new item
1727 QListViewItem * item = new ShadedListItem( 0, catI ); 1803 QListViewItem * item = new ShadedListItem( 0, catI );
1804#ifdef JPATCH_HDE
1805 item->setText( 0, name );
1806 item->setText( 1, user );
1807 item->setText( 2, password );
1808 item->setText( 3, comment );
1809#else
1728 item->setText( 0, tr( name ) ); 1810 item->setText( 0, tr( name ) );
1729 item->setText( 1, tr( user ) ); 1811 item->setText( 1, tr( user ) );
1730 item->setText( 2, tr( password ) ); 1812 item->setText( 2, tr( password ) );
1731 item->setText( 3, tr( comment ) ); 1813 item->setText( 3, tr( comment ) );
1814#endif
1732 catI->setOpen( TRUE ); 1815 catI->setOpen( TRUE );
1733 1816
1734 Category *c1 = new Category(); 1817 Category *c1 = new Category();
1735 c1->setCategoryName(category); 1818 c1->setCategoryName(category);
1736 1819
1737 QString icon; 1820 QString icon;
1738 QString fullIconPath; 1821 QString fullIconPath;
1739 QPixmap *pix; 1822 QPixmap *pix;
1740// #ifndef WIN32 1823// #ifndef WIN32
1741 icon = conf->readEntry(APP_KEY+category); 1824 icon = conf->readEntry(APP_KEY+category);
1742// #endif 1825// #endif
1743 bool isIconAv = false; 1826 bool isIconAv = false;
1744 if (!icon.isEmpty() && !icon.isNull()) 1827 if (!icon.isEmpty() && !icon.isNull())
1745 { 1828 {
1746 // build the full path 1829 // build the full path
1747 fullIconPath = iconPath + icon; 1830 fullIconPath = iconPath + icon;
1748 pix = new QPixmap (fullIconPath); 1831 pix = new QPixmap (fullIconPath);
1749 if (pix) 1832 if (pix)
1750 { 1833 {
1751 QImage img = pix->convertToImage(); 1834 QImage img = pix->convertToImage();
1752 pix->convertFromImage(img.smoothScale(14,14)); 1835 pix->convertFromImage(img.smoothScale(14,14));
1753 c1->setIconName (icon); 1836 c1->setIconName (icon);
1754 c1->setIcon (*pix); 1837 c1->setIcon (*pix);
1755 isIconAv = true; 1838 isIconAv = true;
1756 } 1839 }
1757 } 1840 }
1758 if (!isIconAv) 1841 if (!isIconAv)
1759 { 1842 {
1760 c1->setIcon (*getPredefinedIcon(category)); 1843 c1->setIcon (*getPredefinedIcon(category));
1761 } 1844 }
1762 c1->setListItem (catI); 1845 c1->setListItem (catI);
1763 c1->initListItem(); 1846 c1->initListItem();
1764 categories.insert (c1->getCategoryName(), c1); 1847 categories.insert (c1->getCategoryName(), c1);
1765 } 1848 }
1766 1849
1767 } 1850 }
1768 f.close(); 1851 f.close();
1769 1852
1770} 1853}
1771#endif // UNUSED 1854#endif // UNUSED
1772 1855
1773void ZSafe::resume(int) 1856void ZSafe::resume(int)
1774{ 1857{
1775 qWarning ("Resume"); 1858 qWarning ("Resume");
1776 // hide the main window 1859 // hide the main window
1777 1860
1778 infoForm->hide(); 1861 infoForm->hide();
1779 // open zsafe again 1862 // open zsafe again
@@ -1864,135 +1947,153 @@ bool ZSafe::openDocument(const char* _filename, const char* )
1864 if (retval == 1 && 1947 if (retval == 1 &&
1865 !strcmp (entry[0], "ZSAFECATEGORY") && 1948 !strcmp (entry[0], "ZSAFECATEGORY") &&
1866 !strcmp (entry[1], "name") && 1949 !strcmp (entry[1], "name") &&
1867 !strcmp (entry[2], "username") && 1950 !strcmp (entry[2], "username") &&
1868 !strcmp (entry[3], "password") && 1951 !strcmp (entry[3], "password") &&
1869 !strcmp (entry[4], "comment") ) 1952 !strcmp (entry[4], "comment") )
1870 { 1953 {
1871 for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); 1954 for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
1872 pwdOk = 1; 1955 pwdOk = 1;
1873 break; 1956 break;
1874 } 1957 }
1875 else 1958 else
1876 // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); 1959 // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
1877 fclose (fd); 1960 fclose (fd);
1878 m_password = ""; 1961 m_password = "";
1879 1962
1880 if (i < numberOfTries - 1) 1963 if (i < numberOfTries - 1)
1881 { 1964 {
1882 switch( QMessageBox::warning( this, tr("ZSafe"), 1965 switch( QMessageBox::warning( this, tr("ZSafe"),
1883 tr("Wrong password.\nEnter again?"), 1966 tr("Wrong password.\nEnter again?"),
1884 tr("&Yes"), tr("&No."), 1967 tr("&Yes"), tr("&No."),
1885 0 1968 0
1886 ) ) 1969 ) )
1887 { 1970 {
1888 case 1: // No 1971 case 1: // No
1889 exitZs (1); 1972 exitZs (1);
1890 break; 1973 break;
1891 case 0: // Yes 1974 case 0: // Yes
1892 continue; 1975 continue;
1893 } 1976 }
1894 } 1977 }
1895 } 1978 }
1896 if (pwdOk == 0) 1979 if (pwdOk == 0)
1897 { 1980 {
1898 // unset the document entry 1981 // unset the document entry
1899 conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); 1982 conf->writeEntry(APP_KEY+"document", "INVALIDPWD");
1900 if (conf) 1983 if (conf)
1901 delete conf; 1984 delete conf;
1902 1985
1903 exitZs (1); 1986 exitZs (1);
1904 } 1987 }
1905 1988
1906 1989
1907 retval = loadEntry(entry); 1990 retval = loadEntry(entry);
1908 1991
1909 int numberOfEntries=0; 1992 int numberOfEntries=0;
1910 while (retval == 1) { 1993 while (retval == 1) {
1911 1994
1912 QString category(entry[0]); 1995 QString category( QString::fromUtf8(entry[0]) );
1913 QString name(entry[1]); 1996 QString name( QString::fromUtf8(entry[1]) );
1914 QString user(entry[2]); 1997 QString user( QString::fromUtf8(entry[2]) );
1915 QString password(entry[3]); 1998 QString password( QString::fromUtf8(entry[3]) );
1916 QString comment(entry[4]); 1999 QString comment( QString::fromUtf8(entry[4]) );
1917 QString field5(entry[5]); 2000 QString field5( QString::fromUtf8(entry[5]) );
1918 QString field6(entry[6]); 2001 QString field6( QString::fromUtf8(entry[6]) );
1919 // add the subitems to the categories 2002 // add the subitems to the categories
1920 2003
1921 Category *cat= categories.find (category); 2004 Category *cat= categories.find (category);
1922 if (cat) 2005 if (cat)
1923 { 2006 {
1924 // use the existend item 2007 // use the existend item
1925 QListViewItem *catItem = cat->getListItem(); 2008 QListViewItem *catItem = cat->getListItem();
1926 if (catItem) 2009 if (catItem)
1927 { 2010 {
1928 QListViewItem * item = new ShadedListItem( 0, catItem ); 2011 QListViewItem * item = new ShadedListItem( 0, catItem );
2012#ifdef JPATCH_HDE
2013 item->setText( 0, name );
2014 item->setText( 1, user );
2015 item->setText( 2, password );
2016 item->setText( 3, comment );
2017 item->setText( 4, field5 );
2018 item->setText( 5, field6 );
2019#else
1929 item->setText( 0, tr( name ) ); 2020 item->setText( 0, tr( name ) );
1930 item->setText( 1, tr( user ) ); 2021 item->setText( 1, tr( user ) );
1931 item->setText( 2, tr( password ) ); 2022 item->setText( 2, tr( password ) );
1932 item->setText( 3, tr( comment ) ); 2023 item->setText( 3, tr( comment ) );
1933 item->setText( 4, tr( field5 ) ); 2024 item->setText( 4, tr( field5 ) );
1934 item->setText( 5, tr( field6 ) ); 2025 item->setText( 5, tr( field6 ) );
2026#endif
1935 if (expandTree) 2027 if (expandTree)
1936 catItem->setOpen( TRUE ); 2028 catItem->setOpen( TRUE );
1937 numberOfEntries++; 2029 numberOfEntries++;
1938 } 2030 }
1939 } 2031 }
1940 else 2032 else
1941 { 2033 {
1942 QListViewItem *catI = new ShadedListItem( 1, ListView ); 2034 QListViewItem *catI = new ShadedListItem( 1, ListView );
1943 // create and insert a new item 2035 // create and insert a new item
1944 QListViewItem * item = new ShadedListItem( 0, catI ); 2036 QListViewItem * item = new ShadedListItem( 0, catI );
2037#ifdef JPATCH_HDE
2038 item->setText( 0, name );
2039 item->setText( 1, user );
2040 item->setText( 2, password );
2041 item->setText( 3, comment );
2042 item->setText( 4, field5 );
2043 item->setText( 5, field6 );
2044#else
1945 item->setText( 0, tr( name ) ); 2045 item->setText( 0, tr( name ) );
1946 item->setText( 1, tr( user ) ); 2046 item->setText( 1, tr( user ) );
1947 item->setText( 2, tr( password ) ); 2047 item->setText( 2, tr( password ) );
1948 item->setText( 3, tr( comment ) ); 2048 item->setText( 3, tr( comment ) );
1949 item->setText( 4, tr( field5 ) ); 2049 item->setText( 4, tr( field5 ) );
1950 item->setText( 5, tr( field6 ) ); 2050 item->setText( 5, tr( field6 ) );
2051#endif
1951 if (expandTree) 2052 if (expandTree)
1952 catI->setOpen( TRUE ); 2053 catI->setOpen( TRUE );
1953 2054
1954 Category *c1 = new Category(); 2055 Category *c1 = new Category();
1955 c1->setCategoryName(category); 2056 c1->setCategoryName(category);
1956 2057
1957 QString icon; 2058 QString icon;
1958 QString fullIconPath; 2059 QString fullIconPath;
1959 QPixmap *pix; 2060 QPixmap *pix;
1960// #ifndef WIN32 2061// #ifndef WIN32
1961 icon = conf->readEntry(APP_KEY+category); 2062 icon = conf->readEntry(APP_KEY+category);
1962// #endif 2063// #endif
1963 bool isIconAv = false; 2064 bool isIconAv = false;
1964 if (!icon.isEmpty() && !icon.isNull()) 2065 if (!icon.isEmpty() && !icon.isNull())
1965 { 2066 {
1966 // build the full path 2067 // build the full path
1967 fullIconPath = iconPath + icon; 2068 fullIconPath = iconPath + icon;
1968 pix = new QPixmap (fullIconPath); 2069 pix = new QPixmap (fullIconPath);
1969 if (pix) 2070 if (pix)
1970 { 2071 {
1971 QImage img = pix->convertToImage(); 2072 QImage img = pix->convertToImage();
1972 pix->convertFromImage(img.smoothScale(14,14)); 2073 pix->convertFromImage(img.smoothScale(14,14));
1973 c1->setIconName (icon); 2074 c1->setIconName (icon);
1974 c1->setIcon (*pix); 2075 c1->setIcon (*pix);
1975 isIconAv = true; 2076 isIconAv = true;
1976 } 2077 }
1977 } 2078 }
1978 if (!isIconAv) 2079 if (!isIconAv)
1979 { 2080 {
1980 c1->setIcon (*getPredefinedIcon(category)); 2081 c1->setIcon (*getPredefinedIcon(category));
1981 } 2082 }
1982 2083
1983 c1->setListItem (catI); 2084 c1->setListItem (catI);
1984 c1->initListItem(); 2085 c1->initListItem();
1985 categories.insert (c1->getCategoryName(), c1); 2086 categories.insert (c1->getCategoryName(), c1);
1986 numberOfEntries++; 2087 numberOfEntries++;
1987 } 2088 }
1988 2089
1989 for (int count = 0; count < FIELD_SIZE; count++) { 2090 for (int count = 0; count < FIELD_SIZE; count++) {
1990 free(entry[count]); 2091 free(entry[count]);
1991 } 2092 }
1992 retval = loadEntry(entry); 2093 retval = loadEntry(entry);
1993 if (retval == 2) { 2094 if (retval == 2) {
1994 // m_parent->slotStatusHelpMsg("Last entry loaded"); 2095 // m_parent->slotStatusHelpMsg("Last entry loaded");
1995 } 2096 }
1996 } // end while 2097 } // end while
1997 2098
1998 if (numberOfEntries == 0) 2099 if (numberOfEntries == 0)
@@ -2214,111 +2315,110 @@ bool ZSafe::saveDocument(const char* _filename,
2214 2315
2215 char* entry[FIELD_SIZE]; 2316 char* entry[FIELD_SIZE];
2216 2317
2217 // save the validation entry 2318 // save the validation entry
2218 { 2319 {
2219 int i=0; 2320 int i=0;
2220 entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); 2321 entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1);
2221 strcpy(entry[i++], "ZSAFECATEGORY"); 2322 strcpy(entry[i++], "ZSAFECATEGORY");
2222 entry[i] = (char*)malloc(strlen("name")+1); 2323 entry[i] = (char*)malloc(strlen("name")+1);
2223 strcpy(entry[i++], "name"); 2324 strcpy(entry[i++], "name");
2224 entry[i] = (char*)malloc(strlen("username")+1); 2325 entry[i] = (char*)malloc(strlen("username")+1);
2225 strcpy(entry[i++], "username"); 2326 strcpy(entry[i++], "username");
2226 entry[i] = (char*)malloc(strlen("password")+1); 2327 entry[i] = (char*)malloc(strlen("password")+1);
2227 strcpy(entry[i++], "password"); 2328 strcpy(entry[i++], "password");
2228 entry[i] = (char*)malloc(strlen("comment")+1); 2329 entry[i] = (char*)malloc(strlen("comment")+1);
2229 strcpy(entry[i++], "comment"); 2330 strcpy(entry[i++], "comment");
2230 2331
2231 entry[i] = (char*)malloc(strlen("field5")+1); 2332 entry[i] = (char*)malloc(strlen("field5")+1);
2232 strcpy(entry[i++], "field5"); 2333 strcpy(entry[i++], "field5");
2233 entry[i] = (char*)malloc(strlen("field6")+1); 2334 entry[i] = (char*)malloc(strlen("field6")+1);
2234 strcpy(entry[i++], "field6"); 2335 strcpy(entry[i++], "field6");
2235 2336
2236 retval = saveEntry(entry); 2337 retval = saveEntry(entry);
2237 for (int z=0; z<i; z++) free(entry[z]); 2338 for (int z=0; z<i; z++) free(entry[z]);
2238 if (retval == PWERR_DATA) { 2339 if (retval == PWERR_DATA) {
2239 qWarning("1: Error writing file, contents not saved"); 2340 qWarning("1: Error writing file, contents not saved");
2240 saveFinalize(); 2341 saveFinalize();
2241 return false; 2342 return false;
2242 } 2343 }
2243// #ifndef WIN32 2344// #ifndef WIN32
2244 conf->writeEntry(APP_KEY+"valzsafe", 1); 2345 conf->writeEntry(APP_KEY+"valzsafe", 1);
2245// #endif 2346// #endif
2246 saveConf(); 2347 saveConf();
2247 } 2348 }
2248 2349
2249 QListViewItem *i; 2350 QListViewItem *i;
2250 // step through all categories 2351 // step through all categories
2251 for (i = ListView->firstChild(); 2352 for (i = ListView->firstChild();
2252 i != NULL; 2353 i != NULL;
2253 i = i->nextSibling()) 2354 i = i->nextSibling())
2254 { 2355 {
2255 // step through all subitems 2356 // step through all subitems
2256 QListViewItem *si; 2357 QListViewItem *si;
2257 for (si = i->firstChild(); 2358 for (si = i->firstChild();
2258 si != NULL; 2359 si != NULL;
2259 si = si->nextSibling()) 2360 si = si->nextSibling())
2260 { 2361 {
2261 int j=0; 2362 int j=0;
2262 entry[j] = (char*)malloc(strlen(i->text(0))+1); 2363 entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1);
2263 strcpy(entry[j++], i->text(0)); 2364 strcpy(entry[j++], i->text(0).utf8());
2264 entry[j] = (char*)malloc(strlen(si->text(0))+1); 2365 entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1);
2265 strcpy(entry[j++], si->text(0)); 2366 strcpy(entry[j++], si->text(0).utf8());
2266 entry[j] = (char*)malloc(strlen(si->text(1))+1); 2367 entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1);
2267 strcpy(entry[j++], si->text(1)); 2368 strcpy(entry[j++], si->text(1).utf8());
2268 entry[j] = (char*)malloc(strlen(si->text(2))+1); 2369 entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1);
2269 strcpy(entry[j++], si->text(2)); 2370 strcpy(entry[j++], si->text(2).utf8());
2270 entry[j] = (char*)malloc(strlen(si->text(3))+1); 2371 entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1);
2271 strcpy(entry[j++], si->text(3)); 2372 strcpy(entry[j++], si->text(3).utf8());
2272 2373 entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1);
2273 entry[j] = (char*)malloc(strlen(si->text(4))+1); 2374 strcpy(entry[j++], si->text(4).utf8());
2274 strcpy(entry[j++], si->text(4)); 2375 entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1);
2275 entry[j] = (char*)malloc(strlen(si->text(5))+1); 2376 strcpy(entry[j++], si->text(5).utf8());
2276 strcpy(entry[j++], si->text(5));
2277 2377
2278 retval = saveEntry(entry); 2378 retval = saveEntry(entry);
2279 for (int z=0; z<j; z++) 2379 for (int z=0; z<j; z++)
2280 { 2380 {
2281 free(entry[z]); 2381 free(entry[z]);
2282 } 2382 }
2283 if (retval == PWERR_DATA) { 2383 if (retval == PWERR_DATA) {
2284 qWarning("1: Error writing file, contents not saved"); 2384 qWarning("1: Error writing file, contents not saved");
2285 saveFinalize(); 2385 saveFinalize();
2286 return false; 2386 return false;
2287 } 2387 }
2288 2388
2289 } 2389 }
2290 } 2390 }
2291 2391
2292 if (saveFinalize() == PWERR_DATA) { 2392 if (saveFinalize() == PWERR_DATA) {
2293 qWarning("2: Error writing file, contents not saved"); 2393 qWarning("2: Error writing file, contents not saved");
2294 return false; 2394 return false;
2295 } else { 2395 } else {
2296#ifndef DESKTOP 2396#ifndef DESKTOP
2297 Global::statusMessage (tr("Password file saved.")); 2397 Global::statusMessage (tr("Password file saved."));
2298#endif 2398#endif
2299 modified = false; 2399 modified = false;
2300 return true; 2400 return true;
2301 } 2401 }
2302} 2402}
2303 2403
2304PasswordForm *newPwdDialog; 2404PasswordForm *newPwdDialog;
2305bool newPwdDialogResult = false; 2405bool newPwdDialogResult = false;
2306void ZSafe::setPasswordDialogDone() 2406void ZSafe::setPasswordDialogDone()
2307{ 2407{
2308 newPwdDialogResult = true; 2408 newPwdDialogResult = true;
2309 newPwdDialog->close(); 2409 newPwdDialog->close();
2310} 2410}
2311 2411
2312void ZSafe::getDocPassword(QString title) 2412void ZSafe::getDocPassword(QString title)
2313{ 2413{
2314qWarning ("getDocPassword"); 2414qWarning ("getDocPassword");
2315 // open the 'Password' dialog 2415 // open the 'Password' dialog
2316 PasswordForm *dialog = new PasswordForm(this, title, TRUE); 2416 PasswordForm *dialog = new PasswordForm(this, title, TRUE);
2317 newPwdDialog = dialog; 2417 newPwdDialog = dialog;
2318 newPwdDialogResult = false; 2418 newPwdDialogResult = false;
2319 2419
2320 connect( dialog->PasswordField, SIGNAL( returnPressed() ), 2420 connect( dialog->PasswordField, SIGNAL( returnPressed() ),
2321 this, SLOT( setPasswordDialogDone() ) ); 2421 this, SLOT( setPasswordDialogDone() ) );
2322 2422
2323 // CS: !!! 2423 // CS: !!!
2324 // int pos = filename.findRev ('/'); 2424 // int pos = filename.findRev ('/');
@@ -3158,98 +3258,103 @@ void ZSafe::editCategory()
3158 { 3258 {
3159 categories.remove (category); 3259 categories.remove (category);
3160// #ifndef WIN32 3260// #ifndef WIN32
3161 conf->removeEntry(category); 3261 conf->removeEntry(category);
3162// #endif 3262// #endif
3163 saveConf(); 3263 saveConf();
3164 } 3264 }
3165 3265
3166 category = dialog->CategoryField->currentText(); 3266 category = dialog->CategoryField->currentText();
3167 icon = dialog->IconField->currentText()+".png"; 3267 icon = dialog->IconField->currentText()+".png";
3168 3268
3169 if (cat) 3269 if (cat)
3170 { 3270 {
3171 qWarning("Category found"); 3271 qWarning("Category found");
3172 3272
3173 // if (!icon.isEmpty() && !icon.isNull()) 3273 // if (!icon.isEmpty() && !icon.isNull())
3174 if (icon != "predefined.png") 3274 if (icon != "predefined.png")
3175 { 3275 {
3176 // build the full path 3276 // build the full path
3177 fullIconPath = iconPath + icon; 3277 fullIconPath = iconPath + icon;
3178 pix = new QPixmap (fullIconPath); 3278 pix = new QPixmap (fullIconPath);
3179 if (pix) 3279 if (pix)
3180 { 3280 {
3181 // save the full pixmap name into the config file 3281 // save the full pixmap name into the config file
3182// #ifndef WIN32 3282// #ifndef WIN32
3183 conf->writeEntry(APP_KEY+category, icon); 3283 conf->writeEntry(APP_KEY+category, icon);
3184// #endif 3284// #endif
3185 saveConf(); 3285 saveConf();
3186 QImage img = pix->convertToImage(); 3286 QImage img = pix->convertToImage();
3187 pix->convertFromImage(img.smoothScale(14,14)); 3287 pix->convertFromImage(img.smoothScale(14,14));
3188 cat->setIconName (icon); 3288 cat->setIconName (icon);
3189 cat->setIcon (*pix); 3289 cat->setIcon (*pix);
3190 } 3290 }
3191 } 3291 }
3192 else 3292 else
3193 { 3293 {
3194// #ifndef WIN32 3294// #ifndef WIN32
3195 conf->removeEntry (category); 3295 conf->removeEntry (category);
3196// #endif 3296// #endif
3197 saveConf(); 3297 saveConf();
3198 cat->setIcon (*getPredefinedIcon(category)); 3298 cat->setIcon (*getPredefinedIcon(category));
3199 } 3299 }
3200 3300
3201 // change the category name of the selected category 3301 // change the category name of the selected category
3202 QListViewItem *catItem = cat->getListItem(); 3302 QListViewItem *catItem = cat->getListItem();
3203 if (catItem) 3303 if (catItem)
3204 { 3304 {
3205 qWarning (category); 3305 qWarning (category);
3306#ifdef JPATCH_HDE
3307 catItem->setText( 0, category );
3308 cat->setCategoryName (category);
3309#else
3206 catItem->setText( 0, tr( category ) ); 3310 catItem->setText( 0, tr( category ) );
3207 cat->setCategoryName (tr(category)); 3311 cat->setCategoryName (tr(category));
3312#endif
3208 cat->initListItem(); 3313 cat->initListItem();
3209 categories.insert (category, cat); 3314 categories.insert (category, cat);
3210 } 3315 }
3211 } 3316 }
3212 saveCategoryDialogFields(dialog); 3317 saveCategoryDialogFields(dialog);
3213 } 3318 }
3214 else 3319 else
3215 { 3320 {
3216 // delete dialog; 3321 // delete dialog;
3217 dialog->hide(); 3322 dialog->hide();
3218 return; 3323 return;
3219 } 3324 }
3220 3325
3221 } 3326 }
3222} 3327}
3223 3328
3224void ZSafe::cutItem() 3329void ZSafe::cutItem()
3225{ 3330{
3226 if (!selectedItem) 3331 if (!selectedItem)
3227 return; 3332 return;
3228 if (!isCategory(selectedItem)) 3333 if (!isCategory(selectedItem))
3229 { 3334 {
3230 IsCut = true; 3335 IsCut = true;
3231 copiedItem = selectedItem; 3336 copiedItem = selectedItem;
3232 } 3337 }
3233} 3338}
3234 3339
3235void ZSafe::copyItem() 3340void ZSafe::copyItem()
3236{ 3341{
3237 if (!selectedItem) 3342 if (!selectedItem)
3238 return; 3343 return;
3239 if (!isCategory(selectedItem)) 3344 if (!isCategory(selectedItem))
3240 { 3345 {
3241 IsCopy = true; 3346 IsCopy = true;
3242 copiedItem = selectedItem; 3347 copiedItem = selectedItem;
3243 } 3348 }
3244} 3349}
3245 3350
3246// paste item into category 3351// paste item into category
3247void ZSafe::pasteItem() 3352void ZSafe::pasteItem()
3248{ 3353{
3249 if (!selectedItem) 3354 if (!selectedItem)
3250 return; 3355 return;
3251 if (isCategory(selectedItem)) 3356 if (isCategory(selectedItem))
3252 { 3357 {
3253 modified = true; 3358 modified = true;
3254 if (IsCut) 3359 if (IsCut)
3255 { 3360 {
@@ -3484,109 +3589,131 @@ void ZSafe::saveDocumentAs()
3484 QString newFile = QFileDialog::getSaveFileName( 3589 QString newFile = QFileDialog::getSaveFileName(
3485 QDir::homeDirPath() + "/Documents/application/zsafe", 3590 QDir::homeDirPath() + "/Documents/application/zsafe",
3486 "ZSafe (*.zsf)", 3591 "ZSafe (*.zsf)",
3487 this, 3592 this,
3488 "ZSafe File Dialog" 3593 "ZSafe File Dialog"
3489 "Choose a ZSafe file" ); 3594 "Choose a ZSafe file" );
3490#endif 3595#endif
3491 3596
3492 // open the new document 3597 // open the new document
3493 if (newFile && newFile.length() > 0 ) 3598 if (newFile && newFile.length() > 0 )
3494 { 3599 {
3495 // save the previous opened document 3600 // save the previous opened document
3496 if (!filename.isEmpty()) 3601 if (!filename.isEmpty())
3497 saveDocument(filename, FALSE); 3602 saveDocument(filename, FALSE);
3498 3603
3499 selectedItem = NULL; 3604 selectedItem = NULL;
3500 filename = newFile; 3605 filename = newFile;
3501 3606
3502 // save the current filename to the config file 3607 // save the current filename to the config file
3503 conf->writeEntry(APP_KEY+"document", filename); 3608 conf->writeEntry(APP_KEY+"document", filename);
3504 saveConf(); 3609 saveConf();
3505 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 3610 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
3506#ifdef WIN32 3611#ifdef WIN32
3507 this->setCaption("Qt ZSafe: " + ti); 3612 this->setCaption("Qt ZSafe: " + ti);
3508#else 3613#else
3509 this->setCaption("ZSafe: " + ti); 3614 this->setCaption("ZSafe: " + ti);
3510#endif 3615#endif
3511 3616
3512 QMessageBox::information( this, tr("ZSafe"), 3617 QMessageBox::information( this, tr("ZSafe"),
3513 tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); 3618 tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0);
3514 3619
3515 saveDocumentWithPwd(); 3620 saveDocumentWithPwd();
3516 } 3621 }
3517} 3622}
3518 3623
3519void ZSafe::saveDocumentWithoutPwd() 3624void ZSafe::saveDocumentWithoutPwd()
3520{ 3625{
3521 saveDocument(filename, FALSE); 3626 saveDocument(filename, FALSE);
3522} 3627}
3523 3628
3524void ZSafe::saveDocumentWithPwd() 3629void ZSafe::saveDocumentWithPwd()
3525{ 3630{
3526 saveDocument(filename, TRUE); 3631 saveDocument(filename, TRUE);
3527} 3632}
3528 3633
3529void ZSafe::about() 3634void ZSafe::about()
3530{ 3635{
3531 QString info; 3636 QString info;
3637#ifdef JPATCH_HDE
3638 info = "<html><body><div align=""center"">";
3639 info += "<b>";
3640 info += tr("Zaurus Password Manager<br>");
3641 info += tr("ZSafe version 2.1.2-jv01b<br>");
3642 info += "</b>";
3643 info += tr("by Carsten Schneider<br>");
3644 info += "zcarsten@gmx.net<br>";
3645 info += "http://z-soft.z-portal.info/zsafe";
3646 info += "<br>";
3647 info += tr("Translations by Robert Ernst<br>");
3648 info += "robert.ernst@linux-solutions.at<br>";
3649
3650 info += "<br><br>";
3651 info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>");
3652 info += "HADECO R&D<br>";
3653 info += "r&d@hadeco.co.jp<br>";
3654 info += "http://www.hadeco.co.jp/r&d/<br>";
3655 info += "<br></div>";
3656 info += "</body></html>";
3657#else
3532 info = "<html><body><div align=""center"">"; 3658 info = "<html><body><div align=""center"">";
3533 info += "<b>"; 3659 info += "<b>";
3534 info += tr("Zaurus Password Manager<br>"); 3660 info += tr("Zaurus Password Manager<br>");
3535 info += tr("ZSafe version 2.1.2<br>"); 3661 info += tr("ZSafe version 2.1.2<br>");
3536 info += "</b>"; 3662 info += "</b>";
3537 info += tr("by Carsten Schneider<br>"); 3663 info += tr("by Carsten Schneider<br>");
3538 info += "zcarsten@gmx.net<br>"; 3664 info += "zcarsten@gmx.net<br>";
3539 info += "http://z-soft.z-portal.info/zsafe"; 3665 info += "http://z-soft.z-portal.info/zsafe";
3540 info += "<br>"; 3666 info += "<br>";
3541 info += tr("Translations by Robert Ernst<br>"); 3667 info += tr("Translations by Robert Ernst<br>");
3542 info += "robert.ernst@linux-solutions.at<br>"; 3668 info += "robert.ernst@linux-solutions.at<br>";
3543 info += "<br></div>"; 3669 info += "<br></div>";
3544 info += "</body></html>"; 3670 info += "</body></html>";
3671#endif
3545 3672
3546 // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); 3673 // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0);
3547 3674
3548 QMessageBox mb( this, tr("ZSafe")); 3675 QMessageBox mb( this, tr("ZSafe"));
3549 mb.setText (info); 3676 mb.setText (info);
3550 mb.setButtonText (QMessageBox::Ok, tr ("&OK")); 3677 mb.setButtonText (QMessageBox::Ok, tr ("&OK"));
3551 QPixmap zsafe_img((const char**) zsafe_xpm); 3678 QPixmap zsafe_img((const char**) zsafe_xpm);
3552 mb.setIconPixmap (zsafe_img); 3679 mb.setIconPixmap (zsafe_img);
3553 mb.exec(); 3680 mb.exec();
3554} 3681}
3555 3682
3556void ZSafe::setExpandFlag() 3683void ZSafe::setExpandFlag()
3557{ 3684{
3558 expandTree = !expandTree; 3685 expandTree = !expandTree;
3559 file->setItemChecked('o', expandTree); 3686 file->setItemChecked('o', expandTree);
3560#ifndef DESKTOP 3687#ifndef DESKTOP
3561 conf->setGroup ("zsafePrefs"); 3688 conf->setGroup ("zsafePrefs");
3562#endif 3689#endif
3563// #ifndef WIN32 3690// #ifndef WIN32
3564 conf->writeEntry (APP_KEY+"expandTree", expandTree); 3691 conf->writeEntry (APP_KEY+"expandTree", expandTree);
3565// #endif 3692// #endif
3566 saveConf(); 3693 saveConf();
3567 3694
3568} 3695}
3569 3696
3570void ZSafe::paintEvent( QPaintEvent * ) 3697void ZSafe::paintEvent( QPaintEvent * )
3571{ 3698{
3572 if (raiseFlag) 3699 if (raiseFlag)
3573 { 3700 {
3574 raiseFlag = false; 3701 raiseFlag = false;
3575 raiseTimer.start (1, true); 3702 raiseTimer.start (1, true);
3576 if (infoForm->isVisible()) 3703 if (infoForm->isVisible())
3577 infoForm->raise(); 3704 infoForm->raise();
3578 } 3705 }
3579} 3706}
3580 3707
3581void ZSafe::resizeEvent ( QResizeEvent * ) 3708void ZSafe::resizeEvent ( QResizeEvent * )
3582{ 3709{
3583 // qWarning ("resizeEvent"); 3710 // qWarning ("resizeEvent");
3584#ifndef DESKTOP 3711#ifndef DESKTOP
3585 DeskW = appl->desktop()->width(); 3712 DeskW = appl->desktop()->width();
3586 DeskH = appl->desktop()->height(); 3713 DeskH = appl->desktop()->height();
3587#else 3714#else
3588 DeskW = this->width(); 3715 DeskW = this->width();
3589 DeskH = this->height(); 3716 DeskH = this->height();
3590#endif 3717#endif
3591 qWarning( QString("Width : %1").arg(DeskW), 2000 ); 3718 qWarning( QString("Width : %1").arg(DeskW), 2000 );
3592 qWarning( QString("Height: %1").arg(DeskH), 2000 ); 3719 qWarning( QString("Height: %1").arg(DeskH), 2000 );