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
@@ -44,60 +44,93 @@
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