-rw-r--r-- | core/applets/lockapplet/.cvsignore | 4 | ||||
-rw-r--r-- | core/applets/lockapplet/config.in | 4 | ||||
-rw-r--r-- | core/applets/lockapplet/lock.cpp | 84 | ||||
-rw-r--r-- | core/applets/lockapplet/lock.h | 36 | ||||
-rw-r--r-- | core/applets/lockapplet/lockapplet.pro | 12 | ||||
-rw-r--r-- | core/applets/lockapplet/opie-lockapplet.control | 11 | ||||
-rw-r--r-- | core/launcher/serverapp.cpp | 3 | ||||
-rw-r--r-- | core/settings/security/demo/main.cpp | 2 | ||||
-rw-r--r-- | core/settings/security/multiauthconfig.cpp | 20 |
9 files changed, 157 insertions, 19 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 @@ -465,97 +465,98 @@ void ServerApplication::systemMessage( const QCString& msg, } } } 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; 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,50 +1,50 @@ #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 ) @@ -76,112 +76,98 @@ class ToolButton : public QToolButton { 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); |