-rw-r--r--[-rwxr-xr-x] | noncore/apps/zsafe/extra/qsettings.cpp (renamed from noncore/apps/zsafe/qsettings.cpp) | 10 | ||||
-rw-r--r--[-rwxr-xr-x] | noncore/apps/zsafe/extra/qsettings.h (renamed from noncore/apps/zsafe/qsettings.h) | 0 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 143 |
3 files changed, 92 insertions, 61 deletions
diff --git a/noncore/apps/zsafe/qsettings.cpp b/noncore/apps/zsafe/extra/qsettings.cpp index ee55339..def2e2d 100755..100644 --- a/noncore/apps/zsafe/qsettings.cpp +++ b/noncore/apps/zsafe/extra/qsettings.cpp @@ -1,24 +1,25 @@ /*
** $Id$
*/
#include "qsettings.h"
#include <stdio.h>
#include <qfile.h>
#include <qtextstream.h>
QSettings::QSettings(const QString &_fn)
{
+ qWarning("Settings "+_fn); // read the prefs from the file
fn = _fn;
QFile f(_fn);
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'
char buf[256];
sprintf (buf, "%s", (const char *) s);
int pos = s.find (" = ");
@@ -123,30 +124,33 @@ bool QSettings::writeEntry (const QString &key, const char *val) prefs.replace ((const char *)key, v);
return true;
}
bool QSettings::removeEntry (const QString &key)
{
prefs.remove (key);
return true;
}
QStringList QSettings::entryList (const QString &key) const
{
- QAsciiDictIterator <QString> it( prefs ); // iterator for dict
+ qDebug("entryList: "+key); QStringList list;
-
+ if(!prefs.isEmpty()) { + QAsciiDictIterator <QString> it( prefs ); // iterator for dict + qDebug("ready"); while ( it.current() )
{
char buf[512];
sprintf (buf, "%s", (const char *) *( it.current()));
QString *val = new QString(buf);
sprintf(buf, "%s -> %s\n", it.currentKey(), (const char *)*val );
QString *cat = new QString(it.currentKey());
if (cat->contains("-field", FALSE))
list.append (it.currentKey());
++it;
-
}
+ } + qWarning("Return here"); return list;
}
diff --git a/noncore/apps/zsafe/qsettings.h b/noncore/apps/zsafe/extra/qsettings.h index 95e87b5..95e87b5 100755..100644 --- a/noncore/apps/zsafe/qsettings.h +++ b/noncore/apps/zsafe/extra/qsettings.h diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 0864293..f3d57f8 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp @@ -2,27 +2,27 @@ ** ** 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 : -DNO_OPIE ** Zaurus Opie arm: none -** Linux Desktop : -DDESKTOP -** Windows Desktop: -DDESKTOP -DWIN32 -** +** Linux Desktop : -DDESKTOP -DNO_OPIE +** Windows Desktop: -DDESKTOP -DNO_OPIE +** use qmake ** for japanese version additional use: -DJPATCH_HDE ** ****************************************************************************/ #include "zsafe.h" #include "newdialog.h" #include "searchdialog.h" #include "categorydialog.h" #include "passworddialog.h" #include "infoform.h" #include "zlistview.h" #include "shadedlistitem.h" @@ -34,37 +34,37 @@ using namespace Opie::Core; using namespace Opie::Ui; #else #include "scqtfileedit.h" #endif #endif #include <qclipboard.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> -#ifndef WIN32 +#ifndef Q_WS_WIN #include <unistd.h> #endif #include <string.h> #include <errno.h> #include <qmenubar.h> #include <qpopupmenu.h> #ifdef DESKTOP #include <qfiledialog.h> #include <qdragobject.h> -#ifndef WIN32 +#ifndef Q_WS_WIN #include <qsettings.h> #else #include "qsettings.h" #endif #include <qapplication.h> #else #include <qfile.h> #include <qpe/fileselector.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> @@ -99,25 +99,25 @@ extern int DeskW, DeskH; #ifdef DESKTOP extern QApplication *appl; #else extern QPEApplication *appl; #endif #ifdef JPATCH_HDE #define tr(arg) arg #endif #ifdef DESKTOP -#ifndef WIN32 +#ifndef Q_WS_WIN const QString APP_KEY="/.zsafe/"; #else const QString APP_KEY=""; #endif #else const QString APP_KEY=""; #endif // include xmp images #include "pics/zsafe/copy.xpm" #include "pics/zsafe/cut.xpm" #include "pics/zsafe/edit.xpm" @@ -356,25 +356,25 @@ static const char* const general_data[] = { exit (ec); } // save the configuration into the file void ZSafe::saveConf () { if (conf) { delete conf; #ifdef DESKTOP -#ifndef WIN32 +#ifndef Q_WS_WIN conf = new QSettings (); conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); #else conf = new QSettings (cfgFile); conf->insertSearchPath (QSettings::Unix, cfgFile); #endif #else conf = new Config (cfgFile, Config::File); conf->setGroup ("zsafe"); #endif } } @@ -408,37 +408,37 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) #ifdef DESKTOP iconPath = QDir::homeDirPath() + "/pics/"; #else if (qpedir.isEmpty()) iconPath = "/home/QtPalmtop/pics/"; else iconPath = qpedir + "/pics/"; #endif // create a zsafe configuration object #ifdef DESKTOP -#ifndef WIN32 +#ifndef Q_WS_WIN conf = new QSettings (); conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); #else conf = new QSettings (cfgFile); conf->insertSearchPath (QSettings::Unix, cfgFile); #endif #else conf = new Config (cfgFile, Config::File); conf->setGroup ("zsafePrefs"); #endif #ifdef DESKTOP -// #ifndef WIN32 +// #ifndef Q_WS_WIN expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); // #endif #else expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); #endif #ifndef DESKTOP conf->setGroup ("zsafe"); #endif QPixmap copy_img((const char**) copy_xpm); QPixmap cut_img((const char**) cut_xpm); QPixmap edit_img((const char**) edit_xpm); @@ -455,25 +455,25 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) 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 ); QPixmap image0( ( const char** ) zsafe_xpm ); if ( !name ) setName( "ZSafe" ); #ifdef DESKTOP -#ifdef WIN32 +#ifdef Q_WS_WIN setGeometry(100, 150, DeskW, DeskH-30 ); #else resize( DeskW, DeskH-30 ); #endif #else #ifdef JPATCH_HDE int DeskS; if(DeskW > DeskH) { DeskS = DeskW; @@ -489,25 +489,25 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) resize( DeskW, DeskH-30 ); #endif #endif setCaption( tr( "ZSafe" ) ); QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; QString filename = conf->readEntry(APP_KEY+"document"); if (filename.isEmpty() || filename.isNull()) { // check if the directory application exists, if not // create it -// #ifndef WIN32 +// #ifndef Q_WS_WIN // QString d1("Documents/application"); // #else QString d1(QDir::homeDirPath() + "/Documents/application"); // #endif QDir pd1(d1); if (!pd1.exists()) { QDir pd2(QDir::homeDirPath() + "/Documents"); if (!pd2.exists()) { QDir pd3(QDir::homeDirPath()); if (!pd3.mkdir("Documents", FALSE)) { @@ -516,25 +516,25 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) if (!pd2.mkdir("application", FALSE)) { QMessageBox::critical( 0, tr("ZSafe"), #ifdef JPATCH_HDE tr("<P>Can't create directory ..."+d1+"</P><P>ZSafe will now exit.</P>")); #else tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1)); #endif exitZs (1); } } -// #ifndef WIN32 +// #ifndef Q_WS_WIN // QString d2("Documents/application/zsafe"); // #else QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); // #endif QDir pd2(d2); if (!pd2.exists()) { if (!pd1.mkdir("zsafe", FALSE)) { QMessageBox::critical( 0, tr("ZSafe"), #ifdef JPATCH_HDE tr("<P>Can't create directory ...//Documents/application/zsafe</P><P>ZSafe will now exit.</P")); @@ -547,38 +547,38 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) // set the default filename filename = zsafeAppDirPath + "/passwords.zsf"; // save the current filename to the config file conf->writeEntry(APP_KEY+"document", filename); saveConf(); } //if (filename == "INVALIDPWD") //filename = ""; QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); -#ifdef WIN32 +#ifdef Q_WS_WIN this->setCaption("Qt ZSafe: " + ti); #else this->setCaption("ZSafe: " + ti); #endif selectedItem = NULL; lastSearchedCategory = NULL; lastSearchedItem = NULL; lastSearchedName = ""; lastSearchedUsername = ""; lastSearchedComment = ""; - infoForm = new InfoForm(); + infoForm = new InfoForm(this, "show_info", TRUE); categoryDialog = NULL; infoForm->setIcon( image0); // add a menu bar QMenuBar *menu = new QMenuBar( this ); // add file menu // QPopupMenu *file = new QPopupMenu( this ); file = new QPopupMenu( this ); // #ifdef DESKTOP file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); @@ -761,53 +761,63 @@ void ZSafe::deletePwd() { delCategory(); } } 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 + NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE); +#ifdef Q_WS_WIN dialog->setCaption ("Qt " + tr("Edit Entry")); 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)); QString comment = selectedItem->text (3); comment.replace (QRegExp("<br>"), "\n"); dialog->Field5->setText(selectedItem->text (4)); dialog->Field6->setText(selectedItem->text (5)); dialog->CommentField->insertLine(comment); dialog->CommentField->setCursorPosition(0,0); +#ifdef Q_WS_QWS DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); +#endif #ifdef DESKTOP - result = Accepted; +#ifndef Q_QW_QWIN + dialog->show(); +#endif +#else + dialog->showMaximized(); +#endif + int result = dialog->exec(); +#ifdef DESKTOP +// result = QDialog::Accepted; #endif if (result == Accepted) { modified = true; // edit the selected item QString name = dialog->NameField->text(); selectedItem->setText (0, tr (name)); QString user = dialog->UsernameField->text(); selectedItem->setText (1, tr (user)); QString pwd = dialog->PasswordField->text(); selectedItem->setText (2, tr (pwd)); QString comment = dialog->CommentField->text(); @@ -831,41 +841,52 @@ 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 + NewDialog *dialog = new NewDialog(this, "new_entry", TRUE); +#ifdef Q_WS_WIN dialog->setCaption ("Qt " + tr("New Entry")); 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: +#ifdef Q_WS_QWS DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); +#endif + #ifdef DESKTOP - result = Accepted; +#ifndef Q_QW_QWIN + dialog->show(); +#endif +#else + dialog->showMaximized(); +#endif +#ifdef DESKTOP + int result = dialog->exec(); +// result = QDialog::Accepted; #endif if (result == Accepted) { 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 :-) } @@ -889,25 +910,25 @@ retype: i->setText (5, tr (f6)); } delete dialog; } } void ZSafe::findPwd() { // open the 'Search' dialog SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); -#ifdef WIN32 +#ifdef Q_WS_WIN dialog->setCaption ("Qt " + tr("Search")); #endif #ifdef DESKTOP #endif if (lastSearchedName) dialog->NameField->setText(lastSearchedName); else dialog->NameField->setText(""); if (lastSearchedUsername) dialog->UsernameField->setText(lastSearchedUsername); else @@ -1069,55 +1090,55 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) { QListViewItem *cat = _item->parent(); category = cat->text(0); } } else { return def; } QString app_key = APP_KEY; #ifndef DESKTOP -#ifndef WIN32 +#ifndef Q_WS_WIN conf->setGroup ("fieldDefs"); #endif #else -#ifndef WIN32 +#ifndef Q_WS_WIN app_key += "/fieldDefs/"; #endif #endif -// #ifndef WIN32 +// #ifndef Q_WS_WIN QString label = conf->readEntry(app_key+category+"-field"+field,def); // #else // QString label(def); // #endif #ifndef DESKTOP conf->setGroup ("zsafe"); #endif return label; } QString ZSafe::getFieldLabel (QString category, QString field, QString def) { QString app_key = APP_KEY; #ifndef DESKTOP conf->setGroup ("fieldDefs"); #else -#ifndef WIN32 +#ifndef Q_WS_WIN app_key += "/fieldDefs/"; #endif #endif -// #ifndef WIN32 +// #ifndef Q_WS_WIN 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) @@ -1199,48 +1220,54 @@ void ZSafe::showInfo( QListViewItem *_item) text += "<u><b>"; text += getFieldLabel (selectedItem, "4", tr("Comment")); text += ":<br> </b></u>"; QString comment = selectedItem->text(3); comment.replace (QRegExp("\n"), "<br>"); text += comment; // text += "<br>"; } text += "</body></html>"; infoForm->InfoText->setText(text); - infoForm->hide(); +// infoForm->hide(); +#ifdef Q_WS_QWS QPEApplication::showDialog( infoForm ); +#endif + +#ifdef DESKTOP + infoForm->show(); +#endif } } void ZSafe::listViewSelected( QListViewItem *_item) { if (!_item) return; if (selectedItem != NULL) selectedItem->setSelected(FALSE); selectedItem = _item; #ifndef DESKTOP // 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 -#ifdef WIN32 +#ifdef Q_WS_WIN // 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) @@ -1477,25 +1504,25 @@ void ZSafe::readAllEntries() #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 +#ifndef Q_WS_WIN char buffer[s.length()+1]; #else char buffer[4048]; #endif /* modify QString -> QCString::utf8 */ strcpy (buffer, s.utf8()); QString name; QString user; @@ -1576,25 +1603,25 @@ void ZSafe::readAllEntries() item->setText( 3, tr( comment ) ); item->setText( 4, tr( field5 ) ); item->setText( 5, tr( field6 ) ); catI->setOpen( TRUE ); Category *c1 = new Category(); c1->setCategoryName(category); QString icon; QString fullIconPath; QPixmap *pix; -// #ifndef WIN32 +// #ifndef Q_WS_WIN icon = conf->readEntry(APP_KEY+category); // #endif bool isIconAv = false; if (!icon.isEmpty() && !icon.isNull()) { // build the full path fullIconPath = iconPath + icon; pix = new QPixmap (fullIconPath); if (!pix->isNull()) { QImage img = pix->convertToImage(); pix->convertFromImage(img.smoothScale(14,14)); @@ -1729,25 +1756,25 @@ void ZSafe::readAllEntries() #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 +#ifdef Q_WS_WIN char buffer[512]; #else char buffer[len]; #endif strcpy (buffer, s); QString name; QString user; QString password; QString comment; // separete the entries @@ -1809,25 +1836,25 @@ void ZSafe::readAllEntries() item->setText( 1, tr( user ) ); item->setText( 2, tr( password ) ); item->setText( 3, tr( comment ) ); catI->setOpen( TRUE ); Category *c1 = new Category(); c1->setCategoryName(category); QString icon; QString fullIconPath; QPixmap *pix; -// #ifndef WIN32 +// #ifndef Q_WS_WIN icon = conf->readEntry(APP_KEY+category); // #endif bool isIconAv = false; if (!icon.isEmpty() && !icon.isNull()) { // build the full path fullIconPath = iconPath + icon; pix = new QPixmap (fullIconPath); if (!pix->isNull()) { QImage img = pix->convertToImage(); pix->convertFromImage(img.smoothScale(14,14)); @@ -1887,25 +1914,25 @@ void ZSafe::resume(int) // ask for password and read again openDocument(filename); } } //--------------------------------------------- bool ZSafe::openDocument(const char* _filename, const char* ) { int retval; char* entry[FIELD_SIZE]; -// #ifndef WIN32 +// #ifndef Q_WS_WIN int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); // #else // int validationFlag = 1; // #endif int pwdOk = 0; int numberOfTries = 3; for (int i=0; i < numberOfTries; i++) { QFile f(_filename); if (f.exists()) { @@ -1928,25 +1955,25 @@ bool ZSafe::openDocument(const char* _filename, const char* ) if (retval != PWERR_GOOD) { #ifndef NO_OPIE owarn << "Error loading Document" << oendl; #else qWarning ("Error loading Document"); #endif return false; } } else { -#ifdef WIN32 +#ifdef Q_WS_WIN this->setCaption("Qt ZSafe"); #else this->setCaption("ZSafe"); #endif filename = ""; return false; } // load the validation entry if (validationFlag == 0) { @@ -2045,25 +2072,25 @@ bool ZSafe::openDocument(const char* _filename, const char* ) item->setText( 4, tr( field5 ) ); item->setText( 5, tr( field6 ) ); if (expandTree) catI->setOpen( TRUE ); Category *c1 = new Category(); c1->setCategoryName(category); QString icon; QString fullIconPath; QPixmap *pix; -// #ifndef WIN32 +// #ifndef Q_WS_WIN icon = conf->readEntry(APP_KEY+category); // #endif bool isIconAv = false; if (!icon.isEmpty() && !icon.isNull()) { // build the full path fullIconPath = iconPath + icon; pix = new QPixmap (fullIconPath); if (!pix->isNull()) { QImage img = pix->convertToImage(); pix->convertFromImage(img.smoothScale(14,14)); @@ -2131,42 +2158,42 @@ int ZSafe::loadInit(const char* _filename, const char *password) load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; 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); -#ifndef WIN32 +#ifndef Q_WS_WIN size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); #else size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); #endif 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]; } size = 0; bufferIndex = 0; -#ifndef WIN32 +#ifndef Q_WS_WIN while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { while (count < 8) { count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); #else 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; @@ -2330,25 +2357,25 @@ bool ZSafe::saveDocument(const char* _filename, 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 +// #ifndef Q_WS_WIN conf->writeEntry(APP_KEY+"valzsafe", 1); // #endif saveConf(); } QListViewItem *i; // step through all categories for (i = ListView->firstChild(); i != NULL; i = i->nextSibling()) { // step through all subitems @@ -2425,25 +2452,25 @@ void ZSafe::getDocPassword(QString title) newPwdDialog = dialog; newPwdDialogResult = false; QPixmap image0( ( const char** ) zsafe_xpm ); dialog->setIcon( image0); connect( dialog->PasswordField, SIGNAL( returnPressed() ), this, SLOT( setPasswordDialogDone() ) ); // CS: !!! // int pos = filename.findRev ('/'); QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); -#ifdef WIN32 +#ifdef Q_WS_WIN dialog->setCaption("Qt " + ti); #else dialog->setCaption(ti); #endif // dialog->setCaption(title); dialog->PasswordField->setFocus(); DialogCode result = (DialogCode) dialog->exec(); #ifdef DESKTOP result = Accepted; #endif @@ -2655,36 +2682,36 @@ void ZSafe::addCategory() { // open the 'Category' dialog bool initIcons = false; // open the 'Category' dialog CategoryDialog *dialog; if (categoryDialog) { dialog = categoryDialog; } else { categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); -#ifdef WIN32 +#ifdef Q_WS_WIN categoryDialog->setCaption ("Qt " + tr("Category")); #endif dialog = categoryDialog; connect( dialog->CategoryField, SIGNAL( activated(const QString&)), this, SLOT( categoryFieldActivated(const QString&) ) ); initIcons = true; } #ifdef DESKTOP -#ifndef WIN32 +#ifndef Q_WS_WIN 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' @@ -2709,25 +2736,25 @@ void ZSafe::addCategory() } #endif QStringList::Iterator it = list.begin(); QString categ; QString firstCategory; dialog->CategoryField->clear(); // remove all items while( it != list.end() ) { QString *cat = new QString (*it); if (cat->contains("-field1", FALSE)) { #ifdef DESKTOP -#ifndef WIN32 +#ifndef Q_WS_WIN categ = cat->section ("-field1", 0, 0); #else 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()) { @@ -2777,25 +2804,25 @@ void ZSafe::addCategory() 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 +#ifndef Q_WS_WIN dialog->show(); #endif #ifndef DESKTOP // dialog->move (20, 100); #endif DialogCode result = (DialogCode) dialog->exec(); #ifdef DESKTOP result = Accepted; #endif QString category; QString icon; @@ -2816,25 +2843,25 @@ void ZSafe::addCategory() 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); if (!pix->isNull()) { // save the full pixmap name into the config file -// #ifndef WIN32 +// #ifndef Q_WS_WIN conf->writeEntry(APP_KEY+category, icon); // #endif saveConf(); QImage img = pix->convertToImage(); pix->convertFromImage(img.smoothScale(14,14)); c1->setIcon (*pix); c1->setIconName(icon); } else { QPixmap folder( ( const char** ) general_data ); c1->setIcon (folder); @@ -2868,25 +2895,25 @@ void ZSafe::delCategory() return; if (isCategory(selectedItem)) { switch( QMessageBox::information( this, tr("ZSafe"), tr("Do you want to 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 +// #ifndef Q_WS_WIN conf->removeEntry (selectedItem->text(0)); // #endif saveConf(); // Delete the selected item and all subitems // step through all subitems QListViewItem *si; for (si = selectedItem->firstChild(); si != NULL; ) { QListViewItem *_si = si; si = si->nextSibling(); @@ -3028,30 +3055,30 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) } ++it; } } } void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) { QString app_key = APP_KEY; #ifndef DESKTOP conf->setGroup ("fieldDefs"); #else -#ifndef WIN32 +#ifndef Q_WS_WIN app_key += "/fieldDefs/"; #endif #endif QString category = dialog->CategoryField->currentText(); -// #ifndef WIN32 +// #ifndef Q_WS_WIN conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); // #endif saveConf(); #ifndef DESKTOP conf->setGroup ("zsafe"); #endif } @@ -3064,37 +3091,37 @@ void ZSafe::editCategory() { QString category = selectedItem->text(0); bool initIcons = false; // open the 'Category' dialog CategoryDialog *dialog; if (categoryDialog) { dialog = categoryDialog; } else { categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); -#ifdef WIN32 +#ifdef Q_WS_WIN categoryDialog->setCaption ("Qt " + tr("Category")); #endif dialog = categoryDialog; connect( dialog->CategoryField, SIGNAL( activated(const QString&)), this, SLOT( categoryFieldActivated(const QString&) ) ); initIcons = true; } setCategoryDialogFields(dialog); #ifdef DESKTOP -#ifndef WIN32 +#ifndef Q_WS_WIN 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' @@ -3120,25 +3147,25 @@ void ZSafe::editCategory() #endif QStringList::Iterator it = list.begin(); QString categ; dialog->CategoryField->clear(); // remove all items int i=0; bool foundCategory = false; while( it != list.end() ) { QString *cat = new QString (*it); if (cat->contains("-field1", FALSE)) { #ifdef DESKTOP -#ifndef WIN32 +#ifndef Q_WS_WIN categ = cat->section ("-field1", 0, 0); #else 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()) { @@ -3263,25 +3290,25 @@ void ZSafe::editCategory() #ifdef DESKTOP result = Accepted; #endif QString fullIconPath; QPixmap *pix; if (result == Accepted) { modified = true; if (category != dialog->CategoryField->currentText()) { categories.remove (category); -// #ifndef WIN32 +// #ifndef Q_WS_WIN conf->removeEntry(category); // #endif saveConf(); } category = dialog->CategoryField->currentText(); icon = dialog->IconField->currentText()+".png"; if (cat) { #ifndef NO_OPIE owarn << "Category found" << oendl; @@ -3289,37 +3316,37 @@ void ZSafe::editCategory() 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()) { // save the full pixmap name into the config file -// #ifndef WIN32 +// #ifndef Q_WS_WIN conf->writeEntry(APP_KEY+category, icon); // #endif saveConf(); QImage img = pix->convertToImage(); pix->convertFromImage(img.smoothScale(14,14)); cat->setIconName (icon); cat->setIcon (*pix); } } else { -// #ifndef WIN32 +// #ifndef Q_WS_WIN conf->removeEntry (category); // #endif 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; @@ -3480,25 +3507,25 @@ void ZSafe::newDocument() if (c) delete c; // delete the previous category categories.clear(); // m_password = ""; 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 +#ifdef Q_WS_WIN 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(); } @@ -3564,25 +3591,25 @@ void ZSafe::loadDocument() } } if (c) delete c; // delete the previous category categories.clear(); m_password = ""; 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 +#ifdef Q_WS_WIN this->setCaption("Qt ZSafe: " + ti); #else this->setCaption("ZSafe: " + ti); #endif openDocument(filename); } } void ZSafe::saveDocumentAs() { @@ -3618,25 +3645,25 @@ void ZSafe::saveDocumentAs() { // 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 +#ifdef Q_WS_WIN 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(); } } @@ -3697,25 +3724,25 @@ void ZSafe::about() QPixmap zsafe_img((const char**) zsafe_xpm); mb.setIconPixmap (zsafe_img); mb.exec(); } void ZSafe::setExpandFlag() { expandTree = !expandTree; file->setItemChecked('o', expandTree); #ifndef DESKTOP conf->setGroup ("zsafePrefs"); #endif -// #ifndef WIN32 +// #ifndef Q_WS_WIN conf->writeEntry (APP_KEY+"expandTree", expandTree); // #endif saveConf(); } void ZSafe::paintEvent( QPaintEvent * ) { if (raiseFlag) { raiseFlag = false; raiseTimer.start (1, true); @@ -3782,25 +3809,25 @@ void ZSafe::setDocument(const QString& fileref) filename = link.file(); } else { // if (filename != fileref) // saveDocument(filename, FALSE); filename = fileref; } // 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 +#ifdef Q_WS_WIN this->setCaption("Qt ZSafe: " + ti); #else this->setCaption("ZSafe: " + ti); #endif // clear the password list QListViewItem *i; QListViewItem *c = NULL; // step through all categories for (i = ListView->firstChild(); i != NULL; i = i->nextSibling()) |