-rw-r--r-- | libopie2/opiesecurity/multiauthpassword.cpp | 47 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthpassword.h | 10 |
2 files changed, 48 insertions, 9 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 | |||
@@ -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 | */ |
60 | bool MultiauthPassword::needToAuthenticate(bool at_poweron) | 62 | bool 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 | */ |
83 | void MultiauthPassword::authenticate(bool at_poweron) | 86 | void 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 @@ | |||
38 | namespace Opie { | 38 | namespace Opie { |
39 | namespace Security { | 39 | namespace Security { |
40 | 40 | ||
41 | enum 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 | */ |
50 | class MultiauthPassword { | 55 | class MultiauthPassword { |
56 | |||
51 | public: | 57 | public: |
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 | ||