author | zecke <zecke> | 2004-07-17 16:43:53 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-17 16:43:53 (UTC) |
commit | d6a4bf47ef7dfaabd08fb8d514cde1832a055816 (patch) (unidiff) | |
tree | 6b56864c43d18885924f39bd76bd5ed3852a74b4 /libopie2/opiesecurity | |
parent | 889c782a33abc8f5f15a0669c6d97688d22c304f (diff) | |
download | opie-d6a4bf47ef7dfaabd08fb8d514cde1832a055816.zip opie-d6a4bf47ef7dfaabd08fb8d514cde1832a055816.tar.gz opie-d6a4bf47ef7dfaabd08fb8d514cde1832a055816.tar.bz2 |
Add dropin for the Password implementation of libqpe
-rw-r--r-- | libopie2/opiesecurity/multiauthpassword.cpp | 106 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthpassword.h | 59 |
2 files changed, 165 insertions, 0 deletions
diff --git a/libopie2/opiesecurity/multiauthpassword.cpp b/libopie2/opiesecurity/multiauthpassword.cpp new file mode 100644 index 0000000..16c8568 --- a/dev/null +++ b/libopie2/opiesecurity/multiauthpassword.cpp | |||
@@ -0,0 +1,106 @@ | |||
1 | /** | ||
2 | * \file multiauthpassord.cpp | ||
3 | * \brief Password Dialog dropin. | ||
4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
5 | */ | ||
6 | /* | ||
7 | =. This file is part of the Opie Project | ||
8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This library is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This library is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | |||
35 | /* OPIE */ | ||
36 | #include <opie2/multiauthcommon.h> | ||
37 | #include <opie2/multiauthmainwindow.h> | ||
38 | #include <qpe/config.h> | ||
39 | #include <qpe/qlibrary.h> | ||
40 | #include <qpe/qcom.h> | ||
41 | |||
42 | /* QT */ | ||
43 | #include <qapplication.h> | ||
44 | #include <qvbox.h> | ||
45 | #include <qpushbutton.h> | ||
46 | #include <qlabel.h> | ||
47 | #include <qdir.h> | ||
48 | |||
49 | #include "multiauthpassword.h" | ||
50 | |||
51 | namespace Opie { | ||
52 | namespace Security { | ||
53 | |||
54 | |||
55 | /** | ||
56 | * If the users requires authentication... #fixme | ||
57 | * | ||
58 | * @todo fix up at_poweron attribute | ||
59 | */ | ||
60 | bool MultiauthPassword::needToAuthenticate(bool at_poweron) | ||
61 | { | ||
62 | Config cfg("Security"); | ||
63 | cfg.setGroup("Misc"); | ||
64 | if ( !at_poweron && cfg.readBoolEntry("onStart", true) ) | ||
65 | return true; | ||
66 | else if ( at_poweron && cfg.readBoolEntry("onResume", true) ) | ||
67 | return true; | ||
68 | else | ||
69 | return false; | ||
70 | } | ||
71 | |||
72 | |||
73 | /** | ||
74 | * \brief Require user authentication to unlock and continue | ||
75 | * | ||
76 | * This method will check if you require authentication | ||
77 | * and then will lock the screen and require a succesfull | ||
78 | * authentication. | ||
79 | * Authenticate may enter the event loop and only returns | ||
80 | * if the user sucesfully authenticated to the system. | ||
81 | * | ||
82 | * @return only if succesfully authenticated | ||
83 | */ | ||
84 | void MultiauthPassword::authenticate(bool at_poweron) | ||
85 | { | ||
86 | if ( ! needToAuthenticate(at_poweron) ) | ||
87 | return; | ||
88 | |||
89 | /* Constructs the main window, which displays messages and blocks | ||
90 | * access to the desktop | ||
91 | */ | ||
92 | MultiauthMainWindow win; | ||
93 | |||
94 | // resize the QDialog object so it fills all the screen | ||
95 | QRect desk = qApp->desktop()->geometry(); | ||
96 | win.setGeometry( 0, 0, desk.width(), desk.height() ); | ||
97 | |||
98 | // the authentication has already succeeded (without win interactions) | ||
99 | if ( win.isAlreadyDone() ) | ||
100 | return; | ||
101 | |||
102 | win.exec(); | ||
103 | } | ||
104 | |||
105 | } | ||
106 | } | ||
diff --git a/libopie2/opiesecurity/multiauthpassword.h b/libopie2/opiesecurity/multiauthpassword.h new file mode 100644 index 0000000..1d061b4 --- a/dev/null +++ b/libopie2/opiesecurity/multiauthpassword.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /** | ||
2 | * \file multiauthpassord.h | ||
3 | * \brief Password Dialog dropin. | ||
4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
5 | */ | ||
6 | /* | ||
7 | =. This file is part of the Opie Project | ||
8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This library is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This library is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | |||
35 | #ifndef OPIE_SEC_MULTIAUTHPASSWORD_H | ||
36 | #define OPIE_SEC_MULTIAUTHPASSWORD_H | ||
37 | |||
38 | namespace Opie { | ||
39 | namespace Security { | ||
40 | |||
41 | /** | ||
42 | * This is the dropin replacement for libqpes Password class. | ||
43 | * If you call authenticate() a widget will cover the whole screen | ||
44 | * and only return if the user is able to authenticate with any of the | ||
45 | * configured Authentication Plugins. | ||
46 | * This uses the \sa Opie::Security::MultiauthMainWindow internally. | ||
47 | * | ||
48 | * @author Clement Séveillac, Holger Freyther | ||
49 | */ | ||
50 | class MultiauthPassword { | ||
51 | public: | ||
52 | static bool needToAuthenticate( bool atpoweron=FALSE ); | ||
53 | static void authenticate(bool atpoweron = FALSE ); | ||
54 | }; | ||
55 | |||
56 | |||
57 | } | ||
58 | } | ||
59 | #endif | ||