-rw-r--r-- | core/settings/security/multiauthconfig.cpp | 52 |
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() /// Builds and displays the Opie multi-authentication configuration dialog static void test_and_start() { Config pcfg("Security"); pcfg.setGroup( "Misc" ); bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true); if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) { owarn << "authentication failed, not showing opie-security" << oendl; exit( -1 ); } } MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0) : QDialog(par, w, TRUE, f), m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0), m_generalConfig(0), m_loginWidget(0), m_syncWidget(0), m_nbSuccessReq(0), m_plugins_changed(false) { /* Initializes the global configuration window */ test_and_start(); /* Checks (and memorizes) if any authentication plugins are * installed on the system */ QString path = QPEApplication::qpeDir() + "plugins/security"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); - + m_pluginsInstalled = ! list.isEmpty(); if (m_pluginsInstalled == false) owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl; setCaption( tr( "Security configuration" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" ); layout->addWidget(m_mainTW); if (m_pluginsInstalled) { m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget"); QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); pluginListLayout->setSpacing(6); pluginListLayout->setMargin(11); QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget ); pluginListLayout->addWidget(pluginListTitle); QHBox * pluginListHB = new QHBox(m_pluginListWidget); pluginListLayout->addWidget(pluginListHB); m_pluginListView = new QListView(pluginListHB); m_pluginListView->addColumn("PluginList"); m_pluginListView->header()->hide(); m_pluginListView->setSorting(-1); 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" )); QVBox * pluginListVB = new QVBox(pluginListHB); new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) ); connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) ); @@ -246,70 +246,70 @@ static void test_and_start() { m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() ); } else { /* we don't have any installed plugin there. Let's tell * that to the user in a third tab, using the m_pluginListWidget widget */ m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)"); QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); pluginListLayout->setSpacing(11); pluginListLayout->setMargin(11); pluginListLayout->setAlignment( Qt::AlignTop ); QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box"); pluginListLayout->addWidget(warningBox); 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 ); m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") ); // set the first tab as default. m_mainTW->setCurrentTab(m_loginWidget); } showMaximized(); } /// nothing to do MultiauthConfig::~MultiauthConfig() { } /// saves the general and plugin(s) configurations void MultiauthConfig::writeConfigs() { - writeConfig(); - MultiauthConfigWidget* confWidget = 0; for ( confWidget = configWidgetList.first(); confWidget != 0; confWidget = configWidgetList.next() ) confWidget->writeConfig(); + + writeConfig(); } /// on QDialog::accept, we save all the configurations and exit the QDialog normally void MultiauthConfig::accept() { writeConfigs(); QDialog::accept(); } void MultiauthConfig::done( int r ) { QDialog::done( r ); close(); } /// moves up the selected plugin void MultiauthConfig::moveSelectedUp() { QListViewItem *item = m_pluginListView->selectedItem(); if ( item && item->itemAbove() ) { item->itemAbove()->moveItem( item ); } } /// moves down the selected plugin void MultiauthConfig::moveSelectedDown() { QListViewItem *item = m_pluginListView->selectedItem(); if ( item && item->itemBelow() ) { item->moveItem( item->itemBelow() ); } } /// reads the <code>Security.conf</code> Config file, and updates parts of the user interface @@ -370,153 +370,153 @@ void MultiauthConfig::readConfig() selectNet(auth_peer,auth_peer_bits,TRUE); connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), this, SLOT(setSyncNet(const QString&))); QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; Config loginCfg(configFile,Config::File); loginCfg.setGroup("General"); autoLoginName=loginCfg.readEntry("AutoLogin",""); if (autoLoginName.stripWhiteSpace().isEmpty()) { autoLogin=false; } else { autoLogin=true; } connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); loadUsers(); updateGUI(); } void MultiauthConfig::writeConfig() { - Config* pcfg = new Config("Security"); + Config pcfg("Security"); if (m_pluginsInstalled) { - pcfg->setGroup( "Plugins" ); + pcfg.setGroup( "Plugins" ); QStringList exclude; QStringList include; QStringList allPlugins; QListViewItemIterator list_it( m_pluginListView ); // this makes sure the names get saved in the order selected for ( ; list_it.current(); ++list_it ) { QMap <QString, QCheckListItem *>::Iterator it; for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { if ( list_it.current() == (*it) && !(*it)-> isOn () ) { exclude << it.key(); } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ include << it.key(); } if ( list_it.current() == (*it) ) { allPlugins << it.key(); } } } - pcfg->writeEntry( "ExcludePlugins", exclude, ',' ); - pcfg->writeEntry( "IncludePlugins", include, ',' ); - pcfg->writeEntry( "AllPlugins", allPlugins, ',' ); - - pcfg->setGroup( "Misc" ); - pcfg->writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() ); - pcfg->writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() ); - pcfg->writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() ); - pcfg->writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() ); - pcfg->writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() ); + pcfg.writeEntry( "ExcludePlugins", exclude, ',' ); + pcfg.writeEntry( "IncludePlugins", include, ',' ); + pcfg.writeEntry( "AllPlugins", allPlugins, ',' ); + + pcfg.setGroup( "Misc" ); + pcfg.writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() ); + pcfg.writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() ); + pcfg.writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() ); + pcfg.writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() ); + pcfg.writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() ); } /* Login and Sync stuff */ - pcfg->setGroup("Sync"); + pcfg.setGroup("Sync"); int auth_peer=0; int auth_peer_bits; QString sn = m_syncWidget->syncnet->currentText(); parseNet(sn,auth_peer,auth_peer_bits); //this is the *selected* (active) net range - pcfg->writeEntry("auth_peer",auth_peer); - pcfg->writeEntry("auth_peer_bits",auth_peer_bits); + pcfg.writeEntry("auth_peer",auth_peer); + pcfg.writeEntry("auth_peer_bits",auth_peer_bits); //write back all other net ranges in *cleartext* for (int i=0; i<10; i++) { QString target; target.sprintf("net%d", i); if ( i < m_syncWidget->syncnet->count() ) - pcfg->writeEntry(target, m_syncWidget->syncnet->text(i)); + pcfg.writeEntry(target, m_syncWidget->syncnet->text(i)); else // no more entry in the syncnet list -> we clear the line - pcfg->writeEntry(target, ""); + pcfg.writeEntry(target, ""); } #ifdef ODP #error "Use 0,1,2 and use Launcher" #endif /* keep the old code so we don't use currentItem directly */ int value = 0x02; switch( m_syncWidget->syncModeCombo->currentItem() ) { case 0: value = 0x01; break; case 1: value = 0x02; break; case 2: value = 0x04; break; } - pcfg->setGroup("SyncMode"); - pcfg->writeEntry( "Mode", value ); + pcfg.setGroup("SyncMode"); + pcfg.writeEntry( "Mode", value ); /* - pcfg->setGroup("Remote"); + pcfg.setGroup("Remote"); if ( telnetAvailable() ) - pcfg->writeEntry("allow_telnet",telnet->isChecked()); + pcfg.writeEntry("allow_telnet",telnet->isChecked()); if ( sshAvailable() ) - pcfg->writeEntry("allow_ssh",ssh->isChecked()); + pcfg.writeEntry("allow_ssh",ssh->isChecked()); // ### write ssh/telnet sys config files */ //release the Config handler - delete pcfg; + pcfg.write(); QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; Config loginCfg(configFile,Config::File); loginCfg.setGroup("General"); if (autoLogin) { loginCfg.writeEntry("AutoLogin",autoLoginName); } else { loginCfg.removeEntry("AutoLogin"); } } /// slot used to record the fact plugins order has been modified void MultiauthConfig::pluginsChanged() { m_plugins_changed = true; } /// loads each multiauth plugin void MultiauthConfig::loadPlugins() { QString path = QPEApplication::qpeDir() + "plugins/security"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); QStringList::Iterator it; // temporary list used to sort plugins QMap<QString, MultiauthPlugin> sortList; for ( it = list.begin(); it != list.end(); ++it ) { QInterfacePtr<MultiauthPluginInterface> iface; |