summaryrefslogtreecommitdiff
authorclem <clem>2004-10-05 23:38:06 (UTC)
committer clem <clem>2004-10-05 23:38:06 (UTC)
commitc09e45b02053c61b4e195c9d79a573ebfed2c521 (patch) (unidiff)
tree504a1a7d6b29e9dc186b2a7a7431ea41482041e3
parent2d05ffb4bad93532e17b9350ff2d66fe3419cbe3 (diff)
downloadopie-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.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/settings/security/multiauthconfig.cpp125
-rw-r--r--core/settings/security/multiauthconfig.h18
-rw-r--r--libopie2/opiesecurity/multiauthmainwindow.cpp21
-rw-r--r--libopie2/opiesecurity/multiauthmainwindow.h2
4 files changed, 100 insertions, 66 deletions
diff --git a/core/settings/security/multiauthconfig.cpp b/core/settings/security/multiauthconfig.cpp
index 3c73d7b..192b8ca 100644
--- a/core/settings/security/multiauthconfig.cpp
+++ b/core/settings/security/multiauthconfig.cpp
@@ -1,9 +1,8 @@
1#include "multiauthconfig.h"
2
3#include <opie2/odebug.h> 1#include <opie2/odebug.h>
2#include <opie2/multiauthmainwindow.h>
4 3
5#include <qgroupbox.h> 4#include <qgroupbox.h>
6#include <qvgroupbox.h> 5#include <qvgroupbox.h>
7#include <qpe/resource.h> 6#include <qpe/resource.h>
8#include <qlayout.h> 7#include <qlayout.h>
9#include <qlabel.h> 8#include <qlabel.h>
@@ -14,12 +13,14 @@
14#include <qtoolbutton.h> 13#include <qtoolbutton.h>
15#include <qstringlist.h> 14#include <qstringlist.h>
16#include <qdir.h> 15#include <qdir.h>
17#include <qpe/qlibrary.h> 16#include <qpe/qlibrary.h>
18#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
19 18
19#include "multiauthconfig.h"
20
20 21
21using Opie::Security::MultiauthPluginInterface; 22using Opie::Security::MultiauthPluginInterface;
22using Opie::Security::MultiauthPluginObject; 23using Opie::Security::MultiauthPluginObject;
23using Opie::Security::MultiauthConfigWidget; 24using Opie::Security::MultiauthConfigWidget;
24/// keeps information about MultiauthPluginObject plugins 25/// keeps information about MultiauthPluginObject plugins
25struct MultiauthPlugin { 26struct MultiauthPlugin {
@@ -53,79 +54,94 @@ class ToolButton : public QToolButton {
53 setFocusPolicy( QWidget::NoFocus ); 54 setFocusPolicy( QWidget::NoFocus );
54 setToggleButton( t ); 55 setToggleButton( t );
55 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 56 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
56 } 57 }
57}; 58};
58 59
59 MultiauthGeneralConfig::MultiauthGeneralConfig(QWidget * parent, const char * name = "general Opie-multiauthentication config widget") 60 MultiauthGeneralConfig::MultiauthGeneralConfig(MultiauthConfig * parentConfig, QWidget * parent, const char * name = "general Opie-multiauthentication config widget")
60: QWidget(parent, name), onStart(0), onResume(0), nbSuccessMin(0) 61: QWidget(parent, name), m_onStart(0), m_onResume(0), m_noProtectConfig(0), m_explanScreens(0), m_nbSuccessMin(0), m_tryButton(0)
61{ 62{
63 // keep track of the MultiauthConfig parent in one of our attributes
64 m_parentConfig = parentConfig;
62 QVBoxLayout *vb = new QVBoxLayout(this); 65 QVBoxLayout *vb = new QVBoxLayout(this);
63 vb->setSpacing(11); 66 vb->setSpacing(11);
64 vb->setMargin(11); 67 vb->setMargin(11);
65 vb->setAlignment( Qt::AlignTop ); 68 vb->setAlignment( Qt::AlignTop );
66 69
67 QGroupBox *lockBox = new QGroupBox(0, Qt::Vertical, tr("When to lock Opie"), this, "lock box"); 70 QGroupBox *lockBox = new QGroupBox(0, Qt::Vertical, tr("When to lock Opie"), this, "lock box");
68 vb->addWidget(lockBox); 71 vb->addWidget(lockBox);
69 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() ); 72 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() );
70 onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start"); 73 m_onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start");
71 onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume"); 74 m_onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume");
72 boxLayout->addWidget(onStart, 0, 0); 75 boxLayout->addWidget(m_onStart, 0, 0);
73 boxLayout->addWidget(onResume, 0, 1); 76 boxLayout->addWidget(m_onResume, 0, 1);
74 77
75 QGroupBox *nbBox = new QGroupBox(0, Qt::Vertical, tr("Multiple plugins authentication"), this, "nb box"); 78 QGroupBox *nbBox = new QGroupBox(0, Qt::Vertical, tr("Multiple plugins authentication"), this, "nb box");
76 vb->addWidget(nbBox); 79 vb->addWidget(nbBox);
77 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() ); 80 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() );
78 nbSuccessMin = new QSpinBox(nbBox); 81 m_nbSuccessMin = new QSpinBox(nbBox);
79 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox); 82 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox);
80 nbBoxLayout->addWidget(nbSuccessMin, 0, 0); 83 nbBoxLayout->addWidget(m_nbSuccessMin, 0, 0);
81 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1); 84 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1);
82 nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor 85 m_nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor
83 86
84 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Debug options"), this, "dev box"); 87 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Options"), this, "dev box");
85 vb->addWidget(devBox); 88 vb->addWidget(devBox);
86 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() ); 89 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() );
87 noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config"); 90 m_noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config");
88 explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens"); 91 m_explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens");
89 allowBypass = new QCheckBox( tr("Allow to bypass authentication"), devBox, "AllowBypass"); 92 devBoxLayout->addWidget(m_noProtectConfig, 0, 0);
90 QLabel *logicNote = new QLabel( "<p>" + tr("Note: the third option implies the second one") + "</p>", devBox ); 93 devBoxLayout->addWidget(m_explanScreens, 1, 0);
91 devBoxLayout->addWidget(noProtectConfig, 0, 0); 94
92 devBoxLayout->addWidget(explanScreens, 1, 0); 95 QVGroupBox *tryBox = new QVGroupBox(tr("Testing"), this, "try box");
93 devBoxLayout->addWidget(allowBypass, 2, 0); 96 vb->addWidget(tryBox);
94 devBoxLayout->addMultiCellWidget(logicNote, 3, 3, 0, 1); 97 m_tryButton = new QPushButton( tr("Test the authentication now"), tryBox, "try button");
98 connect( m_tryButton, SIGNAL(clicked()), this, SLOT(tryAuth()) );
95 99
96 connect( explanScreens, SIGNAL(toggled(bool)), this, SLOT(checkBypass()) );
97 connect( allowBypass, SIGNAL(toggled(bool)), this, SLOT(checkScreens()) );
98} 100}
99 101
100/// nothing to do 102/// nothing to do
101MultiauthGeneralConfig::~MultiauthGeneralConfig() 103MultiauthGeneralConfig::~MultiauthGeneralConfig()
102{} 104{}
103 105
104/// Be sure that explanScreens is checked if allowBypass is 106/// launches the authentication process, as configured, with the option to bypass it
105void MultiauthGeneralConfig::checkScreens() 107void MultiauthGeneralConfig::tryAuth()
106{ 108{
107 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) ) 109 QMessageBox confirmSave(
108 explanScreens->setChecked(true); 110 tr("Attention"),
109} 111 "<p>" + tr("You must save your current settings before trying to authenticate. Press OK to accept and launch a simulated authentication process.") + "</p><p><em>" +
112 tr("If you don't like the result of this test, don't forget to change your settings before you exit the configuration application!") + "</em></p>",
113 QMessageBox::Warning,
114 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
115 0, QString::null, TRUE, WStyle_StaysOnTop);
116 confirmSave.setButtonText(QMessageBox::Cancel, tr("Cancel"));
117 confirmSave.setButtonText(QMessageBox::Yes, tr("OK"));
110 118
111/// Be sure that allowBypass is not checked if explanScreens is not 119 if ( confirmSave.exec() == QMessageBox::Yes)
112void MultiauthGeneralConfig::checkBypass()
113{ 120{
114 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) ) 121 owarn << "writing config as user accepted" << oendl;
115 allowBypass->setChecked(false); 122 m_parentConfig->writeConfigs();
116} 123 owarn << "testing authentication" << oendl;
117
118
119
120 124
125 /* launch the authentication in debug, aka "allowBypass == true", mode
126 */
121 127
128 Opie::Security::MultiauthMainWindow win(true);
129 // resize the QDialog object so it fills all the screen
130 QRect desk = qApp->desktop()->geometry();
131 win.setGeometry( 0, 0, desk.width(), desk.height() );
122 132
133 // the authentication has already succeeded (without win interactions)
134 if ( win.isAlreadyDone() )
135 return;
123 136
137 win.exec();
124 138
139 }
125 140
141}
126 142
127 143
128/// Builds and displays the Opie multi-authentication configuration dialog 144/// Builds and displays the Opie multi-authentication configuration dialog
129static void test_and_start() { 145static void test_and_start() {
130 Config pcfg("Security"); 146 Config pcfg("Security");
131 pcfg.setGroup( "Misc" ); 147 pcfg.setGroup( "Misc" );
@@ -136,13 +152,13 @@ static void test_and_start() {
136 exit( -1 ); 152 exit( -1 );
137 } 153 }
138} 154}
139 155
140 156
141 157
142 MultiauthConfig::MultiauthConfig(QWidget* par, const char* w, WFlags f) 158 MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0)
143: QDialog(par, w, TRUE, f), 159: QDialog(par, w, TRUE, f),
144 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0), 160 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0),
145 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0), 161 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0),
146 m_nbSuccessReq(0), m_plugins_changed(false) 162 m_nbSuccessReq(0), m_plugins_changed(false)
147{ 163{
148 /* Initializes the global configuration window 164 /* Initializes the global configuration window
@@ -159,13 +175,13 @@ static void test_and_start() {
159 m_pluginsInstalled = ! list.isEmpty(); 175 m_pluginsInstalled = ! list.isEmpty();
160 if (m_pluginsInstalled == false) 176 if (m_pluginsInstalled == false)
161 owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl; 177 owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl;
162 178
163 setCaption( tr( "Security configuration" ) ); 179 setCaption( tr( "Security configuration" ) );
164 QVBoxLayout *layout = new QVBoxLayout( this ); 180 QVBoxLayout *layout = new QVBoxLayout( this );
165 m_mainTW = new Opie::Ui::OTabWidget( this ); 181 m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" );
166 layout->addWidget(m_mainTW); 182 layout->addWidget(m_mainTW);
167 183
168 if (m_pluginsInstalled) 184 if (m_pluginsInstalled)
169 { 185 {
170 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget"); 186 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget");
171 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); 187 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
@@ -187,13 +203,13 @@ static void test_and_start() {
187 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); 203 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
188 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) ); 204 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) );
189 205
190 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) ); 206 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) );
191 207
192 // general Opie multi-authentication configuration tab 208 // general Opie multi-authentication configuration tab
193 m_generalConfig = new MultiauthGeneralConfig(m_mainTW); 209 m_generalConfig = new MultiauthGeneralConfig(this, m_mainTW);
194 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") ); 210 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") );
195 211
196 } 212 }
197 // login settings page 213 // login settings page
198 m_loginWidget = new LoginBase(m_mainTW, "login config widget"); 214 m_loginWidget = new LoginBase(m_mainTW, "login config widget");
199 m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") ); 215 m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") );
@@ -238,13 +254,13 @@ static void test_and_start() {
238 } 254 }
239 255
240 // set the first tab as default. 256 // set the first tab as default.
241 m_mainTW->setCurrentTab(m_pluginListWidget); 257 m_mainTW->setCurrentTab(m_pluginListWidget);
242 258
243 // put the number of plugins as the max number of req. auth. 259 // put the number of plugins as the max number of req. auth.
244 m_generalConfig->nbSuccessMin->setMaxValue( pluginList.count() ); 260 m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() );
245 } 261 }
246 else 262 else
247 { 263 {
248 /* we don't have any installed plugin there. Let's tell 264 /* we don't have any installed plugin there. Let's tell
249 * that to the user in a third tab, using the m_pluginListWidget widget 265 * that to the user in a third tab, using the m_pluginListWidget widget
250 */ 266 */
@@ -268,20 +284,25 @@ static void test_and_start() {
268 284
269/// nothing to do 285/// nothing to do
270MultiauthConfig::~MultiauthConfig() 286MultiauthConfig::~MultiauthConfig()
271{ 287{
272} 288}
273 289
274void MultiauthConfig::accept() { 290/// saves the general and plugin(s) configurations
291void MultiauthConfig::writeConfigs() {
275 writeConfig(); 292 writeConfig();
276 293
277 MultiauthConfigWidget* confWidget = 0; 294 MultiauthConfigWidget* confWidget = 0;
278 for ( confWidget = configWidgetList.first(); confWidget != 0; 295 for ( confWidget = configWidgetList.first(); confWidget != 0;
279 confWidget = configWidgetList.next() ) 296 confWidget = configWidgetList.next() )
280 confWidget->writeConfig(); 297 confWidget->writeConfig();
298}
281 299
300/// on QDialog::accept, we save all the configurations and exit the QDialog normally
301void MultiauthConfig::accept() {
302 writeConfigs();
282 QDialog::accept(); 303 QDialog::accept();
283} 304}
284 305
285void MultiauthConfig::done( int r ) { 306void MultiauthConfig::done( int r ) {
286 QDialog::done( r ); 307 QDialog::done( r );
287 close(); 308 close();
@@ -311,18 +332,17 @@ void MultiauthConfig::readConfig()
311 // pointer, so we release this Config when we want 332 // pointer, so we release this Config when we want
312 Config* pcfg = new Config("Security"); 333 Config* pcfg = new Config("Security");
313 334
314 if (m_pluginsInstalled) 335 if (m_pluginsInstalled)
315 { 336 {
316 pcfg->setGroup( "Misc" ); 337 pcfg->setGroup( "Misc" );
317 m_generalConfig->onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); 338 m_generalConfig->m_onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) );
318 m_generalConfig->onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); 339 m_generalConfig->m_onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) );
319 m_generalConfig->nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); 340 m_generalConfig->m_nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) );
320 m_generalConfig->noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); 341 m_generalConfig->m_noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) );
321 m_generalConfig->explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); 342 m_generalConfig->m_explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) );
322 m_generalConfig->allowBypass->setChecked( pcfg->readBoolEntry( "allowBypass", false ) );
323 343
324 pcfg->setGroup( "Plugins" ); 344 pcfg->setGroup( "Plugins" );
325 m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' ); 345 m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' );
326 m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' ); 346 m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' );
327 } 347 }
328 348
@@ -420,18 +440,17 @@ void MultiauthConfig::writeConfig()
420 } 440 }
421 pcfg->writeEntry( "ExcludePlugins", exclude, ',' ); 441 pcfg->writeEntry( "ExcludePlugins", exclude, ',' );
422 pcfg->writeEntry( "IncludePlugins", include, ',' ); 442 pcfg->writeEntry( "IncludePlugins", include, ',' );
423 pcfg->writeEntry( "AllPlugins", allPlugins, ',' ); 443 pcfg->writeEntry( "AllPlugins", allPlugins, ',' );
424 444
425 pcfg->setGroup( "Misc" ); 445 pcfg->setGroup( "Misc" );
426 pcfg->writeEntry( "onStart", m_generalConfig->onStart->isChecked() ); 446 pcfg->writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() );
427 pcfg->writeEntry( "onResume", m_generalConfig->onResume->isChecked() ); 447 pcfg->writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() );
428 pcfg->writeEntry( "nbSuccessMin", m_generalConfig->nbSuccessMin->text() ); 448 pcfg->writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() );
429 pcfg->writeEntry( "noProtectConfig", m_generalConfig->noProtectConfig->isChecked() ); 449 pcfg->writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() );
430 pcfg->writeEntry( "explanScreens", m_generalConfig->explanScreens->isChecked() ); 450 pcfg->writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() );
431 pcfg->writeEntry( "allowBypass", m_generalConfig->allowBypass->isChecked() );
432 } 451 }
433 452
434 /* Login and Sync stuff */ 453 /* Login and Sync stuff */
435 454
436 pcfg->setGroup("Sync"); 455 pcfg->setGroup("Sync");
437 int auth_peer=0; 456 int auth_peer=0;
@@ -576,13 +595,13 @@ void MultiauthConfig::restoreDefaults()
576 tr("Attention"), 595 tr("Attention"),
577 "<p>" + tr("All user-defined net ranges will be lost.") + "</p>", 596 "<p>" + tr("All user-defined net ranges will be lost.") + "</p>",
578 QMessageBox::Warning, 597 QMessageBox::Warning,
579 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, 598 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
580 0, QString::null, TRUE, WStyle_StaysOnTop); 599 0, QString::null, TRUE, WStyle_StaysOnTop);
581 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); 600 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel"));
582 unrecbox.setButtonText(QMessageBox::Yes, tr("Ok")); 601 unrecbox.setButtonText(QMessageBox::Yes, tr("OK"));
583 602
584 if ( unrecbox.exec() == QMessageBox::Yes) 603 if ( unrecbox.exec() == QMessageBox::Yes)
585 { 604 {
586 m_syncWidget->syncnet->clear(); 605 m_syncWidget->syncnet->clear();
587 insertDefaultRanges(); 606 insertDefaultRanges();
588 } 607 }
diff --git a/core/settings/security/multiauthconfig.h b/core/settings/security/multiauthconfig.h
index 5287083..e64795c 100644
--- a/core/settings/security/multiauthconfig.h
+++ b/core/settings/security/multiauthconfig.h
@@ -54,59 +54,64 @@
54#include <qtextstream.h> 54#include <qtextstream.h>
55 55
56/* UI */ 56/* UI */
57#include "syncbase.h" 57#include "syncbase.h"
58#include "loginbase.h" 58#include "loginbase.h"
59 59
60class MultiauthConfig;
61class MultiauthGeneralConfig;
60 62
61/// the "misc" configuration tab, about general Opie Multiauth settings 63/// the "misc" configuration tab, about general Opie Multiauth settings
62class MultiauthGeneralConfig : public QWidget 64class MultiauthGeneralConfig : public QWidget
63{ 65{
64 Q_OBJECT 66 Q_OBJECT
65public: 67public:
66 MultiauthGeneralConfig(QWidget * parent, const char * name); 68 MultiauthGeneralConfig(MultiauthConfig * parentConfig, QWidget * parent, const char * name);
67 ~MultiauthGeneralConfig(); 69 ~MultiauthGeneralConfig();
68protected: 70protected:
69 QCheckBox *onStart, *onResume, *noProtectConfig, *explanScreens, *allowBypass; 71 QCheckBox *m_onStart, *m_onResume, *m_noProtectConfig, *m_explanScreens;
70 QSpinBox *nbSuccessMin; 72 QSpinBox *m_nbSuccessMin;
71private: 73private:
72 friend class MultiauthConfig; 74 friend class MultiauthConfig;
75 /// pointer to the MultiauthConfig that called us
76 MultiauthConfig *m_parentConfig;
77 QPushButton *m_tryButton;
73private slots: 78private slots:
74 void checkBypass(); 79 void tryAuth();
75 void checkScreens();
76}; 80};
77 81
78/// the whole configuration dialog 82/// the whole configuration dialog
79class MultiauthConfig : public QDialog 83class MultiauthConfig : public QDialog
80{ 84{
81 Q_OBJECT 85 Q_OBJECT
82 86
83public: 87public:
84 static QString appName() { return QString::fromLatin1("security"); } 88 static QString appName() { return QString::fromLatin1("security"); }
85 MultiauthConfig(QWidget *parent, const char* name, WFlags fl); 89 MultiauthConfig(QWidget *parent, const char* name, WFlags fl);
86 virtual ~MultiauthConfig(); 90 virtual ~MultiauthConfig();
87 void writeConfig();
88 QList<Opie::Security::MultiauthConfigWidget> configWidgetList; 91 QList<Opie::Security::MultiauthConfigWidget> configWidgetList;
89 92
90protected slots: 93protected slots:
91 void accept(); 94 void accept();
92 void done(int r); 95 void done(int r);
93 void pluginsChanged(); 96 void pluginsChanged();
94 void moveSelectedUp(); 97 void moveSelectedUp();
95 void moveSelectedDown(); 98 void moveSelectedDown();
99 void writeConfigs();
96 100
97private slots: 101private slots:
98 // Login and Sync stuff 102 // Login and Sync stuff
99 void setSyncNet(const QString&); 103 void setSyncNet(const QString&);
100 void changeLoginName(int); 104 void changeLoginName(int);
101 void toggleAutoLogin(bool); 105 void toggleAutoLogin(bool);
102 void restoreDefaults(); 106 void restoreDefaults();
103 void insertDefaultRanges(); 107 void insertDefaultRanges();
104 void deleteListEntry(); 108 void deleteListEntry();
105 109
106private: 110private:
111 friend class MultiauthGeneralConfig;
107 /// the widget holding all the tabs (or pages) 112 /// the widget holding all the tabs (or pages)
108 Opie::Ui::OTabWidget *m_mainTW; 113 Opie::Ui::OTabWidget *m_mainTW;
109 /// list of authentication plugins in the "Plugins" page 114 /// list of authentication plugins in the "Plugins" page
110 QListView *m_pluginListView; 115 QListView *m_pluginListView;
111 QStringList m_allPlugins, m_excludePlugins; 116 QStringList m_allPlugins, m_excludePlugins;
112 QMap<QString,QCheckListItem*> m_plugins; 117 QMap<QString,QCheckListItem*> m_plugins;
@@ -121,12 +126,13 @@ private:
121 126
122 int m_nbSuccessReq; 127 int m_nbSuccessReq;
123 bool m_plugins_changed; 128 bool m_plugins_changed;
124 bool m_pluginsInstalled; 129 bool m_pluginsInstalled;
125 130
126 void readConfig(); 131 void readConfig();
132 void writeConfig();
127 void loadPlugins(); 133 void loadPlugins();
128 134
129 // Login and Sync stuff 135 // Login and Sync stuff
130 void loadUsers(); 136 void loadUsers();
131 bool telnetAvailable() const; 137 bool telnetAvailable() const;
132 bool sshAvailable() const; 138 bool sshAvailable() const;
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
@@ -3,28 +3,35 @@
3#include "multiauthcommon.h" 3#include "multiauthcommon.h"
4#include <qpe/config.h> 4#include <qpe/config.h>
5 5
6namespace Opie { 6namespace Opie {
7namespace Security { 7namespace 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
10MultiauthMainWindow::MultiauthMainWindow() 10/**
11 * \note if allowBypass is true, we will show explanatory screens anyway
12 */
13MultiauthMainWindow::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
23 if (allowBypass == true)
24 explanScreens = true;
25 else
26 {
20 Config *pcfg = new Config("Security"); 27 Config *pcfg = new Config("Security");
21 pcfg->setGroup("Misc"); 28 pcfg->setGroup("Misc");
22 explanScreens = pcfg->readBoolEntry("explanScreens", true); 29 explanScreens = pcfg->readBoolEntry("explanScreens", true);
23 allowBypass = pcfg->readBoolEntry("allowBypass", false);
24 delete pcfg; 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
@@ -50,13 +57,13 @@ MultiauthMainWindow::MultiauthMainWindow()
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();
@@ -111,16 +118,18 @@ void MultiauthMainWindow::proceed() {
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
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
@@ -52,13 +52,13 @@ namespace Security {
52 * with it. 52 * with it.
53 */ 53 */
54class MultiauthMainWindow : public QDialog { 54class 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;