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
@@ -884,174 +884,188 @@ retype:
884 comment.replace (QRegExp("\n"), "<br>"); 884 comment.replace (QRegExp("\n"), "<br>");
885 i->setText (3, tr (comment)); 885 i->setText (3, tr (comment));
886 QString f5 = dialog->Field5->text(); 886 QString f5 = dialog->Field5->text();
887 i->setText (4, tr (f5)); 887 i->setText (4, tr (f5));
888 QString f6 = dialog->Field6->text(); 888 QString f6 = dialog->Field6->text();
889 i->setText (5, tr (f6)); 889 i->setText (5, tr (f6));
890 } 890 }
891 891
892 delete dialog; 892 delete dialog;
893 } 893 }
894} 894}
895 895
896void ZSafe::findPwd() 896void ZSafe::findPwd()
897{ 897{
898 898
899 // open the 'Search' dialog 899 // open the 'Search' dialog
900 SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); 900 SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE);
901#ifdef WIN32 901#ifdef WIN32
902 dialog->setCaption ("Qt " + tr("Search")); 902 dialog->setCaption ("Qt " + tr("Search"));
903#endif 903#endif
904 904
905#ifdef DESKTOP 905#ifdef DESKTOP
906#endif 906#endif
907 if (lastSearchedName) 907 if (lastSearchedName)
908 dialog->NameField->setText(lastSearchedName); 908 dialog->NameField->setText(lastSearchedName);
909 else 909 else
910 dialog->NameField->setText(""); 910 dialog->NameField->setText("");
911 if (lastSearchedUsername) 911 if (lastSearchedUsername)
912 dialog->UsernameField->setText(lastSearchedUsername); 912 dialog->UsernameField->setText(lastSearchedUsername);
913 else 913 else
914 dialog->UsernameField->setText(""); 914 dialog->UsernameField->setText("");
915 if (lastSearchedComment) 915 if (lastSearchedComment)
916 dialog->CommentField->setText(lastSearchedComment); 916 dialog->CommentField->setText(lastSearchedComment);
917 else 917 else
918 dialog->CommentField->setText(""); 918 dialog->CommentField->setText("");
919 DialogCode result = (DialogCode) dialog->exec(); 919 DialogCode result = (DialogCode) dialog->exec();
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;
945 lastSearchedItem = NULL; 949 lastSearchedItem = NULL;
946 } 950 }
947 lastSearchedName = name; 951 lastSearchedName = name;
948 if (!username.isEmpty() && username != lastSearchedUsername || 952 if (!username.isEmpty() && username != lastSearchedUsername ||
949 lastSearchedUsername.isEmpty() && !username.isEmpty()) 953 lastSearchedUsername.isEmpty() && !username.isEmpty())
950 { 954 {
951 // set search at the beginning if a new name is given 955 // set search at the beginning if a new name is given
952 lastSearchedCategory = NULL; 956 lastSearchedCategory = NULL;
953 lastSearchedItem = NULL; 957 lastSearchedItem = NULL;
954 } 958 }
955 lastSearchedUsername = username; 959 lastSearchedUsername = username;
956 if (!comment.isEmpty() && comment != lastSearchedComment || 960 if (!comment.isEmpty() && comment != lastSearchedComment ||
957 lastSearchedComment.isEmpty() && !comment.isEmpty()) 961 lastSearchedComment.isEmpty() && !comment.isEmpty())
958 { 962 {
959 // set search at the beginning if a new name is given 963 // set search at the beginning if a new name is given
960 lastSearchedCategory = NULL; 964 lastSearchedCategory = NULL;
961 lastSearchedItem = NULL; 965 lastSearchedItem = NULL;
962 } 966 }
963 lastSearchedComment = comment; 967 lastSearchedComment = comment;
964 968
965 ListView->clearSelection(); 969 ListView->clearSelection();
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
1022 lastSearchedCategory = i->nextSibling(); 1036 lastSearchedCategory = i->nextSibling();
1023 if (!lastSearchedCategory) 1037 if (!lastSearchedCategory)
1024 lastSearchedItem = NULL; // END 1038 lastSearchedItem = NULL; // END
1025 } 1039 }
1026 1040
1027 found = TRUE; 1041 found = TRUE;
1028 delete dialog; 1042 delete dialog;
1029 update(); 1043 update();
1030 return; 1044 return;
1031 } 1045 }
1032 } 1046 }
1033 lastSearchedCategory = i->nextSibling(); 1047 lastSearchedCategory = i->nextSibling();
1034 lastSearchedItem = NULL; 1048 lastSearchedItem = NULL;
1035 } 1049 }
1036 lastSearchedCategory = NULL; 1050 lastSearchedCategory = NULL;
1037 lastSearchedItem = NULL; 1051 lastSearchedItem = NULL;
1038 delete dialog; 1052 delete dialog;
1039 update(); 1053 update();
1040 QMessageBox::information( this, tr("ZSafe"), 1054 QMessageBox::information( this, tr("ZSafe"),
1041 tr("Entry not found"), tr("&OK"), 0); 1055 tr("Entry not found"), tr("&OK"), 0);
1042 1056
1043} 1057}
1044 1058
1045QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) 1059QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
1046{ 1060{
1047 QString category; 1061 QString category;
1048 if (_item) 1062 if (_item)
1049 { 1063 {
1050 if (isCategory(_item)) 1064 if (isCategory(_item))
1051 { 1065 {
1052 category = _item->text(0); 1066 category = _item->text(0);
1053 } 1067 }
1054 else 1068 else
1055 { 1069 {
1056 QListViewItem *cat = _item->parent(); 1070 QListViewItem *cat = _item->parent();
1057 category = cat->text(0); 1071 category = cat->text(0);
@@ -1231,270 +1245,286 @@ void ZSafe::listViewSelected( QListViewItem *_item)
1231 1245
1232bool ZSafe::isCategory(QListViewItem *_item) 1246bool ZSafe::isCategory(QListViewItem *_item)
1233{ 1247{
1234 if (_item == NULL) 1248 if (_item == NULL)
1235 return FALSE; 1249 return FALSE;
1236 1250
1237 QString categoryName = _item->text (0); 1251 QString categoryName = _item->text (0);
1238 if (categories.find (categoryName)) 1252 if (categories.find (categoryName))
1239 return TRUE; 1253 return TRUE;
1240 else 1254 else
1241 return FALSE; 1255 return FALSE;
1242} 1256}
1243 1257
1244void ZSafe::removeAsciiFile() 1258void ZSafe::removeAsciiFile()
1245{ 1259{
1246 // QString fn = filename + ".txt"; 1260 // QString fn = filename + ".txt";
1247 // open the file dialog 1261 // open the file dialog
1248#ifndef DESKTOP 1262#ifndef DESKTOP
1249#ifndef NO_OPIE 1263#ifndef NO_OPIE
1250 QMap<QString, QStringList> mimeTypes; 1264 QMap<QString, QStringList> mimeTypes;
1251 mimeTypes.insert(tr("All"), QStringList() ); 1265 mimeTypes.insert(tr("All"), QStringList() );
1252 mimeTypes.insert(tr("Text"), "text/*" ); 1266 mimeTypes.insert(tr("Text"), "text/*" );
1253 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 1267 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
1254 QDir::homeDirPath() + "/Documents/application/zsafe", 1268 QDir::homeDirPath() + "/Documents/application/zsafe",
1255 QString::null, 1269 QString::null,
1256 mimeTypes, 1270 mimeTypes,
1257 this, 1271 this,
1258 tr ("Remove text file")); 1272 tr ("Remove text file"));
1259#else 1273#else
1260 QString fn = ScQtFileEdit::getOpenFileName(this, 1274 QString fn = ScQtFileEdit::getOpenFileName(this,
1261 tr ("Remove text file"), 1275 tr ("Remove text file"),
1262 QDir::homeDirPath() + "/Documents/application/zsafe", 1276 QDir::homeDirPath() + "/Documents/application/zsafe",
1263 "*.txt"); 1277 "*.txt");
1264#endif 1278#endif
1265#else 1279#else
1266 QString fn = QFileDialog::getOpenFileName( 1280 QString fn = QFileDialog::getOpenFileName(
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"),
1292 tr("No document defined.\nYou have to create a new document")); 1310 tr("No document defined.\nYou have to create a new document"));
1293 return; 1311 return;
1294 } 1312 }
1295 1313
1296 // open the file dialog 1314 // open the file dialog
1297#ifndef DESKTOP 1315#ifndef DESKTOP
1298#ifndef NO_OPIE 1316#ifndef NO_OPIE
1299 QMap<QString, QStringList> mimeTypes; 1317 QMap<QString, QStringList> mimeTypes;
1300 mimeTypes.insert(tr("All"), QStringList() ); 1318 mimeTypes.insert(tr("All"), QStringList() );
1301 mimeTypes.insert(tr("Text"), "text/*" ); 1319 mimeTypes.insert(tr("Text"), "text/*" );
1302 QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, 1320 QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
1303 QDir::homeDirPath() + "/Documents/application/zsafe", 1321 QDir::homeDirPath() + "/Documents/application/zsafe",
1304 QString::null, 1322 QString::null,
1305 mimeTypes, 1323 mimeTypes,
1306 this, 1324 this,
1307 tr ("Export text file")); 1325 tr ("Export text file"));
1308#else 1326#else
1309 QString fn = ScQtFileEdit::getSaveAsFileName(this, 1327 QString fn = ScQtFileEdit::getSaveAsFileName(this,
1310 tr ("Export text file"), 1328 tr ("Export text file"),
1311 QDir::homeDirPath() + "/Documents/application/zsafe", 1329 QDir::homeDirPath() + "/Documents/application/zsafe",
1312 "*.txt"); 1330 "*.txt");
1313#endif 1331#endif
1314#else 1332#else
1315 QString fn = QFileDialog::getSaveFileName( 1333 QString fn = QFileDialog::getSaveFileName(
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 {
1341 // step through all subitems 1363 // step through all subitems
1342 QListViewItem *si; 1364 QListViewItem *si;
1343 for (si = i->firstChild(); 1365 for (si = i->firstChild();
1344 si != NULL; 1366 si != NULL;
1345 si = si->nextSibling()) 1367 si = si->nextSibling())
1346 { 1368 {
1347 QString oneEntry; 1369 QString oneEntry;
1348 oneEntry += "\""; 1370 oneEntry += "\"";
1349 oneEntry += i->text(0); 1371 oneEntry += i->text(0);
1350 oneEntry += "\";"; 1372 oneEntry += "\";";
1351 oneEntry += "\""; 1373 oneEntry += "\"";
1352 oneEntry += si->text(0); 1374 oneEntry += si->text(0);
1353 oneEntry += "\";"; 1375 oneEntry += "\";";
1354 oneEntry += "\""; 1376 oneEntry += "\"";
1355 oneEntry += si->text(1); 1377 oneEntry += si->text(1);
1356 oneEntry += "\";"; 1378 oneEntry += "\";";
1357 oneEntry += "\""; 1379 oneEntry += "\"";
1358 oneEntry += si->text(2); 1380 oneEntry += si->text(2);
1359 oneEntry += "\";"; 1381 oneEntry += "\";";
1360 oneEntry += "\""; 1382 oneEntry += "\"";
1361 QString comment = si->text(3); 1383 QString comment = si->text(3);
1362 comment.replace (QRegExp("\n"), "<br>"); 1384 comment.replace (QRegExp("\n"), "<br>");
1363 oneEntry += comment; 1385 oneEntry += comment;
1364 oneEntry += "\";"; 1386 oneEntry += "\";";
1365 oneEntry += "\""; 1387 oneEntry += "\"";
1366 oneEntry += si->text(4); 1388 oneEntry += si->text(4);
1367 oneEntry += "\";"; 1389 oneEntry += "\";";
1368 oneEntry += "\""; 1390 oneEntry += "\"";
1369 oneEntry += si->text(5); 1391 oneEntry += si->text(5);
1370 oneEntry += "\""; 1392 oneEntry += "\"";
1371 // owarn << oneEntry << oendl; 1393 // owarn << oneEntry << oendl;
1372 t << oneEntry << endl; 1394 t << oneEntry << endl;
1373 1395
1374 // owarn << si->text(0) << oendl; 1396 // owarn << si->text(0) << oendl;
1375 } 1397 }
1376 } 1398 }
1377 f.close(); 1399 f.close();
1378 } 1400 }
1379} 1401}
1380 1402
1381void ZSafe::readAllEntries() 1403void ZSafe::readAllEntries()
1382{ 1404{
1383 if (filename.isEmpty()) 1405 if (filename.isEmpty())
1384 { 1406 {
1385 QMessageBox::critical( 0, tr("ZSafe"), 1407 QMessageBox::critical( 0, tr("ZSafe"),
1386 tr("No document defined.\nYou have to create a new document")); 1408 tr("No document defined.\nYou have to create a new document"));
1387 return; 1409 return;
1388 } 1410 }
1389 1411
1390 // open the file dialog 1412 // open the file dialog
1391#ifndef DESKTOP 1413#ifndef DESKTOP
1392#ifndef NO_OPIE 1414#ifndef NO_OPIE
1393 QMap<QString, QStringList> mimeTypes; 1415 QMap<QString, QStringList> mimeTypes;
1394 mimeTypes.insert(tr("All"), QStringList() ); 1416 mimeTypes.insert(tr("All"), QStringList() );
1395 mimeTypes.insert(tr("Text"), "text/*" ); 1417 mimeTypes.insert(tr("Text"), "text/*" );
1396 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 1418 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
1397 QDir::homeDirPath() + "/Documents/application/zsafe", 1419 QDir::homeDirPath() + "/Documents/application/zsafe",
1398 QString::null, 1420 QString::null,
1399 mimeTypes, 1421 mimeTypes,
1400 this, 1422 this,
1401 tr ("Import text file")); 1423 tr ("Import text file"));
1402#else 1424#else
1403 QString fn = ScQtFileEdit::getOpenFileName(this, 1425 QString fn = ScQtFileEdit::getOpenFileName(this,
1404 tr ("Import text file"), 1426 tr ("Import text file"),
1405 QDir::homeDirPath() + "/Documents/application/zsafe", 1427 QDir::homeDirPath() + "/Documents/application/zsafe",
1406 "*.txt"); 1428 "*.txt");
1407#endif 1429#endif
1408#else 1430#else
1409 QString fn = QFileDialog::getOpenFileName( 1431 QString fn = QFileDialog::getOpenFileName(
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();
1435 i != NULL; 1461 i != NULL;
1436 i = i->nextSibling()) 1462 i = i->nextSibling())
1437 { 1463 {
1438 // step through all subitems 1464 // step through all subitems
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
1465 1495
1466 /* modify QString -> QCString::utf8 */ 1496 /* modify QString -> QCString::utf8 */
1467 1497
1468 strcpy (buffer, s.utf8()); 1498 strcpy (buffer, s.utf8());
1469 1499
1470 QString name; 1500 QString name;
1471 QString user; 1501 QString user;
1472 QString password; 1502 QString password;
1473 QString comment; 1503 QString comment;
1474 QString field5=""; 1504 QString field5="";
1475 QString field6=""; 1505 QString field6="";
1476 1506
1477 // separete the entries 1507 // separete the entries
1478 char *i = strtok (buffer, "|"); 1508 char *i = strtok (buffer, "|");
1479 QString category(QString::fromUtf8(&i[1])); 1509 QString category(QString::fromUtf8(&i[1]));
1480 category.truncate(category.length() -1); 1510 category.truncate(category.length() -1);
1481 1511
1482 int idx=0; 1512 int idx=0;
1483 while ((i = strtok (NULL, "|")) != NULL) 1513 while ((i = strtok (NULL, "|")) != NULL)
1484 { 1514 {
1485 switch (idx) 1515 switch (idx)
1486 { 1516 {
1487 case 0: 1517 case 0:
1488 name = QString::fromUtf8(&i[1]); 1518 name = QString::fromUtf8(&i[1]);
1489 name.truncate(name.length() -1); 1519 name.truncate(name.length() -1);
1490 // name 1520 // name
1491 break; 1521 break;
1492 case 1: 1522 case 1:
1493 // user 1523 // user
1494 user = QString::fromUtf8(&i[1]); 1524 user = QString::fromUtf8(&i[1]);
1495 user.truncate(user.length() -1); 1525 user.truncate(user.length() -1);
1496 break; 1526 break;
1497 case 2: 1527 case 2:
1498 // password 1528 // password
1499 password = QString::fromUtf8(&i[1]); 1529 password = QString::fromUtf8(&i[1]);
1500 password.truncate(password.length() -1); 1530 password.truncate(password.length() -1);
@@ -1550,184 +1580,202 @@ void ZSafe::readAllEntries()
1550 catI->setOpen( TRUE ); 1580 catI->setOpen( TRUE );
1551 1581
1552 Category *c1 = new Category(); 1582 Category *c1 = new Category();
1553 c1->setCategoryName(category); 1583 c1->setCategoryName(category);
1554 1584
1555 QString icon; 1585 QString icon;
1556 QString fullIconPath; 1586 QString fullIconPath;
1557 QPixmap *pix; 1587 QPixmap *pix;
1558// #ifndef WIN32 1588// #ifndef WIN32
1559 icon = conf->readEntry(APP_KEY+category); 1589 icon = conf->readEntry(APP_KEY+category);
1560// #endif 1590// #endif
1561 bool isIconAv = false; 1591 bool isIconAv = false;
1562 if (!icon.isEmpty() && !icon.isNull()) 1592 if (!icon.isEmpty() && !icon.isNull())
1563 { 1593 {
1564 // build the full path 1594 // build the full path
1565 fullIconPath = iconPath + icon; 1595 fullIconPath = iconPath + icon;
1566 pix = new QPixmap (fullIconPath); 1596 pix = new QPixmap (fullIconPath);
1567 if (!pix->isNull()) 1597 if (!pix->isNull())
1568 { 1598 {
1569 QImage img = pix->convertToImage(); 1599 QImage img = pix->convertToImage();
1570 pix->convertFromImage(img.smoothScale(14,14)); 1600 pix->convertFromImage(img.smoothScale(14,14));
1571 c1->setIconName (icon); 1601 c1->setIconName (icon);
1572 c1->setIcon (*pix); 1602 c1->setIcon (*pix);
1573 isIconAv = true; 1603 isIconAv = true;
1574 } 1604 }
1575 } 1605 }
1576 if (!isIconAv) 1606 if (!isIconAv)
1577 { 1607 {
1578 c1->setIcon (*getPredefinedIcon(category)); 1608 c1->setIcon (*getPredefinedIcon(category));
1579 } 1609 }
1580 c1->setListItem (catI); 1610 c1->setListItem (catI);
1581 c1->initListItem(); 1611 c1->initListItem();
1582 categories.insert (c1->getCategoryName(), c1); 1612 categories.insert (c1->getCategoryName(), c1);
1583 } 1613 }
1584 1614
1585 } 1615 }
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 {
1615 // step through all subitems 1656 // step through all subitems
1616 QListViewItem *si; 1657 QListViewItem *si;
1617 for (si = i->firstChild(); 1658 for (si = i->firstChild();
1618 si != NULL; 1659 si != NULL;
1619 si = si->nextSibling()) 1660 si = si->nextSibling())
1620 { 1661 {
1621 QString oneEntry; 1662 QString oneEntry;
1622 oneEntry += "\""; 1663 oneEntry += "\"";
1623 oneEntry += i->text(0); 1664 oneEntry += i->text(0);
1624 oneEntry += "\";"; 1665 oneEntry += "\";";
1625 oneEntry += "\""; 1666 oneEntry += "\"";
1626 oneEntry += si->text(0); 1667 oneEntry += si->text(0);
1627 oneEntry += "\";"; 1668 oneEntry += "\";";
1628 oneEntry += "\""; 1669 oneEntry += "\"";
1629 oneEntry += si->text(1); 1670 oneEntry += si->text(1);
1630 oneEntry += "\";"; 1671 oneEntry += "\";";
1631 oneEntry += "\""; 1672 oneEntry += "\"";
1632 oneEntry += si->text(2); 1673 oneEntry += si->text(2);
1633 oneEntry += "\";"; 1674 oneEntry += "\";";
1634 oneEntry += "\""; 1675 oneEntry += "\"";
1635 // oneEntry += si->text(3); 1676 // oneEntry += si->text(3);
1636 QString comment = si->text(3); 1677 QString comment = si->text(3);
1637 comment.replace (QRegExp("\n"), "<br>"); 1678 comment.replace (QRegExp("\n"), "<br>");
1638 oneEntry += comment; 1679 oneEntry += comment;
1639 oneEntry += "\""; 1680 oneEntry += "\"";
1640 // owarn << oneEntry << oendl; 1681 // owarn << oneEntry << oendl;
1641 t << oneEntry << endl; 1682 t << oneEntry << endl;
1642 1683
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();
1668 i != NULL; 1713 i != NULL;
1669 i = i->nextSibling()) 1714 i = i->nextSibling())
1670 { 1715 {
1671 // step through all subitems 1716 // step through all subitems
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
1698 strcpy (buffer, s); 1746 strcpy (buffer, s);
1699 1747
1700 QString name; 1748 QString name;
1701 QString user; 1749 QString user;
1702 QString password; 1750 QString password;
1703 QString comment; 1751 QString comment;
1704 1752
1705 // separete the entries 1753 // separete the entries
1706 char *i = strtok (buffer, "|"); 1754 char *i = strtok (buffer, "|");
1707 QString category(&i[1]); 1755 QString category(&i[1]);
1708 category.truncate(category.length() -1); 1756 category.truncate(category.length() -1);
1709 1757
1710 int idx=0; 1758 int idx=0;
1711 while (i = strtok (NULL, "|")) 1759 while (i = strtok (NULL, "|"))
1712 { 1760 {
1713 switch (idx) 1761 switch (idx)
1714 { 1762 {
1715 case 0: 1763 case 0:
1716 name = &i[1]; 1764 name = &i[1];
1717 name.truncate(name.length() -1); 1765 name.truncate(name.length() -1);
1718 // name 1766 // name
1719 break; 1767 break;
1720 case 1: 1768 case 1:
1721 // user 1769 // user
1722 user = &i[1]; 1770 user = &i[1];
1723 user.truncate(user.length() -1); 1771 user.truncate(user.length() -1);
1724 break; 1772 break;
1725 case 2: 1773 case 2:
1726 // password 1774 // password
1727 password = &i[1]; 1775 password = &i[1];
1728 password.truncate(password.length() -1); 1776 password.truncate(password.length() -1);
1729 break; 1777 break;
1730 case 3: 1778 case 3:
1731 // comment 1779 // comment
1732 comment = &i[1]; 1780 comment = &i[1];
1733 comment.truncate(comment.length() -1); 1781 comment.truncate(comment.length() -1);
@@ -1760,166 +1808,176 @@ void ZSafe::readAllEntries()
1760 item->setText( 0, tr( name ) ); 1808 item->setText( 0, tr( name ) );
1761 item->setText( 1, tr( user ) ); 1809 item->setText( 1, tr( user ) );
1762 item->setText( 2, tr( password ) ); 1810 item->setText( 2, tr( password ) );
1763 item->setText( 3, tr( comment ) ); 1811 item->setText( 3, tr( comment ) );
1764 1812
1765 catI->setOpen( TRUE ); 1813 catI->setOpen( TRUE );
1766 1814
1767 Category *c1 = new Category(); 1815 Category *c1 = new Category();
1768 c1->setCategoryName(category); 1816 c1->setCategoryName(category);
1769 1817
1770 QString icon; 1818 QString icon;
1771 QString fullIconPath; 1819 QString fullIconPath;
1772 QPixmap *pix; 1820 QPixmap *pix;
1773// #ifndef WIN32 1821// #ifndef WIN32
1774 icon = conf->readEntry(APP_KEY+category); 1822 icon = conf->readEntry(APP_KEY+category);
1775// #endif 1823// #endif
1776 bool isIconAv = false; 1824 bool isIconAv = false;
1777 if (!icon.isEmpty() && !icon.isNull()) 1825 if (!icon.isEmpty() && !icon.isNull())
1778 { 1826 {
1779 // build the full path 1827 // build the full path
1780 fullIconPath = iconPath + icon; 1828 fullIconPath = iconPath + icon;
1781 pix = new QPixmap (fullIconPath); 1829 pix = new QPixmap (fullIconPath);
1782 if (!pix->isNull()) 1830 if (!pix->isNull())
1783 { 1831 {
1784 QImage img = pix->convertToImage(); 1832 QImage img = pix->convertToImage();
1785 pix->convertFromImage(img.smoothScale(14,14)); 1833 pix->convertFromImage(img.smoothScale(14,14));
1786 c1->setIconName (icon); 1834 c1->setIconName (icon);
1787 c1->setIcon (*pix); 1835 c1->setIcon (*pix);
1788 isIconAv = true; 1836 isIconAv = true;
1789 } 1837 }
1790 } 1838 }
1791 if (!isIconAv) 1839 if (!isIconAv)
1792 { 1840 {
1793 c1->setIcon (*getPredefinedIcon(category)); 1841 c1->setIcon (*getPredefinedIcon(category));
1794 } 1842 }
1795 c1->setListItem (catI); 1843 c1->setListItem (catI);
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();
1822 i != NULL; 1872 i != NULL;
1823 i = i->nextSibling()) 1873 i = i->nextSibling())
1824 { 1874 {
1825 // step through all subitems 1875 // step through all subitems
1826 QListViewItem *si; 1876 QListViewItem *si;
1827 for (si = i->firstChild(); 1877 for (si = i->firstChild();
1828 si != NULL; ) 1878 si != NULL; )
1829 { 1879 {
1830 QListViewItem *_si = si; 1880 QListViewItem *_si = si;
1831 si = si->nextSibling(); 1881 si = si->nextSibling();
1832 i->takeItem(_si); // remove from view list 1882 i->takeItem(_si); // remove from view list
1833 if (_si) delete _si; 1883 if (_si) delete _si;
1834 } 1884 }
1835 } 1885 }
1836 1886
1837 // ask for password and read again 1887 // ask for password and read again
1838 openDocument(filename); 1888 openDocument(filename);
1839 } 1889 }
1840} 1890}
1841 1891
1842//--------------------------------------------- 1892//---------------------------------------------
1843 1893
1844 1894
1845bool ZSafe::openDocument(const char* _filename, const char* ) 1895bool ZSafe::openDocument(const char* _filename, const char* )
1846{ 1896{
1847 int retval; 1897 int retval;
1848 char* entry[FIELD_SIZE]; 1898 char* entry[FIELD_SIZE];
1849// #ifndef WIN32 1899// #ifndef WIN32
1850 int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); 1900 int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1);
1851// #else 1901// #else
1852 // int validationFlag = 1; 1902 // int validationFlag = 1;
1853// #endif 1903// #endif
1854 1904
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 }
1890 1948
1891 1949
1892 // load the validation entry 1950 // load the validation entry
1893 if (validationFlag == 0) 1951 if (validationFlag == 0)
1894 { 1952 {
1895 pwdOk = 1; 1953 pwdOk = 1;
1896 break; 1954 break;
1897 } 1955 }
1898 1956
1899 retval = loadEntry(entry); 1957 retval = loadEntry(entry);
1900 if (retval == 1 && 1958 if (retval == 1 &&
1901 !strcmp (entry[0], "ZSAFECATEGORY") && 1959 !strcmp (entry[0], "ZSAFECATEGORY") &&
1902 !strcmp (entry[1], "name") && 1960 !strcmp (entry[1], "name") &&
1903 !strcmp (entry[2], "username") && 1961 !strcmp (entry[2], "username") &&
1904 !strcmp (entry[3], "password") && 1962 !strcmp (entry[3], "password") &&
1905 !strcmp (entry[4], "comment") ) 1963 !strcmp (entry[4], "comment") )
1906 { 1964 {
1907 for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); 1965 for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
1908 pwdOk = 1; 1966 pwdOk = 1;
1909 break; 1967 break;
1910 } 1968 }
1911 else 1969 else
1912 // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); 1970 // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
1913 fclose (fd); 1971 fclose (fd);
1914 m_password = ""; 1972 m_password = "";
1915 1973
1916 if (i < numberOfTries - 1) 1974 if (i < numberOfTries - 1)
1917 { 1975 {
1918 switch( QMessageBox::warning( this, tr("ZSafe"), 1976 switch( QMessageBox::warning( this, tr("ZSafe"),
1919 tr("Wrong password.\nEnter again?"), 1977 tr("Wrong password.\nEnter again?"),
1920 tr("&Yes"), tr("&No."), 1978 tr("&Yes"), tr("&No."),
1921 0 1979 0
1922 ) ) 1980 ) )
1923 { 1981 {
1924 case 1: // No 1982 case 1: // No
1925 exitZs (1); 1983 exitZs (1);
@@ -2228,172 +2286,186 @@ bool ZSafe::saveDocument(const char* _filename,
2228 tr("&Save"), 2286 tr("&Save"),
2229 tr("&Don't Save"), 2287 tr("&Don't Save"),
2230 0 // Enter == button 0 2288 0 // Enter == button 0
2231 ) ) 2289 ) )
2232 { // Escape == button 2 2290 { // Escape == button 2
2233 case 0: // Save clicked, Alt-S or Enter pressed. 2291 case 0: // Save clicked, Alt-S or Enter pressed.
2234 modified = false; 2292 modified = false;
2235 break; 2293 break;
2236 case 1: // Don't Save clicked or Alt-D pressed 2294 case 1: // Don't Save clicked or Alt-D pressed
2237 modified = false; 2295 modified = false;
2238 return true; 2296 return true;
2239 } 2297 }
2240 } 2298 }
2241 modified = false; 2299 modified = false;
2242 2300
2243 if (m_password.isEmpty()) 2301 if (m_password.isEmpty())
2244 return false; 2302 return false;
2245 2303
2246 int retval = saveInit(_filename, m_password); 2304 int retval = saveInit(_filename, m_password);
2247 // int retval = saveInit(_filename, "test"); 2305 // int retval = saveInit(_filename, "test");
2248 if (retval != PWERR_GOOD) { 2306 if (retval != PWERR_GOOD) {
2249 return false; 2307 return false;
2250 } 2308 }
2251 2309
2252 char* entry[FIELD_SIZE]; 2310 char* entry[FIELD_SIZE];
2253 2311
2254 // save the validation entry 2312 // save the validation entry
2255 { 2313 {
2256 int i=0; 2314 int i=0;
2257 entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); 2315 entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1);
2258 strcpy(entry[i++], "ZSAFECATEGORY"); 2316 strcpy(entry[i++], "ZSAFECATEGORY");
2259 entry[i] = (char*)malloc(strlen("name")+1); 2317 entry[i] = (char*)malloc(strlen("name")+1);
2260 strcpy(entry[i++], "name"); 2318 strcpy(entry[i++], "name");
2261 entry[i] = (char*)malloc(strlen("username")+1); 2319 entry[i] = (char*)malloc(strlen("username")+1);
2262 strcpy(entry[i++], "username"); 2320 strcpy(entry[i++], "username");
2263 entry[i] = (char*)malloc(strlen("password")+1); 2321 entry[i] = (char*)malloc(strlen("password")+1);
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();
2289 i != NULL; 2351 i != NULL;
2290 i = i->nextSibling()) 2352 i = i->nextSibling())
2291 { 2353 {
2292 // step through all subitems 2354 // step through all subitems
2293 QListViewItem *si; 2355 QListViewItem *si;
2294 for (si = i->firstChild(); 2356 for (si = i->firstChild();
2295 si != NULL; 2357 si != NULL;
2296 si = si->nextSibling()) 2358 si = si->nextSibling())
2297 { 2359 {
2298 int j=0; 2360 int j=0;
2299 entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); 2361 entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1);
2300 strcpy(entry[j++], i->text(0).utf8()); 2362 strcpy(entry[j++], i->text(0).utf8());
2301 entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); 2363 entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1);
2302 strcpy(entry[j++], si->text(0).utf8()); 2364 strcpy(entry[j++], si->text(0).utf8());
2303 entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); 2365 entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1);
2304 strcpy(entry[j++], si->text(1).utf8()); 2366 strcpy(entry[j++], si->text(1).utf8());
2305 entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); 2367 entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1);
2306 strcpy(entry[j++], si->text(2).utf8()); 2368 strcpy(entry[j++], si->text(2).utf8());
2307 entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); 2369 entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1);
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 ('/');
2364 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 2436 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
2365#ifdef WIN32 2437#ifdef WIN32
2366 dialog->setCaption("Qt " + ti); 2438 dialog->setCaption("Qt " + ti);
2367#else 2439#else
2368 dialog->setCaption(ti); 2440 dialog->setCaption(ti);
2369#endif 2441#endif
2370 // dialog->setCaption(title); 2442 // dialog->setCaption(title);
2371 2443
2372 dialog->PasswordField->setFocus(); 2444 dialog->PasswordField->setFocus();
2373 DialogCode result = (DialogCode) dialog->exec(); 2445 DialogCode result = (DialogCode) dialog->exec();
2374#ifdef DESKTOP 2446#ifdef DESKTOP
2375 result = Accepted; 2447 result = Accepted;
2376#endif 2448#endif
2377 2449
2378 QString password; 2450 QString password;
2379 if (result == Accepted || newPwdDialogResult) 2451 if (result == Accepted || newPwdDialogResult)
2380 { 2452 {
2381 m_password = dialog->PasswordField->text(); 2453 m_password = dialog->PasswordField->text();
2382 } 2454 }
2383 else 2455 else
2384 { 2456 {
2385 exitZs (1); 2457 exitZs (1);
2386 } 2458 }
2387} 2459}
2388 2460
2389int ZSafe::saveInit(const char *_filename, const char *password) 2461int ZSafe::saveInit(const char *_filename, const char *password)
2390{ 2462{
2391 char key[128]; 2463 char key[128];
2392 unsigned int j = 0; 2464 unsigned int j = 0;
2393 unsigned int keylength; 2465 unsigned int keylength;
2394 // int val; 2466 // int val;
2395 int count2; 2467 int count2;
2396 Krc2* krc2 = new Krc2(); 2468 Krc2* krc2 = new Krc2();
2397 2469
2398 /* first we should check the permissions of the filename */ 2470 /* first we should check the permissions of the filename */
2399/* 2471/*
@@ -2484,98 +2556,100 @@ int ZSafe::saveEntry(char *entry[FIELD_SIZE])
2484 2556
2485 /* reset the buffer index */ 2557 /* reset the buffer index */
2486 bufferIndex = 0; 2558 bufferIndex = 0;
2487 if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; 2559 if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA;
2488 if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; 2560 if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA;
2489 } /*for (count3 = 0; count3 < 5; count3++)*/ 2561 } /*for (count3 = 0; count3 < 5; count3++)*/
2490 } /*if (bufferIndex == 5)*/ 2562 } /*if (bufferIndex == 5)*/
2491 /* increment a short, not a byte */ 2563 /* increment a short, not a byte */
2492 count2 += 2; 2564 count2 += 2;
2493 } /*while (count2 < strlen (buffer))*/ 2565 } /*while (count2 < strlen (buffer))*/
2494 int ret = PWERR_GOOD; 2566 int ret = PWERR_GOOD;
2495 return ret; 2567 return ret;
2496} 2568}
2497 2569
2498int ZSafe::saveFinalize(void) 2570int ZSafe::saveFinalize(void)
2499{ 2571{
2500 int count1, retval = PWERR_GOOD; 2572 int count1, retval = PWERR_GOOD;
2501 unsigned short ciphertext[4]; 2573 unsigned short ciphertext[4];
2502 Krc2* krc2 = new Krc2(); 2574 Krc2* krc2 = new Krc2();
2503 2575
2504 /* Tack on the PKCS 5 padding 2576 /* Tack on the PKCS 5 padding
2505 * How it works is we fill up the last n bytes with the value n 2577 * How it works is we fill up the last n bytes with the value n
2506 * 2578 *
2507 * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left 2579 * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left
2508 * over, leaving us 3 short, so we fill it in with 3's. 2580 * over, leaving us 3 short, so we fill it in with 3's.
2509 * 2581 *
2510 * If we come out even, we fill it with 8 8s 2582 * If we come out even, we fill it with 8 8s
2511 * 2583 *
2512 * um, except that in this instance we are using 4 shorts instead of 8 bytes. 2584 * um, except that in this instance we are using 4 shorts instead of 8 bytes.
2513 * so, half everything 2585 * so, half everything
2514 */ 2586 */
2515 for (count1 = bufferIndex; count1 < 4; count1++) { 2587 for (count1 = bufferIndex; count1 < 4; count1++) {
2516 plaintext[count1] = (4 - bufferIndex); 2588 plaintext[count1] = (4 - bufferIndex);
2517 } 2589 }
2518 krc2->rc2_encrypt (plaintext); 2590 krc2->rc2_encrypt (plaintext);
2519 for (count1 = 0; count1 < 4; count1++) { 2591 for (count1 = 0; count1 < 4; count1++) {
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
2546 modified = false; 2620 modified = false;
2547 saveDocument(filename, FALSE); 2621 saveDocument(filename, FALSE);
2548 exitZs (1); 2622 exitZs (1);
2549 break; 2623 break;
2550 case 1: // 2624 case 1: //
2551 // Save with new password 2625 // Save with new password
2552 modified = false; 2626 modified = false;
2553 saveDocument(filename, TRUE); 2627 saveDocument(filename, TRUE);
2554 exitZs (1); 2628 exitZs (1);
2555 break; 2629 break;
2556 case 2: // Don't Save clicked or Alt-D pressed 2630 case 2: // Don't Save clicked or Alt-D pressed
2557 // don't save but exitZs 2631 // don't save but exitZs
2558 exitZs (1); 2632 exitZs (1);
2559 break; 2633 break;
2560 } 2634 }
2561 } 2635 }
2562 exitZs (1); 2636 exitZs (1);
2563 2637
2564} 2638}
2565 2639
2566void ZSafe::categoryFieldActivated( const QString& category) 2640void ZSafe::categoryFieldActivated( const QString& category)
2567{ 2641{
2568 if (categoryDialog) 2642 if (categoryDialog)
2569 setCategoryDialogFields(categoryDialog, category); 2643 setCategoryDialogFields(categoryDialog, category);
2570} 2644}
2571 2645
2572void ZSafe::addCategory() 2646void ZSafe::addCategory()
2573{ 2647{
2574 if (filename.isEmpty()) 2648 if (filename.isEmpty())
2575 { 2649 {
2576 QMessageBox::critical( 0, tr("ZSafe"), 2650 QMessageBox::critical( 0, tr("ZSafe"),
2577 tr("No document defined.\nYou have to create a new document")); 2651 tr("No document defined.\nYou have to create a new document"));
2578 return; 2652 return;
2579 } 2653 }
2580 else 2654 else
2581 { 2655 {
@@ -2688,98 +2762,100 @@ void ZSafe::addCategory()
2688 d.setFilter( QDir::Files); 2762 d.setFilter( QDir::Files);
2689 2763
2690 const QFileInfoList *list = d.entryInfoList(); 2764 const QFileInfoList *list = d.entryInfoList();
2691 QFileInfoListIterator it( *list ); // create list iterator 2765 QFileInfoListIterator it( *list ); // create list iterator
2692 QFileInfo *fi; // pointer for traversing 2766 QFileInfo *fi; // pointer for traversing
2693 2767
2694 dialog->IconField->insertItem("predefined"); 2768 dialog->IconField->insertItem("predefined");
2695 while ( (fi=it.current()) ) { // for each file... 2769 while ( (fi=it.current()) ) { // for each file...
2696 QString fileName = fi->fileName(); 2770 QString fileName = fi->fileName();
2697 if(fileName.right(4) == ".png"){ 2771 if(fileName.right(4) == ".png"){
2698 fileName = fileName.mid(0,fileName.length()-4); 2772 fileName = fileName.mid(0,fileName.length()-4);
2699#ifdef DESKTOP 2773#ifdef DESKTOP
2700 QPixmap imageOfFile; 2774 QPixmap imageOfFile;
2701 imageOfFile.load(iconPath + fi->fileName()); 2775 imageOfFile.load(iconPath + fi->fileName());
2702#else 2776#else
2703 QPixmap imageOfFile(Resource::loadPixmap(fileName)); 2777 QPixmap imageOfFile(Resource::loadPixmap(fileName));
2704#endif 2778#endif
2705 QImage foo = imageOfFile.convertToImage(); 2779 QImage foo = imageOfFile.convertToImage();
2706 foo = foo.smoothScale(16,16); 2780 foo = foo.smoothScale(16,16);
2707 imageOfFile.convertFromImage(foo); 2781 imageOfFile.convertFromImage(foo);
2708 dialog->IconField->insertItem(imageOfFile,fileName); 2782 dialog->IconField->insertItem(imageOfFile,fileName);
2709 } 2783 }
2710 ++it; 2784 ++it;
2711 } 2785 }
2712 waitDialog.hide(); 2786 waitDialog.hide();
2713 } 2787 }
2714 2788
2715#ifndef WIN32 2789#ifndef WIN32
2716 dialog->show(); 2790 dialog->show();
2717#endif 2791#endif
2718#ifndef DESKTOP 2792#ifndef DESKTOP
2719 // dialog->move (20, 100); 2793 // dialog->move (20, 100);
2720#endif 2794#endif
2721 DialogCode result = (DialogCode) dialog->exec(); 2795 DialogCode result = (DialogCode) dialog->exec();
2722#ifdef DESKTOP 2796#ifdef DESKTOP
2723 result = Accepted; 2797 result = Accepted;
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())
2750 { 2826 {
2751 // save the full pixmap name into the config file 2827 // save the full pixmap name into the config file
2752// #ifndef WIN32 2828// #ifndef WIN32
2753 conf->writeEntry(APP_KEY+category, icon); 2829 conf->writeEntry(APP_KEY+category, icon);
2754// #endif 2830// #endif
2755 saveConf(); 2831 saveConf();
2756 QImage img = pix->convertToImage(); 2832 QImage img = pix->convertToImage();
2757 pix->convertFromImage(img.smoothScale(14,14)); 2833 pix->convertFromImage(img.smoothScale(14,14));
2758 c1->setIcon (*pix); 2834 c1->setIcon (*pix);
2759 c1->setIconName(icon); 2835 c1->setIconName(icon);
2760 } 2836 }
2761 else 2837 else
2762 { 2838 {
2763 QPixmap folder( ( const char** ) general_data ); 2839 QPixmap folder( ( const char** ) general_data );
2764 c1->setIcon (folder); 2840 c1->setIcon (folder);
2765 } 2841 }
2766 } 2842 }
2767 else 2843 else
2768 { 2844 {
2769 c1->setIcon (*getPredefinedIcon(category)); 2845 c1->setIcon (*getPredefinedIcon(category));
2770 } 2846 }
2771 2847
2772 c1->setListItem (li); 2848 c1->setListItem (li);
2773 c1->initListItem(); 2849 c1->initListItem();
2774 categories.insert (c1->getCategoryName(), c1); 2850 categories.insert (c1->getCategoryName(), c1);
2775 2851
2776 saveCategoryDialogFields(dialog); 2852 saveCategoryDialogFields(dialog);
2777 } 2853 }
2778 else 2854 else
2779 { 2855 {
2780 // delete dialog; 2856 // delete dialog;
2781 dialog->hide(); 2857 dialog->hide();
2782 return; 2858 return;
2783 } 2859 }
2784 2860
2785 } 2861 }
@@ -3162,131 +3238,139 @@ void ZSafe::editCategory()
3162 while ( (fi=it.current()) ) 3238 while ( (fi=it.current()) )
3163 { // for each file... 3239 { // for each file...
3164 QString fileName = fi->fileName(); 3240 QString fileName = fi->fileName();
3165 if(fileName.right(4) == ".png") 3241 if(fileName.right(4) == ".png")
3166 { 3242 {
3167 fileName = fileName.mid(0,fileName.length()-4); 3243 fileName = fileName.mid(0,fileName.length()-4);
3168 3244
3169 3245
3170 if(fileName+".png"==icon) 3246 if(fileName+".png"==icon)
3171 { 3247 {
3172 dialog->IconField->setCurrentItem(i+1); 3248 dialog->IconField->setCurrentItem(i+1);
3173 break; 3249 break;
3174 } 3250 }
3175 ++i; 3251 ++i;
3176 } 3252 }
3177 ++it; 3253 ++it;
3178 } 3254 }
3179 } 3255 }
3180 } 3256 }
3181 3257
3182 // dialog->show(); 3258 // dialog->show();
3183#ifndef DESKTOP 3259#ifndef DESKTOP
3184 // dialog->move (20, 100); 3260 // dialog->move (20, 100);
3185#endif 3261#endif
3186 DialogCode result = (DialogCode) dialog->exec(); 3262 DialogCode result = (DialogCode) dialog->exec();
3187#ifdef DESKTOP 3263#ifdef DESKTOP
3188 result = Accepted; 3264 result = Accepted;
3189#endif 3265#endif
3190 3266
3191 QString fullIconPath; 3267 QString fullIconPath;
3192 QPixmap *pix; 3268 QPixmap *pix;
3193 if (result == Accepted) 3269 if (result == Accepted)
3194 { 3270 {
3195 modified = true; 3271 modified = true;
3196 if (category != dialog->CategoryField->currentText()) 3272 if (category != dialog->CategoryField->currentText())
3197 { 3273 {
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
3224 saveConf(); 3304 saveConf();
3225 QImage img = pix->convertToImage(); 3305 QImage img = pix->convertToImage();
3226 pix->convertFromImage(img.smoothScale(14,14)); 3306 pix->convertFromImage(img.smoothScale(14,14));
3227 cat->setIconName (icon); 3307 cat->setIconName (icon);
3228 cat->setIcon (*pix); 3308 cat->setIcon (*pix);
3229 } 3309 }
3230 } 3310 }
3231 else 3311 else
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;
3257 dialog->hide(); 3341 dialog->hide();
3258 return; 3342 return;
3259 } 3343 }
3260 3344
3261 } 3345 }
3262} 3346}
3263 3347
3264void ZSafe::cutItem() 3348void ZSafe::cutItem()
3265{ 3349{
3266 if (!selectedItem) 3350 if (!selectedItem)
3267 return; 3351 return;
3268 if (!isCategory(selectedItem)) 3352 if (!isCategory(selectedItem))
3269 { 3353 {
3270 IsCut = true; 3354 IsCut = true;
3271 copiedItem = selectedItem; 3355 copiedItem = selectedItem;
3272 } 3356 }
3273} 3357}
3274 3358
3275void ZSafe::copyItem() 3359void ZSafe::copyItem()
3276{ 3360{
3277 if (!selectedItem) 3361 if (!selectedItem)
3278 return; 3362 return;
3279 if (!isCategory(selectedItem)) 3363 if (!isCategory(selectedItem))
3280 { 3364 {
3281 IsCopy = true; 3365 IsCopy = true;
3282 copiedItem = selectedItem; 3366 copiedItem = selectedItem;
3283 } 3367 }
3284} 3368}
3285 3369
3286// paste item into category 3370// paste item into category
3287void ZSafe::pasteItem() 3371void ZSafe::pasteItem()
3288{ 3372{
3289 if (!selectedItem) 3373 if (!selectedItem)
3290 return; 3374 return;
3291 if (isCategory(selectedItem)) 3375 if (isCategory(selectedItem))
3292 { 3376 {