summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/security/multiauthconfig.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/core/settings/security/multiauthconfig.cpp b/core/settings/security/multiauthconfig.cpp
index 45d691b..7a5f7b9 100644
--- a/core/settings/security/multiauthconfig.cpp
+++ b/core/settings/security/multiauthconfig.cpp
@@ -128,65 +128,65 @@ void MultiauthGeneralConfig::tryAuth()
128 128
129 129
130/// Builds and displays the Opie multi-authentication configuration dialog 130/// Builds and displays the Opie multi-authentication configuration dialog
131static void test_and_start() { 131static void test_and_start() {
132 Config pcfg("Security"); 132 Config pcfg("Security");
133 pcfg.setGroup( "Misc" ); 133 pcfg.setGroup( "Misc" );
134 bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true); 134 bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true);
135 135
136 if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) { 136 if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) {
137 owarn << "authentication failed, not showing opie-security" << oendl; 137 owarn << "authentication failed, not showing opie-security" << oendl;
138 exit( -1 ); 138 exit( -1 );
139 } 139 }
140} 140}
141 141
142 142
143 143
144 MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0) 144 MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0)
145: QDialog(par, w, TRUE, f), 145: QDialog(par, w, TRUE, f),
146 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0), 146 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0),
147 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0), 147 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0),
148 m_nbSuccessReq(0), m_plugins_changed(false) 148 m_nbSuccessReq(0), m_plugins_changed(false)
149{ 149{
150 /* Initializes the global configuration window 150 /* Initializes the global configuration window
151 */ 151 */
152 test_and_start(); 152 test_and_start();
153 153
154 /* Checks (and memorizes) if any authentication plugins are 154 /* Checks (and memorizes) if any authentication plugins are
155 * installed on the system 155 * installed on the system
156 */ 156 */
157 QString path = QPEApplication::qpeDir() + "plugins/security"; 157 QString path = QPEApplication::qpeDir() + "plugins/security";
158 QDir dir( path, "lib*.so" ); 158 QDir dir( path, "lib*.so" );
159 QStringList list = dir.entryList(); 159 QStringList list = dir.entryList();
160 160
161 m_pluginsInstalled = ! list.isEmpty(); 161 m_pluginsInstalled = ! list.isEmpty();
162 if (m_pluginsInstalled == false) 162 if (m_pluginsInstalled == false)
163 owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl; 163 owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl;
164 164
165 setCaption( tr( "Security configuration" ) ); 165 setCaption( tr( "Security configuration" ) );
166 QVBoxLayout *layout = new QVBoxLayout( this ); 166 QVBoxLayout *layout = new QVBoxLayout( this );
167 m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" ); 167 m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" );
168 layout->addWidget(m_mainTW); 168 layout->addWidget(m_mainTW);
169 169
170 if (m_pluginsInstalled) 170 if (m_pluginsInstalled)
171 { 171 {
172 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget"); 172 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget");
173 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); 173 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
174 pluginListLayout->setSpacing(6); 174 pluginListLayout->setSpacing(6);
175 pluginListLayout->setMargin(11); 175 pluginListLayout->setMargin(11);
176 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget ); 176 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget );
177 pluginListLayout->addWidget(pluginListTitle); 177 pluginListLayout->addWidget(pluginListTitle);
178 QHBox * pluginListHB = new QHBox(m_pluginListWidget); 178 QHBox * pluginListHB = new QHBox(m_pluginListWidget);
179 pluginListLayout->addWidget(pluginListHB); 179 pluginListLayout->addWidget(pluginListHB);
180 180
181 m_pluginListView = new QListView(pluginListHB); 181 m_pluginListView = new QListView(pluginListHB);
182 m_pluginListView->addColumn("PluginList"); 182 m_pluginListView->addColumn("PluginList");
183 m_pluginListView->header()->hide(); 183 m_pluginListView->header()->hide();
184 m_pluginListView->setSorting(-1); 184 m_pluginListView->setSorting(-1);
185 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" )); 185 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" ));
186 186
187 QVBox * pluginListVB = new QVBox(pluginListHB); 187 QVBox * pluginListVB = new QVBox(pluginListHB);
188 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); 188 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
189 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); 189 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
190 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) ); 190 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) );
191 191
192 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) ); 192 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) );
@@ -246,70 +246,70 @@ static void test_and_start() {
246 m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() ); 246 m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() );
247 } 247 }
248 else 248 else
249 { 249 {
250 /* we don't have any installed plugin there. Let's tell 250 /* we don't have any installed plugin there. Let's tell
251 * that to the user in a third tab, using the m_pluginListWidget widget 251 * that to the user in a third tab, using the m_pluginListWidget widget
252 */ 252 */
253 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)"); 253 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)");
254 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); 254 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
255 pluginListLayout->setSpacing(11); 255 pluginListLayout->setSpacing(11);
256 pluginListLayout->setMargin(11); 256 pluginListLayout->setMargin(11);
257 pluginListLayout->setAlignment( Qt::AlignTop ); 257 pluginListLayout->setAlignment( Qt::AlignTop );
258 QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box"); 258 QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box");
259 pluginListLayout->addWidget(warningBox); 259 pluginListLayout->addWidget(warningBox);
260 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 ); 260 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 );
261 261
262 m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") ); 262 m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") );
263 263
264 // set the first tab as default. 264 // set the first tab as default.
265 m_mainTW->setCurrentTab(m_loginWidget); 265 m_mainTW->setCurrentTab(m_loginWidget);
266 } 266 }
267 267
268 showMaximized(); 268 showMaximized();
269} 269}
270 270
271/// nothing to do 271/// nothing to do
272MultiauthConfig::~MultiauthConfig() 272MultiauthConfig::~MultiauthConfig()
273{ 273{
274} 274}
275 275
276/// saves the general and plugin(s) configurations 276/// saves the general and plugin(s) configurations
277void MultiauthConfig::writeConfigs() { 277void MultiauthConfig::writeConfigs() {
278 writeConfig();
279
280 MultiauthConfigWidget* confWidget = 0; 278 MultiauthConfigWidget* confWidget = 0;
281 for ( confWidget = configWidgetList.first(); confWidget != 0; 279 for ( confWidget = configWidgetList.first(); confWidget != 0;
282 confWidget = configWidgetList.next() ) 280 confWidget = configWidgetList.next() )
283 confWidget->writeConfig(); 281 confWidget->writeConfig();
282
283 writeConfig();
284} 284}
285 285
286/// on QDialog::accept, we save all the configurations and exit the QDialog normally 286/// on QDialog::accept, we save all the configurations and exit the QDialog normally
287void MultiauthConfig::accept() { 287void MultiauthConfig::accept() {
288 writeConfigs(); 288 writeConfigs();
289 QDialog::accept(); 289 QDialog::accept();
290} 290}
291 291
292void MultiauthConfig::done( int r ) { 292void MultiauthConfig::done( int r ) {
293 QDialog::done( r ); 293 QDialog::done( r );
294 close(); 294 close();
295} 295}
296 296
297/// moves up the selected plugin 297/// moves up the selected plugin
298void MultiauthConfig::moveSelectedUp() 298void MultiauthConfig::moveSelectedUp()
299{ 299{
300 QListViewItem *item = m_pluginListView->selectedItem(); 300 QListViewItem *item = m_pluginListView->selectedItem();
301 if ( item && item->itemAbove() ) { 301 if ( item && item->itemAbove() ) {
302 item->itemAbove()->moveItem( item ); 302 item->itemAbove()->moveItem( item );
303 } 303 }
304} 304}
305 305
306/// moves down the selected plugin 306/// moves down the selected plugin
307void MultiauthConfig::moveSelectedDown() 307void MultiauthConfig::moveSelectedDown()
308{ 308{
309 QListViewItem *item = m_pluginListView->selectedItem(); 309 QListViewItem *item = m_pluginListView->selectedItem();
310 if ( item && item->itemBelow() ) { 310 if ( item && item->itemBelow() ) {
311 item->moveItem( item->itemBelow() ); 311 item->moveItem( item->itemBelow() );
312 } 312 }
313} 313}
314 314
315/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface 315/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface
@@ -370,153 +370,153 @@ void MultiauthConfig::readConfig()
370 selectNet(auth_peer,auth_peer_bits,TRUE); 370 selectNet(auth_peer,auth_peer_bits,TRUE);
371 371
372 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), 372 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)),
373 this, SLOT(setSyncNet(const QString&))); 373 this, SLOT(setSyncNet(const QString&)));
374 374
375 375
376 376
377 QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; 377 QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf";
378 Config loginCfg(configFile,Config::File); 378 Config loginCfg(configFile,Config::File);
379 379
380 loginCfg.setGroup("General"); 380 loginCfg.setGroup("General");
381 autoLoginName=loginCfg.readEntry("AutoLogin",""); 381 autoLoginName=loginCfg.readEntry("AutoLogin","");
382 382
383 if (autoLoginName.stripWhiteSpace().isEmpty()) { 383 if (autoLoginName.stripWhiteSpace().isEmpty()) {
384 autoLogin=false; 384 autoLogin=false;
385 } else { 385 } else {
386 autoLogin=true; 386 autoLogin=true;
387 } 387 }
388 388
389 389
390 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); 390 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool)));
391 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); 391 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int)));
392 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); 392 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults()));
393 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); 393 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry()));
394 394
395 loadUsers(); 395 loadUsers();
396 updateGUI(); 396 updateGUI();
397 397
398} 398}
399 399
400void MultiauthConfig::writeConfig() 400void MultiauthConfig::writeConfig()
401{ 401{
402 Config* pcfg = new Config("Security"); 402 Config pcfg("Security");
403 403
404 if (m_pluginsInstalled) 404 if (m_pluginsInstalled)
405 { 405 {
406 pcfg->setGroup( "Plugins" ); 406 pcfg.setGroup( "Plugins" );
407 QStringList exclude; 407 QStringList exclude;
408 QStringList include; 408 QStringList include;
409 QStringList allPlugins; 409 QStringList allPlugins;
410 410
411 QListViewItemIterator list_it( m_pluginListView ); 411 QListViewItemIterator list_it( m_pluginListView );
412 412
413 // this makes sure the names get saved in the order selected 413 // this makes sure the names get saved in the order selected
414 for ( ; list_it.current(); ++list_it ) { 414 for ( ; list_it.current(); ++list_it ) {
415 QMap <QString, QCheckListItem *>::Iterator it; 415 QMap <QString, QCheckListItem *>::Iterator it;
416 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { 416 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) {
417 if ( list_it.current() == (*it) && !(*it)-> isOn () ) { 417 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
418 exclude << it.key(); 418 exclude << it.key();
419 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ 419 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
420 include << it.key(); 420 include << it.key();
421 } 421 }
422 if ( list_it.current() == (*it) ) { 422 if ( list_it.current() == (*it) ) {
423 allPlugins << it.key(); 423 allPlugins << it.key();
424 } 424 }
425 } 425 }
426 } 426 }
427 pcfg->writeEntry( "ExcludePlugins", exclude, ',' ); 427 pcfg.writeEntry( "ExcludePlugins", exclude, ',' );
428 pcfg->writeEntry( "IncludePlugins", include, ',' ); 428 pcfg.writeEntry( "IncludePlugins", include, ',' );
429 pcfg->writeEntry( "AllPlugins", allPlugins, ',' ); 429 pcfg.writeEntry( "AllPlugins", allPlugins, ',' );
430 430
431 pcfg->setGroup( "Misc" ); 431 pcfg.setGroup( "Misc" );
432 pcfg->writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() ); 432 pcfg.writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() );
433 pcfg->writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() ); 433 pcfg.writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() );
434 pcfg->writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() ); 434 pcfg.writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() );
435 pcfg->writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() ); 435 pcfg.writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() );
436 pcfg->writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() ); 436 pcfg.writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() );
437 } 437 }
438 438
439 /* Login and Sync stuff */ 439 /* Login and Sync stuff */
440 440
441 pcfg->setGroup("Sync"); 441 pcfg.setGroup("Sync");
442 int auth_peer=0; 442 int auth_peer=0;
443 int auth_peer_bits; 443 int auth_peer_bits;
444 QString sn = m_syncWidget->syncnet->currentText(); 444 QString sn = m_syncWidget->syncnet->currentText();
445 parseNet(sn,auth_peer,auth_peer_bits); 445 parseNet(sn,auth_peer,auth_peer_bits);
446 446
447 //this is the *selected* (active) net range 447 //this is the *selected* (active) net range
448 pcfg->writeEntry("auth_peer",auth_peer); 448 pcfg.writeEntry("auth_peer",auth_peer);
449 pcfg->writeEntry("auth_peer_bits",auth_peer_bits); 449 pcfg.writeEntry("auth_peer_bits",auth_peer_bits);
450 450
451 //write back all other net ranges in *cleartext* 451 //write back all other net ranges in *cleartext*
452 for (int i=0; i<10; i++) { 452 for (int i=0; i<10; i++) {
453 QString target; 453 QString target;
454 target.sprintf("net%d", i); 454 target.sprintf("net%d", i);
455 if ( i < m_syncWidget->syncnet->count() ) 455 if ( i < m_syncWidget->syncnet->count() )
456 pcfg->writeEntry(target, m_syncWidget->syncnet->text(i)); 456 pcfg.writeEntry(target, m_syncWidget->syncnet->text(i));
457 else // no more entry in the syncnet list -> we clear the line 457 else // no more entry in the syncnet list -> we clear the line
458 pcfg->writeEntry(target, ""); 458 pcfg.writeEntry(target, "");
459 } 459 }
460 460
461#ifdef ODP 461#ifdef ODP
462#error "Use 0,1,2 and use Launcher" 462#error "Use 0,1,2 and use Launcher"
463#endif 463#endif
464 /* keep the old code so we don't use currentItem directly */ 464 /* keep the old code so we don't use currentItem directly */
465 int value = 0x02; 465 int value = 0x02;
466 switch( m_syncWidget->syncModeCombo->currentItem() ) { 466 switch( m_syncWidget->syncModeCombo->currentItem() ) {
467 case 0: 467 case 0:
468 value = 0x01; 468 value = 0x01;
469 break; 469 break;
470 case 1: 470 case 1:
471 value = 0x02; 471 value = 0x02;
472 break; 472 break;
473 case 2: 473 case 2:
474 value = 0x04; 474 value = 0x04;
475 break; 475 break;
476 } 476 }
477 pcfg->setGroup("SyncMode"); 477 pcfg.setGroup("SyncMode");
478 pcfg->writeEntry( "Mode", value ); 478 pcfg.writeEntry( "Mode", value );
479 479
480 /* 480 /*
481 pcfg->setGroup("Remote"); 481 pcfg.setGroup("Remote");
482 if ( telnetAvailable() ) 482 if ( telnetAvailable() )
483 pcfg->writeEntry("allow_telnet",telnet->isChecked()); 483 pcfg.writeEntry("allow_telnet",telnet->isChecked());
484 if ( sshAvailable() ) 484 if ( sshAvailable() )
485 pcfg->writeEntry("allow_ssh",ssh->isChecked()); 485 pcfg.writeEntry("allow_ssh",ssh->isChecked());
486 // ### write ssh/telnet sys config files 486 // ### write ssh/telnet sys config files
487 */ 487 */
488 488
489 //release the Config handler 489 //release the Config handler
490 delete pcfg; 490 pcfg.write();
491 491
492 QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; 492 QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf";
493 Config loginCfg(configFile,Config::File); 493 Config loginCfg(configFile,Config::File);
494 loginCfg.setGroup("General"); 494 loginCfg.setGroup("General");
495 495
496 if (autoLogin) { 496 if (autoLogin) {
497 loginCfg.writeEntry("AutoLogin",autoLoginName); 497 loginCfg.writeEntry("AutoLogin",autoLoginName);
498 } else { 498 } else {
499 loginCfg.removeEntry("AutoLogin"); 499 loginCfg.removeEntry("AutoLogin");
500 } 500 }
501 501
502} 502}
503 503
504/// slot used to record the fact plugins order has been modified 504/// slot used to record the fact plugins order has been modified
505void MultiauthConfig::pluginsChanged() { 505void MultiauthConfig::pluginsChanged() {
506 m_plugins_changed = true; 506 m_plugins_changed = true;
507} 507}
508 508
509/// loads each multiauth plugin 509/// loads each multiauth plugin
510void MultiauthConfig::loadPlugins() { 510void MultiauthConfig::loadPlugins() {
511 511
512 QString path = QPEApplication::qpeDir() + "plugins/security"; 512 QString path = QPEApplication::qpeDir() + "plugins/security";
513 QDir dir( path, "lib*.so" ); 513 QDir dir( path, "lib*.so" );
514 514
515 QStringList list = dir.entryList(); 515 QStringList list = dir.entryList();
516 QStringList::Iterator it; 516 QStringList::Iterator it;
517 517
518 // temporary list used to sort plugins 518 // temporary list used to sort plugins
519 QMap<QString, MultiauthPlugin> sortList; 519 QMap<QString, MultiauthPlugin> sortList;
520 520
521 for ( it = list.begin(); it != list.end(); ++it ) { 521 for ( it = list.begin(); it != list.end(); ++it ) {
522 QInterfacePtr<MultiauthPluginInterface> iface; 522 QInterfacePtr<MultiauthPluginInterface> iface;