-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 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthpassword.cpp | 47 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthpassword.h | 10 | ||||
-rw-r--r-- | packages | 1 | ||||
-rw-r--r-- | pics/security/lock.png | bin | 0 -> 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 @@ -129,722 +129,723 @@ void DesktopPowerAlerter::alert( const QString &text, int priority ) return; if ( priority > currentPriority ) return; currentPriority = priority; setText( text ); show(); } void DesktopPowerAlerter::hideEvent( QHideEvent *e ) { QMessageBox::hideEvent( e ); alertCount = 0; currentPriority = INT_MAX; } //--------------------------------------------------------------------------- KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) { /* We don't do this cause it would interfere with ODevice */ #if 0 qwsServer->setKeyboardFilter(this); #endif } void KeyFilter::timerEvent(QTimerEvent* e) { if ( e->timerId() == held_tid ) { killTimer(held_tid); // button held if ( heldButton ) { emit activate(heldButton, TRUE); heldButton = 0; } held_tid = 0; } } void KeyFilter::registerKey( const QCopKeyRegister& key ) { m_keys.insert( key.keyCode(), key ); } void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { m_keys.remove( key.keyCode() ); } bool KeyFilter::keyRegistered( int key ) { /* * Check if we've a key registered */ if ( !m_keys[key].send()) return false; else return true; } bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) { if ( !loggedin // Permitted keys && keycode != Key_F34 // power && keycode != Key_F30 // select && keycode != Key_Enter && keycode != Key_Return && keycode != Key_Space && keycode != Key_Left && keycode != Key_Right && keycode != Key_Up && keycode != Key_Down ) return TRUE; /* check if it was registered */ if (!db ) { if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) return true; } else { // First check to see if DeviceButtonManager knows something about this button: const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); if (button && !autoRepeat) { if ( held_tid ) { killTimer(held_tid); held_tid = 0; } if ( button->heldAction().isNull() ) { if ( press ) emit activate(button, FALSE); } else if ( press ) { heldButton = button; held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); } else if ( heldButton ) { heldButton = 0; emit activate(button, FALSE); } QWSServer::screenSaverActivate(FALSE); return TRUE; } return false; } if ( keycode == HardKey_Suspend ) { if ( press ) emit power(); return TRUE; } if ( keycode == HardKey_Backlight ) { if ( press ) emit backlight(); return TRUE; } if ( keycode == Key_F32 ) { #ifndef QT_NO_COP if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); #endif return TRUE; } if ( keycode == Key_F31 ) { if ( press ) emit symbol(); QWSServer::screenSaverActivate(FALSE); return TRUE; } if ( keycode == Key_NumLock ) if ( press ) emit numLockStateToggle(); if ( keycode == Key_CapsLock ) if ( press ) emit capsLockStateToggle(); if ( serverApp ) serverApp->keyClick(keycode,press,autoRepeat); return FALSE; } enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; #if defined(QPE_HAVE_MEMALERTER) QPE_MEMALERTER_IMPL #endif //--------------------------------------------------------------------------- bool ServerApplication::doRestart = FALSE; bool ServerApplication::allowRestart = TRUE; bool ServerApplication::ms_is_starting = TRUE; void ServerApplication::switchLCD( bool on ) { if ( !qApp ) return; ServerApplication *dapp = ServerApplication::me() ; if ( !dapp-> m_screensaver ) return; if ( on ) { dapp-> m_screensaver-> setDisplayState ( true ); dapp-> m_screensaver-> setBacklight ( -3 ); } else dapp-> m_screensaver-> setDisplayState ( false ); } ServerApplication::ServerApplication( int& argc, char **argv, Type t ) : QPEApplication( argc, argv, t ) { ms_is_starting = true; // We know we'll have lots of cached pixmaps due to App/DocLnks QPixmapCache::setCacheLimit(512); m_ps = new PowerStatus; m_ps_last = new PowerStatus; pa = new DesktopPowerAlerter( 0 ); m_apm_timer = new QTimer( this ); connect(m_apm_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); reloadPowerWarnSettings(); QCopChannel *channel = new QCopChannel( "QPE/System", this ); connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), this, SLOT(systemMessage(const QCString&,const QByteArray&) ) ); channel = new QCopChannel("QPE/Launcher", this ); connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) ); m_screensaver = new OpieScreenSaver(); m_screensaver->setInterval( -1 ); QWSServer::setScreenSaver( m_screensaver ); connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( rereadVolumes() ) ); /* ### PluginLoader libqtopia SafeMode */ #if 0 if ( PluginLoader::inSafeMode() ) QTimer::singleShot(500, this, SLOT(showSafeMode()) ); QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); #endif kf = new KeyFilter(this); connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); connect( kf, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), this,SIGNAL(activate(const Opie::Core::ODeviceButton*,bool))); connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); connect( this, SIGNAL(power() ), SLOT(togglePower() ) ); rereadVolumes(); serverApp = this; apmTimeout(); grabKeyboard(); /* make sure the event filter is installed */ /* std::limits<short>::max() when you've stdc++ */ const ODeviceButton* but = ODevice::inst()->buttonForKeycode( SHRT_MAX ); Q_CONST_UNUSED( but ) } ServerApplication::~ServerApplication() { ungrabKeyboard(); delete pa; delete m_ps; delete m_ps_last; } void ServerApplication::apmTimeout() { serverApp-> checkMemory( ); // in case no events are generated *m_ps_last = *m_ps; *m_ps = PowerStatusManager::readStatus(); if ( m_ps->acStatus() != m_ps_last-> acStatus() ) m_screensaver-> powerStatusChanged( *m_ps ); if ( m_ps->acStatus() == PowerStatus::Online ) { return; } int bat = m_ps-> batteryPercentRemaining(); if ( bat < m_ps_last-> batteryPercentRemaining() ) { if ( bat <= m_powerCritical ) { QMessageBox battlow( tr("WARNING"), tr("<p>The battery level is critical!" "<p>Keep power off until AC is restored"), QMessageBox::Warning, QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 0, QString::null, TRUE, WStyle_StaysOnTop); battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); battlow.exec(); } else if ( bat <= m_powerVeryLow ) pa->alert( tr( "The battery is running very low. "), 2 ); } if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { QMessageBox battlow( tr("WARNING"), tr("<p>The Back-up battery is very low" "<p>Please charge the back-up battery"), QMessageBox::Warning, QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 0, QString::null, TRUE, WStyle_StaysOnTop); battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); 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) { if ( e->type() != QEvent::KeyPress && e->type() != QEvent::KeyRelease ) return QPEApplication::eventFilter( o, e ); QKeyEvent *ke = static_cast<QKeyEvent*>( e ); if ( kf->checkButtonAction( true, ke->key(), e->type() == QEvent::KeyPress, ke-> isAutoRepeat() )) return true; return QPEApplication::eventFilter( o, e ); } #ifdef Q_WS_QWS bool ServerApplication::qwsEventFilter( QWSEvent *e ) { checkMemory(); if ( e->type == QWSEvent::Mouse ) { QWSMouseEvent *me = (QWSMouseEvent *)e; static bool up = TRUE; if ( me->simpleData.state&LeftButton ) { if ( up ) { up = FALSE; screenClick(TRUE); } } else if ( !up ) { up = TRUE; screenClick(FALSE); } } else if ( e->type == QWSEvent::Key ) { QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); if ( kf->checkButtonAction( false, ke-> simpleData.keycode, ke-> simpleData.is_press, ke-> simpleData.is_auto_repeat ) ) return true; } return QPEApplication::qwsEventFilter( e ); } #endif /* ### FIXME libqtopia Plugin Safe Mode */ void ServerApplication::showSafeMode() { #if 0 if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " "and the system is now in Safe Mode. " "Plugins are not loaded in Safe Mode. " "You can use the Plugin Manager to " "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { Global::execute( "pluginmanager" ); } #endif } void ServerApplication::clearSafeMode() { #if 0 // If we've been running OK for a while then we won't bother going into // safe mode immediately on the next crash. Config cfg( "PluginLoader" ); cfg.setGroup( "Global" ); QString mode = cfg.readEntry( "Mode", "Normal" ); if ( mode == "MaybeSafe" ) { cfg.writeEntry( "Mode", "Normal" ); } #endif } void ServerApplication::shutdown() { if ( type() != GuiServer ) return; ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), this, SLOT(shutdown(ShutdownImpl::Type)) ); QPEApplication::showWidget( sd ); } void ServerApplication::shutdown( ShutdownImpl::Type t ) { char *opt = 0; switch ( t ) { case ShutdownImpl::ShutdownSystem: opt = "-h"; // fall through case ShutdownImpl::RebootSystem: if ( opt == 0 ) opt = "-r"; if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) perror("shutdown"); // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); break; case ShutdownImpl::RestartDesktop: restart(); break; case ShutdownImpl::TerminateDesktop: prepareForTermination( FALSE ); // This is a workaround for a Qt bug // clipboard applet has to stop its poll timer, or Qt/E // will hang on quit() right before it emits aboutToQuit() emit aboutToQuit ( ); quit(); break; } } void ServerApplication::restart() { if ( allowRestart ) { /* * Applets and restart is a problem. Some applets delete * their widgets even if ownership gets transfered to the * parent (Systray ) but deleting the applet may be unsafe * as well ( double deletion ). Some have topLevel widgets * and when we dlclose and then delete the widget we will * crash and an crash during restart is not nice */ #ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED /* same as above */ emit aboutToQuit(); prepareForTermination(TRUE); doRestart = TRUE; quit(); #else prepareForTermination( true ); for ( int fd = 3; fd < 100; fd++ ) close( fd ); execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); exit( 1 ); #endif } } void ServerApplication::rereadVolumes() { Config cfg( "qpe" ); cfg. setGroup ( "Volume" ); m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); } void ServerApplication::checkMemory() { #if defined(QPE_HAVE_MEMALERTER) static bool ignoreNormal=TRUE; static bool existingMessage=FALSE; if(existingMessage) return; // don't show a second message while still on first existingMessage = TRUE; switch ( memstate ) { case MemUnknown: break; case MemLow: memstate = MemUnknown; if ( !recoverMemory() ) { QMessageBox::warning( 0 , tr("Memory Status"), tr("Memory Low\nPlease save data.") ); ignoreNormal = FALSE; } break; case MemNormal: memstate = MemUnknown; if ( !ignoreNormal ) { ignoreNormal = TRUE; QMessageBox::information ( 0 , tr("Memory Status"), "Memory OK" ); } break; case MemVeryLow: memstate = MemUnknown; QMessageBox::critical( 0 , tr("Memory Status"), tr("Critical Memory Shortage\n" "Please end this application\n" "immediately.") ); recoverMemory(); } existingMessage = FALSE; #endif } bool ServerApplication::recoverMemory() { return FALSE; } void ServerApplication::keyClick(int , bool press, bool ) { if ( press && m_keyclick_sound ) ODevice::inst() -> playKeySound(); } void ServerApplication::screenClick(bool press) { if ( press && m_screentap_sound ) ODevice::inst() -> playTouchSound(); } void ServerApplication::soundAlarm() { if ( me ()->m_alarm_sound ) ODevice::inst()->playAlarmSound(); } ServerApplication *ServerApplication::me ( ) { return static_cast<ServerApplication*>( qApp ); } bool ServerApplication::isStarting() { return ms_is_starting; } int ServerApplication::exec() { ms_is_starting = true; odebug << "Serverapp - exec" << oendl; return QPEApplication::exec(); } #include "serverapp.moc" 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,523 +1,509 @@ #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 // (configWidget will return 0l if there is no configuration GUI) MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW); if ( widget != 0l ) { odebug << "plugin " << plugin.name << " has a configuration widget" << oendl; configWidgetList.append(widget); m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(), plugin.pluginObject->pluginName() ); } // set the order/activate tab QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() ); QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox ); if ( !icon.isNull() ) { item->setPixmap( 0, icon ); } if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) { item->setOn( TRUE ); } m_plugins[plugin.name] = item; } // set the first tab as default. m_mainTW->setCurrentTab(m_pluginListWidget); // put the number of plugins as the max number of req. auth. m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() ); } else { /* we don't have any installed plugin there. Let's tell * that to the user in a third tab, using the m_pluginListWidget widget */ m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)"); QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); pluginListLayout->setSpacing(11); pluginListLayout->setMargin(11); pluginListLayout->setAlignment( Qt::AlignTop ); QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box"); pluginListLayout->addWidget(warningBox); QLabel * warningText = new QLabel( "<p>" + tr("To be able to protect your PDA with one or more authentication plugins (for example, a simple PIN authentication), you must install at least one <em>opie-multiauth-*</em> package! Once you have done that, you will be able to configure your PDA protection here.") + "</p>", warningBox ); m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") ); // set the first tab as default. m_mainTW->setCurrentTab(m_loginWidget); } showMaximized(); } /// nothing to do MultiauthConfig::~MultiauthConfig() { } /// saves the general and plugin(s) configurations void MultiauthConfig::writeConfigs() { writeConfig(); MultiauthConfigWidget* confWidget = 0; for ( confWidget = configWidgetList.first(); confWidget != 0; confWidget = configWidgetList.next() ) confWidget->writeConfig(); } /// on QDialog::accept, we save all the configurations and exit the QDialog normally void MultiauthConfig::accept() { writeConfigs(); QDialog::accept(); } void MultiauthConfig::done( int r ) { QDialog::done( r ); close(); } /// moves up the selected plugin void MultiauthConfig::moveSelectedUp() { QListViewItem *item = m_pluginListView->selectedItem(); if ( item && item->itemAbove() ) { item->itemAbove()->moveItem( item ); } } /// moves down the selected plugin void MultiauthConfig::moveSelectedDown() { QListViewItem *item = m_pluginListView->selectedItem(); if ( item && item->itemBelow() ) { item->moveItem( item->itemBelow() ); } } /// reads the <code>Security.conf</code> Config file, and updates parts of the user interface void MultiauthConfig::readConfig() { // pointer, so we release this Config when we want Config* pcfg = new Config("Security"); if (m_pluginsInstalled) { pcfg->setGroup( "Misc" ); m_generalConfig->m_onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); m_generalConfig->m_onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); m_generalConfig->m_nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); m_generalConfig->m_noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); m_generalConfig->m_explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); pcfg->setGroup( "Plugins" ); m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' ); m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' ); } /* Login and Sync stuff */ pcfg->setGroup("Sync"); int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24); pcfg->setGroup("SyncMode"); int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp switch( mode ) { case 0x01: m_syncWidget->syncModeCombo->setCurrentItem( 0 ); break; case 0x02: default: m_syncWidget->syncModeCombo->setCurrentItem( 1 ); break; case 0x04: m_syncWidget->syncModeCombo->setCurrentItem( 2 ); break; } /* cfg.setGroup("Remote"); if ( telnetAvailable() ) telnet->setChecked(cfg.readEntry("allow_telnet")); else telnet->hide(); if ( sshAvailable() ) ssh->setChecked(cfg.readEntry("allow_ssh")); else ssh->hide(); */ // release the Config handler delete pcfg; // indeed, selectNet will open the config file... selectNet(auth_peer,auth_peer_bits,TRUE); connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), this, SLOT(setSyncNet(const QString&))); QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; Config loginCfg(configFile,Config::File); loginCfg.setGroup("General"); autoLoginName=loginCfg.readEntry("AutoLogin",""); if (autoLoginName.stripWhiteSpace().isEmpty()) { autoLogin=false; } else { autoLogin=true; } connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); loadUsers(); updateGUI(); } void MultiauthConfig::writeConfig() { Config* pcfg = new Config("Security"); if (m_pluginsInstalled) { pcfg->setGroup( "Plugins" ); QStringList exclude; QStringList include; QStringList allPlugins; QListViewItemIterator list_it( m_pluginListView ); // this makes sure the names get saved in the order selected for ( ; list_it.current(); ++list_it ) { QMap <QString, QCheckListItem *>::Iterator it; for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { if ( list_it.current() == (*it) && !(*it)-> isOn () ) { exclude << it.key(); } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ include << it.key(); } if ( list_it.current() == (*it) ) { allPlugins << it.key(); } } } pcfg->writeEntry( "ExcludePlugins", exclude, ',' ); pcfg->writeEntry( "IncludePlugins", include, ',' ); pcfg->writeEntry( "AllPlugins", allPlugins, ',' ); pcfg->setGroup( "Misc" ); pcfg->writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() ); pcfg->writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() ); pcfg->writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() ); pcfg->writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() ); pcfg->writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() ); } /* Login and Sync stuff */ pcfg->setGroup("Sync"); int auth_peer=0; int auth_peer_bits; QString sn = m_syncWidget->syncnet->currentText(); parseNet(sn,auth_peer,auth_peer_bits); //this is the *selected* (active) net range pcfg->writeEntry("auth_peer",auth_peer); pcfg->writeEntry("auth_peer_bits",auth_peer_bits); //write back all other net ranges in *cleartext* for (int i=0; i<10; i++) { QString target; target.sprintf("net%d", i); if ( i < m_syncWidget->syncnet->count() ) pcfg->writeEntry(target, m_syncWidget->syncnet->text(i)); else // no more entry in the syncnet list -> we clear the line pcfg->writeEntry(target, ""); } #ifdef ODP #error "Use 0,1,2 and use Launcher" #endif /* keep the old code so we don't use currentItem directly */ int value = 0x02; switch( m_syncWidget->syncModeCombo->currentItem() ) { case 0: value = 0x01; break; case 1: value = 0x02; break; case 2: value = 0x04; break; } pcfg->setGroup("SyncMode"); pcfg->writeEntry( "Mode", value ); /* pcfg->setGroup("Remote"); if ( telnetAvailable() ) pcfg->writeEntry("allow_telnet",telnet->isChecked()); if ( sshAvailable() ) pcfg->writeEntry("allow_ssh",ssh->isChecked()); // ### write ssh/telnet sys config files */ //release the Config handler delete pcfg; QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; Config loginCfg(configFile,Config::File); loginCfg.setGroup("General"); if (autoLogin) { loginCfg.writeEntry("AutoLogin",autoLoginName); } else { loginCfg.removeEntry("AutoLogin"); } } /// slot used to record the fact plugins order has been modified void MultiauthConfig::pluginsChanged() { m_plugins_changed = true; } /// loads each multiauth plugin 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 @@ -1,240 +1,241 @@ CONFIG_ABOUTAPPLET core/applets/aboutapplet aboutapplet.pro CONFIG_ADDRESSBOOK core/pim/addressbook addressbook.pro CONFIG_ADVANCEDFM noncore/apps/advancedfm advancedfm.pro 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 CONFIG_SSHKEYS noncore/settings/sshkeys sshkeys.pro CONFIG_SUSPENDAPPLET core/applets/suspendapplet suspendapplet.pro CONFIG_SYMLINKER core/symlinker symlinker.pro CONFIG_SYSINFO noncore/settings/sysinfo sysinfo.pro CONFIG_TABLEVIEWER noncore/apps/tableviewer tableviewer.pro CONFIG_TABMANAGER noncore/settings/tabmanager tabmanager.pro CONFIG_TABOAPP core/apps/taboapp taboapp.pro CONFIG_TEST libsql/test test.pro CONFIG_TEST noncore/apps/opie-console/test test.pro CONFIG_TETRIX noncore/games/tetrix tetrix.pro CONFIG_TEXTEDIT core/apps/textedit textedit.pro CONFIG_THEME noncore/styles/theme theme.pro CONFIG_TICTAC noncore/games/tictac tictac.pro CONFIG_TINYKATE noncore/apps/tinykate tinykate.pro CONFIG_TODAY_ADDRESSBOOK core/pim/today/plugins/addressbook addressbook.pro CONFIG_TODAY core/pim/today today.pro CONFIG_TODAY_DATEBOOK core/pim/today/plugins/datebook datebook.pro CONFIG_TODAY_EXAMPLE examples/todayplugin example.pro CONFIG_TODAY_FORTUNE noncore/todayplugins/fortune fortune.pro CONFIG_TODAY_MAIL core/pim/today/plugins/mail mail.pro CONFIG_TODAY_STOCKTICKERLIB noncore/todayplugins/stockticker/stocktickerlib stocktickerlib.pro CONFIG_TODAY_STOCKTICKER noncore/todayplugins/stockticker/stockticker stockticker.pro CONFIG_TODAY_TODOLIST core/pim/today/plugins/todolist todolist.pro CONFIG_TODAY_WEATHER noncore/todayplugins/weather weather.pro CONFIG_TODO core/pim/todo todo.pro CONFIG_TONLEITER noncore/multimedia/tonleiter tonleiter.pro CONFIG_TRACKER noncore/multimedia/tracker tracker.pro CONFIG_UBROWSER noncore/net/ubrowser ubrowser.pro CONFIG_UNIKEYBOARD inputmethods/unikeyboard unikeyboard.pro CONFIG_USERMANAGER noncore/settings/usermanager usermanager.pro CONFIG_VMEMO core/applets/vmemo vmemo.pro CONFIG_VOLUMEAPPLET core/applets/volumeapplet volumeapplet.pro CONFIG_VTAPPLET core/applets/vtapplet vtapplet.pro CONFIG_WAVPLUGIN core/multimedia/opieplayer/wavplugin wavplugin.pro CONFIG_WEBSTYLE noncore/styles/web web.pro CONFIG_WELLENREITER noncore/net/wellenreiter wellenreiter.pro CONFIG_WIRELESSAPPLET noncore/applets/wirelessapplet wirelessapplet.pro CONFIG_WLAN noncore/settings/networksettings/wlan wlan.pro CONFIG_WORDGAME noncore/games/wordgame wordgame.pro CONFIG_YATZEE noncore/games/oyatzee oyatzee.pro CONFIG_ZKBAPPLET noncore/applets/zkbapplet zkbapplet.pro CONFIG_ZLINES noncore/games/zlines zlines.pro CONFIG_ZSAFE noncore/apps/zsafe zsafe.pro CONFIG_ZSAME noncore/games/zsame zsame.pro diff --git a/pics/security/lock.png b/pics/security/lock.png Binary files differnew file mode 100644 index 0000000..94d1dbc --- a/dev/null +++ b/pics/security/lock.png |