author | drw <drw> | 2004-02-23 17:12:28 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-23 17:12:28 (UTC) |
commit | 2f11aa15eeb70dd8826523597adb8947fdffbaa7 (patch) (side-by-side diff) | |
tree | acc6ceb27c67437734e94b39b06835edac5d5bad | |
parent | 20b0e62e6c23cdaed9a30d6fad73431edc60be53 (diff) | |
download | opie-2f11aa15eeb70dd8826523597adb8947fdffbaa7.zip opie-2f11aa15eeb70dd8826523597adb8947fdffbaa7.tar.gz opie-2f11aa15eeb70dd8826523597adb8947fdffbaa7.tar.bz2 |
ZSafe: libopie->libopie2
-rw-r--r-- | noncore/apps/zsafe/config.in | 2 | ||||
-rw-r--r-- | noncore/apps/zsafe/opie-zsafe.control | 2 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.pro | 2 |
4 files changed, 7 insertions, 4 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 @@ -1,1567 +1,1570 @@ /**************************************************************************** ** ** 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 ** ** 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" #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> #include <stdlib.h> #ifndef WIN32 #include <unistd.h> #endif #include <string.h> #include <errno.h> #include <qmenubar.h> #include <qpopupmenu.h> #ifdef DESKTOP #include <qfiledialog.h> #ifndef WIN32 #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> #endif #include <qtimer.h> #include <qlayout.h> #include <qmessagebox.h> #include <qfile.h> #include <qtextstream.h> #include <qheader.h> #include <qlistview.h> #include <qtoolbutton.h> #include <qlayout.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qimage.h> #include <qpixmap.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qregexp.h> #include <qdir.h> #include <qtextbrowser.h> #include <qlabel.h> #include <qcombobox.h> #include "krc2.h" #include "wait.h" 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 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" #include "pics/zsafe/editdelete.xpm" #include "pics/zsafe/find.xpm" #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[] = { "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", "n c #cd4883", "e c #d5ae10", "f c #de3ce6", "i c #e640e6", "c c #ffffff", "..............", ".###########..", ".#ababababa#..", ".#babbbabbb#..", ".#ccccccccc#..", ".#cdcefcghc#..", ".#ccccccccc#..", ".#cicjkclic#..", ".#ccccccccc#..", ".#cmchlcnec#..", ".#ccccccccc#..", ".###########..", "..............", ".............."}; 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", "o c #c5c2ff", "k c #c5ffc5", "f c #ff0000", "d c #ff8100", "b c #ffaa5a", "e c #ffc2c5", "c c #ffdeac", "i c #ffff00", "g c #ffffc5", "............###.", "...........#abb#", "..........#cbab#", ".........#cbdd#.", "######..#cbdd#..", "#eeff#..#add#...", "#eeff#######....", "#ccdbdd#........", "#dddbdd###......", "#gghihhjj#......", "#hhhihhjj###....", "#kklmllnnnn#....", "#lllmllnnnn#....", "#oopqpprprr#....", "#oopqpprprr#....", "############...."}; 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[] = { "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", "#D c #202820", "#y c #292c29", ".c c #293029", ".d c #313031", "#E c #313429", "#r c #313831", ".j c #393c31", "#j c #394039", "#C c #414841", ".w c #4a554a", ".a c #4a594a", ".# c #525052", ".l c #52594a", "#f c #525952", "#v c #525d52", ".O c #5a4c4a", ".9 c #5a595a", ".A c #5a5d52", ".B c #624c52", ".0 c #625552", "#o c #626562", ".R c #626962", "#. c #626d5a", "#p c #626d62", ".2 c #627162", "#h c #6a6d62", "#z c #6a7562", "#w c #6a756a", ".C c #73656a", ".P c #73696a", "#a c #737d6a", ".U c #738573", ".E c #7b817b", "#B c #7b857b", "#s c #7b897b", "#n c #7b917b", ".b c #838d83", ".7 c #839583", ".n c #8b7d7b", "#g c #8b8583", ".g c #8b858b", ".r c #8b898b", ".s c #8b8d8b", ".i c #8b9183", ".8 c #8b918b", "#A c #8b9d8b", ".S c #8ba183", ".Z c #94918b", ".N c #949994", ".F c #949d94", ".x c #94a18b", ".v c #94a194", ".Y c #94aa94", ".h c #9c999c", ".Q c #9ca19c", "#u c #9ca59c", ".H c #9caa9c", "#e c #9cb29c", "#m c #a4b29c", "#t c #a4b2a4", ".M c #a4b69c", "#l c #a4b6a4", ".z c #a4baa4", ".f c #aca5ac", ".q c #acaaac", "#d c #acbeac", ".6 c #acc2ac", ".o c #b4b2b4", ".t c #b4beb4", "#k c #b4c2ac", ".5 c #b4cab4", ".D c #bdb6bd", ".G c #bdc6b4", "#c c #bdceb4", ".X c #bdd2bd", ".4 c #bdd6bd", ".1 c #c5bec5", ".e c #c5c2c5", ".u c #c5cac5", "#b c #c5d6c5", ".J c #c5dec5", ".p c #cdcacd", ".W c #cddecd", ".L c #cde2cd", ".K c #d5eacd", ".V c #d5ead5", ".y c #d5eed5", "QtQtQtQtQtQtQtQtQtQtQtQtQtQt", "QtQtQt.#.a.b.cQtQtQtQtQtQtQt", "QtQt.d.e.f.g.h.i.c.j.dQt.kQt", ".a.l.m.n.o.p.q.r.s.t.u.v.wQt", ".x.y.z.A.B.C.D.p.q.E.F.G.H.I", ".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", "Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", "Qt.3.X.W.4.X.5.6.7.8.9.s#.##", "QtQt#a.X#b#c.5.6#d#e#f#g#h#i", "QtQtQt#j.7#k.6#d#l#m#n#o#p#q", "QtQtQtQt.k#r#s#m#t.H#u#v#w#x", "QtQtQtQtQtQt.k#y#z.v#A#B#C#x", "QtQtQtQtQtQtQtQt.k#D.w#s#E.k", "QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; // exit ZSafe and clear the clipboard for security reasons void ZSafe::exitZs (int ec) { QClipboard *cb = QApplication::clipboard(); cb->clear(); exit (ec); } // save the configuration into the file void ZSafe::saveConf () { if (conf) { delete conf; #ifdef DESKTOP #ifndef WIN32 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 } } /* * 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 ), 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 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 #else conf = new Config (cfgFile, Config::File); conf->setGroup ("zsafePrefs"); #endif #ifdef DESKTOP // #ifndef WIN32 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); QPixmap editdelete_img((const char**) editdelete_xpm); QPixmap find_img((const char**) find_xpm); QPixmap folder_open_img((const char**) folder_open_xpm); QPixmap help_icon_img((const char**) help_icon_xpm); QPixmap new_img((const char**) new_xpm); QPixmap paste_img((const char**) paste_xpm); 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" ); #ifdef DESKTOP #ifdef WIN32 setGeometry(100, 150, DeskW, DeskH-30 ); #else resize( DeskW, DeskH-30 ); #endif #else #ifdef JPATCH_HDE int DeskS; if(DeskW > DeskH) { DeskS = DeskW; } else { DeskS = DeskH; } resize( DeskW, DeskH ); setMinimumSize( QSize( DeskS, DeskS ) ); setMaximumSize( QSize( DeskS, DeskS ) ); #else resize( DeskW, DeskH-30 ); #endif #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"); // #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"); 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 = ""; QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); #ifdef WIN32 this->setCaption("Qt ZSafe: " + ti); #else this->setCaption("ZSafe: " + ti); #endif selectedItem = NULL; lastSearchedCategory = NULL; lastSearchedItem = NULL; lastSearchedName = ""; lastSearchedUsername = ""; lastSearchedComment = ""; infoForm = new InfoForm(); categoryDialog = NULL; // 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()) ); 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, 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, 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 ); QPopupMenu *it = new QPopupMenu( this ); it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); it->insertSeparator(); it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); 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->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->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->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->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 ) ); #else ListView->setResizePolicy(QScrollView::AutoOneFit); // 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() ) ); raiseFlag = true; connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); #else // open the default document openDocument(filename); #endif // signals and slots connections for QTollButton connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); // signals and slots connections for QListView connect( ListView, SIGNAL( selectionChanged( QListViewItem* ) ), 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"), 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; } } else { 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 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); 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(); 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(); comment.replace (QRegExp("\n"), "<br>"); selectedItem->setText (3, tr (comment)); QString f5 = dialog->Field5->text(); selectedItem->setText (4, tr (f5)); QString f6 = dialog->Field6->text(); selectedItem->setText (5, tr (f6)); } delete dialog; } 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 ); #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(); 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(); i->setText (1, tr (user)); QString pwd = dialog->PasswordField->text(); i->setText (2, tr (pwd)); QString comment = dialog->CommentField->text(); comment.replace (QRegExp("\n"), "<br>"); i->setText (3, tr (comment)); QString f5 = dialog->Field5->text(); i->setText (4, tr (f5)); 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); #ifdef WIN32 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 dialog->UsernameField->setText(""); if (lastSearchedComment) dialog->CommentField->setText(lastSearchedComment); else dialog->CommentField->setText(""); DialogCode result = (DialogCode) dialog->exec(); #ifdef DESKTOP result = Accepted; #endif QString name; QString username; QString comment; if (result == Accepted) { name = dialog->NameField->text(); username = dialog->UsernameField->text(); comment = dialog->CommentField->text(); qWarning (name); } else { delete dialog; return; } if (!name.isEmpty() && name != lastSearchedName || lastSearchedName.isEmpty() && !name.isEmpty()) { // set search at the beginning if a new name is given lastSearchedCategory = NULL; lastSearchedItem = NULL; } lastSearchedName = name; if (!username.isEmpty() && username != lastSearchedUsername || lastSearchedUsername.isEmpty() && !username.isEmpty()) { // set search at the beginning if a new name is given lastSearchedCategory = NULL; lastSearchedItem = NULL; } lastSearchedUsername = username; if (!comment.isEmpty() && comment != lastSearchedComment || lastSearchedComment.isEmpty() && !comment.isEmpty()) { // set search at the beginning if a new name is given lastSearchedCategory = NULL; lastSearchedItem = NULL; } lastSearchedComment = comment; ListView->clearSelection(); bool found=FALSE; // step through all categories QListViewItem *i; if (lastSearchedCategory) i = lastSearchedCategory; else i = ListView->firstChild(); 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 != 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; if (!name.isEmpty()) n = (si->text(0)).contains (name, FALSE); if (!username.isEmpty()) u = (si->text(1)).contains (username, FALSE); if (!comment.isEmpty()) c = (si->text(3)).contains (comment, FALSE); if ((n && u && c ) && !found) { qWarning ("Found"); selectedItem = si; si->setSelected(TRUE); ListView->setCurrentItem(si); ListView->ensureItemVisible(si); ListView->triggerUpdate(); lastSearchedCategory = i; // set to the next item lastSearchedItem = si->nextSibling(); if (!lastSearchedItem) { // no next item within category -> set next category lastSearchedCategory = i->nextSibling(); if (!lastSearchedCategory) lastSearchedItem = NULL; // END } found = TRUE; delete dialog; update(); return; } } lastSearchedCategory = i->nextSibling(); lastSearchedItem = NULL; } lastSearchedCategory = NULL; lastSearchedItem = NULL; delete dialog; update(); 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 { QListViewItem *cat = _item->parent(); category = cat->text(0); } } else { return def; } QString app_key = APP_KEY; #ifndef DESKTOP #ifndef WIN32 conf->setGroup ("fieldDefs"); #endif #else #ifndef WIN32 app_key += "/fieldDefs/"; #endif #endif // #ifndef WIN32 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 app_key += "/fieldDefs/"; #endif #endif // #ifndef WIN32 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"; label+=selectedItem->text(3); */ QString text; QString entry; text = "<html><body><div align=""center""><u><b>"; text += selectedItem->text(0); text += "</b></u><br></div><br>"; entry = selectedItem->text(1); if (!entry.isEmpty() && entry.compare(" ")) { text += "<u><b>"; text += getFieldLabel (selectedItem, "2", tr("Username")); text += ":<br></b></u><blockquote>"; text += entry; text += "</blockquote>"; // text += "<br>"; } entry = selectedItem->text(2); if (!entry.isEmpty() && entry.compare(" ")) { text += "<u><b>"; text += getFieldLabel (selectedItem, "3", tr("Password")); text += ":<br> </b></u><blockquote>"; text += entry; text += "</blockquote>"; // text += "<br>"; } entry = selectedItem->text(4); if (!entry.isEmpty() && entry.compare(" ")) { text += "<u><b>"; text += getFieldLabel (selectedItem, "5", tr("Field 4")); text += ":<br> </b></u><blockquote>"; text += entry; text += "</blockquote>"; // text += "<br>"; } entry = selectedItem->text(5); if (!entry.isEmpty() && entry.compare(" ")) { text += "<u><b>"; text += getFieldLabel (selectedItem, "6", tr("Field 5")); text += ":<br> </b></u><blockquote>"; text += entry; text += "</blockquote>"; // text += "<br>"; } entry = selectedItem->text(3); if (!entry.isEmpty() && entry.compare(" ")) { 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(); QPEApplication::showDialog( infoForm ); } } 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 // set the column text dependent on the selected item ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); #endif } bool ZSafe::isCategory(QListViewItem *_item) { if (_item == NULL) return FALSE; QString categoryName = _item->text (0); if (categories.find (categoryName)) return TRUE; else return FALSE; } void ZSafe::removeAsciiFile() { // QString fn = filename + ".txt"; // open the file dialog #ifndef DESKTOP #ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; mimeTypes.insert(tr("All"), QStringList() ); mimeTypes.insert(tr("Text"), "text/*" ); QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, QDir::homeDirPath() + "/Documents/application/zsafe", QString::null, mimeTypes, this, tr ("Remove text file")); #else QString fn = ScQtFileEdit::getOpenFileName(this, tr ("Remove text file"), QDir::homeDirPath() + "/Documents/application/zsafe", "*.txt"); #endif #else QString fn = QFileDialog::getOpenFileName( QDir::homeDirPath() + "/Documents/application/zsafe", "ZSafe (*.txt)", this, "ZSafe File Dialog" "Choose a text file" ); #endif if (fn && fn.length() > 0 ) { QFile f( fn ); if ( !f.remove() ) { qWarning( QString("Could not remove file %1").arg(fn), 2000 ); QMessageBox::critical( 0, tr("ZSafe"), tr("Could not remove text file.") ); return; } } } void ZSafe::writeAllEntries() { if (filename.isEmpty()) { QMessageBox::critical( 0, tr("ZSafe"), tr("No document defined.\nYou have to create a new document")); return; } // open the file dialog #ifndef DESKTOP #ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; mimeTypes.insert(tr("All"), QStringList() ); mimeTypes.insert(tr("Text"), "text/*" ); QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, QDir::homeDirPath() + "/Documents/application/zsafe", QString::null, mimeTypes, this, tr ("Export text file")); #else QString fn = ScQtFileEdit::getSaveAsFileName(this, tr ("Export text file"), QDir::homeDirPath() + "/Documents/application/zsafe", "*.txt"); #endif #else QString fn = QFileDialog::getSaveFileName( QDir::homeDirPath() + "/Documents/application/zsafe", "ZSafe (*.txt)", this, "ZSafe File Dialog" "Choose a text file" ); #endif // open the new document if (fn && fn.length() > 0 ) { QFile f( fn ); if ( !f.open( IO_WriteOnly ) ) { qWarning( QString("Could not write to file %1").arg(fn), 2000 ); 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(); i != NULL; i = i->nextSibling()) { // step through all subitems QListViewItem *si; 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); oneEntry += "\";"; oneEntry += "\""; oneEntry += si->text(2); oneEntry += "\";"; oneEntry += "\""; QString comment = si->text(3); comment.replace (QRegExp("\n"), "<br>"); oneEntry += comment; oneEntry += "\";"; oneEntry += "\""; oneEntry += si->text(4); oneEntry += "\";"; oneEntry += "\""; oneEntry += si->text(5); oneEntry += "\""; // qWarning (oneEntry); t << oneEntry << endl; // qWarning (si->text(0)); } } f.close(); } } void ZSafe::readAllEntries() { if (filename.isEmpty()) { QMessageBox::critical( 0, tr("ZSafe"), tr("No document defined.\nYou have to create a new document")); return; } // open the file dialog #ifndef DESKTOP #ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; mimeTypes.insert(tr("All"), QStringList() ); mimeTypes.insert(tr("Text"), "text/*" ); QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, QDir::homeDirPath() + "/Documents/application/zsafe", QString::null, mimeTypes, this, tr ("Import text file")); #else QString fn = ScQtFileEdit::getOpenFileName(this, tr ("Import text file"), QDir::homeDirPath() + "/Documents/application/zsafe", "*.txt"); #endif #else QString fn = QFileDialog::getOpenFileName( QDir::homeDirPath() + "/Documents/application/zsafe", "ZSafe (*.txt)", this, "ZSafe File Dialog" "Choose a text file" ); #endif if (fn && fn.length() > 0 ) { QFile f( fn ); if ( !f.open( IO_ReadOnly ) ) { qWarning( QString("Could not read file %1").arg(fn), 2000 ); QMessageBox::critical( 0, "ZSafe", QString("Could not import text file.") ); return; } modified = true; // clear the password list selectedItem = NULL; QListViewItem *i; // step through all categories for (i = ListView->firstChild(); i != NULL; i = i->nextSibling()) { // step through all subitems QListViewItem *si; for (si = i->firstChild(); si != NULL; ) // 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() ) { QString s = t.readLine(); s.replace (QRegExp("\";\""), "\"|\""); // char buffer[1024]; #ifndef WIN32 char buffer[s.length()+1]; #else 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])); category.truncate(category.length() -1); int idx=0; while ((i = strtok (NULL, "|")) != NULL) { switch (idx) { case 0: name = QString::fromUtf8(&i[1]); name.truncate(name.length() -1); // name break; case 1: // user user = QString::fromUtf8(&i[1]); user.truncate(user.length() -1); break; case 2: // password password = QString::fromUtf8(&i[1]); password.truncate(password.length() -1); break; case 3: // comment comment = QString::fromUtf8(&i[1]); comment.truncate(comment.length() -1); 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++; } 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 ) ); item->setText( 2, tr( password ) ); item->setText( 3, tr( comment ) ); item->setText( 4, tr( field5 ) ); item->setText( 5, tr( field6 ) ); catItem->setOpen( TRUE ); } } else { QListViewItem *catI = new ShadedListItem( 1, ListView ); // create and insert a new item QListViewItem * item = new ShadedListItem( 0, catI ); item->setText( 0, tr( name ) ); item->setText( 1, tr( user ) ); item->setText( 2, tr( password ) ); 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 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) { QImage img = pix->convertToImage(); pix->convertFromImage(img.smoothScale(14,14)); c1->setIconName (icon); c1->setIcon (*pix); isIconAv = true; } } if (!isIconAv) { c1->setIcon (*getPredefinedIcon(category)); } c1->setListItem (catI); c1->initListItem(); categories.insert (c1->getCategoryName(), c1); } 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 DESTDIR = $(OPIEDIR)/bin HEADERS = zsafe.h krc2.h category.h categorylist.h zlistview.h \ scqtfiledlg.h SOURCES = main.cpp zsafe.cpp krc2.cpp category.cpp \ categorylist.cpp zlistview.cpp shadedlistitem.cpp\ scqtfileedit.cpp scqtfileedit.moc.cpp \ scqtfiledlg.cpp INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui infoform.ui wait.ui INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopie +LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopieui2 TARGET = zsafe include ( $(OPIEDIR)/include.pro ) |