summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/config.in2
-rw-r--r--noncore/apps/zsafe/zsafe.cpp85
-rw-r--r--noncore/apps/zsafe/zsafe.pro2
3 files changed, 85 insertions, 4 deletions
diff --git a/noncore/apps/zsafe/config.in b/noncore/apps/zsafe/config.in
index 53956ad..4b1e968 100644
--- a/noncore/apps/zsafe/config.in
+++ b/noncore/apps/zsafe/config.in
@@ -1,5 +1,5 @@
config ZSAFE
boolean "zsafe (Zaurus Password Manager)"
default "y"
- depends ( LIBQPE || LIBQPE-X11 )
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index bd03031..abf6511 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -1,44 +1,49 @@
/****************************************************************************
**
** Created: Sat Apr 6 17:57:45 2002
**
** Author: Carsten Schneider <CarstenSchneider@t-online.de>
**
** $Id$
**
** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html
**
** Compile Flags:
-** Zaurus arm : none
+** Zaurus arm : -DNO_OPIE
+** Zaurus Opie arm: none
** Linux Desktop : -DDESKTOP
** Windows Desktop: -DDESKTOP -DWIN32
**
****************************************************************************/
#include "zsafe.h"
#include "newdialog.h"
#include "searchdialog.h"
#include "categorydialog.h"
#include "passworddialog.h"
#include "infoform.h"
#include "zlistview.h"
#include "shadedlistitem.h"
#ifndef DESKTOP
+#ifndef NO_OPIE
+#include <opie/ofiledialog.h>
+#else
#include "scqtfileedit.h"
#endif
+#endif
#include <qclipboard.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <string.h>
#include <errno.h>
#include <qmenubar.h>
@@ -1182,48 +1187,63 @@ void ZSafe::listViewSelected( QListViewItem *_item)
ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
#endif
#ifdef WIN32
// set the column text dependent on the selected item
ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
#endif
}
bool ZSafe::isCategory(QListViewItem *_item)
{
+ if (_item == NULL)
+ return FALSE;
+
QString categoryName = _item->text (0);
if (categories.find ((const char *)categoryName))
return TRUE;
else
return FALSE;
}
void ZSafe::removeAsciiFile()
{
// QString fn = filename + ".txt";
// open the file dialog
#ifndef DESKTOP
+#ifndef NO_OPIE
+ QMap<QString, QStringList> mimeTypes;
+ mimeTypes.insert(tr("All"), QStringList() );
+ mimeTypes.insert(tr("Text"), "text/*" );
+ QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
+ QDir::homeDirPath() + "/Documents/application/zsafe",
+ QString::null,
+ mimeTypes,
+ this,
+ tr ("Remove text file"));
+#else
QString fn = ScQtFileEdit::getOpenFileName(this,
tr ("Remove text file"),
QDir::homeDirPath() + "/Documents/application/zsafe",
"*.txt");
+#endif
#else
QString fn = QFileDialog::getOpenFileName(
QDir::homeDirPath() + "/Documents/application/zsafe",
"ZSafe (*.txt)",
this,
"ZSafe File Dialog"
"Choose a text file" );
#endif
if (fn && fn.length() > 0 )
{
QFile f( fn );
if ( !f.remove() )
{
qWarning( QString("Could not remove file %1").arg(fn),
2000 );
@@ -1232,36 +1252,48 @@ void ZSafe::removeAsciiFile()
return;
}
}
}
void ZSafe::writeAllEntries()
{
if (filename.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("No document defined.\nYou have to create a new document"));
return;
}
// open the file dialog
#ifndef DESKTOP
+#ifndef NO_OPIE
+ QMap<QString, QStringList> mimeTypes;
+ mimeTypes.insert(tr("All"), QStringList() );
+ mimeTypes.insert(tr("Text"), "text/*" );
+ QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
+ QDir::homeDirPath() + "/Documents/application/zsafe",
+ QString::null,
+ mimeTypes,
+ this,
+ tr ("Export text file"));
+#else
QString fn = ScQtFileEdit::getSaveAsFileName(this,
tr ("Export text file"),
QDir::homeDirPath() + "/Documents/application/zsafe",
"*.txt");
+#endif
#else
QString fn = QFileDialog::getSaveFileName(
QDir::homeDirPath() + "/Documents/application/zsafe",
"ZSafe (*.txt)",
this,
"ZSafe File Dialog"
"Choose a text file" );
#endif
// open the new document
if (fn && fn.length() > 0 )
{
QFile f( fn );
if ( !f.open( IO_WriteOnly ) ) {
qWarning( QString("Could not write to file %1").arg(fn),
2000 );
@@ -1315,36 +1347,48 @@ void ZSafe::writeAllEntries()
}
f.close();
}
}
void ZSafe::readAllEntries()
{
if (filename.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("No document defined.\nYou have to create a new document"));
return;
}
// open the file dialog
#ifndef DESKTOP
+#ifndef NO_OPIE
+ QMap<QString, QStringList> mimeTypes;
+ mimeTypes.insert(tr("All"), QStringList() );
+ mimeTypes.insert(tr("Text"), "text/*" );
+ QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
+ QDir::homeDirPath() + "/Documents/application/zsafe",
+ QString::null,
+ mimeTypes,
+ this,
+ tr ("Import text file"));
+#else
QString fn = ScQtFileEdit::getOpenFileName(this,
tr ("Import text file"),
QDir::homeDirPath() + "/Documents/application/zsafe",
"*.txt");
+#endif
#else
QString fn = QFileDialog::getOpenFileName(
QDir::homeDirPath() + "/Documents/application/zsafe",
"ZSafe (*.txt)",
this,
"ZSafe File Dialog"
"Choose a text file" );
#endif
if (fn && fn.length() > 0 )
{
QFile f( fn );
if ( !f.open( IO_ReadOnly ) )
{
qWarning( QString("Could not read file %1").arg(fn),
2000 );
@@ -3128,36 +3172,48 @@ void ZSafe::pasteItem()
i->setText (3, copiedItem->text(3));
i->setText (4, copiedItem->text(4));
i->setText (5, copiedItem->text(5));
selectedItem->setOpen( TRUE );
}
}
}
IsCut = false;
IsCopy = false;
}
void ZSafe::newDocument()
{
// open the file dialog
#ifndef DESKTOP
+#ifndef NO_OPIE
+ QMap<QString, QStringList> mimeTypes;
+ mimeTypes.insert(tr("All"), QStringList() );
+ mimeTypes.insert(tr("ZSafe"), "zsafe/*" );
+ QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
+ QDir::homeDirPath() + "/Documents/application/zsafe",
+ QString::null,
+ mimeTypes,
+ this,
+ tr ("Create new ZSafe document"));
+#else
QString newFile = ScQtFileEdit::getSaveAsFileName(this,
tr ("Create new ZSafe document"),
QDir::homeDirPath() + "/Documents/application/zsafe",
"*.zsf");
+#endif
#else
QString newFile = QFileDialog::getSaveFileName(
QDir::homeDirPath() + "/Documents/application/zsafe",
"ZSafe (*.zsf)",
this,
"ZSafe File Dialog"
"Choose a ZSafe file" );
#endif
// open the new document
if (newFile && newFile.length() > 0 )
{
// save the previous opened document
if (!filename.isEmpty())
saveDocument(filename, FALSE);
@@ -3176,64 +3232,76 @@ void ZSafe::newDocument()
c = i;
// step through all subitems
QListViewItem *si;
for (si = i->firstChild();
si != NULL; )
{
QListViewItem *_si = si;
si = si->nextSibling();
i->takeItem(_si); // remove from view list
if (_si) delete _si;
}
}
if (c) delete c; // delete the previous category
categories.clear();
// m_password = "";
- // selectedItem = NULL;
+ selectedItem = NULL;
filename = newFile;
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
#ifdef WIN32
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
// openDocument(filename);
QMessageBox::information( this, tr("ZSafe"),
tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0);
saveDocumentWithPwd();
}
}
void ZSafe::loadDocument()
{
// open the file dialog
#ifndef DESKTOP
+#ifndef NO_OPIE
+ QMap<QString, QStringList> mimeTypes;
+ mimeTypes.insert(tr("All"), QStringList() );
+ mimeTypes.insert(tr("ZSafe"), "zsafe/*" );
+ QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
+ QDir::homeDirPath() + "/Documents/application/zsafe",
+ QString::null,
+ mimeTypes,
+ this,
+ tr ("Open ZSafe document"));
+#else
QString newFile = ScQtFileEdit::getOpenFileName(this,
tr ("Open ZSafe document"),
QDir::homeDirPath() + "/Documents/application/zsafe",
"*.zsf");
+#endif
#else
QString newFile = QFileDialog::getOpenFileName(
QDir::homeDirPath() + "/Documents/application/zsafe",
"ZSafe (*.zsf)",
this,
"ZSafe File Dialog"
"Choose a ZSafe file" );
#endif
// open the new document
if (newFile && newFile.length() > 0 )
{
// save the previous opened document
if (!filename.isEmpty())
saveDocument(filename, FALSE);
@@ -3270,53 +3338,66 @@ void ZSafe::loadDocument()
saveConf();
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
#ifdef WIN32
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
openDocument(filename);
}
}
void ZSafe::saveDocumentAs()
{
#ifndef DESKTOP
+#ifndef NO_OPIE
+ QMap<QString, QStringList> mimeTypes;
+ mimeTypes.insert(tr("All"), QStringList() );
+ mimeTypes.insert(tr("ZSafe"), "zsafe/*" );
+ QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
+ QDir::homeDirPath() + "/Documents/application/zsafe",
+ QString::null,
+ mimeTypes,
+ this,
+ tr ("Save ZSafe document as.."));
+#else
QString newFile = ScQtFileEdit::getSaveAsFileName(this,
tr ("Save ZSafe document as.."),
QDir::homeDirPath() + "/Documents/application/zsafe",
"*.zsf");
+#endif
#else
// open the file dialog
QString newFile = QFileDialog::getSaveFileName(
QDir::homeDirPath() + "/Documents/application/zsafe",
"ZSafe (*.zsf)",
this,
"ZSafe File Dialog"
"Choose a ZSafe file" );
#endif
// open the new document
if (newFile && newFile.length() > 0 )
{
// save the previous opened document
if (!filename.isEmpty())
saveDocument(filename, FALSE);
+ selectedItem = NULL;
filename = newFile;
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
#ifdef WIN32
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
QMessageBox::information( this, tr("ZSafe"),
tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0);
saveDocumentWithPwd();
diff --git a/noncore/apps/zsafe/zsafe.pro b/noncore/apps/zsafe/zsafe.pro
index ae4c793..5cb74dd 100644
--- a/noncore/apps/zsafe/zsafe.pro
+++ b/noncore/apps/zsafe/zsafe.pro
@@ -1,22 +1,22 @@
TEMPLATE = app
CONFIG = qt warn_on release
DESTDIR = $(OPIEDIR)/bin
HEADERS = zsafe.h krc2.h category.h categorylist.h zlistview.h \
scqtfiledlg.h
SOURCES = main.cpp zsafe.cpp krc2.cpp category.cpp \
categorylist.cpp zlistview.cpp shadedlistitem.cpp\
scqtfileedit.cpp scqtfileedit.moc.cpp \
scqtfiledlg.cpp
INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui
INTERFACES += infoform.ui wait.ui
INCLUDEPATH += $(OPIEDIR)/include
INCLUDEPATH += .
INCLUDEPATH += $(OPIEDIR)/noncore/apps/zsafe
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe
+LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopie
TARGET = zsafe
TRANSLATIONS = $(OPIEDIR)/noncore/apps/zsafe/i18n/de/zsafe.ts
#include ( $(OPIEDIR)/include.pro )