summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--pwmanager/pwmanager/configwnd.cpp11
-rw-r--r--pwmanager/pwmanager/pwm.cpp35
-rw-r--r--pwmanager/pwmanager/pwmanagerE.pro27
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp2
-rw-r--r--pwmanager/pwmanager/pwmdoc.h2
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp1
-rw-r--r--pwmanager/pwmanager/pwminit.cpp19
-rw-r--r--pwmanager/pwmanager/pwmtray.cpp4
-rw-r--r--pwmanager/pwmanager/pwmview.cpp4
-rw-r--r--pwmanager/pwmanager/serializer.cpp1
10 files changed, 83 insertions, 23 deletions
diff --git a/pwmanager/pwmanager/configwnd.cpp b/pwmanager/pwmanager/configwnd.cpp
index 230ca1b..108c40f 100644
--- a/pwmanager/pwmanager/configwnd.cpp
+++ b/pwmanager/pwmanager/configwnd.cpp
@@ -1,264 +1,265 @@
/****************************************************************************
** Form implementation generated from reading ui file 'configwnd.ui'
**
** Created: Tue Sep 14 15:20:58 2004
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "configwnd.h"
#include <qvariant.h>
#include <qpushbutton.h>
#include <qtabwidget.h>
#include <qwidget.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qspinbox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/*
* Constructs a configWnd as 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.
*/
configWnd::configWnd( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "configWnd" );
okButton = new QPushButton( this, "okButton" );
okButton->setGeometry( QRect( 10, 280, 107, 27 ) );
cancelButton = new QPushButton( this, "cancelButton" );
cancelButton->setGeometry( QRect( 370, 280, 107, 27 ) );
tabWidget2 = new QTabWidget( this, "tabWidget2" );
tabWidget2->setGeometry( QRect( 10, 10, 470, 260 ) );
+ //////////////////////////////
tab = new QWidget( tabWidget2, "tab" );
windowStyleComboBox = new QComboBox( FALSE, tab, "windowStyleComboBox" );
windowStyleComboBox->setGeometry( QRect( 220, 180, 210, 28 ) );
textLabel1_5 = new QLabel( tab, "textLabel1_5" );
textLabel1_5->setGeometry( QRect( 30, 180, 180, 20 ) );
textLabel1_5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
textLabel1_4 = new QLabel( tab, "textLabel1_4" );
textLabel1_4->setGeometry( QRect( 30, 40, 400, 20 ) );
selEntrFontButton = new QPushButton( tab, "selEntrFontButton" );
selEntrFontButton->setGeometry( QRect( 30, 90, 160, 27 ) );
currEntrFont = new QLabel( tab, "currEntrFont" );
currEntrFont->setGeometry( QRect( 30, 70, 230, 20 ) );
tabWidget2->insertTab( tab, QString("") );
-
+ //////////////////////////////////////
TabPage = new QWidget( tabWidget2, "TabPage" );
compressionComboBox = new QComboBox( FALSE, TabPage, "compressionComboBox" );
compressionComboBox->setGeometry( QRect( 290, 50, 150, 28 ) );
textLabel1_6 = new QLabel( TabPage, "textLabel1_6" );
textLabel1_6->setGeometry( QRect( 10, 50, 270, 20 ) );
textLabel1_6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
textLabel1_8 = new QLabel( TabPage, "textLabel1_8" );
textLabel1_8->setGeometry( QRect( 10, 90, 270, 20 ) );
textLabel1_8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
permissionLineEdit = new QLineEdit( TabPage, "permissionLineEdit" );
permissionLineEdit->setGeometry( QRect( 290, 90, 142, 27 ) );
permissionLineEdit->setMaxLength( 3 );
fileBackupCheckBox = new QCheckBox( TabPage, "fileBackupCheckBox" );
fileBackupCheckBox->setGeometry( QRect( 80, 140, 360, 23 ) );
tabWidget2->insertTab( TabPage, QString("") );
-
+ //////////////////////////////////////
tab_2 = new QWidget( tabWidget2, "tab_2" );
pwTimeoutSpinBox = new QSpinBox( tab_2, "pwTimeoutSpinBox" );
pwTimeoutSpinBox->setGeometry( QRect( 390, 50, 55, 23 ) );
textLabel1 = new QLabel( tab_2, "textLabel1" );
textLabel1->setGeometry( QRect( 10, 20, 370, 80 ) );
textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) );
textLabel1_7 = new QLabel( tab_2, "textLabel1_7" );
textLabel1_7->setGeometry( QRect( 10, 110, 370, 80 ) );
textLabel1_7->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) );
lockTimeoutSpinBox = new QSpinBox( tab_2, "lockTimeoutSpinBox" );
lockTimeoutSpinBox->setGeometry( QRect( 390, 140, 55, 23 ) );
autoDeepLockCheckBox = new QCheckBox( tab_2, "autoDeepLockCheckBox" );
autoDeepLockCheckBox->setGeometry( QRect( 60, 180, 380, 25 ) );
tabWidget2->insertTab( tab_2, QString("") );
-
+ ///////////////////////////////////////////
tab_3 = new QWidget( tabWidget2, "tab_3" );
textLabel1_3 = new QLabel( tab_3, "textLabel1_3" );
textLabel1_3->setGeometry( QRect( 30, 30, 400, 20 ) );
autoStartLineEdit = new QLineEdit( tab_3, "autoStartLineEdit" );
autoStartLineEdit->setGeometry( QRect( 30, 50, 360, 20 ) );
browseAutoStButton = new QPushButton( tab_3, "browseAutoStButton" );
browseAutoStButton->setGeometry( QRect( 400, 50, 30, 20 ) );
autostartDeeplockedCheckBox = new QCheckBox( tab_3, "autostartDeeplockedCheckBox" );
autostartDeeplockedCheckBox->setGeometry( QRect( 40, 80, 390, 25 ) );
tabWidget2->insertTab( tab_3, QString("") );
-
+ ////////////////////////////////////////////
tab_4 = new QWidget( tabWidget2, "tab_4" );
textLabel2 = new QLabel( tab_4, "textLabel2" );
textLabel2->setGeometry( QRect( 20, 40, 280, 20 ) );
textLabel2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
browserLineEdit = new QLineEdit( tab_4, "browserLineEdit" );
browserLineEdit->setGeometry( QRect( 310, 40, 130, 27 ) );
xtermLineEdit = new QLineEdit( tab_4, "xtermLineEdit" );
xtermLineEdit->setGeometry( QRect( 310, 100, 130, 27 ) );
textLabel3 = new QLabel( tab_4, "textLabel3" );
textLabel3->setGeometry( QRect( 20, 100, 280, 20 ) );
textLabel3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
tabWidget2->insertTab( tab_4, QString("") );
-
+ ///////////////////////////////////////////////
tab_5 = new QWidget( tabWidget2, "tab_5" );
trayCheckBox = new QCheckBox( tab_5, "trayCheckBox" );
trayCheckBox->setGeometry( QRect( 30, 30, 400, 20 ) );
openUnlockedCheckBox = new QCheckBox( tab_5, "openUnlockedCheckBox" );
openUnlockedCheckBox->setGeometry( QRect( 30, 80, 400, 20 ) );
autoMinimizeCheckBox = new QCheckBox( tab_5, "autoMinimizeCheckBox" );
autoMinimizeCheckBox->setEnabled( FALSE );
autoMinimizeCheckBox->setGeometry( QRect( 50, 50, 380, 25 ) );
minimizeLockComboBox = new QComboBox( FALSE, tab_5, "minimizeLockComboBox" );
minimizeLockComboBox->setGeometry( QRect( 310, 170, 120, 27 ) );
textLabel1_9 = new QLabel( tab_5, "textLabel1_9" );
textLabel1_9->setGeometry( QRect( 30, 180, 270, 20 ) );
textLabel1_9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
kwalletEmuCheckBox = new QCheckBox( tab_5, "kwalletEmuCheckBox" );
kwalletEmuCheckBox->setGeometry( QRect( 30, 110, 400, 25 ) );
wndCloseCheckBox = new QCheckBox( tab_5, "wndCloseCheckBox" );
wndCloseCheckBox->setGeometry( QRect( 30, 140, 430, 24 ) );
tabWidget2->insertTab( tab_5, QString("") );
languageChange();
resize( QSize(490, 318).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
// signals and slots connections
connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_slot() ) );
connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_slot() ) );
connect( browseAutoStButton, SIGNAL( clicked() ), this, SLOT( browseAutoStButton_slot() ) );
connect( selEntrFontButton, SIGNAL( clicked() ), this, SLOT( selEntrFontButton_slot() ) );
connect( trayCheckBox, SIGNAL( toggled(bool) ), autoMinimizeCheckBox, SLOT( setEnabled(bool) ) );
// tab order
setTabOrder( pwTimeoutSpinBox, trayCheckBox );
setTabOrder( trayCheckBox, okButton );
setTabOrder( okButton, cancelButton );
}
/*
* Destroys the object and frees any allocated resources
*/
configWnd::~configWnd()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void configWnd::languageChange()
{
setCaption( tr( "PwManager Configuration" ) );
okButton->setText( tr( "&OK" ) );
//US ENH okButton->setAccel( QKeySequence( tr( "Alt+O" ) ) );
cancelButton->setText( tr( "&Cancel" ) );
//US ENH cancelButton->setAccel( QKeySequence( tr( "Alt+C" ) ) );
windowStyleComboBox->clear();
windowStyleComboBox->insertItem( tr( "Category on top" ) );
windowStyleComboBox->insertItem( tr( "Category-list left" ) );
textLabel1_5->setText( tr( "Window-style:" ) );
textLabel1_4->setText( tr( "Font for the password entries:" ) );
selEntrFontButton->setText( tr( "select Font" ) );
currEntrFont->setText( QString::null );
tabWidget2->changeTab( tab, tr( "Look && feel" ) );
compressionComboBox->clear();
compressionComboBox->insertItem( tr( "none" ) );
compressionComboBox->insertItem( tr( "gzip" ) );
compressionComboBox->insertItem( tr( "bzip2" ) );
textLabel1_6->setText( tr( "*.pwm file compression:" ) );
textLabel1_8->setText( tr( "permissions:" ) );
fileBackupCheckBox->setText( tr( "Make file backup before saving" ) );
tabWidget2->changeTab( TabPage, tr( "File" ) );
textLabel1->setText( tr( "Password timeout (timeout to hold password in memory, so you don't have to re-enter it, if you already have entered it) [set to 0 to disable]:" ) );
textLabel1_7->setText( tr( "Auto-lock timeout (auto lock document after this amount of seconds) [set to 0 to disable]:" ) );
autoDeepLockCheckBox->setText( tr( "deep-lock on autolock" ) );
tabWidget2->changeTab( tab_2, tr( "Timeout" ) );
textLabel1_3->setText( tr( "Open this file automatically on startup:" ) );
browseAutoStButton->setText( tr( "..." ) );
autostartDeeplockedCheckBox->setText( tr( "open deeplocked" ) );
tabWidget2->changeTab( tab_3, tr( "Autostart" ) );
textLabel2->setText( tr( "Favourite browser:" ) );
textLabel3->setText( tr( "Favourite X-terminal:" ) );
tabWidget2->changeTab( tab_4, tr( "External apps" ) );
trayCheckBox->setText( tr( "Show icon in system-tray" ) );
openUnlockedCheckBox->setText( tr( "Open document with passwords unlocked" ) );
autoMinimizeCheckBox->setText( tr( "auto-minimize to tray on startup" ) );
minimizeLockComboBox->clear();
minimizeLockComboBox->insertItem( tr( "don't lock" ) );
minimizeLockComboBox->insertItem( tr( "normal lock" ) );
minimizeLockComboBox->insertItem( tr( "deep-lock" ) );
textLabel1_9->setText( tr( "auto-lock on minimize:" ) );
kwalletEmuCheckBox->setText( tr( "KWallet emulation" ) );
wndCloseCheckBox->setText( tr( "Do not minimize windows into tray. (Close the window)" ) );
tabWidget2->changeTab( tab_5, tr( "Miscellaneous" ) );
}
void configWnd::okButton_slot()
{
qWarning( "configWnd::okButton_slot(): Not implemented yet" );
}
void configWnd::cancelButton_slot()
{
qWarning( "configWnd::cancelButton_slot(): Not implemented yet" );
}
void configWnd::browseBgButton_slot()
{
qWarning( "configWnd::browseBgButton_slot(): Not implemented yet" );
}
void configWnd::browseAutoStButton_slot()
{
qWarning( "configWnd::browseAutoStButton_slot(): Not implemented yet" );
}
void configWnd::selEntrFontButton_slot()
{
qWarning( "configWnd::selEntrFontButton_slot(): Not implemented yet" );
}
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index e5579f8..08fcb25 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1,245 +1,250 @@
/***************************************************************************
* *
* copyright (C) 2003, 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include <klocale.h>
#include <klistview.h>
#include <ktoolbar.h>
#include <kfiledialog.h>
#include <kiconloader.h>
#include <kmessagebox.h>
#ifndef PWM_EMBEDDED
#include <kmenubar.h>
#include <kstatusbar.h>
#include <dcopclient.h>
+#include "configwndimpl.h"
+#include "configuration.h"
#else
#include <qmenubar.h>
#include <qmessagebox.h>
+#include <pwmprefs.h>
+#include <kpimglobalprefs.h>
+#include <kcmconfigs/kcmpwmconfig.h>
+#include <kcmconfigs/kcmkdepimconfig.h>
+#include <kcmultidialog.h>
#endif
#include <qpixmap.h>
#include <qcheckbox.h>
#include <qspinbox.h>
#include <qlineedit.h>
#include <qfileinfo.h>
#include <qclipboard.h>
#include <stdio.h>
#include "pwm.h"
#include "pwminit.h"
-#include "configwndimpl.h"
#include "pwmprint.h"
#include "addentrywndimpl.h"
#include "globalstuff.h"
#include "findwndimpl.h"
-#include "configuration.h"
#ifdef CONFIG_KWALLETIF
# include "kwalletif.h"
# include "kwalletemu.h"
#endif
#ifdef CONFIG_KEYCARD
# include "pwmkeycard.h"
#endif
#define DEFAULT_SIZE (QSize(700, 400))
// Button IDs for "file" popup menu
enum {
BUTTON_POPUP_FILE_NEW = 0,
BUTTON_POPUP_FILE_OPEN,
BUTTON_POPUP_FILE_CLOSE,
BUTTON_POPUP_FILE_SAVE,
BUTTON_POPUP_FILE_SAVEAS,
BUTTON_POPUP_FILE_EXPORT,
BUTTON_POPUP_FILE_IMPORT,
BUTTON_POPUP_FILE_PRINT,
BUTTON_POPUP_FILE_QUIT
};
// Button IDs for "manage" popup menu
enum {
BUTTON_POPUP_MANAGE_ADD = 0,
BUTTON_POPUP_MANAGE_EDIT,
BUTTON_POPUP_MANAGE_DEL,
BUTTON_POPUP_MANAGE_CHANGEMP
};
// Button IDs for chipcard popup menu
enum {
#ifdef CONFIG_KEYCARD
BUTTON_POPUP_CHIPCARD_GENNEW = 0,
BUTTON_POPUP_CHIPCARD_DEL,
BUTTON_POPUP_CHIPCARD_READID,
BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
#else // CONFIG_KEYCARD
BUTTON_POPUP_CHIPCARD_NO = 0
#endif // CONFIG_KEYCARD
};
// Button IDs for "view" popup menu
enum {
BUTTON_POPUP_VIEW_FIND = 0,
BUTTON_POPUP_VIEW_LOCK,
BUTTON_POPUP_VIEW_DEEPLOCK,
BUTTON_POPUP_VIEW_UNLOCK
};
// Button IDs for "options" popup menu
enum {
BUTTON_POPUP_OPTIONS_CONFIG = 0
};
// Button IDs for "export" popup menu (in "file" popup menu)
enum {
BUTTON_POPUP_EXPORT_TEXT = 0,
BUTTON_POPUP_EXPORT_GPASMAN
#ifdef CONFIG_KWALLETIF
,BUTTON_POPUP_EXPORT_KWALLET
#endif
};
// Button IDs for "import" popup menu (in "file" popup menu)
enum {
BUTTON_POPUP_IMPORT_TEXT = 0,
BUTTON_POPUP_IMPORT_GPASMAN
#ifdef CONFIG_KWALLETIF
,BUTTON_POPUP_IMPORT_KWALLET
#endif
};
#ifdef PWM_EMBEDDED
// Button IDs for "help" popup menu
enum {
BUTTON_POPUP_HELP_LICENSE = 0,
BUTTON_POPUP_HELP_FAQ,
BUTTON_POPUP_HELP_ABOUT
};
#endif
// Button IDs for toolbar
enum {
BUTTON_TOOL_NEW = 0,
BUTTON_TOOL_OPEN,
BUTTON_TOOL_SAVE,
BUTTON_TOOL_SAVEAS,
BUTTON_TOOL_PRINT,
BUTTON_TOOL_ADD,
BUTTON_TOOL_EDIT,
BUTTON_TOOL_DEL,
BUTTON_TOOL_FIND,
BUTTON_TOOL_LOCK,
BUTTON_TOOL_DEEPLOCK,
BUTTON_TOOL_UNLOCK
};
PwM::PwM(PwMInit *_init, PwMDoc *doc,
bool virginity,
QWidget *parent, const char *name)
: KMainWindow(parent, name)
, forceQuit (false)
, forceMinimizeToTray (false)
{
init = _init;
connect(doc, SIGNAL(docClosed(PwMDoc *)),
this, SLOT(docClosed(PwMDoc *)));
initMenubar();
initToolbar();
initMetrics();
setVirgin(virginity);
setFocusPolicy(QWidget::WheelFocus);
#ifndef PWM_EMBEDDED
statusBar()->show();
#endif
view = makeNewListView(doc);
setCentralWidget(view);
updateCaption();
showStatMsg(i18n("Ready."));
}
PwM::~PwM()
{
disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
this, SLOT(docClosed(PwMDoc *)));
conf()->confWndMainWndSize(size());
emit closed(this);
delete view;
}
void PwM::initMenubar()
{
KIconLoader* picons;
#ifndef PWM_EMBEDDED
KIconLoader icons;
picons = &icons;
#else
picons = KGlobal::iconLoader();
#endif
filePopup = new KPopupMenu(this);
importPopup = new KPopupMenu(filePopup);
exportPopup = new KPopupMenu(filePopup);
managePopup = new KPopupMenu(this);
#ifdef CONFIG_KEYCARD
chipcardPopup = new KPopupMenu(this);
#endif // CONFIG_KEYCARD
viewPopup = new KPopupMenu(this);
optionsPopup = new KPopupMenu(this);
// "file" popup menu
filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
i18n("&New"), this,
SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW);
filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)),
i18n("&Open"), this,
SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN);
filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)),
i18n("&Close"), this,
SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE);
filePopup->insertSeparator();
filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)),
i18n("&Save"), this,
SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)),
i18n("Save &as..."),
this, SLOT(saveAs_slot()), 0,
BUTTON_POPUP_FILE_SAVEAS);
filePopup->insertSeparator();
// "file/export" popup menu
exportPopup->insertItem(i18n("&Text-file..."), this,
SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
#ifdef CONFIG_KWALLETIF
exportPopup->insertItem(i18n("&KWallet..."), this,
SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
#endif
filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
i18n("E&xport"), exportPopup,
BUTTON_POPUP_FILE_EXPORT);
// "file/import" popup menu
importPopup->insertItem(i18n("&Text-file..."), this,
SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
#ifdef CONFIG_KWALLETIF
importPopup->insertItem(i18n("&KWallet..."), this,
SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
#endif
filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
i18n("I&mport"), importPopup,
BUTTON_POPUP_FILE_IMPORT);
@@ -562,427 +567,443 @@ void PwM::addPwd_slot(QString *pw, PwMDoc *_doc)
doc = curDoc();
}
PWM_ASSERT(doc);
doc->timer()->getLock(DocTimer::id_autoLockTimer);
AddEntryWndImpl w;
vector<string> catList;
doc->getCategoryList(&catList);
unsigned i, size = catList.size();
for (i = 0; i < size; ++i) {
w.addCategory(catList[i].c_str());
}
w.setCurrCategory(view->getCurrentCategory());
if (pw)
w.pwLineEdit->setText(*pw);
tryAgain:
if (w.exec() == 1)
{
PwMDataItem d;
d.desc = w.getDescription().latin1();
d.name = w.getUsername().latin1();
d.pw = w.getPassword().latin1();
d.comment = w.getComment().latin1();
d.url = w.getUrl().latin1();
d.launcher = w.getLauncher().latin1();
PwMerror ret = doc->addEntry(w.getCategory(), &d);
if (ret == e_entryExists) {
KMessageBox::error(this,
i18n
("An entry with this \"Description\", "
"does already exist.\n"
"Please select another description."),
i18n("entry already exists."));
goto tryAgain;
} else if (ret == e_maxAllowedEntr) {
KMessageBox::error(this, i18n("The maximum possible number of entries "
"has been reached. You can't add more entries."),
i18n("maximum number of entries"));
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
}
setVirgin(false);
doc->timer()->putLock(DocTimer::id_autoLockTimer);
}
//US ENH : changed code to run with older MOC
void PwM::editPwd_slot()
{
editPwd_slot(0,0,0);
}
void PwM::editPwd_slot(const QString *category)
{
editPwd_slot(category, 0, 0);
}
void PwM::editPwd_slot(const QString *category, const int *index,
PwMDoc *_doc)
{
PwMDoc *doc;
if (_doc) {
doc = _doc;
} else {
doc = curDoc();
}
PWM_ASSERT(doc);
if (doc->isDocEmpty())
return;
if (doc->isDeepLocked())
return;
doc->timer()->getLock(DocTimer::id_autoLockTimer);
unsigned int curEntryIndex;
if (index) {
curEntryIndex = *index;
} else {
if (!(view->getCurEntryIndex(&curEntryIndex))) {
printDebug("couldn't get index. Maybe we have a binary entry here.");
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
}
QString curCategory;
if (category) {
curCategory = *category;
} else {
curCategory = view->getCurrentCategory();
}
PwMDataItem currItem;
if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
BUG_ON(currItem.binary);
AddEntryWndImpl w;
vector<string> catList;
doc->getCategoryList(&catList);
unsigned i, size = catList.size();
for (i = 0; i < size; ++i) {
w.addCategory(catList[i].c_str());
}
w.setCurrCategory(curCategory);
w.setDescription(currItem.desc.c_str());
w.setUsername(currItem.name.c_str());
w.setPassword(currItem.pw.c_str());
w.setUrl(currItem.url.c_str());
w.setLauncher(currItem.launcher.c_str());
w.setComment(currItem.comment.c_str());
if (w.exec() == 1) {
currItem.desc = w.getDescription().latin1();
currItem.name = w.getUsername().latin1();
currItem.pw = w.getPassword().latin1();
currItem.comment = w.getComment().latin1();
currItem.url = w.getUrl().latin1();
currItem.launcher = w.getLauncher().latin1();
if (!doc->editEntry(curCategory, w.getCategory(),
curEntryIndex, &currItem)) {
KMessageBox::error(this,
i18n("Couldn't edit the entry.\n"
"Maybe you changed the category and "
"this entry is already present in the new "
"category?"),
i18n("couldn't edit entry."));
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
}
doc->timer()->putLock(DocTimer::id_autoLockTimer);
}
void PwM::deletePwd_slot()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty())
return;
if (curDoc()->isDeepLocked())
return;
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
unsigned int curEntryIndex = 0;
if (!(view->getCurEntryIndex(&curEntryIndex))) {
printDebug("couldn't get index");
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
PwMDataItem currItem;
QString curCategory = view->getCurrentCategory();
if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
printDebug("couldn't get entry");
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
if (KMessageBox::
questionYesNo(this,
i18n
("Do you really want to delete the selected entry") +
" \"" + QString(currItem.desc.c_str())
+ "\" ?", i18n("delete?"))
== KMessageBox::Yes) {
curDoc()->delEntry(curCategory, curEntryIndex);
}
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
}
void PwM::changeMasterPwd_slot()
{
PWM_ASSERT(curDoc());
curDoc()->changeCurrentPw();
}
void PwM::lockWnd_slot()
{
PWM_ASSERT(curDoc());
curDoc()->lockAll(true);
}
void PwM::deepLockWnd_slot()
{
PWM_ASSERT(curDoc());
curDoc()->deepLock();
}
void PwM::unlockWnd_slot()
{
PWM_ASSERT(curDoc());
curDoc()->lockAll(false);
}
void PwM::config_slot()
{
- Configuration *conf = Configuration::obj();
- int oldStyle = conf->confWndMainViewStyle();
+ int oldStyle = conf()->confWndMainViewStyle();
+#ifdef PWM_EMBEDDED
+ KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true );
+ KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" );
+ ConfigureDialog->addModule(pwmcfg );
+
+ KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
+ ConfigureDialog->addModule(kdelibcfg );
+
+#ifndef DESKTOP_VERSION
+ ConfigureDialog->showMaximized();
+#endif
+ if ( ConfigureDialog->exec() )
+ KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
+ delete ConfigureDialog;
+
+#else //PWM_EMBEDDED
// display the configuration window (modal mode)
- if (!conf->showConfWnd(this))
+ if (!conf()->showConfWnd(this))
return;
+#endif
- int newStyle = conf->confWndMainViewStyle();
+ int newStyle = conf()->confWndMainViewStyle();
// reinitialize tray
init->initTray();
// reinitialize KWallet emulation
init->initKWalletEmu();
PwMDocList *_dl = PwMDoc::getOpenDocList();
const vector<PwMDocList::listItem> *dl = _dl->getList();
vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
end = dl->end();
PwMDoc *doc;
while (i != end) {
doc = (*i).doc;
// unlock-without-mpw timeout
doc->timer()->start(DocTimer::id_mpwTimer);
// auto-lock timeout
doc->timer()->start(DocTimer::id_autoLockTimer);
++i;
}
const QValueList<PwM *> *ml = init->mainWndList();
#ifndef PWM_EMBEDDED
QValueList<PwM *>::const_iterator i2 = ml->begin(),
end2 = ml->end();
#else
QValueList<PwM *>::ConstIterator i2 = ml->begin(),
end2 = ml->end();
#endif
PwM *pwm;
while (i2 != end2) {
pwm = *i2;
// reinitialize the window style.
if (oldStyle != newStyle)
pwm->curView()->initStyle(newStyle);
// set the new font
- pwm->curView()->setFont(conf->confGlobEntryFont());
+ pwm->curView()->setFont(conf()->confGlobEntryFont());
++i2;
}
}
void PwM::activateMpButton(bool activate)
{
managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
}
void PwM::closeEvent(QCloseEvent *e)
{
e->accept();
}
void PwM::docClosed(PwMDoc *doc)
{
PARAM_UNUSED(doc);
PWM_ASSERT(doc == curDoc());
close();
}
void PwM::find_slot()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty())
return;
if (curDoc()->isDeepLocked())
return;
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
FindWndImpl findWnd(view);
findWnd.exec();
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
}
void PwM::exportToText()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty()) {
KMessageBox::information(this,
i18n
("Sorry, there's nothing to export.\n"
"Please first add some passwords."),
i18n("nothing to do"));
return;
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
QString fn(KFileDialog::getSaveFileName(QString::null,
i18n("*|plain-text file"),
this));
if (fn == "") {
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
PwMerror ret = curDoc()->exportToText(&fn);
if (ret != e_success) {
KMessageBox::error(this,
i18n("Error: Couldn't write to file.\n"
"Please check if you have permission to write "
"to the file in that directory."),
i18n("error while writing"));
} else
showStatMsg(i18n("Successfully exported data."));
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
}
bool PwM::importFromText()
{
if (!isVirgin()) {
if (KMessageBox::questionYesNo(this,
i18n("Do you want to import the data "
"into the current document? (If you "
"select \"no\", a new document will be "
"opened.)"),
i18n("import into this document?"))
== KMessageBox::No) {
// import the data to a new window.
PwM *newInstance = init->createMainWnd();
bool ok = newInstance->importFromText();
if (!ok) {
newInstance->setForceQuit(true);
delete_and_null(newInstance);
}
return ok;
}
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
PwMerror ret;
QString path(KFileDialog::getOpenFileName(QString::null,
i18n("*|PWM-exported text file"),
this));
if (path == "")
goto cancelImport;
ret = curDoc()->importFromText(&path, 0);
if (ret == e_fileFormat) {
KMessageBox::error(this,
i18n("Could not read file-format.\n"
"This seems to be _not_ a valid file "
"exported by PwM."),
i18n("invalid file-format"));
goto cancelImport;
} else if (ret == e_invalidArg) {
BUG();
goto cancelImport;
} else if (ret != e_success) {
KMessageBox::error(this,
i18n("Could not import file!\n"
"Do you have permission to read this file? "
"Do you have enough free memory?"),
i18n("import failed"));
goto cancelImport;
}
setVirgin(false);
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return true;
cancelImport:
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return false;
}
void PwM::exportToGpasman()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty()) {
KMessageBox::information(this,
i18n
("Sorry, there's nothing to export.\n"
"Please first add some passwords."),
i18n("nothing to do"));
return;
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
QString fn(KFileDialog::getSaveFileName(QString::null,
i18n("*|Gpasman or Kpasman file"),
this));
if (fn == "") {
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
PwMerror ret = curDoc()->exportToGpasman(&fn);
if (ret != e_success) {
if (ret == e_noPw) {
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
KMessageBox::error(this,
i18n("Error: Couldn't write to file.\n"
"Please check if you have permission to write "
"to the file in that directory."),
i18n("error while writing"));
} else
showStatMsg(i18n("Successfully exported data."));
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
}
void PwM::exportToKWallet()
{
#ifdef CONFIG_KWALLETIF
if (!checkAndAskForKWalletEmu())
return;
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty()) {
KMessageBox::information(this,
i18n
("Sorry, there's nothing to export.\n"
"Please first add some passwords."),
i18n("nothing to do"));
init->initKWalletEmu();
return;
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
KWalletIf walletIf(this);
if (walletIf.kwalletExport(curDoc())) {
KMessageBox::information(this,
i18n("Successfully exported the data of the current "
"document to KWallet."),
i18n("Successfully exported data."));
showStatMsg(i18n("Successfully exported data."));
}
init->initKWalletEmu();
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
#endif // CONFIG_KWALLETIF
}
bool PwM::importFromGpasman()
{
if (!isVirgin()) {
if (KMessageBox::questionYesNo(this,
diff --git a/pwmanager/pwmanager/pwmanagerE.pro b/pwmanager/pwmanager/pwmanagerE.pro
index 2cd69a5..5c29ea4 100644
--- a/pwmanager/pwmanager/pwmanagerE.pro
+++ b/pwmanager/pwmanager/pwmanagerE.pro
@@ -1,144 +1,153 @@
TEMPLATE = app
CONFIG += qt warn_on
TARGET = pwmpi
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
DESTDIR=$(QPEDIR)/bin
-INCLUDEPATH += . ../../qtcompat ../../qtcompat/xml ../../microkde ../../microkde/kdecore ../../microkde/kdeui $(QPEDIR)/include
+INCLUDEPATH += . ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include
DEFINES += PWM_EMBEDDED PWM_DEBUG
LIBS += -lmicrokde
LIBS += -lmicroqtcompat
+LIBS += -lmicrokdepim
LIBS += -L$(QPEDIR)/lib
LIBS += -lqpe
LIBS += -lbz2
LIBS += $(QTOPIALIB)
#INTERFACES = \
#addentrywnd.ui \
#configwnd.ui \
#findwnd.ui \
#getmasterpwwnd.ui \
#pwgenwnd.ui \
#setmasterpwwnd.ui \
#subtbledit.ui
#INTERFACES = \
#subtbledit.ui \
#HEADERS = \
+#configuration_31compat.h \
+#configuration.h \
+#configwnd.h \
+#configwndimpl.h \
#selftest.h
HEADERS = \
addentrywnd.h \
addentrywndimpl.h \
base64.h \
binentrygen.h \
blowfish.h \
commentbox.h \
compiler.h \
compressbzip2.h \
compressgzip.h \
-configuration_31compat.h \
-configuration.h \
-configwnd.h \
-configwndimpl.h \
findwnd.h \
findwndimpl.h \
genpasswd.h \
getkeycardwnd.h \
getmasterpwwnd.h \
getmasterpwwndimpl.h \
globalstuff.h \
gpasmanfile.h \
htmlgen.h \
htmlparse.h \
ipc.h \
listobjselectwnd.h \
listviewpwm.h \
printtext.h \
pwgenwnd.h \
pwgenwndimpl.h \
pwmdoc.h \
pwmdocui.h \
pwmexception.h \
pwm.h \
pwminit.h \
+pwmprefs.h \
pwmprint.h \
pwmtray.h \
pwmview.h \
pwmviewstyle_0.h \
pwmviewstyle_1.h \
pwmviewstyle.h \
randomizer.h \
rc2.h \
rencatwnd.h \
serializer.h \
setmasterpwwnd.h \
setmasterpwwndimpl.h \
sha1.h \
subtbledit.h \
subtbleditimpl.h \
-waitwnd.h
+waitwnd.h \
+kcmconfigs/kcmpwmconfig.h \
+kcmconfigs/pwmconfigwidget.h \
+#sources that need not be build
#SOURCES = \
#advcommeditimpl.cpp \
+#configuration.cpp \
+#configwnd.cpp \
+#configwndimpl.cpp \
#configuration_31compat.cpp \
#htmlparse.cpp \
#printtext.cpp \
#selftest.cpp \
#pwmprint.cpp \
#spinforsignal.cpp
SOURCES = \
addentrywnd.cpp \
addentrywndimpl.cpp \
base64.cpp \
binentrygen.cpp \
blowfish.cpp \
commentbox.cpp \
compressbzip2.cpp \
compressgzip.cpp \
-configuration.cpp \
-configwnd.cpp \
-configwndimpl.cpp \
findwnd.cpp \
findwndimpl.cpp \
genpasswd.cpp \
getkeycardwnd.cpp \
getmasterpwwnd.cpp \
getmasterpwwndimpl.cpp \
globalstuff.cpp \
gpasmanfile.cpp \
htmlgen.cpp \
ipc.cpp \
listobjselectwnd.cpp \
listviewpwm.cpp \
main.cpp \
pwgenwnd.cpp \
pwgenwndimpl.cpp \
pwm.cpp \
pwmdoc.cpp \
pwmdocui.cpp \
pwmexception.cpp \
pwminit.cpp \
+pwmprefs.cpp \
pwmtray.cpp \
pwmview.cpp \
pwmviewstyle_0.cpp \
pwmviewstyle_1.cpp \
pwmviewstyle.cpp \
randomizer.cpp \
rc2.cpp \
rencatwnd.cpp \
serializer.cpp \
setmasterpwwnd.cpp \
setmasterpwwndimpl.cpp \
sha1.cpp \
subtbledit.cpp \
subtbleditimpl.cpp \
waitwnd.cpp \
+kcmconfigs/kcmpwmconfig.cpp \
+kcmconfigs/pwmconfigwidget.cpp \
+
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 04af360..9fe4809 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -1,225 +1,227 @@
/***************************************************************************
* *
* copyright (C) 2003, 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 2.0 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "pwmdoc.h"
#include "pwmview.h"
#include "blowfish.h"
#include "sha1.h"
#include "globalstuff.h"
#include "gpasmanfile.h"
#include "serializer.h"
#include "compressgzip.h"
#include "compressbzip2.h"
#include "randomizer.h"
#include "pwminit.h"
#ifndef PWM_EMBEDDED
//US #include "libgryptif.h"
#else
+#include "pwmprefs.h"
+#include "kglobal.h"
#endif
#ifdef CONFIG_KWALLETIF
# include "kwalletemu.h"
#endif // CONFIG_KWALLETIF
#include <qdatetime.h>
#include <qsize.h>
#include <qfileinfo.h>
#include <qfile.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdint.h>
//TODO: reset to its normal value.
#define META_CHECK_TIMER_INTERVAL 10/*300*/ /* sek */
using namespace std;
void PwMDocList::add(PwMDoc *doc, const string &id)
{
#ifdef PWM_DEBUG
// check for existance of object in debug mode only.
vector<listItem>::iterator begin = docList.begin(),
end = docList.end(),
i = begin;
while (i != end) {
if (i->doc == doc) {
BUG();
return;
}
++i;
}
#endif
listItem newItem;
newItem.doc = doc;
newItem.docId = id;
docList.push_back(newItem);
}
void PwMDocList::edit(PwMDoc *doc, const string &newId)
{
vector<listItem>::iterator begin = docList.begin(),
end = docList.end(),
i = begin;
while (i != end) {
if (i->doc == doc) {
i->docId = newId;
return;
}
++i;
}
}
void PwMDocList::del(PwMDoc *doc)
{
vector<listItem>::iterator begin = docList.begin(),
end = docList.end(),
i = begin;
while (i != end) {
if (i->doc == doc) {
docList.erase(i);
return;
}
++i;
}
}
bool PwMDocList::find(const string &id, listItem *ret)
{
vector<listItem>::iterator begin = docList.begin(),
end = docList.end(),
i = begin;
while (i != end) {
if (i->docId == id) {
if (ret)
*ret = *i;
return true;
}
++i;
}
return false;
}
DocTimer::DocTimer(PwMDoc *_doc)
: doc (_doc)
, mpwLock (0)
, autoLockLock (0)
, metaCheckLock (0)
{
mpwTimer = new QTimer;
autoLockTimer = new QTimer;
metaCheckTimer = new QTimer;
connect(mpwTimer, SIGNAL(timeout()),
this, SLOT(mpwTimeout()));
connect(autoLockTimer, SIGNAL(timeout()),
this, SLOT(autoLockTimeout()));
connect(metaCheckTimer, SIGNAL(timeout()),
this, SLOT(metaCheckTimeout()));
}
DocTimer::~DocTimer()
{
delete mpwTimer;
delete autoLockTimer;
delete metaCheckTimer;
}
void DocTimer::start(TimerIDs timer)
{
switch (timer) {
case id_mpwTimer:
if (mpwTimer->isActive())
mpwTimer->stop();
doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW);
mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true);
break;
case id_autoLockTimer:
if (autoLockTimer->isActive())
autoLockTimer->stop();
if (conf()->confGlobLockTimeout() > 0)
autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true);
break;
case id_metaCheckTimer:
if (metaCheckTimer->isActive())
metaCheckTimer->stop();
metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true);
break;
}
}
void DocTimer::stop(TimerIDs timer)
{
switch (timer) {
case id_mpwTimer:
mpwTimer->stop();
break;
case id_autoLockTimer:
autoLockTimer->stop();
break;
case id_metaCheckTimer:
metaCheckTimer->stop();
break;
}
}
void DocTimer::getLock(TimerIDs timer)
{
switch (timer) {
case id_mpwTimer:
++mpwLock;
break;
case id_autoLockTimer:
++autoLockLock;
break;
case id_metaCheckTimer:
++metaCheckLock;
break;
}
}
void DocTimer::putLock(TimerIDs timer)
{
switch (timer) {
case id_mpwTimer:
if (mpwLock)
--mpwLock;
break;
case id_autoLockTimer:
if (autoLockLock)
--autoLockLock;
break;
case id_metaCheckTimer:
if (metaCheckLock)
--metaCheckLock;
break;
}
}
void DocTimer::mpwTimeout()
{
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 9650d55..193247e 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -1,251 +1,251 @@
/***************************************************************************
* *
* copyright (C) 2003, 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 2.0 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#ifndef __PWMDOC_H
#define __PWMDOC_H
#define PWM_FILE_VER (static_cast<char>(0x05))
#define PWM_HASH_SHA1 (static_cast<char>(0x01))
#define PWM_HASH_SHA256 (static_cast<char>(0x02))
#define PWM_HASH_SHA384 (static_cast<char>(0x03))
#define PWM_HASH_SHA512 (static_cast<char>(0x04))
#define PWM_HASH_MD5 (static_cast<char>(0x05))
#define PWM_HASH_RMD160 (static_cast<char>(0x06))
#define PWM_HASH_TIGER (static_cast<char>(0x07))
#define PWM_CRYPT_BLOWFISH (static_cast<char>(0x01))
#define PWM_CRYPT_AES128 (static_cast<char>(0x02))
#define PWM_CRYPT_AES192 (static_cast<char>(0x03))
#define PWM_CRYPT_AES256 (static_cast<char>(0x04))
#define PWM_CRYPT_3DES (static_cast<char>(0x05))
#define PWM_CRYPT_TWOFISH (static_cast<char>(0x06))
#define PWM_CRYPT_TWOFISH128 (static_cast<char>(0x07))
#define PWM_COMPRESS_NONE (static_cast<char>(0x00))
#define PWM_COMPRESS_GZIP (static_cast<char>(0x01))
#define PWM_COMPRESS_BZIP2 (static_cast<char>(0x02))
#define DEFAULT_MAX_ENTRIES (~(static_cast<unsigned int>(0)))
#define FILE_ID_HEADER "PWM_PASSWORD_FILE"
#include "pwmexception.h"
#include "pwmdocui.h"
-#include "configuration.h"
#include <qobject.h>
#include <qtimer.h>
#include <qdatetime.h>
#include <kprocess.h>
#ifndef PWM_EMBEDDED
+#include "configuration.h"
#else
#include <kapplication.h>
#endif
#include <string>
#include <vector>
#include <utility>
using std::vector;
using std::string;
using std::pair;
/* used in findEntry() function */
#define SEARCH_IN_DESC (1)
#define SEARCH_IN_NAME (1 << 1)
#define SEARCH_IN_PW (1 << 2)
#define SEARCH_IN_COMMENT (1 << 3)
#define SEARCH_IN_URL (1 << 4)
#define SEARCH_IN_LAUNCHER (1 << 5)
#define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME | \
SEARCH_IN_PW | SEARCH_IN_COMMENT | \
SEARCH_IN_URL | SEARCH_IN_LAUNCHER)
/** document deeplocked. Data is out for lunch to disk */
#define DOC_STAT_DEEPLOCKED (1)
/** encrypted document on disk is dirty. data has to go to disk. */
#define DOC_STAT_DISK_DIRTY (1 << 1)
/** we are using a chipcard to encrypt the data */
#define DOC_STAT_USE_CHIPCARD (1 << 2)
/** use "currentPw" to unlock. (This flag is set/unset by a timer) */
#define DOC_STAT_UNLOCK_WITHOUT_PW (1 << 3)
class PwMDoc;
class PwMView;
class QFile;
/* meta data for a PwMDataItem */
struct PwMMetaData
{
PwMMetaData()
: updateInt (0)
{ }
/** creation date of the PwMDataItem to which
* this meta data belongs.
*/
QDateTime create;
/** becomes valid on this date */
QDateTime valid;
/** expire date */
QDateTime expire;
/** update date (last updated at this date) */
QDateTime update;
/** update interval (in minutes). Time since the
* last update to remind the user to update the item.
* 0 disables.
*/
unsigned long updateInt;
//US ENH: enhancements of the filestructure
/* each entry gets a unique id assigned */
QString uniqueid;
void clear()
{
create = QDateTime();
expire = QDateTime();
update = QDateTime();
updateInt = 0;
uniqueid = KApplication::randomString(8);
}
inline bool isValid() const
{
if (valid.isNull())
return true;
return (valid < QDateTime::currentDateTime());
}
inline bool isExpired() const
{
if (expire.isNull())
return false;
return (expire < QDateTime::currentDateTime());
}
inline bool isUpdateIntOver() const
{
if (updateInt == 0 ||
update.isNull())
return false;
QDateTime d(update);
return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime());
}
};
struct PwMDataItem
{
PwMDataItem()
: lockStat (true)
, listViewPos (-1)
, binary (false)
, rev (0)
{ }
/** password description */
string desc;
/** user-name */
string name;
/** the password itself */
string pw;
/** some comment */
string comment;
/** an URL string */
string url;
/** launcher. Can be executed as a system() command */
string launcher;
/** locking status. If locked (true), pw is not emitted through getEntry() */
bool lockStat;
/** position of this item in main "list-view"
* If -1, the position is not yet specified and should be appended to the list
*/
int listViewPos;
/** does this entry contain binary data? */
bool binary;
/** meta data for this data item. */
PwMMetaData meta;
/** data revision counter. This counter can be used
* to easily, efficiently determine if this data item
* has changed since some time.
* This counter is incremented on every update.
*/
unsigned int rev;
void clear(bool clearMeta = true)
{
/* NOTE: Don't use .clear() here to be
* backward compatible with gcc-2 (Debian Woody)
*/
desc = "";
name = "";
pw = "";
comment = "";
url = "";
launcher = "";
lockStat = true;
listViewPos = -1;
binary = false;
if (clearMeta)
meta.clear();
}
};
struct PwMCategoryItem
{
/** all PwMDataItems (all passwords) within this category */
vector<PwMDataItem> d;
/** category name/description */
string name;
void clear()
{
d.clear();
name = "";
}
};
/** "Function Object" for sort()ing PwMDataItem::listViewPos */
class dta_lvp_greater
{
public:
bool operator() (const pair<unsigned int, unsigned int> &d1,
const pair<unsigned int, unsigned int> &d2)
{
return d1.second > d2.second;
}
};
/** list of PwMDoc documents and it's IDs */
class PwMDocList
{
public:
struct listItem
{
/** document filename (known as ID, here) */
string docId;
/** pointer to the document class */
PwMDoc *doc;
};
PwMDocList() {}
/** add a new item to the list */
void add(PwMDoc *doc, const string &id);
/** changes the contents of an existing item */
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index b308b40..3993fa8 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -1,230 +1,231 @@
/***************************************************************************
* *
* copyright (C) 2003, 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "pwmdocui.h"
#include "setmasterpwwndimpl.h"
#include "getmasterpwwndimpl.h"
#include "pwmexception.h"
#include "getkeycardwnd.h"
#include "pwm.h"
#include "globalstuff.h"
#include "spinforsignal.h"
#include <qlineedit.h>
#include <qtabwidget.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#ifndef PWM_EMBEDDED
#include <kwin.h>
#else
#include <qdir.h>
+#include "pwmprefs.h"
#endif
#ifdef CONFIG_KEYCARD
# include "pwmkeycard.h"
#endif
PwMDocUi::PwMDocUi(QObject *parent, const char *name)
: QObject(parent, name)
{
currentView = 0;
keyCard = 0;
}
PwMDocUi::~PwMDocUi()
{
}
QString PwMDocUi::requestMpw(bool chipcard)
{
QString pw;
if (chipcard) {
#ifdef CONFIG_KEYCARD
PWM_ASSERT(keyCard);
uint32_t id;
string ret;
SpinForSignal *spinner = keyCard->getSpinner();
connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
spinner, SLOT(u32_str_slot(uint32_t, const string &)));
keyCard->getKey();
spinner->spin(&id, &ret);
disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
spinner, SLOT(u32_str_slot(uint32_t, const string &)));
if (ret == "")
return "";
pw = ret.c_str();
#else // CONFIG_KEYCARD
no_keycard_support_msg_box(currentView);
#endif // CONFIG_KEYCARD
} else {
GetMasterPwWndImpl pwWnd;
#ifndef PWM_EMBEDDED
KWin::setState(pwWnd.winId(), NET::StaysOnTop);
#endif
if (pwWnd.exec() != 1)
return "";
pw = pwWnd.pwLineEdit->text();
}
return pw;
}
QString PwMDocUi::requestNewMpw(bool *chipcard)
{
QString pw;
SetMasterPwWndImpl pwWnd(currentView);
pwWnd.setPwMKeyCard(keyCard);
#ifndef PWM_EMBEDDED
if (!chipcard) {
pwWnd.mainTab->removePage(pwWnd.mainTab->page(1));
}
#else
qDebug("PwMDocUi::requestNewMpw must be implemented");
#endif
if (pwWnd.exec() != 1)
return "";
pw = pwWnd.getPw(chipcard).c_str();
return pw;
}
QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard)
{
QString pw(requestMpw(*chipcard));
if (pw == "")
return "";
if (pw != *currentPw) {
wrongMpwMsgBox(*chipcard);
return "";
}
pw = requestNewMpw(chipcard);
if (pw == "")
return "";
return pw;
}
void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix)
{
QString msg;
if (prefix != "") {
msg += prefix;
msg += "\n";
}
if (chipcard) {
msg += i18n("Wrong key-card!\n"
"Please try again with the "
"correct key-card.");
} else {
msg += i18n("Wrong master-password!\n"
"Please try again.");
}
if (postfix != "") {
msg += "\n";
msg += postfix;
}
KMessageBox::error(currentView, msg,
(chipcard) ? (i18n("wrong chipcard"))
: (i18n("password error")));
}
void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix)
{
QString msg;
if (prefix != "") {
msg += prefix;
msg += "\n";
}
if (chipcard) {
msg += i18n("No key-card found!\n"
"Please insert the "
"correct key-card.");
} else {
msg += i18n("No master-password given!");
}
if (postfix != "") {
msg += "\n";
msg += postfix;
}
KMessageBox::error(currentView, msg,
(chipcard) ? (i18n("no chipcard"))
: (i18n("password error")));
}
void PwMDocUi::rootAlertMsgBox()
{
KMessageBox::error(currentView,
i18n("This feature is not available, "
"if you execute PwM with \"root\" "
"UID 0 privileges, for security reasons!"),
i18n("not allowed as root!"));
}
void PwMDocUi::cantDeeplock_notSavedMsgBox()
{
KMessageBox::error(currentView,
i18n("Can't deep-lock, because the document "
"hasn't been saved, yet. Please save "
"to a file and try again."),
i18n("not saved, yet"));
}
void PwMDocUi::gpmPwLenErrMsgBox()
{
KMessageBox::error(currentView,
i18n("GPasman does not support passwords "
"shorter than 4 characters! Please try "
"again with a longer password."),
i18n("password too short"));
}
int PwMDocUi::dirtyAskSave(const QString &docTitle)
{
int ret;
#ifndef PWM_EMBEDDED
ret = KMessageBox::questionYesNoCancel(currentView,
i18n("The list \"") +
docTitle +
i18n
("\" has been modified.\n"
"Do you want to save it?"),
i18n("save?"));
if (ret == KMessageBox::Yes) {
return 0;
} else if (ret == KMessageBox::No) {
return 1;
}
#else
ret = KMessageBox::warningYesNoCancel(currentView,
i18n("The list \"") +
docTitle +
i18n
("\" has been modified.\n"
"Do you want to save it?"),
i18n("save?"));
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp
index 2f1aa4e..8946443 100644
--- a/pwmanager/pwmanager/pwminit.cpp
+++ b/pwmanager/pwmanager/pwminit.cpp
@@ -1,340 +1,357 @@
/***************************************************************************
* *
* copyright (C) 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "pwminit.h"
-#include "configuration.h"
#include "randomizer.h"
#ifndef PWM_EMBEDDED
#include "selftest.h"
+#include "configuration.h"
+#else
+#include "pwmprefs.h"
#endif
#include "pwm.h"
#include "pwmexception.h"
#include "pwmtray.h"
#include "pwmdoc.h"
#ifdef CONFIG_KWALLETIF
# include "kwalletemu.h"
#endif // CONFIG_KWALLETIF
#ifdef CONFIG_KEYCARD
# include "pwmkeycard.h"
#endif // CONFIG_KEYCARD
#include <qmessagebox.h>
#include <kmessagebox.h>
#ifndef PWM_EMBEDDED
#include <kcmdlineargs.h>
#include <kwin.h>
#include <dcopclient.h>
#endif
#include <kapplication.h>
#include <kiconloader.h>
#include <signal.h>
static PwMInit *sig_init_pointer;
static NOREGPARM void sig_handler(int signum)
{
switch (signum) {
case SIGINT:
case SIGTERM:
sig_init_pointer->shutdownApp(20 + signum);
break;
default:
printDebug(string("unhandled signal ")
+ tostr(signum));
}
}
PwMInit::PwMInit(PwMApplication *_app)
: runStatus (unknown)
, _curWidget (0)
, _dcopClient (0)
, _kwalletEmu (0)
, _keycard (0)
, _tray (0)
{
sig_init_pointer = this;
app = _app;
}
PwMInit::~PwMInit()
{
#ifndef PWM_EMBEDDED
SelfTest::cancel();
// close all open mainwnds
QValueList<PwM *>::iterator i = _mainWndList.begin(),
end = _mainWndList.end();
#else
// close all open mainwnds
QValueList<PwM *>::Iterator i = _mainWndList.begin(),
end = _mainWndList.end();
#endif
while (i != end) {
disconnect(*i, SIGNAL(closed(PwM *)),
this, SLOT(mainWndClosed(PwM *)));
delete *i;
++i;
}
_mainWndList.clear();
// close all remaining open documents
PwMDocList *_dl = PwMDoc::getOpenDocList();
vector<PwMDocList::listItem> dl = *(_dl->getList());
vector<PwMDocList::listItem>::iterator i2 = dl.begin(),
end2 = dl.end();
while (i2 != end2) {
delete (*i2).doc;
++i2;
}
#ifdef CONFIG_KWALLETIF
delete_ifnot_null(_kwalletEmu);
#endif // CONFIG_KWALLETIF
#ifdef CONFIG_KEYCARD
delete_ifnot_null(_keycard);
#endif // CONFIG_KEYCARD
delete_ifnot_null(_tray);
Randomizer::cleanup();
+#ifndef PWM_EMBEDDED
Configuration::cleanup();
+#endif
}
void PwMInit::initializeApp()
{
PWM_ASSERT(runStatus == unknown);
runStatus = init;
initPosixSignalHandler();
Randomizer::init();
+#ifndef PWM_EMBEDDED
Configuration::init();
+#endif
initDCOP();
initKWalletEmu();
initKeycard();
initTray();
handleCmdLineArgs();
bool openDeeplocked = false;
if (conf()->confGlobAutostartDeepLocked() ||
savedCmd.open_deeplocked)
openDeeplocked = true;
if (conf()->confWndAutoMinimizeOnStart() ||
savedCmd.minToTray) {
PwMDoc *newDoc = createDoc();
if (!newDoc->openDocUi(newDoc,
conf()->confGlobAutoStart(),
openDeeplocked)) {
delete newDoc;
+
+ //US ENH for embedded devices: in the case of failure, open a document the default way
+ createMainWnd(conf()->confGlobAutoStart(),
+ openDeeplocked,
+ true,
+ 0,
+ savedCmd.minimized);
+
+
+
+
}
} else {
createMainWnd(conf()->confGlobAutoStart(),
openDeeplocked,
true,
0,
savedCmd.minimized);
}
runStatus = running;
}
void PwMInit::shutdownApp(int exitStatus)
{
printDebug(string("PwMInit::shutdownApp(")
+ tostr(exitStatus) + ") called.");
PWM_ASSERT((runStatus == running) || (runStatus == init));
runStatus = shutdown;
QApplication::exit(exitStatus);
/* The destructor of PwMInit is called when control
* leaves main()
*/
}
void PwMInit::initPosixSignalHandler()
{
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
}
void PwMInit::initDCOP()
{
#ifndef PWM_EMBEDDED
_dcopClient = app->dcopClient();
_dcopClient->setNotifications(true);
#endif
}
void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload)
{
#ifdef CONFIG_KWALLETIF
if (!conf()->confGlobKwalletEmu() ||
forceDisable) {
delete_ifnot_null(_kwalletEmu);
return;
}
try {
if (_kwalletEmu && forceReload)
delete_and_null(_kwalletEmu);
if (!_kwalletEmu)
_kwalletEmu = new KWalletEmu(this);
} catch (PwMException e) {
string errMsg("initializing KWallet emulation failed. ID: ");
errMsg += tostr(static_cast<int>(e.getId()));
errMsg += " err-message: ";
errMsg += e.getMessage();
printWarn(errMsg);
return;
}
#else // CONFIG_KWALLETIF
PARAM_UNUSED(forceDisable);
PARAM_UNUSED(forceReload);
#endif // CONFIG_KWALLETIF
}
void PwMInit::initKeycard()
{
#ifdef CONFIG_KEYCARD
PWM_ASSERT(!_keycard);
_keycard = new PwMKeyCard(this);
#endif // CONFIG_KEYCARD
}
void PwMInit::initTray()
{
#ifdef PWM_EMBEDDED
//US ENH : embedded version does not support a tray
return;
#endif
if (!conf()->confGlobTray()) {
if (!_tray)
return;
_tray->hide();
delete_and_null(_tray);
return;
}
if (_tray)
return;
_tray = new PwMTray(this);
connect(_tray, SIGNAL(quitSelected()),
this, SLOT(removeTrayAndQuit()));
connect(_tray, SIGNAL(closed(PwMTray *)),
this, SLOT(trayIconClosed(PwMTray *)));
KIconLoader icons;
#ifndef PWM_EMBEDDED
_tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small));
#endif
_tray->show();
// connect the signals of all open documents.
const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList();
vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
end = dl->end();
while (i != end) {
_tray->connectDocToTray((*i).doc);
++i;
}
}
void PwMInit::removeTrayAndQuit()
{
PWM_ASSERT(_tray);
// _tray is deleted in ~PwMInit
shutdownApp(0);
}
PwM * PwMInit::createMainWnd(const QString &loadFile,
bool loadFileDeepLocked,
bool virginity,
PwMDoc *doc,
bool minimized)
{
PwM *newWnd;
if (!doc)
doc = createDoc();
newWnd = new PwM(this, doc, virginity);
#ifndef PWM_EMBEDDED
_mainWndList.push_back(newWnd);
#else
_mainWndList.append(newWnd);
#endif
connect(newWnd, SIGNAL(closed(PwM *)),
this, SLOT(mainWndClosed(PwM *)));
connect(newWnd, SIGNAL(gotFocus(PwM *)),
this, SLOT(setCurWidget(PwM *)));
connect(newWnd, SIGNAL(lostFocus(PwM *)),
this, SLOT(resetCurWidget()));
//US ENH
#ifndef PWM_EMBEDDED
if (minimized)
newWnd->showMinimized();
else
newWnd->show();
#else //PWM_EMBEDDED
#ifndef DESKTOP_VERSION
app->showMainWidget( newWnd );
#else //DESKTOP_VERSION
app->setMainWidget( newWnd );
newWnd->resize (640, 480 );
newWnd->show();
#endif //DESKTOP_VERSION
#endif //PWM_EMBEDDED
if (loadFile != QString::null &&
loadFile != "") {
newWnd->openDoc(loadFile, loadFileDeepLocked);
}
return newWnd;
}
PwMDoc * PwMInit::createDoc()
{
PwMDoc *doc = new PwMDoc(this);
#ifdef CONFIG_KEYCARD
doc->setPwMKeyCard(keycard());
#endif
#ifdef CONFIG_KWALLETIF
if (kwalletEmu())
kwalletEmu()->connectDocSignals(doc);
#endif
if (_tray)
_tray->connectDocToTray(doc);
return doc;
}
void PwMInit::mainWndClosed(PwM *wnd)
{
bool doMinimizeToTray = false;
bool doDeleteDoc = false;
#ifndef PWM_EMBEDDED
dcopClient()->suspend();
dcopClient()->setAcceptCalls(false);
#endif
again:
diff --git a/pwmanager/pwmanager/pwmtray.cpp b/pwmanager/pwmanager/pwmtray.cpp
index 0f286c1..fe074ca 100644
--- a/pwmanager/pwmanager/pwmtray.cpp
+++ b/pwmanager/pwmanager/pwmtray.cpp
@@ -1,220 +1,224 @@
/***************************************************************************
* *
* copyright (C) 2003, 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* Original implementation of the tray-tree *
* (c) by Matt Scifo <mscifo@o1.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "pwmtray.h"
#include "pwmexception.h"
#include "pwm.h"
#include "pwmdoc.h"
#include "pwminit.h"
+#ifndef PWM_EMBEDDED
#include "configuration.h"
+#else
+#include "pwmprefs.h"
+#endif
#include <klocale.h>
void ActiveTreeItem::execIt()
{
#ifndef PWM_EMBEDDED
unsigned int entr = static_cast<unsigned int>(entry);
unsigned int cat = static_cast<unsigned int>(category);
#else
unsigned int entr = (unsigned int)(entry);
unsigned int cat = (unsigned int)(category);
#endif
switch (task) {
case pwToClipboard: {
PwMDataItem d;
doc->getDataChangedLock();
bool wasLocked = doc->isLocked(cat, entr);
doc->getEntry(cat, entr, &d, true);
if (wasLocked)
doc->lockAt(cat, entr, true);
doc->putDataChangedLock();
PwM::copyToClipboard(d.pw.c_str());
break;
} case nameToClipboard: {
PwMDataItem d;
doc->getEntry(cat, entr, &d);
PwM::copyToClipboard(d.name.c_str());
break;
} case descToClipboard: {
PwMDataItem d;
doc->getEntry(cat, entr, &d);
PwM::copyToClipboard(d.desc.c_str());
break;
} case urlToClipboard: {
PwMDataItem d;
doc->getEntry(cat, entr, &d);
PwM::copyToClipboard(d.url.c_str());
break;
} case launcherToClipboard: {
PwMDataItem d;
doc->getEntry(cat, entr, &d);
PwM::copyToClipboard(d.launcher.c_str());
break;
} case commentToClipboard: {
PwMDataItem d;
doc->getEntry(cat, entr, &d);
PwM::copyToClipboard(d.comment.c_str());
break;
} case execLauncher: {
doc->execLauncher(cat, entr);
break;
} case goToURL: {
doc->goToURL(cat, entr);
break;
} case openMainWnd: {
// search if there is already an open window.
const QValueList<PwM *> *wl = tray->init->mainWndList();
#ifndef PWM_EMBEDDED
QValueList<PwM *>::const_iterator i = wl->begin(),
end = wl->end();
#else
QValueList<PwM *>::ConstIterator i = wl->begin(),
end = wl->end();
#endif
PwM *wnd;
while (i != end) {
wnd = *i;
if (wnd->curDoc() == doc) {
// now bring this window to the foreground.
if (!wnd->hasFocus()) {
wnd->hide();
wnd->showNormal();
wnd->setFocus();
}
return;
}
++i;
}
// there is no open window, so open a new one.
tray->init->createMainWnd(QString::null, false, false, doc);
break;
} case closeDoc: {
doc->tryDelete();
break;
} case lock: {
doc->lockAll(true);
break;
} case deepLock: {
doc->deepLock();
break;
} case unlock: {
doc->lockAll(false);
break;
} default: {
BUG();
}
}
}
#ifndef PWM_EMBEDDED
PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name)
: KSystemTray(parent, name)
#else
PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name)
: QWidget(parent, name)
#endif
{
init = _init;
buildMain();
}
PwMTray::~PwMTray()
{
emit closed(this);
}
//US ENH for embedded tray class
KPopupMenu* PwMTray::contextMenu()
{
if (m_ctxMenu == 0)
{
m_ctxMenu = new KPopupMenu();
}
return m_ctxMenu;
}
void PwMTray::buildMain()
{
KPopupMenu *ctxMenu = contextMenu();
ctxMenu->insertSeparator();
ctxMenu->insertItem(i18n("&New main window..."), this,
SLOT(newMainWnd()));
ctxMenu->insertItem(i18n("&Open file..."), this,
SLOT(openDoc()));
ctxMenu->insertSeparator();
ctxMenu->insertItem(i18n("&Remove from tray"), this,
SLOT(undock()));
}
void PwMTray::insertActiveTreeItem(KPopupMenu *insertIn, const QString &text,
ActiveTreeItem::Task task, PwMDoc *doc,
int docCategory, int docEntry,
QValueList<int> *activeItemsList)
{
ActiveTreeItem *activeItem;
int id;
activeItem = new ActiveTreeItem(text, insertIn->font(), task,
doc, docCategory, docEntry,
this);
id = insertIn->insertItem(activeItem);
insertIn->connectItem(id, activeItem, SLOT(execIt()));
#ifndef PWM_EMBEDDED
activeItemsList->push_back(id);
#else
activeItemsList->append(id);
#endif
}
void PwMTray::rebuildTree(KPopupMenu *popup, PwMDoc *doc,
QValueList<int> *activeItems)
{
PWM_ASSERT(doc);
PWM_ASSERT(popup);
activeItems->clear();
popup->clear();
#ifndef PWM_EMBEDDED
popup->insertTitle(i18n("Categories:"));
#endif
vector<string> catList;
vector<string> entrList;
doc->getCategoryList(&catList);
KPopupMenu *newCatMenu;
KPopupMenu *newEntrMenu;
int i, size = catList.size();
int j, entries;
for (i = 0; i < size; ++i) {
newCatMenu = new KPopupMenu(popup);
popup->insertItem(catList[i].c_str(), newCatMenu);
doc->getEntryList(i, &entrList);
entries = entrList.size();
for (j = 0; j < entries; ++j) {
newEntrMenu = new KPopupMenu(newCatMenu);
newCatMenu->insertItem(entrList[j].c_str(), newEntrMenu);
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index c09fbf5..58c2fca 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -1,217 +1,221 @@
/***************************************************************************
* *
* copyright (C) 2003, 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "pwmview.h"
#include "pwmexception.h"
#include "globalstuff.h"
#include "pwm.h"
#include "rencatwnd.h"
+#ifndef PWM_EMBEDDED
#include "configuration.h"
+#else
+#include "pwmprefs.h"
+#endif
#include "commentbox.h"
#include <kmessagebox.h>
#include <klocale.h>
#include <qlineedit.h>
#include <qpoint.h>
#include <qapplication.h>
#define COLUMN_DESC 0
#define COLUMN_NAME 1
#define COLUMN_PW 2
#define COLUMN_URL 3
#define COLUMN_LAUNCHER 4
PwMView::PwMView(PwM *_mainClass,
QWidget *parent, PwMDoc *_doc,
const char *name)
: PwMViewStyle(parent, name)
{
PWM_ASSERT(_mainClass);
PWM_ASSERT(parent);
PWM_ASSERT(_doc);
setView(this);
doc = _doc;
doc->setListViewPointer(this);
mainClass = _mainClass;
resize(_mainClass->size());
initStyle(conf()->confWndMainViewStyle());
initCtxMenu();
doc->setCurrentView(this);
connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView()));
}
PwMView::~PwMView()
{
}
void PwMView::initCtxMenu()
{
ctxMenu = new QPopupMenu(this);
ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot()));
ctxMenu->insertSeparator();
ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot()));
ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot()));
ctxMenu->insertSeparator();
ctxMenu->insertItem(i18n("copy password to clipboard"),
this, SLOT(copyPwToClip()));
ctxMenu->insertItem(i18n("copy username to clipboard"),
this, SLOT(copyNameToClip()));
ctxMenu->insertItem(i18n("copy description to clipboard"),
this, SLOT(copyDescToClip()));
ctxMenu->insertItem(i18n("copy url to clipboard"),
this, SLOT(copyUrlToClip()));
ctxMenu->insertItem(i18n("copy launcher to clipboard"),
this, SLOT(copyLauncherToClip()));
ctxMenu->insertItem(i18n("copy comment to clipboard"),
this, SLOT(copyCommentToClip()));
ctxMenu->insertSeparator();
ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass,
SLOT(execLauncher_slot()));
ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass,
SLOT(goToURL_slot()));
}
void PwMView::resizeEvent(QResizeEvent *)
{
resizeView(size());
}
void PwMView::refreshCommentTextEdit(QListViewItem *curItem)
{
PWM_ASSERT(commentBox);
if (!curItem)
return;
string comment;
PwMerror ret;
ret = document()->getCommentByLvp(getCurrentCategory(),
lv->childCount() - lv->itemIndex(curItem) - 1,
&comment);
if (ret == e_binEntry) {
commentBox->setContent(i18n("This is a binary entry.\n"
"It is not a normal password-entry, as it contains "
"binary data, which PwManager can't display here."));
} else if (ret == e_normalEntry) {
commentBox->setContent(comment.c_str());
} else {
BUG();
return;
}
lv->ensureItemVisible(curItem);
}
void PwMView::keyReleaseEvent(QKeyEvent * /*e*/)
{
refreshCommentTextEdit(lv->currentItem());
}
bool PwMView::getCurEntryIndex(unsigned int *index)
{
QListViewItem *current = lv->currentItem();
if (!current)
return false;
return getDocEntryIndex(index, current);
}
bool PwMView::getDocEntryIndex(unsigned int *index,
const QListViewItem *item)
{
vector<unsigned int> foundPositions;
PwMDataItem curItem;
curItem.desc = item->text(COLUMN_DESC).latin1();
curItem.name = item->text(COLUMN_NAME).latin1();
document()->getCommentByLvp(getCurrentCategory(),
lv->childCount() - lv->itemIndex(item) - 1,
&curItem.comment);
curItem.url = item->text(COLUMN_URL).latin1();
curItem.launcher = item->text(COLUMN_LAUNCHER).latin1();
document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC |
SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL |
SEARCH_IN_LAUNCHER,
&foundPositions, true);
if (foundPositions.size()) {
*index = foundPositions[0];
return true;
}
return false;
}
void PwMView::handleToggle(QListViewItem *item)
{
PWM_ASSERT(doc);
if (!item)
return;
QCheckListItem *clItem = (QCheckListItem *)item;
QString curCat(getCurrentCategory());
// find document position of this entry.
unsigned int curEntryDocIndex;
if (!getDocEntryIndex(&curEntryDocIndex, item))
return;
// hack to refresh the comment, if only one item is present
if (lv->childCount() == 1)
refreshCommentTextEdit(lv->currentItem());
if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn())
return; // this is just a click somewhere on the entry
if (doc->isDeepLocked()) {
PwMerror ret;
ret = doc->deepLock(false);
if (ret != e_success)
clItem->setOn(false);
return;
}
doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn());
}
void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int)
{
if (!item)
return;
ctxMenu->move(point);
/* don't use ctxMenu->exec() here, as it generates race conditions
* with the card interface code. Believe it or not. :)
*/
ctxMenu->show();
}
void PwMView::updateCategories()
{
QString oldSel(getCurrentCategory());
delAllCategories();
QStringList catList;
document()->getCategoryList(&catList);
catList.sort();
#ifndef PWM_EMBEDDED
QStringList::iterator i = catList.begin(),
end = catList.end();
#else
QStringList::Iterator i = catList.begin(),
end = catList.end();
#endif
while (i != end) {
addCategory(*i);
++i;
}
selectCategory(oldSel);
}
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 65e442d..f29ef6c 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -1,216 +1,217 @@
/***************************************************************************
* *
* copyright (C) 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 2.0 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "serializer.h"
#include "pwmexception.h"
#ifdef PWM_EMBEDDED
+#include <kglobal.h>
#include <klocale.h>
#endif
/* enable/disable serializer debugging (0/1) */
#define SERIALIZER_DEBUG 0
/* use the old xml tags for writing (0/1) */
#define USE_OLD_TAGS 0
/* write a CDATA section (0/1) */
#define WRITE_CDATA_SEC 0
#define META_CREATE_DATE "c"
#define META_VALID_DATE "v"
#define META_EXPIRE_DATE "e"
#define META_UPDATE_DATE "u"
#define META_UPDATE_INT "i"
//US ENH : uniqueid
#define META_UNIQUEID "n"
/* This is compatibility stuff.
* The names of the entries have changed and here are the
* new and old ones
*/
#define ROOT_MAGIC_OLD "PwM-xml-dat"
#define VER_STR_OLD "ver"
#define COMPAT_VER_OLD "0x02"
#define CAT_ROOT_OLD "categories"
#define CAT_PREFIX_OLD "cat_"
#define CAT_NAME_OLD "name"
#define ENTRY_PREFIX_OLD "entry_"
#define ENTRY_DESC_OLD "desc"
#define ENTRY_NAME_OLD "name"
#define ENTRY_PW_OLD "pw"
#define ENTRY_COMMENT_OLD "comment"
#define ENTRY_URL_OLD "url"
#define ENTRY_LAUNCHER_OLD "launcher"
#define ENTRY_LVP_OLD "listViewPos"
#define ENTRY_BIN_OLD "b"
#define ENTRY_META_OLD "m"
#define ROOT_MAGIC_NEW "P"
#define VER_STR_NEW "v"
#define COMPAT_VER_NEW "2"
#define CAT_ROOT_NEW "c"
#define CAT_PREFIX_NEW "c"
#define CAT_NAME_NEW "n"
#define ENTRY_PREFIX_NEW "e"
#define ENTRY_DESC_NEW "d"
#define ENTRY_NAME_NEW "n"
#define ENTRY_PW_NEW "p"
#define ENTRY_COMMENT_NEW "c"
#define ENTRY_URL_NEW "u"
#define ENTRY_LAUNCHER_NEW "l"
#define ENTRY_LVP_NEW "v"
#define ENTRY_BIN_NEW ENTRY_BIN_OLD
#define ENTRY_META_NEW ENTRY_META_OLD
#if USE_OLD_TAGS != 0
# define ROOT_MAGIC_WR ROOT_MAGIC_OLD
# define VER_STR_WR VER_STR_OLD
# define COMPAT_VER_WR COMPAT_VER_OLD
# define CAT_ROOT_WR CAT_ROOT_OLD
# define CAT_PREFIX_WR CAT_PREFIX_OLD
# define CAT_NAME_WR CAT_NAME_OLD
# define ENTRY_PREFIX_WR ENTRY_PREFIX_OLD
# define ENTRY_DESC_WR ENTRY_DESC_OLD
# define ENTRY_NAME_WR ENTRY_NAME_OLD
# define ENTRY_PW_WR ENTRY_PW_OLD
# define ENTRY_COMMENT_WR ENTRY_COMMENT_OLD
# define ENTRY_URL_WR ENTRY_URL_OLD
# define ENTRY_LAUNCHER_WR ENTRY_LAUNCHER_OLD
# define ENTRY_LVP_WR ENTRY_LVP_OLD
# define ENTRY_BIN_WR ENTRY_BIN_OLD
# define ENTRY_META_WR ENTRY_META_OLD
#else
# define ROOT_MAGIC_WR ROOT_MAGIC_NEW
# define VER_STR_WR VER_STR_NEW
# define COMPAT_VER_WR COMPAT_VER_NEW
# define CAT_ROOT_WR CAT_ROOT_NEW
# define CAT_PREFIX_WR CAT_PREFIX_NEW
# define CAT_NAME_WR CAT_NAME_NEW
# define ENTRY_PREFIX_WR ENTRY_PREFIX_NEW
# define ENTRY_DESC_WR ENTRY_DESC_NEW
# define ENTRY_NAME_WR ENTRY_NAME_NEW
# define ENTRY_PW_WR ENTRY_PW_NEW
# define ENTRY_COMMENT_WR ENTRY_COMMENT_NEW
# define ENTRY_URL_WR ENTRY_URL_NEW
# define ENTRY_LAUNCHER_WR ENTRY_LAUNCHER_NEW
# define ENTRY_LVP_WR ENTRY_LVP_NEW
# define ENTRY_BIN_WR ENTRY_BIN_NEW
# define ENTRY_META_WR ENTRY_META_NEW
#endif
Serializer::Serializer()
{
defaultLockStat = true;
domDoc = new QDomDocument;
}
Serializer::Serializer(const QCString &buffer)
{
defaultLockStat = true;
domDoc = new QDomDocument;
if (!parseXml(buffer)) {
delete domDoc;
#ifndef PWM_EMBEDDED
throw PwMException(PwMException::EX_PARSE);
#else
qDebug("Serializer::Serializer : Parse Exception ");
#endif
}
}
Serializer::~Serializer()
{
delete_ifnot_null(domDoc);
}
void Serializer::clear()
{
delete_ifnot_null(domDoc);
domDoc = new QDomDocument;
}
bool Serializer::parseXml(const QCString &buffer)
{
PWM_ASSERT(domDoc);
#ifndef PWM_EMBEDDED
if (!domDoc->setContent(buffer, true))
return false;
#else
if (!domDoc->setContent(buffer))
return false;
#endif
if (!checkValid())
return false;
return true;
}
QCString Serializer::getXml()
{
PWM_ASSERT(domDoc);
#ifndef PWM_EMBEDDED
#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
QCString tmp(domDoc->toCString(8));
printDebug("<BEGIN Serializer::getXml() dump>\n");
cout << tmp << endl;
printDebug("<END Serializer::getXml() dump>");
#endif // DEBUG
QCString ret(domDoc->toCString(0));
ret.replace('\n', "");
return ret;
#else
#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
QCString tmp(" " + domDoc->toCString());
printDebug("<BEGIN Serializer::getXml() dump>\n");
cout << tmp << endl;
printDebug("<END Serializer::getXml() dump>");
#endif // DEBUG
QCString ret(domDoc->toCString());
ret.replace(QRegExp("\n"), "");
return ret;
#endif
}
bool Serializer::serialize(const vector<PwMCategoryItem> &dta)
{
PWM_ASSERT(domDoc);
QDomElement root(genNewRoot());
QDomElement catNode(domDoc->createElement(CAT_ROOT_WR));
root.appendChild(catNode);
if (!addCategories(&catNode, dta))
return false;
return true;
}
bool Serializer::deSerialize(vector<PwMCategoryItem> *dta)
{
PWM_ASSERT(domDoc);
PWM_ASSERT(dta);
QDomElement root(domDoc->documentElement());
QDomNode n;
dta->clear();
for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) {
// find <categories> ... </categories>