summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--pwmanager/pwmanager/addentrywnd_emb.cpp2
-rw-r--r--pwmanager/pwmanager/findwnd_emb.cpp123
-rw-r--r--pwmanager/pwmanager/findwnd_emb.h62
-rw-r--r--pwmanager/pwmanager/findwndimpl.cpp13
-rw-r--r--pwmanager/pwmanager/findwndimpl.h8
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.cpp86
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.h48
-rw-r--r--pwmanager/pwmanager/getmasterpwwndimpl.cpp14
-rw-r--r--pwmanager/pwmanager/getmasterpwwndimpl.h7
-rw-r--r--pwmanager/pwmanager/listviewpwm.cpp15
-rw-r--r--pwmanager/pwmanager/main.cpp2
-rw-r--r--pwmanager/pwmanager/pwgenwnd_emb.cpp3
-rw-r--r--pwmanager/pwmanager/pwm.cpp35
-rw-r--r--pwmanager/pwmanager/pwmanagerE.pro12
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp15
-rw-r--r--pwmanager/pwmanager/pwmviewstyle.cpp14
-rw-r--r--pwmanager/pwmanager/serializer.cpp2
-rw-r--r--pwmanager/pwmanager/setmasterpwwnd_emb.cpp163
-rw-r--r--pwmanager/pwmanager/setmasterpwwnd_emb.h62
-rw-r--r--pwmanager/pwmanager/setmasterpwwndimpl.cpp43
-rw-r--r--pwmanager/pwmanager/setmasterpwwndimpl.h8
21 files changed, 699 insertions, 38 deletions
diff --git a/pwmanager/pwmanager/addentrywnd_emb.cpp b/pwmanager/pwmanager/addentrywnd_emb.cpp
index 3a40cfc..ed02e6d 100644
--- a/pwmanager/pwmanager/addentrywnd_emb.cpp
+++ b/pwmanager/pwmanager/addentrywnd_emb.cpp
@@ -1,141 +1,141 @@
/*
This file is part of PwManager/Platform independent.
Copyright (c) 2004 Ulf Schenk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
$Id$
*/
#include "addentrywnd_emb.h"
#include <qlayout.h>
#include <qlabel.h>
#include <qtabwidget.h>
#include <qgroupbox.h>
#include <klocale.h>
#include <kcombobox.h>
#include <klineedit.h>
#include <qpushbutton.h>
/*
* Constructs a addEntryWnd 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.
*/
addEntryWnd::addEntryWnd( QWidget* parent, const char* name)
- : KDialogBase( KDialogBase::Plain, i18n( "Edit Password" ),
+ : KDialogBase( KDialogBase::Plain, i18n( "edit/add a password entry" ),
KDialogBase::Ok | KDialogBase::Cancel,
KDialogBase::Ok, parent, name, true )
{
QWidget *page = plainPage();
QVBoxLayout *pageLayout = new QVBoxLayout( page );
QTabWidget* mTabWidget = new QTabWidget( page );
pageLayout->addWidget( mTabWidget );
////////////////////////////////////////////////////////////////////
// This is the Password tab
QWidget *tab1 = new QWidget( mTabWidget );
QGridLayout *layout = new QGridLayout( tab1, 3, 1 );
layout->setMargin( KDialogBase::marginHint() );
layout->setSpacing( KDialogBase::spacingHint() );
int i = 0;
descLineEdit = new KLineEdit( tab1, "descLineEdit" );
QLabel* label = new QLabel( descLineEdit, i18n("Description:"), tab1 );
layout->addWidget( label, i, 0 );
layout->addWidget( descLineEdit, i, 1 );
i++;
categoryComboBox = new KComboBox( tab1 );
label = new QLabel( categoryComboBox, i18n("Category:"), tab1 );
layout->addWidget( label, i, 0 );
layout->addWidget( categoryComboBox, i, 1 );
i++;
categoryComboBox->setEditable( TRUE );
categoryComboBox->setSizeLimit( 100 );
categoryComboBox->setAutoCompletion( TRUE );
categoryComboBox->setDuplicatesEnabled( FALSE );
usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" );
label = new QLabel( usernameLineEdit, i18n("Username:"), tab1 );
layout->addWidget( label, i, 0 );
layout->addWidget( usernameLineEdit, i, 1 );
i++;
pwLineEdit = new KLineEdit( tab1, "pwLineEdit" );
pwLineEdit->setEchoMode( QLineEdit::Password );
label = new QLabel( pwLineEdit, i18n("Password:"), tab1 );
layout->addWidget( label, i, 0 );
layout->addWidget( pwLineEdit, i, 1 );
i++;
revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" );
revealButton->setToggleButton( TRUE );
layout->addWidget( revealButton, i, 0 );
generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" );
layout->addWidget( generateButton, i, 1 );
i++;
urlLineEdit = new KLineEdit( tab1, "urlLineEdit" );
label = new QLabel( urlLineEdit, i18n("URL:"), tab1 );
layout->addWidget( label, i, 0 );
layout->addWidget( urlLineEdit, i, 1 );
i++;
mTabWidget->addTab( tab1, i18n( "&Password" ) );
////////////////////////////////////////////////////////////////////
// This is the Comment tab
QWidget *tab2 = new QWidget( mTabWidget );
layout = new QGridLayout( tab2, 3, 1 );
layout->setMargin( KDialogBase::marginHintSmall() );
layout->setSpacing( KDialogBase::spacingHintSmall() );
i = 0;
groupBox1 = new QGroupBox( tab2, "groupBox1" );
commentDummy = new QLabel( groupBox1, "commentDummy" );
commentDummy->setText( QString::null );
groupBox1->setTitle( i18n( "Comment:" ) );
layout->addMultiCellWidget( groupBox1, i, i, 0, 1 );
i++;
advancedCommentButton = new QPushButton( i18n("advanced comment"), groupBox1, "advancedCommentButton" );
advancedCommentButton->setToggleButton( FALSE );
layout->addMultiCellWidget( advancedCommentButton, i, i, 0, 1 );
i++;
mTabWidget->addTab( tab2, i18n( "&Comments" ) );
diff --git a/pwmanager/pwmanager/findwnd_emb.cpp b/pwmanager/pwmanager/findwnd_emb.cpp
new file mode 100644
index 0000000..6db2684
--- a/dev/null
+++ b/pwmanager/pwmanager/findwnd_emb.cpp
@@ -0,0 +1,123 @@
+/*
+ This file is part of PwManager/Platform independent.
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+$Id$
+*/
+
+#include "findwnd_emb.h"
+
+#include <klocale.h>
+
+#include <qcheckbox.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qlayout.h>
+#include <klineedit.h>
+#include <qlabel.h>
+
+/*
+#include <qvariant.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+*/
+
+/*
+ * Constructs a findWnd as a child of 'parent', with the
+ * name 'name'.
+ */
+findWnd::findWnd( QWidget* parent, const char* name )
+ : KDialogBase( KDialogBase::Plain, i18n( "Find" ),
+ KDialogBase::Ok | KDialogBase::Cancel,
+ KDialogBase::Ok, parent, name, true )
+{
+ QWidget *page = plainPage();
+ QVBoxLayout *layout = new QVBoxLayout( page );
+ layout->setMargin( KDialogBase::marginHint() );
+ layout->setSpacing( KDialogBase::spacingHint() );
+
+ exactCheckBox = new QCheckBox( i18n( "&Exact match" ), page );
+ layout->addWidget( exactCheckBox );
+
+ caseSensCheckBox = new QCheckBox( i18n( "&Case sensitive" ), page );
+ layout->addWidget( caseSensCheckBox );
+
+
+ QButtonGroup* buttonGroup1 = new QButtonGroup(1, Qt::Horizontal, i18n( "Search in Column" ), page );
+ layout->addWidget( buttonGroup1 );
+
+ descRadioButton = new QRadioButton( i18n( "&Description" ), buttonGroup1 );
+ pwRadioButton = new QRadioButton( i18n( "&Password" ), buttonGroup1 );
+ commentRadioButton = new QRadioButton( i18n( "C&omment" ), buttonGroup1 );
+ nameRadioButton = new QRadioButton( i18n( "&Username" ), buttonGroup1 );
+ urlRadioButton = new QRadioButton( i18n( "U&RL" ), buttonGroup1 );
+ launcherRadioButton = new QRadioButton( i18n( "&Launcher" ), buttonGroup1 );
+ descRadioButton->setChecked( TRUE );
+
+ findLineEdit = new KLineEdit( page );
+ QLabel* label = new QLabel( findLineEdit, i18n( "Find:" ), page );
+ layout->addWidget( label );
+ layout->addWidget( findLineEdit );
+
+ setButtonText( KDialogBase::Ok, "&Find" );
+ setButtonText( KDialogBase::Cancel, "&Close" );
+
+
+ // resize( QSize(200, 150) );
+
+
+ connect( buttonGroup1, SIGNAL( clicked(int) ), this, SLOT( selectionChanged_slot() ) );
+ connect( findLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( selectionChanged_slot() ) );
+ connect( caseSensCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( selectionChanged_slot() ) );
+ connect( exactCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( selectionChanged_slot() ) );
+
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+findWnd::~findWnd()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void findWnd::findButton_slot()
+{
+ qWarning( "findWnd::findButton_slot(): Not implemented yet" );
+}
+
+void findWnd::selectionChanged_slot()
+{
+ qWarning( "findWnd::selectionChanged_slot(): Not implemented yet" );
+}
+
+void findWnd::closeButton_slot()
+{
+ qWarning( "findWnd::closeButton_slot(): Not implemented yet" );
+}
+
diff --git a/pwmanager/pwmanager/findwnd_emb.h b/pwmanager/pwmanager/findwnd_emb.h
new file mode 100644
index 0000000..9ad5a73
--- a/dev/null
+++ b/pwmanager/pwmanager/findwnd_emb.h
@@ -0,0 +1,62 @@
+/*
+ This file is part of PwManager/Platform independent.
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+$Id$
+*/
+
+
+#ifndef FINDWND_EMB_H
+#define FINDWND_EMB_H
+
+#include <kdialogbase.h>
+
+
+class QLineEdit;
+class QCheckBox;
+class QRadioButton;
+
+
+class findWnd : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ findWnd( QWidget* parent = 0, const char* name = 0 );
+ ~findWnd();
+
+ QLineEdit* findLineEdit;
+ QCheckBox* exactCheckBox;
+ QCheckBox* caseSensCheckBox;
+ QRadioButton* descRadioButton;
+ QRadioButton* pwRadioButton;
+ QRadioButton* commentRadioButton;
+ QRadioButton* nameRadioButton;
+ QRadioButton* urlRadioButton;
+ QRadioButton* launcherRadioButton;
+
+public slots:
+ virtual void findButton_slot();
+ virtual void selectionChanged_slot();
+ virtual void closeButton_slot();
+};
+
+#endif // FINDWND_H
diff --git a/pwmanager/pwmanager/findwndimpl.cpp b/pwmanager/pwmanager/findwndimpl.cpp
index fec1a6a..059219f 100644
--- a/pwmanager/pwmanager/findwndimpl.cpp
+++ b/pwmanager/pwmanager/findwndimpl.cpp
@@ -15,111 +15,124 @@
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "findwndimpl.h"
#include "pwmexception.h"
#include "pwmdoc.h"
#include "pwmview.h"
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <kmessagebox.h>
#include <klocale.h>
FindWndImpl::FindWndImpl(PwMView * _parent)
: findWnd()
{
parent = _parent;
fAt = 0;
refVal = 0;
currFoundPos = -1;
numEntries = parent->document()->numEntries(parent->getCurrentCategory());
connect(this, SIGNAL(foundAt(int)), parent, SLOT(selAt(int)));
}
FindWndImpl::~FindWndImpl()
{
}
void FindWndImpl::findButton_slot()
{
if (findLineEdit->text() == "")
return;
static vector<unsigned int> foundPositions;
PwMDoc *doc = parent->document();
if (currFoundPos < 0) {
bool unlockedTempoary = false;
foundPositions.clear();
PwMDataItem findThis;
unsigned int searchIn = 0;
if (descRadioButton->isChecked()) {
searchIn = SEARCH_IN_DESC;
findThis.desc = findLineEdit->text().latin1();
} else if (nameRadioButton->isChecked()) {
searchIn = SEARCH_IN_NAME;
findThis.name = findLineEdit->text().latin1();
} else if (pwRadioButton->isChecked()) {
searchIn = SEARCH_IN_PW;
findThis.pw = findLineEdit->text().latin1();
} else if (commentRadioButton->isChecked()) {
searchIn = SEARCH_IN_COMMENT;
findThis.comment = findLineEdit->text().latin1();
} else if (urlRadioButton->isChecked()) {
searchIn = SEARCH_IN_URL;
findThis.url = findLineEdit->text().latin1();
} else if (launcherRadioButton->isChecked()) {
searchIn = SEARCH_IN_LAUNCHER;
findThis.launcher = findLineEdit->text().latin1();
}
if (pwRadioButton->isChecked()) {
if (!doc->unlockAll_tempoary())
return;
unlockedTempoary = true;
}
doc->findEntry(parent->getCurrentCategory(), findThis,
searchIn, &foundPositions, false,
caseSensCheckBox->isChecked(),
exactCheckBox->isChecked(),
true);
if (unlockedTempoary) {
doc->unlockAll_tempoary(true);
}
if (!foundPositions.size()) {
KMessageBox::information(this,
i18n("No entry found."),
i18n("not found"));
return;
}
currFoundPos = 0;
}
int lvp = doc->getListViewPos(parent->getCurrentCategory(),
foundPositions[currFoundPos++]);
emit foundAt(numEntries - 1 - lvp);
if (currFoundPos + 1 > static_cast<int>(foundPositions.size()))
currFoundPos = 0;
}
+
+#ifdef PWM_EMBEDDED
+void FindWndImpl::slotOk()
+{
+ findButton_slot();
+
+ //do not call KDialogBase::slotOk() here
+ // user should press the close button instead
+}
+#endif
+
void FindWndImpl::closeButton_slot()
{
+#ifndef PWM_EMBEDDED
done(0);
+#endif
}
void FindWndImpl::selectionChanged_slot()
{
fAt = 0;
refVal = 0;
currFoundPos = -1;
}
#ifndef PWM_EMBEDDED
#include "findwndimpl.moc"
#endif
diff --git a/pwmanager/pwmanager/findwndimpl.h b/pwmanager/pwmanager/findwndimpl.h
index d8cb65d..b601390 100644
--- a/pwmanager/pwmanager/findwndimpl.h
+++ b/pwmanager/pwmanager/findwndimpl.h
@@ -1,61 +1,69 @@
/***************************************************************************
* *
* copyright (C) 2003 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$
**************************************************************************/
#ifndef FINDWNDIMPL_H
#define FINDWNDIMPL_H
+#ifndef PWM_EMBEDDED
#include "findwnd.h"
+#else
+#include "findwnd_emb.h"
+#endif
class PwMView;
/** "add" Window */
class FindWndImpl : public findWnd
{
Q_OBJECT
public:
FindWndImpl(PwMView *_parent);
~FindWndImpl();
signals:
void foundAt(int index);
public slots:
/** find button pressed */
void findButton_slot();
/** close button pressed */
void closeButton_slot();
/** selection of one of the radio buttons changed */
void selectionChanged_slot();
+#ifdef PWM_EMBEDDED
+ virtual void slotOk();
+#endif
+
protected:
/** parent view */
PwMView *parent;
/** entry found at */
unsigned int fAt;
/** reference value */
unsigned int refVal;
/** current position in the found-items-vector */
int currFoundPos;
/** the number of entries in the current category */
unsigned int numEntries;
/** index number of the current category */
unsigned int catIndex;
};
#endif
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
new file mode 100644
index 0000000..3519de8
--- a/dev/null
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
@@ -0,0 +1,86 @@
+/*
+ This file is part of PwManager/Platform independent.
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+$Id$
+*/
+
+#include "getmasterpwwnd_emb.h"
+
+#include "klocale.h"
+/*
+#include <qvariant.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+*/
+
+#include <qwidget.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+
+/*
+ * Constructs a getMasterPwWnd as a child of 'parent', with the
+ * name 'name'
+ */
+getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name)
+ : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ),
+ KDialogBase::Ok | KDialogBase::Cancel,
+ KDialogBase::Ok, parent, name, true )
+{
+ QWidget *page = plainPage();
+ QVBoxLayout *pageLayout = new QVBoxLayout( page );
+
+ pwLineEdit = new QLineEdit( page, "pwLineEdit" );
+ pwLineEdit->setEchoMode( QLineEdit::Password );
+
+ QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" );
+ textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
+ pageLayout->addWidget(textLabel1);
+ pageLayout->addWidget(pwLineEdit);
+
+
+ resize( QSize(200, 100) );
+
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+getMasterPwWnd::~getMasterPwWnd()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void getMasterPwWnd::okButton_slot()
+{
+ qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" );
+}
+
+void getMasterPwWnd::cancelButton_slot()
+{
+ qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" );
+}
+
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.h b/pwmanager/pwmanager/getmasterpwwnd_emb.h
new file mode 100644
index 0000000..64121c4
--- a/dev/null
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.h
@@ -0,0 +1,48 @@
+/*
+ This file is part of PwManager/Platform independent.
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+$Id$
+*/
+
+#ifndef GETMASTERPWWND_EMB_H
+#define GETMASTERPWWND_EMB_H
+
+#include <kdialogbase.h>
+
+class QLineEdit;
+
+class getMasterPwWnd : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ getMasterPwWnd( QWidget* parent = 0, const char* name = 0);
+ ~getMasterPwWnd();
+
+ QLineEdit* pwLineEdit;
+
+public slots:
+ virtual void okButton_slot();
+ virtual void cancelButton_slot();
+};
+
+#endif // GETMASTERPWWND_H
diff --git a/pwmanager/pwmanager/getmasterpwwndimpl.cpp b/pwmanager/pwmanager/getmasterpwwndimpl.cpp
index db0223e..6be9618 100644
--- a/pwmanager/pwmanager/getmasterpwwndimpl.cpp
+++ b/pwmanager/pwmanager/getmasterpwwndimpl.cpp
@@ -1,46 +1,60 @@
/***************************************************************************
* *
* copyright (C) 2003 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 "getmasterpwwndimpl.h"
#include <qlineedit.h>
GetMasterPwWndImpl::GetMasterPwWndImpl(QWidget * parent, const char *name)
: getMasterPwWnd(parent, name)
{
}
GetMasterPwWndImpl::~GetMasterPwWndImpl()
{
}
void GetMasterPwWndImpl::okButton_slot()
{
+#ifndef PWM_EMBEDDED
if (pwLineEdit->text() != "")
done(1);
+#endif
}
void GetMasterPwWndImpl::cancelButton_slot()
{
+#ifndef PWM_EMBEDDED
done(2);
+#endif
}
+#ifdef PWM_EMBEDDED
+void GetMasterPwWndImpl::slotOk()
+{
+ if (pwLineEdit->text() != "")
+ getMasterPwWnd::slotOk();
+ else
+ return;
+}
+#endif
+
#ifndef PWM_EMBEDDED
#include "getmasterpwwndimpl.moc"
#endif
diff --git a/pwmanager/pwmanager/getmasterpwwndimpl.h b/pwmanager/pwmanager/getmasterpwwndimpl.h
index 28aa427..8a4c03e 100644
--- a/pwmanager/pwmanager/getmasterpwwndimpl.h
+++ b/pwmanager/pwmanager/getmasterpwwndimpl.h
@@ -1,40 +1,47 @@
/***************************************************************************
* *
* copyright (C) 2003 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$
**************************************************************************/
#ifndef GETMASTERPWWNDIMPL_H
#define GETMASTERPWWNDIMPL_H
+#ifndef PWM_EMBEDDED
#include "getmasterpwwnd.h"
+#else
+#include "getmasterpwwnd_emb.h"
+#endif
/** set master pw wnd */
class GetMasterPwWndImpl : public getMasterPwWnd
{
Q_OBJECT
public:
GetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0);
~GetMasterPwWndImpl();
public slots:
/** ok button pressed */
void okButton_slot();
/** cancel button pressed */
void cancelButton_slot();
+#ifdef PWM_EMBEDDED
+ virtual void slotOk();
+#endif
};
#endif
diff --git a/pwmanager/pwmanager/listviewpwm.cpp b/pwmanager/pwmanager/listviewpwm.cpp
index b987c9e..c53cfd7 100644
--- a/pwmanager/pwmanager/listviewpwm.cpp
+++ b/pwmanager/pwmanager/listviewpwm.cpp
@@ -1,86 +1,97 @@
/***************************************************************************
* *
* 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 "listviewpwm.h"
#include "pwmexception.h"
#include <qpainter.h>
#include <qpixmap.h>
#include <kiconloader.h>
+#ifdef PWM_EMBEDDED
+#include <kglobal.h>
+#endif
ListViewPwM::ListViewPwM(QWidget *parent, const char *name)
: KListView(parent, name)
{
// setResizeMode(QListView::AllColumns);
}
bool ListViewPwM::event(QEvent *e)
{
if (e->type() == QEvent::LayoutHint)
emit layoutChanged();
return KListView::event(e);
}
QPixmap * ListViewItemPwM::onPix = 0;
QPixmap * ListViewItemPwM::offPix = 0;
ListViewItemPwM::ListViewItemPwM(QListView *parent)
: QCheckListItem(parent, "", QCheckListItem::CheckBox)
{
if (!onPix) {
PWM_ASSERT(!offPix);
+ KIconLoader* picons;
+#ifndef PWM_EMBEDDED
+ KIconLoader il;
+ picons = &il;
+#else
+ picons = KGlobal::iconLoader();
+#endif
+
KIconLoader il;
- static QPixmap onP(il.loadIcon("button_ok", KIcon::Small));
+ static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small));
onPix = &onP;
- static QPixmap offP(il.loadIcon("encrypted", KIcon::Small));
+ static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small));
offPix = &offP;
}
}
void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg,
int column, int width, int align)
{
if (!p)
return;
if (column != 0) {
QCheckListItem::paintCell(p, cg, column, width, align);
return;
}
QPixmap *curPix = isOn() ? onPix : offPix;
int pixSpace = curPix->width();
pixSpace += 4;
#ifndef PWM_EMBEDDED
QRect window(p->viewport());
// clear the rectangle (we have to clear it first. see QT doc)
p->eraseRect(0, 0, pixSpace, window.height());
// now draw the pixmap
int y = (height() - curPix->height()) / 2;
p->drawPixmap(1, y, *curPix);
window.moveLeft(pixSpace);
p->setViewport(window);
#endif
QListViewItem::paintCell(p, cg, column, width - pixSpace, align);
}
#ifndef PWM_EMBEDDED
#include "listviewpwm.moc"
#endif
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp
index d720e1f..3ae4d55 100644
--- a/pwmanager/pwmanager/main.cpp
+++ b/pwmanager/pwmanager/main.cpp
@@ -1,210 +1,212 @@
/***************************************************************************
* *
* 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$
**************************************************************************/
#ifndef PWM_EMBEDDED
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#else
#include <qdir.h>
+#include <kpimglobalprefs.h>
#endif
#include <klocale.h>
#include <kstandarddirs.h>
#include "pwmexception.h"
#include "pwminit.h"
#define LICENSE_FILE (::locate("data", "pwmanager/pwmanager_license_text"))
int PwMApplication::newInstance()
{
static bool initial = true;
if (initial) {
initial = false;
init = new PwMInit(this);
init->initializeApp();
} else {
BUG_ON(!init);
printInfo("passing parameters to old instance.");
init->handleCmdLineArgs(false);
}
return EXIT_SUCCESS;
}
static const char *description = I18N_NOOP("PwManager\n"
"The convenient way of managing passwords");
#ifndef PWM_EMBEDDED
static KCmdLineOptions options[] =
{
{ "minimized", I18N_NOOP("Windows minimized"), 0 },
{ "mintray", I18N_NOOP("Windows minimized to tray"), 0 },
{ "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"), 0 },
{ "skip-self-test", I18N_NOOP("Don't run a self-test on startup"), 0 },
{ "+[files...]", I18N_NOOP("Files to open on startup"), 0 },
{ 0, 0, 0 }
};
#endif
#ifdef PWM_DEBUG
static void printDebugConfigureInfo()
{
cout << "================================" << endl;
cout << PROG_NAME " version " PACKAGE_VER << endl;
#ifdef CONFIG_KEYCARD
cout << "CONFIG_KEYCARD: enabled" << endl;
#else
cout << "CONFIG_KEYCARD: disabled" << endl;
#endif
#ifdef CONFIG_KWALLETIF
cout << "CONFIG_KWALLETIF: enabled" << endl;
#else
cout << "CONFIG_KWALLETIF: disabled" << endl;
#endif
#ifdef BIG_ENDIAN_HOST
cout << "Endianess: big-endian" << endl;
#else
cout << "Endianess: little-endian" << endl;
#endif
cout << "sizeof(long): " << sizeof(long) << endl;
cout << "================================" << endl;
}
#else // PWM_DEBUG
static inline void printDebugConfigureInfo() { /* nothing */ }
#endif // PWM_DEBUG
#ifndef PWM_EMBEDDED
static void addAuthors(KAboutData *aboutData)
{
aboutData->addAuthor("Michael Buesch",
I18N_NOOP(
"main programming and current maintainer"),
"mbuesch@freenet.de");
aboutData->addAuthor("Matt Scifo",
I18N_NOOP(
"original implementaion of \n"
"\"categories\" and the password-tree \n"
"in the system-tray. Original implementations of \n"
"numerous view-improvements."),
"mscifo@o1.com");
aboutData->addCredit("Elias Probst",
I18N_NOOP(
"Gentoo ebuild maintainer."),
"elias.probst@gmx.de");
aboutData->addCredit("George Staikos",
I18N_NOOP("KWallet"),
"staikos@kde.org");
aboutData->addCredit("Matthew Palmer",
I18N_NOOP("rc2 code"),
"mjp16@uow.edu.au");
aboutData->addCredit("Olivier Sessink",
I18N_NOOP("gpasman"),
"gpasman@nl.linux.org");
aboutData->addCredit("The libgcrypt developers",
I18N_NOOP("Blowfish and SHA1 algorithms"),
0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/");
aboutData->addCredit("Troy Engel",
I18N_NOOP("kpasman"),
"tengel@sonic.net");
aboutData->addCredit("Wickey",
I18N_NOOP("graphics-design in older versions."),
"wickey@gmx.at");
aboutData->addCredit("Ian MacGregor",
I18N_NOOP(
"original documentation author."));
}
#endif
int main(int argc, char *argv[])
{
printDebugConfigureInfo();
#ifndef PWM_EMBEDDED
KAboutData aboutData(PACKAGE_NAME, PROG_NAME,
PACKAGE_VER, description, KAboutData::License_File,
"(c) 2003, 2004 Michael Buesch and the PwManager Team", 0,
"http://passwordmanager.sourceforge.net/",
"mbuesch@freenet.de");
addAuthors(&aboutData);
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineArgs::addCmdLineOptions(options);
KUniqueApplication::addCmdLineOptions();
if (!KUniqueApplication::start()) {
printInfo("already running.");
return EXIT_SUCCESS;
}
PwMApplication a;
aboutData.setLicenseTextFile(LICENSE_FILE);
return a.exec();
#else
bool exitHelp = false;
if ( argc > 1 ) {
QString command = argv[1];
if ( command == "-help" ){
printf("PWM/PI command line commands:\n");
printf(" no command: Start PWM/PI in usual way\n");
printf(" -help: This output\n");
printf(" PWM/PI is exiting now. Bye!\n");
exitHelp = true;
}
}
if ( ! exitHelp ) {
PwMApplication a(argc, argv);
KGlobal::setAppName( "pwmanager" );
#ifndef DESKTOP_VERSION
//US if ( QApplication::desktop()->width() > 320 )
//US KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
//US else
KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
#else
QString fileName ;
fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
QApplication::addLibraryPath ( qApp->applicationDirPath () );
#endif
KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
+ KPimGlobalPrefs::instance()->setGlobalConfig();
a.newInstance();
//US KAddressBookMain m ;
//US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
/*US
#ifndef DESKTOP_VERSION
a.showMainWidget( &m );
#else
a.setMainWidget( &m );
m.resize (640, 480 );
m.show();
#endif
*/
a.exec();
}
qDebug("PWMPI: Bye! ");
#endif
}
diff --git a/pwmanager/pwmanager/pwgenwnd_emb.cpp b/pwmanager/pwmanager/pwgenwnd_emb.cpp
index 9655e9f..429904c 100644
--- a/pwmanager/pwmanager/pwgenwnd_emb.cpp
+++ b/pwmanager/pwmanager/pwgenwnd_emb.cpp
@@ -1,137 +1,134 @@
/*
This file is part of PwManager/Platform independent.
Copyright (c) 2004 Ulf Schenk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
$Id$
*/
#include "pwgenwnd_emb.h"
#include <qpushbutton.h>
#include <qgroupbox.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qlayout.h>
#include "klocale.h"
/*
* Constructs a pwGenWnd as a child of 'parent', with the
* name 'name'.
*
*/
pwGenWnd::pwGenWnd( QWidget* parent, const char* name)
: KDialogBase( KDialogBase::Plain, i18n( "Password generator" ),
KDialogBase::Ok | KDialogBase::Cancel,
KDialogBase::Ok, parent, name, true )
{
- if ( !name )
- setName( "pwGenWnd" );
-
QWidget *page = plainPage();
QVBoxLayout* pwGenWndLayout = new QVBoxLayout( page, 11, 6, "pwGenWndLayout");
QGroupBox* groupBox1 = new QGroupBox( page, "groupBox1" );
groupBox1->setTitle( i18n( "Character set:" ) );
groupBox1->setColumnLayout(0, Qt::Vertical );
groupBox1->layout()->setSpacing( 6 );
groupBox1->layout()->setMargin( 11 );
QVBoxLayout* groupBox1Layout = new QVBoxLayout( groupBox1->layout() );
groupBox1Layout->setAlignment( Qt::AlignTop );
int_charLowerCheckBox = new QCheckBox( i18n("Lowercase (abc)"), groupBox1, "int_charLowerCheckBox" );
int_charLowerCheckBox->setChecked( TRUE );
groupBox1Layout->addWidget( int_charLowerCheckBox );
int_charUpperCheckBox = new QCheckBox( i18n("Uppercase (ABC)"), groupBox1, "int_charUpperCheckBox" );
int_charUpperCheckBox->setChecked( TRUE );
groupBox1Layout->addWidget( int_charUpperCheckBox );
int_charNumCheckBox = new QCheckBox( i18n("Numbers (123)"), groupBox1, "int_charNumCheckBox" );
int_charNumCheckBox->setChecked( TRUE );
groupBox1Layout->addWidget( int_charNumCheckBox );
int_charSpecCheckBox = new QCheckBox( i18n("Special characters:"), groupBox1, "int_charSpecCheckBox" );
groupBox1Layout->addWidget( int_charSpecCheckBox );
QLabel* textLabel7 = new QLabel( groupBox1, "textLabel7" );
QString st("\x21\x22\xc2\xa7\x24\x25\x26\x2f\x28\x29\x3d\x3f\x2c\x2e\x2d\x3b\x3a\x5f\x2b");
textLabel7->setText( st.utf8() );
groupBox1Layout->addWidget( textLabel7 );
int_charBlankCheckBox = new QCheckBox( i18n( "Spaces (blank characters)"), groupBox1, "int_charBlankCheckBox" );
groupBox1Layout->addWidget( int_charBlankCheckBox );
QHBoxLayout* layout7 = new QHBoxLayout( 0, 0, 6, "layout7");
int_charUserCheckBox = new QCheckBox( i18n("User defined:"), groupBox1, "int_charUserCheckBox" );
layout7->addWidget( int_charUserCheckBox );
int_userDefLineEdit = new QLineEdit( groupBox1, "int_userDefLineEdit" );
int_userDefLineEdit->setEnabled( FALSE );
layout7->addWidget( int_userDefLineEdit );
groupBox1Layout->addLayout( layout7 );
pwGenWndLayout->addWidget( groupBox1 );
QHBoxLayout* layout8 = new QHBoxLayout( 0, 0, 6, "layout8");
int_lenSpinBox = new QSpinBox( page, "int_lenSpinBox" );
QLabel* textLabel2 = new QLabel( int_lenSpinBox, i18n("Password Length:"), page, "textLabel2" );
layout8->addWidget( textLabel2 );
int_lenSpinBox->setMaxValue( 9999 );
int_lenSpinBox->setMinValue( 1 );
int_lenSpinBox->setValue( 8 );
layout8->addWidget( int_lenSpinBox );
pwGenWndLayout->addLayout( layout8 );
int_filterCheckBox = new QCheckBox( i18n( "Enable Filtering to get better passwords" ), page, "int_filterCheckBox" );
int_filterCheckBox->setChecked( TRUE );
pwGenWndLayout->addWidget( int_filterCheckBox );
setButtonText( KDialogBase::Ok, "&Generate now" );
// signals and slots connections
connect( int_charUserCheckBox, SIGNAL( toggled(bool) ), int_userDefLineEdit, SLOT( setEnabled(bool) ) );
}
/*
* Destroys the object and frees any allocated resources
*/
pwGenWnd::~pwGenWnd()
{
// no need to delete child widgets, Qt does it all for us
}
void pwGenWnd::cancelButton_slot()
{
qWarning( "pwGenWnd::cancelButton_slot(): Not implemented yet" );
}
void pwGenWnd::genButton_slot()
{
qWarning( "pwGenWnd::genButton_slot(): Not implemented yet" );
}
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 107e845..bd07c80 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -264,199 +264,204 @@ void PwM::initMenubar()
BUTTON_POPUP_MANAGE_ADD);
managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
BUTTON_POPUP_MANAGE_EDIT);
managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
i18n("&Delete"), this, SLOT(deletePwd_slot()),
0, BUTTON_POPUP_MANAGE_DEL);
managePopup->insertSeparator();
managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
i18n("Change &Master Password"), this,
SLOT(changeMasterPwd_slot()), 0,
BUTTON_POPUP_MANAGE_CHANGEMP);
menuBar()->insertItem(i18n("&Manage"), managePopup);
// "chipcard" popup menu
#ifdef CONFIG_KEYCARD
chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
i18n("&Generate new key-card"), this,
SLOT(genNewCard_slot()), 0,
BUTTON_POPUP_CHIPCARD_GENNEW);
chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
i18n("&Erase key-card"), this,
SLOT(eraseCard_slot()), 0,
BUTTON_POPUP_CHIPCARD_DEL);
chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
i18n("Read card-&ID"), this,
SLOT(readCardId_slot()), 0,
BUTTON_POPUP_CHIPCARD_READID);
chipcardPopup->insertSeparator();
chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
i18n("&Make card backup-image"), this,
SLOT(makeCardBackup_slot()), 0,
BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
i18n("&Replay card backup-image"), this,
SLOT(replayCardBackup_slot()), 0,
BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
#endif // CONFIG_KEYCARD
// "view" popup menu
viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
i18n("&Find"), this,
SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
viewPopup->insertSeparator();
viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
i18n("&Lock all entries"), this,
SLOT(lockWnd_slot()), 0,
BUTTON_POPUP_VIEW_LOCK);
viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
i18n("&Deep-lock all entries"), this,
SLOT(deepLockWnd_slot()), 0,
BUTTON_POPUP_VIEW_DEEPLOCK);
viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
i18n("&Unlock all entries"), this,
SLOT(unlockWnd_slot()), 0,
BUTTON_POPUP_VIEW_UNLOCK);
menuBar()->insertItem(i18n("&View"), viewPopup);
// "options" popup menu
optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
i18n("&Configure..."), this,
SLOT(config_slot()),
BUTTON_POPUP_OPTIONS_CONFIG);
menuBar()->insertItem(i18n("&Options"), optionsPopup);
// "help" popup menu
#ifndef PWM_EMBEDDED
helpPopup = helpMenu(QString::null, false);
#else
helpPopup = new KPopupMenu(this);
helpPopup->insertItem(i18n("&License"), this,
SLOT(showLicense_slot()), 0,
BUTTON_POPUP_HELP_LICENSE);
helpPopup->insertItem(i18n("&Faq"), this,
SLOT(faq_slot()), 0,
BUTTON_POPUP_HELP_FAQ);
helpPopup->insertItem(i18n("&About PwManager"), this,
SLOT(createAboutData_slot()), 0,
BUTTON_POPUP_HELP_ABOUT);
#endif
menuBar()->insertItem(i18n("&Help"), helpPopup);
}
void PwM::initToolbar()
{
KIconLoader* picons;
#ifndef PWM_EMBEDDED
KIconLoader icons;
picons = &icons;
#else
picons = KGlobal::iconLoader();
#endif
+#ifdef PWM_EMBEDDED
+ if ( QApplication::desktop()->width() > 320 )
+#endif
+ {
toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
SLOT(new_slot()), true, i18n("New"));
toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
SLOT(open_slot()), true, i18n("Open"));
toolBar()->insertSeparator();
+ }
toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
SLOT(save_slot()), true, i18n("Save"));
toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
SLOT(saveAs_slot()), true, i18n("Save as"));
toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
SLOT(print_slot()), true, i18n("Print..."));
toolBar()->insertSeparator();
toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
SLOT(addPwd_slot()), true,
i18n("Add password"));
toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
SLOT(editPwd_slot()), true,
i18n("Edit password"));
toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
SLOT(deletePwd_slot()), true,
i18n("Delete password"));
toolBar()->insertSeparator();
toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
SLOT(find_slot()), true, i18n("Find entry"));
toolBar()->insertSeparator();
toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
SLOT(lockWnd_slot()), true,
i18n("Lock all entries"));
toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
SLOT(deepLockWnd_slot()), true,
i18n("Deep-Lock all entries"));
toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
SLOT(unlockWnd_slot()), true,
i18n("Unlock all entries"));
}
void PwM::initMetrics()
{
QSize s = conf()->confWndMainWndSize();
if (s.isValid())
resize(s);
else
resize(DEFAULT_SIZE);
}
void PwM::updateCaption()
{
setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER);
}
void PwM::hideEvent(QHideEvent *)
{
if (isMinimized()) {
if (init->tray()) {
forceMinimizeToTray = true;
close();
}
int mmlock = conf()->confGlobMinimizeLock();
switch (mmlock) {
case 0: // don't lock anything
break;
case 1: { // normal lock
curDoc()->lockAll(true);
break;
} case 2: { // deep-lock
curDoc()->deepLock();
break;
} default:
WARN();
}
}
}
void PwM::setVirgin(bool v)
{
if (virgin == v)
return;
virgin = v;
filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
@@ -632,194 +637,194 @@ void PwM::editPwd_slot(const QString *category, const int *index,
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())
+ ("Do you really want to delete\nthe selected entry") +
+ " \n\"" + 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()
{
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))
return;
#endif
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());
++i2;
}
}
@@ -1189,121 +1194,117 @@ void PwM::replayCardBackup_slot()
}
void PwM::execLauncher_slot()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDeepLocked())
return;
unsigned int curEntryIndex;
if (!view->getCurEntryIndex(&curEntryIndex))
return;
bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
curEntryIndex);
if (ret)
showStatMsg(i18n("Executed the \"Launcher\"."));
else
showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
}
void PwM::goToURL_slot()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDeepLocked())
return;
unsigned int curEntryIndex;
if (!view->getCurEntryIndex(&curEntryIndex))
return;
bool ret = curDoc()->goToURL(view->getCurrentCategory(),
curEntryIndex);
if (ret)
showStatMsg(i18n("started browser with current URL."));
else
showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
}
void PwM::copyToClipboard(const QString &s)
{
QClipboard *cb = QApplication::clipboard();
#ifndef PWM_EMBEDDED
if (cb->supportsSelection())
cb->setText(s, QClipboard::Selection);
cb->setText(s, QClipboard::Clipboard);
#else
cb->setText(s);
#endif
}
void PwM::showStatMsg(const QString &msg)
{
#ifndef PWM_EMBEDDED
KStatusBar *statBar = statusBar();
statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
#else
qDebug("Statusbar : %s",msg.latin1());
#endif
}
void PwM::focusInEvent(QFocusEvent *e)
{
if (e->gotFocus()) {
emit gotFocus(this);
} else if (e->lostFocus()) {
emit lostFocus(this);
}
}
#ifdef PWM_EMBEDDED
void PwM::showLicense_slot()
{
KApplication::showLicence();
}
void PwM::faq_slot()
{
KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
}
void PwM::createAboutData_slot()
{
QString version;
#include <../version>
QMessageBox::about( this, "About PwManager/Pi",
"PwManager/Platform-independent\n"
"(PWM/Pi) " +version + " - " +
#ifdef DESKTOP_VERSION
"Desktop Edition\n"
#else
"PDA-Edition\n"
"for: Zaurus 5500 / 7x0 / 8x0\n"
#endif
"(c) 2004 Ulf Schenk\n"
"(c) 2004 Lutz Rogowski\n"
- "(c) 1997-2003, The KDE PIM Team\n"
-
- "Michael Buesch - main programming and current maintainer\nmbuesch@freenet.de\n"
- "Matt Scifo - original implementaion of \n"
- "\"categories\" and the password-tree \n"
- "in the system-tray. Original implementations of \n"
- "numerous view-improvements.\n"
- "mscifo@o1.com\n"
- "Elias Probst - Gentoo ebuild maintainer.\nelias.probst@gmx.de\n"
- "George Staikos - KWallet\nstaikos@kde.org\n"
- "Matthew Palmer - rc2 code\nmjp16@uow.edu.au\n"
- "Olivier Sessink - gpasman\ngpasman@nl.linux.org\n"
- "The libgcrypt developers - Blowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
- "Troy Engel - kpasman\n tengel@sonic.net\n"
- "Wickey - graphics-design in older versions\nwickey@gmx.at\n"
+ "(c) 1997-2004, The KDE PIM Team\n"
+
+ "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n"
+ "Matt Scifo - mscifo@o1.com\n"
+ "Elias Probst - elias.probst@gmx.de\n"
+ "George Staikos - staikos@kde.org\n"
+ "Matthew Palmer - mjp16@uow.edu.au\n"
+ "Olivier Sessink - gpasman@nl.linux.org\n"
+ "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
+ "Troy Engel - tengel@sonic.net\n"
+ "Wickey - wickey@gmx.at\n"
"Ian MacGregor - original documentation author.\n"
);
}
#endif
#ifndef PWM_EMBEDDED
#include "pwm.moc"
#endif
diff --git a/pwmanager/pwmanager/pwmanagerE.pro b/pwmanager/pwmanager/pwmanagerE.pro
index 87142b7..b0c9236 100644
--- a/pwmanager/pwmanager/pwmanagerE.pro
+++ b/pwmanager/pwmanager/pwmanagerE.pro
@@ -1,153 +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 ../../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_emb.h \
addentrywndimpl.h \
base64.h \
binentrygen.h \
blowfish.h \
commentbox.h \
compiler.h \
compressbzip2.h \
compressgzip.h \
-findwnd.h \
+findwnd_emb.h \
findwndimpl.h \
genpasswd.h \
getkeycardwnd.h \
-getmasterpwwnd.h \
+getmasterpwwnd_emb.h \
getmasterpwwndimpl.h \
globalstuff.h \
gpasmanfile.h \
htmlgen.h \
htmlparse.h \
ipc.h \
listobjselectwnd.h \
listviewpwm.h \
printtext.h \
pwgenwnd_emb.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 \
+setmasterpwwnd_emb.h \
setmasterpwwndimpl.h \
sha1.h \
subtbledit.h \
subtbleditimpl.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_emb.cpp \
addentrywndimpl.cpp \
base64.cpp \
binentrygen.cpp \
blowfish.cpp \
commentbox.cpp \
compressbzip2.cpp \
compressgzip.cpp \
-findwnd.cpp \
+findwnd_emb.cpp \
findwndimpl.cpp \
genpasswd.cpp \
getkeycardwnd.cpp \
-getmasterpwwnd.cpp \
+getmasterpwwnd_emb.cpp \
getmasterpwwndimpl.cpp \
globalstuff.cpp \
gpasmanfile.cpp \
htmlgen.cpp \
ipc.cpp \
listobjselectwnd.cpp \
listviewpwm.cpp \
main.cpp \
pwgenwnd_emb.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 \
+setmasterpwwnd_emb.cpp \
setmasterpwwndimpl.cpp \
sha1.cpp \
subtbledit.cpp \
subtbleditimpl.cpp \
waitwnd.cpp \
kcmconfigs/kcmpwmconfig.cpp \
kcmconfigs/pwmconfigwidget.cpp \
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index 3993fa8..e42dd9d 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -1,262 +1,264 @@
/***************************************************************************
* *
* 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
+ GetMasterPwWndImpl pwWnd;
KWin::setState(pwWnd.winId(), NET::StaysOnTop);
+#else
+ GetMasterPwWndImpl pwWnd;
#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) {
+#ifndef PWM_EMBEDDED
pwWnd.mainTab->removePage(pwWnd.mainTab->page(1));
- }
#else
- qDebug("PwMDocUi::requestNewMpw must be implemented");
+ pwWnd.mainTab->removePage(pwWnd.tab_2);
#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 "
+ "Please try again with the\n"
"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 "
+ "Please insert the\n"
"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?"));
if (ret == KMessageBox::Yes) {
return 0;
} else if (ret == KMessageBox::No) {
return 1;
}
#endif
// cancel
return -1;
}
bool PwMDocUi::saveDocUi(PwMDoc *doc)
{
PWM_ASSERT(doc);
doc->timer()->getLock(DocTimer::id_autoLockTimer);
if (doc->isDocEmpty()) {
KMessageBox::information(currentView,
i18n
("Sorry, there's nothing to save.\n"
"Please first add some passwords."),
i18n("nothing to do"));
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return true;
}
PwMerror ret = doc->saveDoc(conf()->confGlobCompression());
if (ret == e_filename) {
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return saveAsDocUi(doc);
} else if (ret == e_weakPw) {
KMessageBox::error(currentView,
@@ -267,188 +269,189 @@ bool PwMDocUi::saveDocUi(PwMDoc *doc)
return false;
} else if (ret == e_fileBackup) {
KMessageBox::error(currentView,
i18n("Error: Couldn't make backup-file!"),
i18n("backup failed"));
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return false;
} else if (ret != e_success) {
KMessageBox::error(currentView,
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"));
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return false;
}
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return true;
}
bool PwMDocUi::saveAsDocUi(PwMDoc *doc)
{
PWM_ASSERT(doc);
doc->timer()->getLock(DocTimer::id_autoLockTimer);
if (doc->isDocEmpty()) {
KMessageBox::information(currentView,
i18n
("Sorry, there's nothing to save.\n"
"Please first add some passwords."),
i18n("nothing to do"));
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return true;
}
#ifndef PWM_EMBEDDED
QString fn(KFileDialog::getSaveFileName(QString::null,
i18n("*.pwm|PwManager Password file"),
currentView));
#else
QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" );
fn = KFileDialog::getSaveFileName(fn,
i18n("password filename(*.pwm)"),
currentView);
#endif
if (fn == "") {
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return false;
}
if (fn.right(4) != ".pwm")
fn += ".pwm";
PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn);
if (ret != e_success) {
KMessageBox::error(currentView,
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"));
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return false;
}
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return true;
}
bool PwMDocUi::openDocUi(PwMDoc *doc,
QString filename,
bool openDeepLocked)
{
if (filename.isEmpty())
{
#ifndef PWM_EMBEDDED
filename = KFileDialog::getOpenFileName(QString::null,
i18n("*.pwm|PwManager Password file\n"
"*|All files"), getCurrentView());
#else
filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm");
filename = KFileDialog::getOpenFileName(filename,
i18n("password filename(*.pwm)"), getCurrentView());
#endif
}
if (filename.isEmpty())
goto cancelOpen;
PwMerror ret;
while (true) {
int lockStat = -1;
if (openDeepLocked) {
lockStat = 2;
} else {
if (conf()->confGlobUnlockOnOpen()) {
lockStat = 0;
} else {
lockStat = 1;
}
}
ret = doc->openDoc(&filename, lockStat);
+ qDebug("pwmdocui::OpenDocui %i", ret);
if (ret != e_success) {
if (ret == e_readFile || ret == e_openFile) {
KMessageBox::error(getCurrentView(),
i18n("Could not read file!")
+ "\n"
+ filename,
i18n("file error"));
goto cancelOpen;
}
if (ret == e_alreadyOpen) {
KMessageBox::error(getCurrentView(),
i18n("This file is already open."),
i18n("already open"));
goto cancelOpen;
}
if (ret == e_fileVer) {
KMessageBox::error(getCurrentView(),
i18n
("File-version is not supported!\n"
"Did you create this file with an older or newer version of PwM?"),
i18n
("incompatible version"));
goto cancelOpen;
}
if (ret == e_wrongPw) {
continue;
}
if (ret == e_noPw) {
goto cancelOpen;
}
if (ret == e_fileFormat) {
KMessageBox::error(getCurrentView(),
i18n
("Sorry, this file has not been recognized "
"as a PwM Password file.\n"
"Probably you have selected the wrong file."),
i18n
("no PwM password-file"));
goto cancelOpen;
}
if (ret == e_fileCorrupt) {
KMessageBox::error(getCurrentView(),
i18n
("File corrupt!\n"
"Maybe the media, you stored this file on, "
"had bad sectors?"),
i18n
("checksum error"));
goto cancelOpen;
}
}
break;
}
return true;
cancelOpen:
return false;
}
QString PwMDocUi::string_defaultCategory()
{
return i18n("Default");
}
QString PwMDocUi::string_locked()
{
return i18n("<LOCKED>");
}
QString PwMDocUi::string_deepLockedShort()
{
return i18n("DEEP-LOCKED");
}
QString PwMDocUi::string_deepLockedLong()
{
return i18n("This file is DEEP-LOCKED!\n"
"That means all data has been encrypted "
"and written out to the file. If you want "
"to see the entries, please UNLOCK the file. "
"While unlocking, you will be prompted for the "
"master-password or the key-card.");
}
QString PwMDocUi::string_defaultTitle()
{
return i18n("Untitled");
}
#ifndef PWM_EMBEDDED
#include "pwmdocui.moc"
#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle.cpp b/pwmanager/pwmanager/pwmviewstyle.cpp
index 67b5197..51d8f6c 100644
--- a/pwmanager/pwmanager/pwmviewstyle.cpp
+++ b/pwmanager/pwmanager/pwmviewstyle.cpp
@@ -1,177 +1,189 @@
/***************************************************************************
* *
* 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 "pwmviewstyle.h"
#include "pwmexception.h"
#include "pwmviewstyle_0.h"
#include "pwmviewstyle_1.h"
#include "listviewpwm.h"
#include "pwmview.h"
#include "commentbox.h"
-
+#ifndef PWM_EMBEDDED
+#include "configuration.h"
+#else
+#include "pwmprefs.h"
+#endif
PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name)
: QWidget(parent, name)
{
curStyle = style_notset;
s0 = 0;
s1 = 0;
}
PwMViewStyle::~PwMViewStyle()
{
+ //US ENH : load and store the size of the listviewcolumns
+ lv->saveLayout(conf()->getConfig(), "listview");
+ conf()->getConfig()->sync();
+
delete_ifnot_null(s0);
delete_ifnot_null(s1);
}
void PwMViewStyle::initStyle(style_t style)
{
printDebug(string("initializing style ") + tostr(style));
bool wasMaximized = v->isMaximized();
if (v->isVisible())
v->hide();
switch (style) {
case style_0:
delete_ifnot_null(s0);
delete_ifnot_null(s1);
s0 = new PwMViewStyle_0(v);
lv = s0->getLv();
commentBox = s0->getCommentBox();
break;
case style_1:
delete_ifnot_null(s0);
delete_ifnot_null(s1);
s1 = new PwMViewStyle_1(v);
lv = s1->getLv();
commentBox = s1->getCommentBox();
break;
default:
BUG();
return;
}
curStyle = style;
connect(lv, SIGNAL(pressed(QListViewItem *)),
v, SLOT(handleToggle(QListViewItem *)));
connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)),
v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int)));
connect(lv, SIGNAL(clicked(QListViewItem *)),
v, SLOT(refreshCommentTextEdit(QListViewItem *)));
lv->addColumn(i18n("Description"), 180);
lv->addColumn(i18n("Username"), 150);
lv->addColumn(i18n("Password"), 150);
lv->addColumn(i18n("URL"), 180);
lv->addColumn(i18n("Launcher"), 120);
v->tmpReEnableSort();
+
+ //US ENH : load and store the size of the listviewcolumns
+ lv->restoreLayout(conf()->getConfig(), "listview");
+
resizeView(v->size());
v->updateView();
if (wasMaximized) {
v->showMaximized();
} else {
v->show();
}
connect(lv, SIGNAL(layoutChanged()),
v, SLOT(reorgLp()));
}
void PwMViewStyle::resizeView(const QSize &size)
{
switch (curStyle) {
case style_0:
PWM_ASSERT(s0);
s0->resize(size);
return;
case style_1:
PWM_ASSERT(s1);
s1->resize(size);
return;
default:
BUG();
}
}
QString PwMViewStyle::getCurrentCategory()
{
switch (curStyle) {
case style_0:
PWM_ASSERT(s0);
return s0->getCurrentCategory();
case style_1:
PWM_ASSERT(s1);
return s1->getCurrentCategory();
default:
BUG();
}
return "";
}
void PwMViewStyle::addCategory(const QString &cat)
{
switch (curStyle) {
case style_0:
PWM_ASSERT(s0);
s0->addCategory(cat);
return;
case style_1:
PWM_ASSERT(s1);
s1->addCategory(cat);
return;
default:
BUG();
}
}
void PwMViewStyle::delCategory(const QString &cat)
{
switch (curStyle) {
case style_0:
PWM_ASSERT(s0);
s0->delCategory(cat);
return;
case style_1:
PWM_ASSERT(s1);
s1->delCategory(cat);
return;
default:
BUG();
}
}
void PwMViewStyle::delAllCategories()
{
switch (curStyle) {
case style_0:
PWM_ASSERT(s0);
s0->delAllCategories();
return;
case style_1:
PWM_ASSERT(s1);
s1->delAllCategories();
return;
default:
BUG();
}
}
void PwMViewStyle::selectCategory(const QString &cat)
{
switch (curStyle) {
case style_0:
PWM_ASSERT(s0);
s0->selectCategory(cat);
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index f29ef6c..2810b48 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -1,126 +1,126 @@
/***************************************************************************
* *
* 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
+#define SERIALIZER_DEBUG 1
/* 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)
diff --git a/pwmanager/pwmanager/setmasterpwwnd_emb.cpp b/pwmanager/pwmanager/setmasterpwwnd_emb.cpp
new file mode 100644
index 0000000..e6471e6
--- a/dev/null
+++ b/pwmanager/pwmanager/setmasterpwwnd_emb.cpp
@@ -0,0 +1,163 @@
+/*
+ This file is part of PwManager/Platform independent.
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+$Id$
+*/
+
+#include "setmasterpwwnd_emb.h"
+
+#include <qpushbutton.h>
+#include <qtabwidget.h>
+#include <qwidget.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+
+#include <klocale.h>
+
+/*US
+#include <qvariant.h>
+#include <qpushbutton.h>
+#include <qtabwidget.h>
+#include <qwidget.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+*/
+
+/*
+ * Constructs a setMasterPwWnd as a child of 'parent', with the
+ * name 'name'
+ *
+ */
+setMasterPwWnd::setMasterPwWnd( QWidget* parent, const char* name )
+ : KDialogBase( KDialogBase::Plain, i18n( "Set master-password" ),
+ KDialogBase::Ok | KDialogBase::Cancel,
+ KDialogBase::Ok, parent, name, true )
+{
+ QWidget *page = plainPage();
+ QVBoxLayout *pageLayout = new QVBoxLayout( page );
+
+ mainTab = new QTabWidget( page );
+ pageLayout->addWidget( mainTab );
+
+
+ if ( !name )
+ setName( "setMasterPwWnd" );
+
+ ////////////////////////////////////////////////////////////////////
+ // This is the Password tab1
+ tab = new QWidget( mainTab );
+
+ QGridLayout *layout = new QGridLayout( tab, 5, 1 );
+ layout->setMargin( KDialogBase::marginHint() );
+ layout->setSpacing( KDialogBase::spacingHint() );
+
+ QLabel* label = new QLabel( i18n( "Using a normal password-string to encrypt the data." ), tab );
+ label->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
+ layout->addWidget(label, 0, 0);
+
+ pwEdit_1 = new QLineEdit( tab, "pwEdit_1" );
+ pwEdit_1->setEchoMode( QLineEdit::Password );
+
+ label = new QLabel( pwEdit_1, i18n( "Please enter the new master-password:" ), tab );
+ layout->addWidget(label, 1, 0);
+ layout->addWidget(pwEdit_1, 2, 0);
+
+ pwEdit_2 = new QLineEdit( tab, "pwEdit_2" );
+ pwEdit_2->setEchoMode( QLineEdit::Password );
+
+ label = new QLabel( pwEdit_2, i18n( "Please enter the password again:" ), tab );
+ layout->addWidget(label, 3, 0);
+ layout->addWidget(pwEdit_2, 4, 0);
+
+ mainTab->insertTab( tab, i18n("Normal password") );
+
+
+ ////////////////////////////////////////////////////////////////////
+ // This is the Password tab2
+ tab_2 = new QWidget( mainTab );
+
+ layout = new QGridLayout( tab_2, 5, 1 );
+ layout->setMargin( KDialogBase::marginHint() );
+ layout->setSpacing( KDialogBase::spacingHint() );
+
+ label = new QLabel( i18n( "Using a PwM key-card to encrypt the data." ), tab_2 );
+ label->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
+ layout->addWidget(label, 0, 0);
+
+ label = new QLabel( i18n( "selected card:" ), tab_2 );
+ label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+ layout->addWidget(label, 1, 0);
+
+ selCardButton = new QPushButton( i18n( "&Select the currently inserted card as key-card" ), tab_2 );
+ layout->addWidget(selCardButton, 2, 0);
+
+ genCardButton = new QPushButton( i18n( "&generate new key-card") , tab_2 );
+ layout->addWidget(genCardButton, 3, 0);
+
+ curCardIdLabel = new QLabel( QString("") , tab_2 );
+ layout->addWidget(curCardIdLabel, 4, 0);
+
+ mainTab->insertTab( tab_2, i18n("Key-card (chipcard)" ) );
+
+
+ // resize( QSize(411, 313).expandedTo(minimumSizeHint()) );
+
+ // signals and slots connections
+ // connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_slot() ) );
+ // connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_slot() ) );
+ connect( genCardButton, SIGNAL( clicked() ), this, SLOT( genCardButton_slot() ) );
+ connect( selCardButton, SIGNAL( clicked() ), this, SLOT( selCardButton_slot() ) );
+
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+setMasterPwWnd::~setMasterPwWnd()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void setMasterPwWnd::okButton_slot()
+{
+ qWarning( "setMasterPwWnd::okButton_slot(): Not implemented yet" );
+}
+
+void setMasterPwWnd::cancelButton_slot()
+{
+ qWarning( "setMasterPwWnd::cancelButton_slot(): Not implemented yet" );
+}
+
+void setMasterPwWnd::genCardButton_slot()
+{
+ qWarning( "setMasterPwWnd::genCardButton_slot(): Not implemented yet" );
+}
+
+void setMasterPwWnd::selCardButton_slot()
+{
+ qWarning( "setMasterPwWnd::selCardButton_slot(): Not implemented yet" );
+}
+
diff --git a/pwmanager/pwmanager/setmasterpwwnd_emb.h b/pwmanager/pwmanager/setmasterpwwnd_emb.h
new file mode 100644
index 0000000..c8ddec6
--- a/dev/null
+++ b/pwmanager/pwmanager/setmasterpwwnd_emb.h
@@ -0,0 +1,62 @@
+/*
+ This file is part of PwManager/Platform independent.
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+$Id$
+*/
+
+#ifndef SETMASTERPWWND_EMB_H
+#define SETMASTERPWWND_EMB_H
+
+#include <kdialogbase.h>
+
+class QLineEdit;
+class QPushButton;
+class QLabel;
+class QTabWidget;
+class QWidget;
+
+class setMasterPwWnd : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ setMasterPwWnd( QWidget* parent = 0, const char* name = 0 );
+ ~setMasterPwWnd();
+
+ QTabWidget* mainTab;
+ QWidget* tab;
+ QWidget* tab_2;
+ QLineEdit* pwEdit_1;
+ QLineEdit* pwEdit_2;
+ QPushButton* selCardButton;
+ QPushButton* genCardButton;
+ QLabel* curCardIdLabel;
+
+public slots:
+ virtual void okButton_slot();
+ virtual void cancelButton_slot();
+ virtual void genCardButton_slot();
+ virtual void selCardButton_slot();
+
+};
+
+#endif // SETMASTERPWWND_H
diff --git a/pwmanager/pwmanager/setmasterpwwndimpl.cpp b/pwmanager/pwmanager/setmasterpwwndimpl.cpp
index aac0408..3482643 100644
--- a/pwmanager/pwmanager/setmasterpwwndimpl.cpp
+++ b/pwmanager/pwmanager/setmasterpwwndimpl.cpp
@@ -1,152 +1,193 @@
/***************************************************************************
* *
* 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 "setmasterpwwndimpl.h"
#include "pwm.h"
#include "globalstuff.h"
#include <kmessagebox.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qtabwidget.h>
#include <stdio.h>
#ifdef CONFIG_KEYCARD
# include "pwmkeycard.h"
#endif
#define STRING_CARD_NONE (SetMasterPwWndImpl::string_cardNone())
SetMasterPwWndImpl::SetMasterPwWndImpl(QWidget * parent, const char *name)
: setMasterPwWnd(parent, name)
{
#ifdef CONFIG_KEYCARD
curCardIdLabel->setText(STRING_CARD_NONE);
#else // CONFIG_KEYCARD
#ifndef PWM_EMBEDDED
mainTab->removePage(mainTab->page(1));
#else
- qDebug("SetMasterPwWndImpl::SetMasterPwWndImpl has to be fixed");
+ mainTab->removePage(tab_2);
#endif
+
#endif // CONFIG_KEYCARD
keyCard = 0;
}
SetMasterPwWndImpl::~SetMasterPwWndImpl()
{
}
void SetMasterPwWndImpl::okButton_slot()
{
+#ifndef PWM_EMBEDDED
int index = mainTab->currentPageIndex();
if (index == 0) {
// normal password
if (pwEdit_1->text() != pwEdit_2->text()) {
KMessageBox::error(this,
i18n
("The two passwords you have entered don't match.\n"
"Please try entering them again."),
i18n("Different passwords"));
return;
}
if (pwEdit_1->text() == "") {
KMessageBox::error(this,
i18n("No password entered. "
"Please type in a password, that "
"you want to use for the encryption."),
i18n("no password"));
return;
}
} else {
// key-card
if (curCardIdLabel->text() == STRING_CARD_NONE) {
KMessageBox::error(this,
i18n("You didn't select a card as "
"PwM-key-card."),
i18n("no card"));
return;
}
}
done(1);
+#endif
}
void SetMasterPwWndImpl::cancelButton_slot()
{
+#ifndef PWM_EMBEDDED
done(2);
+#endif
+}
+
+void SetMasterPwWndImpl::slotOk()
+{
+ int index = mainTab->currentPageIndex();
+ if (index == 0) {
+ // normal password
+ if (pwEdit_1->text() != pwEdit_2->text()) {
+ KMessageBox::error(this,
+ i18n
+ ("The two passwords you have entered\ndon't match.\n"
+ "Please try entering them again."),
+ i18n("Different passwords"));
+ return;
}
+ if (pwEdit_1->text() == "") {
+ KMessageBox::error(this,
+ i18n("No password entered.\n"
+ "Please type in a password,\nthat "
+ "you want to use for\nthe encryption."),
+ i18n("no password"));
+ return;
+ }
+ } else {
+ // key-card
+ if (curCardIdLabel->text() == STRING_CARD_NONE) {
+ KMessageBox::error(this,
+ i18n("You didn't select a card as\n"
+ "PwM-key-card."),
+ i18n("no card"));
+ return;
+ }
+ }
+
+ setMasterPwWnd::slotOk();
+}
+
void SetMasterPwWndImpl::genCardButton_slot()
{
#ifdef CONFIG_KEYCARD
PWM_ASSERT(keyCard);
keyCard->genNewCard();
#endif // CONFIG_KEYCARD
}
void SetMasterPwWndImpl::selCardButton_slot()
{
#ifdef CONFIG_KEYCARD
PWM_ASSERT(keyCard);
connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
this, SLOT(keyAvailable_slot(uint32_t, const string &)));
keyCard->getKey();
#endif // CONFIG_KEYCARD
}
void SetMasterPwWndImpl::keyAvailable_slot(uint32_t cardId,
const string &key)
{
if (key == "")
return;
curCardKey = key;
char id_buf[(sizeof(cardId) * 2) + 2 /* "0x" */ + 1 /* NULL */];
memcpy(id_buf, "0x", 2);
sprintf(id_buf + 2, "%X", cardId);
curCardIdLabel->setText(id_buf);
}
string SetMasterPwWndImpl::getPw(bool *useCard)
{
int index = mainTab->currentPageIndex();
if (index == 0) {
// normal password
if (useCard)
*useCard = false;
PWM_ASSERT(pwEdit_1->text() == pwEdit_2->text());
return pwEdit_1->text().latin1();
} else {
#ifdef CONFIG_KEYCARD
// key-card
if (useCard)
*useCard = true;
PWM_ASSERT(curCardKey != "");
PWM_ASSERT(curCardIdLabel->text() != STRING_CARD_NONE);
return curCardKey;
#endif // CONFIG_KEYCARD
}
return "";
}
#ifndef PWM_EMBEDDED
#include "setmasterpwwndimpl.moc"
#endif
diff --git a/pwmanager/pwmanager/setmasterpwwndimpl.h b/pwmanager/pwmanager/setmasterpwwndimpl.h
index 56effc1..3203d4d 100644
--- a/pwmanager/pwmanager/setmasterpwwndimpl.h
+++ b/pwmanager/pwmanager/setmasterpwwndimpl.h
@@ -1,72 +1,80 @@
/***************************************************************************
* *
* copyright (C) 2003 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$
**************************************************************************/
#ifndef SETMASTERPWWNDIMPL_H
#define SETMASTERPWWNDIMPL_H
+#ifndef PWM_EMBEDDED
#include "setmasterpwwnd.h"
+#else
+#include "setmasterpwwnd_emb.h"
+#endif
#include <klocale.h>
#include <stdint.h>
#include <string>
using std::string;
class PwMKeyCard;
/** set master pw wnd */
class SetMasterPwWndImpl : public setMasterPwWnd
{
Q_OBJECT
public:
SetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0);
~SetMasterPwWndImpl();
static QString string_cardNone()
{ return i18n("NONE"); }
/** returns the selected pw (or the key on the card) */
string getPw(bool *useCard);
/** set pointer to the keycard-access object */
void setPwMKeyCard(PwMKeyCard *_keyCard)
{ keyCard = _keyCard; }
public slots:
/** ok button pressed */
void okButton_slot();
/** cancel button pressed */
void cancelButton_slot();
/** "generate a new card" button pressed */
void genCardButton_slot();
/** "select current card" button pressed */
void selCardButton_slot();
+#ifdef PWM_EMBEDDED
+ virtual void slotOk();
+#endif
+
protected slots:
/** key from PwMKeyCard is available */
void keyAvailable_slot(uint32_t cardId, const string &key);
protected:
/** key of currently inserted card */
string curCardKey;
/** pointer to the keycard-access object */
PwMKeyCard *keyCard;
};
#endif