summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/zsafe/zsafe.cpp86
1 files changed, 85 insertions, 1 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
@@ -924,17 +924,21 @@ void ZSafe::findPwd()
QString name;
QString username;
QString comment;
if (result == Accepted)
{
name = dialog->NameField->text();
username = dialog->UsernameField->text();
comment = dialog->CommentField->text();
+#ifndef NO_OPIE
owarn << name << oendl;
+#else
+ qWarning (name);
+#endif
}
else
{
delete dialog;
return;
}
if (!name.isEmpty() && name != lastSearchedName ||
@@ -970,48 +974,58 @@ void ZSafe::findPwd()
if (lastSearchedCategory)
i = lastSearchedCategory;
else
i = ListView->firstChild();
for (;
i != NULL;
i = i->nextSibling())
{
+#ifndef NO_OPIE
owarn << i->text(0) << oendl;
+#endif
i->setSelected(FALSE);
// step through all subitems
QListViewItem *si;
if (lastSearchedItem)
si = lastSearchedItem;
else
si = i->firstChild();
// for (si = i->firstChild();
for (;
si != NULL;
si = si->nextSibling())
{
+#ifndef NO_OPIE
owarn << si->text(0) << oendl;
+#else
+ qWarning (si->text(0));
+#endif
if (si->isSelected())
si->setSelected(FALSE);
// ListView->repaintItem(si);
bool n=TRUE;
bool u=TRUE;
bool c=TRUE;
if (!name.isEmpty())
n = (si->text(0)).contains (name, FALSE);
if (!username.isEmpty())
u = (si->text(1)).contains (username, FALSE);
if (!comment.isEmpty())
c = (si->text(3)).contains (comment, FALSE);
if ((n && u && c ) && !found)
{
+#ifndef NO_OPIE
owarn << "Found" << oendl;
+#else
+ qWarning ("Found");
+#endif
selectedItem = si;
si->setSelected(TRUE);
ListView->setCurrentItem(si);
ListView->ensureItemVisible(si);
ListView->triggerUpdate();
lastSearchedCategory = i;
// set to the next item
@@ -1271,17 +1285,21 @@ void ZSafe::removeAsciiFile()
"Choose a text file" );
#endif
if (fn && fn.length() > 0 )
{
QFile f( fn );
if ( !f.remove() )
{
+#ifndef NO_OPIE
owarn << "Could not remove file " << fn << oendl;
+#else
+ qWarning( QString("Could not remove file %1").arg(fn),2000 );
+#endif
QMessageBox::critical( 0, tr("ZSafe"),
tr("Could not remove text file.") );
return;
}
}
}
void ZSafe::writeAllEntries()
@@ -1320,17 +1338,21 @@ void ZSafe::writeAllEntries()
"Choose a text file" );
#endif
// open the new document
if (fn && fn.length() > 0 )
{
QFile f( fn );
if ( !f.open( IO_WriteOnly ) ) {
+#ifndef NO_OPIE
owarn << "Could not write to file " << fn << oendl;
+#else
+ qWarning( QString("Could not write to file %1").arg(fn),2000 );
+#endif
QMessageBox::critical( 0, "ZSafe",
QString("Could not export to text file.") );
return;
}
QTextStream t( &f );
QListViewItem *i;
// step through all categories
@@ -1414,17 +1436,21 @@ void ZSafe::readAllEntries()
"Choose a text file" );
#endif
if (fn && fn.length() > 0 )
{
QFile f( fn );
if ( !f.open( IO_ReadOnly ) )
{
+#ifndef NO_OPIE
owarn << "Could not read file " << fn << oendl;
+#else
+ qWarning( QString("Could not read file %1").arg(fn), 2000 );
+#endif
QMessageBox::critical( 0, "ZSafe",
QString("Could not import text file.") );
return;
}
modified = true;
// clear the password list
@@ -1443,17 +1469,21 @@ void ZSafe::readAllEntries()
{
QListViewItem *_si = si;
si = si->nextSibling();
i->takeItem(_si); // remove from view list
if (_si) delete _si;
}
}
+#ifndef NO_OPIE
owarn << "ReadAllEntries(): " << oendl;
+#else
+ qWarning ("ReadAllEntries(): ");
+#endif
QTextStream t(&f);
while ( !t.eof() )
{
QString s = t.readLine();
s.replace (QRegExp("\";\""), "\"|\"");
// char buffer[1024];
#ifndef WIN32
@@ -1590,21 +1620,32 @@ void ZSafe::readAllEntries()
{
}
}
#ifdef UNUSED
void ZSafe::writeAllEntries()
{
+ if (filename.isEmpty())
+ {
+ QMessageBox::critical( 0, tr("ZSafe"),
+ tr("<P>No document defined. You have to create a new document</P>"));
+ return;
+ }
+
// open the file for writing
QString fn = filename + ".txt";
QFile f( fn );
if ( !f.open( IO_WriteOnly ) ) {
+#ifndef NO_OPIE
owarn << "Could not write to file " << fn << oendl;
+#else
+ qWarning( QString("Could not write to file %1").arg(fn), 2000 );
+#endif
QMessageBox::critical( 0, tr("ZSafe"),
tr("Could not export to text file.") );
return;
}
QTextStream t( &f );
QListViewItem *i;
// step through all categories
@@ -1647,17 +1688,21 @@ void ZSafe::writeAllEntries()
}
void ZSafe::readAllEntries()
{
QString fn = filename + ".txt";
QFile f( fn );
if ( !f.open( IO_ReadOnly ) )
{
+#ifndef NO_OPIE
owarn << "Could not read file " << fn << oendl;
+#else
+ qWarning( QString("Could not read file %1").arg(fn), 2000 );
+#endif
QMessageBox::critical( 0, tr("ZSafe"),
tr("Could not import text file.") );
return;
}
modified = true;
// clear the password list
@@ -1676,18 +1721,21 @@ void ZSafe::readAllEntries()
{
QListViewItem *_si = si;
si = si->nextSibling();
i->takeItem(_si); // remove from view list
if (_si) delete _si;
}
}
+#ifndef NO_OPIE
owarn << "ReadAllEntries(): " << oendl;
-
+#else
+ qWarning ("ReadAllEntries(): ");
+#endif
QTextStream t(&f);
while ( !t.eof() )
{
QString s = t.readLine();
s.replace (QRegExp("\";\""), "\"|\"");
// char buffer[1024];
int len=s.length()+1;
#ifdef WIN32
@@ -1800,17 +1848,19 @@ void ZSafe::readAllEntries()
}
f.close();
}
#endif // UNUSED
void ZSafe::resume(int)
{
+#ifndef NO_OPIE
owarn << "Resume" << oendl;
+#endif
// hide the main window
if ( !showpwd )
{
infoForm->hide();
// open zsafe again
m_password = "";
selectedItem = NULL;
@@ -1859,26 +1909,34 @@ bool ZSafe::openDocument(const char* _filename, const char* )
QFile f(_filename);
if (f.exists())
{
// ask with a dialog for the password
if (m_password.isEmpty())
getDocPassword(tr("Enter Password"));
if (m_password.isEmpty() && validationFlag == 0)
{
+#ifndef NO_OPIE
owarn << "Wrong password" << oendl;
+#else
+ qWarning ("Wrong password");
+#endif
QMessageBox::critical( 0, tr("ZSafe"),
tr("Wrong password.\n\nZSafe will now exit.") );
exitZs (1);
}
retval = loadInit(_filename, m_password);
if (retval != PWERR_GOOD)
{
+#ifndef NO_OPIE
owarn << "Error loading Document" << oendl;
+#lese
+ qWarning ("Error loading Document");
+#endif
return false;
}
}
else
{
#ifdef WIN32
this->setCaption("Qt ZSafe");
#else
@@ -2268,17 +2326,21 @@ bool ZSafe::saveDocument(const char* _filename,
entry[i] = (char*)malloc(strlen("field5")+1);
strcpy(entry[i++], "field5");
entry[i] = (char*)malloc(strlen("field6")+1);
strcpy(entry[i++], "field6");
retval = saveEntry(entry);
for (int z=0; z<i; z++) free(entry[z]);
if (retval == PWERR_DATA) {
+#ifndef NO_OPIE
owarn << "1: Error writing file, contents not saved" << oendl;
+#else
+ qWarning("1: Error writing file, contents not saved");
+#endif
saveFinalize();
return false;
}
// #ifndef WIN32
conf->writeEntry(APP_KEY+"valzsafe", 1);
// #endif
saveConf();
}
@@ -2312,26 +2374,34 @@ bool ZSafe::saveDocument(const char* _filename,
strcpy(entry[j++], si->text(5).utf8());
retval = saveEntry(entry);
for (int z=0; z<j; z++)
{
free(entry[z]);
}
if (retval == PWERR_DATA) {
+#ifndef NO_OPIE
owarn << "1: Error writing file, contents not saved" << oendl;
+#else
+ qWarning("1: Error writing file, contents not saved");
+#endif
saveFinalize();
return false;
}
}
}
if (saveFinalize() == PWERR_DATA) {
+#ifndef NO_OPIE
owarn << "2: Error writing file, contents not saved" << oendl;
+#else
+ qWarning("2: Error writing file, contents not saved");
+#endif
return false;
} else {
#ifndef DESKTOP
Global::statusMessage (tr("Password file saved."));
#endif
modified = false;
return true;
}
@@ -2342,17 +2412,19 @@ bool newPwdDialogResult = false;
void ZSafe::setPasswordDialogDone()
{
newPwdDialogResult = true;
newPwdDialog->close();
}
void ZSafe::getDocPassword(QString title)
{
+#ifndef NO_OPIE
owarn << "getDocPassword" << oendl;
+#endif
// open the 'Password' dialog
PasswordForm *dialog = new PasswordForm(this, title, TRUE);
newPwdDialog = dialog;
newPwdDialogResult = false;
QPixmap image0( ( const char** ) zsafe_xpm );
dialog->setIcon( image0);
@@ -2524,17 +2596,19 @@ int ZSafe::saveFinalize(void)
fclose (fd);
free(buffer);
return retval;
}
void ZSafe::quitMe ()
{
+#ifndef NO_OPIE
owarn << "QUIT..." << oendl;
+#endif
if (modified)
{
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to save\nbefore exiting?"),
tr("&Save"),
tr("S&ave with\nnew\npassword"),
tr("&Don't Save"),
@@ -2728,17 +2802,19 @@ void ZSafe::addCategory()
QString fullIconPath;
QPixmap *pix;
if (result == Accepted)
{
modified = true;
category = dialog->CategoryField->currentText();
icon = dialog->IconField->currentText()+".png";
+#ifndef NO_OPIE
owarn << category << oendl;
+#endif
QListViewItem *li = new ShadedListItem( 1, ListView );
Category *c1 = new Category();
c1->setCategoryName(category);
// if (!icon.isEmpty() && !icon.isNull())
if (icon != "predefined.png")
{
@@ -3202,17 +3278,21 @@ void ZSafe::editCategory()
saveConf();
}
category = dialog->CategoryField->currentText();
icon = dialog->IconField->currentText()+".png";
if (cat)
{
+#ifndef NO_OPIE
owarn << "Category found" << oendl;
+#else
+ qWarning("Category found");
+#endif
// if (!icon.isEmpty() && !icon.isNull())
if (icon != "predefined.png")
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
if (!pix->isNull())
@@ -3236,17 +3316,21 @@ void ZSafe::editCategory()
saveConf();
cat->setIcon (*getPredefinedIcon(category));
}
// change the category name of the selected category
QListViewItem *catItem = cat->getListItem();
if (catItem)
{
+#ifndef NO_OPIE
owarn << category << oendl;
+#else
+ qWarning (category);
+#endif
catItem->setText( 0, tr( category ) );
cat->setCategoryName (tr(category));
cat->initListItem();
categories.insert (category, cat);
}
}
saveCategoryDialogFields(dialog);