Diffstat (limited to 'noncore/apps/zsafe/zsafe.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 6ff05ac..ca3ff52 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -872,25 +872,25 @@ void ZSafe::findPwd() | |||
872 | #ifdef DESKTOP | 872 | #ifdef DESKTOP |
873 | result = Accepted; | 873 | result = Accepted; |
874 | #endif | 874 | #endif |
875 | 875 | ||
876 | QString name; | 876 | QString name; |
877 | QString username; | 877 | QString username; |
878 | QString comment; | 878 | QString comment; |
879 | if (result == Accepted) | 879 | if (result == Accepted) |
880 | { | 880 | { |
881 | name = dialog->NameField->text(); | 881 | name = dialog->NameField->text(); |
882 | username = dialog->UsernameField->text(); | 882 | username = dialog->UsernameField->text(); |
883 | comment = dialog->CommentField->text(); | 883 | comment = dialog->CommentField->text(); |
884 | qWarning (name); | 884 | owarn << name << oendl; |
885 | } | 885 | } |
886 | else | 886 | else |
887 | { | 887 | { |
888 | delete dialog; | 888 | delete dialog; |
889 | return; | 889 | return; |
890 | } | 890 | } |
891 | 891 | ||
892 | if (!name.isEmpty() && name != lastSearchedName || | 892 | if (!name.isEmpty() && name != lastSearchedName || |
893 | lastSearchedName.isEmpty() && !name.isEmpty()) | 893 | lastSearchedName.isEmpty() && !name.isEmpty()) |
894 | { | 894 | { |
895 | // set search at the beginning if a new name is given | 895 | // set search at the beginning if a new name is given |
896 | lastSearchedCategory = NULL; | 896 | lastSearchedCategory = NULL; |
@@ -918,56 +918,56 @@ void ZSafe::findPwd() | |||
918 | 918 | ||
919 | bool found=FALSE; | 919 | bool found=FALSE; |
920 | // step through all categories | 920 | // step through all categories |
921 | QListViewItem *i; | 921 | QListViewItem *i; |
922 | if (lastSearchedCategory) | 922 | if (lastSearchedCategory) |
923 | i = lastSearchedCategory; | 923 | i = lastSearchedCategory; |
924 | else | 924 | else |
925 | i = ListView->firstChild(); | 925 | i = ListView->firstChild(); |
926 | for (; | 926 | for (; |
927 | i != NULL; | 927 | i != NULL; |
928 | i = i->nextSibling()) | 928 | i = i->nextSibling()) |
929 | { | 929 | { |
930 | qWarning (i->text(0)); | 930 | owarn << i->text(0) << oendl; |
931 | i->setSelected(FALSE); | 931 | i->setSelected(FALSE); |
932 | 932 | ||
933 | // step through all subitems | 933 | // step through all subitems |
934 | QListViewItem *si; | 934 | QListViewItem *si; |
935 | if (lastSearchedItem) | 935 | if (lastSearchedItem) |
936 | si = lastSearchedItem; | 936 | si = lastSearchedItem; |
937 | else | 937 | else |
938 | si = i->firstChild(); | 938 | si = i->firstChild(); |
939 | // for (si = i->firstChild(); | 939 | // for (si = i->firstChild(); |
940 | for (; | 940 | for (; |
941 | si != NULL; | 941 | si != NULL; |
942 | si = si->nextSibling()) | 942 | si = si->nextSibling()) |
943 | { | 943 | { |
944 | qWarning (si->text(0)); | 944 | owarn << si->text(0) << oendl; |
945 | if (si->isSelected()) | 945 | if (si->isSelected()) |
946 | si->setSelected(FALSE); | 946 | si->setSelected(FALSE); |
947 | // ListView->repaintItem(si); | 947 | // ListView->repaintItem(si); |
948 | 948 | ||
949 | bool n=TRUE; | 949 | bool n=TRUE; |
950 | bool u=TRUE; | 950 | bool u=TRUE; |
951 | bool c=TRUE; | 951 | bool c=TRUE; |
952 | if (!name.isEmpty()) | 952 | if (!name.isEmpty()) |
953 | n = (si->text(0)).contains (name, FALSE); | 953 | n = (si->text(0)).contains (name, FALSE); |
954 | if (!username.isEmpty()) | 954 | if (!username.isEmpty()) |
955 | u = (si->text(1)).contains (username, FALSE); | 955 | u = (si->text(1)).contains (username, FALSE); |
956 | if (!comment.isEmpty()) | 956 | if (!comment.isEmpty()) |
957 | c = (si->text(3)).contains (comment, FALSE); | 957 | c = (si->text(3)).contains (comment, FALSE); |
958 | 958 | ||
959 | if ((n && u && c ) && !found) | 959 | if ((n && u && c ) && !found) |
960 | { | 960 | { |
961 | qWarning ("Found"); | 961 | owarn << "Found" << oendl; |
962 | selectedItem = si; | 962 | selectedItem = si; |
963 | si->setSelected(TRUE); | 963 | si->setSelected(TRUE); |
964 | ListView->setCurrentItem(si); | 964 | ListView->setCurrentItem(si); |
965 | ListView->ensureItemVisible(si); | 965 | ListView->ensureItemVisible(si); |
966 | ListView->triggerUpdate(); | 966 | ListView->triggerUpdate(); |
967 | 967 | ||
968 | lastSearchedCategory = i; | 968 | lastSearchedCategory = i; |
969 | // set to the next item | 969 | // set to the next item |
970 | lastSearchedItem = si->nextSibling(); | 970 | lastSearchedItem = si->nextSibling(); |
971 | if (!lastSearchedItem) | 971 | if (!lastSearchedItem) |
972 | { | 972 | { |
973 | // no next item within category -> set next category | 973 | // no next item within category -> set next category |
@@ -1219,26 +1219,25 @@ void ZSafe::removeAsciiFile() | |||
1219 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1219 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1220 | "ZSafe (*.txt)", | 1220 | "ZSafe (*.txt)", |
1221 | this, | 1221 | this, |
1222 | "ZSafe File Dialog" | 1222 | "ZSafe File Dialog" |
1223 | "Choose a text file" ); | 1223 | "Choose a text file" ); |
1224 | #endif | 1224 | #endif |
1225 | 1225 | ||
1226 | if (fn && fn.length() > 0 ) | 1226 | if (fn && fn.length() > 0 ) |
1227 | { | 1227 | { |
1228 | QFile f( fn ); | 1228 | QFile f( fn ); |
1229 | if ( !f.remove() ) | 1229 | if ( !f.remove() ) |
1230 | { | 1230 | { |
1231 | qWarning( QString("Could not remove file %1").arg(fn), | 1231 | owarn << "Could not remove file " << fn << oendl; |
1232 | 2000 ); | ||
1233 | QMessageBox::critical( 0, tr("ZSafe"), | 1232 | QMessageBox::critical( 0, tr("ZSafe"), |
1234 | tr("Could not remove text file.") ); | 1233 | tr("Could not remove text file.") ); |
1235 | return; | 1234 | return; |
1236 | } | 1235 | } |
1237 | } | 1236 | } |
1238 | } | 1237 | } |
1239 | 1238 | ||
1240 | void ZSafe::writeAllEntries() | 1239 | void ZSafe::writeAllEntries() |
1241 | { | 1240 | { |
1242 | if (filename.isEmpty()) | 1241 | if (filename.isEmpty()) |
1243 | { | 1242 | { |
1244 | QMessageBox::critical( 0, tr("ZSafe"), | 1243 | QMessageBox::critical( 0, tr("ZSafe"), |
@@ -1269,26 +1268,25 @@ void ZSafe::writeAllEntries() | |||
1269 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1268 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1270 | "ZSafe (*.txt)", | 1269 | "ZSafe (*.txt)", |
1271 | this, | 1270 | this, |
1272 | "ZSafe File Dialog" | 1271 | "ZSafe File Dialog" |
1273 | "Choose a text file" ); | 1272 | "Choose a text file" ); |
1274 | #endif | 1273 | #endif |
1275 | 1274 | ||
1276 | // open the new document | 1275 | // open the new document |
1277 | if (fn && fn.length() > 0 ) | 1276 | if (fn && fn.length() > 0 ) |
1278 | { | 1277 | { |
1279 | QFile f( fn ); | 1278 | QFile f( fn ); |
1280 | if ( !f.open( IO_WriteOnly ) ) { | 1279 | if ( !f.open( IO_WriteOnly ) ) { |
1281 | qWarning( QString("Could not write to file %1").arg(fn), | 1280 | owarn << "Could not write to file " << fn << oendl; |
1282 | 2000 ); | ||
1283 | QMessageBox::critical( 0, "ZSafe", | 1281 | QMessageBox::critical( 0, "ZSafe", |
1284 | QString("Could not export to text file.") ); | 1282 | QString("Could not export to text file.") ); |
1285 | return; | 1283 | return; |
1286 | } | 1284 | } |
1287 | QTextStream t( &f ); | 1285 | QTextStream t( &f ); |
1288 | 1286 | ||
1289 | QListViewItem *i; | 1287 | QListViewItem *i; |
1290 | // step through all categories | 1288 | // step through all categories |
1291 | for (i = ListView->firstChild(); | 1289 | for (i = ListView->firstChild(); |
1292 | i != NULL; | 1290 | i != NULL; |
1293 | i = i->nextSibling()) | 1291 | i = i->nextSibling()) |
1294 | { | 1292 | { |
@@ -1313,28 +1311,28 @@ void ZSafe::writeAllEntries() | |||
1313 | oneEntry += "\";"; | 1311 | oneEntry += "\";"; |
1314 | oneEntry += "\""; | 1312 | oneEntry += "\""; |
1315 | QString comment = si->text(3); | 1313 | QString comment = si->text(3); |
1316 | comment.replace (QRegExp("\n"), "<br>"); | 1314 | comment.replace (QRegExp("\n"), "<br>"); |
1317 | oneEntry += comment; | 1315 | oneEntry += comment; |
1318 | oneEntry += "\";"; | 1316 | oneEntry += "\";"; |
1319 | oneEntry += "\""; | 1317 | oneEntry += "\""; |
1320 | oneEntry += si->text(4); | 1318 | oneEntry += si->text(4); |
1321 | oneEntry += "\";"; | 1319 | oneEntry += "\";"; |
1322 | oneEntry += "\""; | 1320 | oneEntry += "\""; |
1323 | oneEntry += si->text(5); | 1321 | oneEntry += si->text(5); |
1324 | oneEntry += "\""; | 1322 | oneEntry += "\""; |
1325 | // qWarning (oneEntry); | 1323 | // owarn << oneEntry << oendl; |
1326 | t << oneEntry << endl; | 1324 | t << oneEntry << endl; |
1327 | 1325 | ||
1328 | // qWarning (si->text(0)); | 1326 | // owarn << si->text(0) << oendl; |
1329 | } | 1327 | } |
1330 | } | 1328 | } |
1331 | f.close(); | 1329 | f.close(); |
1332 | } | 1330 | } |
1333 | } | 1331 | } |
1334 | 1332 | ||
1335 | void ZSafe::readAllEntries() | 1333 | void ZSafe::readAllEntries() |
1336 | { | 1334 | { |
1337 | if (filename.isEmpty()) | 1335 | if (filename.isEmpty()) |
1338 | { | 1336 | { |
1339 | QMessageBox::critical( 0, tr("ZSafe"), | 1337 | QMessageBox::critical( 0, tr("ZSafe"), |
1340 | tr("No document defined.\nYou have to create a new document")); | 1338 | tr("No document defined.\nYou have to create a new document")); |
@@ -1364,26 +1362,25 @@ void ZSafe::readAllEntries() | |||
1364 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1362 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1365 | "ZSafe (*.txt)", | 1363 | "ZSafe (*.txt)", |
1366 | this, | 1364 | this, |
1367 | "ZSafe File Dialog" | 1365 | "ZSafe File Dialog" |
1368 | "Choose a text file" ); | 1366 | "Choose a text file" ); |
1369 | #endif | 1367 | #endif |
1370 | 1368 | ||
1371 | if (fn && fn.length() > 0 ) | 1369 | if (fn && fn.length() > 0 ) |
1372 | { | 1370 | { |
1373 | QFile f( fn ); | 1371 | QFile f( fn ); |
1374 | if ( !f.open( IO_ReadOnly ) ) | 1372 | if ( !f.open( IO_ReadOnly ) ) |
1375 | { | 1373 | { |
1376 | qWarning( QString("Could not read file %1").arg(fn), | 1374 | owarn << "Could not read file " << fn << oendl; |
1377 | 2000 ); | ||
1378 | QMessageBox::critical( 0, "ZSafe", | 1375 | QMessageBox::critical( 0, "ZSafe", |
1379 | QString("Could not import text file.") ); | 1376 | QString("Could not import text file.") ); |
1380 | return; | 1377 | return; |
1381 | } | 1378 | } |
1382 | 1379 | ||
1383 | modified = true; | 1380 | modified = true; |
1384 | 1381 | ||
1385 | // clear the password list | 1382 | // clear the password list |
1386 | selectedItem = NULL; | 1383 | selectedItem = NULL; |
1387 | QListViewItem *i; | 1384 | QListViewItem *i; |
1388 | // step through all categories | 1385 | // step through all categories |
1389 | for (i = ListView->firstChild(); | 1386 | for (i = ListView->firstChild(); |
@@ -1394,25 +1391,25 @@ void ZSafe::readAllEntries() | |||
1394 | QListViewItem *si; | 1391 | QListViewItem *si; |
1395 | for (si = i->firstChild(); | 1392 | for (si = i->firstChild(); |
1396 | si != NULL; ) | 1393 | si != NULL; ) |
1397 | // si = si->nextSibling()) | 1394 | // si = si->nextSibling()) |
1398 | { | 1395 | { |
1399 | QListViewItem *_si = si; | 1396 | QListViewItem *_si = si; |
1400 | si = si->nextSibling(); | 1397 | si = si->nextSibling(); |
1401 | i->takeItem(_si); // remove from view list | 1398 | i->takeItem(_si); // remove from view list |
1402 | if (_si) delete _si; | 1399 | if (_si) delete _si; |
1403 | } | 1400 | } |
1404 | } | 1401 | } |
1405 | 1402 | ||
1406 | qWarning ("ReadAllEntries(): "); | 1403 | owarn << "ReadAllEntries(): " << oendl; |
1407 | 1404 | ||
1408 | QTextStream t(&f); | 1405 | QTextStream t(&f); |
1409 | while ( !t.eof() ) | 1406 | while ( !t.eof() ) |
1410 | { | 1407 | { |
1411 | QString s = t.readLine(); | 1408 | QString s = t.readLine(); |
1412 | s.replace (QRegExp("\";\""), "\"|\""); | 1409 | s.replace (QRegExp("\";\""), "\"|\""); |
1413 | // char buffer[1024]; | 1410 | // char buffer[1024]; |
1414 | #ifndef WIN32 | 1411 | #ifndef WIN32 |
1415 | char buffer[s.length()+1]; | 1412 | char buffer[s.length()+1]; |
1416 | #else | 1413 | #else |
1417 | char buffer[4048]; | 1414 | char buffer[4048]; |
1418 | #endif | 1415 | #endif |
@@ -1545,26 +1542,25 @@ void ZSafe::readAllEntries() | |||
1545 | { | 1542 | { |
1546 | } | 1543 | } |
1547 | 1544 | ||
1548 | } | 1545 | } |
1549 | 1546 | ||
1550 | #ifdef UNUSED | 1547 | #ifdef UNUSED |
1551 | void ZSafe::writeAllEntries() | 1548 | void ZSafe::writeAllEntries() |
1552 | { | 1549 | { |
1553 | // open the file for writing | 1550 | // open the file for writing |
1554 | QString fn = filename + ".txt"; | 1551 | QString fn = filename + ".txt"; |
1555 | QFile f( fn ); | 1552 | QFile f( fn ); |
1556 | if ( !f.open( IO_WriteOnly ) ) { | 1553 | if ( !f.open( IO_WriteOnly ) ) { |
1557 | qWarning( QString("Could not write to file %1").arg(fn), | 1554 | owarn << "Could not write to file " << fn << oendl; |
1558 | 2000 ); | ||
1559 | QMessageBox::critical( 0, tr("ZSafe"), | 1555 | QMessageBox::critical( 0, tr("ZSafe"), |
1560 | tr("Could not export to text file.") ); | 1556 | tr("Could not export to text file.") ); |
1561 | return; | 1557 | return; |
1562 | } | 1558 | } |
1563 | QTextStream t( &f ); | 1559 | QTextStream t( &f ); |
1564 | 1560 | ||
1565 | QListViewItem *i; | 1561 | QListViewItem *i; |
1566 | // step through all categories | 1562 | // step through all categories |
1567 | for (i = ListView->firstChild(); | 1563 | for (i = ListView->firstChild(); |
1568 | i != NULL; | 1564 | i != NULL; |
1569 | i = i->nextSibling()) | 1565 | i = i->nextSibling()) |
1570 | { | 1566 | { |
@@ -1584,41 +1580,40 @@ void ZSafe::writeAllEntries() | |||
1584 | oneEntry += "\""; | 1580 | oneEntry += "\""; |
1585 | oneEntry += si->text(1); | 1581 | oneEntry += si->text(1); |
1586 | oneEntry += "\";"; | 1582 | oneEntry += "\";"; |
1587 | oneEntry += "\""; | 1583 | oneEntry += "\""; |
1588 | oneEntry += si->text(2); | 1584 | oneEntry += si->text(2); |
1589 | oneEntry += "\";"; | 1585 | oneEntry += "\";"; |
1590 | oneEntry += "\""; | 1586 | oneEntry += "\""; |
1591 | // oneEntry += si->text(3); | 1587 | // oneEntry += si->text(3); |
1592 | QString comment = si->text(3); | 1588 | QString comment = si->text(3); |
1593 | comment.replace (QRegExp("\n"), "<br>"); | 1589 | comment.replace (QRegExp("\n"), "<br>"); |
1594 | oneEntry += comment; | 1590 | oneEntry += comment; |
1595 | oneEntry += "\""; | 1591 | oneEntry += "\""; |
1596 | // qWarning (oneEntry); | 1592 | // owarn << oneEntry << oendl; |
1597 | t << oneEntry << endl; | 1593 | t << oneEntry << endl; |
1598 | 1594 | ||
1599 | // qWarning (si->text(0)); | 1595 | // owarn << si->text(0) << oendl; |
1600 | } | 1596 | } |
1601 | } | 1597 | } |
1602 | f.close(); | 1598 | f.close(); |
1603 | } | 1599 | } |
1604 | 1600 | ||
1605 | void ZSafe::readAllEntries() | 1601 | void ZSafe::readAllEntries() |
1606 | { | 1602 | { |
1607 | QString fn = filename + ".txt"; | 1603 | QString fn = filename + ".txt"; |
1608 | QFile f( fn ); | 1604 | QFile f( fn ); |
1609 | if ( !f.open( IO_ReadOnly ) ) | 1605 | if ( !f.open( IO_ReadOnly ) ) |
1610 | { | 1606 | { |
1611 | qWarning( QString("Could not read file %1").arg(fn), | 1607 | owarn << "Could not read file " << fn << oendl; |
1612 | 2000 ); | ||
1613 | QMessageBox::critical( 0, tr("ZSafe"), | 1608 | QMessageBox::critical( 0, tr("ZSafe"), |
1614 | tr("Could not import text file.") ); | 1609 | tr("Could not import text file.") ); |
1615 | return; | 1610 | return; |
1616 | } | 1611 | } |
1617 | 1612 | ||
1618 | modified = true; | 1613 | modified = true; |
1619 | 1614 | ||
1620 | // clear the password list | 1615 | // clear the password list |
1621 | selectedItem = NULL; | 1616 | selectedItem = NULL; |
1622 | QListViewItem *i; | 1617 | QListViewItem *i; |
1623 | // step through all categories | 1618 | // step through all categories |
1624 | for (i = ListView->firstChild(); | 1619 | for (i = ListView->firstChild(); |
@@ -1629,25 +1624,25 @@ void ZSafe::readAllEntries() | |||
1629 | QListViewItem *si; | 1624 | QListViewItem *si; |
1630 | for (si = i->firstChild(); | 1625 | for (si = i->firstChild(); |
1631 | si != NULL; ) | 1626 | si != NULL; ) |
1632 | // si = si->nextSibling()) | 1627 | // si = si->nextSibling()) |
1633 | { | 1628 | { |
1634 | QListViewItem *_si = si; | 1629 | QListViewItem *_si = si; |
1635 | si = si->nextSibling(); | 1630 | si = si->nextSibling(); |
1636 | i->takeItem(_si); // remove from view list | 1631 | i->takeItem(_si); // remove from view list |
1637 | if (_si) delete _si; | 1632 | if (_si) delete _si; |
1638 | } | 1633 | } |
1639 | } | 1634 | } |
1640 | 1635 | ||
1641 | qWarning ("ReadAllEntries(): "); | 1636 | owarn << "ReadAllEntries(): " << oendl; |
1642 | 1637 | ||
1643 | QTextStream t(&f); | 1638 | QTextStream t(&f); |
1644 | while ( !t.eof() ) | 1639 | while ( !t.eof() ) |
1645 | { | 1640 | { |
1646 | QString s = t.readLine(); | 1641 | QString s = t.readLine(); |
1647 | s.replace (QRegExp("\";\""), "\"|\""); | 1642 | s.replace (QRegExp("\";\""), "\"|\""); |
1648 | // char buffer[1024]; | 1643 | // char buffer[1024]; |
1649 | int len=s.length()+1; | 1644 | int len=s.length()+1; |
1650 | #ifdef WIN32 | 1645 | #ifdef WIN32 |
1651 | char buffer[512]; | 1646 | char buffer[512]; |
1652 | #else | 1647 | #else |
1653 | char buffer[len]; | 1648 | char buffer[len]; |
@@ -1753,25 +1748,25 @@ void ZSafe::readAllEntries() | |||
1753 | c1->initListItem(); | 1748 | c1->initListItem(); |
1754 | categories.insert (c1->getCategoryName(), c1); | 1749 | categories.insert (c1->getCategoryName(), c1); |
1755 | } | 1750 | } |
1756 | 1751 | ||
1757 | } | 1752 | } |
1758 | f.close(); | 1753 | f.close(); |
1759 | 1754 | ||
1760 | } | 1755 | } |
1761 | #endif // UNUSED | 1756 | #endif // UNUSED |
1762 | 1757 | ||
1763 | void ZSafe::resume(int) | 1758 | void ZSafe::resume(int) |
1764 | { | 1759 | { |
1765 | qWarning ("Resume"); | 1760 | owarn << "Resume" << oendl; |
1766 | // hide the main window | 1761 | // hide the main window |
1767 | 1762 | ||
1768 | infoForm->hide(); | 1763 | infoForm->hide(); |
1769 | // open zsafe again | 1764 | // open zsafe again |
1770 | m_password = ""; | 1765 | m_password = ""; |
1771 | selectedItem = NULL; | 1766 | selectedItem = NULL; |
1772 | 1767 | ||
1773 | // clear the password list | 1768 | // clear the password list |
1774 | QListViewItem *i; | 1769 | QListViewItem *i; |
1775 | // step through all categories | 1770 | // step through all categories |
1776 | for (i = ListView->firstChild(); | 1771 | for (i = ListView->firstChild(); |
1777 | i != NULL; | 1772 | i != NULL; |
@@ -1809,34 +1804,34 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1809 | int pwdOk = 0; | 1804 | int pwdOk = 0; |
1810 | int numberOfTries = 3; | 1805 | int numberOfTries = 3; |
1811 | for (int i=0; i < numberOfTries; i++) | 1806 | for (int i=0; i < numberOfTries; i++) |
1812 | { | 1807 | { |
1813 | QFile f(_filename); | 1808 | QFile f(_filename); |
1814 | if (f.exists()) | 1809 | if (f.exists()) |
1815 | { | 1810 | { |
1816 | // ask with a dialog for the password | 1811 | // ask with a dialog for the password |
1817 | if (m_password.isEmpty()) | 1812 | if (m_password.isEmpty()) |
1818 | getDocPassword(tr("Enter Password")); | 1813 | getDocPassword(tr("Enter Password")); |
1819 | if (m_password.isEmpty() && validationFlag == 0) | 1814 | if (m_password.isEmpty() && validationFlag == 0) |
1820 | { | 1815 | { |
1821 | qWarning ("Wrong password"); | 1816 | owarn << "Wrong password" << oendl; |
1822 | QMessageBox::critical( 0, tr("ZSafe"), | 1817 | QMessageBox::critical( 0, tr("ZSafe"), |
1823 | tr("Wrong password.\n\nZSafe will now exit.") ); | 1818 | tr("Wrong password.\n\nZSafe will now exit.") ); |
1824 | exitZs (1); | 1819 | exitZs (1); |
1825 | } | 1820 | } |
1826 | 1821 | ||
1827 | retval = loadInit(_filename, m_password); | 1822 | retval = loadInit(_filename, m_password); |
1828 | if (retval != PWERR_GOOD) | 1823 | if (retval != PWERR_GOOD) |
1829 | { | 1824 | { |
1830 | qWarning ("Error loading Document"); | 1825 | owarn << "Error loading Document" << oendl; |
1831 | return false; | 1826 | return false; |
1832 | } | 1827 | } |
1833 | } | 1828 | } |
1834 | else | 1829 | else |
1835 | { | 1830 | { |
1836 | #ifdef WIN32 | 1831 | #ifdef WIN32 |
1837 | this->setCaption("Qt ZSafe"); | 1832 | this->setCaption("Qt ZSafe"); |
1838 | #else | 1833 | #else |
1839 | this->setCaption("ZSafe"); | 1834 | this->setCaption("ZSafe"); |
1840 | #endif | 1835 | #endif |
1841 | filename = ""; | 1836 | filename = ""; |
1842 | return false; | 1837 | return false; |
@@ -2292,25 +2287,25 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2292 | } | 2287 | } |
2293 | 2288 | ||
2294 | PasswordForm *newPwdDialog; | 2289 | PasswordForm *newPwdDialog; |
2295 | bool newPwdDialogResult = false; | 2290 | bool newPwdDialogResult = false; |
2296 | void ZSafe::setPasswordDialogDone() | 2291 | void ZSafe::setPasswordDialogDone() |
2297 | { | 2292 | { |
2298 | newPwdDialogResult = true; | 2293 | newPwdDialogResult = true; |
2299 | newPwdDialog->close(); | 2294 | newPwdDialog->close(); |
2300 | } | 2295 | } |
2301 | 2296 | ||
2302 | void ZSafe::getDocPassword(QString title) | 2297 | void ZSafe::getDocPassword(QString title) |
2303 | { | 2298 | { |
2304 | qWarning ("getDocPassword"); | 2299 | owarn << "getDocPassword" << oendl; |
2305 | // open the 'Password' dialog | 2300 | // open the 'Password' dialog |
2306 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); | 2301 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); |
2307 | newPwdDialog = dialog; | 2302 | newPwdDialog = dialog; |
2308 | newPwdDialogResult = false; | 2303 | newPwdDialogResult = false; |
2309 | 2304 | ||
2310 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), | 2305 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), |
2311 | this, SLOT( setPasswordDialogDone() ) ); | 2306 | this, SLOT( setPasswordDialogDone() ) ); |
2312 | 2307 | ||
2313 | // CS: !!! | 2308 | // CS: !!! |
2314 | // int pos = filename.findRev ('/'); | 2309 | // int pos = filename.findRev ('/'); |
2315 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 2310 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
2316 | #ifdef WIN32 | 2311 | #ifdef WIN32 |
@@ -2471,25 +2466,25 @@ int ZSafe::saveFinalize(void) | |||
2471 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; | 2466 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; |
2472 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; | 2467 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; |
2473 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; | 2468 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; |
2474 | } | 2469 | } |
2475 | 2470 | ||
2476 | fclose (fd); | 2471 | fclose (fd); |
2477 | free(buffer); | 2472 | free(buffer); |
2478 | return retval; | 2473 | return retval; |
2479 | } | 2474 | } |
2480 | 2475 | ||
2481 | void ZSafe::quitMe () | 2476 | void ZSafe::quitMe () |
2482 | { | 2477 | { |
2483 | qWarning ("QUIT..."); | 2478 | owarn << "QUIT..." << oendl; |
2484 | 2479 | ||
2485 | if (modified) | 2480 | if (modified) |
2486 | { | 2481 | { |
2487 | switch( QMessageBox::information( this, tr("ZSafe"), | 2482 | switch( QMessageBox::information( this, tr("ZSafe"), |
2488 | tr("Do you want to save\nbefore exiting?"), | 2483 | tr("Do you want to save\nbefore exiting?"), |
2489 | tr("&Save"), | 2484 | tr("&Save"), |
2490 | tr("S&ave with\nnew\npassword"), | 2485 | tr("S&ave with\nnew\npassword"), |
2491 | tr("&Don't Save"), | 2486 | tr("&Don't Save"), |
2492 | 0 // Enter == button 0 | 2487 | 0 // Enter == button 0 |
2493 | ) ) | 2488 | ) ) |
2494 | { // Escape == button 2 | 2489 | { // Escape == button 2 |
2495 | case 0: // Save clicked, Alt-S or Enter pressed. | 2490 | case 0: // Save clicked, Alt-S or Enter pressed. |
@@ -2675,25 +2670,25 @@ void ZSafe::addCategory() | |||
2675 | #endif | 2670 | #endif |
2676 | 2671 | ||
2677 | QString category; | 2672 | QString category; |
2678 | QString icon; | 2673 | QString icon; |
2679 | QString fullIconPath; | 2674 | QString fullIconPath; |
2680 | QPixmap *pix; | 2675 | QPixmap *pix; |
2681 | if (result == Accepted) | 2676 | if (result == Accepted) |
2682 | { | 2677 | { |
2683 | modified = true; | 2678 | modified = true; |
2684 | category = dialog->CategoryField->currentText(); | 2679 | category = dialog->CategoryField->currentText(); |
2685 | icon = dialog->IconField->currentText()+".png"; | 2680 | icon = dialog->IconField->currentText()+".png"; |
2686 | 2681 | ||
2687 | qWarning (category); | 2682 | owarn << category << oendl; |
2688 | 2683 | ||
2689 | QListViewItem *li = new ShadedListItem( 1, ListView ); | 2684 | QListViewItem *li = new ShadedListItem( 1, ListView ); |
2690 | Category *c1 = new Category(); | 2685 | Category *c1 = new Category(); |
2691 | c1->setCategoryName(category); | 2686 | c1->setCategoryName(category); |
2692 | 2687 | ||
2693 | // if (!icon.isEmpty() && !icon.isNull()) | 2688 | // if (!icon.isEmpty() && !icon.isNull()) |
2694 | if (icon != "predefined.png") | 2689 | if (icon != "predefined.png") |
2695 | { | 2690 | { |
2696 | // build the full path | 2691 | // build the full path |
2697 | fullIconPath = iconPath + icon; | 2692 | fullIconPath = iconPath + icon; |
2698 | pix = new QPixmap (fullIconPath); | 2693 | pix = new QPixmap (fullIconPath); |
2699 | // pix->resize(14, 14); | 2694 | // pix->resize(14, 14); |
@@ -3183,25 +3178,25 @@ void ZSafe::editCategory() | |||
3183 | { | 3178 | { |
3184 | // #ifndef WIN32 | 3179 | // #ifndef WIN32 |
3185 | conf->removeEntry (category); | 3180 | conf->removeEntry (category); |
3186 | // #endif | 3181 | // #endif |
3187 | saveConf(); | 3182 | saveConf(); |
3188 | cat->setIcon (*getPredefinedIcon(category)); | 3183 | cat->setIcon (*getPredefinedIcon(category)); |
3189 | } | 3184 | } |
3190 | 3185 | ||
3191 | // change the category name of the selected category | 3186 | // change the category name of the selected category |
3192 | QListViewItem *catItem = cat->getListItem(); | 3187 | QListViewItem *catItem = cat->getListItem(); |
3193 | if (catItem) | 3188 | if (catItem) |
3194 | { | 3189 | { |
3195 | qWarning (category); | 3190 | owarn << category << oendl; |
3196 | catItem->setText( 0, tr( category ) ); | 3191 | catItem->setText( 0, tr( category ) ); |
3197 | cat->setCategoryName (tr(category)); | 3192 | cat->setCategoryName (tr(category)); |
3198 | 3193 | ||
3199 | cat->initListItem(); | 3194 | cat->initListItem(); |
3200 | categories.insert (category, cat); | 3195 | categories.insert (category, cat); |
3201 | } | 3196 | } |
3202 | } | 3197 | } |
3203 | saveCategoryDialogFields(dialog); | 3198 | saveCategoryDialogFields(dialog); |
3204 | } | 3199 | } |
3205 | else | 3200 | else |
3206 | { | 3201 | { |
3207 | // delete dialog; | 3202 | // delete dialog; |
@@ -3584,25 +3579,25 @@ void ZSafe::paintEvent( QPaintEvent * ) | |||
3584 | { | 3579 | { |
3585 | if (raiseFlag) | 3580 | if (raiseFlag) |
3586 | { | 3581 | { |
3587 | raiseFlag = false; | 3582 | raiseFlag = false; |
3588 | raiseTimer.start (1, true); | 3583 | raiseTimer.start (1, true); |
3589 | if (infoForm->isVisible()) | 3584 | if (infoForm->isVisible()) |
3590 | infoForm->raise(); | 3585 | infoForm->raise(); |
3591 | } | 3586 | } |
3592 | } | 3587 | } |
3593 | 3588 | ||
3594 | void ZSafe::resizeEvent ( QResizeEvent * ) | 3589 | void ZSafe::resizeEvent ( QResizeEvent * ) |
3595 | { | 3590 | { |
3596 | // qWarning ("resizeEvent"); | 3591 | // owarn << "resizeEvent" << oendl; |
3597 | #ifndef DESKTOP | 3592 | #ifndef DESKTOP |
3598 | DeskW = appl->desktop()->width(); | 3593 | DeskW = appl->desktop()->width(); |
3599 | DeskH = appl->desktop()->height(); | 3594 | DeskH = appl->desktop()->height(); |
3600 | #else | 3595 | #else |
3601 | DeskW = this->width(); | 3596 | DeskW = this->width(); |
3602 | DeskH = this->height(); | 3597 | DeskH = this->height(); |
3603 | #endif | 3598 | #endif |
3604 | 3599 | ||
3605 | if (New) | 3600 | if (New) |
3606 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); | 3601 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); |
3607 | if (Edit) | 3602 | if (Edit) |
3608 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); | 3603 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); |