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
@@ -512,3 +512,4 @@ void ServerApplication::login(bool at_poweron)
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;
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
@@ -10,3 +10,3 @@ int main( int argc, char ** argv )
// 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,3 +1,3 @@
#include <opie2/odebug.h>
-#include <opie2/multiauthmainwindow.h>
+#include <opie2/multiauthpassword.h>
@@ -123,18 +123,4 @@ void MultiauthGeneralConfig::tryAuth()
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);
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
@@ -55,5 +55,7 @@ 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
*/
@@ -72,4 +74,5 @@ bool MultiauthPassword::needToAuthenticate(bool at_poweron)
+
/**
- * \brief Require user authentication to unlock and continue
+ * \brief Require (if configured so) user authentication to unlock and continue
*
@@ -82,6 +85,36 @@ bool MultiauthPassword::needToAuthenticate(bool at_poweron)
*/
-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;
@@ -90,3 +123,3 @@ void MultiauthPassword::authenticate(bool at_poweron)
*/
- MultiauthMainWindow win;
+ MultiauthMainWindow win(allowByPass);
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
@@ -40,2 +40,7 @@ namespace Security {
+enum lockMode {
+ IfPowerOn,
+ IfResume,
+ TestNow,
+ LockNow };
/**
@@ -50,5 +55,6 @@ namespace Security {
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 );
};
diff --git a/packages b/packages
index 275d2f9..dcbbe78 100644
--- a/packages
+++ b/packages
@@ -100,2 +100,3 @@ 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
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