summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/lockapplet/.cvsignore4
-rw-r--r--core/applets/lockapplet/config.in4
-rw-r--r--core/applets/lockapplet/lock.cpp84
-rw-r--r--core/applets/lockapplet/lock.h36
-rw-r--r--core/applets/lockapplet/lockapplet.pro12
-rw-r--r--core/applets/lockapplet/opie-lockapplet.control11
-rw-r--r--core/launcher/serverapp.cpp3
-rw-r--r--core/settings/security/demo/main.cpp2
-rw-r--r--core/settings/security/multiauthconfig.cpp20
-rw-r--r--libopie2/opiesecurity/multiauthpassword.cpp47
-rw-r--r--libopie2/opiesecurity/multiauthpassword.h10
-rw-r--r--packages1
-rw-r--r--pics/security/lock.pngbin0 -> 419 bytes
13 files changed, 206 insertions, 28 deletions
diff --git a/core/applets/lockapplet/.cvsignore b/core/applets/lockapplet/.cvsignore
new file mode 100644
index 0000000..5e2908c
--- a/dev/null
+++ b/core/applets/lockapplet/.cvsignore
@@ -0,0 +1,4 @@
+Makefile*
+.moc
+.obj
+
diff --git a/core/applets/lockapplet/config.in b/core/applets/lockapplet/config.in
new file mode 100644
index 0000000..ddc3522
--- a/dev/null
+++ b/core/applets/lockapplet/config.in
@@ -0,0 +1,4 @@
+ config LOCKAPPLET
+ boolean "opie-lockapplet (button in the Opie menu to lock the PDA)"
+ default "y"
+ depends ( LIBQPE || LIBQPE-X11 ) && SECURITY
diff --git a/core/applets/lockapplet/lock.cpp b/core/applets/lockapplet/lock.cpp
new file mode 100644
index 0000000..89f27bb
--- a/dev/null
+++ b/core/applets/lockapplet/lock.cpp
@@ -0,0 +1,84 @@
+#include "lock.h"
+
+/* OPIE */
+#include <opie2/multiauthpassword.h>
+
+#include <qpe/applnk.h>
+#include <qpe/resource.h>
+
+/* QT */
+#include <qiconset.h>
+#include <qpopupmenu.h>
+#include <qmessagebox.h>
+
+
+LockMenuApplet::LockMenuApplet()
+ :QObject( 0, "LockMenuApplet" )
+{
+}
+
+LockMenuApplet::~LockMenuApplet ( )
+{}
+
+int LockMenuApplet::position() const
+{
+ return 3;
+}
+
+QString LockMenuApplet::name() const
+{
+ return tr( "Lock shortcut" );
+}
+
+QString LockMenuApplet::text() const
+{
+ return tr( "Lock" );
+}
+
+
+QIconSet LockMenuApplet::icon() const
+{
+ QPixmap pix;
+ QImage img = Resource::loadImage( "security/lock" );
+ if ( !img.isNull() )
+ pix.convertFromImage( img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
+ return pix;
+}
+
+QPopupMenu* LockMenuApplet::popup(QWidget*) const
+{
+ /* no subdir */
+ return 0;
+}
+
+void LockMenuApplet::activated()
+{
+ /*
+ QMessageBox::information(0,tr("No white rabbit found"),
+ tr("<qt>No white rabbit was seen near Opie."
+ "Only the beautiful OpieZilla is available"
+ "for your pleassure</qt>"));
+ */
+ Opie::Security::MultiauthPassword::authenticate(Opie::Security::LockNow);
+}
+
+
+QRESULT LockMenuApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_MenuApplet )
+ *iface = this;
+ else
+ return QS_FALSE;
+
+ if ( *iface )
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( LockMenuApplet )
+}
diff --git a/core/applets/lockapplet/lock.h b/core/applets/lockapplet/lock.h
new file mode 100644
index 0000000..ff94bce
--- a/dev/null
+++ b/core/applets/lockapplet/lock.h
@@ -0,0 +1,36 @@
+/**
+ * \file lock.h
+ * \brief defines a lock button that goes in the 'O' Opie menu
+ * It's based on the examples/menuapplet code of 2004/10/06.
+ */
+#ifndef CORE_SETTINGS_SECURITY_LOCKAPPLET_LOCK_H
+#define CORE_SETTINGS_SECURITY_LOCKAPPLET_LOCK_H
+
+#include <qpe/menuappletinterface.h>
+#include <qobject.h>
+
+class LockMenuApplet: public QObject, public MenuAppletInterface
+{
+
+ Q_OBJECT
+
+public:
+ LockMenuApplet ( );
+ virtual ~LockMenuApplet ( );
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+
+ virtual int position() const;
+
+ virtual QString name ( ) const;
+ virtual QIconSet icon ( ) const;
+ virtual QString text ( ) const;
+ /* virtual QString tr( const char* ) const;
+ virtual QString tr( const char*, const char* ) const;
+ */
+ virtual QPopupMenu *popup ( QWidget *parent ) const;
+ virtual void activated ( );
+};
+
+#endif
diff --git a/core/applets/lockapplet/lockapplet.pro b/core/applets/lockapplet/lockapplet.pro
new file mode 100644
index 0000000..e0ee780
--- a/dev/null
+++ b/core/applets/lockapplet/lockapplet.pro
@@ -0,0 +1,12 @@
+TEMPLATE = lib
+CONFIG += qt plugn warn_on
+HEADERS = lock.h
+SOURCES = lock.cpp
+TARGET = lockapplet
+DESTDIR = $(OPIEDIR)/plugins/applets
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe
+VERSION = 1.0.0
+
+include ( $(OPIEDIR)/include.pro )
diff --git a/core/applets/lockapplet/opie-lockapplet.control b/core/applets/lockapplet/opie-lockapplet.control
new file mode 100644
index 0000000..e175a3e
--- a/dev/null
+++ b/core/applets/lockapplet/opie-lockapplet.control
@@ -0,0 +1,11 @@
+Package: opie-lockapplet
+Files: plugins/applets/liblockapplet.so*
+Priority: optional
+Section: opie/applets
+Maintainer: Opie Team <opie@handhelds.org>
+Architecture: arm
+Depends: task-opie-minimal, opie-security
+Description: Lock Opie now
+ Button to lock Opie (as configured in the Security
+ settings) on demand.
+Version: $QPE_VERSION$EXTRAVERSION
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp
index dc1f2c7..e541d10 100644
--- a/core/launcher/serverapp.cpp
+++ b/core/launcher/serverapp.cpp
@@ -417,193 +417,194 @@ void ServerApplication::apmTimeout()
battlow.exec();
}
}
void ServerApplication::systemMessage( const QCString& msg,
const QByteArray& data )
{
QDataStream stream ( data, IO_ReadOnly );
if ( msg == "setScreenSaverInterval(int)" ) {
int time;
stream >> time;
m_screensaver-> setInterval( time );
}
else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
int t1, t2, t3;
stream >> t1 >> t2 >> t3;
m_screensaver-> setIntervals( t1, t2, t3 );
}
else if ( msg == "setBacklight(int)" ) {
int bright;
stream >> bright;
m_screensaver-> setBacklight( bright );
}
else if ( msg == "setScreenSaverMode(int)" ) {
int mode;
stream >> mode;
m_screensaver-> setMode ( mode );
}
else if ( msg == "reloadPowerWarnSettings()" ) {
reloadPowerWarnSettings();
}
else if ( msg == "setDisplayState(int)" ) {
int state;
stream >> state;
m_screensaver-> setDisplayState ( state != 0 );
}
else if ( msg == "suspend()" ) {
emit power();
}
else if ( msg == "sendBusinessCard()" ) {
QString card = ::getenv ( "HOME" );
card += "/Applications/addressbook/businesscard.vcf";
if ( QFile::exists( card ) ) {
QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" );
QString mimetype = "text/x-vCard";
e << tr( "business card" ) << card << mimetype;
}
}
}
void ServerApplication::reloadPowerWarnSettings ( )
{
Config cfg ( "apm" );
cfg. setGroup ( "Warnings" );
int iv = cfg. readNumEntry ( "checkinterval", 10000 );
m_apm_timer-> stop ( );
if ( iv )
m_apm_timer-> start ( iv );
m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 );
m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 );
}
void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data )
{
QDataStream stream ( data, IO_ReadOnly );
if ( msg == "deviceButton(int,int,int)" ) {
int keycode, press, autoRepeat;
stream >> keycode >> press >> autoRepeat;
kf->checkButtonAction ( true, keycode, press, autoRepeat );
}
else if ( msg == "keyRegister(int,QCString,QCString)" ) {
int k;
QCString c, m;
stream >> k >> c >> m;
kf -> registerKey( QCopKeyRegister(k, c, m) );
}
}
bool ServerApplication::screenLocked()
{
return loggedin == 0;
}
void ServerApplication::login(bool at_poweron)
{
if ( !loggedin ) {
Global::terminateBuiltin("calibrate"); // No tr
- Opie::Security::MultiauthPassword::authenticate(at_poweron);
+ int lockMode = at_poweron ? Opie::Security::IfPowerOn : Opie::Security::IfResume;
+ Opie::Security::MultiauthPassword::authenticate(lockMode);
loggedin=1;
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/Desktop", "unlocked()" );
#endif
}
}
#if defined(QPE_HAVE_TOGGLELIGHT)
#include <qtopia/config.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <linux/ioctl.h>
#include <time.h>
#endif
namespace {
void execAutoStart(const QDateTime& suspendTime ) {
QString appName;
int delay;
QDateTime now = QDateTime::currentDateTime();
Config cfg( "autostart" );
cfg.setGroup( "AutoStart" );
appName = cfg.readEntry( "Apps", "" );
delay = cfg.readNumEntry( "Delay", 0 );
// If the time between suspend and resume was longer then the
// value saved as delay, start the app
if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
QCopEnvelope e( "QPE/System", "execute(QString)" );
e << QString( appName );
}
}
}
void ServerApplication::togglePower()
{
static bool excllock = false;
if ( excllock )
return ;
excllock = true;
bool wasloggedin = loggedin;
loggedin = 0;
m_suspendTime = QDateTime::currentDateTime();
#ifdef QWS
if ( Opie::Security::MultiauthPassword::needToAuthenticate ( true ) && qt_screen ) {
// Should use a big black window instead.
// But this would not show up fast enough
QGfx *g = qt_screen-> screenGfx ( );
g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
delete g;
}
#endif
ODevice::inst ( )-> suspend ( );
ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call
QWSServer::screenSaverActivate ( false );
{
QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
}
if ( wasloggedin )
login ( true );
execAutoStart(m_suspendTime);
//qcopBridge->closeOpenConnections();
excllock = false;
}
void ServerApplication::toggleLight()
{
#ifndef QT_NO_COP
QCopEnvelope e("QPE/System", "setBacklight(int)");
e << -2; // toggle
#endif
}
/*
* We still listen to key events but handle them in
* a special class
*/
bool ServerApplication::eventFilter( QObject *o, QEvent *e) {
diff --git a/core/settings/security/demo/main.cpp b/core/settings/security/demo/main.cpp
index 1c49f57..82f940d 100644
--- a/core/settings/security/demo/main.cpp
+++ b/core/settings/security/demo/main.cpp
@@ -1,12 +1,12 @@
#include <opie2/multiauthpassword.h>
#include <opie2/oapplication.h>
/// Run an authentication sequence using the global opie-security settings
int main( int argc, char ** argv )
{
Opie::Core::OApplication app(argc, argv, "Multi-authentication demo");
// Run the authentication process until it succeeds
- Opie::Security::MultiauthPassword::authenticate();
+ Opie::Security::MultiauthPassword::authenticate(Opie::Security::LockNow);
}
diff --git a/core/settings/security/multiauthconfig.cpp b/core/settings/security/multiauthconfig.cpp
index 192b8ca..9d5c032 100644
--- a/core/settings/security/multiauthconfig.cpp
+++ b/core/settings/security/multiauthconfig.cpp
@@ -1,235 +1,221 @@
#include <opie2/odebug.h>
-#include <opie2/multiauthmainwindow.h>
+#include <opie2/multiauthpassword.h>
#include <qgroupbox.h>
#include <qvgroupbox.h>
#include <qpe/resource.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qheader.h>
#include <qvbox.h>
#include <qwhatsthis.h>
#include <qtoolbutton.h>
#include <qstringlist.h>
#include <qdir.h>
#include <qpe/qlibrary.h>
#include <qpe/qpeapplication.h>
#include "multiauthconfig.h"
using Opie::Security::MultiauthPluginInterface;
using Opie::Security::MultiauthPluginObject;
using Opie::Security::MultiauthConfigWidget;
/// keeps information about MultiauthPluginObject plugins
struct MultiauthPlugin {
MultiauthPlugin() : library( 0 ), iface( 0 ), pluginObject( 0 ) {}
/// plugin file
QLibrary *library;
/// the plugin object interface
QInterfacePtr<MultiauthPluginInterface> iface;
/// the plugin object itself
MultiauthPluginObject *pluginObject;
/// name of the plugin file
QString name;
/// should the plugin be launched during authentication or not
bool active;
/// order of the plugin, in the pluginListWidget and during authentication
int pos;
};
/// list of available MultiauthPlugin objects
static QValueList<MultiauthPlugin> pluginList;
/// extension of QToolButton that adds signals, icons and stuff (taken from todayconfig.cpp)
class ToolButton : public QToolButton {
public:
ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
: QToolButton( parent, name ) {
setPixmap( Resource::loadPixmap( icon ) );
setAutoRaise( TRUE );
setFocusPolicy( QWidget::NoFocus );
setToggleButton( t );
connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
}
};
MultiauthGeneralConfig::MultiauthGeneralConfig(MultiauthConfig * parentConfig, QWidget * parent, const char * name = "general Opie-multiauthentication config widget")
: QWidget(parent, name), m_onStart(0), m_onResume(0), m_noProtectConfig(0), m_explanScreens(0), m_nbSuccessMin(0), m_tryButton(0)
{
// keep track of the MultiauthConfig parent in one of our attributes
m_parentConfig = parentConfig;
QVBoxLayout *vb = new QVBoxLayout(this);
vb->setSpacing(11);
vb->setMargin(11);
vb->setAlignment( Qt::AlignTop );
QGroupBox *lockBox = new QGroupBox(0, Qt::Vertical, tr("When to lock Opie"), this, "lock box");
vb->addWidget(lockBox);
QGridLayout *boxLayout = new QGridLayout( lockBox->layout() );
m_onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start");
m_onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume");
boxLayout->addWidget(m_onStart, 0, 0);
boxLayout->addWidget(m_onResume, 0, 1);
QGroupBox *nbBox = new QGroupBox(0, Qt::Vertical, tr("Multiple plugins authentication"), this, "nb box");
vb->addWidget(nbBox);
QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() );
m_nbSuccessMin = new QSpinBox(nbBox);
QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox);
nbBoxLayout->addWidget(m_nbSuccessMin, 0, 0);
nbBoxLayout->addWidget(lNbSuccessMin, 0, 1);
m_nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor
QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Options"), this, "dev box");
vb->addWidget(devBox);
QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() );
m_noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config");
m_explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens");
devBoxLayout->addWidget(m_noProtectConfig, 0, 0);
devBoxLayout->addWidget(m_explanScreens, 1, 0);
QVGroupBox *tryBox = new QVGroupBox(tr("Testing"), this, "try box");
vb->addWidget(tryBox);
m_tryButton = new QPushButton( tr("Test the authentication now"), tryBox, "try button");
connect( m_tryButton, SIGNAL(clicked()), this, SLOT(tryAuth()) );
}
/// nothing to do
MultiauthGeneralConfig::~MultiauthGeneralConfig()
{}
/// launches the authentication process, as configured, with the option to bypass it
void MultiauthGeneralConfig::tryAuth()
{
QMessageBox confirmSave(
tr("Attention"),
"<p>" + tr("You must save your current settings before trying to authenticate. Press OK to accept and launch a simulated authentication process.") + "</p><p><em>" +
tr("If you don't like the result of this test, don't forget to change your settings before you exit the configuration application!") + "</em></p>",
QMessageBox::Warning,
QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
0, QString::null, TRUE, WStyle_StaysOnTop);
confirmSave.setButtonText(QMessageBox::Cancel, tr("Cancel"));
confirmSave.setButtonText(QMessageBox::Yes, tr("OK"));
if ( confirmSave.exec() == QMessageBox::Yes)
{
owarn << "writing config as user accepted" << oendl;
m_parentConfig->writeConfigs();
owarn << "testing authentication" << oendl;
-
- /* launch the authentication in debug, aka "allowBypass == true", mode
- */
-
- Opie::Security::MultiauthMainWindow win(true);
- // resize the QDialog object so it fills all the screen
- QRect desk = qApp->desktop()->geometry();
- win.setGeometry( 0, 0, desk.width(), desk.height() );
-
- // the authentication has already succeeded (without win interactions)
- if ( win.isAlreadyDone() )
- return;
-
- win.exec();
-
- }
+ // launch the authentication in testing mode
+ Opie::Security::MultiauthPassword::authenticate(Opie::Security::TestNow);
}
/// Builds and displays the Opie multi-authentication configuration dialog
static void test_and_start() {
Config pcfg("Security");
pcfg.setGroup( "Misc" );
bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true);
if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) {
owarn << "authentication failed, not showing opie-security" << oendl;
exit( -1 );
}
}
MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0)
: QDialog(par, w, TRUE, f),
m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0),
m_generalConfig(0), m_loginWidget(0), m_syncWidget(0),
m_nbSuccessReq(0), m_plugins_changed(false)
{
/* Initializes the global configuration window
*/
test_and_start();
/* Checks (and memorizes) if any authentication plugins are
* installed on the system
*/
QString path = QPEApplication::qpeDir() + "/plugins/security";
QDir dir( path, "lib*.so" );
QStringList list = dir.entryList();
m_pluginsInstalled = ! list.isEmpty();
if (m_pluginsInstalled == false)
owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl;
setCaption( tr( "Security configuration" ) );
QVBoxLayout *layout = new QVBoxLayout( this );
m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" );
layout->addWidget(m_mainTW);
if (m_pluginsInstalled)
{
m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget");
QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
pluginListLayout->setSpacing(6);
pluginListLayout->setMargin(11);
QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget );
pluginListLayout->addWidget(pluginListTitle);
QHBox * pluginListHB = new QHBox(m_pluginListWidget);
pluginListLayout->addWidget(pluginListHB);
m_pluginListView = new QListView(pluginListHB);
m_pluginListView->addColumn("PluginList");
m_pluginListView->header()->hide();
m_pluginListView->setSorting(-1);
QWhatsThis::add(m_pluginListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the order they will appear in" ));
QVBox * pluginListVB = new QVBox(pluginListHB);
new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) );
connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) );
// general Opie multi-authentication configuration tab
m_generalConfig = new MultiauthGeneralConfig(this, m_mainTW);
m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") );
}
// login settings page
m_loginWidget = new LoginBase(m_mainTW, "login config widget");
m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") );
// sync settings page
m_syncWidget = new SyncBase( m_mainTW, "sync config widget" );
m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") );
// read the "Security" Config file and update our UI
readConfig();
if (m_pluginsInstalled)
{
/* loads plugins configuration widgets in mainTW tabs and in pluginListView
*/
loadPlugins();
for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
MultiauthPlugin plugin = pluginList[i];
// load the config widgets in the tabs
diff --git a/libopie2/opiesecurity/multiauthpassword.cpp b/libopie2/opiesecurity/multiauthpassword.cpp
index 42341f7..8eda554 100644
--- a/libopie2/opiesecurity/multiauthpassword.cpp
+++ b/libopie2/opiesecurity/multiauthpassword.cpp
@@ -1,105 +1,138 @@
/**
* \file multiauthpassword.cpp
* \brief Password Dialog dropin.
* \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
*/
/*
=. This file is part of the Opie Project
.=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
.>+-=
_;:, .> :=|. This library is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This library is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/multiauthcommon.h>
#include <opie2/multiauthmainwindow.h>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/qcom.h>
/* QT */
#include <qapplication.h>
#include <qvbox.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qdir.h>
#include "multiauthpassword.h"
namespace Opie {
namespace Security {
/**
- * If the users requires authentication... #fixme
+ * Tells if the users requires authentication (used internally to
+ * know whether to repaint the screen on resume)
*
- * @todo fix up at_poweron attribute
+ * \param at_poweron true if we are booting Opie, false if we are resuming it
+ * \return true if authenticate() launched right now would trigger an authentication
*/
bool MultiauthPassword::needToAuthenticate(bool at_poweron)
{
Config cfg("Security");
cfg.setGroup("Misc");
if ( !at_poweron && cfg.readBoolEntry("onStart", false) )
return true;
else if ( at_poweron && cfg.readBoolEntry("onResume", false) )
return true;
else
return false;
}
+
/**
- * \brief Require user authentication to unlock and continue
+ * \brief Require (if configured so) user authentication to unlock and continue
*
* This method will check if you require authentication
* and then will lock the screen and ask for a successful
* authentication (explaining what it does or not, depending
* on your local configuration).
* It may go into an event loop, but anyhow it will only end
* when the user has successfully authenticated to the system.
*/
-void MultiauthPassword::authenticate(bool at_poweron)
+void MultiauthPassword::authenticate(int lockMode)
{
- if ( ! needToAuthenticate(at_poweron) )
- return;
+ /**
+ * \par Conditions
+ *
+ * If lockMode is an If, it's conditional:
+ * \li IfPowerOn will not trigger an authentication if
+ * onStart is set to false in Security.conf,
+ * \li IfResume will not trigger an authentication if
+ * onResume is set to false in Security.conf.
+ */
+ if ( (lockMode == IfPowerOn) || (lockMode == IfResume) )
+ {
+ Config cfg("Security");
+ cfg.setGroup("Misc");
+ if ( (
+ (lockMode == IfPowerOn) && cfg.readBoolEntry("onStart", false)
+ ) || (
+ (lockMode == IfResume) && cfg.readBoolEntry("onResume", false)
+ ) )
+ return;
+ }
+
+ /**
+ * \li TestNow will ensure that the authentication window will let
+ * people escape through the last screen (which they can reach skipping
+ * all the authentication steps)
+ * \li LockNow will always go on with the authentication, and won't let
+ * people escape.
+ */
+ bool allowByPass = false;
+
+ if (lockMode == TestNow)
+ allowByPass = true;
/* Constructs the main window, which displays messages and blocks
* access to the desktop
*/
- MultiauthMainWindow win;
+ MultiauthMainWindow win(allowByPass);
// resize the QDialog object so it fills all the screen
QRect desk = qApp->desktop()->geometry();
win.setGeometry( 0, 0, desk.width(), desk.height() );
// the authentication has already succeeded (without win interactions)
if ( win.isAlreadyDone() )
return;
win.exec();
}
}
}
diff --git a/libopie2/opiesecurity/multiauthpassword.h b/libopie2/opiesecurity/multiauthpassword.h
index fe276da..effdaa1 100644
--- a/libopie2/opiesecurity/multiauthpassword.h
+++ b/libopie2/opiesecurity/multiauthpassword.h
@@ -1,59 +1,65 @@
/**
* \file multiauthpassword.h
* \brief Password Dialog dropin.
* \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
*/
/*
=. This file is part of the Opie Project
.=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
.>+-=
_;:, .> :=|. This library is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This library is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OPIE_SEC_MULTIAUTHPASSWORD_H
#define OPIE_SEC_MULTIAUTHPASSWORD_H
namespace Opie {
namespace Security {
+enum lockMode {
+ IfPowerOn,
+ IfResume,
+ TestNow,
+ LockNow };
/**
* This is the dropin replacement for the libqpe Password class.
* If you call authenticate() a widget will cover the whole screen
* and only return if the user is able to authenticate with any of the
* configured Authentication Plugins.
* It uses the Opie::Security::MultiauthMainWindow QDialog internally.
*
* @author Clement Séveillac, Holger Freyther
*/
class MultiauthPassword {
+
public:
- static bool needToAuthenticate( bool atpoweron = false );
- static void authenticate(bool atpoweron = false);
+ static void authenticate(int authMode = LockNow);
+ static bool needToAuthenticate( bool atpoweron = false );
};
}
}
#endif
diff --git a/packages b/packages
index 275d2f9..dcbbe78 100644
--- a/packages
+++ b/packages
@@ -5,192 +5,193 @@ CONFIG_APPEARANCE2 noncore/settings/appearance2 appearance2.pro
CONFIG_APPLET_EXAMPLE examples/applet example.pro
CONFIG_APPSKEY noncore/settings/appskey appskey.pro
CONFIG_AQPKG noncore/settings/aqpkg aqpkg.pro
CONFIG_AUTOROTATEAPPLET noncore/applets/autorotateapplet autorotateapplet.pro
CONFIG_BACKGAMMON noncore/games/backgammon backgammon.pro
CONFIG_BACKUP noncore/settings/backup backup.pro
CONFIG_BARTENDER noncore/apps/opie-bartender bartender.pro
CONFIG_BATTERYAPPLET core/applets/batteryapplet batteryapplet.pro
CONFIG_BEND noncore/unsupported/mail2/bend bend.pro
CONFIG_BIGSCREEN_EXAMPLE libopie/big-screen/example osplitter_mail.pro
CONFIG_BINARY noncore/tools/calc2/binary binary.pro
CONFIG_BLUE-PIN noncore/net/opietooth/blue-pin blue-pin.pro
CONFIG_BOUNCE noncore/games/bounce bounce.pro
CONFIG_BRIGHTNESSAPPLET noncore/applets/brightnessapplet brightnessapplet.pro
CONFIG_BUTTON-SETTINGS core/settings/button button.pro
CONFIG_BUZZWORD noncore/games/buzzword buzzword.pro
CONFIG_CALC2 noncore/tools/calc2 calc.pro
CONFIG_CALCULATOR noncore/tools/calculator calculator.pro
CONFIG_CALIBRATE core/apps/calibrate calibrate.pro
CONFIG_CAMERA noncore/multimedia/camera camera.pro
CONFIG_CARDMON core/applets/cardmon cardmon.pro
CONFIG_CHECKBOOK noncore/apps/checkbook checkbook.pro
CONFIG_CITYTIME core/settings/citytime citytime.pro
CONFIG_CLIPBOARDAPPLET core/applets/clipboardapplet clipboardapplet.pro
CONFIG_CLOCKAPPLET core/applets/clockapplet clockapplet.pro
CONFIG_CLOCK noncore/tools/clock clock.pro
CONFIG_CONFEDIT noncore/apps/confedit confedit.pro
CONFIG_DAGGER noncore/apps/dagger dagger.pro
CONFIG_DASHER inputmethods/dasher dasher.pro
CONFIG_DATEBOOK2 core/pim/datebook2 datebook2.pro
CONFIG_DATEBOOK core/pim/datebook datebook.pro
CONFIG_DECO_FLAT noncore/decorations/flat flat.pro
CONFIG_DECO_LIQUID noncore/decorations/liquid liquid.pro
CONFIG_DECO_POLISHED noncore/decorations/polished polished.pro
CONFIG_DICTIONARY noncore/apps/dictionary dictionary.pro
CONFIG_DOCTAB noncore/settings/doctab doctab.pro
CONFIG_DRAWPAD noncore/graphics/drawpad drawpad.pro
CONFIG_DVORAK inputmethods/dvorak dvorak.pro
CONFIG_EMBEDDEDKONSOLE core/apps/embeddedkonsole embeddedkonsole.pro
CONFIG_EUROCONV noncore/tools/euroconv/ euroconv.pro
CONFIG_EXAMPLE_BOARD examples/inputmethod example.pro
CONFIG_EXAMPLE_MENU examples/menuapplet menuapplet.pro
CONFIG_EXAMPLE_VPN examples/networksettings example.pro
CONFIG_FIFTEEN noncore/games/fifteen fifteen.pro
CONFIG_FILEBROWSER noncore/unsupported/filebrowser filebrowser.pro
CONFIG_FLAT noncore/styles/flat flat.pro
CONFIG_FORMATTER noncore/tools/formatter formatter.pro
CONFIG_FREETYPE freetype freetype.pro
CONFIG_FRESH noncore/styles/fresh fresh.pro
CONFIG_FTPLIB noncore/net/ftplib ftplib.pro
CONFIG_GO noncore/games/go go.pro
CONFIG_GSMTOOL noncore/unsupported/gsmtool gsmtool.pro
CONFIG_GUTENBROWSER noncore/apps/opie-gutenbrowser opie-gutenbrowser.pro
CONFIG_HANDWRITING inputmethods/handwriting handwriting.pro
CONFIG_HELPBROWSER core/apps/helpbrowser helpbrowser.pro
CONFIG_HOMEAPPLET core/applets/homeapplet homeapplet.pro
CONFIG_INTERFACES noncore/settings/networksettings/interfaces interfaces.pro
CONFIG_IRDAAPPLET core/applets/irdaapplet irdaapplet.pro
CONFIG_JUMPX inputmethods/jumpx jumpx.pro
CONFIG_KBILL noncore/games/kbill kbill.pro
CONFIG_KCHECKERS noncore/games/kcheckers kcheckers.pro
CONFIG_KEYBOARD inputmethods/keyboard keyboard.pro
CONFIG_KEYPEBBLE noncore/comm/keypebble keypebble.pro
CONFIG_KEYVIEW development/keyview keyview.pro
CONFIG_KJUMPX inputmethods/kjumpx kjumpx.pro
CONFIG_KPACMAN noncore/games/kpacman kpacman.pro
CONFIG_LANGUAGE noncore/settings/language language.pro
CONFIG_LAUNCHER core/launcher server.pro
CONFIG_LAUNCHER-SETTINGS core/settings/launcher launcher.pro
CONFIG_LIBFFMPEG core/multimedia/opieplayer/libffmpeg libffmpeg.pro
CONFIG_LIBFLASH core/multimedia/opieplayer/libflash libflash.pro
CONFIG_LIBMAD core/multimedia/opieplayer/libmad libmad.pro
CONFIG_LIBMAIL noncore/unsupported/mail2/libmail libmail.pro
CONFIG_LIBMAILWRAPPER noncore/net/mail/libmailwrapper libmailwrapper.pro
CONFIG_LIBMPEG3 core/multimedia/opieplayer/libmpeg3 libmpeg3.pro
CONFIG_LIBOPIE2CORE libopie2/opiecore opiecore.pro
CONFIG_LIBOPIE2DB libopie2/opiedb opiedb.pro
CONFIG_LIBOPIE2EXAMPLES libopie2/examples examples.pro
CONFIG_LIBOPIE2MM libopie2/opiemm opiemm.pro
CONFIG_LIBOPIE2NET libopie2/opienet opienet.pro
CONFIG_LIBOPIE2PIM libopie2/opiepim opiepim.pro
CONFIG_LIBOPIE2SECURITY libopie2/opiesecurity opiesecurity.pro
CONFIG_LIBOPIE2UI libopie2/opieui opieui.pro
CONFIG_LIBOPIE libopie libopie.pro
CONFIG_LIBOPIE_PIM libopie/pim pim.pro
CONFIG_LIBOPIETOOTH noncore/net/opietooth/lib lib.pro
CONFIG_LIBQPE library library.pro
CONFIG_LIBQPE-X11 x11/libqpe-x11 libqpe-x11.pro
CONFIG_LIBQRSYNC rsync rsync.pro
CONFIG_LIBQTAUX libqtaux libqtaux.pro
CONFIG_LIBSLCOMPAT libslcompat libslcompat.pro
CONFIG_LIBSQL libsql libsql.pro
CONFIG_LIBTREMOR core/multimedia/opieplayer/vorbis/tremor tremor.pro
CONFIG_LIBTREMORPLUGIN core/multimedia/opieplayer/vorbis libtremor.pro
CONFIG_LIGHT-AND-POWER core/settings/light-and-power light-and-power.pro
CONFIG_LIQUID noncore/styles/liquid liquid.pro
+CONFIG_LOCKAPPLET core/applets/lockapplet lockapplet.pro
CONFIG_LOGOUTAPPLET core/applets/logoutapplet logoutapplet.pro
CONFIG_MAIL3 noncore/net/mail mail.pro
CONFIG_MAILAPPLET noncore/net/mail/taskbarapplet taskbarapplet.pro
CONFIG_MAILIT noncore/unsupported/mailit mailit.pro
CONFIG_MAIN_TAB_EXAMPLE examples/main-tab example.pro
CONFIG_MEDIUMMOUNT noncore/settings/mediummount mediummount.pro
CONFIG_MEMORYAPPLET noncore/applets/memoryapplet memoryapplet.pro
CONFIG_METAL noncore/styles/metal metal.pro
CONFIG_MINDBREAKER noncore/games/mindbreaker mindbreaker.pro
CONFIG_MINESWEEP noncore/games/minesweep minesweep.pro
CONFIG_MOBILEMSG noncore/comm/mobilemsg mobilemsg.pro
CONFIG_MODPLUG core/multimedia/opieplayer/modplug modplug.pro
CONFIG_MULTIAUTH_BLUEPING noncore/securityplugins/blueping bluepingplugin.pro
CONFIG_MULTIAUTH_DUMMY noncore/securityplugins/dummy dummyplugin.pro
CONFIG_MULTIAUTH_NOTICE noncore/securityplugins/notice noticeplugin.pro
CONFIG_MULTIAUTH_PIN noncore/securityplugins/pin pinplugin.pro
CONFIG_MULTIKEYAPPLET core/applets/multikeyapplet multikeyapplet.pro
CONFIG_MULTIKEY inputmethods/multikey multikey.pro
CONFIG_NETSYSTEMTIME noncore/settings/netsystemtime netsystemtime.pro
CONFIG_NETWORKAPPLET noncore/applets/networkapplet networkapplet.pro
CONFIG_NETWORKSETUP noncore/settings/networksettings networksettings.pro
CONFIG_NOTESAPPLET noncore/applets/notesapplet notesapplet.pro
CONFIG_NS2BT noncore/settings/networksettings2/bluetooth bluetooth.pro
CONFIG_NS2CABLE noncore/settings/networksettings2/cable cable.pro
CONFIG_NS2CORE noncore/settings/networksettings2/networksettings2 networksettings2.pro
CONFIG_NS2IRDA noncore/settings/networksettings2/irda irda.pro
CONFIG_NS2LANCARD noncore/settings/networksettings2/lancard lancard.pro
CONFIG_NS2MODEM noncore/settings/networksettings2/modem modem.pro
CONFIG_NS2NETWORK noncore/settings/networksettings2/network network.pro
CONFIG_NS2 noncore/settings/networksettings2 networksettings.pro
CONFIG_NS2PPP noncore/settings/networksettings2/ppp ppp.pro
CONFIG_NS2PROFILE noncore/settings/networksettings2/profile profile.pro
CONFIG_NS2USB noncore/settings/networksettings2/usb usb.pro
CONFIG_NS2VPN noncore/settings/networksettings2/vpn vpn.pro
CONFIG_NS2WLAN noncore/settings/networksettings2/wlan wlan.pro
CONFIG_OAPP core/apps/oapp oapp.pro
CONFIG_OBEX core/obex obex.pro
CONFIG_ODICT noncore/apps/odict odict.pro
CONFIG_OIPKG noncore/unsupported/oipkg oipkg.pro
CONFIG_OPIEALARM core/opiealarm opiealarm.pro
CONFIG_OPIE-CONSOLE noncore/apps/opie-console opie-console.pro
CONFIG_OPIE_EYE noncore/graphics/opie-eye phunk_view.pro
CONFIG_OPIE_EYE_SLAVE noncore/graphics/opie-eye/slave slave.pro
CONFIG_OPIEFTP noncore/net/opieftp opieftp.pro
CONFIG_OPIEIRC noncore/net/opieirc opieirc.pro
CONFIG_OPIE-LOGIN core/opie-login opie-login.pro
CONFIG_OPIEMAIL2 noncore/unsupported/mail2 mail.pro
CONFIG_OPIEPLAYER2 noncore/multimedia/opieplayer2 opieplayer2.pro
CONFIG_OPIEPLAYER core/multimedia/opieplayer opieplayer.pro
CONFIG_OPIE-RDESKTOP noncore/net/opierdesktop opierdesktop.pro
CONFIG_OPIE-READER noncore/apps/opie-reader opie-reader.pro
CONFIG_OPIEREC noncore/multimedia/opierec opierec.pro
CONFIG_OPIE-SHEET noncore/apps/opie-sheet opie-sheet.pro
CONFIG_OPIE-SH noncore/tools/opie-sh opie-sh.pro
CONFIG_OPIETOOTH-APPLET noncore/net/opietooth/applet applet.pro
CONFIG_OPIETOOTH-MANAGER noncore/net/opietooth/manager manager.pro
CONFIG_OPIE-WRITE noncore/apps/opie-write opie-write.pro
CONFIG_OSEARCH core/pim/osearch osearch.pro
CONFIG_OXYGEN noncore/apps/oxygen oxygen.pro
CONFIG_PACKAGEMANAGER noncore/settings/packagemanager packagemanager.pro
CONFIG_PARASHOOT noncore/games/parashoot parashoot.pro
CONFIG_PHASE noncore/styles/phase phase.pro
CONFIG_PICKBOARD inputmethods/pickboard pickboard.pro
CONFIG_PIMCONVERTER noncore/tools/pimconverter converter.pro
CONFIG_POWERCHORD noncore/multimedia/powerchord powerchord.pro
CONFIG_PPP noncore/settings/networksettings/ppp ppp.pro
CONFIG_PYQUICKLAUNCH-APPLET noncore/applets/pyquicklaunch pyquicklaunch.pro
CONFIG_PYQUICKLAUNCHER noncore/tools/pyquicklauncher pyquicklauncher.pro
CONFIG_PYTHON-EXAMPLES examples/python bla.pro
CONFIG_QASHMONEY noncore/apps/qashmoney qashmoney.pro
CONFIG_QASTEROIDS noncore/games/qasteroids qasteroids.pro
CONFIG_QCOP core/apps/qcop qcop.pro
CONFIG_QPDF noncore/unsupported/qpdf qpdf.pro
CONFIG_QUICKLAUNCHER core/tools/quicklauncher quicklauncher.pro
CONFIG_QWS core/qws qws.pro
CONFIG_REMOTE noncore/tools/remote remote.pro
CONFIG_RESTARTAPPLET2 core/applets/restartapplet2 restartapplet2.pro
CONFIG_RESTARTAPPLET core/applets/restartapplet restartapplet.pro
CONFIG_ROTATEAPPLET core/applets/rotateapplet rotateapplet.pro
CONFIG_ROTATION noncore/settings/rotation rotation.pro
CONFIG_RUNAPPLET core/applets/runapplet runapplet.pro
CONFIG_SCREENSHOTAPPLET core/applets/screenshotapplet screenshotapplet.pro
CONFIG_SECURITY core/settings/security security.pro
CONFIG_MULTIAUTH_DEMO core/settings/security/demo multiauth.pro
CONFIG_SFCAVE noncore/games/sfcave sfcave.pro
CONFIG_SFCAVE-SDL noncore/games/sfcave-sdl sfcave-sdl.pro
CONFIG_SHOWIMG noncore/multimedia/showimg showimg.pro
CONFIG_SIMPLE_EXAMPLE examples/simple example.pro
CONFIG_SIMPLE_ICON examples/simple-icon example.pro
CONFIG_SIMPLE_MAIN examples/simple-main example.pro
CONFIG_SIMPLE noncore/tools/calc2/simple simple.pro
CONFIG_SIMPLE_PIM examples/simple-pim example.pro
CONFIG_SINGLE single single.pro
CONFIG_SNAKE noncore/games/snake snake.pro
CONFIG_SOLITAIRE noncore/games/solitaire solitaire.pro
CONFIG_SOUND noncore/settings/sound sound.pro
diff --git a/pics/security/lock.png b/pics/security/lock.png
new file mode 100644
index 0000000..94d1dbc
--- a/dev/null
+++ b/pics/security/lock.png
Binary files differ