summaryrefslogtreecommitdiff
Unidiff
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 @@
1Makefile*
2.moc
3.obj
4
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 @@
1 config LOCKAPPLET
2 boolean "opie-lockapplet (button in the Opie menu to lock the PDA)"
3 default "y"
4 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 @@
1#include "lock.h"
2
3/* OPIE */
4#include <opie2/multiauthpassword.h>
5
6#include <qpe/applnk.h>
7#include <qpe/resource.h>
8
9/* QT */
10#include <qiconset.h>
11#include <qpopupmenu.h>
12#include <qmessagebox.h>
13
14
15LockMenuApplet::LockMenuApplet()
16 :QObject( 0, "LockMenuApplet" )
17{
18}
19
20LockMenuApplet::~LockMenuApplet ( )
21{}
22
23int LockMenuApplet::position() const
24{
25 return 3;
26}
27
28QString LockMenuApplet::name() const
29{
30 return tr( "Lock shortcut" );
31}
32
33QString LockMenuApplet::text() const
34{
35 return tr( "Lock" );
36}
37
38
39QIconSet LockMenuApplet::icon() const
40{
41 QPixmap pix;
42 QImage img = Resource::loadImage( "security/lock" );
43 if ( !img.isNull() )
44 pix.convertFromImage( img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
45 return pix;
46}
47
48QPopupMenu* LockMenuApplet::popup(QWidget*) const
49{
50 /* no subdir */
51 return 0;
52}
53
54void LockMenuApplet::activated()
55{
56 /*
57 QMessageBox::information(0,tr("No white rabbit found"),
58 tr("<qt>No white rabbit was seen near Opie."
59 "Only the beautiful OpieZilla is available"
60 "for your pleassure</qt>"));
61 */
62 Opie::Security::MultiauthPassword::authenticate(Opie::Security::LockNow);
63}
64
65
66QRESULT LockMenuApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
67{
68 *iface = 0;
69 if ( uuid == IID_QUnknown )
70 *iface = this;
71 else if ( uuid == IID_MenuApplet )
72 *iface = this;
73 else
74 return QS_FALSE;
75
76 if ( *iface )
77 (*iface)->addRef();
78 return QS_OK;
79}
80
81Q_EXPORT_INTERFACE()
82{
83 Q_CREATE_INSTANCE( LockMenuApplet )
84}
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 @@
1/**
2 * \file lock.h
3 * \brief defines a lock button that goes in the 'O' Opie menu
4 * It's based on the examples/menuapplet code of 2004/10/06.
5 */
6#ifndef CORE_SETTINGS_SECURITY_LOCKAPPLET_LOCK_H
7#define CORE_SETTINGS_SECURITY_LOCKAPPLET_LOCK_H
8
9#include <qpe/menuappletinterface.h>
10#include <qobject.h>
11
12class LockMenuApplet: public QObject, public MenuAppletInterface
13{
14
15 Q_OBJECT
16
17public:
18 LockMenuApplet ( );
19 virtual ~LockMenuApplet ( );
20
21 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
22 Q_REFCOUNT
23
24 virtual int position() const;
25
26 virtual QString name ( ) const;
27 virtual QIconSet icon ( ) const;
28 virtual QString text ( ) const;
29 /* virtual QString tr( const char* ) const;
30 virtual QString tr( const char*, const char* ) const;
31 */
32 virtual QPopupMenu *popup ( QWidget *parent ) const;
33 virtual void activated ( );
34};
35
36#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 @@
1TEMPLATE = lib
2CONFIG += qt plugn warn_on
3HEADERS = lock.h
4SOURCES = lock.cpp
5TARGET = lockapplet
6DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe
10VERSION = 1.0.0
11
12include ( $(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 @@
1Package: opie-lockapplet
2Files: plugins/applets/liblockapplet.so*
3Priority: optional
4Section: opie/applets
5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm
7Depends: task-opie-minimal, opie-security
8Description: Lock Opie now
9 Button to lock Opie (as configured in the Security
10 settings) on demand.
11Version: $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
@@ -510,7 +510,8 @@ void ServerApplication::login(bool at_poweron)
510{ 510{
511 if ( !loggedin ) { 511 if ( !loggedin ) {
512 Global::terminateBuiltin("calibrate"); // No tr 512 Global::terminateBuiltin("calibrate"); // No tr
513 Opie::Security::MultiauthPassword::authenticate(at_poweron); 513 int lockMode = at_poweron ? Opie::Security::IfPowerOn : Opie::Security::IfResume;
514 Opie::Security::MultiauthPassword::authenticate(lockMode);
514 loggedin=1; 515 loggedin=1;
515#ifndef QT_NO_COP 516#ifndef QT_NO_COP
516 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 517 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
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
@@ -8,5 +8,5 @@ int main( int argc, char ** argv )
8 Opie::Core::OApplication app(argc, argv, "Multi-authentication demo"); 8 Opie::Core::OApplication app(argc, argv, "Multi-authentication demo");
9 9
10 // Run the authentication process until it succeeds 10 // Run the authentication process until it succeeds
11 Opie::Security::MultiauthPassword::authenticate(); 11 Opie::Security::MultiauthPassword::authenticate(Opie::Security::LockNow);
12} 12}
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,5 +1,5 @@
1#include <opie2/odebug.h> 1#include <opie2/odebug.h>
2#include <opie2/multiauthmainwindow.h> 2#include <opie2/multiauthpassword.h>
3 3
4#include <qgroupbox.h> 4#include <qgroupbox.h>
5#include <qvgroupbox.h> 5#include <qvgroupbox.h>
@@ -121,22 +121,8 @@ void MultiauthGeneralConfig::tryAuth()
121 owarn << "writing config as user accepted" << oendl; 121 owarn << "writing config as user accepted" << oendl;
122 m_parentConfig->writeConfigs(); 122 m_parentConfig->writeConfigs();
123 owarn << "testing authentication" << oendl; 123 owarn << "testing authentication" << oendl;
124 124 // launch the authentication in testing mode
125 /* launch the authentication in debug, aka "allowBypass == true", mode 125 Opie::Security::MultiauthPassword::authenticate(Opie::Security::TestNow);
126 */
127
128 Opie::Security::MultiauthMainWindow win(true);
129 // resize the QDialog object so it fills all the screen
130 QRect desk = qApp->desktop()->geometry();
131 win.setGeometry( 0, 0, desk.width(), desk.height() );
132
133 // the authentication has already succeeded (without win interactions)
134 if ( win.isAlreadyDone() )
135 return;
136
137 win.exec();
138
139 }
140 126
141} 127}
142 128
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
@@ -53,9 +53,11 @@ namespace Security {
53 53
54 54
55/** 55/**
56 * If the users requires authentication... #fixme 56 * Tells if the users requires authentication (used internally to
57 * know whether to repaint the screen on resume)
57 * 58 *
58 * @todo fix up at_poweron attribute 59 * \param at_poweron true if we are booting Opie, false if we are resuming it
60 * \return true if authenticate() launched right now would trigger an authentication
59 */ 61 */
60bool MultiauthPassword::needToAuthenticate(bool at_poweron) 62bool MultiauthPassword::needToAuthenticate(bool at_poweron)
61{ 63{
@@ -70,8 +72,9 @@ bool MultiauthPassword::needToAuthenticate(bool at_poweron)
70} 72}
71 73
72 74
75
73/** 76/**
74 * \brief Require user authentication to unlock and continue 77 * \brief Require (if configured so) user authentication to unlock and continue
75 * 78 *
76 * This method will check if you require authentication 79 * This method will check if you require authentication
77 * and then will lock the screen and ask for a successful 80 * and then will lock the screen and ask for a successful
@@ -80,15 +83,45 @@ bool MultiauthPassword::needToAuthenticate(bool at_poweron)
80 * It may go into an event loop, but anyhow it will only end 83 * It may go into an event loop, but anyhow it will only end
81 * when the user has successfully authenticated to the system. 84 * when the user has successfully authenticated to the system.
82 */ 85 */
83void MultiauthPassword::authenticate(bool at_poweron) 86void MultiauthPassword::authenticate(int lockMode)
84{ 87{
85 if ( ! needToAuthenticate(at_poweron) ) 88 /**
86 return; 89 * \par Conditions
90 *
91 * If lockMode is an If, it's conditional:
92 * \li IfPowerOn will not trigger an authentication if
93 * onStart is set to false in Security.conf,
94 * \li IfResume will not trigger an authentication if
95 * onResume is set to false in Security.conf.
96 */
97 if ( (lockMode == IfPowerOn) || (lockMode == IfResume) )
98 {
99 Config cfg("Security");
100 cfg.setGroup("Misc");
101 if ( (
102 (lockMode == IfPowerOn) && cfg.readBoolEntry("onStart", false)
103 ) || (
104 (lockMode == IfResume) && cfg.readBoolEntry("onResume", false)
105 ) )
106 return;
107 }
108
109 /**
110 * \li TestNow will ensure that the authentication window will let
111 * people escape through the last screen (which they can reach skipping
112 * all the authentication steps)
113 * \li LockNow will always go on with the authentication, and won't let
114 * people escape.
115 */
116 bool allowByPass = false;
117
118 if (lockMode == TestNow)
119 allowByPass = true;
87 120
88 /* Constructs the main window, which displays messages and blocks 121 /* Constructs the main window, which displays messages and blocks
89 * access to the desktop 122 * access to the desktop
90 */ 123 */
91 MultiauthMainWindow win; 124 MultiauthMainWindow win(allowByPass);
92 125
93 // resize the QDialog object so it fills all the screen 126 // resize the QDialog object so it fills all the screen
94 QRect desk = qApp->desktop()->geometry(); 127 QRect desk = qApp->desktop()->geometry();
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
@@ -38,6 +38,11 @@
38namespace Opie { 38namespace Opie {
39namespace Security { 39namespace Security {
40 40
41enum lockMode {
42 IfPowerOn,
43 IfResume,
44 TestNow,
45 LockNow };
41/** 46/**
42 * This is the dropin replacement for the libqpe Password class. 47 * This is the dropin replacement for the libqpe Password class.
43 * If you call authenticate() a widget will cover the whole screen 48 * If you call authenticate() a widget will cover the whole screen
@@ -48,9 +53,10 @@ namespace Security {
48 * @author Clement Séveillac, Holger Freyther 53 * @author Clement Séveillac, Holger Freyther
49 */ 54 */
50class MultiauthPassword { 55class MultiauthPassword {
56
51public: 57public:
52 static bool needToAuthenticate( bool atpoweron = false ); 58 static void authenticate(int authMode = LockNow);
53 static void authenticate(bool atpoweron = false); 59 static bool needToAuthenticate( bool atpoweron = false );
54}; 60};
55 61
56 62
diff --git a/packages b/packages
index 275d2f9..dcbbe78 100644
--- a/packages
+++ b/packages
@@ -98,6 +98,7 @@ CONFIG_LIBTREMOR core/multimedia/opieplayer/vorbis/tremor tremor.pro
98CONFIG_LIBTREMORPLUGIN core/multimedia/opieplayer/vorbis libtremor.pro 98CONFIG_LIBTREMORPLUGIN core/multimedia/opieplayer/vorbis libtremor.pro
99 CONFIG_LIGHT-AND-POWER core/settings/light-and-powerlight-and-power.pro 99 CONFIG_LIGHT-AND-POWER core/settings/light-and-powerlight-and-power.pro
100 CONFIG_LIQUID noncore/styles/liquidliquid.pro 100 CONFIG_LIQUID noncore/styles/liquidliquid.pro
101 CONFIG_LOCKAPPLET core/applets/lockappletlockapplet.pro
101 CONFIG_LOGOUTAPPLET core/applets/logoutappletlogoutapplet.pro 102 CONFIG_LOGOUTAPPLET core/applets/logoutappletlogoutapplet.pro
102 CONFIG_MAIL3 noncore/net/mail mail.pro 103 CONFIG_MAIL3 noncore/net/mail mail.pro
103CONFIG_MAILAPPLET noncore/net/mail/taskbarapplet taskbarapplet.pro 104CONFIG_MAILAPPLET noncore/net/mail/taskbarapplet taskbarapplet.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