summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/securityplugins/blueping/bluepingplugin.cpp3
-rw-r--r--noncore/securityplugins/blueping/bluepingplugin.h4
-rw-r--r--noncore/securityplugins/blueping/bluepingpluginimpl.cpp3
-rw-r--r--noncore/securityplugins/blueping/bluepingpluginimpl.h5
-rw-r--r--noncore/securityplugins/dummy/dummyplugin.cpp3
-rw-r--r--noncore/securityplugins/dummy/dummyplugin.h4
-rw-r--r--noncore/securityplugins/dummy/dummypluginimpl.cpp3
-rw-r--r--noncore/securityplugins/dummy/dummypluginimpl.h5
-rw-r--r--noncore/securityplugins/notice/noticeConfigWidget.cpp2
-rw-r--r--noncore/securityplugins/notice/noticeConfigWidget.h3
-rw-r--r--noncore/securityplugins/notice/noticeplugin.cpp2
-rw-r--r--noncore/securityplugins/notice/noticeplugin.h4
-rw-r--r--noncore/securityplugins/notice/noticepluginimpl.cpp3
-rw-r--r--noncore/securityplugins/notice/noticepluginimpl.h5
-rw-r--r--noncore/securityplugins/pin/pin.cpp5
-rw-r--r--noncore/securityplugins/pin/pin.h4
-rw-r--r--noncore/securityplugins/pin/pinConfigWidget.cpp2
-rw-r--r--noncore/securityplugins/pin/pinConfigWidget.h2
-rw-r--r--noncore/securityplugins/pin/pinpluginimpl.cpp3
-rw-r--r--noncore/securityplugins/pin/pinpluginimpl.h5
20 files changed, 47 insertions, 23 deletions
diff --git a/noncore/securityplugins/blueping/bluepingplugin.cpp b/noncore/securityplugins/blueping/bluepingplugin.cpp
index af0448b..f4c5e95 100644
--- a/noncore/securityplugins/blueping/bluepingplugin.cpp
+++ b/noncore/securityplugins/blueping/bluepingplugin.cpp
@@ -1,198 +1,201 @@
#include "bluepingplugin.h"
#include <opie2/oapplication.h>
#include <opie2/odebug.h>
#include <opie2/odevice.h>
#include <qdialog.h>
#include <qlayout.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qtimer.h>
using namespace Opie::Core;
+using Opie::Security::MultiauthPluginObject;
+using Opie::Security::MultiauthConfigWidget;
+
/// creates and initializes the m_config Config object
BluepingPlugin::BluepingPlugin() : MultiauthPluginObject(), m_ping(0) {
m_config = new Config("Security");
m_config->setGroup("BluepingPlugin");
bluetoothAlreadyRestarted = false;
}
/// deletes the m_config Config object and noticeW if necessary
BluepingPlugin::~BluepingPlugin() {
delete m_config;
if (m_ping != 0)
delete m_ping;
}
/// Simply return its name (Blueping plugin)
QString BluepingPlugin::pluginName() const {
return "Blueping plugin";
}
/// no configuration widget for the moment
MultiauthConfigWidget * BluepingPlugin::configWidget(QWidget * parent) {
return 0l;
}
QString BluepingPlugin::pixmapNameWidget() const {
return "security/bluepingplugin";
}
QString BluepingPlugin::pixmapNameConfig() const {
return 0l;
}
/// Emit the MultiauthPluginObject::Success emitCode
void BluepingPlugin::success() {
emit emitCode(MultiauthPluginObject::Success);
}
/// Emit the MultiauthPluginObject::Failure emitCode
void BluepingPlugin::failure() {
emit emitCode(MultiauthPluginObject::Failure);
}
/// Emit the MultiauthPluginObject::Skip emitCode
void BluepingPlugin::skip() {
emit emitCode(MultiauthPluginObject::Skip);
}
/// do the actual ping
void BluepingPlugin::ping() {
m_ping = new OProcess();
odebug << "pinging device: " << macToPing << oendl;
*m_ping << "l2ping" << "-c 1" << macToPing;
// starting to ping in the background
/// \todo as soon as ping is launched, check RSSI (signal strength) and check
/// it's high enough, meaning the device is close enough?
/// \todo make it optionally pollable, so don't finish the ping and call
/// Opie suspend if l2ping timeouts?
if ( !m_ping->start() ) {
oerr << "could not start l2ping" << oendl;
this->skip();
}
QObject::connect(m_ping, SIGNAL(processExited(Opie::Core::OProcess*)),
this, SLOT(pingFinished(Opie::Core::OProcess*)) );
}
/// Deals with m_ping result
void BluepingPlugin::pingFinished(OProcess * ping) {
if ( ping->normalExit() && (ping->exitStatus() == 0) )
{
odebug << "Successful Bluetooth ping!" << oendl;
success();
}
else
{
odebug << "Failed Bluetooth ping..." << oendl;
failure();
}
}
/// Make one authentication attempt with this plugin
/**
* (very simple "success" / "failure" buttons in a dialog)
* \return The outcome code of this authentication
*/
int BluepingPlugin::authenticate() {
Config cfg("Security");
cfg.setGroup("BluepingPlugin");
macToPing = cfg.readEntry("mac");
if (!macToPing.isEmpty())
{
/* Standard, inescapable authentication dialog
*/
QDialog bluepingDialog(0,
"Blueping dialog",
TRUE,
Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop);
QRect desk = oApp->desktop()->geometry();
bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() );
// Creation of the particular widgets of our Blueping user interface
QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog);
layout->setSpacing(11);
layout->setMargin(11);
layout->setAlignment( Qt::AlignTop );
QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog);
QLabel subTitle("<center><h2>Trying to reach your configured bluetooth device...</h2></center>", &bluepingDialog);
QLabel subTitle2("<center>You can skip this step and use another authentication way with the following button</center>", &bluepingDialog);
QPushButton pbSkip("Skip", &bluepingDialog);
layout->addWidget(&title);
layout->addWidget(&subTitle);
layout->addWidget(&subTitle2);
layout->addWidget(&pbSkip, 0, Qt::AlignHCenter);
// connect the skip button to the skip signal emitting function
QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip()));
// connect the signal emitting functions to the bluepingDialog done(int) finishing function
QObject::connect(this, SIGNAL(emitCode(int)), &bluepingDialog, SLOT(done(int)));
if (!bluetoothAlreadyRestarted)
{
// we have just started or resumed the device, so Bluetooth has to be (re)started
OProcess killB;
killB << "killall" << "hciattach";
odebug << "killing Bluetooth..." << oendl;
if ( !killB.start(OProcess::Block) ) {
oerr << "could not kill bluetooth" << oendl;
}
OProcess startB;
switch ( ODevice::inst()->model() ) {
case Model_iPAQ_H39xx:
startB << "/sbin/hciattach" << "/dev/tts/1" << "bcsp" << "921600";
break;
case Model_iPAQ_H5xxx:
startB << "/sbin/hciattach" << "/dev/tts/1" << "any" << "921600";
break;
default:
startB << "/sbin/hciattach" << "/dev/ttySB0" << "bcsp" << "230400";
break;
} // end switch on device models
if ( !startB.start(OProcess::Block) ) {
oerr << "could not (re)start bluetooth" << oendl;
return MultiauthPluginObject::Skip;
}
else
{
if ( startB.normalExit() && (startB.exitStatus() == 0) )
{
odebug << "hciattach exited normally."<< oendl;
bluetoothAlreadyRestarted = true;
// 500 ms timer, so l2ping won't try to find a route before bluetooth has \em really started
QTimer::singleShot( 500, this, SLOT(ping()) );
}
else
{
owarn << "hciattach exited anormally (error code: " << startB.exitStatus() << ")" << oendl;
} // end if startBluetooth exit status == 0
} // end if startBluetooth started
}
else
{
// we don't need to wait, since bluetooth has been started long enough ago
ping();
} // end if bluetooth not restarted
// start the dialog event loop, while the ping is starting (or will start soon) in the background
return bluepingDialog.exec();
}
else
{
owarn << "No Bluetooth device has been set!" << oendl;
owarn << "We will consider it as a successful authentication though." << oendl;
return MultiauthPluginObject::Success;
} // end if mac defined
}
diff --git a/noncore/securityplugins/blueping/bluepingplugin.h b/noncore/securityplugins/blueping/bluepingplugin.h
index c122471..0df3f78 100644
--- a/noncore/securityplugins/blueping/bluepingplugin.h
+++ b/noncore/securityplugins/blueping/bluepingplugin.h
@@ -1,81 +1,81 @@
/**
* \file bluepingplugin.h
* \brief Standard Opie multiauth plugin definition
* \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
.> <`_, > . <= 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
+ . -:. = 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.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef BLUEPING_PLUGIN_H
#define BLUEPING_PLUGIN_H
#include <opie2/multiauthplugininterface.h>
#include <opie2/oprocess.h>
#include <qobject.h>
#include <qstring.h>
#include <qpe/config.h>
/// Multi-authentication bluetooth plugin, which tries to ping a specific MAC address.
/**
* The plugin itself, implementing the main authenticate() function.
*/
-class BluepingPlugin : public QObject, public MultiauthPluginObject {
+class BluepingPlugin : public QObject, public Opie::Security::MultiauthPluginObject {
Q_OBJECT
public:
BluepingPlugin();
virtual ~BluepingPlugin();
int authenticate();
- MultiauthConfigWidget * configWidget(QWidget * parent);
+ Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent);
QString pixmapNameConfig() const;
QString pixmapNameWidget() const;
QString pluginName() const;
signals:
/// Signal carrying the result code of this plugin
void emitCode(int resultCode);
private slots:
void success();
void failure();
void skip();
void ping();
void pingFinished(Opie::Core::OProcess * ping);
private:
Opie::Core::OProcess *m_ping;
Config * m_config;
bool bluetoothAlreadyRestarted;
QString macToPing;
};
#endif
diff --git a/noncore/securityplugins/blueping/bluepingpluginimpl.cpp b/noncore/securityplugins/blueping/bluepingpluginimpl.cpp
index f7b1bfc..dbca91f 100644
--- a/noncore/securityplugins/blueping/bluepingpluginimpl.cpp
+++ b/noncore/securityplugins/blueping/bluepingpluginimpl.cpp
@@ -1,28 +1,31 @@
#include "bluepingpluginimpl.h"
+using Opie::Security::MultiauthPluginInterface;
+using Opie::Security::MultiauthPluginObject;
+
BluepingPluginImpl::BluepingPluginImpl() {
bluepingPlugin = new BluepingPlugin();
}
BluepingPluginImpl::~BluepingPluginImpl() {
delete bluepingPlugin;
}
MultiauthPluginObject* BluepingPluginImpl::plugin() {
return bluepingPlugin;
}
Q_EXPORT_INTERFACE() {
Q_CREATE_INSTANCE( BluepingPluginImpl )
}
QRESULT BluepingPluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) {
*iface = 0;
if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MultiauthPluginInterface ) ) {
*iface = this, (*iface)->addRef();
} else {
return QE_NOINTERFACE;
}
return QS_OK;
}
diff --git a/noncore/securityplugins/blueping/bluepingpluginimpl.h b/noncore/securityplugins/blueping/bluepingpluginimpl.h
index 2fd023a..4663602 100644
--- a/noncore/securityplugins/blueping/bluepingpluginimpl.h
+++ b/noncore/securityplugins/blueping/bluepingpluginimpl.h
@@ -1,58 +1,57 @@
/**
* \file bluepingpluginimpl.h
* \brief Standard Opie multiauth plugin interface definition
* \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
.> <`_, > . <= 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
+ . -:. = 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.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef BLUEPING_PLUGIN_IMPL_H
#define BLUEPING_PLUGIN_IMPL_H
#include "bluepingplugin.h"
/// Standard multiauth plugin class
-class BluepingPluginImpl : public MultiauthPluginInterface{
+class BluepingPluginImpl : public Opie::Security::MultiauthPluginInterface{
public:
BluepingPluginImpl();
virtual ~BluepingPluginImpl();
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
BluepingPlugin *bluepingPlugin;
- ulong ref;
};
#endif
diff --git a/noncore/securityplugins/dummy/dummyplugin.cpp b/noncore/securityplugins/dummy/dummyplugin.cpp
index 0d19e43..594825e 100644
--- a/noncore/securityplugins/dummy/dummyplugin.cpp
+++ b/noncore/securityplugins/dummy/dummyplugin.cpp
@@ -1,92 +1,95 @@
#include "dummyplugin.h"
#include <opie2/oapplication.h>
#include <qdialog.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qpushbutton.h>
+using Opie::Security::MultiauthConfigWidget;
+using Opie::Security::MultiauthPluginObject;
+
/// Simply return its name (Dummy plugin)
QString DummyPlugin::pluginName() const {
return "Dummy plugin";
}
/// no configuration widget for the moment
MultiauthConfigWidget * DummyPlugin::configWidget(QWidget * parent) {
return 0l;
}
QString DummyPlugin::pixmapNameWidget() const {
return "security/dummyplugin";
}
QString DummyPlugin::pixmapNameConfig() const {
return 0l;
}
/// Emit the MultiauthPluginObject::Success emitCode
void DummyPlugin::success() {
emit emitCode(MultiauthPluginObject::Success);
}
/// Emit the MultiauthPluginObject::Failure emitCode
void DummyPlugin::failure() {
emit emitCode(MultiauthPluginObject::Failure);
}
/// Emit the MultiauthPluginObject::Skip emitCode
void DummyPlugin::skip() {
emit emitCode(MultiauthPluginObject::Skip);
}
/// Make one authentication attempt with this plugin
/**
* (very simple "success" / "failure" buttons in a dialog)
* \return The outcome code of this authentication
*/
int DummyPlugin::authenticate() {
/* Standard, inescapable authentication dialog
*/
QDialog dummyDialog(0,
"Dummy dialog",
TRUE,
Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop);
QRect desk = oApp->desktop()->geometry();
dummyDialog.setGeometry( 0, 0, desk.width(), desk.height() );
/* Creation of the particular widgets of our Dummy user interface
* Note: we have to resize the VBox to the QDialog size, since it's not
* done automatically.
*/
QVBoxLayout layout(&dummyDialog);
layout.setSpacing(11);
layout.setMargin(11);
layout.setAlignment( Qt::AlignTop );
QLabel title("<center><h1>" + tr("\"Dummy\" <br />demonstration plugin") + "</h1></center>", &dummyDialog);
QLabel subTitle("<center><h2>" +tr("You can simulate the following outcomes:") + "</h2></center>", &dummyDialog);
layout.addWidget(&title);
layout.addWidget(&subTitle);
QHBoxLayout hl(&layout);
QPushButton pbSuccess("Success", &dummyDialog);
QPushButton pbSkip("Skip", &dummyDialog);
QPushButton pbFailure("Failure", &dummyDialog);
hl.addWidget(&pbSuccess, 0, Qt::AlignHCenter);
hl.addWidget(&pbSkip, 0, Qt::AlignHCenter);
hl.addWidget(&pbFailure, 0, Qt::AlignHCenter);
/* Linking our pushbuttons to exit functions
* (each result button here has a corresponding slot)
*/
QObject::connect(&pbSuccess, SIGNAL(clicked()), this, SLOT(success()));
QObject::connect(&pbFailure, SIGNAL(clicked()), this, SLOT(failure()));
QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip()));
/* The value of the signal these three slots will emit corresponds to
* the different values we want to return
*/
QObject::connect(this, SIGNAL(emitCode(int)), &dummyDialog, SLOT(done(int)));
return dummyDialog.exec();
}
diff --git a/noncore/securityplugins/dummy/dummyplugin.h b/noncore/securityplugins/dummy/dummyplugin.h
index 9680dff..3bfca98 100644
--- a/noncore/securityplugins/dummy/dummyplugin.h
+++ b/noncore/securityplugins/dummy/dummyplugin.h
@@ -1,66 +1,66 @@
/**
* \file dummyplugin.h
* \brief Standard Opie multiauth plugin definition
* \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
.> <`_, > . <= 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
+ . -:. = 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.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef DUMMY_PLUGIN_H
#define DUMMY_PLUGIN_H
#include <qobject.h>
#include <qstring.h>
#include <opie2/multiauthplugininterface.h>
/// Multi-authentication example plugin, implementing a trivial 'yes/no' verification.
/**
* The plugin itself, implementing the main authenticate() function.
*/
-class DummyPlugin : public QObject, public MultiauthPluginObject {
+class DummyPlugin : 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;
signals:
/// Signal carrying the result code of this plugin
void emitCode(int resultCode);
private slots:
void success();
void failure();
void skip();
};
#endif
diff --git a/noncore/securityplugins/dummy/dummypluginimpl.cpp b/noncore/securityplugins/dummy/dummypluginimpl.cpp
index 518996c..54dbdd1 100644
--- a/noncore/securityplugins/dummy/dummypluginimpl.cpp
+++ b/noncore/securityplugins/dummy/dummypluginimpl.cpp
@@ -1,28 +1,31 @@
#include "dummypluginimpl.h"
+using Opie::Security::MultiauthPluginInterface;
+using Opie::Security::MultiauthPluginObject;
+
DummyPluginImpl::DummyPluginImpl() {
dummyPlugin = new DummyPlugin();
}
DummyPluginImpl::~DummyPluginImpl() {
delete dummyPlugin;
}
MultiauthPluginObject* DummyPluginImpl::plugin() {
return dummyPlugin;
}
Q_EXPORT_INTERFACE() {
Q_CREATE_INSTANCE( DummyPluginImpl )
}
QRESULT DummyPluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) {
*iface = 0;
if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MultiauthPluginInterface ) ) {
*iface = this, (*iface)->addRef();
} else {
return QE_NOINTERFACE;
}
return QS_OK;
}
diff --git a/noncore/securityplugins/dummy/dummypluginimpl.h b/noncore/securityplugins/dummy/dummypluginimpl.h
index 49a18cd..ce8620d 100644
--- a/noncore/securityplugins/dummy/dummypluginimpl.h
+++ b/noncore/securityplugins/dummy/dummypluginimpl.h
@@ -1,58 +1,57 @@
/**
* \file dummypluginimpl.h
* \brief Standard Opie multiauth plugin interface definition
* \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
.> <`_, > . <= 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
+ . -:. = 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.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef DUMMY_PLUGIN_IMPL_H
#define DUMMY_PLUGIN_IMPL_H
#include "dummyplugin.h"
/// Standard multiauth plugin class
-class DummyPluginImpl : public MultiauthPluginInterface{
+class DummyPluginImpl : public Opie::Security::MultiauthPluginInterface{
public:
DummyPluginImpl();
virtual ~DummyPluginImpl();
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
DummyPlugin *dummyPlugin;
- ulong ref;
};
#endif
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.cpp b/noncore/securityplugins/notice/noticeConfigWidget.cpp
index e2c2d83..e532232 100644
--- a/noncore/securityplugins/notice/noticeConfigWidget.cpp
+++ b/noncore/securityplugins/notice/noticeConfigWidget.cpp
@@ -1,81 +1,83 @@
#include "noticeConfigWidget.h"
#include <opie2/odebug.h>
#include <qwidget.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qregexp.h>
#include <qgroupbox.h>
+using Opie::Security::MultiauthConfigWidget;
+
/// constructs the widget, filling the noticeMLE QMultiLineEdit with the "noticeText" entry
NoticeConfigWidget::NoticeConfigWidget(QWidget* parent = 0, const char* name = "Notice configuration widget") : MultiauthConfigWidget(parent, name)
{
QVBoxLayout *baseLayout = new QVBoxLayout( this);
baseLayout->setSpacing(11);
baseLayout->setMargin(6);
baseLayout->setAlignment( Qt::AlignTop );
QGroupBox *configBox = new QGroupBox(0, Qt::Vertical, tr("Set the message the user must accept"), this);
baseLayout->addWidget(configBox);
QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() );
QLabel * comment1 = new QLabel("<p><em>" + tr("You may want to consult your legal department for proper wording here.") + "</em></p>", configBox);
boxLayout->addWidget(comment1);
// Set the multilineedit box text to getNoticeText()
noticeMLE = new QMultiLineEdit(configBox, "notice text");
noticeMLE->setWordWrap(QMultiLineEdit::WidgetWidth);
noticeMLE->setFocus();
noticeMLE->setText(getNoticeText());
boxLayout->addWidget(noticeMLE);
resetNoticeButton = new QPushButton( tr("Reset notice to default"), configBox, "reset Notice Button" );
connect(resetNoticeButton, SIGNAL( clicked() ), this, SLOT( resetNotice() ));
boxLayout->addWidget(resetNoticeButton, 0, Qt::AlignHCenter);
QLabel * comment2 = new QLabel("<p>" + tr("Note: you can use HTML tags to improve its layout (example: text between &lt;em&gt; and &lt;/em&gt; will be <em>emphasized</em>)") + "</p>", configBox);
boxLayout->addWidget(comment2);
}
/// nothing to do
NoticeConfigWidget::~NoticeConfigWidget()
{}
/// write the notice text in the multiauth.conf Config file
void NoticeConfigWidget::writeConfig()
{
if ( noticeMLE->edited() ) {
odebug << "writing new notice text in Security.conf" << oendl;
setNoticeText(noticeMLE->text());
}
}
/// reset the notice text to the hard-coded example defaultNoticeText
void NoticeConfigWidget::resetNotice()
{
noticeMLE->setText(defaultNoticeText);
}
/// get the notice text from the config file (with true new lines)
/**
* if no text has been defined yet returns defaultNoticeText
*/
QString NoticeConfigWidget::getNoticeText() {
m_config = new Config("Security");
m_config->setGroup("NoticePlugin");
// Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
QString noticeText = m_config->readEntry("noticeText", defaultNoticeText).replace( QRegExp("\\\\n"), "\n" );
delete m_config;
return noticeText;
}
/// set the notice text in our m_config config file (escaping new lines)
void NoticeConfigWidget::setNoticeText(QString noticeText) {
m_config = new Config("Security");
m_config->setGroup("NoticePlugin");
// since Config files do not allow true newlines, we replace them with litteral "\n"
m_config->writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" ));
delete m_config;
}
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.h b/noncore/securityplugins/notice/noticeConfigWidget.h
index 69f15bf..c90484c 100644
--- a/noncore/securityplugins/notice/noticeConfigWidget.h
+++ b/noncore/securityplugins/notice/noticeConfigWidget.h
@@ -1,71 +1,72 @@
/**
* \file noticeConfigWidget.h
* \brief Notice 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
.> <`_, > . <= 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
+ . -:. = 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.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef NOTICECONFIGWIDGET_H
#define NOTICECONFIGWIDGET_H
#include <qpushbutton.h>
#include <qmultilineedit.h>
#include <qpe/config.h>
#include <opie2/multiauthconfigwidget.h>
static char defaultNoticeText [] = "<h2>NOTICE TO USERS</h2>\n"
"<p>This is a private computer system and is the property of "
"the company XXX / Mr or Ms X. It is for authorized "
"use only. Users have no expectation of privacy.</p>\n"
"<p><strong>Unauthorized or improper use of this system may result in "
"disciplinary action and civil and criminal penalties. <em>By continuing to use "
"this system you indicate your awareness of and consent to these "
"terms. LOG OFF IMMEDIATELY if you do not agree to them.</em></strong></p>";
-class NoticeConfigWidget : public MultiauthConfigWidget {
+class NoticeConfigWidget : public Opie::Security::MultiauthConfigWidget {
Q_OBJECT
public:
NoticeConfigWidget(QWidget* parent, const char* name);
virtual ~NoticeConfigWidget();
virtual void writeConfig();
private:
QMultiLineEdit * noticeMLE;
QPushButton * resetNoticeButton;
private slots:
void resetNotice();
private:
Config * m_config;
QString getNoticeText();
void setNoticeText(QString noticeText);
};
#endif // NOTICECONFIGWIDGET_H
+
diff --git a/noncore/securityplugins/notice/noticeplugin.cpp b/noncore/securityplugins/notice/noticeplugin.cpp
index bacc439..25a452a 100644
--- a/noncore/securityplugins/notice/noticeplugin.cpp
+++ b/noncore/securityplugins/notice/noticeplugin.cpp
@@ -1,84 +1,86 @@
#include "noticeplugin.h"
#include <opie2/oapplication.h>
#include <qmessagebox.h>
#include <qregexp.h>
+using Opie::Security::MultiauthPluginObject;
+using Opie::Security::MultiauthConfigWidget;
/// creates and initializes the m_config Config object
NoticePlugin::NoticePlugin() : MultiauthPluginObject(), noticeW(0) {
m_config = new Config("Security");
m_config->setGroup("NoticePlugin");
}
/// deletes the m_config Config object and noticeW if necessary
NoticePlugin::~NoticePlugin() {
delete m_config;
if (noticeW != 0)
delete noticeW;
}
/// Simply return its name (Notice plugin)
QString NoticePlugin::pluginName() const {
return "Notice plugin";
}
/// return the Notice widget configuration widget
/**
* \return noticeW, the NoticeConfigWidget
*/
MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) {
if (noticeW == 0)
noticeW = new NoticeConfigWidget(parent, "Notice configuration widget");
return noticeW;
}
/// return the path of the small tab icon
QString NoticePlugin::pixmapNameConfig() const {
return "security/noticeplugin_small";
}
/// return the path of the big icon for the active/order checklist
QString NoticePlugin::pixmapNameWidget() const {
return "security/noticeplugin";
}
/// Displays the configured message and an 'Accept' button
/**
* \return the outcome code of this authentication (can be only success)
*/
int NoticePlugin::authenticate() {
QMessageBox noticeDialog("Notice plugin",
getNoticeText(),
QMessageBox::Warning,
QMessageBox::Yes,
0,
0,
0,
"notice plugin dialog",
true,
Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop);
noticeDialog.setButtonText(QMessageBox::Yes, tr("I accept"));
QRect desk = oApp->desktop()->geometry();
noticeDialog.setGeometry( 0, 0, desk.width(), desk.height() );
switch (noticeDialog.exec())
{
case QMessageBox::Yes:
return MultiauthPluginObject::Success;
}
return 255; //should not be returned anyway
}
/// get the notice text from our m_config config file (with true new lines)
/**
* if no text has been defined yet returns defaultNoticeText
*/
QString NoticePlugin::getNoticeText() {
// Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
return m_config->readEntry("noticeText", defaultNoticeText).replace( QRegExp("\\\\n"), "\n" );
}
diff --git a/noncore/securityplugins/notice/noticeplugin.h b/noncore/securityplugins/notice/noticeplugin.h
index 842d47b..4aa6f02 100644
--- a/noncore/securityplugins/notice/noticeplugin.h
+++ b/noncore/securityplugins/notice/noticeplugin.h
@@ -1,64 +1,64 @@
/**
* \file noticeplugin.h
* \brief Standard Opie multiauth plugin definition
* \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
.> <`_, > . <= 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
+ . -:. = 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.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef NOTICE_PLUGIN_H
#define NOTICE_PLUGIN_H
#include <qstring.h>
#include <qpe/config.h>
#include <opie2/multiauthplugininterface.h>
#include "noticeConfigWidget.h"
/// Multi-authentication plugin, having the user accept a (legal, etc.) notice text.
/**
* The plugin itself, implementing the main authenticate() function.
*/
-class NoticePlugin : public QObject, public MultiauthPluginObject {
+class NoticePlugin : public QObject, public Opie::Security::MultiauthPluginObject {
Q_OBJECT;
public:
NoticePlugin();
virtual ~NoticePlugin();
int authenticate();
- MultiauthConfigWidget * configWidget(QWidget * parent);
+ Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent);
QString pixmapNameConfig() const;
QString pixmapNameWidget() const;
QString pluginName() const;
private:
NoticeConfigWidget * noticeW;
Config * m_config;
QString getNoticeText();
};
#endif
diff --git a/noncore/securityplugins/notice/noticepluginimpl.cpp b/noncore/securityplugins/notice/noticepluginimpl.cpp
index 34e3cfc..7524512 100644
--- a/noncore/securityplugins/notice/noticepluginimpl.cpp
+++ b/noncore/securityplugins/notice/noticepluginimpl.cpp
@@ -1,28 +1,31 @@
#include "noticepluginimpl.h"
+using Opie::Security::MultiauthPluginObject;
+using Opie::Security::MultiauthPluginInterface;
+
NoticePluginImpl::NoticePluginImpl() {
noticePlugin = new NoticePlugin();
}
NoticePluginImpl::~NoticePluginImpl() {
delete noticePlugin;
}
MultiauthPluginObject* NoticePluginImpl::plugin() {
return noticePlugin;
}
Q_EXPORT_INTERFACE() {
Q_CREATE_INSTANCE( NoticePluginImpl )
}
QRESULT NoticePluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) {
*iface = 0;
if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MultiauthPluginInterface ) ) {
*iface = this, (*iface)->addRef();
} else {
return QE_NOINTERFACE;
}
return QS_OK;
}
diff --git a/noncore/securityplugins/notice/noticepluginimpl.h b/noncore/securityplugins/notice/noticepluginimpl.h
index b2a1140..1b1e22f 100644
--- a/noncore/securityplugins/notice/noticepluginimpl.h
+++ b/noncore/securityplugins/notice/noticepluginimpl.h
@@ -1,61 +1,60 @@
/**
* \file noticepluginimpl.h
* \brief Standard Opie multiauth plugin definition
* \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
.> <`_, > . <= 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
+ . -:. = 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.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef NOTICE_PLUGIN_IMPL
#define NOTICE_PLUGIN_IMPL
#include "noticeplugin.h"
/**
* \brief Standard multiauth plugin class
*/
-class NoticePluginImpl : public MultiauthPluginInterface{
+class NoticePluginImpl : public Opie::Security::MultiauthPluginInterface{
public:
NoticePluginImpl();
virtual ~NoticePluginImpl();
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
NoticePlugin *noticePlugin;
- ulong ref;
};
#endif
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
@@ -1,342 +1,345 @@
/**
* \note Taken from opie-security and libqpe password.cpp, and modified for Opie multiauth by Clement Seveillac
*/
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "pin.h"
#include "pinDialogBase.h"
#include "pinConfigWidget.h"
/* OPIE */
#include <opie2/odebug.h>
#include <opie2/oapplication.h>
/* QT */
#include <qpe/config.h>
#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
public:
PinDialog( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~PinDialog();
void clear();
void setPrompt( const QString& );
signals:
/// emitted when we press the Enter button
void passwordEntered( const QString& );
/// emitted when we press the Skip button
void skip();
protected:
bool eventFilter( QObject*, QEvent* );
private:
void input( QString );
friend class PinPlugin;
QString text;
};
/// Constructs a PinDialog widget, and initializes things
PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl )
: PinDialogBase( parent, name, fl )
{
QRect desk = oApp->desktop()->geometry();
if ( desk.width() < 220 ) {
QFont f( font() );
f.setPointSize( 18 );
setFont( f );
f.setPointSize( 12 );
prompt->setFont( f );
}
button_0->installEventFilter( this );
button_1->installEventFilter( this );
button_2->installEventFilter( this );
button_3->installEventFilter( this );
button_4->installEventFilter( this );
button_5->installEventFilter( this );
button_6->installEventFilter( this );
button_7->installEventFilter( this );
button_8->installEventFilter( this );
button_9->installEventFilter( this );
button_Skip->installEventFilter( this );
button_OK->installEventFilter( this );
setFocus();
}
/// nothing to do
PinDialog::~PinDialog()
{
// no need to delete child widgets, Qt does it all for us
}
/// Record the pressed numbers, and the Skip and Enter commands
bool PinDialog::eventFilter( QObject*o, QEvent*e )
{
if ( e->type() == QEvent::MouseButtonRelease ) {
if ( o == button_OK ) {
emit passwordEntered( text );
}
else if ( o == button_Skip ) {
isSkip = TRUE;
emit skip();
}
else {
QLabel *l = (QLabel*)o;
input(l->text());
}
}
return FALSE;
}
void PinDialog::input( QString c )
{
text += c;
display->setText( text );
}
void PinDialog::setPrompt( const QString& s )
{
prompt->setText( s );
}
void PinDialog::clear()
{
text = "";
input("");
}
/// PIN dialog
/**
* Dialog containing the PinDialog widget (which asks for a PIN) and interfacing with its I/O.
* \sa PinDialog
*/
class PinDlg : public QDialog
{
public:
PinDlg( QWidget *parent, const char * name, bool modal, bool fullscreen = FALSE )
: QDialog( parent, name, modal, fullscreen ? WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop : 0 ),
modl(modal)
{
pinD = new PinDialog( this );
if ( fullscreen ) {
QRect desk = oApp->desktop()->geometry();
setGeometry( 0, 0, desk.width(), desk.height() );
}
connect( pinD, SIGNAL(passwordEntered(const QString&)),
this, SLOT(accept()) );
connect( pinD, SIGNAL(skip()), this, SLOT(accept()) );
}
void resizeEvent( QResizeEvent * )
{
pinD->resize( size() );
}
void reset()
{
pinD->clear();
}
/// Slot receiving the Skip or Enter commands, and closing the QDialog
void accept()
{
if ( !modl )
oApp->exit_loop();
QDialog::accept();
}
PinDialog *pinD;
bool modl;
};
/// generate a fairly random salt and return the PIN hashed by crypt()
QString PinPlugin::encrypt(const QString& pin)
{
// the salt must begin by "$1$" if we want crypt() to use MD5
char salt[] = "$1$........";
const char *const seedchars = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
// initialize the random generator
srandom(time(0));
int i;
for(i = 0; i < 8; i++)
{
// initialize the salt with random()
salt[i+3] = seedchars[random() % 64];
}
return QString::fromLatin1(crypt(pin.latin1(),salt));
}
/// verify a PIN against its crypt() hash
/**
* \return true if the \a pin matches its \a hash
*/
bool PinPlugin::verify(const QString& pin, const QString& hash)
{
// the hash, which contains the salt (8 chars after "$1$"), can be given as the salt
return hash.compare( QString::fromLatin1(crypt( pin.latin1(), hash.latin1() )) ) == 0 ? true : false;
}
/// 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
/**
* \return the hashed ( =one-way encrypted) PIN typed in by the user
* \param prompt the prompt to display in the PinDialog
*/
QString PinPlugin::getCryptedPIN( const QString& prompt )
{
return encrypt(getPIN(prompt));
}
/// Displays the PIN dialog, asks 2 times for a new PIN, saves it if entered two times
/**
* writes nothing if we enter nothing the first time
*/
void PinPlugin::changePIN()
{
QString new1, new2;
do {
new1 = getPIN(QObject::tr("Enter new PIN"));
if ( new1.isNull() )
return;
new2 = getPIN(QObject::tr("Re-enter new PIN"));
} while (new1 != new2);
odebug << "writing new PIN hash in Security.conf" << oendl;
Config cfg("Security");
cfg.setGroup("PinPlugin");
cfg.writeEntry("hashedPIN", encrypt(new1));
}
/// Removes the PIN hashed value in the config file
void PinPlugin::clearPIN()
{
Config cfg("Security");
cfg.setGroup("PinPlugin");
cfg.removeEntry("hashedPIN");
}
/// Prompt, fullscreen, for the user's PIN and compare it to the stored one.
/**
* \return the result code, as a MultiauthPluginObject::authResult object
*/
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
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
@@ -1,68 +1,68 @@
/**
* \file pin.h
* \brief Standard Opie multiauth plugin definition
* \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
.> <`_, > . <= 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
+ . -:. = 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.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#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);
bool verify(const QString& pin, const QString& hash);
};
#endif // PIN_H
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
.> <`_, > . <= 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
+ . -:. = 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.
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;
};
#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,28 +1,31 @@
#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;
}
Q_EXPORT_INTERFACE() {
Q_CREATE_INSTANCE( PinPluginImpl )
}
QRESULT PinPluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) {
*iface = 0;
if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MultiauthPluginInterface ) ) {
*iface = this, (*iface)->addRef();
} else {
return QE_NOINTERFACE;
}
return QS_OK;
}
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
@@ -1,58 +1,57 @@
/**
* \file pinpluginimpl.h
* \brief Standard Opie multiauth plugin definition
* \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
.> <`_, > . <= 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
+ . -:. = 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.
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