author | clem <clem> | 2004-10-05 23:38:06 (UTC) |
---|---|---|
committer | clem <clem> | 2004-10-05 23:38:06 (UTC) |
commit | c09e45b02053c61b4e195c9d79a573ebfed2c521 (patch) (unidiff) | |
tree | 504a1a7d6b29e9dc186b2a7a7431ea41482041e3 /libopie2 | |
parent | 2d05ffb4bad93532e17b9350ff2d66fe3419cbe3 (diff) | |
download | opie-c09e45b02053c61b4e195c9d79a573ebfed2c521.zip opie-c09e45b02053c61b4e195c9d79a573ebfed2c521.tar.gz opie-c09e45b02053c61b4e195c9d79a573ebfed2c521.tar.bz2 |
Changed the way to test authentication: instead of having a hardcoded config
option, allowByPass, we now have a "Test now" button in the configuration
interface. We add to change both the config app and the libopie2security files
for that, since the MultiauthMainWindow constructor has to know whether to
implement a debug mode (with an new argument, false by default). We also had
to give MultiauthGeneralConfig a link to MultiauthConfig, since the test
button triggers the writing of the whole configuration.
Some cleaning too (m_ on *all* member attributes, removal of obsolete
allowByPass / explanScreens checking code.
-rw-r--r-- | libopie2/opiesecurity/multiauthmainwindow.cpp | 29 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthmainwindow.h | 2 |
2 files changed, 20 insertions, 11 deletions
diff --git a/libopie2/opiesecurity/multiauthmainwindow.cpp b/libopie2/opiesecurity/multiauthmainwindow.cpp index fa247ab..fb720bb 100644 --- a/libopie2/opiesecurity/multiauthmainwindow.cpp +++ b/libopie2/opiesecurity/multiauthmainwindow.cpp | |||
@@ -1,135 +1,144 @@ | |||
1 | #include "multiauthmainwindow.h" | 1 | #include "multiauthmainwindow.h" |
2 | 2 | ||
3 | #include "multiauthcommon.h" | 3 | #include "multiauthcommon.h" |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | 5 | ||
6 | namespace Opie { | 6 | namespace Opie { |
7 | namespace Security { | 7 | namespace Security { |
8 | 8 | ||
9 | /// Initializes widgets according to allowBypass and explanScreens config | 9 | /// Initializes widgets according to allowBypass argument (false by default) and explanScreens config |
10 | MultiauthMainWindow::MultiauthMainWindow() | 10 | /** |
11 | * \note if allowBypass is true, we will show explanatory screens anyway | ||
12 | */ | ||
13 | MultiauthMainWindow::MultiauthMainWindow(bool allowBypass = false) | ||
11 | : QDialog(0, "main Opie multiauth modal dialog", TRUE, | 14 | : QDialog(0, "main Opie multiauth modal dialog", TRUE, |
12 | Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop) | 15 | Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop) |
13 | 16 | ||
14 | { | 17 | { |
15 | alreadyDone = false; | 18 | alreadyDone = false; |
16 | // initializes widget pointers which not always point to an object | 19 | // initializes widget pointers which not always point to an object |
17 | quit = 0; | 20 | quit = 0; |
18 | message2 = 0; | 21 | message2 = 0; |
19 | 22 | ||
20 | Config *pcfg = new Config("Security"); | 23 | if (allowBypass == true) |
21 | pcfg->setGroup("Misc"); | 24 | explanScreens = true; |
22 | explanScreens = pcfg->readBoolEntry("explanScreens", true); | 25 | else |
23 | allowBypass = pcfg->readBoolEntry("allowBypass", false); | 26 | { |
24 | delete pcfg; | 27 | Config *pcfg = new Config("Security"); |
28 | pcfg->setGroup("Misc"); | ||
29 | explanScreens = pcfg->readBoolEntry("explanScreens", true); | ||
30 | delete pcfg; | ||
31 | } | ||
25 | 32 | ||
26 | layout = new QVBoxLayout(this); | 33 | layout = new QVBoxLayout(this); |
27 | layout->setSpacing(11); | 34 | layout->setSpacing(11); |
28 | layout->setMargin(11); | 35 | layout->setMargin(11); |
29 | layout->setAlignment( Qt::AlignTop ); | 36 | layout->setAlignment( Qt::AlignTop ); |
30 | 37 | ||
31 | // if explanScreens is false, we don't show any text in the QDialog, | 38 | // if explanScreens is false, we don't show any text in the QDialog, |
32 | // and we proceed directly | 39 | // and we proceed directly |
33 | if ( explanScreens == true ) | 40 | if ( explanScreens == true ) |
34 | { | 41 | { |
35 | title = new QLabel("<center><h1>" + tr("Welcome to Opie Multi-authentication Framework") + "</h1></center>", this); | 42 | title = new QLabel("<center><h1>" + tr("Welcome to Opie Multi-authentication Framework") + "</h1></center>", this); |
36 | message = new QLabel("<center><h3>" + tr("Launching authentication plugins...") + "</h3></center>", this); | 43 | message = new QLabel("<center><h3>" + tr("Launching authentication plugins...") + "</h3></center>", this); |
37 | } else { | 44 | } else { |
38 | title = new QLabel("", this); | 45 | title = new QLabel("", this); |
39 | message = new QLabel("", this); | 46 | message = new QLabel("", this); |
40 | } | 47 | } |
41 | 48 | ||
42 | layout->addWidget(title); | 49 | layout->addWidget(title); |
43 | layout->addWidget(message); | 50 | layout->addWidget(message); |
44 | proceedButton = new QPushButton(tr("Proceed..."), this); | 51 | proceedButton = new QPushButton(tr("Proceed..."), this); |
45 | layout->addWidget(proceedButton, 0, Qt::AlignHCenter); | 52 | layout->addWidget(proceedButton, 0, Qt::AlignHCenter); |
46 | 53 | ||
47 | QObject::connect(proceedButton, SIGNAL(clicked()), this, SLOT(proceed())); | 54 | QObject::connect(proceedButton, SIGNAL(clicked()), this, SLOT(proceed())); |
48 | 55 | ||
49 | if ( explanScreens == true ) | 56 | if ( explanScreens == true ) |
50 | { | 57 | { |
51 | quit = new QPushButton("Exit", this); | 58 | quit = new QPushButton("Exit", this); |
52 | layout->addWidget(quit, 0, Qt::AlignHCenter); | 59 | layout->addWidget(quit, 0, Qt::AlignHCenter); |
53 | if ( allowBypass == true ) | 60 | if ( allowBypass == true ) |
54 | { | 61 | { |
55 | // very important: we can close the widget through the quit button, and bypass authentication, only if allowBypass is set! | 62 | // very important: we can close the widget through the quit button, and bypass authentication, only if allowBypass is set! |
56 | message2 = new QLabel("<center><i>" + tr("Note: the 'exit' button should be removed for real protection, through Security config dialog") + ".</i></center>", this); | 63 | message2 = new QLabel("<center><i>" + tr("Note: this 'exit' button only appears during <b>simulations</b>, like the one we are in.") + "</i></center>", this); |
57 | layout->addWidget(message2); | 64 | layout->addWidget(message2); |
58 | QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close())); | 65 | QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close())); |
59 | } | 66 | } |
60 | else | 67 | else |
61 | { | 68 | { |
62 | quit->hide(); | 69 | quit->hide(); |
63 | } | 70 | } |
64 | 71 | ||
65 | } | 72 | } |
66 | else | 73 | else |
67 | { | 74 | { |
68 | // we will need this button only if runPlugins() fails in proceed() | 75 | // we will need this button only if runPlugins() fails in proceed() |
69 | proceedButton->hide(); | 76 | proceedButton->hide(); |
70 | // let's proceed now | 77 | // let's proceed now |
71 | proceed(); | 78 | proceed(); |
72 | } | 79 | } |
73 | } | 80 | } |
74 | 81 | ||
75 | /// nothing to do | 82 | /// nothing to do |
76 | MultiauthMainWindow::~MultiauthMainWindow() { | 83 | MultiauthMainWindow::~MultiauthMainWindow() { |
77 | } | 84 | } |
78 | 85 | ||
79 | /// launch the authentication | 86 | /// launch the authentication |
80 | void MultiauthMainWindow::proceed() { | 87 | void MultiauthMainWindow::proceed() { |
81 | int result = Internal::runPlugins(); | 88 | int result = Internal::runPlugins(); |
82 | 89 | ||
83 | 90 | ||
84 | if ( (result == 0) && !explanScreens ) | 91 | if ( (result == 0) && !explanScreens ) |
85 | { | 92 | { |
86 | // the authentication has succeeded, we can exit directly | 93 | // the authentication has succeeded, we can exit directly |
87 | // this will work if we haven't been called by the constructor of MultiauthMainWindow | 94 | // this will work if we haven't been called by the constructor of MultiauthMainWindow |
88 | close(); | 95 | close(); |
89 | // and if we've been called by this constructor, we use this variable to tell our | 96 | // and if we've been called by this constructor, we use this variable to tell our |
90 | // caller we're already done | 97 | // caller we're already done |
91 | alreadyDone = true; | 98 | alreadyDone = true; |
92 | return; | 99 | return; |
93 | } | 100 | } |
94 | else | 101 | else |
95 | { | 102 | { |
96 | 103 | ||
97 | proceedButton->setText("Another try?"); | 104 | proceedButton->setText("Another try?"); |
98 | QString resultMessage; | 105 | QString resultMessage; |
99 | 106 | ||
100 | if (result == 0) | 107 | if (result == 0) |
101 | { | 108 | { |
102 | // authentication has succeeded, adapt interface then | 109 | // authentication has succeeded, adapt interface then |
103 | message->setText( "<center><h3>" + tr("Congratulations! Your authentication has been successful.") + "</h3></center>" ); | 110 | message->setText( "<center><h3>" + tr("Congratulations! Your authentication has been successful.") + "</h3></center>" ); |
104 | quit->setText("Enter Opie"); | 111 | quit->setText("Enter Opie"); |
105 | if ( quit->isHidden() ) | 112 | if ( quit->isHidden() ) |
106 | { | 113 | { |
107 | // that means we don't allow to bypass, but now we can show and connect this button | 114 | // that means we don't allow to bypass, but now we can show and connect this button |
108 | QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close())); | 115 | QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close())); |
109 | quit->show(); | 116 | quit->show(); |
110 | } else { | 117 | } else { |
111 | if ( message2 != 0 ) message2->hide(); | 118 | if ( message2 != 0 ) message2->hide(); |
112 | } | 119 | } |
113 | } | 120 | } |
114 | else | 121 | else |
115 | { | 122 | { |
116 | // authentication has failed, explain that according to allowBypass | 123 | // authentication has failed, explain that according to allowBypass |
117 | message->setText( "<center><h3>" + tr("You have not succeeded enough authentication steps!") + "</h3></center>" ); | 124 | message->setText( "<center><h3>" + tr("You have <b>not</b> succeeded enough authentication steps!") + "</h3></center>" ); |
118 | proceedButton->show(); | 125 | proceedButton->show(); |
119 | if ( allowBypass == true ) | 126 | if ( allowBypass == true ) |
120 | message2->setText( "<center><p>" + tr("Note: if 'allow to bypass' was uncheck in Security config, you would have to go back through all the steps now.") + "</p></center>" ); | 127 | { |
128 | message2->setText( "<center><p>" + tr("Be careful: if this was not a <b>simulation</b>, you would have to go back through all the steps now.") + "</p></center>" ); | ||
129 | message2->show(); | ||
121 | } | 130 | } |
122 | } | 131 | } |
123 | } | 132 | } |
124 | 133 | ||
125 | /** When we don't show explanatory screens and we succeed authentication, | 134 | /** When we don't show explanatory screens and we succeed authentication, |
126 | * as early as during the proceed() call of the constructor, the caller must know | 135 | * as early as during the proceed() call of the constructor, the caller must know |
127 | * (through this function) authentication has already been succeeded.. | 136 | * (through this function) authentication has already been succeeded.. |
128 | * \todo try to avoid this hack? | 137 | * \todo try to avoid this hack? |
129 | */ | 138 | */ |
130 | bool MultiauthMainWindow::isAlreadyDone() { | 139 | bool MultiauthMainWindow::isAlreadyDone() { |
131 | return alreadyDone; | 140 | return alreadyDone; |
132 | } | 141 | } |
133 | 142 | ||
134 | } | 143 | } |
135 | } | 144 | } |
diff --git a/libopie2/opiesecurity/multiauthmainwindow.h b/libopie2/opiesecurity/multiauthmainwindow.h index 626b8b3..9d2376b 100644 --- a/libopie2/opiesecurity/multiauthmainwindow.h +++ b/libopie2/opiesecurity/multiauthmainwindow.h | |||
@@ -1,84 +1,84 @@ | |||
1 | /** | 1 | /** |
2 | * \file multiauthmainwindow.h | 2 | * \file multiauthmainwindow.h |
3 | * \brief Defines the Opie multiauth main window. | 3 | * \brief Defines the Opie multiauth main window. |
4 | * | 4 | * |
5 | * This implementation was derived from the today plugins implementation. | 5 | * This implementation was derived from the today plugins implementation. |
6 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | 6 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) |
7 | */ | 7 | */ |
8 | /* | 8 | /* |
9 | =. This file is part of the Opie Project | 9 | =. This file is part of the Opie Project |
10 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | 10 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
11 | .>+-= | 11 | .>+-= |
12 | _;:, .> :=|. This library is free software; you can | 12 | _;:, .> :=|. This library is free software; you can |
13 | .> <`_, > . <= redistribute it and/or modify it under | 13 | .> <`_, > . <= redistribute it and/or modify it under |
14 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 14 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
15 | .="- .-=="i, .._ License as published by the Free Software | 15 | .="- .-=="i, .._ License as published by the Free Software |
16 | - . .-<_> .<> Foundation; either version 2 of the License, | 16 | - . .-<_> .<> Foundation; either version 2 of the License, |
17 | ._= =} : or (at your option) any later version. | 17 | ._= =} : or (at your option) any later version. |
18 | .%`+i> _;_. | 18 | .%`+i> _;_. |
19 | .i_,=:_. -<s. This library is distributed in the hope that | 19 | .i_,=:_. -<s. This library is distributed in the hope that |
20 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 20 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
21 | : .. .:, . . . without even the implied warranty of | 21 | : .. .:, . . . without even the implied warranty of |
22 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 22 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
23 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 23 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
24 | ..}^=.= = ; Library General Public License for more | 24 | ..}^=.= = ; Library General Public License for more |
25 | ++= -. .` .: details. | 25 | ++= -. .` .: details. |
26 | : = ...= . :.=- | 26 | : = ...= . :.=- |
27 | -. .:....=;==+<; You should have received a copy of the GNU | 27 | -. .:....=;==+<; You should have received a copy of the GNU |
28 | -_. . . )=. = Library General Public License along with | 28 | -_. . . )=. = Library General Public License along with |
29 | -- :-=` this library; see the file COPYING.LIB. | 29 | -- :-=` this library; see the file COPYING.LIB. |
30 | If not, write to the Free Software Foundation, | 30 | If not, write to the Free Software Foundation, |
31 | Inc., 59 Temple Place - Suite 330, | 31 | Inc., 59 Temple Place - Suite 330, |
32 | Boston, MA 02111-1307, USA. | 32 | Boston, MA 02111-1307, USA. |
33 | 33 | ||
34 | */ | 34 | */ |
35 | 35 | ||
36 | #ifndef MULTIAUTHMAINWINDOW_H | 36 | #ifndef MULTIAUTHMAINWINDOW_H |
37 | #define MULTIAUTHMAINWINDOW_H | 37 | #define MULTIAUTHMAINWINDOW_H |
38 | 38 | ||
39 | #include <qdialog.h> | 39 | #include <qdialog.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | 43 | ||
44 | 44 | ||
45 | namespace Opie { | 45 | namespace Opie { |
46 | namespace Security { | 46 | namespace Security { |
47 | 47 | ||
48 | /// Multiauth main window | 48 | /// Multiauth main window |
49 | /** | 49 | /** |
50 | * This QDialog window displays some information and an exit button, | 50 | * This QDialog window displays some information and an exit button, |
51 | * and completely hides the desktop, preventing user interactions | 51 | * and completely hides the desktop, preventing user interactions |
52 | * with it. | 52 | * with it. |
53 | */ | 53 | */ |
54 | class MultiauthMainWindow : public QDialog { | 54 | class MultiauthMainWindow : public QDialog { |
55 | Q_OBJECT | 55 | Q_OBJECT |
56 | 56 | ||
57 | public: | 57 | public: |
58 | MultiauthMainWindow(); | 58 | MultiauthMainWindow(bool allowBypass = false); |
59 | ~MultiauthMainWindow(); | 59 | ~MultiauthMainWindow(); |
60 | bool isAlreadyDone(); | 60 | bool isAlreadyDone(); |
61 | 61 | ||
62 | private: | 62 | private: |
63 | QVBoxLayout * layout; | 63 | QVBoxLayout * layout; |
64 | QLabel * title, * message, * message2; | 64 | QLabel * title, * message, * message2; |
65 | QPushButton * proceedButton, * quit; | 65 | QPushButton * proceedButton, * quit; |
66 | /// whether to show explanatory screens before and after the authentication plugins | 66 | /// whether to show explanatory screens before and after the authentication plugins |
67 | bool explanScreens; | 67 | bool explanScreens; |
68 | /// allow to bypass authnentication via 'exit' buttons on both explan. screens | 68 | /// allow to bypass authnentication via 'exit' buttons on both explan. screens |
69 | bool allowBypass; | 69 | bool allowBypass; |
70 | /// true when the authentication has been done successfully | 70 | /// true when the authentication has been done successfully |
71 | bool alreadyDone; | 71 | bool alreadyDone; |
72 | 72 | ||
73 | private slots: | 73 | private slots: |
74 | void proceed(); | 74 | void proceed(); |
75 | private: | 75 | private: |
76 | struct Private; | 76 | struct Private; |
77 | Private *d; | 77 | Private *d; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | #endif // MULTIAUTHMAINWINDOW_H | 83 | #endif // MULTIAUTHMAINWINDOW_H |
84 | 84 | ||