From 5431072f0ea1cbc8ca37914b6349e66079f1acff Mon Sep 17 00:00:00 2001 From: clem Date: Tue, 15 Jun 2004 13:49:36 +0000 Subject: First revision of securityplugins, called by libopiesecurity2 authentication framework (see http://dudu.dyn.2-h.org/nist/OMAF.php). --- (limited to 'noncore/securityplugins') diff --git a/noncore/securityplugins/blueping/.cvsignore b/noncore/securityplugins/blueping/.cvsignore new file mode 100644 index 0000000..a4e0e29 --- a/dev/null +++ b/noncore/securityplugins/blueping/.cvsignore @@ -0,0 +1,3 @@ +.moc +.obj +Makefile diff --git a/noncore/securityplugins/blueping/Makefile b/noncore/securityplugins/blueping/Makefile new file mode 100644 index 0000000..990a4e0 --- a/dev/null +++ b/noncore/securityplugins/blueping/Makefile @@ -0,0 +1,204 @@ +############################################################################# +# Makefile for building: libmultiauthbluepingplugin.so.1.0.0 +# Generated by qmake (1.05a) (Qt 3.1.2) on: Mon Jun 14 11:00:20 2004 +# Project: bluepingplugin.pro +# Template: lib +# Command: $(QMAKE) -o Makefile bluepingplugin.pro +############################################################################# + +####### Compiler, tools and options + +CC = $(CCACHE) $(DISTCC) gcc +CXX = $(CCACHE) $(DISTCC) g++ +LEX = flex +YACC = yacc +CFLAGS = -pipe $(CFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 +CXXFLAGS = -pipe $(CFLAGS_EXTRA) -DQWS -fno-exceptions -fno-rtti $(CXXFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 +LEXFLAGS = +YACCFLAGS= -d +INCPATH = -I/opt/opie/mkspecs/qws/linux-generic-g++ -I. -I$(OPIEDIR)/include -I$(QTDIR)/include -I.moc/$(PLATFORM)/ +LINK = g++ +LFLAGS = $(LFLAGS_EXTRA) -Wl,-rpath-link,$(OPIEDIR)/lib -shared -Wl,-soname,libmultiauthbluepingplugin.so.1 -Wl,-rpath,/opt/opie/plugins/security +LIBS = $(SUBLIBS) -Wl,-rpath,$(QTDIR)/lib -L$(QTDIR)/lib $(LIBS_EXTRA) -lqpe -lopieui2 -lopiecore2 -L$(OPIEDIR)/lib -lqte +AR = ar cqs +RANLIB = +MOC = $(QTDIR)/bin/moc +UIC = $(QTDIR)/bin/uic +QMAKE = qmake +TAR = tar -cf +GZIP = gzip -9f +COPY = cp -f +COPY_FILE= $(COPY) -p +COPY_DIR = $(COPY) -pR +DEL_FILE = rm -f +SYMLINK = ln -sf +DEL_DIR = rmdir +MOVE = mv -f +PRO = bluepingplugin.pro +CHK_DIR_EXISTS= +MKDIR = + +####### Output directory + +OBJECTS_DIR = .obj/$(PLATFORM)/ + +####### Files + +HEADERS = bluepingplugin.h \ + bluepingpluginimpl.h +SOURCES = bluepingplugin.cpp \ + bluepingpluginimpl.cpp +OBJECTS = .obj/$(PLATFORM)/bluepingplugin.o \ + .obj/$(PLATFORM)/bluepingpluginimpl.o +FORMS = +UICDECLS = +UICIMPLS = +SRCMOC = .moc/$(PLATFORM)/moc_bluepingplugin.cpp +OBJMOC = .obj/$(PLATFORM)/moc_bluepingplugin.o +DIST = ../../../gen.pro \ + ../../../include.pro \ + bluepingplugin.pro +QMAKE_TARGET = multiauthbluepingplugin +DESTDIR = $(OPIEDIR)/plugins/security/ +TARGET = libmultiauthbluepingplugin.so.1.0.0 +TARGETA = $(OPIEDIR)/plugins/security/libmultiauthbluepingplugin.a +TARGETD = libmultiauthbluepingplugin.so.1.0.0 +TARGET0 = libmultiauthbluepingplugin.so +TARGET1 = libmultiauthbluepingplugin.so.1 +TARGET2 = libmultiauthbluepingplugin.so.1.0 + +first: all +####### Implicit rules + +.SUFFIXES: .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + +all: Makefile $(OPIEDIR)/plugins/security/$(TARGET) + +$(OPIEDIR)/plugins/security/$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + test -d $(OPIEDIR)/plugins/security/ || mkdir -p $(OPIEDIR)/plugins/security/ + -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + -ln -s $(TARGET) $(TARGET0) + -ln -s $(TARGET) $(TARGET1) + -ln -s $(TARGET) $(TARGET2) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET1) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET2) + -$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(OPIEDIR)/plugins/security/ + + + +staticlib: $(TARGETA) + +$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC) + -$(DEL_FILE) $(TARGETA) + $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC) + +mocables: $(SRCMOC) + +$(MOC): + ( cd $(QTDIR)/src/moc ; $(MAKE) ) + +Makefile: bluepingplugin.pro /opt/opie/mkspecs/qws/linux-generic-g++/qmake.conf ../../../gen.pro \ + ../../../include.pro + $(QMAKE) -o Makefile bluepingplugin.pro +qmake: + @$(QMAKE) -o Makefile bluepingplugin.pro + +dist: + @mkdir -p .obj/$(PLATFORM)/multiauthbluepingplugin && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .obj/$(PLATFORM)/multiauthbluepingplugin/ && ( cd `dirname .obj/$(PLATFORM)/multiauthbluepingplugin` && $(TAR) multiauthbluepingplugin.tar multiauthbluepingplugin && $(GZIP) multiauthbluepingplugin.tar ) && $(MOVE) `dirname .obj/$(PLATFORM)/multiauthbluepingplugin`/multiauthbluepingplugin.tar.gz . && $(DEL_FILE) -r .obj/$(PLATFORM)/multiauthbluepingplugin + +mocclean: + -$(DEL_FILE) $(OBJMOC) + -$(DEL_FILE) $(SRCMOC) + +uiclean: + +yaccclean: +lexclean: +clean: mocclean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) $(TARGET) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) $(OPIEDIR)/plugins/security/$(TARGET1) $(OPIEDIR)/plugins/security/$(TARGET2) $(TARGETA) + + +lupdate: + lupdate -noobsolete $(PRO) + +lrelease: + lrelease $(PRO) + +ipk: + tmp=`mktemp -d /tmp/ipkg-opie.XXXXXXXXXX` && ( $(MAKE) INSTALL_ROOT="" install && ipkg-build ; rm -rf ; ) + +opie-lupdate: + opie-lupdate $(PRO) + +opie-lrelease: + opie-lrelease $(PRO) + +messages: + xgettext -C -n -ktr -kQT_TRANSLATE_NOOP bluepingplugin.h bluepingpluginimpl.h bluepingplugin.cpp bluepingpluginimpl.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-tr.po' && xgettext -C -n -a bluepingplugin.h bluepingpluginimpl.h bluepingplugin.cpp bluepingpluginimpl.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-allstrings.po' + +FORCE: + +####### Compile + +.obj/$(PLATFORM)/bluepingplugin.o: bluepingplugin.cpp bluepingplugin.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/bluepingplugin.o bluepingplugin.cpp + +.obj/$(PLATFORM)/bluepingpluginimpl.o: bluepingpluginimpl.cpp bluepingpluginimpl.h \ + bluepingplugin.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/bluepingpluginimpl.o bluepingpluginimpl.cpp + +.obj/$(PLATFORM)/moc_bluepingplugin.o: .moc/$(PLATFORM)/moc_bluepingplugin.cpp bluepingplugin.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/moc_bluepingplugin.o .moc/$(PLATFORM)/moc_bluepingplugin.cpp + +.moc/x86-linux/moc_bluepingplugin.cpp: $(MOC) bluepingplugin.h + $(MOC) bluepingplugin.h -o .moc/x86-linux/moc_bluepingplugin.cpp + +####### Install + +install_target: + @$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" || $(MKDIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" + -$(COPY) "$(OPIEDIR)/plugins/security/$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" + +uninstall_target: + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" + -$(DEL_DIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" + + +install: all install_target + +uninstall: uninstall_target + diff --git a/noncore/securityplugins/blueping/bluepingplugin.control b/noncore/securityplugins/blueping/bluepingplugin.control new file mode 100644 index 0000000..9c5ec66 --- a/dev/null +++ b/noncore/securityplugins/blueping/bluepingplugin.control @@ -0,0 +1,12 @@ +Package: opie-multiauth-bluepingplugin +Files: plugins/security/libmultiauthbluepingplugin.so* pics/security/bluepingplugin.png +Priority: optional +Section: opie/settings +Maintainer: Clement Seveillac +Architecture: arm +Version: 0.0.2.5 +Depends: libopiecore2, opie-security +Description: Blueping plugin for opie-security authentication. + This is a bluetooth-based authentication plugin (you need + to have another Bluetooth device around, the more secure the + bonding they made, the more secure the authentication) diff --git a/noncore/securityplugins/blueping/bluepingplugin.cpp b/noncore/securityplugins/blueping/bluepingplugin.cpp new file mode 100644 index 0000000..af0448b --- a/dev/null +++ b/noncore/securityplugins/blueping/bluepingplugin.cpp @@ -0,0 +1,198 @@ +#include "bluepingplugin.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace Opie::Core; + +/// 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("

\"Blueping\"
plugin

", &bluepingDialog); + QLabel subTitle("

Trying to reach your configured bluetooth device...

", &bluepingDialog); + QLabel subTitle2("
You can skip this step and use another authentication way with the following button
", &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 new file mode 100644 index 0000000..c122471 --- a/dev/null +++ b/noncore/securityplugins/blueping/bluepingplugin.h @@ -0,0 +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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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 + +#include + +#include +#include +#include + +/// 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 { + + Q_OBJECT + + public: + BluepingPlugin(); + virtual ~BluepingPlugin(); + int authenticate(); + 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/bluepingplugin.pro b/noncore/securityplugins/blueping/bluepingplugin.pro new file mode 100644 index 0000000..1b92c16 --- a/dev/null +++ b/noncore/securityplugins/blueping/bluepingplugin.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +CONFIG += qt warn_on + +HEADERS = bluepingplugin.h bluepingpluginimpl.h + +SOURCES = bluepingplugin.cpp bluepingpluginimpl.cpp + + +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += + +LIBS += -lqpe -lopieui2 -lopiecore2 + +DESTDIR = $(OPIEDIR)/plugins/security +TARGET = multiauthbluepingplugin + +include ( $(OPIEDIR)/include.pro ) + diff --git a/noncore/securityplugins/blueping/bluepingpluginimpl.cpp b/noncore/securityplugins/blueping/bluepingpluginimpl.cpp new file mode 100644 index 0000000..f7b1bfc --- a/dev/null +++ b/noncore/securityplugins/blueping/bluepingpluginimpl.cpp @@ -0,0 +1,28 @@ +#include "bluepingpluginimpl.h" + +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 new file mode 100644 index 0000000..2fd023a --- a/dev/null +++ b/noncore/securityplugins/blueping/bluepingpluginimpl.h @@ -0,0 +1,58 @@ +/** + * \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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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{ + + public: + BluepingPluginImpl(); + virtual ~BluepingPluginImpl(); + + QRESULT queryInterface( const QUuid &, QUnknownInterface** ); + /// defines standard addRef() and release() functions + Q_REFCOUNT; + + virtual MultiauthPluginObject *plugin(); + + private: + /// the plugin itself + BluepingPlugin *bluepingPlugin; + ulong ref; +}; + +#endif diff --git a/noncore/securityplugins/blueping/config.in b/noncore/securityplugins/blueping/config.in new file mode 100644 index 0000000..ec17c33 --- a/dev/null +++ b/noncore/securityplugins/blueping/config.in @@ -0,0 +1,4 @@ + config MULTIAUTH_BLUEPING + boolean "opie-multiauth-blueping (blueping authentication plugin for opie-multiauth testing)" + default "y" + depends SECURITY diff --git a/noncore/securityplugins/dummy/.cvsignore b/noncore/securityplugins/dummy/.cvsignore new file mode 100644 index 0000000..a4e0e29 --- a/dev/null +++ b/noncore/securityplugins/dummy/.cvsignore @@ -0,0 +1,3 @@ +.moc +.obj +Makefile diff --git a/noncore/securityplugins/dummy/Makefile b/noncore/securityplugins/dummy/Makefile new file mode 100644 index 0000000..f6a1f9f --- a/dev/null +++ b/noncore/securityplugins/dummy/Makefile @@ -0,0 +1,204 @@ +############################################################################# +# Makefile for building: libmultiauthdummyplugin.so.1.0.0 +# Generated by qmake (1.05a) (Qt 3.1.2) on: Mon Jun 14 11:00:19 2004 +# Project: dummyplugin.pro +# Template: lib +# Command: $(QMAKE) -o Makefile dummyplugin.pro +############################################################################# + +####### Compiler, tools and options + +CC = $(CCACHE) $(DISTCC) gcc +CXX = $(CCACHE) $(DISTCC) g++ +LEX = flex +YACC = yacc +CFLAGS = -pipe $(CFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 +CXXFLAGS = -pipe $(CFLAGS_EXTRA) -DQWS -fno-exceptions -fno-rtti $(CXXFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 +LEXFLAGS = +YACCFLAGS= -d +INCPATH = -I/opt/opie/mkspecs/qws/linux-generic-g++ -I. -I$(OPIEDIR)/include -I$(QTDIR)/include -I.moc/$(PLATFORM)/ +LINK = g++ +LFLAGS = $(LFLAGS_EXTRA) -Wl,-rpath-link,$(OPIEDIR)/lib -shared -Wl,-soname,libmultiauthdummyplugin.so.1 -Wl,-rpath,/opt/opie/plugins/security +LIBS = $(SUBLIBS) -Wl,-rpath,$(QTDIR)/lib -L$(QTDIR)/lib $(LIBS_EXTRA) -lqpe -lopieui2 -L$(OPIEDIR)/lib -lqte +AR = ar cqs +RANLIB = +MOC = $(QTDIR)/bin/moc +UIC = $(QTDIR)/bin/uic +QMAKE = qmake +TAR = tar -cf +GZIP = gzip -9f +COPY = cp -f +COPY_FILE= $(COPY) -p +COPY_DIR = $(COPY) -pR +DEL_FILE = rm -f +SYMLINK = ln -sf +DEL_DIR = rmdir +MOVE = mv -f +PRO = dummyplugin.pro +CHK_DIR_EXISTS= +MKDIR = + +####### Output directory + +OBJECTS_DIR = .obj/$(PLATFORM)/ + +####### Files + +HEADERS = dummyplugin.h \ + dummypluginimpl.h +SOURCES = dummyplugin.cpp \ + dummypluginimpl.cpp +OBJECTS = .obj/$(PLATFORM)/dummyplugin.o \ + .obj/$(PLATFORM)/dummypluginimpl.o +FORMS = +UICDECLS = +UICIMPLS = +SRCMOC = .moc/$(PLATFORM)/moc_dummyplugin.cpp +OBJMOC = .obj/$(PLATFORM)/moc_dummyplugin.o +DIST = ../../../gen.pro \ + ../../../include.pro \ + dummyplugin.pro +QMAKE_TARGET = multiauthdummyplugin +DESTDIR = $(OPIEDIR)/plugins/security/ +TARGET = libmultiauthdummyplugin.so.1.0.0 +TARGETA = $(OPIEDIR)/plugins/security/libmultiauthdummyplugin.a +TARGETD = libmultiauthdummyplugin.so.1.0.0 +TARGET0 = libmultiauthdummyplugin.so +TARGET1 = libmultiauthdummyplugin.so.1 +TARGET2 = libmultiauthdummyplugin.so.1.0 + +first: all +####### Implicit rules + +.SUFFIXES: .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + +all: Makefile $(OPIEDIR)/plugins/security/$(TARGET) + +$(OPIEDIR)/plugins/security/$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + test -d $(OPIEDIR)/plugins/security/ || mkdir -p $(OPIEDIR)/plugins/security/ + -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + -ln -s $(TARGET) $(TARGET0) + -ln -s $(TARGET) $(TARGET1) + -ln -s $(TARGET) $(TARGET2) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET1) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET2) + -$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(OPIEDIR)/plugins/security/ + + + +staticlib: $(TARGETA) + +$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC) + -$(DEL_FILE) $(TARGETA) + $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC) + +mocables: $(SRCMOC) + +$(MOC): + ( cd $(QTDIR)/src/moc ; $(MAKE) ) + +Makefile: dummyplugin.pro /opt/opie/mkspecs/qws/linux-generic-g++/qmake.conf ../../../gen.pro \ + ../../../include.pro + $(QMAKE) -o Makefile dummyplugin.pro +qmake: + @$(QMAKE) -o Makefile dummyplugin.pro + +dist: + @mkdir -p .obj/$(PLATFORM)/multiauthdummyplugin && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .obj/$(PLATFORM)/multiauthdummyplugin/ && ( cd `dirname .obj/$(PLATFORM)/multiauthdummyplugin` && $(TAR) multiauthdummyplugin.tar multiauthdummyplugin && $(GZIP) multiauthdummyplugin.tar ) && $(MOVE) `dirname .obj/$(PLATFORM)/multiauthdummyplugin`/multiauthdummyplugin.tar.gz . && $(DEL_FILE) -r .obj/$(PLATFORM)/multiauthdummyplugin + +mocclean: + -$(DEL_FILE) $(OBJMOC) + -$(DEL_FILE) $(SRCMOC) + +uiclean: + +yaccclean: +lexclean: +clean: mocclean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) $(TARGET) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) $(OPIEDIR)/plugins/security/$(TARGET1) $(OPIEDIR)/plugins/security/$(TARGET2) $(TARGETA) + + +lupdate: + lupdate -noobsolete $(PRO) + +lrelease: + lrelease $(PRO) + +ipk: + tmp=`mktemp -d /tmp/ipkg-opie.XXXXXXXXXX` && ( $(MAKE) INSTALL_ROOT="" install && ipkg-build ; rm -rf ; ) + +opie-lupdate: + opie-lupdate $(PRO) + +opie-lrelease: + opie-lrelease $(PRO) + +messages: + xgettext -C -n -ktr -kQT_TRANSLATE_NOOP dummyplugin.h dummypluginimpl.h dummyplugin.cpp dummypluginimpl.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-tr.po' && xgettext -C -n -a dummyplugin.h dummypluginimpl.h dummyplugin.cpp dummypluginimpl.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-allstrings.po' + +FORCE: + +####### Compile + +.obj/$(PLATFORM)/dummyplugin.o: dummyplugin.cpp dummyplugin.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/dummyplugin.o dummyplugin.cpp + +.obj/$(PLATFORM)/dummypluginimpl.o: dummypluginimpl.cpp dummypluginimpl.h \ + dummyplugin.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/dummypluginimpl.o dummypluginimpl.cpp + +.obj/$(PLATFORM)/moc_dummyplugin.o: .moc/$(PLATFORM)/moc_dummyplugin.cpp dummyplugin.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/moc_dummyplugin.o .moc/$(PLATFORM)/moc_dummyplugin.cpp + +.moc/x86-linux/moc_dummyplugin.cpp: $(MOC) dummyplugin.h + $(MOC) dummyplugin.h -o .moc/x86-linux/moc_dummyplugin.cpp + +####### Install + +install_target: + @$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" || $(MKDIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" + -$(COPY) "$(OPIEDIR)/plugins/security/$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" + +uninstall_target: + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" + -$(DEL_DIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" + + +install: all install_target + +uninstall: uninstall_target + diff --git a/noncore/securityplugins/dummy/config.in b/noncore/securityplugins/dummy/config.in new file mode 100644 index 0000000..2053eef --- a/dev/null +++ b/noncore/securityplugins/dummy/config.in @@ -0,0 +1,4 @@ + config MULTIAUTH_DUMMY + boolean "opie-multiauth-dummy (dummy authentication plugin for opie-multiauth testing)" + default "y" + depends SECURITY diff --git a/noncore/securityplugins/dummy/dummyplugin.control b/noncore/securityplugins/dummy/dummyplugin.control new file mode 100644 index 0000000..1bd9700 --- a/dev/null +++ b/noncore/securityplugins/dummy/dummyplugin.control @@ -0,0 +1,11 @@ +Package: opie-multiauth-dummyplugin +Files: plugins/security/libmultiauthdummyplugin.so* pics/security/dummyplugin.png +Priority: optional +Section: opie/settings +Maintainer: Clement Seveillac +Architecture: arm +Version: 0.0.2.3 +Depends: opie-security +Description: Dummy plugin for opie-security authentication. + This is a very simple authentication plugin (you just have + to press a button basically), for demonstration purpose. diff --git a/noncore/securityplugins/dummy/dummyplugin.cpp b/noncore/securityplugins/dummy/dummyplugin.cpp new file mode 100644 index 0000000..0d19e43 --- a/dev/null +++ b/noncore/securityplugins/dummy/dummyplugin.cpp @@ -0,0 +1,92 @@ +#include "dummyplugin.h" + +#include + +#include +#include +#include +#include + +/// 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("

" + tr("\"Dummy\"
demonstration plugin") + "

", &dummyDialog); + QLabel subTitle("

" +tr("You can simulate the following outcomes:") + "

", &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 new file mode 100644 index 0000000..9680dff --- a/dev/null +++ b/noncore/securityplugins/dummy/dummyplugin.h @@ -0,0 +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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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 +#include +#include + +/// Multi-authentication example plugin, implementing a trivial 'yes/no' verification. +/** + * The plugin itself, implementing the main authenticate() function. + */ +class DummyPlugin : public QObject, public MultiauthPluginObject { + + Q_OBJECT + + public: + int authenticate(); + 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/dummyplugin.pro b/noncore/securityplugins/dummy/dummyplugin.pro new file mode 100644 index 0000000..bb9971c --- a/dev/null +++ b/noncore/securityplugins/dummy/dummyplugin.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib +CONFIG += qt warn_on +CONFIG -= moc + +HEADERS = dummyplugin.h dummypluginimpl.h + +SOURCES = dummyplugin.cpp dummypluginimpl.cpp + + +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += + +LIBS += -lqpe -lopieui2 + +DESTDIR = $(OPIEDIR)/plugins/security +TARGET = multiauthdummyplugin + +include ( $(OPIEDIR)/include.pro ) + diff --git a/noncore/securityplugins/dummy/dummypluginimpl.cpp b/noncore/securityplugins/dummy/dummypluginimpl.cpp new file mode 100644 index 0000000..518996c --- a/dev/null +++ b/noncore/securityplugins/dummy/dummypluginimpl.cpp @@ -0,0 +1,28 @@ +#include "dummypluginimpl.h" + +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 new file mode 100644 index 0000000..49a18cd --- a/dev/null +++ b/noncore/securityplugins/dummy/dummypluginimpl.h @@ -0,0 +1,58 @@ +/** + * \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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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{ + + public: + DummyPluginImpl(); + virtual ~DummyPluginImpl(); + + QRESULT queryInterface( const QUuid &, QUnknownInterface** ); + /// defines standard addRef() and release() functions + Q_REFCOUNT; + + virtual MultiauthPluginObject *plugin(); + + private: + /// the plugin itself + DummyPlugin *dummyPlugin; + ulong ref; +}; + +#endif diff --git a/noncore/securityplugins/notice/.cvsignore b/noncore/securityplugins/notice/.cvsignore new file mode 100644 index 0000000..a4e0e29 --- a/dev/null +++ b/noncore/securityplugins/notice/.cvsignore @@ -0,0 +1,3 @@ +.moc +.obj +Makefile diff --git a/noncore/securityplugins/notice/Makefile b/noncore/securityplugins/notice/Makefile new file mode 100644 index 0000000..6303951 --- a/dev/null +++ b/noncore/securityplugins/notice/Makefile @@ -0,0 +1,212 @@ +############################################################################# +# Makefile for building: libmultiauthnoticeplugin.so.1.0.0 +# Generated by qmake (1.05a) (Qt 3.1.2) on: Mon Jun 14 11:00:20 2004 +# Project: noticeplugin.pro +# Template: lib +# Command: $(QMAKE) -o Makefile noticeplugin.pro +############################################################################# + +####### Compiler, tools and options + +CC = $(CCACHE) $(DISTCC) gcc +CXX = $(CCACHE) $(DISTCC) g++ +LEX = flex +YACC = yacc +CFLAGS = -pipe $(CFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 +CXXFLAGS = -pipe $(CFLAGS_EXTRA) -DQWS -fno-exceptions -fno-rtti $(CXXFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 +LEXFLAGS = +YACCFLAGS= -d +INCPATH = -I/opt/opie/mkspecs/qws/linux-generic-g++ -I. -I$(OPIEDIR)/include -I$(QTDIR)/include -I.moc/$(PLATFORM)/ +LINK = g++ +LFLAGS = $(LFLAGS_EXTRA) -Wl,-rpath-link,$(OPIEDIR)/lib -shared -Wl,-soname,libmultiauthnoticeplugin.so.1 -Wl,-rpath,/opt/opie/plugins/security +LIBS = $(SUBLIBS) -Wl,-rpath,$(QTDIR)/lib -L$(QTDIR)/lib $(LIBS_EXTRA) -lqpe -lopieui2 -L$(OPIEDIR)/lib -lqte +AR = ar cqs +RANLIB = +MOC = $(QTDIR)/bin/moc +UIC = $(QTDIR)/bin/uic +QMAKE = qmake +TAR = tar -cf +GZIP = gzip -9f +COPY = cp -f +COPY_FILE= $(COPY) -p +COPY_DIR = $(COPY) -pR +DEL_FILE = rm -f +SYMLINK = ln -sf +DEL_DIR = rmdir +MOVE = mv -f +PRO = noticeplugin.pro +CHK_DIR_EXISTS= +MKDIR = + +####### Output directory + +OBJECTS_DIR = .obj/$(PLATFORM)/ + +####### Files + +HEADERS = noticeplugin.h \ + noticepluginimpl.h \ + noticeConfigWidget.h +SOURCES = noticeplugin.cpp \ + noticepluginimpl.cpp \ + noticeConfigWidget.cpp +OBJECTS = .obj/$(PLATFORM)/noticeplugin.o \ + .obj/$(PLATFORM)/noticepluginimpl.o \ + .obj/$(PLATFORM)/noticeConfigWidget.o +FORMS = +UICDECLS = +UICIMPLS = +SRCMOC = .moc/$(PLATFORM)/moc_noticeConfigWidget.cpp +OBJMOC = .obj/$(PLATFORM)/moc_noticeConfigWidget.o +DIST = ../../../gen.pro \ + ../../../include.pro \ + noticeplugin.pro +QMAKE_TARGET = multiauthnoticeplugin +DESTDIR = $(OPIEDIR)/plugins/security/ +TARGET = libmultiauthnoticeplugin.so.1.0.0 +TARGETA = $(OPIEDIR)/plugins/security/libmultiauthnoticeplugin.a +TARGETD = libmultiauthnoticeplugin.so.1.0.0 +TARGET0 = libmultiauthnoticeplugin.so +TARGET1 = libmultiauthnoticeplugin.so.1 +TARGET2 = libmultiauthnoticeplugin.so.1.0 + +first: all +####### Implicit rules + +.SUFFIXES: .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + +all: Makefile $(OPIEDIR)/plugins/security/$(TARGET) + +$(OPIEDIR)/plugins/security/$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + test -d $(OPIEDIR)/plugins/security/ || mkdir -p $(OPIEDIR)/plugins/security/ + -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + -ln -s $(TARGET) $(TARGET0) + -ln -s $(TARGET) $(TARGET1) + -ln -s $(TARGET) $(TARGET2) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET1) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET2) + -$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(OPIEDIR)/plugins/security/ + + + +staticlib: $(TARGETA) + +$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC) + -$(DEL_FILE) $(TARGETA) + $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC) + +mocables: $(SRCMOC) + +$(MOC): + ( cd $(QTDIR)/src/moc ; $(MAKE) ) + +Makefile: noticeplugin.pro /opt/opie/mkspecs/qws/linux-generic-g++/qmake.conf ../../../gen.pro \ + ../../../include.pro + $(QMAKE) -o Makefile noticeplugin.pro +qmake: + @$(QMAKE) -o Makefile noticeplugin.pro + +dist: + @mkdir -p .obj/$(PLATFORM)/multiauthnoticeplugin && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .obj/$(PLATFORM)/multiauthnoticeplugin/ && ( cd `dirname .obj/$(PLATFORM)/multiauthnoticeplugin` && $(TAR) multiauthnoticeplugin.tar multiauthnoticeplugin && $(GZIP) multiauthnoticeplugin.tar ) && $(MOVE) `dirname .obj/$(PLATFORM)/multiauthnoticeplugin`/multiauthnoticeplugin.tar.gz . && $(DEL_FILE) -r .obj/$(PLATFORM)/multiauthnoticeplugin + +mocclean: + -$(DEL_FILE) $(OBJMOC) + -$(DEL_FILE) $(SRCMOC) + +uiclean: + +yaccclean: +lexclean: +clean: mocclean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) $(TARGET) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) $(OPIEDIR)/plugins/security/$(TARGET1) $(OPIEDIR)/plugins/security/$(TARGET2) $(TARGETA) + + +lupdate: + lupdate -noobsolete $(PRO) + +lrelease: + lrelease $(PRO) + +ipk: + tmp=`mktemp -d /tmp/ipkg-opie.XXXXXXXXXX` && ( $(MAKE) INSTALL_ROOT="" install && ipkg-build ; rm -rf ; ) + +opie-lupdate: + opie-lupdate $(PRO) + +opie-lrelease: + opie-lrelease $(PRO) + +messages: + xgettext -C -n -ktr -kQT_TRANSLATE_NOOP noticeplugin.h noticepluginimpl.h noticeConfigWidget.h noticeplugin.cpp noticepluginimpl.cpp noticeConfigWidget.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-tr.po' && xgettext -C -n -a noticeplugin.h noticepluginimpl.h noticeConfigWidget.h noticeplugin.cpp noticepluginimpl.cpp noticeConfigWidget.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-allstrings.po' + +FORCE: + +####### Compile + +.obj/$(PLATFORM)/noticeplugin.o: noticeplugin.cpp noticeplugin.h \ + noticeConfigWidget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/noticeplugin.o noticeplugin.cpp + +.obj/$(PLATFORM)/noticepluginimpl.o: noticepluginimpl.cpp noticepluginimpl.h \ + noticeplugin.h \ + noticeConfigWidget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/noticepluginimpl.o noticepluginimpl.cpp + +.obj/$(PLATFORM)/noticeConfigWidget.o: noticeConfigWidget.cpp noticeConfigWidget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/noticeConfigWidget.o noticeConfigWidget.cpp + +.obj/$(PLATFORM)/moc_noticeConfigWidget.o: .moc/$(PLATFORM)/moc_noticeConfigWidget.cpp noticeConfigWidget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/moc_noticeConfigWidget.o .moc/$(PLATFORM)/moc_noticeConfigWidget.cpp + +.moc/x86-linux/moc_noticeConfigWidget.cpp: $(MOC) noticeConfigWidget.h + $(MOC) noticeConfigWidget.h -o .moc/x86-linux/moc_noticeConfigWidget.cpp + +####### Install + +install_target: + @$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" || $(MKDIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" + -$(COPY) "$(OPIEDIR)/plugins/security/$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" + +uninstall_target: + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" + -$(DEL_DIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" + + +install: all install_target + +uninstall: uninstall_target + diff --git a/noncore/securityplugins/notice/config.in b/noncore/securityplugins/notice/config.in new file mode 100644 index 0000000..bfc649e --- a/dev/null +++ b/noncore/securityplugins/notice/config.in @@ -0,0 +1,4 @@ + config MULTIAUTH_NOTICE + boolean "opie-multiauth-notice (Notice plugin for opie-multiauth)" + default "y" + depends SECURITY diff --git a/noncore/securityplugins/notice/notice.control b/noncore/securityplugins/notice/notice.control new file mode 100644 index 0000000..890e0c9 --- a/dev/null +++ b/noncore/securityplugins/notice/notice.control @@ -0,0 +1,11 @@ +Package: opie-multiauth-noticeplugin +Files: plugins/security/libmultiauthnoticeplugin.so* pics/security/noticeplugin.png pics/security/noticeplugin_small.png +Priority: optional +Section: opie/settings +Maintainer: Clement Seveillac +Architecture: arm +Version: 0.0.1.6 +Depends: opie-security +Description: Notice plugin for opie-security authentication. + It allows you to display, for example, a notice from your legal departement. + diff --git a/noncore/securityplugins/notice/noticeConfigWidget.cpp b/noncore/securityplugins/notice/noticeConfigWidget.cpp new file mode 100644 index 0000000..e2c2d83 --- a/dev/null +++ b/noncore/securityplugins/notice/noticeConfigWidget.cpp @@ -0,0 +1,81 @@ +#include "noticeConfigWidget.h" + +#include + +#include +#include +#include +#include +#include + +/// 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("

" + tr("You may want to consult your legal department for proper wording here.") + "

", 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("

" + tr("Note: you can use HTML tags to improve its layout (example: text between <em> and </em> will be emphasized)") + "

", 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 new file mode 100644 index 0000000..69f15bf --- a/dev/null +++ b/noncore/securityplugins/notice/noticeConfigWidget.h @@ -0,0 +1,71 @@ +/** + * \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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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 +#include +#include + +#include + +static char defaultNoticeText [] = "

NOTICE TO USERS

\n" + "

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.

\n" + "

Unauthorized or improper use of this system may result in " + "disciplinary action and civil and criminal penalties. 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.

"; + +class NoticeConfigWidget : public 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 new file mode 100644 index 0000000..f7d41ab --- a/dev/null +++ b/noncore/securityplugins/notice/noticeplugin.cpp @@ -0,0 +1,83 @@ +#include "noticeplugin.h" + +#include + +#include +#include + +/// 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, "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 new file mode 100644 index 0000000..e01cb93 --- a/dev/null +++ b/noncore/securityplugins/notice/noticeplugin.h @@ -0,0 +1,62 @@ +/** + * \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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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 +#include +#include +#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 MultiauthPluginObject { + +public: + NoticePlugin(); + virtual ~NoticePlugin(); + int authenticate(); + 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/noticeplugin.pro b/noncore/securityplugins/notice/noticeplugin.pro new file mode 100644 index 0000000..51532a2 --- a/dev/null +++ b/noncore/securityplugins/notice/noticeplugin.pro @@ -0,0 +1,17 @@ +TEMPLATE = lib +CONFIG += qt warn_on + +HEADERS = noticeplugin.h noticepluginimpl.h noticeConfigWidget.h + +SOURCES = noticeplugin.cpp noticepluginimpl.cpp noticeConfigWidget.cpp + + +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += + +LIBS += -lqpe -lopieui2 + +DESTDIR = $(OPIEDIR)/plugins/security +TARGET = multiauthnoticeplugin + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/securityplugins/notice/noticepluginimpl.cpp b/noncore/securityplugins/notice/noticepluginimpl.cpp new file mode 100644 index 0000000..34e3cfc --- a/dev/null +++ b/noncore/securityplugins/notice/noticepluginimpl.cpp @@ -0,0 +1,28 @@ +#include "noticepluginimpl.h" + +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 new file mode 100644 index 0000000..b2a1140 --- a/dev/null +++ b/noncore/securityplugins/notice/noticepluginimpl.h @@ -0,0 +1,61 @@ +/** + * \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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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{ + + public: + NoticePluginImpl(); + virtual ~NoticePluginImpl(); + + QRESULT queryInterface( const QUuid &, QUnknownInterface** ); + /// defines standard addRef() and release() functions + Q_REFCOUNT; + + virtual MultiauthPluginObject *plugin(); + + private: + /// the plugin itself + NoticePlugin *noticePlugin; + ulong ref; +}; + +#endif + diff --git a/noncore/securityplugins/pin/.cvsignore b/noncore/securityplugins/pin/.cvsignore new file mode 100644 index 0000000..2fc28bd --- a/dev/null +++ b/noncore/securityplugins/pin/.cvsignore @@ -0,0 +1,4 @@ +*.moc +Makefile +pinDialogBase.cpp +pinDialogBase.h diff --git a/noncore/securityplugins/pin/Makefile b/noncore/securityplugins/pin/Makefile new file mode 100644 index 0000000..8c6a231 --- a/dev/null +++ b/noncore/securityplugins/pin/Makefile @@ -0,0 +1,237 @@ +############################################################################# +# Makefile for building: libmultiauthpinplugin.so.0.0.2 +# Generated by qmake (1.05a) (Qt 3.1.2) on: Mon Jun 14 11:00:20 2004 +# Project: pinplugin.pro +# Template: lib +# Command: $(QMAKE) -o Makefile pinplugin.pro +############################################################################# + +####### Compiler, tools and options + +CC = $(CCACHE) $(DISTCC) gcc +CXX = $(CCACHE) $(DISTCC) g++ +LEX = flex +YACC = yacc +CFLAGS = -pipe $(CFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 +CXXFLAGS = -pipe $(CFLAGS_EXTRA) -DQWS -fno-exceptions -fno-rtti $(CXXFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 +LEXFLAGS = +YACCFLAGS= -d +INCPATH = -I/opt/opie/mkspecs/qws/linux-generic-g++ -I. -I$(OPIEDIR)/include -I$(QTDIR)/include -I.moc/$(PLATFORM)/ +LINK = g++ +LFLAGS = $(LFLAGS_EXTRA) -Wl,-rpath-link,$(OPIEDIR)/lib -shared -Wl,-soname,libmultiauthpinplugin.so.0 -Wl,-rpath,/opt/opie/plugins/security +LIBS = $(SUBLIBS) -Wl,-rpath,$(QTDIR)/lib -L$(QTDIR)/lib $(LIBS_EXTRA) -lqpe -lopieui2 -L$(OPIEDIR)/lib -lqte +AR = ar cqs +RANLIB = +MOC = $(QTDIR)/bin/moc +UIC = $(QTDIR)/bin/uic +QMAKE = qmake +TAR = tar -cf +GZIP = gzip -9f +COPY = cp -f +COPY_FILE= $(COPY) -p +COPY_DIR = $(COPY) -pR +DEL_FILE = rm -f +SYMLINK = ln -sf +DEL_DIR = rmdir +MOVE = mv -f +PRO = pinplugin.pro +CHK_DIR_EXISTS= +MKDIR = + +####### Output directory + +OBJECTS_DIR = .obj/$(PLATFORM)/ + +####### Files + +HEADERS = pin.h \ + pinpluginimpl.h \ + pinConfigWidget.h +SOURCES = pin.cpp \ + pinpluginimpl.cpp \ + pinConfigWidget.cpp +OBJECTS = .obj/$(PLATFORM)/pin.o \ + .obj/$(PLATFORM)/pinpluginimpl.o \ + .obj/$(PLATFORM)/pinConfigWidget.o \ + .obj/$(PLATFORM)/pinDialogBase.o +FORMS = pinDialogBase.ui +UICDECLS = pinDialogBase.h +UICIMPLS = pinDialogBase.cpp +SRCMOC = .moc/$(PLATFORM)/moc_pin.cpp \ + .moc/$(PLATFORM)/moc_pinDialogBase.cpp \ + .moc/$(PLATFORM)/pin.moc +OBJMOC = .obj/$(PLATFORM)/moc_pin.o \ + .obj/$(PLATFORM)/moc_pinDialogBase.o +DIST = ../../../gen.pro \ + ../../../include.pro \ + pinplugin.pro +QMAKE_TARGET = multiauthpinplugin +DESTDIR = $(OPIEDIR)/plugins/security/ +TARGET = libmultiauthpinplugin.so.0.0.2 +TARGETA = $(OPIEDIR)/plugins/security/libmultiauthpinplugin.a +TARGETD = libmultiauthpinplugin.so.0.0.2 +TARGET0 = libmultiauthpinplugin.so +TARGET1 = libmultiauthpinplugin.so.0 +TARGET2 = libmultiauthpinplugin.so.0.0 + +first: all +####### Implicit rules + +.SUFFIXES: .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + +all: Makefile $(OPIEDIR)/plugins/security/$(TARGET) + +$(OPIEDIR)/plugins/security/$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + test -d $(OPIEDIR)/plugins/security/ || mkdir -p $(OPIEDIR)/plugins/security/ + -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + -ln -s $(TARGET) $(TARGET0) + -ln -s $(TARGET) $(TARGET1) + -ln -s $(TARGET) $(TARGET2) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET1) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET2) + -$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(OPIEDIR)/plugins/security/ + + + +staticlib: $(TARGETA) + +$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC) + -$(DEL_FILE) $(TARGETA) + $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC) + +mocables: $(SRCMOC) + +$(MOC): + ( cd $(QTDIR)/src/moc ; $(MAKE) ) + +Makefile: pinplugin.pro /opt/opie/mkspecs/qws/linux-generic-g++/qmake.conf ../../../gen.pro \ + ../../../include.pro + $(QMAKE) -o Makefile pinplugin.pro +qmake: + @$(QMAKE) -o Makefile pinplugin.pro + +dist: + @mkdir -p .obj/$(PLATFORM)/multiauthpinplugin && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .obj/$(PLATFORM)/multiauthpinplugin/ && ( cd `dirname .obj/$(PLATFORM)/multiauthpinplugin` && $(TAR) multiauthpinplugin.tar multiauthpinplugin && $(GZIP) multiauthpinplugin.tar ) && $(MOVE) `dirname .obj/$(PLATFORM)/multiauthpinplugin`/multiauthpinplugin.tar.gz . && $(DEL_FILE) -r .obj/$(PLATFORM)/multiauthpinplugin + +mocclean: + -$(DEL_FILE) $(OBJMOC) + -$(DEL_FILE) $(SRCMOC) + +uiclean: + -$(DEL_FILE) $(UICIMPLS) $(UICDECLS) + +yaccclean: +lexclean: +clean: mocclean uiclean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) $(TARGET) + -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) $(OPIEDIR)/plugins/security/$(TARGET1) $(OPIEDIR)/plugins/security/$(TARGET2) $(TARGETA) + + +lupdate: + lupdate -noobsolete $(PRO) + +lrelease: + lrelease $(PRO) + +ipk: + tmp=`mktemp -d /tmp/ipkg-opie.XXXXXXXXXX` && ( $(MAKE) INSTALL_ROOT="" install && ipkg-build ; rm -rf ; ) + +opie-lupdate: + opie-lupdate $(PRO) + +opie-lrelease: + opie-lrelease $(PRO) + +messages: + xgettext -C -n -ktr -kQT_TRANSLATE_NOOP pin.h pinpluginimpl.h pinConfigWidget.h pin.cpp pinpluginimpl.cpp pinConfigWidget.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-tr.po' && xgettext -C -n -a pin.h pinpluginimpl.h pinConfigWidget.h pin.cpp pinpluginimpl.cpp pinConfigWidget.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-allstrings.po' + +FORCE: + +####### Compile + +.obj/$(PLATFORM)/pin.o: pin.cpp pin.h \ + pinDialogBase.h \ + pinConfigWidget.h \ + .moc/$(PLATFORM)/pin.moc + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/pin.o pin.cpp + +.obj/$(PLATFORM)/pinpluginimpl.o: pinpluginimpl.cpp pinpluginimpl.h \ + pin.h \ + pinConfigWidget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/pinpluginimpl.o pinpluginimpl.cpp + +.obj/$(PLATFORM)/pinConfigWidget.o: pinConfigWidget.cpp pinConfigWidget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/pinConfigWidget.o pinConfigWidget.cpp + +pinDialogBase.h: pinDialogBase.ui + $(UIC) pinDialogBase.ui -o pinDialogBase.h + +pinDialogBase.cpp: pinDialogBase.h pinDialogBase.ui + $(UIC) pinDialogBase.ui -i pinDialogBase.h -o pinDialogBase.cpp + +.obj/$(PLATFORM)/pinDialogBase.o: pinDialogBase.cpp pinDialogBase.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/pinDialogBase.o pinDialogBase.cpp + +.obj/$(PLATFORM)/moc_pin.o: .moc/$(PLATFORM)/moc_pin.cpp pin.h pinConfigWidget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/moc_pin.o .moc/$(PLATFORM)/moc_pin.cpp + +.obj/$(PLATFORM)/moc_pinDialogBase.o: .moc/$(PLATFORM)/moc_pinDialogBase.cpp pinDialogBase.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/moc_pinDialogBase.o .moc/$(PLATFORM)/moc_pinDialogBase.cpp + +.moc/x86-linux/moc_pin.cpp: $(MOC) pin.h + $(MOC) pin.h -o .moc/x86-linux/moc_pin.cpp + +.moc/x86-linux/pin.moc: $(MOC) pin.cpp + $(MOC) pin.cpp -o .moc/x86-linux/pin.moc + +.moc/x86-linux/moc_pinDialogBase.cpp: $(MOC) pinDialogBase.h + $(MOC) pinDialogBase.h -o .moc/x86-linux/moc_pinDialogBase.cpp + +####### Install + +install_target: + @$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" || $(MKDIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" + -$(COPY) "$(OPIEDIR)/plugins/security/$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" + +uninstall_target: + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" + -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" + -$(DEL_DIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" + + +install: all install_target + +uninstall: uninstall_target + diff --git a/noncore/securityplugins/pin/config.in b/noncore/securityplugins/pin/config.in new file mode 100644 index 0000000..d255038 --- a/dev/null +++ b/noncore/securityplugins/pin/config.in @@ -0,0 +1,4 @@ + config MULTIAUTH_PIN + boolean "opie-multiauth-pin (PIN authentication plugin for opie-multiauth)" + default "y" + depends SECURITY diff --git a/noncore/securityplugins/pin/pin.control b/noncore/securityplugins/pin/pin.control new file mode 100644 index 0000000..158e20d --- a/dev/null +++ b/noncore/securityplugins/pin/pin.control @@ -0,0 +1,12 @@ +Package: opie-multiauth-pinplugin +Files: plugins/security/libmultiauthpinplugin.so* pics/security/pinplugin.png +Priority: optional +Section: opie/settings +Maintainer: Clement Seveillac +Architecture: arm +Version: 0.0.2.6 +Depends: opie-security +Description: PIN plugin for opie-security authentication. + It implements the same kind of widgets as opie-security package, + but this implementation can be used along with other authentication + methods in the Opie Multi-Authentication Framework. diff --git a/noncore/securityplugins/pin/pin.cpp b/noncore/securityplugins/pin/pin.cpp new file mode 100644 index 0000000..37dc5be --- a/dev/null +++ b/noncore/securityplugins/pin/pin.cpp @@ -0,0 +1,342 @@ +/** + * \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 +#include +/* QT */ +#include +#include +#include +#include +#include +#include +/* UNIX */ +#include +#include +#include + +extern "C" char *crypt(const char *key, const char *salt); + +/// set to TRUE when we press the 'Skip' button +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 new file mode 100644 index 0000000..6cd328a --- a/dev/null +++ b/noncore/securityplugins/pin/pin.h @@ -0,0 +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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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 +#include +#include +#include "pinConfigWidget.h" + +/// Multi-authentication plugin, implementing a PIN verification. +/** + * The plugin itself, implementing the main authenticate() function. + */ +class PinPlugin : public QObject, public MultiauthPluginObject { + + Q_OBJECT + +public: + int authenticate(); + 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 new file mode 100644 index 0000000..53e1a20 --- a/dev/null +++ b/noncore/securityplugins/pin/pinConfigWidget.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +#include "pinConfigWidget.h" + +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("

" + tr("PIN protection provides a minimal level of protection from casual access to this device.") + "

", 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 new file mode 100644 index 0000000..3242ad0 --- a/dev/null +++ b/noncore/securityplugins/pin/pinConfigWidget.h @@ -0,0 +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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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 + +#include + +class PinConfigWidget : public 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/pinDialogBase.cpp b/noncore/securityplugins/pin/pinDialogBase.cpp new file mode 100644 index 0000000..244a75e --- a/dev/null +++ b/noncore/securityplugins/pin/pinDialogBase.cpp @@ -0,0 +1,304 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'pinDialogBase.ui' +** +** Created: Mon Jun 14 11:01:08 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "pinDialogBase.h" + +#include +#include +#include +#include +#include +#include + +/* + * Constructs a PinDialogBase which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +PinDialogBase::PinDialogBase( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "PinDialogBase" ); + resize( 231, 293 ); + QFont f( font() ); + f.setPointSize( 24 ); + setFont( f ); + setCaption( tr( "PinDialogBase" ) ); + + button_4 = new QLabel( this, "button_4" ); + button_4->setGeometry( QRect( 11, 138, 68, 44 ) ); + button_4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_4->sizePolicy().hasHeightForWidth() ) ); + button_4->setFrameShape( QLabel::Box ); + button_4->setFrameShadow( QLabel::Raised ); + button_4->setText( tr( "4" ) ); + button_4->setAlignment( int( QLabel::AlignCenter ) ); + + button_7 = new QLabel( this, "button_7" ); + button_7->setGeometry( QRect( 11, 188, 68, 44 ) ); + button_7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_7->sizePolicy().hasHeightForWidth() ) ); + button_7->setFrameShape( QLabel::Box ); + button_7->setFrameShadow( QLabel::Raised ); + button_7->setText( tr( "7" ) ); + button_7->setAlignment( int( QLabel::AlignCenter ) ); + + prompt = new QLabel( this, "prompt" ); + prompt->setGeometry( QRect( 11, 11, 217, 25 ) ); + QFont prompt_font( prompt->font() ); + prompt_font.setPointSize( 18 ); + prompt->setFont( prompt_font ); + prompt->setText( tr( "Enter your PIN" ) ); + + display = new QLineEdit( this, "display" ); + display->setEnabled( FALSE ); + display->setGeometry( QRect( 11, 42, 217, 40 ) ); + QPalette pal; + QColorGroup cg; + cg.setColor( QColorGroup::Foreground, black ); + cg.setColor( QColorGroup::Button, QColor( 228, 228, 228) ); + cg.setColor( QColorGroup::Light, white ); + cg.setColor( QColorGroup::Midlight, QColor( 242, 242, 242) ); + cg.setColor( QColorGroup::Dark, QColor( 78, 78, 78) ); + cg.setColor( QColorGroup::Mid, QColor( 183, 183, 183) ); + cg.setColor( QColorGroup::Text, black ); + cg.setColor( QColorGroup::BrightText, white ); + cg.setColor( QColorGroup::ButtonText, black ); + cg.setColor( QColorGroup::Base, white ); + cg.setColor( QColorGroup::Background, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Shadow, black ); + cg.setColor( QColorGroup::Highlight, QColor( 10, 95, 137) ); + cg.setColor( QColorGroup::HighlightedText, white ); + pal.setActive( cg ); + cg.setColor( QColorGroup::Foreground, black ); + cg.setColor( QColorGroup::Button, QColor( 228, 228, 228) ); + cg.setColor( QColorGroup::Light, white ); + cg.setColor( QColorGroup::Midlight, QColor( 242, 242, 242) ); + cg.setColor( QColorGroup::Dark, QColor( 78, 78, 78) ); + cg.setColor( QColorGroup::Mid, QColor( 183, 183, 183) ); + cg.setColor( QColorGroup::Text, black ); + cg.setColor( QColorGroup::BrightText, white ); + cg.setColor( QColorGroup::ButtonText, black ); + cg.setColor( QColorGroup::Base, white ); + cg.setColor( QColorGroup::Background, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Shadow, black ); + cg.setColor( QColorGroup::Highlight, QColor( 10, 95, 137) ); + cg.setColor( QColorGroup::HighlightedText, white ); + pal.setInactive( cg ); + cg.setColor( QColorGroup::Foreground, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Button, QColor( 228, 228, 228) ); + cg.setColor( QColorGroup::Light, white ); + cg.setColor( QColorGroup::Midlight, white ); + cg.setColor( QColorGroup::Dark, QColor( 114, 114, 114) ); + cg.setColor( QColorGroup::Mid, QColor( 152, 152, 152) ); + cg.setColor( QColorGroup::Text, black ); + cg.setColor( QColorGroup::BrightText, white ); + cg.setColor( QColorGroup::ButtonText, black ); + cg.setColor( QColorGroup::Base, white ); + cg.setColor( QColorGroup::Background, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Shadow, black ); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, white ); + pal.setDisabled( cg ); + display->setPalette( pal ); + display->setEchoMode( QLineEdit::Password ); + + button_1 = new QLabel( this, "button_1" ); + button_1->setGeometry( QRect( 11, 88, 68, 44 ) ); + button_1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_1->sizePolicy().hasHeightForWidth() ) ); + button_1->setFrameShape( QLabel::Box ); + button_1->setFrameShadow( QLabel::Raised ); + button_1->setText( tr( "1" ) ); + button_1->setAlignment( int( QLabel::AlignCenter ) ); + + button_2 = new QLabel( this, "button_2" ); + button_2->setGeometry( QRect( 85, 88, 69, 44 ) ); + button_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_2->sizePolicy().hasHeightForWidth() ) ); + button_2->setFrameShape( QLabel::Box ); + button_2->setFrameShadow( QLabel::Raised ); + button_2->setText( tr( "2" ) ); + button_2->setAlignment( int( QLabel::AlignCenter ) ); + + button_5 = new QLabel( this, "button_5" ); + button_5->setGeometry( QRect( 85, 138, 69, 44 ) ); + button_5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_5->sizePolicy().hasHeightForWidth() ) ); + button_5->setFrameShape( QLabel::Box ); + button_5->setFrameShadow( QLabel::Raised ); + button_5->setText( tr( "5" ) ); + button_5->setAlignment( int( QLabel::AlignCenter ) ); + + button_6 = new QLabel( this, "button_6" ); + button_6->setGeometry( QRect( 160, 138, 68, 44 ) ); + button_6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_6->sizePolicy().hasHeightForWidth() ) ); + button_6->setFrameShape( QLabel::Box ); + button_6->setFrameShadow( QLabel::Raised ); + button_6->setText( tr( "6" ) ); + button_6->setAlignment( int( QLabel::AlignCenter ) ); + + button_3 = new QLabel( this, "button_3" ); + button_3->setGeometry( QRect( 160, 88, 68, 44 ) ); + button_3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_3->sizePolicy().hasHeightForWidth() ) ); + button_3->setFrameShape( QLabel::Box ); + button_3->setFrameShadow( QLabel::Raised ); + button_3->setText( tr( "3" ) ); + button_3->setAlignment( int( QLabel::AlignCenter ) ); + + button_0 = new QLabel( this, "button_0" ); + button_0->setGeometry( QRect( 11, 238, 68, 44 ) ); + button_0->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_0->sizePolicy().hasHeightForWidth() ) ); + button_0->setFrameShape( QLabel::Box ); + button_0->setFrameShadow( QLabel::Raised ); + button_0->setText( tr( "0" ) ); + button_0->setAlignment( int( QLabel::AlignCenter ) ); + + button_8 = new QLabel( this, "button_8" ); + button_8->setGeometry( QRect( 85, 188, 69, 44 ) ); + button_8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_8->sizePolicy().hasHeightForWidth() ) ); + button_8->setFrameShape( QLabel::Box ); + button_8->setFrameShadow( QLabel::Raised ); + button_8->setText( tr( "8" ) ); + button_8->setAlignment( int( QLabel::AlignCenter ) ); + + button_9 = new QLabel( this, "button_9" ); + button_9->setGeometry( QRect( 160, 188, 68, 44 ) ); + button_9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_9->sizePolicy().hasHeightForWidth() ) ); + button_9->setFrameShape( QLabel::Box ); + button_9->setFrameShadow( QLabel::Raised ); + button_9->setText( tr( "9" ) ); + button_9->setAlignment( int( QLabel::AlignCenter ) ); + + button_OK = new QLabel( this, "button_OK" ); + button_OK->setGeometry( QRect( 160, 238, 68, 44 ) ); + button_OK->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_OK->sizePolicy().hasHeightForWidth() ) ); + cg.setColor( QColorGroup::Foreground, black ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, white ); + cg.setColor( QColorGroup::Midlight, QColor( 223, 223, 223) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, black ); + cg.setColor( QColorGroup::BrightText, white ); + cg.setColor( QColorGroup::ButtonText, black ); + cg.setColor( QColorGroup::Base, white ); + cg.setColor( QColorGroup::Background, QColor( 0, 170, 0) ); + cg.setColor( QColorGroup::Shadow, black ); + cg.setColor( QColorGroup::Highlight, black ); + cg.setColor( QColorGroup::HighlightedText, white ); + pal.setActive( cg ); + cg.setColor( QColorGroup::Foreground, black ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, white ); + cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, black ); + cg.setColor( QColorGroup::BrightText, white ); + cg.setColor( QColorGroup::ButtonText, black ); + cg.setColor( QColorGroup::Base, white ); + cg.setColor( QColorGroup::Background, QColor( 0, 170, 0) ); + cg.setColor( QColorGroup::Shadow, black ); + cg.setColor( QColorGroup::Highlight, black ); + cg.setColor( QColorGroup::HighlightedText, white ); + pal.setInactive( cg ); + cg.setColor( QColorGroup::Foreground, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, white ); + cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, black ); + cg.setColor( QColorGroup::BrightText, white ); + cg.setColor( QColorGroup::ButtonText, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Base, white ); + cg.setColor( QColorGroup::Background, QColor( 0, 170, 0) ); + cg.setColor( QColorGroup::Shadow, black ); + cg.setColor( QColorGroup::Highlight, black ); + cg.setColor( QColorGroup::HighlightedText, white ); + pal.setDisabled( cg ); + button_OK->setPalette( pal ); + button_OK->setFrameShape( QLabel::Box ); + button_OK->setFrameShadow( QLabel::Raised ); + button_OK->setText( tr( "Enter" ) ); + button_OK->setAlignment( int( QLabel::AlignCenter ) ); + + button_Skip = new QLabel( this, "button_Skip" ); + button_Skip->setGeometry( QRect( 85, 238, 69, 44 ) ); + button_Skip->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, button_Skip->sizePolicy().hasHeightForWidth() ) ); + cg.setColor( QColorGroup::Foreground, black ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, white ); + cg.setColor( QColorGroup::Midlight, QColor( 223, 223, 223) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, black ); + cg.setColor( QColorGroup::BrightText, white ); + cg.setColor( QColorGroup::ButtonText, black ); + cg.setColor( QColorGroup::Base, white ); + cg.setColor( QColorGroup::Background, QColor( 255, 255, 127) ); + cg.setColor( QColorGroup::Shadow, black ); + cg.setColor( QColorGroup::Highlight, black ); + cg.setColor( QColorGroup::HighlightedText, white ); + pal.setActive( cg ); + cg.setColor( QColorGroup::Foreground, black ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, white ); + cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, black ); + cg.setColor( QColorGroup::BrightText, white ); + cg.setColor( QColorGroup::ButtonText, black ); + cg.setColor( QColorGroup::Base, white ); + cg.setColor( QColorGroup::Background, QColor( 255, 255, 127) ); + cg.setColor( QColorGroup::Shadow, black ); + cg.setColor( QColorGroup::Highlight, black ); + cg.setColor( QColorGroup::HighlightedText, white ); + pal.setInactive( cg ); + cg.setColor( QColorGroup::Foreground, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, white ); + cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, black ); + cg.setColor( QColorGroup::BrightText, white ); + cg.setColor( QColorGroup::ButtonText, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Base, white ); + cg.setColor( QColorGroup::Background, QColor( 255, 255, 127) ); + cg.setColor( QColorGroup::Shadow, black ); + cg.setColor( QColorGroup::Highlight, black ); + cg.setColor( QColorGroup::HighlightedText, white ); + pal.setDisabled( cg ); + button_Skip->setPalette( pal ); + button_Skip->setFrameShape( QLabel::Box ); + button_Skip->setFrameShadow( QLabel::Raised ); + button_Skip->setText( tr( "Skip" ) ); + button_Skip->setAlignment( int( QLabel::AlignCenter ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +PinDialogBase::~PinDialogBase() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * Main event handler. Reimplemented to handle application + * font changes + */ +bool PinDialogBase::event( QEvent* ev ) +{ + bool ret = QWidget::event( ev ); + if ( ev->type() == QEvent::ApplicationFontChange ) { + QFont prompt_font( prompt->font() ); + prompt_font.setPointSize( 18 ); + prompt->setFont( prompt_font ); + } + return ret; +} + diff --git a/noncore/securityplugins/pin/pinDialogBase.h b/noncore/securityplugins/pin/pinDialogBase.h new file mode 100644 index 0000000..3ed2b63 --- a/dev/null +++ b/noncore/securityplugins/pin/pinDialogBase.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'pinDialogBase.ui' +** +** Created: Mon Jun 14 11:00:59 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef PINDIALOGBASE_H +#define PINDIALOGBASE_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QLabel; +class QLineEdit; + +class PinDialogBase : public QWidget +{ + Q_OBJECT + +public: + PinDialogBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~PinDialogBase(); + + QLabel* button_4; + QLabel* button_7; + QLabel* prompt; + QLineEdit* display; + QLabel* button_1; + QLabel* button_2; + QLabel* button_5; + QLabel* button_6; + QLabel* button_3; + QLabel* button_0; + QLabel* button_8; + QLabel* button_9; + QLabel* button_OK; + QLabel* button_Skip; + +protected: + bool event( QEvent* ); +}; + +#endif // PINDIALOGBASE_H diff --git a/noncore/securityplugins/pin/pinDialogBase.ui b/noncore/securityplugins/pin/pinDialogBase.ui new file mode 100644 index 0000000..79e7a55 --- a/dev/null +++ b/noncore/securityplugins/pin/pinDialogBase.ui @@ -0,0 +1,1258 @@ + +PinDialogBase + + QWidget + + name + PinDialogBase + + + geometry + + 0 + 0 + 231 + 293 + + + + font + + 24 + + + + caption + PinDialogBase + + + QLabel + + name + button_4 + + + geometry + + 11 + 138 + 68 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 4 + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + button_7 + + + geometry + + 11 + 188 + 68 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 7 + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + prompt + + + geometry + + 11 + 11 + 217 + 25 + + + + font + + 18 + + + + text + Enter your PIN + + + + QLineEdit + + name + display + + + enabled + false + + + geometry + + 11 + 42 + 217 + 40 + + + + palette + + + + 0 + 0 + 0 + + + 228 + 228 + 228 + + + 255 + 255 + 255 + + + 242 + 242 + 242 + + + 78 + 78 + 78 + + + 183 + 183 + 183 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + + + 128 + 128 + 128 + + + 228 + 228 + 228 + + + 255 + 255 + 255 + + + 255 + 255 + 255 + + + 114 + 114 + 114 + + + 152 + 152 + 152 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 0 + 0 + 128 + + + 255 + 255 + 255 + + + + + 0 + 0 + 0 + + + 228 + 228 + 228 + + + 255 + 255 + 255 + + + 242 + 242 + 242 + + + 78 + 78 + 78 + + + 183 + 183 + 183 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 10 + 95 + 137 + + + 255 + 255 + 255 + + + + + + echoMode + Password + + + + QLabel + + name + button_1 + + + geometry + + 11 + 88 + 68 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 1 + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + button_2 + + + geometry + + 85 + 88 + 69 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 2 + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + button_5 + + + geometry + + 85 + 138 + 69 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 5 + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + button_6 + + + geometry + + 160 + 138 + 68 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 6 + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + button_3 + + + geometry + + 160 + 88 + 68 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 3 + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + button_0 + + + geometry + + 11 + 238 + 68 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 0 + + + alignment + AlignCenter + + + hAlign + + + layoutMargin + + + layoutSpacing + + + + QLabel + + name + button_8 + + + geometry + + 85 + 188 + 69 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 8 + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + button_9 + + + geometry + + 160 + 188 + 68 + 44 + + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Raised + + + text + 9 + + + alignment + AlignCenter + + + hAlign + + + layoutMargin + + + layoutSpacing + + + + QLabel + + name + button_OK + + + geometry + + 160 + 238 + 68 + 44 + + + + sizePolicy + + 5 + 5 + + + + palette + + + + 0 + 0 + 0 + + + 192 + 192 + 192 + + + 255 + 255 + 255 + + + 223 + 223 + 223 + + + 96 + 96 + 96 + + + 128 + 128 + 128 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 170 + 0 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + + + 128 + 128 + 128 + + + 192 + 192 + 192 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 96 + 96 + 96 + + + 128 + 128 + 128 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 128 + 128 + 128 + + + 255 + 255 + 255 + + + 0 + 170 + 0 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + + + 0 + 0 + 0 + + + 192 + 192 + 192 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 96 + 96 + 96 + + + 128 + 128 + 128 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 170 + 0 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + + + + frameShape + Box + + + frameShadow + Raised + + + text + Enter + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + button_Skip + + + geometry + + 85 + 238 + 69 + 44 + + + + sizePolicy + + 5 + 5 + + + + palette + + + + 0 + 0 + 0 + + + 192 + 192 + 192 + + + 255 + 255 + 255 + + + 223 + 223 + 223 + + + 96 + 96 + 96 + + + 128 + 128 + 128 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 255 + 255 + 127 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + + + 128 + 128 + 128 + + + 192 + 192 + 192 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 96 + 96 + 96 + + + 128 + 128 + 128 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 128 + 128 + 128 + + + 255 + 255 + 255 + + + 255 + 255 + 127 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + + + 0 + 0 + 0 + + + 192 + 192 + 192 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 96 + 96 + 96 + + + 128 + 128 + 128 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 255 + 255 + 127 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + + + + frameShape + Box + + + frameShadow + Raised + + + text + Skip + + + alignment + AlignCenter + + + hAlign + + + + diff --git a/noncore/securityplugins/pin/pinplugin.pro b/noncore/securityplugins/pin/pinplugin.pro new file mode 100644 index 0000000..d066805 --- a/dev/null +++ b/noncore/securityplugins/pin/pinplugin.pro @@ -0,0 +1,21 @@ +VERSION = 0.0.2 +TEMPLATE = lib +CONFIG += qt warn_on + +HEADERS = pin.h pinpluginimpl.h pinConfigWidget.h + +INTERFACES = pinDialogBase.ui + +SOURCES = pin.cpp pinpluginimpl.cpp pinConfigWidget.cpp + + +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += + +LIBS += -lqpe -lopieui2 + +DESTDIR = $(OPIEDIR)/plugins/security +TARGET = multiauthpinplugin + +include ( $(OPIEDIR)/include.pro ) + diff --git a/noncore/securityplugins/pin/pinpluginimpl.cpp b/noncore/securityplugins/pin/pinpluginimpl.cpp new file mode 100644 index 0000000..1c32f81 --- a/dev/null +++ b/noncore/securityplugins/pin/pinpluginimpl.cpp @@ -0,0 +1,28 @@ +#include "pinpluginimpl.h" + +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 new file mode 100644 index 0000000..e604b64 --- a/dev/null +++ b/noncore/securityplugins/pin/pinpluginimpl.h @@ -0,0 +1,58 @@ +/** + * \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 + .>+-= + _;:, .> :=|. 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_,=:_. -`: 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{ + + public: + PinPluginImpl(); + virtual ~PinPluginImpl(); + + QRESULT queryInterface( const QUuid &, QUnknownInterface** ); + // defines standard addRef() and release() functions + Q_REFCOUNT; + + virtual MultiauthPluginObject *plugin(); + + private: + /// the plugin itself + PinPlugin *pinPlugin; + ulong ref; +}; + +#endif -- cgit v0.9.0.2