summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-10 01:55:11 (UTC)
committer llornkcor <llornkcor>2004-07-10 01:55:11 (UTC)
commit9c40b0465fc9d553077f020bed889bb1ac1a472f (patch) (unidiff)
tree3f315ab6dca8a78e7b8428b23b5370bf294e9897
parentd83b24ab6a294e320146220d7b1302f86b0c3560 (diff)
downloadopie-9c40b0465fc9d553077f020bed889bb1ac1a472f.zip
opie-9c40b0465fc9d553077f020bed889bb1ac1a472f.tar.gz
opie-9c40b0465fc9d553077f020bed889bb1ac1a472f.tar.bz2
qwarning for non opie
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/zsafe.cpp104
1 files changed, 94 insertions, 10 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index 5cad7cb..824b841 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -920,25 +920,29 @@ void ZSafe::findPwd()
920#ifdef DESKTOP 920#ifdef DESKTOP
921 result = Accepted; 921 result = Accepted;
922#endif 922#endif
923 923
924 QString name; 924 QString name;
925 QString username; 925 QString username;
926 QString comment; 926 QString comment;
927 if (result == Accepted) 927 if (result == Accepted)
928 { 928 {
929 name = dialog->NameField->text(); 929 name = dialog->NameField->text();
930 username = dialog->UsernameField->text(); 930 username = dialog->UsernameField->text();
931 comment = dialog->CommentField->text(); 931 comment = dialog->CommentField->text();
932 owarn << name << oendl; 932#ifndef NO_OPIE
933 owarn << name << oendl;
934#else
935 qWarning (name);
936#endif
933 } 937 }
934 else 938 else
935 { 939 {
936 delete dialog; 940 delete dialog;
937 return; 941 return;
938 } 942 }
939 943
940 if (!name.isEmpty() && name != lastSearchedName || 944 if (!name.isEmpty() && name != lastSearchedName ||
941 lastSearchedName.isEmpty() && !name.isEmpty()) 945 lastSearchedName.isEmpty() && !name.isEmpty())
942 { 946 {
943 // set search at the beginning if a new name is given 947 // set search at the beginning if a new name is given
944 lastSearchedCategory = NULL; 948 lastSearchedCategory = NULL;
@@ -966,56 +970,66 @@ void ZSafe::findPwd()
966 970
967 bool found=FALSE; 971 bool found=FALSE;
968 // step through all categories 972 // step through all categories
969 QListViewItem *i; 973 QListViewItem *i;
970 if (lastSearchedCategory) 974 if (lastSearchedCategory)
971 i = lastSearchedCategory; 975 i = lastSearchedCategory;
972 else 976 else
973 i = ListView->firstChild(); 977 i = ListView->firstChild();
974 for (; 978 for (;
975 i != NULL; 979 i != NULL;
976 i = i->nextSibling()) 980 i = i->nextSibling())
977 { 981 {
982#ifndef NO_OPIE
978 owarn << i->text(0) << oendl; 983 owarn << i->text(0) << oendl;
984#endif
979 i->setSelected(FALSE); 985 i->setSelected(FALSE);
980 986
981 // step through all subitems 987 // step through all subitems
982 QListViewItem *si; 988 QListViewItem *si;
983 if (lastSearchedItem) 989 if (lastSearchedItem)
984 si = lastSearchedItem; 990 si = lastSearchedItem;
985 else 991 else
986 si = i->firstChild(); 992 si = i->firstChild();
987 // for (si = i->firstChild(); 993 // for (si = i->firstChild();
988 for (; 994 for (;
989 si != NULL; 995 si != NULL;
990 si = si->nextSibling()) 996 si = si->nextSibling())
991 { 997 {
998#ifndef NO_OPIE
992 owarn << si->text(0) << oendl; 999 owarn << si->text(0) << oendl;
1000#else
1001 qWarning (si->text(0));
1002#endif
993 if (si->isSelected()) 1003 if (si->isSelected())
994 si->setSelected(FALSE); 1004 si->setSelected(FALSE);
995 // ListView->repaintItem(si); 1005 // ListView->repaintItem(si);
996 1006
997 bool n=TRUE; 1007 bool n=TRUE;
998 bool u=TRUE; 1008 bool u=TRUE;
999 bool c=TRUE; 1009 bool c=TRUE;
1000 if (!name.isEmpty()) 1010 if (!name.isEmpty())
1001 n = (si->text(0)).contains (name, FALSE); 1011 n = (si->text(0)).contains (name, FALSE);
1002 if (!username.isEmpty()) 1012 if (!username.isEmpty())
1003 u = (si->text(1)).contains (username, FALSE); 1013 u = (si->text(1)).contains (username, FALSE);
1004 if (!comment.isEmpty()) 1014 if (!comment.isEmpty())
1005 c = (si->text(3)).contains (comment, FALSE); 1015 c = (si->text(3)).contains (comment, FALSE);
1006 1016
1007 if ((n && u && c ) && !found) 1017 if ((n && u && c ) && !found)
1008 { 1018 {
1019#ifndef NO_OPIE
1009 owarn << "Found" << oendl; 1020 owarn << "Found" << oendl;
1021#else
1022 qWarning ("Found");
1023#endif
1010 selectedItem = si; 1024 selectedItem = si;
1011 si->setSelected(TRUE); 1025 si->setSelected(TRUE);
1012 ListView->setCurrentItem(si); 1026 ListView->setCurrentItem(si);
1013 ListView->ensureItemVisible(si); 1027 ListView->ensureItemVisible(si);
1014 ListView->triggerUpdate(); 1028 ListView->triggerUpdate();
1015 1029
1016 lastSearchedCategory = i; 1030 lastSearchedCategory = i;
1017 // set to the next item 1031 // set to the next item
1018 lastSearchedItem = si->nextSibling(); 1032 lastSearchedItem = si->nextSibling();
1019 if (!lastSearchedItem) 1033 if (!lastSearchedItem)
1020 { 1034 {
1021 // no next item within category -> set next category 1035 // no next item within category -> set next category
@@ -1267,25 +1281,29 @@ void ZSafe::removeAsciiFile()
1267 QDir::homeDirPath() + "/Documents/application/zsafe", 1281 QDir::homeDirPath() + "/Documents/application/zsafe",
1268 "ZSafe (*.txt)", 1282 "ZSafe (*.txt)",
1269 this, 1283 this,
1270 "ZSafe File Dialog" 1284 "ZSafe File Dialog"
1271 "Choose a text file" ); 1285 "Choose a text file" );
1272#endif 1286#endif
1273 1287
1274 if (fn && fn.length() > 0 ) 1288 if (fn && fn.length() > 0 )
1275 { 1289 {
1276 QFile f( fn ); 1290 QFile f( fn );
1277 if ( !f.remove() ) 1291 if ( !f.remove() )
1278 { 1292 {
1293#ifndef NO_OPIE
1279 owarn << "Could not remove file " << fn << oendl; 1294 owarn << "Could not remove file " << fn << oendl;
1295#else
1296 qWarning( QString("Could not remove file %1").arg(fn),2000 );
1297#endif
1280 QMessageBox::critical( 0, tr("ZSafe"), 1298 QMessageBox::critical( 0, tr("ZSafe"),
1281 tr("Could not remove text file.") ); 1299 tr("Could not remove text file.") );
1282 return; 1300 return;
1283 } 1301 }
1284 } 1302 }
1285} 1303}
1286 1304
1287void ZSafe::writeAllEntries() 1305void ZSafe::writeAllEntries()
1288{ 1306{
1289 if (filename.isEmpty()) 1307 if (filename.isEmpty())
1290 { 1308 {
1291 QMessageBox::critical( 0, tr("ZSafe"), 1309 QMessageBox::critical( 0, tr("ZSafe"),
@@ -1316,25 +1334,29 @@ void ZSafe::writeAllEntries()
1316 QDir::homeDirPath() + "/Documents/application/zsafe", 1334 QDir::homeDirPath() + "/Documents/application/zsafe",
1317 "ZSafe (*.txt)", 1335 "ZSafe (*.txt)",
1318 this, 1336 this,
1319 "ZSafe File Dialog" 1337 "ZSafe File Dialog"
1320 "Choose a text file" ); 1338 "Choose a text file" );
1321#endif 1339#endif
1322 1340
1323 // open the new document 1341 // open the new document
1324 if (fn && fn.length() > 0 ) 1342 if (fn && fn.length() > 0 )
1325 { 1343 {
1326 QFile f( fn ); 1344 QFile f( fn );
1327 if ( !f.open( IO_WriteOnly ) ) { 1345 if ( !f.open( IO_WriteOnly ) ) {
1346#ifndef NO_OPIE
1328 owarn << "Could not write to file " << fn << oendl; 1347 owarn << "Could not write to file " << fn << oendl;
1348#else
1349 qWarning( QString("Could not write to file %1").arg(fn),2000 );
1350#endif
1329 QMessageBox::critical( 0, "ZSafe", 1351 QMessageBox::critical( 0, "ZSafe",
1330 QString("Could not export to text file.") ); 1352 QString("Could not export to text file.") );
1331 return; 1353 return;
1332 } 1354 }
1333 QTextStream t( &f ); 1355 QTextStream t( &f );
1334 1356
1335 QListViewItem *i; 1357 QListViewItem *i;
1336 // step through all categories 1358 // step through all categories
1337 for (i = ListView->firstChild(); 1359 for (i = ListView->firstChild();
1338 i != NULL; 1360 i != NULL;
1339 i = i->nextSibling()) 1361 i = i->nextSibling())
1340 { 1362 {
@@ -1410,25 +1432,29 @@ void ZSafe::readAllEntries()
1410 QDir::homeDirPath() + "/Documents/application/zsafe", 1432 QDir::homeDirPath() + "/Documents/application/zsafe",
1411 "ZSafe (*.txt)", 1433 "ZSafe (*.txt)",
1412 this, 1434 this,
1413 "ZSafe File Dialog" 1435 "ZSafe File Dialog"
1414 "Choose a text file" ); 1436 "Choose a text file" );
1415#endif 1437#endif
1416 1438
1417 if (fn && fn.length() > 0 ) 1439 if (fn && fn.length() > 0 )
1418 { 1440 {
1419 QFile f( fn ); 1441 QFile f( fn );
1420 if ( !f.open( IO_ReadOnly ) ) 1442 if ( !f.open( IO_ReadOnly ) )
1421 { 1443 {
1444#ifndef NO_OPIE
1422 owarn << "Could not read file " << fn << oendl; 1445 owarn << "Could not read file " << fn << oendl;
1446#else
1447 qWarning( QString("Could not read file %1").arg(fn), 2000 );
1448#endif
1423 QMessageBox::critical( 0, "ZSafe", 1449 QMessageBox::critical( 0, "ZSafe",
1424 QString("Could not import text file.") ); 1450 QString("Could not import text file.") );
1425 return; 1451 return;
1426 } 1452 }
1427 1453
1428 modified = true; 1454 modified = true;
1429 1455
1430 // clear the password list 1456 // clear the password list
1431 selectedItem = NULL; 1457 selectedItem = NULL;
1432 QListViewItem *i; 1458 QListViewItem *i;
1433 // step through all categories 1459 // step through all categories
1434 for (i = ListView->firstChild(); 1460 for (i = ListView->firstChild();
@@ -1439,26 +1465,30 @@ void ZSafe::readAllEntries()
1439 QListViewItem *si; 1465 QListViewItem *si;
1440 for (si = i->firstChild(); 1466 for (si = i->firstChild();
1441 si != NULL; ) 1467 si != NULL; )
1442 // si = si->nextSibling()) 1468 // si = si->nextSibling())
1443 { 1469 {
1444 QListViewItem *_si = si; 1470 QListViewItem *_si = si;
1445 si = si->nextSibling(); 1471 si = si->nextSibling();
1446 i->takeItem(_si); // remove from view list 1472 i->takeItem(_si); // remove from view list
1447 if (_si) delete _si; 1473 if (_si) delete _si;
1448 } 1474 }
1449 } 1475 }
1450 1476
1477#ifndef NO_OPIE
1451 owarn << "ReadAllEntries(): " << oendl; 1478 owarn << "ReadAllEntries(): " << oendl;
1452 1479#else
1480 qWarning ("ReadAllEntries(): ");
1481#endif
1482
1453 QTextStream t(&f); 1483 QTextStream t(&f);
1454 while ( !t.eof() ) 1484 while ( !t.eof() )
1455 { 1485 {
1456 QString s = t.readLine(); 1486 QString s = t.readLine();
1457 s.replace (QRegExp("\";\""), "\"|\""); 1487 s.replace (QRegExp("\";\""), "\"|\"");
1458 // char buffer[1024]; 1488 // char buffer[1024];
1459#ifndef WIN32 1489#ifndef WIN32
1460 char buffer[s.length()+1]; 1490 char buffer[s.length()+1];
1461#else 1491#else
1462 char buffer[4048]; 1492 char buffer[4048];
1463#endif 1493#endif
1464 1494
@@ -1586,29 +1616,40 @@ void ZSafe::readAllEntries()
1586 f.close(); 1616 f.close();
1587 1617
1588 } 1618 }
1589 else 1619 else
1590 { 1620 {
1591 } 1621 }
1592 1622
1593} 1623}
1594 1624
1595#ifdef UNUSED 1625#ifdef UNUSED
1596void ZSafe::writeAllEntries() 1626void ZSafe::writeAllEntries()
1597{ 1627{
1628 if (filename.isEmpty())
1629 {
1630 QMessageBox::critical( 0, tr("ZSafe"),
1631 tr("<P>No document defined. You have to create a new document</P>"));
1632 return;
1633 }
1634
1598 // open the file for writing 1635 // open the file for writing
1599 QString fn = filename + ".txt"; 1636 QString fn = filename + ".txt";
1600 QFile f( fn ); 1637 QFile f( fn );
1601 if ( !f.open( IO_WriteOnly ) ) { 1638 if ( !f.open( IO_WriteOnly ) ) {
1639#ifndef NO_OPIE
1602 owarn << "Could not write to file " << fn << oendl; 1640 owarn << "Could not write to file " << fn << oendl;
1641#else
1642 qWarning( QString("Could not write to file %1").arg(fn), 2000 );
1643#endif
1603 QMessageBox::critical( 0, tr("ZSafe"), 1644 QMessageBox::critical( 0, tr("ZSafe"),
1604 tr("Could not export to text file.") ); 1645 tr("Could not export to text file.") );
1605 return; 1646 return;
1606 } 1647 }
1607 QTextStream t( &f ); 1648 QTextStream t( &f );
1608 1649
1609 QListViewItem *i; 1650 QListViewItem *i;
1610 // step through all categories 1651 // step through all categories
1611 for (i = ListView->firstChild(); 1652 for (i = ListView->firstChild();
1612 i != NULL; 1653 i != NULL;
1613 i = i->nextSibling()) 1654 i = i->nextSibling())
1614 { 1655 {
@@ -1643,25 +1684,29 @@ void ZSafe::writeAllEntries()
1643 // owarn << si->text(0) << oendl; 1684 // owarn << si->text(0) << oendl;
1644 } 1685 }
1645 } 1686 }
1646 f.close(); 1687 f.close();
1647} 1688}
1648 1689
1649void ZSafe::readAllEntries() 1690void ZSafe::readAllEntries()
1650{ 1691{
1651 QString fn = filename + ".txt"; 1692 QString fn = filename + ".txt";
1652 QFile f( fn ); 1693 QFile f( fn );
1653 if ( !f.open( IO_ReadOnly ) ) 1694 if ( !f.open( IO_ReadOnly ) )
1654 { 1695 {
1696#ifndef NO_OPIE
1655 owarn << "Could not read file " << fn << oendl; 1697 owarn << "Could not read file " << fn << oendl;
1698#else
1699 qWarning( QString("Could not read file %1").arg(fn), 2000 );
1700#endif
1656 QMessageBox::critical( 0, tr("ZSafe"), 1701 QMessageBox::critical( 0, tr("ZSafe"),
1657 tr("Could not import text file.") ); 1702 tr("Could not import text file.") );
1658 return; 1703 return;
1659 } 1704 }
1660 1705
1661 modified = true; 1706 modified = true;
1662 1707
1663 // clear the password list 1708 // clear the password list
1664 selectedItem = NULL; 1709 selectedItem = NULL;
1665 QListViewItem *i; 1710 QListViewItem *i;
1666 // step through all categories 1711 // step through all categories
1667 for (i = ListView->firstChild(); 1712 for (i = ListView->firstChild();
@@ -1672,26 +1717,29 @@ void ZSafe::readAllEntries()
1672 QListViewItem *si; 1717 QListViewItem *si;
1673 for (si = i->firstChild(); 1718 for (si = i->firstChild();
1674 si != NULL; ) 1719 si != NULL; )
1675 // si = si->nextSibling()) 1720 // si = si->nextSibling())
1676 { 1721 {
1677 QListViewItem *_si = si; 1722 QListViewItem *_si = si;
1678 si = si->nextSibling(); 1723 si = si->nextSibling();
1679 i->takeItem(_si); // remove from view list 1724 i->takeItem(_si); // remove from view list
1680 if (_si) delete _si; 1725 if (_si) delete _si;
1681 } 1726 }
1682 } 1727 }
1683 1728
1729#ifndef NO_OPIE
1684 owarn << "ReadAllEntries(): " << oendl; 1730 owarn << "ReadAllEntries(): " << oendl;
1685 1731#else
1732 qWarning ("ReadAllEntries(): ");
1733#endif
1686 QTextStream t(&f); 1734 QTextStream t(&f);
1687 while ( !t.eof() ) 1735 while ( !t.eof() )
1688 { 1736 {
1689 QString s = t.readLine(); 1737 QString s = t.readLine();
1690 s.replace (QRegExp("\";\""), "\"|\""); 1738 s.replace (QRegExp("\";\""), "\"|\"");
1691 // char buffer[1024]; 1739 // char buffer[1024];
1692 int len=s.length()+1; 1740 int len=s.length()+1;
1693#ifdef WIN32 1741#ifdef WIN32
1694 char buffer[512]; 1742 char buffer[512];
1695#else 1743#else
1696 char buffer[len]; 1744 char buffer[len];
1697#endif 1745#endif
@@ -1796,26 +1844,28 @@ void ZSafe::readAllEntries()
1796 c1->initListItem(); 1844 c1->initListItem();
1797 categories.insert (c1->getCategoryName(), c1); 1845 categories.insert (c1->getCategoryName(), c1);
1798 } 1846 }
1799 1847
1800 } 1848 }
1801 f.close(); 1849 f.close();
1802 1850
1803} 1851}
1804#endif // UNUSED 1852#endif // UNUSED
1805 1853
1806void ZSafe::resume(int) 1854void ZSafe::resume(int)
1807{ 1855{
1856#ifndef NO_OPIE
1808 owarn << "Resume" << oendl; 1857 owarn << "Resume" << oendl;
1809 // hide the main window 1858#endif
1859 // hide the main window
1810 1860
1811 if ( !showpwd ) 1861 if ( !showpwd )
1812 { 1862 {
1813 infoForm->hide(); 1863 infoForm->hide();
1814 // open zsafe again 1864 // open zsafe again
1815 m_password = ""; 1865 m_password = "";
1816 selectedItem = NULL; 1866 selectedItem = NULL;
1817 1867
1818 // clear the password list 1868 // clear the password list
1819 QListViewItem *i; 1869 QListViewItem *i;
1820 // step through all categories 1870 // step through all categories
1821 for (i = ListView->firstChild(); 1871 for (i = ListView->firstChild();
@@ -1855,35 +1905,43 @@ bool ZSafe::openDocument(const char* _filename, const char* )
1855 int pwdOk = 0; 1905 int pwdOk = 0;
1856 int numberOfTries = 3; 1906 int numberOfTries = 3;
1857 for (int i=0; i < numberOfTries; i++) 1907 for (int i=0; i < numberOfTries; i++)
1858 { 1908 {
1859 QFile f(_filename); 1909 QFile f(_filename);
1860 if (f.exists()) 1910 if (f.exists())
1861 { 1911 {
1862 // ask with a dialog for the password 1912 // ask with a dialog for the password
1863 if (m_password.isEmpty()) 1913 if (m_password.isEmpty())
1864 getDocPassword(tr("Enter Password")); 1914 getDocPassword(tr("Enter Password"));
1865 if (m_password.isEmpty() && validationFlag == 0) 1915 if (m_password.isEmpty() && validationFlag == 0)
1866 { 1916 {
1917#ifndef NO_OPIE
1867 owarn << "Wrong password" << oendl; 1918 owarn << "Wrong password" << oendl;
1919#else
1920 qWarning ("Wrong password");
1921#endif
1868 QMessageBox::critical( 0, tr("ZSafe"), 1922 QMessageBox::critical( 0, tr("ZSafe"),
1869 tr("Wrong password.\n\nZSafe will now exit.") ); 1923 tr("Wrong password.\n\nZSafe will now exit.") );
1870 exitZs (1); 1924 exitZs (1);
1871 } 1925 }
1872 1926
1873 retval = loadInit(_filename, m_password); 1927 retval = loadInit(_filename, m_password);
1874 if (retval != PWERR_GOOD) 1928 if (retval != PWERR_GOOD)
1875 { 1929 {
1930#ifndef NO_OPIE
1876 owarn << "Error loading Document" << oendl; 1931 owarn << "Error loading Document" << oendl;
1877 return false; 1932#lese
1933 qWarning ("Error loading Document");
1934#endif
1935 return false;
1878 } 1936 }
1879 } 1937 }
1880 else 1938 else
1881 { 1939 {
1882#ifdef WIN32 1940#ifdef WIN32
1883 this->setCaption("Qt ZSafe"); 1941 this->setCaption("Qt ZSafe");
1884#else 1942#else
1885 this->setCaption("ZSafe"); 1943 this->setCaption("ZSafe");
1886#endif 1944#endif
1887 filename = ""; 1945 filename = "";
1888 return false; 1946 return false;
1889 } 1947 }
@@ -2264,25 +2322,29 @@ bool ZSafe::saveDocument(const char* _filename,
2264 strcpy(entry[i++], "password"); 2322 strcpy(entry[i++], "password");
2265 entry[i] = (char*)malloc(strlen("comment")+1); 2323 entry[i] = (char*)malloc(strlen("comment")+1);
2266 strcpy(entry[i++], "comment"); 2324 strcpy(entry[i++], "comment");
2267 2325
2268 entry[i] = (char*)malloc(strlen("field5")+1); 2326 entry[i] = (char*)malloc(strlen("field5")+1);
2269 strcpy(entry[i++], "field5"); 2327 strcpy(entry[i++], "field5");
2270 entry[i] = (char*)malloc(strlen("field6")+1); 2328 entry[i] = (char*)malloc(strlen("field6")+1);
2271 strcpy(entry[i++], "field6"); 2329 strcpy(entry[i++], "field6");
2272 2330
2273 retval = saveEntry(entry); 2331 retval = saveEntry(entry);
2274 for (int z=0; z<i; z++) free(entry[z]); 2332 for (int z=0; z<i; z++) free(entry[z]);
2275 if (retval == PWERR_DATA) { 2333 if (retval == PWERR_DATA) {
2334#ifndef NO_OPIE
2276 owarn << "1: Error writing file, contents not saved" << oendl; 2335 owarn << "1: Error writing file, contents not saved" << oendl;
2336#else
2337 qWarning("1: Error writing file, contents not saved");
2338#endif
2277 saveFinalize(); 2339 saveFinalize();
2278 return false; 2340 return false;
2279 } 2341 }
2280// #ifndef WIN32 2342// #ifndef WIN32
2281 conf->writeEntry(APP_KEY+"valzsafe", 1); 2343 conf->writeEntry(APP_KEY+"valzsafe", 1);
2282// #endif 2344// #endif
2283 saveConf(); 2345 saveConf();
2284 } 2346 }
2285 2347
2286 QListViewItem *i; 2348 QListViewItem *i;
2287 // step through all categories 2349 // step through all categories
2288 for (i = ListView->firstChild(); 2350 for (i = ListView->firstChild();
@@ -2308,56 +2370,66 @@ bool ZSafe::saveDocument(const char* _filename,
2308 strcpy(entry[j++], si->text(3).utf8()); 2370 strcpy(entry[j++], si->text(3).utf8());
2309 entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); 2371 entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1);
2310 strcpy(entry[j++], si->text(4).utf8()); 2372 strcpy(entry[j++], si->text(4).utf8());
2311 entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); 2373 entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1);
2312 strcpy(entry[j++], si->text(5).utf8()); 2374 strcpy(entry[j++], si->text(5).utf8());
2313 2375
2314 retval = saveEntry(entry); 2376 retval = saveEntry(entry);
2315 for (int z=0; z<j; z++) 2377 for (int z=0; z<j; z++)
2316 { 2378 {
2317 free(entry[z]); 2379 free(entry[z]);
2318 } 2380 }
2319 if (retval == PWERR_DATA) { 2381 if (retval == PWERR_DATA) {
2382#ifndef NO_OPIE
2320 owarn << "1: Error writing file, contents not saved" << oendl; 2383 owarn << "1: Error writing file, contents not saved" << oendl;
2384#else
2385 qWarning("1: Error writing file, contents not saved");
2386#endif
2321 saveFinalize(); 2387 saveFinalize();
2322 return false; 2388 return false;
2323 } 2389 }
2324 2390
2325 } 2391 }
2326 } 2392 }
2327 2393
2328 if (saveFinalize() == PWERR_DATA) { 2394 if (saveFinalize() == PWERR_DATA) {
2395#ifndef NO_OPIE
2329 owarn << "2: Error writing file, contents not saved" << oendl; 2396 owarn << "2: Error writing file, contents not saved" << oendl;
2330 return false; 2397#else
2398 qWarning("2: Error writing file, contents not saved");
2399#endif
2400 return false;
2331 } else { 2401 } else {
2332#ifndef DESKTOP 2402#ifndef DESKTOP
2333 Global::statusMessage (tr("Password file saved.")); 2403 Global::statusMessage (tr("Password file saved."));
2334#endif 2404#endif
2335 modified = false; 2405 modified = false;
2336 return true; 2406 return true;
2337 } 2407 }
2338} 2408}
2339 2409
2340PasswordForm *newPwdDialog; 2410PasswordForm *newPwdDialog;
2341bool newPwdDialogResult = false; 2411bool newPwdDialogResult = false;
2342void ZSafe::setPasswordDialogDone() 2412void ZSafe::setPasswordDialogDone()
2343{ 2413{
2344 newPwdDialogResult = true; 2414 newPwdDialogResult = true;
2345 newPwdDialog->close(); 2415 newPwdDialog->close();
2346} 2416}
2347 2417
2348void ZSafe::getDocPassword(QString title) 2418void ZSafe::getDocPassword(QString title)
2349{ 2419{
2420#ifndef NO_OPIE
2350 owarn << "getDocPassword" << oendl; 2421 owarn << "getDocPassword" << oendl;
2351 // open the 'Password' dialog 2422#endif
2423 // open the 'Password' dialog
2352 PasswordForm *dialog = new PasswordForm(this, title, TRUE); 2424 PasswordForm *dialog = new PasswordForm(this, title, TRUE);
2353 newPwdDialog = dialog; 2425 newPwdDialog = dialog;
2354 newPwdDialogResult = false; 2426 newPwdDialogResult = false;
2355 2427
2356 QPixmap image0( ( const char** ) zsafe_xpm ); 2428 QPixmap image0( ( const char** ) zsafe_xpm );
2357 dialog->setIcon( image0); 2429 dialog->setIcon( image0);
2358 2430
2359 connect( dialog->PasswordField, SIGNAL( returnPressed() ), 2431 connect( dialog->PasswordField, SIGNAL( returnPressed() ),
2360 this, SLOT( setPasswordDialogDone() ) ); 2432 this, SLOT( setPasswordDialogDone() ) );
2361 2433
2362 // CS: !!! 2434 // CS: !!!
2363 // int pos = filename.findRev ('/'); 2435 // int pos = filename.findRev ('/');
@@ -2520,26 +2592,28 @@ int ZSafe::saveFinalize(void)
2520 ciphertext[count1] = iv[count1] ^ plaintext[count1]; 2592 ciphertext[count1] = iv[count1] ^ plaintext[count1];
2521 if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; 2593 if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA;
2522 if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; 2594 if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA;
2523 } 2595 }
2524 2596
2525 fclose (fd); 2597 fclose (fd);
2526 free(buffer); 2598 free(buffer);
2527 return retval; 2599 return retval;
2528} 2600}
2529 2601
2530void ZSafe::quitMe () 2602void ZSafe::quitMe ()
2531{ 2603{
2604#ifndef NO_OPIE
2532 owarn << "QUIT..." << oendl; 2605 owarn << "QUIT..." << oendl;
2533 2606#endif
2607
2534 if (modified) 2608 if (modified)
2535 { 2609 {
2536 switch( QMessageBox::information( this, tr("ZSafe"), 2610 switch( QMessageBox::information( this, tr("ZSafe"),
2537 tr("Do you want to save\nbefore exiting?"), 2611 tr("Do you want to save\nbefore exiting?"),
2538 tr("&Save"), 2612 tr("&Save"),
2539 tr("S&ave with\nnew\npassword"), 2613 tr("S&ave with\nnew\npassword"),
2540 tr("&Don't Save"), 2614 tr("&Don't Save"),
2541 0 // Enter == button 0 2615 0 // Enter == button 0
2542 ) ) 2616 ) )
2543 { // Escape == button 2 2617 { // Escape == button 2
2544 case 0: // Save clicked, Alt-S or Enter pressed. 2618 case 0: // Save clicked, Alt-S or Enter pressed.
2545 // save 2619 // save
@@ -2724,26 +2798,28 @@ void ZSafe::addCategory()
2724#endif 2798#endif
2725 2799
2726 QString category; 2800 QString category;
2727 QString icon; 2801 QString icon;
2728 QString fullIconPath; 2802 QString fullIconPath;
2729 QPixmap *pix; 2803 QPixmap *pix;
2730 if (result == Accepted) 2804 if (result == Accepted)
2731 { 2805 {
2732 modified = true; 2806 modified = true;
2733 category = dialog->CategoryField->currentText(); 2807 category = dialog->CategoryField->currentText();
2734 icon = dialog->IconField->currentText()+".png"; 2808 icon = dialog->IconField->currentText()+".png";
2735 2809
2810#ifndef NO_OPIE
2736 owarn << category << oendl; 2811 owarn << category << oendl;
2737 2812#endif
2813
2738 QListViewItem *li = new ShadedListItem( 1, ListView ); 2814 QListViewItem *li = new ShadedListItem( 1, ListView );
2739 Category *c1 = new Category(); 2815 Category *c1 = new Category();
2740 c1->setCategoryName(category); 2816 c1->setCategoryName(category);
2741 2817
2742 // if (!icon.isEmpty() && !icon.isNull()) 2818 // if (!icon.isEmpty() && !icon.isNull())
2743 if (icon != "predefined.png") 2819 if (icon != "predefined.png")
2744 { 2820 {
2745 // build the full path 2821 // build the full path
2746 fullIconPath = iconPath + icon; 2822 fullIconPath = iconPath + icon;
2747 pix = new QPixmap (fullIconPath); 2823 pix = new QPixmap (fullIconPath);
2748 // pix->resize(14, 14); 2824 // pix->resize(14, 14);
2749 if (!pix->isNull()) 2825 if (!pix->isNull())
@@ -3198,26 +3274,30 @@ void ZSafe::editCategory()
3198 categories.remove (category); 3274 categories.remove (category);
3199// #ifndef WIN32 3275// #ifndef WIN32
3200 conf->removeEntry(category); 3276 conf->removeEntry(category);
3201// #endif 3277// #endif
3202 saveConf(); 3278 saveConf();
3203 } 3279 }
3204 3280
3205 category = dialog->CategoryField->currentText(); 3281 category = dialog->CategoryField->currentText();
3206 icon = dialog->IconField->currentText()+".png"; 3282 icon = dialog->IconField->currentText()+".png";
3207 3283
3208 if (cat) 3284 if (cat)
3209 { 3285 {
3286#ifndef NO_OPIE
3210 owarn << "Category found" << oendl; 3287 owarn << "Category found" << oendl;
3211 3288#else
3289 qWarning("Category found");
3290#endif
3291
3212 // if (!icon.isEmpty() && !icon.isNull()) 3292 // if (!icon.isEmpty() && !icon.isNull())
3213 if (icon != "predefined.png") 3293 if (icon != "predefined.png")
3214 { 3294 {
3215 // build the full path 3295 // build the full path
3216 fullIconPath = iconPath + icon; 3296 fullIconPath = iconPath + icon;
3217 pix = new QPixmap (fullIconPath); 3297 pix = new QPixmap (fullIconPath);
3218 if (!pix->isNull()) 3298 if (!pix->isNull())
3219 { 3299 {
3220 // save the full pixmap name into the config file 3300 // save the full pixmap name into the config file
3221// #ifndef WIN32 3301// #ifndef WIN32
3222 conf->writeEntry(APP_KEY+category, icon); 3302 conf->writeEntry(APP_KEY+category, icon);
3223// #endif 3303// #endif
@@ -3232,25 +3312,29 @@ void ZSafe::editCategory()
3232 { 3312 {
3233// #ifndef WIN32 3313// #ifndef WIN32
3234 conf->removeEntry (category); 3314 conf->removeEntry (category);
3235// #endif 3315// #endif
3236 saveConf(); 3316 saveConf();
3237 cat->setIcon (*getPredefinedIcon(category)); 3317 cat->setIcon (*getPredefinedIcon(category));
3238 } 3318 }
3239 3319
3240 // change the category name of the selected category 3320 // change the category name of the selected category
3241 QListViewItem *catItem = cat->getListItem(); 3321 QListViewItem *catItem = cat->getListItem();
3242 if (catItem) 3322 if (catItem)
3243 { 3323 {
3324#ifndef NO_OPIE
3244 owarn << category << oendl; 3325 owarn << category << oendl;
3326#else
3327 qWarning (category);
3328#endif
3245 catItem->setText( 0, tr( category ) ); 3329 catItem->setText( 0, tr( category ) );
3246 cat->setCategoryName (tr(category)); 3330 cat->setCategoryName (tr(category));
3247 3331
3248 cat->initListItem(); 3332 cat->initListItem();
3249 categories.insert (category, cat); 3333 categories.insert (category, cat);
3250 } 3334 }
3251 } 3335 }
3252 saveCategoryDialogFields(dialog); 3336 saveCategoryDialogFields(dialog);
3253 } 3337 }
3254 else 3338 else
3255 { 3339 {
3256 // delete dialog; 3340 // delete dialog;