author | drw <drw> | 2004-02-23 17:12:28 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-23 17:12:28 (UTC) |
commit | 2f11aa15eeb70dd8826523597adb8947fdffbaa7 (patch) (unidiff) | |
tree | acc6ceb27c67437734e94b39b06835edac5d5bad /noncore/apps/zsafe/zsafe.cpp | |
parent | 20b0e62e6c23cdaed9a30d6fad73431edc60be53 (diff) | |
download | opie-2f11aa15eeb70dd8826523597adb8947fdffbaa7.zip opie-2f11aa15eeb70dd8826523597adb8947fdffbaa7.tar.gz opie-2f11aa15eeb70dd8826523597adb8947fdffbaa7.tar.bz2 |
ZSafe: libopie->libopie2
Diffstat (limited to 'noncore/apps/zsafe/zsafe.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 989 |
1 files changed, 496 insertions, 493 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index bdd2aed..f43a206 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -30,3 +30,6 @@ | |||
30 | #ifndef NO_OPIE | 30 | #ifndef NO_OPIE |
31 | #include <opie/ofiledialog.h> | 31 | #include <opie2/ofiledialog.h> |
32 | |||
33 | using Opie::OFileDialog; | ||
34 | using Opie::OFileSelector; | ||
32 | #else | 35 | #else |
@@ -136,3 +139,3 @@ const QString APP_KEY=""; | |||
136 | 139 | ||
137 | static const char* const bank_cards_data[] = { | 140 | static const char* const bank_cards_data[] = { |
138 | "14 14 16 1", | 141 | "14 14 16 1", |
@@ -170,3 +173,3 @@ static const char* const bank_cards_data[] = { | |||
170 | 173 | ||
171 | static const char* const passwords_data[] = { | 174 | static const char* const passwords_data[] = { |
172 | "16 16 20 1", | 175 | "16 16 20 1", |
@@ -209,3 +212,3 @@ static const char* const passwords_data[] = { | |||
209 | 212 | ||
210 | static const char* const software_data[] = { | 213 | static const char* const software_data[] = { |
211 | "16 16 5 1", | 214 | "16 16 5 1", |
@@ -233,3 +236,3 @@ static const char* const software_data[] = { | |||
233 | 236 | ||
234 | static const char* const general_data[] = { | 237 | static const char* const general_data[] = { |
235 | "14 14 98 2", | 238 | "14 14 98 2", |
@@ -381,5 +384,5 @@ static const char* const general_data[] = { | |||
381 | 384 | ||
382 | /* | 385 | /* |
383 | * Constructs a ZSafe which is a child of 'parent', with the | 386 | * Constructs a ZSafe which is a child of 'parent', with the |
384 | * name 'name' and widget flags set to 'f' | 387 | * name 'name' and widget flags set to 'f' |
385 | * | 388 | * |
@@ -389,3 +392,3 @@ static const char* const general_data[] = { | |||
389 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | 392 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) |
390 | : QDialog( parent, name, modal, fl ), | 393 | : QDialog( parent, name, modal, fl ), |
391 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) | 394 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) |
@@ -411,3 +414,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
411 | iconPath = "/home/QtPalmtop/pics/"; | 414 | iconPath = "/home/QtPalmtop/pics/"; |
412 | else | 415 | else |
413 | iconPath = qpedir + "/pics/"; | 416 | iconPath = qpedir + "/pics/"; |
@@ -460,3 +463,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
460 | if ( !name ) | 463 | if ( !name ) |
461 | setName( "ZSafe" ); | 464 | setName( "ZSafe" ); |
462 | 465 | ||
@@ -464,5 +467,5 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
464 | #ifdef WIN32 | 467 | #ifdef WIN32 |
465 | setGeometry(100, 150, DeskW, DeskH-30 ); | 468 | setGeometry(100, 150, DeskW, DeskH-30 ); |
466 | #else | 469 | #else |
467 | resize( DeskW, DeskH-30 ); | 470 | resize( DeskW, DeskH-30 ); |
468 | #endif | 471 | #endif |
@@ -500,3 +503,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
500 | // #else | 503 | // #else |
501 | QString d1(QDir::homeDirPath() + "/Documents/application"); | 504 | QString d1(QDir::homeDirPath() + "/Documents/application"); |
502 | // #endif | 505 | // #endif |
@@ -517,3 +520,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
517 | } | 520 | } |
518 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); | 521 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); |
519 | QDir pd2(d2); | 522 | QDir pd2(d2); |
@@ -533,3 +536,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
533 | } | 536 | } |
534 | 537 | ||
535 | 538 | ||
@@ -578,3 +581,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
578 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); | 581 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); |
579 | file->insertItem( save_img, tr("S&ave document with new Password"), this, | 582 | file->insertItem( save_img, tr("S&ave document with new Password"), this, |
580 | SLOT(saveDocumentWithPwd()) ); | 583 | SLOT(saveDocumentWithPwd()) ); |
@@ -585,3 +588,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
585 | file->insertSeparator(); | 588 | file->insertSeparator(); |
586 | file->insertItem( expand_img, tr("&Open entries expanded"), this, | 589 | file->insertItem( expand_img, tr("&Open entries expanded"), this, |
587 | SLOT(setExpandFlag()), 0, 'o'); | 590 | SLOT(setExpandFlag()), 0, 'o'); |
@@ -616,3 +619,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
616 | New = new QToolButton( menu, "New" ); | 619 | New = new QToolButton( menu, "New" ); |
617 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); | 620 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); |
618 | New->setMouseTracking( TRUE ); | 621 | New->setMouseTracking( TRUE ); |
@@ -623,3 +626,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
623 | Edit = new QToolButton( menu, "Edit" ); | 626 | Edit = new QToolButton( menu, "Edit" ); |
624 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); | 627 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); |
625 | Edit->setText( tr( "" ) ); | 628 | Edit->setText( tr( "" ) ); |
@@ -629,3 +632,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
629 | Delete = new QToolButton( menu, "Delete" ); | 632 | Delete = new QToolButton( menu, "Delete" ); |
630 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 633 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
631 | Delete->setText( tr( "" ) ); | 634 | Delete->setText( tr( "" ) ); |
@@ -635,3 +638,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
635 | Find = new QToolButton( menu, "Find" ); | 638 | Find = new QToolButton( menu, "Find" ); |
636 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); | 639 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); |
637 | Find->setText( tr( "" ) ); | 640 | Find->setText( tr( "" ) ); |
@@ -660,7 +663,7 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
660 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 663 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
661 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); | 664 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); |
662 | #else | 665 | #else |
663 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 666 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
664 | // ListView->setGeometry( QRect( 0, 22, | 667 | // ListView->setGeometry( QRect( 0, 22, |
665 | // this->width(), this->height() - 30 ) ); | 668 | // this->width(), this->height() - 30 ) ); |
666 | // ListView->setMaximumSize( QSize( 440, 290 ) ); | 669 | // ListView->setMaximumSize( QSize( 440, 290 ) ); |
@@ -703,3 +706,3 @@ const QColor *ZSafe::oddRowColor = new QColor(216,240,255); | |||
703 | 706 | ||
704 | /* | 707 | /* |
705 | * Destroys the object and frees any allocated resources | 708 | * Destroys the object and frees any allocated resources |
@@ -727,3 +730,3 @@ void ZSafe::deletePwd() | |||
727 | tr("Do you want to delete?"), | 730 | tr("Do you want to delete?"), |
728 | tr("&Delete"), tr("D&on't Delete"), | 731 | tr("&Delete"), tr("D&on't Delete"), |
729 | 0 // Enter == button 0 | 732 | 0 // Enter == button 0 |
@@ -756,5 +759,5 @@ void ZSafe::editPwd() | |||
756 | dialog->setCaption ("Qt " + tr("Edit Entry")); | 759 | dialog->setCaption ("Qt " + tr("Edit Entry")); |
757 | dialog->setGeometry(200, 250, 220, 310 ); | 760 | dialog->setGeometry(200, 250, 220, 310 ); |
758 | #endif | 761 | #endif |
759 | 762 | ||
760 | // set the labels | 763 | // set the labels |
@@ -787,14 +790,14 @@ void ZSafe::editPwd() | |||
787 | // edit the selected item | 790 | // edit the selected item |
788 | QString name = dialog->NameField->text(); | 791 | QString name = dialog->NameField->text(); |
789 | selectedItem->setText (0, tr (name)); | 792 | selectedItem->setText (0, tr (name)); |
790 | QString user = dialog->UsernameField->text(); | 793 | QString user = dialog->UsernameField->text(); |
791 | selectedItem->setText (1, tr (user)); | 794 | selectedItem->setText (1, tr (user)); |
792 | QString pwd = dialog->PasswordField->text(); | 795 | QString pwd = dialog->PasswordField->text(); |
793 | selectedItem->setText (2, tr (pwd)); | 796 | selectedItem->setText (2, tr (pwd)); |
794 | QString comment = dialog->CommentField->text(); | 797 | QString comment = dialog->CommentField->text(); |
795 | comment.replace (QRegExp("\n"), "<br>"); | 798 | comment.replace (QRegExp("\n"), "<br>"); |
796 | selectedItem->setText (3, tr (comment)); | 799 | selectedItem->setText (3, tr (comment)); |
797 | QString f5 = dialog->Field5->text(); | 800 | QString f5 = dialog->Field5->text(); |
798 | selectedItem->setText (4, tr (f5)); | 801 | selectedItem->setText (4, tr (f5)); |
799 | QString f6 = dialog->Field6->text(); | 802 | QString f6 = dialog->Field6->text(); |
800 | selectedItem->setText (5, tr (f6)); | 803 | selectedItem->setText (5, tr (f6)); |
@@ -804,3 +807,3 @@ void ZSafe::editPwd() | |||
804 | } | 807 | } |
805 | else | 808 | else |
806 | { | 809 | { |
@@ -826,3 +829,3 @@ void ZSafe::newPwd() | |||
826 | dialog->setCaption ("Qt " + tr("New Entry")); | 829 | dialog->setCaption ("Qt " + tr("New Entry")); |
827 | dialog->setGeometry(200, 250, 220, 310 ); | 830 | dialog->setGeometry(200, 250, 220, 310 ); |
828 | #endif | 831 | #endif |
@@ -845,3 +848,3 @@ retype: | |||
845 | 848 | ||
846 | QString name = dialog->NameField->text(); | 849 | QString name = dialog->NameField->text(); |
847 | if (cat == name) | 850 | if (cat == name) |
@@ -859,12 +862,12 @@ retype: | |||
859 | i->setText (0, tr (name)); | 862 | i->setText (0, tr (name)); |
860 | QString user = dialog->UsernameField->text(); | 863 | QString user = dialog->UsernameField->text(); |
861 | i->setText (1, tr (user)); | 864 | i->setText (1, tr (user)); |
862 | QString pwd = dialog->PasswordField->text(); | 865 | QString pwd = dialog->PasswordField->text(); |
863 | i->setText (2, tr (pwd)); | 866 | i->setText (2, tr (pwd)); |
864 | QString comment = dialog->CommentField->text(); | 867 | QString comment = dialog->CommentField->text(); |
865 | comment.replace (QRegExp("\n"), "<br>"); | 868 | comment.replace (QRegExp("\n"), "<br>"); |
866 | i->setText (3, tr (comment)); | 869 | i->setText (3, tr (comment)); |
867 | QString f5 = dialog->Field5->text(); | 870 | QString f5 = dialog->Field5->text(); |
868 | i->setText (4, tr (f5)); | 871 | i->setText (4, tr (f5)); |
869 | QString f6 = dialog->Field6->text(); | 872 | QString f6 = dialog->Field6->text(); |
870 | i->setText (5, tr (f6)); | 873 | i->setText (5, tr (f6)); |
@@ -954,3 +957,3 @@ void ZSafe::findPwd() | |||
954 | i = ListView->firstChild(); | 957 | i = ListView->firstChild(); |
955 | for (; | 958 | for (; |
956 | i != NULL; | 959 | i != NULL; |
@@ -967,3 +970,3 @@ void ZSafe::findPwd() | |||
967 | si = i->firstChild(); | 970 | si = i->firstChild(); |
968 | // for (si = i->firstChild(); | 971 | // for (si = i->firstChild(); |
969 | for (; | 972 | for (; |
@@ -1020,5 +1023,5 @@ void ZSafe::findPwd() | |||
1020 | update(); | 1023 | update(); |
1021 | QMessageBox::information( this, tr("ZSafe"), | 1024 | QMessageBox::information( this, tr("ZSafe"), |
1022 | tr("Entry not found"), tr("&OK"), 0); | 1025 | tr("Entry not found"), tr("&OK"), 0); |
1023 | 1026 | ||
1024 | } | 1027 | } |
@@ -1078,3 +1081,3 @@ QString ZSafe::getFieldLabel (QString category, QString field, QString def) | |||
1078 | // #ifndef WIN32 | 1081 | // #ifndef WIN32 |
1079 | QString label = conf->readEntry(app_key+category+"-field"+field, | 1082 | QString label = conf->readEntry(app_key+category+"-field"+field, |
1080 | def); | 1083 | def); |
@@ -1095,3 +1098,3 @@ void ZSafe::showInfo( QListViewItem *_item) | |||
1095 | selectedItem->setSelected(FALSE); | 1098 | selectedItem->setSelected(FALSE); |
1096 | 1099 | ||
1097 | selectedItem = _item; | 1100 | selectedItem = _item; |
@@ -1240,3 +1243,3 @@ void ZSafe::removeAsciiFile() | |||
1240 | #else | 1243 | #else |
1241 | QString fn = ScQtFileEdit::getOpenFileName(this, | 1244 | QString fn = ScQtFileEdit::getOpenFileName(this, |
1242 | tr ("Remove text file"), | 1245 | tr ("Remove text file"), |
@@ -1247,3 +1250,3 @@ void ZSafe::removeAsciiFile() | |||
1247 | QString fn = QFileDialog::getOpenFileName( | 1250 | QString fn = QFileDialog::getOpenFileName( |
1248 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1251 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1249 | "ZSafe (*.txt)", | 1252 | "ZSafe (*.txt)", |
@@ -1257,3 +1260,3 @@ void ZSafe::removeAsciiFile() | |||
1257 | QFile f( fn ); | 1260 | QFile f( fn ); |
1258 | if ( !f.remove() ) | 1261 | if ( !f.remove() ) |
1259 | { | 1262 | { |
@@ -1290,3 +1293,3 @@ void ZSafe::writeAllEntries() | |||
1290 | #else | 1293 | #else |
1291 | QString fn = ScQtFileEdit::getSaveAsFileName(this, | 1294 | QString fn = ScQtFileEdit::getSaveAsFileName(this, |
1292 | tr ("Export text file"), | 1295 | tr ("Export text file"), |
@@ -1297,3 +1300,3 @@ void ZSafe::writeAllEntries() | |||
1297 | QString fn = QFileDialog::getSaveFileName( | 1300 | QString fn = QFileDialog::getSaveFileName( |
1298 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1301 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1299 | "ZSafe (*.txt)", | 1302 | "ZSafe (*.txt)", |
@@ -1319,3 +1322,3 @@ void ZSafe::writeAllEntries() | |||
1319 | // step through all categories | 1322 | // step through all categories |
1320 | for (i = ListView->firstChild(); | 1323 | for (i = ListView->firstChild(); |
1321 | i != NULL; | 1324 | i != NULL; |
@@ -1325,3 +1328,3 @@ void ZSafe::writeAllEntries() | |||
1325 | QListViewItem *si; | 1328 | QListViewItem *si; |
1326 | for (si = i->firstChild(); | 1329 | for (si = i->firstChild(); |
1327 | si != NULL; | 1330 | si != NULL; |
@@ -1385,3 +1388,3 @@ void ZSafe::readAllEntries() | |||
1385 | #else | 1388 | #else |
1386 | QString fn = ScQtFileEdit::getOpenFileName(this, | 1389 | QString fn = ScQtFileEdit::getOpenFileName(this, |
1387 | tr ("Import text file"), | 1390 | tr ("Import text file"), |
@@ -1392,3 +1395,3 @@ void ZSafe::readAllEntries() | |||
1392 | QString fn = QFileDialog::getOpenFileName( | 1395 | QString fn = QFileDialog::getOpenFileName( |
1393 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1396 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1394 | "ZSafe (*.txt)", | 1397 | "ZSafe (*.txt)", |
@@ -1437,3 +1440,3 @@ void ZSafe::readAllEntries() | |||
1437 | QTextStream t(&f); | 1440 | QTextStream t(&f); |
1438 | while ( !t.eof() ) | 1441 | while ( !t.eof() ) |
1439 | { | 1442 | { |
@@ -1443,5 +1446,5 @@ void ZSafe::readAllEntries() | |||
1443 | #ifndef WIN32 | 1446 | #ifndef WIN32 |
1444 | char buffer[s.length()+1]; | 1447 | char buffer[s.length()+1]; |
1445 | #else | 1448 | #else |
1446 | char buffer[4048]; | 1449 | char buffer[4048]; |
1447 | #endif | 1450 | #endif |
@@ -1450,3 +1453,3 @@ void ZSafe::readAllEntries() | |||
1450 | /* modify QString -> QCString::utf8 */ | 1453 | /* modify QString -> QCString::utf8 */ |
1451 | 1454 | ||
1452 | strcpy (buffer, s.utf8()); | 1455 | strcpy (buffer, s.utf8()); |
@@ -1501,3 +1504,3 @@ void ZSafe::readAllEntries() | |||
1501 | } | 1504 | } |
1502 | idx++; | 1505 | idx++; |
1503 | } | 1506 | } |
@@ -1595,3 +1598,3 @@ void ZSafe::writeAllEntries() | |||
1595 | // step through all categories | 1598 | // step through all categories |
1596 | for (i = ListView->firstChild(); | 1599 | for (i = ListView->firstChild(); |
1597 | i != NULL; | 1600 | i != NULL; |
@@ -1601,3 +1604,3 @@ void ZSafe::writeAllEntries() | |||
1601 | QListViewItem *si; | 1604 | QListViewItem *si; |
1602 | for (si = i->firstChild(); | 1605 | for (si = i->firstChild(); |
1603 | si != NULL; | 1606 | si != NULL; |
@@ -1672,3 +1675,3 @@ void ZSafe::readAllEntries() | |||
1672 | QTextStream t(&f); | 1675 | QTextStream t(&f); |
1673 | while ( !t.eof() ) | 1676 | while ( !t.eof() ) |
1674 | { | 1677 | { |
@@ -1677,5 +1680,5 @@ void ZSafe::readAllEntries() | |||
1677 | // char buffer[1024]; | 1680 | // char buffer[1024]; |
1678 | int len=s.length()+1; | 1681 | int len=s.length()+1; |
1679 | #ifdef WIN32 | 1682 | #ifdef WIN32 |
1680 | char buffer[512]; | 1683 | char buffer[512]; |
1681 | #else | 1684 | #else |
@@ -1721,3 +1724,3 @@ void ZSafe::readAllEntries() | |||
1721 | } | 1724 | } |
1722 | idx++; | 1725 | idx++; |
1723 | } | 1726 | } |
@@ -1834,3 +1837,3 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1834 | // #else | 1837 | // #else |
1835 | // int validationFlag = 1; | 1838 | // int validationFlag = 1; |
1836 | // #endif | 1839 | // #endif |
@@ -1845,5 +1848,5 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1845 | // ask with a dialog for the password | 1848 | // ask with a dialog for the password |
1846 | if (m_password.isEmpty()) | 1849 | if (m_password.isEmpty()) |
1847 | getDocPassword(tr("Enter Password")); | 1850 | getDocPassword(tr("Enter Password")); |
1848 | if (m_password.isEmpty() && validationFlag == 0) | 1851 | if (m_password.isEmpty() && validationFlag == 0) |
1849 | { | 1852 | { |
@@ -1855,8 +1858,8 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1855 | 1858 | ||
1856 | retval = loadInit(_filename, m_password); | 1859 | retval = loadInit(_filename, m_password); |
1857 | if (retval != PWERR_GOOD) | 1860 | if (retval != PWERR_GOOD) |
1858 | { | 1861 | { |
1859 | qWarning ("Error loading Document"); | 1862 | qWarning ("Error loading Document"); |
1860 | return false; | 1863 | return false; |
1861 | } | 1864 | } |
1862 | } | 1865 | } |
@@ -1881,3 +1884,3 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1881 | 1884 | ||
1882 | retval = loadEntry(entry); | 1885 | retval = loadEntry(entry); |
1883 | if (retval == 1 && | 1886 | if (retval == 1 && |
@@ -1889,3 +1892,3 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1889 | { | 1892 | { |
1890 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1893 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1891 | pwdOk = 1; | 1894 | pwdOk = 1; |
@@ -1894,4 +1897,4 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1894 | else | 1897 | else |
1895 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1898 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1896 | fclose (fd); | 1899 | fclose (fd); |
1897 | m_password = ""; | 1900 | m_password = ""; |
@@ -1902,6 +1905,6 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1902 | tr("Wrong password.\nEnter again?"), | 1905 | tr("Wrong password.\nEnter again?"), |
1903 | tr("&Yes"), tr("&No."), | 1906 | tr("&Yes"), tr("&No."), |
1904 | 0 | 1907 | 0 |
1905 | ) ) | 1908 | ) ) |
1906 | { | 1909 | { |
1907 | case 1: // No | 1910 | case 1: // No |
@@ -1925,6 +1928,6 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1925 | 1928 | ||
1926 | retval = loadEntry(entry); | 1929 | retval = loadEntry(entry); |
1927 | 1930 | ||
1928 | int numberOfEntries=0; | 1931 | int numberOfEntries=0; |
1929 | while (retval == 1) { | 1932 | while (retval == 1) { |
1930 | 1933 | ||
@@ -2010,10 +2013,10 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
2010 | 2013 | ||
2011 | for (int count = 0; count < FIELD_SIZE; count++) { | 2014 | for (int count = 0; count < FIELD_SIZE; count++) { |
2012 | free(entry[count]); | 2015 | free(entry[count]); |
2013 | } | 2016 | } |
2014 | retval = loadEntry(entry); | 2017 | retval = loadEntry(entry); |
2015 | if (retval == 2) { | 2018 | if (retval == 2) { |
2016 | // m_parent->slotStatusHelpMsg("Last entry loaded"); | 2019 | // m_parent->slotStatusHelpMsg("Last entry loaded"); |
2017 | } | 2020 | } |
2018 | } // end while | 2021 | } // end while |
2019 | 2022 | ||
@@ -2021,10 +2024,10 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
2021 | { | 2024 | { |
2022 | 2025 | ||
2023 | switch( QMessageBox::warning( this, tr("ZSafe"), | 2026 | switch( QMessageBox::warning( this, tr("ZSafe"), |
2024 | tr("Empty document or\nwrong password.\nContinue?"), | 2027 | tr("Empty document or\nwrong password.\nContinue?"), |
2025 | tr("&No"), tr("&Yes."), | 2028 | tr("&No"), tr("&Yes."), |
2026 | 0 | 2029 | 0 |
2027 | ) ) { | 2030 | ) ) { |
2028 | case 0: // No | 2031 | case 0: // No |
2029 | retval = loadFinalize(); | 2032 | retval = loadFinalize(); |
2030 | exitZs (1); | 2033 | exitZs (1); |
@@ -2034,7 +2037,7 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
2034 | } | 2037 | } |
2035 | } | 2038 | } |
2036 | 2039 | ||
2037 | retval = loadFinalize(); | 2040 | retval = loadFinalize(); |
2038 | 2041 | ||
2039 | return true; | 2042 | return true; |
2040 | } | 2043 | } |
@@ -2043,11 +2046,11 @@ int ZSafe::loadInit(const char* _filename, const char *password) | |||
2043 | { | 2046 | { |
2044 | unsigned int j = 0; | 2047 | unsigned int j = 0; |
2045 | unsigned int keylength=0; | 2048 | unsigned int keylength=0; |
2046 | int count=0, count2=0, count3=0; | 2049 | int count=0, count2=0, count3=0; |
2047 | unsigned char charbuf[8]; | 2050 | unsigned char charbuf[8]; |
2048 | unsigned short ciphertext[4]; | 2051 | unsigned short ciphertext[4]; |
2049 | char key[128]; | 2052 | char key[128]; |
2050 | Krc2* krc2 = new Krc2(); | 2053 | Krc2* krc2 = new Krc2(); |
2051 | 2054 | ||
2052 | fd = fopen (_filename, "rb"); | 2055 | fd = fopen (_filename, "rb"); |
2053 | 2056 | ||
@@ -2057,16 +2060,16 @@ int ZSafe::loadInit(const char* _filename, const char *password) | |||
2057 | 2060 | ||
2058 | if (fd == NULL) | 2061 | if (fd == NULL) |
2059 | return PWERR_OPEN; | 2062 | return PWERR_OPEN; |
2060 | 2063 | ||
2061 | buffer = (char *)malloc(load_buffer_length); | 2064 | buffer = (char *)malloc(load_buffer_length); |
2062 | for (j = 0; password[j] != '\0'; j++) { | 2065 | for (j = 0; password[j] != '\0'; j++) { |
2063 | key[j] = password[j]; | 2066 | key[j] = password[j]; |
2064 | } | 2067 | } |
2065 | keylength = j; | 2068 | keylength = j; |
2066 | krc2->rc2_expandkey (key, keylength, 128); | 2069 | krc2->rc2_expandkey (key, keylength, 128); |
2067 | 2070 | ||
2068 | #ifndef WIN32 | 2071 | #ifndef WIN32 |
2069 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); | 2072 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); |
2070 | #else | 2073 | #else |
2071 | printf ("LoadInit() read1"); | 2074 | printf ("LoadInit() read1"); |
2072 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 2075 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
@@ -2074,50 +2077,50 @@ int ZSafe::loadInit(const char* _filename, const char *password) | |||
2074 | 2077 | ||
2075 | if (size < 8) | 2078 | if (size < 8) |
2076 | return PWERR_DATA; | 2079 | return PWERR_DATA; |
2077 | 2080 | ||
2078 | for (count = 0; count < 4; count++) { | 2081 | for (count = 0; count < 4; count++) { |
2079 | count2 = count << 1; | 2082 | count2 = count << 1; |
2080 | iv[count] = charbuf[count2] << 8; | 2083 | iv[count] = charbuf[count2] << 8; |
2081 | iv[count] += charbuf[count2 + 1]; | 2084 | iv[count] += charbuf[count2 + 1]; |
2082 | } | 2085 | } |
2083 | 2086 | ||
2084 | size = 0; | 2087 | size = 0; |
2085 | bufferIndex = 0; | 2088 | bufferIndex = 0; |
2086 | #ifndef WIN32 | 2089 | #ifndef WIN32 |
2087 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { | 2090 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { |
2088 | while (count < 8) { | 2091 | while (count < 8) { |
2089 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); | 2092 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); |
2090 | #else | 2093 | #else |
2091 | printf ("LoadInit() read2"); | 2094 | printf ("LoadInit() read2"); |
2092 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { | 2095 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { |
2093 | while (count < 8) { | 2096 | while (count < 8) { |
2094 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 2097 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
2095 | #endif | 2098 | #endif |
2096 | if (count2 == 0) { | 2099 | if (count2 == 0) { |
2097 | return PWERR_DATA; | 2100 | return PWERR_DATA; |
2098 | } | 2101 | } |
2099 | count += count2; | 2102 | count += count2; |
2100 | } /* while (count < 8) */ | 2103 | } /* while (count < 8) */ |
2101 | 2104 | ||
2102 | size += 8; | 2105 | size += 8; |
2103 | for (count2 = 0; count2 < 8; count2 += 2) { | 2106 | for (count2 = 0; count2 < 8; count2 += 2) { |
2104 | count3 = count2 >> 1; | 2107 | count3 = count2 >> 1; |
2105 | ciphertext[count3] = charbuf[count2] << 8; | 2108 | ciphertext[count3] = charbuf[count2] << 8; |
2106 | ciphertext[count3] += charbuf[count2 + 1]; | 2109 | ciphertext[count3] += charbuf[count2 + 1]; |
2107 | 2110 | ||
2108 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; | 2111 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; |
2109 | iv[count3] = plaintext[count3]; | 2112 | iv[count3] = plaintext[count3]; |
2110 | } /* for (count2) */ | 2113 | } /* for (count2) */ |
2111 | 2114 | ||
2112 | krc2->rc2_decrypt (plaintext); | 2115 | krc2->rc2_decrypt (plaintext); |
2113 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); | 2116 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); |
2114 | bufferIndex += 8; | 2117 | bufferIndex += 8; |
2115 | buffer[bufferIndex + 1] = '\0'; | 2118 | buffer[bufferIndex + 1] = '\0'; |
2116 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ | 2119 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ |
2117 | size -= buffer[size - 1]; | 2120 | size -= buffer[size - 1]; |
2118 | lastcount = 0; | 2121 | lastcount = 0; |
2119 | 2122 | ||
2120 | /* This will point to the starting index */ | 2123 | /* This will point to the starting index */ |
2121 | bufferIndex = 0; | 2124 | bufferIndex = 0; |
2122 | return PWERR_GOOD; | 2125 | return PWERR_GOOD; |
2123 | } | 2126 | } |
@@ -2126,26 +2129,26 @@ int ZSafe::loadEntry(char *entry[FIELD_SIZE]) | |||
2126 | { | 2129 | { |
2127 | /* Strip off PKCS 5 padding | 2130 | /* Strip off PKCS 5 padding |
2128 | * Should check to make sure it's good here | 2131 | * Should check to make sure it's good here |
2129 | */ | 2132 | */ |
2130 | int count, count1=0; | 2133 | int count, count1=0; |
2131 | 2134 | ||
2132 | for (count = lastcount; count < size; count++) { | 2135 | for (count = lastcount; count < size; count++) { |
2133 | if ((unsigned char) (buffer[count]) == 255) { | 2136 | if ((unsigned char) (buffer[count]) == 255) { |
2134 | if (buffer[bufferIndex] == '\0') { | 2137 | if (buffer[bufferIndex] == '\0') { |
2135 | bufferIndex++; | 2138 | bufferIndex++; |
2136 | } | 2139 | } |
2137 | entry[count1] = (char *) malloc (count - bufferIndex + 1); | 2140 | entry[count1] = (char *) malloc (count - bufferIndex + 1); |
2138 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); | 2141 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); |
2139 | entry[count1][count - bufferIndex] = '\0'; | 2142 | entry[count1][count - bufferIndex] = '\0'; |
2140 | count++; | 2143 | count++; |
2141 | bufferIndex = count; | 2144 | bufferIndex = count; |
2142 | count1++; | 2145 | count1++; |
2143 | if (count1 == FIELD_SIZE) { | 2146 | if (count1 == FIELD_SIZE) { |
2144 | lastcount = count; | 2147 | lastcount = count; |
2145 | return 1; | 2148 | return 1; |
2146 | } | 2149 | } |
2147 | } /* if ((unsigned char) (buffer[count]) == 255) */ | 2150 | } /* if ((unsigned char) (buffer[count]) == 255) */ |
2148 | } /* for (count = 0; count < size; count++) */ | 2151 | } /* for (count = 0; count < size; count++) */ |
2149 | 2152 | ||
2150 | return 2; | 2153 | return 2; |
2151 | } | 2154 | } |
@@ -2154,9 +2157,9 @@ int ZSafe::loadFinalize(void) | |||
2154 | { | 2157 | { |
2155 | fclose (fd); | 2158 | fclose (fd); |
2156 | if (buffer) free(buffer); | 2159 | if (buffer) free(buffer); |
2157 | return PWERR_GOOD; | 2160 | return PWERR_GOOD; |
2158 | } | 2161 | } |
2159 | 2162 | ||
2160 | bool ZSafe::saveDocument(const char* _filename, | 2163 | bool ZSafe::saveDocument(const char* _filename, |
2161 | bool withPwd, | 2164 | bool withPwd, |
2162 | const char* ) | 2165 | const char* ) |
@@ -2177,7 +2180,7 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2177 | { | 2180 | { |
2178 | getDocPassword(tr("Enter Password")); | 2181 | getDocPassword(tr("Enter Password")); |
2179 | if (m_password.isEmpty()) | 2182 | if (m_password.isEmpty()) |
2180 | { | 2183 | { |
2181 | 2184 | ||
2182 | QMessageBox::critical( 0, tr("ZSafe"), | 2185 | QMessageBox::critical( 0, tr("ZSafe"), |
2183 | tr("Password is empty.\nPlease enter again.")); | 2186 | tr("Password is empty.\nPlease enter again.")); |
@@ -2185,9 +2188,9 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2185 | } | 2188 | } |
2186 | 2189 | ||
2187 | QString firstPasswd = m_password; | 2190 | QString firstPasswd = m_password; |
2188 | 2191 | ||
2189 | getDocPassword(tr("Reenter Password")); | 2192 | getDocPassword(tr("Reenter Password")); |
2190 | if (m_password.isEmpty()) | 2193 | if (m_password.isEmpty()) |
2191 | { | 2194 | { |
2192 | QMessageBox::critical( 0, tr("ZSafe"), | 2195 | QMessageBox::critical( 0, tr("ZSafe"), |
2193 | tr("Password is empty.\nPlease enter again.")); | 2196 | tr("Password is empty.\nPlease enter again.")); |
@@ -2197,4 +2200,4 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2197 | { | 2200 | { |
2198 | 2201 | ||
2199 | QMessageBox::critical( 0, tr("ZSafe"), | 2202 | QMessageBox::critical( 0, tr("ZSafe"), |
2200 | tr("Passwords must be identical.\nPlease enter again.")); | 2203 | tr("Passwords must be identical.\nPlease enter again.")); |
@@ -2202,6 +2205,6 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2202 | } | 2205 | } |
2203 | pwdOk = TRUE; | 2206 | pwdOk = TRUE; |
2204 | modified = false; | 2207 | modified = false; |
2205 | } | 2208 | } |
2206 | } | 2209 | } |
2207 | else if (modified) | 2210 | else if (modified) |
@@ -2212,6 +2215,6 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2212 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), | 2215 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), |
2213 | tr("&Save"), | 2216 | tr("&Save"), |
2214 | tr("&Don't Save"), | 2217 | tr("&Don't Save"), |
2215 | 0 // Enter == button 0 | 2218 | 0 // Enter == button 0 |
2216 | ) ) | 2219 | ) ) |
2217 | { // Escape == button 2 | 2220 | { // Escape == button 2 |
@@ -2226,3 +2229,3 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2226 | modified = false; | 2229 | modified = false; |
2227 | 2230 | ||
2228 | if (m_password.isEmpty()) | 2231 | if (m_password.isEmpty()) |
@@ -2231,8 +2234,8 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2231 | int retval = saveInit(_filename, m_password); | 2234 | int retval = saveInit(_filename, m_password); |
2232 | // int retval = saveInit(_filename, "test"); | 2235 | // int retval = saveInit(_filename, "test"); |
2233 | if (retval != PWERR_GOOD) { | 2236 | if (retval != PWERR_GOOD) { |
2234 | return false; | 2237 | return false; |
2235 | } | 2238 | } |
2236 | 2239 | ||
2237 | char* entry[FIELD_SIZE]; | 2240 | char* entry[FIELD_SIZE]; |
2238 | 2241 | ||
@@ -2241,19 +2244,19 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2241 | int i=0; | 2244 | int i=0; |
2242 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); | 2245 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); |
2243 | strcpy(entry[i++], "ZSAFECATEGORY"); | 2246 | strcpy(entry[i++], "ZSAFECATEGORY"); |
2244 | entry[i] = (char*)malloc(strlen("name")+1); | 2247 | entry[i] = (char*)malloc(strlen("name")+1); |
2245 | strcpy(entry[i++], "name"); | 2248 | strcpy(entry[i++], "name"); |
2246 | entry[i] = (char*)malloc(strlen("username")+1); | 2249 | entry[i] = (char*)malloc(strlen("username")+1); |
2247 | strcpy(entry[i++], "username"); | 2250 | strcpy(entry[i++], "username"); |
2248 | entry[i] = (char*)malloc(strlen("password")+1); | 2251 | entry[i] = (char*)malloc(strlen("password")+1); |
2249 | strcpy(entry[i++], "password"); | 2252 | strcpy(entry[i++], "password"); |
2250 | entry[i] = (char*)malloc(strlen("comment")+1); | 2253 | entry[i] = (char*)malloc(strlen("comment")+1); |
2251 | strcpy(entry[i++], "comment"); | 2254 | strcpy(entry[i++], "comment"); |
2252 | 2255 | ||
2253 | entry[i] = (char*)malloc(strlen("field5")+1); | 2256 | entry[i] = (char*)malloc(strlen("field5")+1); |
2254 | strcpy(entry[i++], "field5"); | 2257 | strcpy(entry[i++], "field5"); |
2255 | entry[i] = (char*)malloc(strlen("field6")+1); | 2258 | entry[i] = (char*)malloc(strlen("field6")+1); |
2256 | strcpy(entry[i++], "field6"); | 2259 | strcpy(entry[i++], "field6"); |
2257 | 2260 | ||
2258 | retval = saveEntry(entry); | 2261 | retval = saveEntry(entry); |
2259 | for (int z=0; z<i; z++) free(entry[z]); | 2262 | for (int z=0; z<i; z++) free(entry[z]); |
@@ -2298,3 +2301,3 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2298 | 2301 | ||
2299 | retval = saveEntry(entry); | 2302 | retval = saveEntry(entry); |
2300 | for (int z=0; z<j; z++) | 2303 | for (int z=0; z<j; z++) |
@@ -2312,6 +2315,6 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2312 | 2315 | ||
2313 | if (saveFinalize() == PWERR_DATA) { | 2316 | if (saveFinalize() == PWERR_DATA) { |
2314 | qWarning("2: Error writing file, contents not saved"); | 2317 | qWarning("2: Error writing file, contents not saved"); |
2315 | return false; | 2318 | return false; |
2316 | } else { | 2319 | } else { |
2317 | #ifndef DESKTOP | 2320 | #ifndef DESKTOP |
@@ -2320,4 +2323,4 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2320 | modified = false; | 2323 | modified = false; |
2321 | return true; | 2324 | return true; |
2322 | } | 2325 | } |
2323 | } | 2326 | } |
@@ -2372,23 +2375,23 @@ int ZSafe::saveInit(const char *_filename, const char *password) | |||
2372 | { | 2375 | { |
2373 | char key[128]; | 2376 | char key[128]; |
2374 | unsigned int j = 0; | 2377 | unsigned int j = 0; |
2375 | unsigned int keylength; | 2378 | unsigned int keylength; |
2376 | // int val; | 2379 | // int val; |
2377 | int count2; | 2380 | int count2; |
2378 | Krc2* krc2 = new Krc2(); | 2381 | Krc2* krc2 = new Krc2(); |
2379 | 2382 | ||
2380 | /* first we should check the permissions of the filename */ | 2383 | /* first we should check the permissions of the filename */ |
2381 | /* | 2384 | /* |
2382 | if (QFile::exists(_filename)) { | 2385 | if (QFile::exists(_filename)) { |
2383 | val = checkFile(_filename); | 2386 | val = checkFile(_filename); |
2384 | if (val != PWERR_GOOD) | 2387 | if (val != PWERR_GOOD) |
2385 | return val; | 2388 | return val; |
2386 | } else | 2389 | } else |
2387 | { | 2390 | { |
2388 | val = creat (_filename, (S_IRUSR | S_IWUSR)); | 2391 | val = creat (_filename, (S_IRUSR | S_IWUSR)); |
2389 | if (val == -1) | 2392 | if (val == -1) |
2390 | return PWERR_OPEN; | 2393 | return PWERR_OPEN; |
2391 | else | 2394 | else |
2392 | close(val); | 2395 | close(val); |
2393 | } | 2396 | } |
2394 | */ | 2397 | */ |
@@ -2398,24 +2401,24 @@ int ZSafe::saveInit(const char *_filename, const char *password) | |||
2398 | 2401 | ||
2399 | fd = fopen (_filename, "wb"); | 2402 | fd = fopen (_filename, "wb"); |
2400 | if (fd == NULL) | 2403 | if (fd == NULL) |
2401 | return PWERR_OPEN; | 2404 | return PWERR_OPEN; |
2402 | 2405 | ||
2403 | buffer = (char*)malloc(save_buffer_length); | 2406 | buffer = (char*)malloc(save_buffer_length); |
2404 | 2407 | ||
2405 | /* make the key ready */ | 2408 | /* make the key ready */ |
2406 | for (j = 0; password[j] != '\0'; j++) { | 2409 | for (j = 0; password[j] != '\0'; j++) { |
2407 | key[j] = password[j]; | 2410 | key[j] = password[j]; |
2408 | } | 2411 | } |
2409 | keylength = j; | 2412 | keylength = j; |
2410 | krc2->rc2_expandkey (key, keylength, 128); | 2413 | krc2->rc2_expandkey (key, keylength, 128); |
2411 | 2414 | ||
2412 | /* First, we make the IV */ | 2415 | /* First, we make the IV */ |
2413 | for (count2 = 0; count2 < 4; count2++) { | 2416 | for (count2 = 0; count2 < 4; count2++) { |
2414 | iv[count2] = rand (); | 2417 | iv[count2] = rand (); |
2415 | putc ((unsigned char) (iv[count2] >> 8), fd); | 2418 | putc ((unsigned char) (iv[count2] >> 8), fd); |
2416 | putc ((unsigned char) (iv[count2] & 0xff), fd); | 2419 | putc ((unsigned char) (iv[count2] & 0xff), fd); |
2417 | } | 2420 | } |
2418 | 2421 | ||
2419 | bufferIndex = 0; | 2422 | bufferIndex = 0; |
2420 | return PWERR_GOOD; | 2423 | return PWERR_GOOD; |
2421 | } | 2424 | } |
@@ -2425,54 +2428,54 @@ int ZSafe::saveEntry(char *entry[FIELD_SIZE]) | |||
2425 | { | 2428 | { |
2426 | char *text1; | 2429 | char *text1; |
2427 | int count2, count3; | 2430 | int count2, count3; |
2428 | unsigned short ciphertext[4]; | 2431 | unsigned short ciphertext[4]; |
2429 | Krc2* krc2 = new Krc2(); | 2432 | Krc2* krc2 = new Krc2(); |
2430 | 2433 | ||
2431 | buffer = (char*)memset(buffer, '\0', save_buffer_length); | 2434 | buffer = (char*)memset(buffer, '\0', save_buffer_length); |
2432 | 2435 | ||
2433 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { | 2436 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { |
2434 | text1 = entry[count2]; | 2437 | text1 = entry[count2]; |
2435 | if (strlen (text1) == 0) { | 2438 | if (strlen (text1) == 0) { |
2436 | strncat(buffer, " ", strlen(" ")); | 2439 | strncat(buffer, " ", strlen(" ")); |
2437 | } else { | 2440 | } else { |
2438 | strncat(buffer, text1, strlen(text1)); | 2441 | strncat(buffer, text1, strlen(text1)); |
2439 | } | 2442 | } |
2440 | /* Use 255 as the marker. \n is too tough to test for */ | 2443 | /* Use 255 as the marker. \n is too tough to test for */ |
2441 | buffer[strlen (buffer)] = 255; | 2444 | buffer[strlen (buffer)] = 255; |
2442 | } /*for (count2 = 0; count2 < 5; count2++)*/ | 2445 | } /*for (count2 = 0; count2 < 5; count2++)*/ |
2443 | count2 = 0; | 2446 | count2 = 0; |
2444 | /* I'm using CBC mode and encrypting the data straight from top down. | 2447 | /* I'm using CBC mode and encrypting the data straight from top down. |
2445 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. | 2448 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. |
2446 | * PKCS 5 padding (explained at the code section | 2449 | * PKCS 5 padding (explained at the code section |
2447 | */ | 2450 | */ |
2448 | while (count2 < (int)strlen (buffer)) { | 2451 | while (count2 < (int)strlen (buffer)) { |
2449 | #ifndef WORDS_BIGENDIAN | 2452 | #ifndef WORDS_BIGENDIAN |
2450 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; | 2453 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; |
2451 | plaintext[bufferIndex] += buffer[count2] & 0xff; | 2454 | plaintext[bufferIndex] += buffer[count2] & 0xff; |
2452 | #endif | 2455 | #endif |
2453 | #ifdef WORDS_BIGENDIAN | 2456 | #ifdef WORDS_BIGENDIAN |
2454 | plaintext[bufferIndex] = buffer[count2] << 8; | 2457 | plaintext[bufferIndex] = buffer[count2] << 8; |
2455 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; | 2458 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; |
2456 | #endif | 2459 | #endif |
2457 | bufferIndex++; | 2460 | bufferIndex++; |
2458 | if (bufferIndex == 4) { | 2461 | if (bufferIndex == 4) { |
2459 | krc2->rc2_encrypt (plaintext); | 2462 | krc2->rc2_encrypt (plaintext); |
2460 | 2463 | ||
2461 | for (count3 = 0; count3 < 4; count3++) { | 2464 | for (count3 = 0; count3 < 4; count3++) { |
2462 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; | 2465 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; |
2463 | 2466 | ||
2464 | /* Now store the ciphertext as the iv */ | 2467 | /* Now store the ciphertext as the iv */ |
2465 | iv[count3] = plaintext[count3]; | 2468 | iv[count3] = plaintext[count3]; |
2466 | 2469 | ||
2467 | /* reset the buffer index */ | 2470 | /* reset the buffer index */ |
2468 | bufferIndex = 0; | 2471 | bufferIndex = 0; |
2469 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; | 2472 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; |
2470 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; | 2473 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; |
2471 | } /*for (count3 = 0; count3 < 5; count3++)*/ | 2474 | } /*for (count3 = 0; count3 < 5; count3++)*/ |
2472 | } /*if (bufferIndex == 5)*/ | 2475 | } /*if (bufferIndex == 5)*/ |
2473 | /* increment a short, not a byte */ | 2476 | /* increment a short, not a byte */ |
2474 | count2 += 2; | 2477 | count2 += 2; |
2475 | } /*while (count2 < strlen (buffer))*/ | 2478 | } /*while (count2 < strlen (buffer))*/ |
2476 | int ret = PWERR_GOOD; | 2479 | int ret = PWERR_GOOD; |
2477 | return ret; | 2480 | return ret; |
2478 | } | 2481 | } |
@@ -2481,30 +2484,30 @@ int ZSafe::saveFinalize(void) | |||
2481 | { | 2484 | { |
2482 | int count1, retval = PWERR_GOOD; | 2485 | int count1, retval = PWERR_GOOD; |
2483 | unsigned short ciphertext[4]; | 2486 | unsigned short ciphertext[4]; |
2484 | Krc2* krc2 = new Krc2(); | 2487 | Krc2* krc2 = new Krc2(); |
2485 | 2488 | ||
2486 | /* Tack on the PKCS 5 padding | 2489 | /* Tack on the PKCS 5 padding |
2487 | * How it works is we fill up the last n bytes with the value n | 2490 | * How it works is we fill up the last n bytes with the value n |
2488 | * | 2491 | * |
2489 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left | 2492 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left |
2490 | * over, leaving us 3 short, so we fill it in with 3's. | 2493 | * over, leaving us 3 short, so we fill it in with 3's. |
2491 | * | 2494 | * |
2492 | * If we come out even, we fill it with 8 8s | 2495 | * If we come out even, we fill it with 8 8s |
2493 | * | 2496 | * |
2494 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. | 2497 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. |
2495 | * so, half everything | 2498 | * so, half everything |
2496 | */ | 2499 | */ |
2497 | for (count1 = bufferIndex; count1 < 4; count1++) { | 2500 | for (count1 = bufferIndex; count1 < 4; count1++) { |
2498 | plaintext[count1] = (4 - bufferIndex); | 2501 | plaintext[count1] = (4 - bufferIndex); |
2499 | } | 2502 | } |
2500 | krc2->rc2_encrypt (plaintext); | 2503 | krc2->rc2_encrypt (plaintext); |
2501 | for (count1 = 0; count1 < 4; count1++) { | 2504 | for (count1 = 0; count1 < 4; count1++) { |
2502 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; | 2505 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; |
2503 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; | 2506 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; |
2504 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; | 2507 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; |
2505 | } | 2508 | } |
2506 | 2509 | ||
2507 | fclose (fd); | 2510 | fclose (fd); |
2508 | free(buffer); | 2511 | free(buffer); |
2509 | return retval; | 2512 | return retval; |
2510 | } | 2513 | } |
@@ -2519,7 +2522,7 @@ void ZSafe::quitMe () | |||
2519 | tr("Do you want to save\nbefore exiting?"), | 2522 | tr("Do you want to save\nbefore exiting?"), |
2520 | tr("&Save"), | 2523 | tr("&Save"), |
2521 | tr("S&ave with\nnew\npassword"), | 2524 | tr("S&ave with\nnew\npassword"), |
2522 | tr("&Don't Save"), | 2525 | tr("&Don't Save"), |
2523 | 0 // Enter == button 0 | 2526 | 0 // Enter == button 0 |
2524 | ) ) | 2527 | ) ) |
2525 | { // Escape == button 2 | 2528 | { // Escape == button 2 |
@@ -2531,3 +2534,3 @@ void ZSafe::quitMe () | |||
2531 | break; | 2534 | break; |
2532 | case 1: // | 2535 | case 1: // |
2533 | // Save with new password | 2536 | // Save with new password |
@@ -2578,3 +2581,3 @@ void ZSafe::addCategory() | |||
2578 | dialog = categoryDialog; | 2581 | dialog = categoryDialog; |
2579 | connect( dialog->CategoryField, | 2582 | connect( dialog->CategoryField, |
2580 | SIGNAL( activated ( const QString &)), | 2583 | SIGNAL( activated ( const QString &)), |
@@ -2603,3 +2606,3 @@ void ZSafe::addCategory() | |||
2603 | #endif | 2606 | #endif |
2604 | #else | 2607 | #else |
2605 | // read all categories from the config file and store | 2608 | // read all categories from the config file and store |
@@ -2622,3 +2625,3 @@ void ZSafe::addCategory() | |||
2622 | dialog->CategoryField->clear(); // remove all items | 2625 | dialog->CategoryField->clear(); // remove all items |
2623 | while( it != list.end() ) | 2626 | while( it != list.end() ) |
2624 | { | 2627 | { |
@@ -2626,3 +2629,3 @@ void ZSafe::addCategory() | |||
2626 | if (cat->contains("-field1", FALSE)) | 2629 | if (cat->contains("-field1", FALSE)) |
2627 | { | 2630 | { |
2628 | #ifdef DESKTOP | 2631 | #ifdef DESKTOP |
@@ -2632,3 +2635,3 @@ void ZSafe::addCategory() | |||
2632 | int pos = cat->find ("-field1"); | 2635 | int pos = cat->find ("-field1"); |
2633 | categ = cat->left (pos); | 2636 | categ = cat->left (pos); |
2634 | #endif | 2637 | #endif |
@@ -2659,39 +2662,39 @@ void ZSafe::addCategory() | |||
2659 | { | 2662 | { |
2660 | Wait waitDialog(this, tr("Wait dialog")); | 2663 | Wait waitDialog(this, tr("Wait dialog")); |
2661 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2664 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
2662 | waitDialog.show(); | 2665 | waitDialog.show(); |
2663 | qApp->processEvents(); | 2666 | qApp->processEvents(); |
2664 | 2667 | ||
2665 | #ifdef DESKTOP | 2668 | #ifdef DESKTOP |
2666 | QDir d(iconPath); | 2669 | QDir d(iconPath); |
2667 | #else | 2670 | #else |
2668 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2671 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2669 | #endif | 2672 | #endif |
2670 | d.setFilter( QDir::Files); | 2673 | d.setFilter( QDir::Files); |
2671 | 2674 | ||
2672 | const QFileInfoList *list = d.entryInfoList(); | 2675 | const QFileInfoList *list = d.entryInfoList(); |
2673 | QFileInfoListIterator it( *list ); // create list iterator | 2676 | QFileInfoListIterator it( *list ); // create list iterator |
2674 | QFileInfo *fi; // pointer for traversing | 2677 | QFileInfo *fi; // pointer for traversing |
2675 | 2678 | ||
2676 | dialog->IconField->insertItem("predefined"); | 2679 | dialog->IconField->insertItem("predefined"); |
2677 | while ( (fi=it.current()) ) { // for each file... | 2680 | while ( (fi=it.current()) ) { // for each file... |
2678 | QString fileName = fi->fileName(); | 2681 | QString fileName = fi->fileName(); |
2679 | if(fileName.right(4) == ".png"){ | 2682 | if(fileName.right(4) == ".png"){ |
2680 | fileName = fileName.mid(0,fileName.length()-4); | 2683 | fileName = fileName.mid(0,fileName.length()-4); |
2681 | #ifdef DESKTOP | 2684 | #ifdef DESKTOP |
2682 | QPixmap imageOfFile; | 2685 | QPixmap imageOfFile; |
2683 | imageOfFile.load(iconPath + fi->fileName()); | 2686 | imageOfFile.load(iconPath + fi->fileName()); |
2684 | #else | 2687 | #else |
2685 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2688 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
2686 | #endif | 2689 | #endif |
2687 | QImage foo = imageOfFile.convertToImage(); | 2690 | QImage foo = imageOfFile.convertToImage(); |
2688 | foo = foo.smoothScale(16,16); | 2691 | foo = foo.smoothScale(16,16); |
2689 | imageOfFile.convertFromImage(foo); | 2692 | imageOfFile.convertFromImage(foo); |
2690 | dialog->IconField->insertItem(imageOfFile,fileName); | 2693 | dialog->IconField->insertItem(imageOfFile,fileName); |
2691 | } | 2694 | } |
2692 | ++it; | 2695 | ++it; |
2693 | } | 2696 | } |
2694 | waitDialog.hide(); | 2697 | waitDialog.hide(); |
2695 | } | 2698 | } |
2696 | 2699 | ||
2697 | #ifndef WIN32 | 2700 | #ifndef WIN32 |
@@ -2729,3 +2732,3 @@ void ZSafe::addCategory() | |||
2729 | pix = new QPixmap (fullIconPath); | 2732 | pix = new QPixmap (fullIconPath); |
2730 | // pix->resize(14, 14); | 2733 | // pix->resize(14, 14); |
2731 | if (pix) | 2734 | if (pix) |
@@ -2778,3 +2781,3 @@ void ZSafe::delCategory() | |||
2778 | tr("Do you want to delete?"), | 2781 | tr("Do you want to delete?"), |
2779 | tr("&Delete"), tr("D&on't Delete"), | 2782 | tr("&Delete"), tr("D&on't Delete"), |
2780 | 0 // Enter == button 0 | 2783 | 0 // Enter == button 0 |
@@ -2819,3 +2822,3 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | |||
2819 | QString icon; | 2822 | QString icon; |
2820 | if (selectedItem) | 2823 | if (selectedItem) |
2821 | { | 2824 | { |
@@ -2847,12 +2850,12 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | |||
2847 | #ifdef DESKTOP | 2850 | #ifdef DESKTOP |
2848 | QDir d(iconPath); | 2851 | QDir d(iconPath); |
2849 | #else | 2852 | #else |
2850 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2853 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2851 | #endif | 2854 | #endif |
2852 | d.setFilter( QDir::Files); | 2855 | d.setFilter( QDir::Files); |
2853 | 2856 | ||
2854 | const QFileInfoList *list = d.entryInfoList(); | 2857 | const QFileInfoList *list = d.entryInfoList(); |
2855 | int i=0; | 2858 | int i=0; |
2856 | QFileInfoListIterator it( *list ); // create list iterator | 2859 | QFileInfoListIterator it( *list ); // create list iterator |
2857 | QFileInfo *fi; // pointer for traversing | 2860 | QFileInfo *fi; // pointer for traversing |
2858 | if (icon.isEmpty() || icon.isNull()) | 2861 | if (icon.isEmpty() || icon.isNull()) |
@@ -2863,10 +2866,10 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | |||
2863 | { | 2866 | { |
2864 | while ( (fi=it.current()) ) | 2867 | while ( (fi=it.current()) ) |
2865 | { // for each file... | 2868 | { // for each file... |
2866 | QString fileName = fi->fileName(); | 2869 | QString fileName = fi->fileName(); |
2867 | if(fileName.right(4) == ".png") | 2870 | if(fileName.right(4) == ".png") |
2868 | { | 2871 | { |
2869 | fileName = fileName.mid(0,fileName.length()-4); | 2872 | fileName = fileName.mid(0,fileName.length()-4); |
2870 | 2873 | ||
2871 | if(fileName+".png"==icon) | 2874 | if(fileName+".png"==icon) |
2872 | { | 2875 | { |
@@ -2875,7 +2878,7 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | |||
2875 | } | 2878 | } |
2876 | ++i; | 2879 | ++i; |
2877 | } | 2880 | } |
2878 | ++it; | 2881 | ++it; |
2879 | } | 2882 | } |
2880 | } | 2883 | } |
2881 | } | 2884 | } |
@@ -2904,12 +2907,12 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | |||
2904 | #ifdef DESKTOP | 2907 | #ifdef DESKTOP |
2905 | QDir d(iconPath); | 2908 | QDir d(iconPath); |
2906 | #else | 2909 | #else |
2907 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2910 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2908 | #endif | 2911 | #endif |
2909 | d.setFilter( QDir::Files); | 2912 | d.setFilter( QDir::Files); |
2910 | 2913 | ||
2911 | const QFileInfoList *list = d.entryInfoList(); | 2914 | const QFileInfoList *list = d.entryInfoList(); |
2912 | int i=0; | 2915 | int i=0; |
2913 | QFileInfoListIterator it( *list ); // create list iterator | 2916 | QFileInfoListIterator it( *list ); // create list iterator |
2914 | QFileInfo *fi; // pointer for traversing | 2917 | QFileInfo *fi; // pointer for traversing |
2915 | if (icon.isEmpty() || icon.isNull()) | 2918 | if (icon.isEmpty() || icon.isNull()) |
@@ -2920,10 +2923,10 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | |||
2920 | { | 2923 | { |
2921 | while ( (fi=it.current()) ) | 2924 | while ( (fi=it.current()) ) |
2922 | { // for each file... | 2925 | { // for each file... |
2923 | QString fileName = fi->fileName(); | 2926 | QString fileName = fi->fileName(); |
2924 | if(fileName.right(4) == ".png") | 2927 | if(fileName.right(4) == ".png") |
2925 | { | 2928 | { |
2926 | fileName = fileName.mid(0,fileName.length()-4); | 2929 | fileName = fileName.mid(0,fileName.length()-4); |
2927 | 2930 | ||
2928 | if(fileName+".png"==icon) | 2931 | if(fileName+".png"==icon) |
2929 | { | 2932 | { |
@@ -2932,7 +2935,7 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | |||
2932 | } | 2935 | } |
2933 | ++i; | 2936 | ++i; |
2934 | } | 2937 | } |
2935 | ++it; | 2938 | ++it; |
2936 | } | 2939 | } |
2937 | } | 2940 | } |
2938 | } | 2941 | } |
@@ -2985,3 +2988,3 @@ void ZSafe::editCategory() | |||
2985 | dialog = categoryDialog; | 2988 | dialog = categoryDialog; |
2986 | connect( dialog->CategoryField, | 2989 | connect( dialog->CategoryField, |
2987 | SIGNAL( activated ( const QString &)), | 2990 | SIGNAL( activated ( const QString &)), |
@@ -3031,3 +3034,3 @@ void ZSafe::editCategory() | |||
3031 | bool foundCategory = false; | 3034 | bool foundCategory = false; |
3032 | while( it != list.end() ) | 3035 | while( it != list.end() ) |
3033 | { | 3036 | { |
@@ -3035,3 +3038,3 @@ void ZSafe::editCategory() | |||
3035 | if (cat->contains("-field1", FALSE)) | 3038 | if (cat->contains("-field1", FALSE)) |
3036 | { | 3039 | { |
3037 | #ifdef DESKTOP | 3040 | #ifdef DESKTOP |
@@ -3040,4 +3043,4 @@ void ZSafe::editCategory() | |||
3040 | #else | 3043 | #else |
3041 | int pos = cat->find ("-field1"); | 3044 | int pos = cat->find ("-field1"); |
3042 | categ = cat->left (pos); | 3045 | categ = cat->left (pos); |
3043 | #endif | 3046 | #endif |
@@ -3077,18 +3080,18 @@ void ZSafe::editCategory() | |||
3077 | 3080 | ||
3078 | Wait waitDialog(this, tr("Wait dialog")); | 3081 | Wait waitDialog(this, tr("Wait dialog")); |
3079 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 3082 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
3080 | waitDialog.show(); | 3083 | waitDialog.show(); |
3081 | qApp->processEvents(); | 3084 | qApp->processEvents(); |
3082 | 3085 | ||
3083 | #ifdef DESKTOP | 3086 | #ifdef DESKTOP |
3084 | QDir d(iconPath); | 3087 | QDir d(iconPath); |
3085 | #else | 3088 | #else |
3086 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3089 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
3087 | #endif | 3090 | #endif |
3088 | d.setFilter( QDir::Files); | 3091 | d.setFilter( QDir::Files); |
3089 | 3092 | ||
3090 | const QFileInfoList *list = d.entryInfoList(); | 3093 | const QFileInfoList *list = d.entryInfoList(); |
3091 | int i=0; | 3094 | int i=0; |
3092 | QFileInfoListIterator it( *list ); // create list iterator | 3095 | QFileInfoListIterator it( *list ); // create list iterator |
3093 | QFileInfo *fi; // pointer for traversing | 3096 | QFileInfo *fi; // pointer for traversing |
3094 | if (icon.isEmpty() || icon.isNull()) | 3097 | if (icon.isEmpty() || icon.isNull()) |
@@ -3098,25 +3101,25 @@ void ZSafe::editCategory() | |||
3098 | 3101 | ||
3099 | dialog->IconField->insertItem("predefined"); | 3102 | dialog->IconField->insertItem("predefined"); |
3100 | while ( (fi=it.current()) ) { // for each file... | 3103 | while ( (fi=it.current()) ) { // for each file... |
3101 | QString fileName = fi->fileName(); | 3104 | QString fileName = fi->fileName(); |
3102 | if(fileName.right(4) == ".png") | 3105 | if(fileName.right(4) == ".png") |
3103 | { | 3106 | { |
3104 | fileName = fileName.mid(0,fileName.length()-4); | 3107 | fileName = fileName.mid(0,fileName.length()-4); |
3105 | #ifdef DESKTOP | 3108 | #ifdef DESKTOP |
3106 | QPixmap imageOfFile; | 3109 | QPixmap imageOfFile; |
3107 | imageOfFile.load(iconPath + fi->fileName()); | 3110 | imageOfFile.load(iconPath + fi->fileName()); |
3108 | #else | 3111 | #else |
3109 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 3112 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
3110 | #endif | 3113 | #endif |
3111 | QImage foo = imageOfFile.convertToImage(); | 3114 | QImage foo = imageOfFile.convertToImage(); |
3112 | foo = foo.smoothScale(16,16); | 3115 | foo = foo.smoothScale(16,16); |
3113 | imageOfFile.convertFromImage(foo); | 3116 | imageOfFile.convertFromImage(foo); |
3114 | dialog->IconField->insertItem(imageOfFile,fileName); | 3117 | dialog->IconField->insertItem(imageOfFile,fileName); |
3115 | if(fileName+".png"==icon) | 3118 | if(fileName+".png"==icon) |
3116 | dialog->IconField->setCurrentItem(i+1); | 3119 | dialog->IconField->setCurrentItem(i+1); |
3117 | ++i; | 3120 | ++i; |
3118 | } | 3121 | } |
3119 | ++it; | 3122 | ++it; |
3120 | } | 3123 | } |
3121 | waitDialog.hide(); | 3124 | waitDialog.hide(); |
3122 | } | 3125 | } |
@@ -3125,13 +3128,13 @@ void ZSafe::editCategory() | |||
3125 | #ifdef DESKTOP | 3128 | #ifdef DESKTOP |
3126 | // QDir d(QDir::homeDirPath() + "/pics/"); | 3129 | // QDir d(QDir::homeDirPath() + "/pics/"); |
3127 | QDir d(iconPath); | 3130 | QDir d(iconPath); |
3128 | #else | 3131 | #else |
3129 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3132 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
3130 | #endif | 3133 | #endif |
3131 | d.setFilter( QDir::Files); | 3134 | d.setFilter( QDir::Files); |
3132 | 3135 | ||
3133 | const QFileInfoList *list = d.entryInfoList(); | 3136 | const QFileInfoList *list = d.entryInfoList(); |
3134 | int i=0; | 3137 | int i=0; |
3135 | QFileInfoListIterator it( *list ); // create list iterator | 3138 | QFileInfoListIterator it( *list ); // create list iterator |
3136 | QFileInfo *fi; // pointer for traversing | 3139 | QFileInfo *fi; // pointer for traversing |
3137 | if (icon.isEmpty() || icon.isNull()) | 3140 | if (icon.isEmpty() || icon.isNull()) |
@@ -3143,11 +3146,11 @@ void ZSafe::editCategory() | |||
3143 | 3146 | ||
3144 | while ( (fi=it.current()) ) | 3147 | while ( (fi=it.current()) ) |
3145 | { // for each file... | 3148 | { // for each file... |
3146 | QString fileName = fi->fileName(); | 3149 | QString fileName = fi->fileName(); |
3147 | if(fileName.right(4) == ".png") | 3150 | if(fileName.right(4) == ".png") |
3148 | { | 3151 | { |
3149 | fileName = fileName.mid(0,fileName.length()-4); | 3152 | fileName = fileName.mid(0,fileName.length()-4); |
3150 | 3153 | ||
3151 | 3154 | ||
3152 | if(fileName+".png"==icon) | 3155 | if(fileName+".png"==icon) |
3153 | { | 3156 | { |
@@ -3156,7 +3159,7 @@ void ZSafe::editCategory() | |||
3156 | } | 3159 | } |
3157 | ++i; | 3160 | ++i; |
3158 | } | 3161 | } |
3159 | ++it; | 3162 | ++it; |
3160 | } | 3163 | } |
3161 | } | 3164 | } |
3162 | } | 3165 | } |
@@ -3332,3 +3335,3 @@ void ZSafe::newDocument() | |||
3332 | #else | 3335 | #else |
3333 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3336 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3334 | tr ("Create new ZSafe document"), | 3337 | tr ("Create new ZSafe document"), |
@@ -3339,3 +3342,3 @@ void ZSafe::newDocument() | |||
3339 | QString newFile = QFileDialog::getSaveFileName( | 3342 | QString newFile = QFileDialog::getSaveFileName( |
3340 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3343 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3341 | "ZSafe (*.zsf)", | 3344 | "ZSafe (*.zsf)", |
@@ -3397,3 +3400,3 @@ void ZSafe::newDocument() | |||
3397 | 3400 | ||
3398 | QMessageBox::information( this, tr("ZSafe"), | 3401 | QMessageBox::information( this, tr("ZSafe"), |
3399 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3402 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
@@ -3420,3 +3423,3 @@ void ZSafe::loadDocument() | |||
3420 | #else | 3423 | #else |
3421 | QString newFile = ScQtFileEdit::getOpenFileName(this, | 3424 | QString newFile = ScQtFileEdit::getOpenFileName(this, |
3422 | tr ("Open ZSafe document"), | 3425 | tr ("Open ZSafe document"), |
@@ -3427,3 +3430,3 @@ void ZSafe::loadDocument() | |||
3427 | QString newFile = QFileDialog::getOpenFileName( | 3430 | QString newFile = QFileDialog::getOpenFileName( |
3428 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3431 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3429 | "ZSafe (*.zsf)", | 3432 | "ZSafe (*.zsf)", |
@@ -3498,3 +3501,3 @@ void ZSafe::saveDocumentAs() | |||
3498 | #else | 3501 | #else |
3499 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3502 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3500 | tr ("Save ZSafe document as.."), | 3503 | tr ("Save ZSafe document as.."), |
@@ -3506,3 +3509,3 @@ void ZSafe::saveDocumentAs() | |||
3506 | QString newFile = QFileDialog::getSaveFileName( | 3509 | QString newFile = QFileDialog::getSaveFileName( |
3507 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3510 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3508 | "ZSafe (*.zsf)", | 3511 | "ZSafe (*.zsf)", |
@@ -3533,3 +3536,3 @@ void ZSafe::saveDocumentAs() | |||
3533 | 3536 | ||
3534 | QMessageBox::information( this, tr("ZSafe"), | 3537 | QMessageBox::information( this, tr("ZSafe"), |
3535 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3538 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
@@ -3624,3 +3627,3 @@ void ZSafe::paintEvent( QPaintEvent * ) | |||
3624 | 3627 | ||
3625 | void ZSafe::resizeEvent ( QResizeEvent * ) | 3628 | void ZSafe::resizeEvent ( QResizeEvent * ) |
3626 | { | 3629 | { |
@@ -3636,9 +3639,9 @@ void ZSafe::resizeEvent ( QResizeEvent * ) | |||
3636 | if (New) | 3639 | if (New) |
3637 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); | 3640 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); |
3638 | if (Edit) | 3641 | if (Edit) |
3639 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); | 3642 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); |
3640 | if (Delete) | 3643 | if (Delete) |
3641 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 3644 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
3642 | if (Find) | 3645 | if (Find) |
3643 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); | 3646 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); |
3644 | } | 3647 | } |
@@ -3724,3 +3727,3 @@ void ZSafe::setDocument(const QString& fileref) | |||
3724 | selectedItem = NULL; | 3727 | selectedItem = NULL; |
3725 | 3728 | ||
3726 | openDocument(filename); | 3729 | openDocument(filename); |