-rw-r--r-- | noncore/securityplugins/pin/pin.cpp | 17 | ||||
-rw-r--r-- | noncore/securityplugins/pin/pin.h | 4 | ||||
-rw-r--r-- | noncore/securityplugins/pin/pinConfigWidget.cpp | 6 | ||||
-rw-r--r-- | noncore/securityplugins/pin/pinConfigWidget.h | 16 | ||||
-rw-r--r-- | noncore/securityplugins/pin/pinpluginimpl.cpp | 3 | ||||
-rw-r--r-- | noncore/securityplugins/pin/pinpluginimpl.h | 5 |
6 files changed, 29 insertions, 22 deletions
diff --git a/noncore/securityplugins/pin/pin.cpp b/noncore/securityplugins/pin/pin.cpp index 37dc5be..c21ffcd 100644 --- a/noncore/securityplugins/pin/pin.cpp +++ b/noncore/securityplugins/pin/pin.cpp @@ -32,26 +32,29 @@ #include <qlabel.h> #include <qlineedit.h> #include <qtextview.h> #include <qstring.h> #include <qdialog.h> /* UNIX */ #include <unistd.h> #include <stdlib.h> #include <time.h> extern "C" char *crypt(const char *key, const char *salt); +using Opie::Security::MultiauthConfigWidget; +using Opie::Security::MultiauthPluginObject; + /// set to TRUE when we press the 'Skip' button -bool isSkip = FALSE; +static bool isSkip = FALSE; /// PIN input graphical widget. /** * Inherits the PinDialogBase class defined originally in pinDialogBase.ui interface file. * \sa PinDlg and PinDialog (the class generated from the .ui file) * It comes from the original PIN locking code in Opie : * \sa http://dudu.dyn.2-h.org/opiedoxydoc/library_2password_8cpp-source.html */ class PinDialog : public PinDialogBase { Q_OBJECT @@ -223,28 +226,28 @@ bool PinPlugin::verify(const QString& pin, const QString& hash) } /// Displays a PinDialog and returns the typed in PIN /** * The returned value is QString::null if the user cancels the operation, * or the empty string if the user enters no password (but confirms the * dialog). */ QString PinPlugin::getPIN( const QString& prompt ) { PinDlg pd(0,0,TRUE); pd.pinD->setPrompt( prompt ); - + pd.showMaximized(); int r = pd.exec(); - + if ( r == QDialog::Accepted ) { if (pd.pinD->text.isEmpty()) return ""; else return pd.pinD->text; } else return QString::null; } /// Displays the PIN dialog and returns a hash of the typed in PIN /** @@ -293,50 +296,50 @@ int PinPlugin::authenticate() // reset skip (if we ran Pin two times in a row, skipping the first time, it must be put to 0 again) isSkip = FALSE; // fetch value in config Config cfg("Security"); cfg.setGroup("PinPlugin"); QString hashedPin = cfg.readEntry("hashedPIN"); if (!hashedPin.isEmpty()) { // prompt for the PIN in a fullscreen modal dialog PinDlg pd(0,0,TRUE,TRUE); pd.reset(); pd.exec(); - + // analyse the result if (isSkip == TRUE) return MultiauthPluginObject::Skip; else if (verify(pd.pinD->text, hashedPin)) return MultiauthPluginObject::Success; - else + else return MultiauthPluginObject::Failure; } owarn << "No PIN has been defined! We consider it as a successful authentication though." << oendl; return MultiauthPluginObject::Success; } /// Simply returns the plugin name (PIN plugin) QString PinPlugin::pluginName() const { return "PIN Plugin"; } QString PinPlugin::pixmapNameWidget() const { return "security/pinplugin"; } QString PinPlugin::pixmapNameConfig() const { return "security/pinplugin"; } /// returns a PinConfigWidget MultiauthConfigWidget * PinPlugin::configWidget(QWidget * parent) { PinConfigWidget * pinw = new PinConfigWidget(parent, "PIN configuration widget"); - + connect(pinw->changePIN, SIGNAL( clicked() ), this, SLOT( changePIN() )); connect(pinw->clearPIN, SIGNAL( clicked() ), this, SLOT( clearPIN() )); - + return pinw; } #include "pin.moc" diff --git a/noncore/securityplugins/pin/pin.h b/noncore/securityplugins/pin/pin.h index 6cd328a..1832210 100644 --- a/noncore/securityplugins/pin/pin.h +++ b/noncore/securityplugins/pin/pin.h @@ -34,31 +34,31 @@ #ifndef PIN_H #define PIN_H #include <qobject.h> #include <qstring.h> #include <opie2/multiauthplugininterface.h> #include "pinConfigWidget.h" /// Multi-authentication plugin, implementing a PIN verification. /** * The plugin itself, implementing the main authenticate() function. */ -class PinPlugin : public QObject, public MultiauthPluginObject { +class PinPlugin : public QObject, public Opie::Security::MultiauthPluginObject { Q_OBJECT public: int authenticate(); - MultiauthConfigWidget * configWidget(QWidget * parent); + Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent); QString pixmapNameConfig() const; QString pixmapNameWidget() const; QString pluginName() const; private slots: QString getPIN( const QString& prompt ); QString getCryptedPIN( const QString& prompt ); void changePIN(); void clearPIN(); private: QString encrypt(const QString& pin); diff --git a/noncore/securityplugins/pin/pinConfigWidget.cpp b/noncore/securityplugins/pin/pinConfigWidget.cpp index 53e1a20..b34db8b 100644 --- a/noncore/securityplugins/pin/pinConfigWidget.cpp +++ b/noncore/securityplugins/pin/pinConfigWidget.cpp @@ -1,39 +1,41 @@ #include <qwidget.h> #include <qlayout.h> #include <qlabel.h> #include <qgroupbox.h> #include "pinConfigWidget.h" +using Opie::Security::MultiauthConfigWidget; + PinConfigWidget::PinConfigWidget(QWidget* parent = 0, const char* name = "PIN configuration widget") : MultiauthConfigWidget(parent, name) { QVBoxLayout * baseLayout = new QVBoxLayout( this); baseLayout->setSpacing(11); baseLayout->setMargin(11); baseLayout->setAlignment( Qt::AlignTop ); - + QGroupBox * configBox = new QGroupBox(0, Qt::Vertical, tr("Configure your PIN here"), this); baseLayout->addWidget(configBox); QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() ); QLabel * description = new QLabel("<p>" + tr("PIN protection provides a minimal level of protection from casual access to this device.") + "</p>", configBox); boxLayout->addWidget(description); QHBoxLayout * buttonLayout = new QHBoxLayout(); buttonLayout->setSpacing(6); changePIN = new QPushButton( tr("Change PIN"), configBox, "changePIN" ); clearPIN = new QPushButton( tr("Clear PIN"), configBox, "clearPIN" ); buttonLayout->addWidget(changePIN); buttonLayout->addWidget(clearPIN); boxLayout->addLayout(buttonLayout); - + } /// nothing to do PinConfigWidget::~PinConfigWidget() {} /// does nothing since the config file update is already done in changePIN or clearPIN void PinConfigWidget::writeConfig() {} diff --git a/noncore/securityplugins/pin/pinConfigWidget.h b/noncore/securityplugins/pin/pinConfigWidget.h index 3242ad0..6d5edff 100644 --- a/noncore/securityplugins/pin/pinConfigWidget.h +++ b/noncore/securityplugins/pin/pinConfigWidget.h @@ -1,51 +1,51 @@ /** * \file pinConfigWidget.h * \brief PIN plugin configuration widget * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) */ /* =. This file is part of the Opie Project .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> .>+-= - _;:, .> :=|. This library is free software; you can + _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This library is distributed in the hope that + .%`+i> _;_. + .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. - : = ...= . :.=- + : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. + -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef PINCONFIGWIDGET_H #define PINCONFIGWIDGET_H #include <qpushbutton.h> #include <opie2/multiauthconfigwidget.h> -class PinConfigWidget : public MultiauthConfigWidget { +class PinConfigWidget : public Opie::Security::MultiauthConfigWidget { public: PinConfigWidget(QWidget* parent, const char* name); virtual ~PinConfigWidget(); virtual void writeConfig(); ///\todo to protect? QPushButton *changePIN; - QPushButton *clearPIN; - + QPushButton *clearPIN; + }; #endif // PINCONFIGWIDGET_H diff --git a/noncore/securityplugins/pin/pinpluginimpl.cpp b/noncore/securityplugins/pin/pinpluginimpl.cpp index 1c32f81..6cd2467 100644 --- a/noncore/securityplugins/pin/pinpluginimpl.cpp +++ b/noncore/securityplugins/pin/pinpluginimpl.cpp @@ -1,14 +1,17 @@ #include "pinpluginimpl.h" +using Opie::Security::MultiauthPluginObject; +using Opie::Security::MultiauthPluginInterface; + PinPluginImpl::PinPluginImpl() { pinPlugin = new PinPlugin(); } PinPluginImpl::~PinPluginImpl() { delete pinPlugin; } MultiauthPluginObject* PinPluginImpl::plugin() { return pinPlugin; } diff --git a/noncore/securityplugins/pin/pinpluginimpl.h b/noncore/securityplugins/pin/pinpluginimpl.h index e604b64..cbb9ef0 100644 --- a/noncore/securityplugins/pin/pinpluginimpl.h +++ b/noncore/securityplugins/pin/pinpluginimpl.h @@ -28,31 +28,30 @@ If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef PIN_PLUGIN_IMPL_H #define PIN_PLUGIN_IMPL_H #include "pin.h" /// Standard multiauth plugin class -class PinPluginImpl : public MultiauthPluginInterface{ +class PinPluginImpl : public Opie::Security::MultiauthPluginInterface{ public: PinPluginImpl(); virtual ~PinPluginImpl(); QRESULT queryInterface( const QUuid &, QUnknownInterface** ); // defines standard addRef() and release() functions Q_REFCOUNT; - virtual MultiauthPluginObject *plugin(); + virtual Opie::Security::MultiauthPluginObject *plugin(); private: /// the plugin itself PinPlugin *pinPlugin; - ulong ref; }; #endif |