summaryrefslogtreecommitdiff
path: root/libopie2/opiesecurity/multiauthpassword.cpp
Unidiff
Diffstat (limited to 'libopie2/opiesecurity/multiauthpassword.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiesecurity/multiauthpassword.cpp45
1 files changed, 39 insertions, 6 deletions
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
@@ -8,98 +8,131 @@
8 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> 8 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
9 .>+-= 9 .>+-=
10 _;:, .> :=|. This library is free software; you can 10 _;:, .> :=|. This library is free software; you can
11.> <`_, > . <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 12:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
13.="- .-=="i, .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - . .-<_> .<> Foundation; either version 2 of the License, 14 - . .-<_> .<> Foundation; either version 2 of the License,
15 ._= =} : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16 .%`+i> _;_. 16 .%`+i> _;_.
17 .i_,=:_. -<s. This library is distributed in the hope that 17 .i_,=:_. -<s. This library is distributed in the hope that
18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19 : .. .:, . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.= = ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++= -. .` .: details. 23++= -. .` .: details.
24 : = ...= . :.=- 24 : = ...= . :.=-
25 -. .:....=;==+<; You should have received a copy of the GNU 25 -. .:....=;==+<; You should have received a copy of the GNU
26 -_. . . )=. = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27 -- :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34 34
35/* OPIE */ 35/* OPIE */
36#include <opie2/multiauthcommon.h> 36#include <opie2/multiauthcommon.h>
37#include <opie2/multiauthmainwindow.h> 37#include <opie2/multiauthmainwindow.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39#include <qpe/qlibrary.h> 39#include <qpe/qlibrary.h>
40#include <qpe/qcom.h> 40#include <qpe/qcom.h>
41 41
42/* QT */ 42/* QT */
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qvbox.h> 44#include <qvbox.h>
45#include <qpushbutton.h> 45#include <qpushbutton.h>
46#include <qlabel.h> 46#include <qlabel.h>
47#include <qdir.h> 47#include <qdir.h>
48 48
49#include "multiauthpassword.h" 49#include "multiauthpassword.h"
50 50
51namespace Opie { 51namespace Opie {
52namespace Security { 52namespace 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{
62 Config cfg("Security"); 64 Config cfg("Security");
63 cfg.setGroup("Misc"); 65 cfg.setGroup("Misc");
64 if ( !at_poweron && cfg.readBoolEntry("onStart", false) ) 66 if ( !at_poweron && cfg.readBoolEntry("onStart", false) )
65 return true; 67 return true;
66 else if ( at_poweron && cfg.readBoolEntry("onResume", false) ) 68 else if ( at_poweron && cfg.readBoolEntry("onResume", false) )
67 return true; 69 return true;
68 else 70 else
69 return false; 71 return false;
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
78 * authentication (explaining what it does or not, depending 81 * authentication (explaining what it does or not, depending
79 * on your local configuration). 82 * on your local configuration).
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)
87{
88 /**
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) )
84{ 98{
85 if ( ! needToAuthenticate(at_poweron) ) 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 ) )
86 return; 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();
95 win.setGeometry( 0, 0, desk.width(), desk.height() ); 128 win.setGeometry( 0, 0, desk.width(), desk.height() );
96 129
97 // the authentication has already succeeded (without win interactions) 130 // the authentication has already succeeded (without win interactions)
98 if ( win.isAlreadyDone() ) 131 if ( win.isAlreadyDone() )
99 return; 132 return;
100 133
101 win.exec(); 134 win.exec();
102} 135}
103 136
104} 137}
105} 138}