summaryrefslogtreecommitdiff
path: root/core/settings
authorclem <clem>2004-09-30 15:11:21 (UTC)
committer clem <clem>2004-09-30 15:11:21 (UTC)
commita823eb5b367c32936a9958f69a9981a55e2022bf (patch) (unidiff)
tree96c61ec870bd72f53047439eb9c610207e510f6a /core/settings
parent5cb30454d4a974bacfae126a5b8b321bae8ca600 (diff)
downloadopie-a823eb5b367c32936a9958f69a9981a55e2022bf.zip
opie-a823eb5b367c32936a9958f69a9981a55e2022bf.tar.gz
opie-a823eb5b367c32936a9958f69a9981a55e2022bf.tar.bz2
- As Zecke suggested, we now hide the plugin list and authentication
configuration tabs if no authentication plugin is installed (but we tell the user a few things about authentication in a third tab). - Small warning about syncnet removed.
Diffstat (limited to 'core/settings') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/security/multiauthconfig.cpp264
-rw-r--r--core/settings/security/multiauthconfig.h1
2 files changed, 158 insertions, 107 deletions
diff --git a/core/settings/security/multiauthconfig.cpp b/core/settings/security/multiauthconfig.cpp
index ff11e49..3c73d7b 100644
--- a/core/settings/security/multiauthconfig.cpp
+++ b/core/settings/security/multiauthconfig.cpp
@@ -3,6 +3,7 @@
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4 4
5#include <qgroupbox.h> 5#include <qgroupbox.h>
6#include <qvgroupbox.h>
6#include <qpe/resource.h> 7#include <qpe/resource.h>
7#include <qlayout.h> 8#include <qlayout.h>
8#include <qlabel.h> 9#include <qlabel.h>
@@ -55,8 +56,8 @@ class ToolButton : public QToolButton {
55 } 56 }
56}; 57};
57 58
58MultiauthGeneralConfig::MultiauthGeneralConfig(QWidget * parent, const char * name = "general Opie-multiauthentication config widget") 59 MultiauthGeneralConfig::MultiauthGeneralConfig(QWidget * parent, const char * name = "general Opie-multiauthentication config widget")
59 : QWidget(parent, name), onStart(0), onResume(0), nbSuccessMin(0) 60: QWidget(parent, name), onStart(0), onResume(0), nbSuccessMin(0)
60{ 61{
61 QVBoxLayout *vb = new QVBoxLayout(this); 62 QVBoxLayout *vb = new QVBoxLayout(this);
62 vb->setSpacing(11); 63 vb->setSpacing(11);
@@ -131,53 +132,68 @@ static void test_and_start() {
131 bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true); 132 bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true);
132 133
133 if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) { 134 if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) {
134 owarn << "authentication failed, not showing opie-security" << oendl; 135 owarn << "authentication failed, not showing opie-security" << oendl;
135 exit( -1 ); 136 exit( -1 );
136 } 137 }
137} 138}
138 139
139 140
140 141
141MultiauthConfig::MultiauthConfig(QWidget* par, const char* w, WFlags f) 142 MultiauthConfig::MultiauthConfig(QWidget* par, const char* w, WFlags f)
142 : QDialog(par, w, TRUE, f), 143: QDialog(par, w, TRUE, f),
143 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0), 144 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0),
144 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0), 145 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0),
145 m_nbSuccessReq(0), m_plugins_changed(false) 146 m_nbSuccessReq(0), m_plugins_changed(false)
146{ 147{
147 /* Initializes the global configuration window 148 /* Initializes the global configuration window
148 */ 149 */
149 test_and_start(); 150 test_and_start();
150 151
152 /* Checks (and memorizes) if any authentication plugins are
153 * installed on the system
154 */
155 QString path = QPEApplication::qpeDir() + "/plugins/security";
156 QDir dir( path, "lib*.so" );
157 QStringList list = dir.entryList();
158
159 m_pluginsInstalled = ! list.isEmpty();
160 if (m_pluginsInstalled == false)
161 owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl;
162
151 setCaption( tr( "Security configuration" ) ); 163 setCaption( tr( "Security configuration" ) );
152 QVBoxLayout *layout = new QVBoxLayout( this ); 164 QVBoxLayout *layout = new QVBoxLayout( this );
153 m_mainTW = new Opie::Ui::OTabWidget( this ); 165 m_mainTW = new Opie::Ui::OTabWidget( this );
154 layout->addWidget(m_mainTW); 166 layout->addWidget(m_mainTW);
155 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget");
156 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
157 pluginListLayout->setSpacing(6);
158 pluginListLayout->setMargin(11);
159 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget );
160 pluginListLayout->addWidget(pluginListTitle);
161 QHBox * pluginListHB = new QHBox(m_pluginListWidget);
162 pluginListLayout->addWidget(pluginListHB);
163
164 m_pluginListView = new QListView(pluginListHB);
165 m_pluginListView->addColumn("PluginList");
166 m_pluginListView->header()->hide();
167 m_pluginListView->setSorting(-1);
168 QWhatsThis::add(m_pluginListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the order they will appear in" ));
169
170 QVBox * pluginListVB = new QVBox(pluginListHB);
171 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
172 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
173 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) );
174
175 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) );
176
177 // general Opie multi-authentication configuration tab
178 m_generalConfig = new MultiauthGeneralConfig(m_mainTW);
179 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") );
180 167
168 if (m_pluginsInstalled)
169 {
170 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget");
171 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
172 pluginListLayout->setSpacing(6);
173 pluginListLayout->setMargin(11);
174 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget );
175 pluginListLayout->addWidget(pluginListTitle);
176 QHBox * pluginListHB = new QHBox(m_pluginListWidget);
177 pluginListLayout->addWidget(pluginListHB);
178
179 m_pluginListView = new QListView(pluginListHB);
180 m_pluginListView->addColumn("PluginList");
181 m_pluginListView->header()->hide();
182 m_pluginListView->setSorting(-1);
183 QWhatsThis::add(m_pluginListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the order they will appear in" ));
184
185 QVBox * pluginListVB = new QVBox(pluginListHB);
186 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
187 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
188 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) );
189
190 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) );
191
192 // general Opie multi-authentication configuration tab
193 m_generalConfig = new MultiauthGeneralConfig(m_mainTW);
194 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") );
195
196 }
181 // login settings page 197 // login settings page
182 m_loginWidget = new LoginBase(m_mainTW, "login config widget"); 198 m_loginWidget = new LoginBase(m_mainTW, "login config widget");
183 m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") ); 199 m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") );
@@ -189,40 +205,63 @@ MultiauthConfig::MultiauthConfig(QWidget* par, const char* w, WFlags f)
189 // read the "Security" Config file and update our UI 205 // read the "Security" Config file and update our UI
190 readConfig(); 206 readConfig();
191 207
192 /* loads plugins configuration widgets in mainTW tabs and in pluginListView
193 */
194
195 loadPlugins();
196
197 for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
198 MultiauthPlugin plugin = pluginList[i];
199 208
200 // load the config widgets in the tabs 209 if (m_pluginsInstalled)
201 // (configWidget will return 0l if there is no configuration GUI) 210 {
202 MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW); 211 /* loads plugins configuration widgets in mainTW tabs and in pluginListView
203 if ( widget != 0l ) { 212 */
204 odebug << "plugin " << plugin.name << " has a configuration widget" << oendl; 213
205 configWidgetList.append(widget); 214 loadPlugins();
206 m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(), 215
207 plugin.pluginObject->pluginName() ); 216 for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
208 } 217 MultiauthPlugin plugin = pluginList[i];
209 // set the order/activate tab 218
210 QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() ); 219 // load the config widgets in the tabs
211 QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox ); 220 // (configWidget will return 0l if there is no configuration GUI)
212 if ( !icon.isNull() ) { 221 MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW);
213 item->setPixmap( 0, icon ); 222 if ( widget != 0l ) {
214 } 223 odebug << "plugin " << plugin.name << " has a configuration widget" << oendl;
215 if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) { 224 configWidgetList.append(widget);
216 item->setOn( TRUE ); 225 m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(),
226 plugin.pluginObject->pluginName() );
227 }
228 // set the order/activate tab
229 QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() );
230 QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox );
231 if ( !icon.isNull() ) {
232 item->setPixmap( 0, icon );
233 }
234 if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) {
235 item->setOn( TRUE );
236 }
237 m_plugins[plugin.name] = item;
217 } 238 }
218 m_plugins[plugin.name] = item;
219 }
220 239
221 // set the first tab as default. 240 // set the first tab as default.
222 m_mainTW->setCurrentTab(m_pluginListWidget); 241 m_mainTW->setCurrentTab(m_pluginListWidget);
223 242
224 // put the number of plugins as the max number of req. auth. 243 // put the number of plugins as the max number of req. auth.
225 m_generalConfig->nbSuccessMin->setMaxValue( pluginList.count() ); 244 m_generalConfig->nbSuccessMin->setMaxValue( pluginList.count() );
245 }
246 else
247 {
248 /* 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
250 */
251 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)");
252 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
253 pluginListLayout->setSpacing(11);
254 pluginListLayout->setMargin(11);
255 pluginListLayout->setAlignment( Qt::AlignTop );
256 QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box");
257 pluginListLayout->addWidget(warningBox);
258 QLabel * warningText = new QLabel( "<p>" + tr("To be able to protect your PDA with one or more authentication plugins (for example, a simple PIN authentication), you must install at least one <em>opie-multiauth-*</em> package! Once you have done that, you will be able to configure your PDA protection here.") + "</p>", warningBox );
259
260 m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") );
261
262 // set the first tab as default.
263 m_mainTW->setCurrentTab(m_loginWidget);
264 }
226 265
227 showMaximized(); 266 showMaximized();
228} 267}
@@ -271,17 +310,21 @@ void MultiauthConfig::readConfig()
271{ 310{
272 // pointer, so we release this Config when we want 311 // pointer, so we release this Config when we want
273 Config* pcfg = new Config("Security"); 312 Config* pcfg = new Config("Security");
274 pcfg->setGroup( "Misc" ); 313
275 m_generalConfig->onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); 314 if (m_pluginsInstalled)
276 m_generalConfig->onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); 315 {
277 m_generalConfig->nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); 316 pcfg->setGroup( "Misc" );
278 m_generalConfig->noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); 317 m_generalConfig->onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) );
279 m_generalConfig->explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); 318 m_generalConfig->onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) );
280 m_generalConfig->allowBypass->setChecked( pcfg->readBoolEntry( "allowBypass", false ) ); 319 m_generalConfig->nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) );
281 320 m_generalConfig->noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) );
282 pcfg->setGroup( "Plugins" ); 321 m_generalConfig->explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) );
283 m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' ); 322 m_generalConfig->allowBypass->setChecked( pcfg->readBoolEntry( "allowBypass", false ) );
284 m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' ); 323
324 pcfg->setGroup( "Plugins" );
325 m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' );
326 m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' );
327 }
285 328
286 /* Login and Sync stuff */ 329 /* Login and Sync stuff */
287 pcfg->setGroup("Sync"); 330 pcfg->setGroup("Sync");
@@ -313,7 +356,7 @@ void MultiauthConfig::readConfig()
313 ssh->setChecked(cfg.readEntry("allow_ssh")); 356 ssh->setChecked(cfg.readEntry("allow_ssh"));
314 else 357 else
315 ssh->hide(); 358 ssh->hide();
316 */ 359 */
317 360
318 // release the Config handler 361 // release the Config handler
319 delete pcfg; 362 delete pcfg;
@@ -351,38 +394,42 @@ void MultiauthConfig::readConfig()
351void MultiauthConfig::writeConfig() 394void MultiauthConfig::writeConfig()
352{ 395{
353 Config* pcfg = new Config("Security"); 396 Config* pcfg = new Config("Security");
354 pcfg->setGroup( "Plugins" ); 397
355 QStringList exclude; 398 if (m_pluginsInstalled)
356 QStringList include; 399 {
357 QStringList allPlugins; 400 pcfg->setGroup( "Plugins" );
358 401 QStringList exclude;
359 QListViewItemIterator list_it( m_pluginListView ); 402 QStringList include;
360 403 QStringList allPlugins;
361 // this makes sure the names get saved in the order selected 404
362 for ( ; list_it.current(); ++list_it ) { 405 QListViewItemIterator list_it( m_pluginListView );
363 QMap <QString, QCheckListItem *>::Iterator it; 406
364 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { 407 // this makes sure the names get saved in the order selected
365 if ( list_it.current() == (*it) && !(*it)-> isOn () ) { 408 for ( ; list_it.current(); ++list_it ) {
366 exclude << it.key(); 409 QMap <QString, QCheckListItem *>::Iterator it;
367 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ 410 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) {
368 include << it.key(); 411 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
369 } 412 exclude << it.key();
370 if ( list_it.current() == (*it) ) { 413 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
371 allPlugins << it.key(); 414 include << it.key();
415 }
416 if ( list_it.current() == (*it) ) {
417 allPlugins << it.key();
418 }
372 } 419 }
373 } 420 }
421 pcfg->writeEntry( "ExcludePlugins", exclude, ',' );
422 pcfg->writeEntry( "IncludePlugins", include, ',' );
423 pcfg->writeEntry( "AllPlugins", allPlugins, ',' );
424
425 pcfg->setGroup( "Misc" );
426 pcfg->writeEntry( "onStart", m_generalConfig->onStart->isChecked() );
427 pcfg->writeEntry( "onResume", m_generalConfig->onResume->isChecked() );
428 pcfg->writeEntry( "nbSuccessMin", m_generalConfig->nbSuccessMin->text() );
429 pcfg->writeEntry( "noProtectConfig", m_generalConfig->noProtectConfig->isChecked() );
430 pcfg->writeEntry( "explanScreens", m_generalConfig->explanScreens->isChecked() );
431 pcfg->writeEntry( "allowBypass", m_generalConfig->allowBypass->isChecked() );
374 } 432 }
375 pcfg->writeEntry( "ExcludePlugins", exclude, ',' );
376 pcfg->writeEntry( "IncludePlugins", include, ',' );
377 pcfg->writeEntry( "AllPlugins", allPlugins, ',' );
378
379 pcfg->setGroup( "Misc" );
380 pcfg->writeEntry( "onStart", m_generalConfig->onStart->isChecked() );
381 pcfg->writeEntry( "onResume", m_generalConfig->onResume->isChecked() );
382 pcfg->writeEntry( "nbSuccessMin", m_generalConfig->nbSuccessMin->text() );
383 pcfg->writeEntry( "noProtectConfig", m_generalConfig->noProtectConfig->isChecked() );
384 pcfg->writeEntry( "explanScreens", m_generalConfig->explanScreens->isChecked() );
385 pcfg->writeEntry( "allowBypass", m_generalConfig->allowBypass->isChecked() );
386 433
387 /* Login and Sync stuff */ 434 /* Login and Sync stuff */
388 435
@@ -400,7 +447,10 @@ void MultiauthConfig::writeConfig()
400 for (int i=0; i<10; i++) { 447 for (int i=0; i<10; i++) {
401 QString target; 448 QString target;
402 target.sprintf("net%d", i); 449 target.sprintf("net%d", i);
403 pcfg->writeEntry(target,m_syncWidget->syncnet->text(i)); 450 if ( i < m_syncWidget->syncnet->count() )
451 pcfg->writeEntry(target, m_syncWidget->syncnet->text(i));
452 else // no more entry in the syncnet list -> we clear the line
453 pcfg->writeEntry(target, "");
404 } 454 }
405 455
406#ifdef ODP 456#ifdef ODP
@@ -429,7 +479,7 @@ void MultiauthConfig::writeConfig()
429 if ( sshAvailable() ) 479 if ( sshAvailable() )
430 pcfg->writeEntry("allow_ssh",ssh->isChecked()); 480 pcfg->writeEntry("allow_ssh",ssh->isChecked());
431 // ### write ssh/telnet sys config files 481 // ### write ssh/telnet sys config files
432 */ 482 */
433 483
434 //release the Config handler 484 //release the Config handler
435 delete pcfg; 485 delete pcfg;
diff --git a/core/settings/security/multiauthconfig.h b/core/settings/security/multiauthconfig.h
index 649815d..5287083 100644
--- a/core/settings/security/multiauthconfig.h
+++ b/core/settings/security/multiauthconfig.h
@@ -121,6 +121,7 @@ private:
121 121
122 int m_nbSuccessReq; 122 int m_nbSuccessReq;
123 bool m_plugins_changed; 123 bool m_plugins_changed;
124 bool m_pluginsInstalled;
124 125
125 void readConfig(); 126 void readConfig();
126 void loadPlugins(); 127 void loadPlugins();