summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/config.in2
-rw-r--r--noncore/apps/zsafe/opie-zsafe.control2
-rw-r--r--noncore/apps/zsafe/zsafe.cpp989
-rw-r--r--noncore/apps/zsafe/zsafe.pro16
4 files changed, 506 insertions, 503 deletions
diff --git a/noncore/apps/zsafe/config.in b/noncore/apps/zsafe/config.in
index 4b1e968..6e321f3 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 ) && LIBOPIE
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI
diff --git a/noncore/apps/zsafe/opie-zsafe.control b/noncore/apps/zsafe/opie-zsafe.control
index b58a987..6288fac 100644
--- a/noncore/apps/zsafe/opie-zsafe.control
+++ b/noncore/apps/zsafe/opie-zsafe.control
@@ -1,9 +1,9 @@
Package: opie-zsafe
Files: bin/zsafe apps/Applications/zsafe.desktop pics/zsafe/*.png
Priority: optional
Section: opie/applications
Version: $QPE_VERSION$EXTRAVERSION
Architecture: arm
-Depends: task-opie-minimal
+Depends: task-opie-minimal, libopieui2
Maintainer: Carsten Schneider <zcarsten@gmx.net>
Description: This is a password manager program for Opie.
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index bdd2aed..f43a206 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -19,25 +19,28 @@
****************************************************************************/
#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>
+#include <opie2/ofiledialog.h>
+
+using Opie::OFileDialog;
+using Opie::OFileSelector;
#else
#include "scqtfileedit.h"
#endif
#endif
#include <qclipboard.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -125,25 +128,25 @@ const QString APP_KEY="";
#include "pics/zsafe/folder_open.xpm"
#include "pics/zsafe/help_icon.xpm"
#include "pics/zsafe/new.xpm"
#include "pics/zsafe/paste.xpm"
#include "pics/zsafe/quit_icon.xpm"
#include "pics/zsafe/save.xpm"
#include "pics/zsafe/trash.xpm"
#include "pics/zsafe/expand.xpm"
#include "pics/zsafe/export.xpm"
#include "pics/zsafe/import.xpm"
#include "pics/zsafe/zsafe.xpm"
-static const char* const bank_cards_data[] = {
+static const char* const bank_cards_data[] = {
"14 14 16 1",
". c None",
"# c #000000",
"b c #0000de",
"a c #0000e6",
"j c #41de83",
"k c #4acecd",
"h c #4aced5",
"g c #5a40cd",
"d c #5a44d5",
"l c #9440d5",
"m c #b4ce4a",
@@ -159,25 +162,25 @@ static const char* const bank_cards_data[] = {
".#ccccccccc#..",
".#cdcefcghc#..",
".#ccccccccc#..",
".#cicjkclic#..",
".#ccccccccc#..",
".#cmchlcnec#..",
".#ccccccccc#..",
".###########..",
"..............",
".............."};
-static const char* const passwords_data[] = {
+static const char* const passwords_data[] = {
"16 16 20 1",
". c None",
"# c #000000",
"r c #000083",
"p c #0000c5",
"q c #0000ff",
"n c #008100",
"l c #00c200",
"m c #00ff00",
"j c #838100",
"a c #c55900",
"h c #c5c200",
@@ -198,49 +201,49 @@ static const char* const passwords_data[] = {
"#eeff#..#add#...",
"#eeff#######....",
"#ccdbdd#........",
"#dddbdd###......",
"#gghihhjj#......",
"#hhhihhjj###....",
"#kklmllnnnn#....",
"#lllmllnnnn#....",
"#oopqpprprr#....",
"#oopqpprprr#....",
"############...."};
-static const char* const software_data[] = {
+static const char* const software_data[] = {
"16 16 5 1",
". c None",
"# c #000000",
"b c #838183",
"c c #c5ffff",
"a c #ffffff",
"................",
".##############.",
"#aaaaaaaaaaaaaa#",
"#abbbbbbbbbbbbb#",
"#ab##########ab#",
"#ab#c########ab#",
"#ab#c#c######ab#",
"#ab##########ab#",
"#ab##########ab#",
"#ab##########ab#",
"#ab##########ab#",
"#ab##########ab#",
"#aaaaaaaaaaaaab#",
"#bbbbbbbbbbbbbb#",
".##############.",
"................"};
-static const char* const general_data[] = {
+static const char* const general_data[] = {
"14 14 98 2",
"Qt c None",
".k c #000000",
"#x c #080808",
"#F c #101008",
"#q c #101010",
"#i c #101410",
"## c #101810",
".m c #181818",
".3 c #181c18",
".I c #182018",
".T c #202420",
@@ -370,55 +373,55 @@ static const char* const general_data[] = {
#else
conf = new QSettings (cfgFile);
conf->insertSearchPath (QSettings::Unix, cfgFile);
#endif
#else
conf = new Config (cfgFile, Config::File);
conf->setGroup ("zsafe");
#endif
}
}
-/*
- * Constructs a ZSafe which is a child of 'parent', with the
- * name 'name' and widget flags set to 'f'
+/*
+ * Constructs a ZSafe which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
- : QDialog( parent, name, modal, fl ),
+ : QDialog( parent, name, modal, fl ),
Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l)
{
IsCut = false;
IsCopy = false;
modified = false;
// set the config file
cfgFile=QDir::homeDirPath();
cfgFile += "/.zsafe.cfg";
// set the icon path
#ifdef NO_OPIE
QString qpedir ((const char *)getenv("QPEDIR"));
#else
QString qpedir ((const char *)getenv("OPIEDIR"));
#endif
#ifdef DESKTOP
iconPath = QDir::homeDirPath() + "/pics/";
#else
if (qpedir.isEmpty())
iconPath = "/home/QtPalmtop/pics/";
- else
+ else
iconPath = qpedir + "/pics/";
#endif
// create a zsafe configuration object
#ifdef DESKTOP
#ifndef WIN32
conf = new QSettings ();
conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
#else
conf = new QSettings (cfgFile);
conf->insertSearchPath (QSettings::Unix, cfgFile);
#endif
@@ -449,31 +452,31 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
QPixmap quit_icon_img((const char**) quit_icon_xpm);
QPixmap save_img((const char**) save_xpm);
QPixmap trash_img((const char**) trash_xpm);
QPixmap expand_img((const char**) expand_xpm);
QPixmap export_img((const char**) export_xpm);
QPixmap import_img((const char**) import_xpm);
QPixmap bank_cards( ( const char** ) bank_cards_data );
QPixmap passwords( ( const char** ) passwords_data );
QPixmap software( ( const char** ) software_data );
QPixmap general( ( const char** ) general_data );
if ( !name )
- setName( "ZSafe" );
+ setName( "ZSafe" );
#ifdef DESKTOP
#ifdef WIN32
- setGeometry(100, 150, DeskW, DeskH-30 );
+ setGeometry(100, 150, DeskW, DeskH-30 );
#else
- resize( DeskW, DeskH-30 );
+ resize( DeskW, DeskH-30 );
#endif
#else
#ifdef JPATCH_HDE
int DeskS;
if(DeskW > DeskH)
{
DeskS = DeskW;
}
else
{
@@ -489,58 +492,58 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
#endif
// setCaption( tr( "ZSafe" ) );
filename = conf->readEntry(APP_KEY+"document");
if (filename.isEmpty() || filename.isNull())
{
// check if the directory application exists, if not
// create it
// #ifndef WIN32
// QString d1("Documents/application");
// #else
- QString d1(QDir::homeDirPath() + "/Documents/application");
+ QString d1(QDir::homeDirPath() + "/Documents/application");
// #endif
QDir pd1(d1);
if (!pd1.exists())
{
QDir pd1("Documents");
if (!pd1.mkdir("application", FALSE))
{
QMessageBox::critical( 0, tr("ZSafe"),
#ifdef JPATCH_HDE
tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit."));
#else
tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1));
#endif
exitZs (1);
}
}
- QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
+ QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
QDir pd2(d2);
if (!pd2.exists())
{
QDir pd2(QDir::homeDirPath() + "Documents/application");
if (!pd2.mkdir("zsafe", FALSE))
{
QMessageBox::critical( 0, tr("ZSafe"),
#ifdef JPATCH_HDE
tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit."));
#else
tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2));
#endif
exitZs (1);
}
}
-
+
// set the default filename
filename=d2 + "/passwords.zsf";
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
}
//if (filename == "INVALIDPWD")
//filename = "";
@@ -567,32 +570,32 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
// add file menu
// QPopupMenu *file = new QPopupMenu( this );
file = new QPopupMenu( this );
// #ifdef DESKTOP
file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) );
file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) );
file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) );
file->insertSeparator();
// #endif
file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) );
- file->insertItem( save_img, tr("S&ave document with new Password"), this,
+ file->insertItem( save_img, tr("S&ave document with new Password"), this,
SLOT(saveDocumentWithPwd()) );
file->insertSeparator();
file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) );
file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) );
file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) );
file->insertSeparator();
- file->insertItem( expand_img, tr("&Open entries expanded"), this,
+ file->insertItem( expand_img, tr("&Open entries expanded"), this,
SLOT(setExpandFlag()), 0, 'o');
file->setItemChecked('o', expandTree);
file->insertSeparator();
file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) );
menu->insertItem( tr("&File"), file );
QPopupMenu *cat = new QPopupMenu( this );
cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) );
cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) );
cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) );
menu->insertItem( tr("&Category"), cat );
@@ -605,73 +608,73 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) );
it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) );
it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) );
menu->insertItem( tr("&Entry"), it );
QPopupMenu *help = new QPopupMenu( this );
help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) );
menu->insertItem( tr("&Help"), help );
// toolbar icons
New = new QToolButton( menu, "New" );
- New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) );
+ New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) );
New->setMouseTracking( TRUE );
New->setText( tr( "" ) );
New->setPixmap( new_img );
QToolTip::add( New, tr( "New entry" ) );
Edit = new QToolButton( menu, "Edit" );
- Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) );
+ Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) );
Edit->setText( tr( "" ) );
Edit->setPixmap( edit_img );
QToolTip::add( Edit, tr( "Edit category or entry" ) );
Delete = new QToolButton( menu, "Delete" );
- Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
+ Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
Delete->setText( tr( "" ) );
Delete->setPixmap( trash_img );
QToolTip::add( Delete, tr( "Delete category or entry" ) );
Find = new QToolButton( menu, "Find" );
- Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) );
+ Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) );
Find->setText( tr( "" ) );
Find->setPixmap( find_img );
QToolTip::add( Find, tr( "Find entry" ) );
/*
QBoxLayout * h = new QHBoxLayout( this );
h->addWidget (menu);
h->addWidget (New);
h->addWidget (Edit);
h->addWidget (Delete);
h->addWidget (Find);
*/
ListView = new ZListView( this, "ListView" );
ListView->addColumn( tr( "Name" ) );
ListView->addColumn( tr( "Field 2" ) );
ListView->addColumn( tr( "Field 3" ) );
ListView->addColumn( tr( "Comment" ) );
ListView->addColumn( tr( "Field 4" ) );
ListView->addColumn( tr( "Field 5" ) );
ListView->setAllColumnsShowFocus(TRUE);
#ifdef DESKTOP
ListView->setResizePolicy(QScrollView::AutoOneFit);
- // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) );
+ // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) );
#else
ListView->setResizePolicy(QScrollView::AutoOneFit);
- // ListView->setGeometry( QRect( 0, 22,
- // this->width(), this->height() - 30 ) );
+ // ListView->setGeometry( QRect( 0, 22,
+ // this->width(), this->height() - 30 ) );
// ListView->setMaximumSize( QSize( 440, 290 ) );
#endif
ListView->setVScrollBarMode( QListView::Auto );
QBoxLayout * l = new QVBoxLayout( this );
l->addWidget (menu);
l->addWidget (ListView);
#ifndef DESKTOP
// start a timer (100 ms) to load the default document
docuTimer.start( 100, true );
connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) );
@@ -692,49 +695,49 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
this, SLOT( listViewSelected( QListViewItem* ) ) );
connect( ListView, SIGNAL( doubleClicked( QListViewItem* ) ),
this, SLOT( showInfo( QListViewItem* ) ) );
connect( ListView, SIGNAL( returnPressed( QListViewItem* ) ),
this, SLOT( showInfo( QListViewItem* ) ) );
}
const QColor *ZSafe::evenRowColor = &Qt::white;
// const QColor *ZSafe::oddRowColor = &Qt::lightGray;
const QColor *ZSafe::oddRowColor = new QColor(216,240,255);
-/*
+/*
* Destroys the object and frees any allocated resources
*/
ZSafe::~ZSafe()
{
// no need to delete child widgets, Qt does it all for us
quitMe();
}
// load the default document
void ZSafe::slotLoadDocu()
{
openDocument (filename);
}
void ZSafe::deletePwd()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
{
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to delete?"),
- tr("&Delete"), tr("D&on't Delete"),
+ tr("&Delete"), tr("D&on't Delete"),
0 // Enter == button 0
) ) { // Escape == button 2
case 0: // Delete clicked, Alt-S or Enter pressed.
// Delete
modified = true;
selectedItem->parent()->takeItem(selectedItem);
selectedItem = NULL;
break;
case 1: // Don't delete
break;
}
}
@@ -745,27 +748,27 @@ void ZSafe::deletePwd()
}
void ZSafe::editPwd()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
{
// open the 'New Entry' dialog
NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE);
#ifdef WIN32
dialog->setCaption ("Qt " + tr("Edit Entry"));
- dialog->setGeometry(200, 250, 220, 310 );
+ dialog->setGeometry(200, 250, 220, 310 );
#endif
-
+
// set the labels
dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
// set the fields
dialog->NameField->setText(selectedItem->text (0));
dialog->UsernameField->setText(selectedItem->text (1));
dialog->PasswordField->setText(selectedItem->text (2));
@@ -776,106 +779,106 @@ void ZSafe::editPwd()
dialog->CommentField->insertLine(comment);
dialog->CommentField->setCursorPosition(0,0);
DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
#ifdef DESKTOP
result = Accepted;
#endif
if (result == Accepted)
{
modified = true;
// edit the selected item
- QString name = dialog->NameField->text();
+ QString name = dialog->NameField->text();
selectedItem->setText (0, tr (name));
- QString user = dialog->UsernameField->text();
+ QString user = dialog->UsernameField->text();
selectedItem->setText (1, tr (user));
- QString pwd = dialog->PasswordField->text();
+ QString pwd = dialog->PasswordField->text();
selectedItem->setText (2, tr (pwd));
- QString comment = dialog->CommentField->text();
+ QString comment = dialog->CommentField->text();
comment.replace (QRegExp("\n"), "<br>");
selectedItem->setText (3, tr (comment));
- QString f5 = dialog->Field5->text();
+ QString f5 = dialog->Field5->text();
selectedItem->setText (4, tr (f5));
- QString f6 = dialog->Field6->text();
+ QString f6 = dialog->Field6->text();
selectedItem->setText (5, tr (f6));
}
delete dialog;
}
- else
+ else
{
editCategory();
}
}
void ZSafe::newPwd()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
selectedItem = selectedItem->parent();
if (isCategory(selectedItem))
{
QString cat = selectedItem->text(0);
// open the 'New Entry' dialog
NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE);
#ifdef WIN32
dialog->setCaption ("Qt " + tr("New Entry"));
- dialog->setGeometry(200, 250, 220, 310 );
+ dialog->setGeometry(200, 250, 220, 310 );
#endif
// set the labels
dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
retype:
DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
#ifdef DESKTOP
result = Accepted;
#endif
if (result == Accepted)
{
- QString name = dialog->NameField->text();
+ QString name = dialog->NameField->text();
if (cat == name)
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("Entry name must be different\nfrom the category name.") );
goto retype; // it's not a good programming style :-)
}
modified = true;
// add the new item
QListViewItem *i = new ShadedListItem (0, selectedItem);
i->setOpen (TRUE);
i->setText (0, tr (name));
- QString user = dialog->UsernameField->text();
+ QString user = dialog->UsernameField->text();
i->setText (1, tr (user));
- QString pwd = dialog->PasswordField->text();
+ QString pwd = dialog->PasswordField->text();
i->setText (2, tr (pwd));
- QString comment = dialog->CommentField->text();
+ QString comment = dialog->CommentField->text();
comment.replace (QRegExp("\n"), "<br>");
i->setText (3, tr (comment));
- QString f5 = dialog->Field5->text();
+ QString f5 = dialog->Field5->text();
i->setText (4, tr (f5));
- QString f6 = dialog->Field6->text();
+ QString f6 = dialog->Field6->text();
i->setText (5, tr (f6));
}
delete dialog;
}
}
void ZSafe::findPwd()
{
// open the 'Search' dialog
SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE);
@@ -943,38 +946,38 @@ void ZSafe::findPwd()
}
lastSearchedComment = comment;
ListView->clearSelection();
bool found=FALSE;
// step through all categories
QListViewItem *i;
if (lastSearchedCategory)
i = lastSearchedCategory;
else
i = ListView->firstChild();
- for (;
+ for (;
i != NULL;
i = i->nextSibling())
{
qWarning (i->text(0));
i->setSelected(FALSE);
// step through all subitems
QListViewItem *si;
if (lastSearchedItem)
si = lastSearchedItem;
else
si = i->firstChild();
- // for (si = i->firstChild();
+ // for (si = i->firstChild();
for (;
si != NULL;
si = si->nextSibling())
{
qWarning (si->text(0));
if (si->isSelected())
si->setSelected(FALSE);
// ListView->repaintItem(si);
bool n=TRUE;
bool u=TRUE;
bool c=TRUE;
@@ -1009,27 +1012,27 @@ void ZSafe::findPwd()
delete dialog;
update();
return;
}
}
lastSearchedCategory = i->nextSibling();
lastSearchedItem = NULL;
}
lastSearchedCategory = NULL;
lastSearchedItem = NULL;
delete dialog;
update();
- QMessageBox::information( this, tr("ZSafe"),
+ QMessageBox::information( this, tr("ZSafe"),
tr("Entry not found"), tr("&OK"), 0);
-
+
}
QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
{
QString category;
if (_item)
{
if (isCategory(_item))
{
category = _item->text(0);
}
else
@@ -1067,42 +1070,42 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
QString ZSafe::getFieldLabel (QString category, QString field, QString def)
{
QString app_key = APP_KEY;
#ifndef DESKTOP
conf->setGroup ("fieldDefs");
#else
#ifndef WIN32
app_key += "/fieldDefs/";
#endif
#endif
// #ifndef WIN32
- QString label = conf->readEntry(app_key+category+"-field"+field,
+ QString label = conf->readEntry(app_key+category+"-field"+field,
def);
// #else
// QString label(def);
// #endif
#ifndef DESKTOP
conf->setGroup ("zsafe");
#endif
return label;
}
void ZSafe::showInfo( QListViewItem *_item)
{
if (!_item)
return;
if (selectedItem != NULL)
selectedItem->setSelected(FALSE);
-
+
selectedItem = _item;
selectedItem->setSelected(TRUE);
if (!isCategory(_item))
{
/*
QString label=selectedItem->text(0);
label+="\n";
label+=selectedItem->text(1);
label+="\n";
label+=selectedItem->text(2);
label+="\n";
@@ -1229,42 +1232,42 @@ void ZSafe::removeAsciiFile()
#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,
+ 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",
+ 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() )
+ if ( !f.remove() )
{
qWarning( QString("Could not remove file %1").arg(fn),
2000 );
QMessageBox::critical( 0, tr("ZSafe"),
tr("Could not remove text file.") );
return;
}
}
}
void ZSafe::writeAllEntries()
{
@@ -1279,60 +1282,60 @@ void ZSafe::writeAllEntries()
#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,
+ 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",
+ 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 );
QMessageBox::critical( 0, "ZSafe",
QString("Could not export to text file.") );
return;
}
QTextStream t( &f );
QListViewItem *i;
// step through all categories
- for (i = ListView->firstChild();
+ for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
// step through all subitems
QListViewItem *si;
- for (si = i->firstChild();
+ for (si = i->firstChild();
si != NULL;
si = si->nextSibling())
{
QString oneEntry;
oneEntry += "\"";
oneEntry += i->text(0);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(0);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(1);
@@ -1374,32 +1377,32 @@ void ZSafe::readAllEntries()
#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,
+ 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",
+ 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),
@@ -1426,38 +1429,38 @@ void ZSafe::readAllEntries()
// si = si->nextSibling())
{
QListViewItem *_si = si;
si = si->nextSibling();
i->takeItem(_si); // remove from view list
if (_si) delete _si;
}
}
qWarning ("ReadAllEntries(): ");
QTextStream t(&f);
- while ( !t.eof() )
+ while ( !t.eof() )
{
QString s = t.readLine();
s.replace (QRegExp("\";\""), "\"|\"");
// char buffer[1024];
#ifndef WIN32
- char buffer[s.length()+1];
+ char buffer[s.length()+1];
#else
- char buffer[4048];
+ char buffer[4048];
#endif
/* modify QString -> QCString::utf8 */
-
+
strcpy (buffer, s.utf8());
QString name;
QString user;
QString password;
QString comment;
QString field5="";
QString field6="";
// separete the entries
char *i = strtok (buffer, "|");
QString category(QString::fromUtf8(&i[1]));
@@ -1490,25 +1493,25 @@ void ZSafe::readAllEntries()
break;
case 4:
// field5
field5 = QString::fromUtf8(&i[1]);
field5.truncate(field5.length() -1);
break;
case 5:
// field6
field6 = QString::fromUtf8(&i[1]);
field6.truncate(field6.length() -1);
break;
}
- idx++;
+ idx++;
}
Category *cat= categories.find (category);
if (cat)
{
// use the existend item
QListViewItem *catItem = cat->getListItem();
if (catItem)
{
QListViewItem * item = new ShadedListItem( 0, catItem );
item->setText( 0, tr( name ) );
item->setText( 1, tr( user ) );
@@ -1584,31 +1587,31 @@ void ZSafe::writeAllEntries()
QFile f( fn );
if ( !f.open( IO_WriteOnly ) ) {
qWarning( QString("Could not write to file %1").arg(fn),
2000 );
QMessageBox::critical( 0, tr("ZSafe"),
tr("Could not export to text file.") );
return;
}
QTextStream t( &f );
QListViewItem *i;
// step through all categories
- for (i = ListView->firstChild();
+ for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
// step through all subitems
QListViewItem *si;
- for (si = i->firstChild();
+ for (si = i->firstChild();
si != NULL;
si = si->nextSibling())
{
QString oneEntry;
oneEntry += "\"";
oneEntry += i->text(0);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(0);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(1);
@@ -1661,32 +1664,32 @@ void ZSafe::readAllEntries()
// si = si->nextSibling())
{
QListViewItem *_si = si;
si = si->nextSibling();
i->takeItem(_si); // remove from view list
if (_si) delete _si;
}
}
qWarning ("ReadAllEntries(): ");
QTextStream t(&f);
- while ( !t.eof() )
+ while ( !t.eof() )
{
QString s = t.readLine();
s.replace (QRegExp("\";\""), "\"|\"");
// char buffer[1024];
- int len=s.length()+1;
+ int len=s.length()+1;
#ifdef WIN32
- char buffer[512];
+ char buffer[512];
#else
char buffer[len];
#endif
strcpy (buffer, s);
QString name;
QString user;
QString password;
QString comment;
// separete the entries
char *i = strtok (buffer, "|");
@@ -1710,25 +1713,25 @@ void ZSafe::readAllEntries()
break;
case 2:
// password
password = &i[1];
password.truncate(password.length() -1);
break;
case 3:
// comment
comment = &i[1];
comment.truncate(comment.length() -1);
break;
}
- idx++;
+ idx++;
}
Category *cat= categories.find (category);
if (cat)
{
// use the existend item
QListViewItem *catItem = cat->getListItem();
if (catItem)
{
QListViewItem * item = new ShadedListItem( 0, catItem );
item->setText( 0, tr( name ) );
item->setText( 1, tr( user ) );
@@ -1823,119 +1826,119 @@ void ZSafe::resume(int)
}
//---------------------------------------------
bool ZSafe::openDocument(const char* _filename, const char* )
{
int retval;
char* entry[FIELD_SIZE];
// #ifndef WIN32
int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1);
// #else
- // int validationFlag = 1;
+ // int validationFlag = 1;
// #endif
int pwdOk = 0;
int numberOfTries = 3;
for (int i=0; i < numberOfTries; i++)
{
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)
+ if (m_password.isEmpty())
+ getDocPassword(tr("Enter Password"));
+ if (m_password.isEmpty() && validationFlag == 0)
{
qWarning ("Wrong password");
QMessageBox::critical( 0, tr("ZSafe"),
tr("Wrong password.\n\nZSafe will now exit.") );
exitZs (1);
}
- retval = loadInit(_filename, m_password);
- if (retval != PWERR_GOOD)
+ retval = loadInit(_filename, m_password);
+ if (retval != PWERR_GOOD)
{
qWarning ("Error loading Document");
- return false;
- }
+ return false;
+ }
}
else
{
#ifdef WIN32
this->setCaption("Qt ZSafe");
#else
this->setCaption("ZSafe");
#endif
filename = "";
return false;
}
// load the validation entry
if (validationFlag == 0)
{
pwdOk = 1;
break;
}
- retval = loadEntry(entry);
+ retval = loadEntry(entry);
if (retval == 1 &&
!strcmp (entry[0], "ZSAFECATEGORY") &&
!strcmp (entry[1], "name") &&
!strcmp (entry[2], "username") &&
!strcmp (entry[3], "password") &&
!strcmp (entry[4], "comment") )
{
- for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
+ for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
pwdOk = 1;
break;
}
else
- // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
- fclose (fd);
+ // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
+ fclose (fd);
m_password = "";
if (i < numberOfTries - 1)
{
switch( QMessageBox::warning( this, tr("ZSafe"),
tr("Wrong password.\nEnter again?"),
- tr("&Yes"), tr("&No."),
- 0
- ) )
- {
+ tr("&Yes"), tr("&No."),
+ 0
+ ) )
+ {
case 1: // No
exitZs (1);
break;
case 0: // Yes
continue;
}
}
}
if (pwdOk == 0)
{
// unset the document entry
conf->writeEntry(APP_KEY+"document", "INVALIDPWD");
if (conf)
delete conf;
exitZs (1);
}
- retval = loadEntry(entry);
-
+ retval = loadEntry(entry);
+
int numberOfEntries=0;
- while (retval == 1) {
+ while (retval == 1) {
QString category( QString::fromUtf8(entry[0]) );
QString name( QString::fromUtf8(entry[1]) );
QString user( QString::fromUtf8(entry[2]) );
QString password( QString::fromUtf8(entry[3]) );
QString comment( QString::fromUtf8(entry[4]) );
QString field5( QString::fromUtf8(entry[5]) );
QString field6( QString::fromUtf8(entry[6]) );
// add the subitems to the categories
Category *cat= categories.find (category);
if (cat)
@@ -1999,272 +2002,272 @@ bool ZSafe::openDocument(const char* _filename, const char* )
}
if (!isIconAv)
{
c1->setIcon (*getPredefinedIcon(category));
}
c1->setListItem (catI);
c1->initListItem();
categories.insert (c1->getCategoryName(), c1);
numberOfEntries++;
}
- for (int count = 0; count < FIELD_SIZE; count++) {
- free(entry[count]);
- }
- retval = loadEntry(entry);
- if (retval == 2) {
- // m_parent->slotStatusHelpMsg("Last entry loaded");
- }
- } // end while
+ for (int count = 0; count < FIELD_SIZE; count++) {
+ free(entry[count]);
+ }
+ retval = loadEntry(entry);
+ if (retval == 2) {
+ // m_parent->slotStatusHelpMsg("Last entry loaded");
+ }
+ } // end while
if (numberOfEntries == 0)
{
-
+
switch( QMessageBox::warning( this, tr("ZSafe"),
tr("Empty document or\nwrong password.\nContinue?"),
- tr("&No"), tr("&Yes."),
- 0
- ) ) {
+ tr("&No"), tr("&Yes."),
+ 0
+ ) ) {
case 0: // No
- retval = loadFinalize();
+ retval = loadFinalize();
exitZs (1);
break;
case 1: // Yes
break;
}
- }
+ }
- retval = loadFinalize();
+ retval = loadFinalize();
- return true;
+ return true;
}
int ZSafe::loadInit(const char* _filename, const char *password)
{
- unsigned int j = 0;
- unsigned int keylength=0;
- int count=0, count2=0, count3=0;
- unsigned char charbuf[8];
- unsigned short ciphertext[4];
- char key[128];
- Krc2* krc2 = new Krc2();
+ unsigned int j = 0;
+ unsigned int keylength=0;
+ int count=0, count2=0, count3=0;
+ unsigned char charbuf[8];
+ unsigned short ciphertext[4];
+ char key[128];
+ Krc2* krc2 = new Krc2();
- fd = fopen (_filename, "rb");
+ fd = fopen (_filename, "rb");
QFileInfo f (_filename);
load_buffer_length = f.size();
load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2;
- if (fd == NULL)
- return PWERR_OPEN;
+ if (fd == NULL)
+ return PWERR_OPEN;
- buffer = (char *)malloc(load_buffer_length);
- for (j = 0; password[j] != '\0'; j++) {
- key[j] = password[j];
- }
- keylength = j;
- krc2->rc2_expandkey (key, keylength, 128);
+ buffer = (char *)malloc(load_buffer_length);
+ for (j = 0; password[j] != '\0'; j++) {
+ key[j] = password[j];
+ }
+ keylength = j;
+ krc2->rc2_expandkey (key, keylength, 128);
#ifndef WIN32
- size = read(fileno (fd), (unsigned char *) (charbuf + count), 8);
+ size = read(fileno (fd), (unsigned char *) (charbuf + count), 8);
#else
- printf ("LoadInit() read1");
+ printf ("LoadInit() read1");
size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
#endif
- if (size < 8)
- return PWERR_DATA;
+ if (size < 8)
+ return PWERR_DATA;
- for (count = 0; count < 4; count++) {
- count2 = count << 1;
- iv[count] = charbuf[count2] << 8;
- iv[count] += charbuf[count2 + 1];
- }
+ for (count = 0; count < 4; count++) {
+ count2 = count << 1;
+ iv[count] = charbuf[count2] << 8;
+ iv[count] += charbuf[count2 + 1];
+ }
- size = 0;
- bufferIndex = 0;
+ size = 0;
+ bufferIndex = 0;
#ifndef WIN32
- while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) {
- while (count < 8) {
- count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8);
+ while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) {
+ while (count < 8) {
+ count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8);
#else
- printf ("LoadInit() read2");
+ printf ("LoadInit() read2");
while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) {
- while (count < 8) {
- count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
-#endif
- if (count2 == 0) {
- return PWERR_DATA;
- }
- count += count2;
- } /* while (count < 8) */
-
- size += 8;
- for (count2 = 0; count2 < 8; count2 += 2) {
- count3 = count2 >> 1;
- ciphertext[count3] = charbuf[count2] << 8;
- ciphertext[count3] += charbuf[count2 + 1];
-
- plaintext[count3] = ciphertext[count3] ^ iv[count3];
- iv[count3] = plaintext[count3];
- } /* for (count2) */
-
- krc2->rc2_decrypt (plaintext);
- memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8);
- bufferIndex += 8;
- buffer[bufferIndex + 1] = '\0';
- } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */
- size -= buffer[size - 1];
- lastcount = 0;
-
- /* This will point to the starting index */
- bufferIndex = 0;
- return PWERR_GOOD;
+ while (count < 8) {
+ count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
+#endif
+ if (count2 == 0) {
+ return PWERR_DATA;
+ }
+ count += count2;
+ } /* while (count < 8) */
+
+ size += 8;
+ for (count2 = 0; count2 < 8; count2 += 2) {
+ count3 = count2 >> 1;
+ ciphertext[count3] = charbuf[count2] << 8;
+ ciphertext[count3] += charbuf[count2 + 1];
+
+ plaintext[count3] = ciphertext[count3] ^ iv[count3];
+ iv[count3] = plaintext[count3];
+ } /* for (count2) */
+
+ krc2->rc2_decrypt (plaintext);
+ memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8);
+ bufferIndex += 8;
+ buffer[bufferIndex + 1] = '\0';
+ } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */
+ size -= buffer[size - 1];
+ lastcount = 0;
+
+ /* This will point to the starting index */
+ bufferIndex = 0;
+ return PWERR_GOOD;
}
int ZSafe::loadEntry(char *entry[FIELD_SIZE])
{
- /* Strip off PKCS 5 padding
- * Should check to make sure it's good here
- */
- int count, count1=0;
-
- for (count = lastcount; count < size; count++) {
- if ((unsigned char) (buffer[count]) == 255) {
- if (buffer[bufferIndex] == '\0') {
- bufferIndex++;
- }
- entry[count1] = (char *) malloc (count - bufferIndex + 1);
- memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex);
- entry[count1][count - bufferIndex] = '\0';
- count++;
- bufferIndex = count;
- count1++;
- if (count1 == FIELD_SIZE) {
- lastcount = count;
- return 1;
- }
- } /* if ((unsigned char) (buffer[count]) == 255) */
- } /* for (count = 0; count < size; count++) */
-
- return 2;
+ /* Strip off PKCS 5 padding
+ * Should check to make sure it's good here
+ */
+ int count, count1=0;
+
+ for (count = lastcount; count < size; count++) {
+ if ((unsigned char) (buffer[count]) == 255) {
+ if (buffer[bufferIndex] == '\0') {
+ bufferIndex++;
+ }
+ entry[count1] = (char *) malloc (count - bufferIndex + 1);
+ memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex);
+ entry[count1][count - bufferIndex] = '\0';
+ count++;
+ bufferIndex = count;
+ count1++;
+ if (count1 == FIELD_SIZE) {
+ lastcount = count;
+ return 1;
+ }
+ } /* if ((unsigned char) (buffer[count]) == 255) */
+ } /* for (count = 0; count < size; count++) */
+
+ return 2;
}
int ZSafe::loadFinalize(void)
{
- fclose (fd);
+ fclose (fd);
if (buffer) free(buffer);
- return PWERR_GOOD;
+ return PWERR_GOOD;
}
-bool ZSafe::saveDocument(const char* _filename,
- bool withPwd,
+bool ZSafe::saveDocument(const char* _filename,
+ bool withPwd,
const char* )
{
if (filename.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("No document defined.\nYou have to create a new document"));
return false;
}
// if (m_password.isEmpty())
// withPwd = true; // the document must be saved with a valid password
if (withPwd)
{
bool pwdOk = FALSE;
while (!pwdOk)
{
- getDocPassword(tr("Enter Password"));
- if (m_password.isEmpty())
+ getDocPassword(tr("Enter Password"));
+ if (m_password.isEmpty())
{
-
- QMessageBox::critical( 0, tr("ZSafe"),
+
+ QMessageBox::critical( 0, tr("ZSafe"),
tr("Password is empty.\nPlease enter again."));
continue;
}
-
+
QString firstPasswd = m_password;
-
- getDocPassword(tr("Reenter Password"));
- if (m_password.isEmpty())
+
+ getDocPassword(tr("Reenter Password"));
+ if (m_password.isEmpty())
{
- QMessageBox::critical( 0, tr("ZSafe"),
+ QMessageBox::critical( 0, tr("ZSafe"),
tr("Password is empty.\nPlease enter again."));
continue;
}
if (firstPasswd != m_password)
{
-
- QMessageBox::critical( 0, tr("ZSafe"),
+
+ QMessageBox::critical( 0, tr("ZSafe"),
tr("Passwords must be identical.\nPlease enter again."));
continue;
}
- pwdOk = TRUE;
+ pwdOk = TRUE;
modified = false;
}
- }
+ }
else if (modified)
{
QString fns(_filename);
fns = fns.right (fns.length() - fns.findRev ('/') - 1);
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to save ") + fns + tr("\nbefore continuing?"),
- tr("&Save"),
- tr("&Don't Save"),
+ tr("&Save"),
+ tr("&Don't Save"),
0 // Enter == button 0
- ) )
+ ) )
{ // Escape == button 2
case 0: // Save clicked, Alt-S or Enter pressed.
modified = false;
break;
case 1: // Don't Save clicked or Alt-D pressed
modified = false;
return true;
}
}
modified = false;
-
+
if (m_password.isEmpty())
return false;
int retval = saveInit(_filename, m_password);
- // int retval = saveInit(_filename, "test");
- if (retval != PWERR_GOOD) {
- return false;
+ // int retval = saveInit(_filename, "test");
+ if (retval != PWERR_GOOD) {
+ return false;
}
-
- char* entry[FIELD_SIZE];
+
+ char* entry[FIELD_SIZE];
// save the validation entry
{
int i=0;
- entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1);
- strcpy(entry[i++], "ZSAFECATEGORY");
- entry[i] = (char*)malloc(strlen("name")+1);
- strcpy(entry[i++], "name");
- entry[i] = (char*)malloc(strlen("username")+1);
- strcpy(entry[i++], "username");
- entry[i] = (char*)malloc(strlen("password")+1);
- strcpy(entry[i++], "password");
- entry[i] = (char*)malloc(strlen("comment")+1);
- strcpy(entry[i++], "comment");
-
- 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);
+ entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1);
+ strcpy(entry[i++], "ZSAFECATEGORY");
+ entry[i] = (char*)malloc(strlen("name")+1);
+ strcpy(entry[i++], "name");
+ entry[i] = (char*)malloc(strlen("username")+1);
+ strcpy(entry[i++], "username");
+ entry[i] = (char*)malloc(strlen("password")+1);
+ strcpy(entry[i++], "password");
+ entry[i] = (char*)malloc(strlen("comment")+1);
+ strcpy(entry[i++], "comment");
+
+ 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) {
qWarning("1: Error writing file, contents not saved");
saveFinalize();
return false;
}
// #ifndef WIN32
conf->writeEntry(APP_KEY+"valzsafe", 1);
// #endif
saveConf();
}
@@ -2287,48 +2290,48 @@ bool ZSafe::saveDocument(const char* _filename,
strcpy(entry[j++], si->text(0).utf8());
entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1);
strcpy(entry[j++], si->text(1).utf8());
entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1);
strcpy(entry[j++], si->text(2).utf8());
entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1);
strcpy(entry[j++], si->text(3).utf8());
entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1);
strcpy(entry[j++], si->text(4).utf8());
entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1);
strcpy(entry[j++], si->text(5).utf8());
- retval = saveEntry(entry);
+ retval = saveEntry(entry);
for (int z=0; z<j; z++)
{
free(entry[z]);
}
if (retval == PWERR_DATA) {
qWarning("1: Error writing file, contents not saved");
saveFinalize();
return false;
}
}
}
- if (saveFinalize() == PWERR_DATA) {
+ if (saveFinalize() == PWERR_DATA) {
qWarning("2: Error writing file, contents not saved");
- return false;
- } else {
+ return false;
+ } else {
#ifndef DESKTOP
Global::statusMessage (tr("Password file saved."));
#endif
modified = false;
- return true;
- }
+ return true;
+ }
}
PasswordForm *newPwdDialog;
bool newPwdDialogResult = false;
void ZSafe::setPasswordDialogDone()
{
newPwdDialogResult = true;
newPwdDialog->close();
}
void ZSafe::getDocPassword(QString title)
{
@@ -2361,184 +2364,184 @@ qWarning ("getDocPassword");
if (result == Accepted || newPwdDialogResult)
{
m_password = dialog->PasswordField->text();
}
else
{
exitZs (1);
}
}
int ZSafe::saveInit(const char *_filename, const char *password)
{
- char key[128];
- unsigned int j = 0;
- unsigned int keylength;
- // int val;
- int count2;
- Krc2* krc2 = new Krc2();
-
- /* first we should check the permissions of the filename */
+ char key[128];
+ unsigned int j = 0;
+ unsigned int keylength;
+ // int val;
+ int count2;
+ Krc2* krc2 = new Krc2();
+
+ /* first we should check the permissions of the filename */
/*
- if (QFile::exists(_filename)) {
- val = checkFile(_filename);
- if (val != PWERR_GOOD)
- return val;
- } else
+ if (QFile::exists(_filename)) {
+ val = checkFile(_filename);
+ if (val != PWERR_GOOD)
+ return val;
+ } else
{
- val = creat (_filename, (S_IRUSR | S_IWUSR));
- if (val == -1)
- return PWERR_OPEN;
- else
- close(val);
- }
+ val = creat (_filename, (S_IRUSR | S_IWUSR));
+ if (val == -1)
+ return PWERR_OPEN;
+ else
+ close(val);
+ }
*/
QFileInfo f (_filename);
save_buffer_length = f.size();
save_buffer_length = ((save_buffer_length / 1024)+1) * 1024;
- fd = fopen (_filename, "wb");
- if (fd == NULL)
- return PWERR_OPEN;
-
- buffer = (char*)malloc(save_buffer_length);
-
- /* make the key ready */
- for (j = 0; password[j] != '\0'; j++) {
- key[j] = password[j];
- }
- keylength = j;
- krc2->rc2_expandkey (key, keylength, 128);
-
- /* First, we make the IV */
- for (count2 = 0; count2 < 4; count2++) {
- iv[count2] = rand ();
- putc ((unsigned char) (iv[count2] >> 8), fd);
- putc ((unsigned char) (iv[count2] & 0xff), fd);
- }
-
- bufferIndex = 0;
- return PWERR_GOOD;
+ fd = fopen (_filename, "wb");
+ if (fd == NULL)
+ return PWERR_OPEN;
+
+ buffer = (char*)malloc(save_buffer_length);
+
+ /* make the key ready */
+ for (j = 0; password[j] != '\0'; j++) {
+ key[j] = password[j];
+ }
+ keylength = j;
+ krc2->rc2_expandkey (key, keylength, 128);
+
+ /* First, we make the IV */
+ for (count2 = 0; count2 < 4; count2++) {
+ iv[count2] = rand ();
+ putc ((unsigned char) (iv[count2] >> 8), fd);
+ putc ((unsigned char) (iv[count2] & 0xff), fd);
+ }
+
+ bufferIndex = 0;
+ return PWERR_GOOD;
}
int ZSafe::saveEntry(char *entry[FIELD_SIZE])
{
- char *text1;
- int count2, count3;
- unsigned short ciphertext[4];
- Krc2* krc2 = new Krc2();
-
- buffer = (char*)memset(buffer, '\0', save_buffer_length);
-
- for (count2 = 0; count2 < FIELD_SIZE; count2++) {
- text1 = entry[count2];
- if (strlen (text1) == 0) {
- strncat(buffer, " ", strlen(" "));
- } else {
- strncat(buffer, text1, strlen(text1));
- }
- /* Use 255 as the marker. \n is too tough to test for */
- buffer[strlen (buffer)] = 255;
- } /*for (count2 = 0; count2 < 5; count2++)*/
- count2 = 0;
- /* I'm using CBC mode and encrypting the data straight from top down.
- * At the bottom, encrypted, I will append an MD5 hash of the file, eventually.
- * PKCS 5 padding (explained at the code section
- */
- while (count2 < (int)strlen (buffer)) {
+ char *text1;
+ int count2, count3;
+ unsigned short ciphertext[4];
+ Krc2* krc2 = new Krc2();
+
+ buffer = (char*)memset(buffer, '\0', save_buffer_length);
+
+ for (count2 = 0; count2 < FIELD_SIZE; count2++) {
+ text1 = entry[count2];
+ if (strlen (text1) == 0) {
+ strncat(buffer, " ", strlen(" "));
+ } else {
+ strncat(buffer, text1, strlen(text1));
+ }
+ /* Use 255 as the marker. \n is too tough to test for */
+ buffer[strlen (buffer)] = 255;
+ } /*for (count2 = 0; count2 < 5; count2++)*/
+ count2 = 0;
+ /* I'm using CBC mode and encrypting the data straight from top down.
+ * At the bottom, encrypted, I will append an MD5 hash of the file, eventually.
+ * PKCS 5 padding (explained at the code section
+ */
+ while (count2 < (int)strlen (buffer)) {
#ifndef WORDS_BIGENDIAN
- plaintext[bufferIndex] = buffer[count2 + 1] << 8;
- plaintext[bufferIndex] += buffer[count2] & 0xff;
+ plaintext[bufferIndex] = buffer[count2 + 1] << 8;
+ plaintext[bufferIndex] += buffer[count2] & 0xff;
#endif
#ifdef WORDS_BIGENDIAN
- plaintext[bufferIndex] = buffer[count2] << 8;
- plaintext[bufferIndex] += buffer[count2 + 1] & 0xff;
-#endif
- bufferIndex++;
- if (bufferIndex == 4) {
- krc2->rc2_encrypt (plaintext);
-
- for (count3 = 0; count3 < 4; count3++) {
- ciphertext[count3] = iv[count3] ^ plaintext[count3];
-
- /* Now store the ciphertext as the iv */
- iv[count3] = plaintext[count3];
-
- /* reset the buffer index */
- bufferIndex = 0;
- if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA;
- if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA;
- } /*for (count3 = 0; count3 < 5; count3++)*/
- } /*if (bufferIndex == 5)*/
- /* increment a short, not a byte */
- count2 += 2;
- } /*while (count2 < strlen (buffer))*/
+ plaintext[bufferIndex] = buffer[count2] << 8;
+ plaintext[bufferIndex] += buffer[count2 + 1] & 0xff;
+#endif
+ bufferIndex++;
+ if (bufferIndex == 4) {
+ krc2->rc2_encrypt (plaintext);
+
+ for (count3 = 0; count3 < 4; count3++) {
+ ciphertext[count3] = iv[count3] ^ plaintext[count3];
+
+ /* Now store the ciphertext as the iv */
+ iv[count3] = plaintext[count3];
+
+ /* reset the buffer index */
+ bufferIndex = 0;
+ if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA;
+ if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA;
+ } /*for (count3 = 0; count3 < 5; count3++)*/
+ } /*if (bufferIndex == 5)*/
+ /* increment a short, not a byte */
+ count2 += 2;
+ } /*while (count2 < strlen (buffer))*/
int ret = PWERR_GOOD;
- return ret;
+ return ret;
}
int ZSafe::saveFinalize(void)
{
- int count1, retval = PWERR_GOOD;
- unsigned short ciphertext[4];
- Krc2* krc2 = new Krc2();
-
- /* Tack on the PKCS 5 padding
- * How it works is we fill up the last n bytes with the value n
- *
- * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left
- * over, leaving us 3 short, so we fill it in with 3's.
- *
- * If we come out even, we fill it with 8 8s
- *
- * um, except that in this instance we are using 4 shorts instead of 8 bytes.
- * so, half everything
- */
- for (count1 = bufferIndex; count1 < 4; count1++) {
- plaintext[count1] = (4 - bufferIndex);
- }
- krc2->rc2_encrypt (plaintext);
- for (count1 = 0; count1 < 4; count1++) {
- ciphertext[count1] = iv[count1] ^ plaintext[count1];
- if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA;
- if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA;
- }
-
- fclose (fd);
- free(buffer);
- return retval;
+ int count1, retval = PWERR_GOOD;
+ unsigned short ciphertext[4];
+ Krc2* krc2 = new Krc2();
+
+ /* Tack on the PKCS 5 padding
+ * How it works is we fill up the last n bytes with the value n
+ *
+ * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left
+ * over, leaving us 3 short, so we fill it in with 3's.
+ *
+ * If we come out even, we fill it with 8 8s
+ *
+ * um, except that in this instance we are using 4 shorts instead of 8 bytes.
+ * so, half everything
+ */
+ for (count1 = bufferIndex; count1 < 4; count1++) {
+ plaintext[count1] = (4 - bufferIndex);
+ }
+ krc2->rc2_encrypt (plaintext);
+ for (count1 = 0; count1 < 4; count1++) {
+ ciphertext[count1] = iv[count1] ^ plaintext[count1];
+ if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA;
+ if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA;
+ }
+
+ fclose (fd);
+ free(buffer);
+ return retval;
}
void ZSafe::quitMe ()
{
qWarning ("QUIT...");
if (modified)
{
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to save\nbefore exiting?"),
- tr("&Save"),
+ tr("&Save"),
tr("S&ave with\nnew\npassword"),
- tr("&Don't Save"),
+ tr("&Don't Save"),
0 // Enter == button 0
- ) )
+ ) )
{ // Escape == button 2
case 0: // Save clicked, Alt-S or Enter pressed.
// save
modified = false;
saveDocument(filename, FALSE);
exitZs (1);
break;
- case 1: //
+ case 1: //
// Save with new password
modified = false;
saveDocument(filename, TRUE);
exitZs (1);
break;
case 2: // Don't Save clicked or Alt-D pressed
// don't save but exitZs
exitZs (1);
break;
}
}
exitZs (1);
@@ -2567,79 +2570,79 @@ void ZSafe::addCategory()
CategoryDialog *dialog;
if (categoryDialog)
{
dialog = categoryDialog;
}
else
{
categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
#ifdef WIN32
categoryDialog->setCaption ("Qt " + tr("Category"));
#endif
dialog = categoryDialog;
- connect( dialog->CategoryField,
+ connect( dialog->CategoryField,
SIGNAL( activated ( const QString &)),
this, SLOT( categoryFieldActivated( const QString & ) ) );
initIcons = true;
}
#ifdef DESKTOP
#ifndef WIN32
QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
QString s;
int n = 1;
while ( !t.eof() ) { // until end of file...
s = t.readLine(); // line of text excluding '\n'
list.append(s);
}
f.close();
}
#endif
-#else
+#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
QString s;
while ( !t.eof() ) { // until end of file...
s = t.readLine(); // line of text excluding '\n'
list.append(s);
}
f.close();
}
#endif
QStringList::Iterator it = list.begin();
QString categ;
QString firstCategory;
dialog->CategoryField->clear(); // remove all items
- while( it != list.end() )
+ while( it != list.end() )
{
QString *cat = new QString (*it);
if (cat->contains("-field1", FALSE))
- {
+ {
#ifdef DESKTOP
#ifndef WIN32
categ = cat->section ("-field1", 0, 0);
#else
int pos = cat->find ("-field1");
- categ = cat->left (pos);
+ categ = cat->left (pos);
#endif
#else
int pos = cat->find ("-field1");
cat->truncate(pos);
categ = *cat;
#endif
if (!categ.isEmpty())
{
dialog->CategoryField->insertItem (categ, -1);
if (firstCategory.isEmpty())
firstCategory = categ;
}
@@ -2648,61 +2651,61 @@ void ZSafe::addCategory()
}
if (firstCategory.isEmpty())
setCategoryDialogFields(dialog);
else
setCategoryDialogFields(dialog, firstCategory);
// CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE);
if (initIcons)
{
- Wait waitDialog(this, tr("Wait dialog"));
- waitDialog.waitLabel->setText(tr("Gathering icons..."));
- waitDialog.show();
- qApp->processEvents();
+ Wait waitDialog(this, tr("Wait dialog"));
+ waitDialog.waitLabel->setText(tr("Gathering icons..."));
+ waitDialog.show();
+ qApp->processEvents();
#ifdef DESKTOP
- QDir d(iconPath);
+ QDir d(iconPath);
#else
- QDir d(QPEApplication::qpeDir() + "/pics/");
+ QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
- d.setFilter( QDir::Files);
+ d.setFilter( QDir::Files);
- const QFileInfoList *list = d.entryInfoList();
- QFileInfoListIterator it( *list ); // create list iterator
- QFileInfo *fi; // pointer for traversing
+ const QFileInfoList *list = d.entryInfoList();
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
- dialog->IconField->insertItem("predefined");
- while ( (fi=it.current()) ) { // for each file...
- QString fileName = fi->fileName();
- if(fileName.right(4) == ".png"){
- fileName = fileName.mid(0,fileName.length()-4);
+ dialog->IconField->insertItem("predefined");
+ while ( (fi=it.current()) ) { // for each file...
+ QString fileName = fi->fileName();
+ if(fileName.right(4) == ".png"){
+ fileName = fileName.mid(0,fileName.length()-4);
#ifdef DESKTOP
- QPixmap imageOfFile;
+ QPixmap imageOfFile;
imageOfFile.load(iconPath + fi->fileName());
#else
- QPixmap imageOfFile(Resource::loadPixmap(fileName));
-#endif
- QImage foo = imageOfFile.convertToImage();
- foo = foo.smoothScale(16,16);
- imageOfFile.convertFromImage(foo);
- dialog->IconField->insertItem(imageOfFile,fileName);
- }
- ++it;
- }
- waitDialog.hide();
+ QPixmap imageOfFile(Resource::loadPixmap(fileName));
+#endif
+ QImage foo = imageOfFile.convertToImage();
+ foo = foo.smoothScale(16,16);
+ imageOfFile.convertFromImage(foo);
+ dialog->IconField->insertItem(imageOfFile,fileName);
+ }
+ ++it;
+ }
+ waitDialog.hide();
}
-
+
#ifndef WIN32
dialog->show();
#endif
#ifndef DESKTOP
// dialog->move (20, 100);
#endif
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString category;
@@ -2718,25 +2721,25 @@ void ZSafe::addCategory()
qWarning (category);
QListViewItem *li = new ShadedListItem( 1, ListView );
Category *c1 = new Category();
c1->setCategoryName(category);
// if (!icon.isEmpty() && !icon.isNull())
if (icon != "predefined.png")
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
- // pix->resize(14, 14);
+ // pix->resize(14, 14);
if (pix)
{
// save the full pixmap name into the config file
// #ifndef WIN32
conf->writeEntry(APP_KEY+category, icon);
// #endif
saveConf();
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIcon (*pix);
c1->setIconName(icon);
}
@@ -2767,25 +2770,25 @@ void ZSafe::addCategory()
}
}
void ZSafe::delCategory()
{
if (!selectedItem)
return;
if (isCategory(selectedItem))
{
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to delete?"),
- tr("&Delete"), tr("D&on't Delete"),
+ tr("&Delete"), tr("D&on't Delete"),
0 // Enter == button 0
) ) { // Escape == button 2
case 0: // Delete clicked, Alt-S or Enter pressed.
// Delete from the category list
modified = true;
categories.remove (selectedItem->text(0));
// #ifndef WIN32
conf->removeEntry (selectedItem->text(0));
// #endif
saveConf();
// Delete the selected item and all subitems
@@ -2808,25 +2811,25 @@ void ZSafe::delCategory()
break;
}
}
}
void ZSafe::setCategoryDialogFields(CategoryDialog *dialog)
{
if (!dialog)
return;
QString icon;
- if (selectedItem)
+ if (selectedItem)
{
dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name")));
dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username")));
dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password")));
dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4")));
dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5")));
Category *cat= categories.find (selectedItem->text(0));
if (cat)
{
icon = cat->getIconName();
@@ -2836,114 +2839,114 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog)
}
else
{
dialog->Field1->setText(tr("Name"));
dialog->Field2->setText(tr("Username"));
dialog->Field3->setText(tr("Password"));
dialog->Field4->setText(tr("Comment"));
dialog->Field5->setText(tr("Field 4"));
dialog->Field6->setText(tr("Field 5"));
}
#ifdef DESKTOP
- QDir d(iconPath);
+ QDir d(iconPath);
#else
- QDir d(QPEApplication::qpeDir() + "/pics/");
+ QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
- d.setFilter( QDir::Files);
+ d.setFilter( QDir::Files);
- const QFileInfoList *list = d.entryInfoList();
- int i=0;
- QFileInfoListIterator it( *list ); // create list iterator
- QFileInfo *fi; // pointer for traversing
+ const QFileInfoList *list = d.entryInfoList();
+ int i=0;
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
if (icon.isEmpty() || icon.isNull())
{
dialog->IconField->setCurrentItem(0);
}
else
{
- while ( (fi=it.current()) )
+ while ( (fi=it.current()) )
{ // for each file...
- QString fileName = fi->fileName();
- if(fileName.right(4) == ".png")
+ QString fileName = fi->fileName();
+ if(fileName.right(4) == ".png")
{
- fileName = fileName.mid(0,fileName.length()-4);
+ fileName = fileName.mid(0,fileName.length()-4);
- if(fileName+".png"==icon)
+ if(fileName+".png"==icon)
{
dialog->IconField->setCurrentItem(i+1);
break;
}
- ++i;
- }
- ++it;
- }
- }
+ ++i;
+ }
+ ++it;
+ }
+ }
}
void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category)
{
if (!dialog)
return;
dialog->Field1->setText(getFieldLabel (category, "1", tr("Name")));
dialog->Field2->setText(getFieldLabel (category, "2", tr("Username")));
dialog->Field3->setText(getFieldLabel (category, "3", tr("Password")));
dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment")));
dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4")));
dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5")));
QString icon;
Category *cat= categories.find (category);
if (cat)
{
icon = cat->getIconName();
}
else
icon = conf->readEntry(APP_KEY+category);
#ifdef DESKTOP
- QDir d(iconPath);
+ QDir d(iconPath);
#else
- QDir d(QPEApplication::qpeDir() + "/pics/");
+ QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
- d.setFilter( QDir::Files);
+ d.setFilter( QDir::Files);
- const QFileInfoList *list = d.entryInfoList();
- int i=0;
- QFileInfoListIterator it( *list ); // create list iterator
- QFileInfo *fi; // pointer for traversing
+ const QFileInfoList *list = d.entryInfoList();
+ int i=0;
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
if (icon.isEmpty() || icon.isNull())
{
dialog->IconField->setCurrentItem(0);
}
else
{
- while ( (fi=it.current()) )
+ while ( (fi=it.current()) )
{ // for each file...
- QString fileName = fi->fileName();
- if(fileName.right(4) == ".png")
+ QString fileName = fi->fileName();
+ if(fileName.right(4) == ".png")
{
- fileName = fileName.mid(0,fileName.length()-4);
+ fileName = fileName.mid(0,fileName.length()-4);
- if(fileName+".png"==icon)
+ if(fileName+".png"==icon)
{
dialog->IconField->setCurrentItem(i+1);
break;
}
- ++i;
- }
- ++it;
- }
- }
+ ++i;
+ }
+ ++it;
+ }
+ }
}
void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog)
{
QString app_key = APP_KEY;
#ifndef DESKTOP
conf->setGroup ("fieldDefs");
#else
#ifndef WIN32
app_key += "/fieldDefs/";
#endif
#endif
@@ -2974,25 +2977,25 @@ void ZSafe::editCategory()
CategoryDialog *dialog;
if (categoryDialog)
{
dialog = categoryDialog;
}
else
{
categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
#ifdef WIN32
categoryDialog->setCaption ("Qt " + tr("Category"));
#endif
dialog = categoryDialog;
- connect( dialog->CategoryField,
+ connect( dialog->CategoryField,
SIGNAL( activated ( const QString &)),
this, SLOT( categoryFieldActivated( const QString & ) ) );
initIcons = true;
}
setCategoryDialogFields(dialog);
#ifdef DESKTOP
#ifndef WIN32
QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
#else
// read all categories from the config file and store
// into a list
@@ -3020,35 +3023,35 @@ void ZSafe::editCategory()
while ( !t.eof() ) { // until end of file...
s = t.readLine(); // line of text excluding '\n'
list.append(s);
}
f.close();
}
#endif
QStringList::Iterator it = list.begin();
QString categ;
dialog->CategoryField->clear(); // remove all items
int i=0;
bool foundCategory = false;
- while( it != list.end() )
+ while( it != list.end() )
{
QString *cat = new QString (*it);
if (cat->contains("-field1", FALSE))
- {
+ {
#ifdef DESKTOP
#ifndef WIN32
categ = cat->section ("-field1", 0, 0);
#else
- int pos = cat->find ("-field1");
- categ = cat->left (pos);
+ int pos = cat->find ("-field1");
+ categ = cat->left (pos);
#endif
#else
int pos = cat->find ("-field1");
cat->truncate(pos);
categ = *cat;
#endif
if (!categ.isEmpty())
{
dialog->CategoryField->insertItem (categ, i);
if (category.compare(categ) == 0)
{
dialog->CategoryField->setCurrentItem(i);
@@ -3066,108 +3069,108 @@ void ZSafe::editCategory()
}
QString icon;
Category *cat= categories.find (selectedItem->text(0));
if (cat)
{
icon = cat->getIconName();
}
if (initIcons)
{
- Wait waitDialog(this, tr("Wait dialog"));
- waitDialog.waitLabel->setText(tr("Gathering icons..."));
- waitDialog.show();
- qApp->processEvents();
+ Wait waitDialog(this, tr("Wait dialog"));
+ waitDialog.waitLabel->setText(tr("Gathering icons..."));
+ waitDialog.show();
+ qApp->processEvents();
#ifdef DESKTOP
- QDir d(iconPath);
+ QDir d(iconPath);
#else
- QDir d(QPEApplication::qpeDir() + "/pics/");
+ QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
- d.setFilter( QDir::Files);
+ d.setFilter( QDir::Files);
- const QFileInfoList *list = d.entryInfoList();
- int i=0;
- QFileInfoListIterator it( *list ); // create list iterator
- QFileInfo *fi; // pointer for traversing
+ const QFileInfoList *list = d.entryInfoList();
+ int i=0;
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
if (icon.isEmpty() || icon.isNull())
{
dialog->IconField->setCurrentItem(0);
}
- dialog->IconField->insertItem("predefined");
- while ( (fi=it.current()) ) { // for each file...
- QString fileName = fi->fileName();
- if(fileName.right(4) == ".png")
+ dialog->IconField->insertItem("predefined");
+ while ( (fi=it.current()) ) { // for each file...
+ QString fileName = fi->fileName();
+ if(fileName.right(4) == ".png")
{
- fileName = fileName.mid(0,fileName.length()-4);
+ fileName = fileName.mid(0,fileName.length()-4);
#ifdef DESKTOP
- QPixmap imageOfFile;
+ QPixmap imageOfFile;
imageOfFile.load(iconPath + fi->fileName());
#else
- QPixmap imageOfFile(Resource::loadPixmap(fileName));
+ QPixmap imageOfFile(Resource::loadPixmap(fileName));
#endif
- QImage foo = imageOfFile.convertToImage();
- foo = foo.smoothScale(16,16);
- imageOfFile.convertFromImage(foo);
- dialog->IconField->insertItem(imageOfFile,fileName);
- if(fileName+".png"==icon)
+ QImage foo = imageOfFile.convertToImage();
+ foo = foo.smoothScale(16,16);
+ imageOfFile.convertFromImage(foo);
+ dialog->IconField->insertItem(imageOfFile,fileName);
+ if(fileName+".png"==icon)
dialog->IconField->setCurrentItem(i+1);
- ++i;
- }
- ++it;
- }
- waitDialog.hide();
+ ++i;
+ }
+ ++it;
+ }
+ waitDialog.hide();
}
else
{
#ifdef DESKTOP
- // QDir d(QDir::homeDirPath() + "/pics/");
- QDir d(iconPath);
+ // QDir d(QDir::homeDirPath() + "/pics/");
+ QDir d(iconPath);
#else
- QDir d(QPEApplication::qpeDir() + "/pics/");
+ QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
- d.setFilter( QDir::Files);
+ d.setFilter( QDir::Files);
- const QFileInfoList *list = d.entryInfoList();
- int i=0;
- QFileInfoListIterator it( *list ); // create list iterator
- QFileInfo *fi; // pointer for traversing
+ const QFileInfoList *list = d.entryInfoList();
+ int i=0;
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
if (icon.isEmpty() || icon.isNull())
{
dialog->IconField->setCurrentItem(0);
}
else
{
- while ( (fi=it.current()) )
+ while ( (fi=it.current()) )
{ // for each file...
- QString fileName = fi->fileName();
- if(fileName.right(4) == ".png")
+ QString fileName = fi->fileName();
+ if(fileName.right(4) == ".png")
{
- fileName = fileName.mid(0,fileName.length()-4);
+ fileName = fileName.mid(0,fileName.length()-4);
- if(fileName+".png"==icon)
+ if(fileName+".png"==icon)
{
dialog->IconField->setCurrentItem(i+1);
break;
}
- ++i;
- }
- ++it;
- }
- }
+ ++i;
+ }
+ ++it;
+ }
+ }
}
// dialog->show();
#ifndef DESKTOP
// dialog->move (20, 100);
#endif
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString fullIconPath;
@@ -3321,32 +3324,32 @@ void ZSafe::newDocument()
#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,
+ 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",
+ 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);
@@ -3386,55 +3389,55 @@ void ZSafe::newDocument()
// 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"),
+ 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,
+ 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",
+ 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);
@@ -3487,33 +3490,33 @@ 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,
+ 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",
+ 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);
@@ -3522,25 +3525,25 @@ void ZSafe::saveDocumentAs()
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"),
+ 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::saveDocumentWithoutPwd()
{
saveDocument(filename, FALSE);
}
void ZSafe::saveDocumentWithPwd()
@@ -3613,43 +3616,43 @@ void ZSafe::setExpandFlag()
void ZSafe::paintEvent( QPaintEvent * )
{
if (raiseFlag)
{
raiseFlag = false;
raiseTimer.start (1, true);
if (infoForm->isVisible())
infoForm->raise();
}
}
-void ZSafe::resizeEvent ( QResizeEvent * )
+void ZSafe::resizeEvent ( QResizeEvent * )
{
// qWarning ("resizeEvent");
#ifndef DESKTOP
DeskW = appl->desktop()->width();
DeskH = appl->desktop()->height();
#else
DeskW = this->width();
DeskH = this->height();
#endif
if (New)
- New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) );
+ New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) );
if (Edit)
- Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) );
+ Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) );
if (Delete)
- Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
+ Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
if (Find)
- Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) );
+ Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) );
}
void ZSafe::slotRaiseTimer()
{
if (infoForm->isVisible())
infoForm->raise();
raiseFlag = true;
}
QPixmap * ZSafe::getPredefinedIcon(QString category)
{
QPixmap *pm;
@@ -3713,19 +3716,19 @@ void ZSafe::setDocument(const QString& fileref)
{
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;
-
+
openDocument(filename);
#endif
}
diff --git a/noncore/apps/zsafe/zsafe.pro b/noncore/apps/zsafe/zsafe.pro
index 65bcb79..1e8e4ac 100644
--- a/noncore/apps/zsafe/zsafe.pro
+++ b/noncore/apps/zsafe/zsafe.pro
@@ -1,17 +1,17 @@
-TEMPLATE = app
-CONFIG = qt warn_on release
+TEMPLATE = app
+CONFIG = qt warn_on release
DESTDIR = $(OPIEDIR)/bin
HEADERS = zsafe.h krc2.h category.h categorylist.h zlistview.h \
- scqtfiledlg.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 infoform.ui wait.ui
-INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += $(OPIEDIR)/include
-LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopie
-TARGET = zsafe
+INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui infoform.ui wait.ui
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopieui2
+TARGET = zsafe
include ( $(OPIEDIR)/include.pro )