summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -1,496 +1,546 @@
1#include "multiauthconfig.h" 1#include "multiauthconfig.h"
2 2
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>
9#include <qhbox.h> 10#include <qhbox.h>
10#include <qheader.h> 11#include <qheader.h>
11#include <qvbox.h> 12#include <qvbox.h>
12#include <qwhatsthis.h> 13#include <qwhatsthis.h>
13#include <qtoolbutton.h> 14#include <qtoolbutton.h>
14#include <qstringlist.h> 15#include <qstringlist.h>
15#include <qdir.h> 16#include <qdir.h>
16#include <qpe/qlibrary.h> 17#include <qpe/qlibrary.h>
17#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
18 19
19 20
20using Opie::Security::MultiauthPluginInterface; 21using Opie::Security::MultiauthPluginInterface;
21using Opie::Security::MultiauthPluginObject; 22using Opie::Security::MultiauthPluginObject;
22using Opie::Security::MultiauthConfigWidget; 23using Opie::Security::MultiauthConfigWidget;
23/// keeps information about MultiauthPluginObject plugins 24/// keeps information about MultiauthPluginObject plugins
24struct MultiauthPlugin { 25struct MultiauthPlugin {
25 MultiauthPlugin() : library( 0 ), iface( 0 ), pluginObject( 0 ) {} 26 MultiauthPlugin() : library( 0 ), iface( 0 ), pluginObject( 0 ) {}
26 /// plugin file 27 /// plugin file
27 QLibrary *library; 28 QLibrary *library;
28 /// the plugin object interface 29 /// the plugin object interface
29 QInterfacePtr<MultiauthPluginInterface> iface; 30 QInterfacePtr<MultiauthPluginInterface> iface;
30 /// the plugin object itself 31 /// the plugin object itself
31 MultiauthPluginObject *pluginObject; 32 MultiauthPluginObject *pluginObject;
32 /// name of the plugin file 33 /// name of the plugin file
33 QString name; 34 QString name;
34 /// should the plugin be launched during authentication or not 35 /// should the plugin be launched during authentication or not
35 bool active; 36 bool active;
36 /// order of the plugin, in the pluginListWidget and during authentication 37 /// order of the plugin, in the pluginListWidget and during authentication
37 int pos; 38 int pos;
38}; 39};
39 40
40/// list of available MultiauthPlugin objects 41/// list of available MultiauthPlugin objects
41static QValueList<MultiauthPlugin> pluginList; 42static QValueList<MultiauthPlugin> pluginList;
42 43
43 44
44/// extension of QToolButton that adds signals, icons and stuff (taken from todayconfig.cpp) 45/// extension of QToolButton that adds signals, icons and stuff (taken from todayconfig.cpp)
45class ToolButton : public QToolButton { 46class ToolButton : public QToolButton {
46 47
47 public: 48 public:
48 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 49 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
49 : QToolButton( parent, name ) { 50 : QToolButton( parent, name ) {
50 setPixmap( Resource::loadPixmap( icon ) ); 51 setPixmap( Resource::loadPixmap( icon ) );
51 setAutoRaise( TRUE ); 52 setAutoRaise( TRUE );
52 setFocusPolicy( QWidget::NoFocus ); 53 setFocusPolicy( QWidget::NoFocus );
53 setToggleButton( t ); 54 setToggleButton( t );
54 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 55 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
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);
63 vb->setMargin(11); 64 vb->setMargin(11);
64 vb->setAlignment( Qt::AlignTop ); 65 vb->setAlignment( Qt::AlignTop );
65 66
66 QGroupBox *lockBox = new QGroupBox(0, Qt::Vertical, tr("When to lock Opie"), this, "lock box"); 67 QGroupBox *lockBox = new QGroupBox(0, Qt::Vertical, tr("When to lock Opie"), this, "lock box");
67 vb->addWidget(lockBox); 68 vb->addWidget(lockBox);
68 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() ); 69 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() );
69 onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start"); 70 onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start");
70 onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume"); 71 onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume");
71 boxLayout->addWidget(onStart, 0, 0); 72 boxLayout->addWidget(onStart, 0, 0);
72 boxLayout->addWidget(onResume, 0, 1); 73 boxLayout->addWidget(onResume, 0, 1);
73 74
74 QGroupBox *nbBox = new QGroupBox(0, Qt::Vertical, tr("Multiple plugins authentication"), this, "nb box"); 75 QGroupBox *nbBox = new QGroupBox(0, Qt::Vertical, tr("Multiple plugins authentication"), this, "nb box");
75 vb->addWidget(nbBox); 76 vb->addWidget(nbBox);
76 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() ); 77 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() );
77 nbSuccessMin = new QSpinBox(nbBox); 78 nbSuccessMin = new QSpinBox(nbBox);
78 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox); 79 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox);
79 nbBoxLayout->addWidget(nbSuccessMin, 0, 0); 80 nbBoxLayout->addWidget(nbSuccessMin, 0, 0);
80 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1); 81 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1);
81 nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor 82 nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor
82 83
83 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Debug options"), this, "dev box"); 84 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Debug options"), this, "dev box");
84 vb->addWidget(devBox); 85 vb->addWidget(devBox);
85 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() ); 86 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() );
86 noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config"); 87 noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config");
87 explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens"); 88 explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens");
88 allowBypass = new QCheckBox( tr("Allow to bypass authentication"), devBox, "AllowBypass"); 89 allowBypass = new QCheckBox( tr("Allow to bypass authentication"), devBox, "AllowBypass");
89 QLabel *logicNote = new QLabel( "<p>" + tr("Note: the third option implies the second one") + "</p>", devBox ); 90 QLabel *logicNote = new QLabel( "<p>" + tr("Note: the third option implies the second one") + "</p>", devBox );
90 devBoxLayout->addWidget(noProtectConfig, 0, 0); 91 devBoxLayout->addWidget(noProtectConfig, 0, 0);
91 devBoxLayout->addWidget(explanScreens, 1, 0); 92 devBoxLayout->addWidget(explanScreens, 1, 0);
92 devBoxLayout->addWidget(allowBypass, 2, 0); 93 devBoxLayout->addWidget(allowBypass, 2, 0);
93 devBoxLayout->addMultiCellWidget(logicNote, 3, 3, 0, 1); 94 devBoxLayout->addMultiCellWidget(logicNote, 3, 3, 0, 1);
94 95
95 connect( explanScreens, SIGNAL(toggled(bool)), this, SLOT(checkBypass()) ); 96 connect( explanScreens, SIGNAL(toggled(bool)), this, SLOT(checkBypass()) );
96 connect( allowBypass, SIGNAL(toggled(bool)), this, SLOT(checkScreens()) ); 97 connect( allowBypass, SIGNAL(toggled(bool)), this, SLOT(checkScreens()) );
97} 98}
98 99
99/// nothing to do 100/// nothing to do
100MultiauthGeneralConfig::~MultiauthGeneralConfig() 101MultiauthGeneralConfig::~MultiauthGeneralConfig()
101{} 102{}
102 103
103/// Be sure that explanScreens is checked if allowBypass is 104/// Be sure that explanScreens is checked if allowBypass is
104void MultiauthGeneralConfig::checkScreens() 105void MultiauthGeneralConfig::checkScreens()
105{ 106{
106 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) ) 107 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) )
107 explanScreens->setChecked(true); 108 explanScreens->setChecked(true);
108} 109}
109 110
110/// Be sure that allowBypass is not checked if explanScreens is not 111/// Be sure that allowBypass is not checked if explanScreens is not
111void MultiauthGeneralConfig::checkBypass() 112void MultiauthGeneralConfig::checkBypass()
112{ 113{
113 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) ) 114 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) )
114 allowBypass->setChecked(false); 115 allowBypass->setChecked(false);
115} 116}
116 117
117 118
118 119
119 120
120 121
121 122
122 123
123 124
124 125
125 126
126 127
127/// Builds and displays the Opie multi-authentication configuration dialog 128/// Builds and displays the Opie multi-authentication configuration dialog
128static void test_and_start() { 129static void test_and_start() {
129 Config pcfg("Security"); 130 Config pcfg("Security");
130 pcfg.setGroup( "Misc" ); 131 pcfg.setGroup( "Misc" );
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") );
184 200
185 // sync settings page 201 // sync settings page
186 m_syncWidget = new SyncBase( m_mainTW, "sync config widget" ); 202 m_syncWidget = new SyncBase( m_mainTW, "sync config widget" );
187 m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") ); 203 m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") );
188 204
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}
229 268
230/// nothing to do 269/// nothing to do
231MultiauthConfig::~MultiauthConfig() 270MultiauthConfig::~MultiauthConfig()
232{ 271{
233} 272}
234 273
235void MultiauthConfig::accept() { 274void MultiauthConfig::accept() {
236 writeConfig(); 275 writeConfig();
237 276
238 MultiauthConfigWidget* confWidget = 0; 277 MultiauthConfigWidget* confWidget = 0;
239 for ( confWidget = configWidgetList.first(); confWidget != 0; 278 for ( confWidget = configWidgetList.first(); confWidget != 0;
240 confWidget = configWidgetList.next() ) 279 confWidget = configWidgetList.next() )
241 confWidget->writeConfig(); 280 confWidget->writeConfig();
242 281
243 QDialog::accept(); 282 QDialog::accept();
244} 283}
245 284
246void MultiauthConfig::done( int r ) { 285void MultiauthConfig::done( int r ) {
247 QDialog::done( r ); 286 QDialog::done( r );
248 close(); 287 close();
249} 288}
250 289
251/// moves up the selected plugin 290/// moves up the selected plugin
252void MultiauthConfig::moveSelectedUp() 291void MultiauthConfig::moveSelectedUp()
253{ 292{
254 QListViewItem *item = m_pluginListView->selectedItem(); 293 QListViewItem *item = m_pluginListView->selectedItem();
255 if ( item && item->itemAbove() ) { 294 if ( item && item->itemAbove() ) {
256 item->itemAbove()->moveItem( item ); 295 item->itemAbove()->moveItem( item );
257 } 296 }
258} 297}
259 298
260/// moves down the selected plugin 299/// moves down the selected plugin
261void MultiauthConfig::moveSelectedDown() 300void MultiauthConfig::moveSelectedDown()
262{ 301{
263 QListViewItem *item = m_pluginListView->selectedItem(); 302 QListViewItem *item = m_pluginListView->selectedItem();
264 if ( item && item->itemBelow() ) { 303 if ( item && item->itemBelow() ) {
265 item->moveItem( item->itemBelow() ); 304 item->moveItem( item->itemBelow() );
266 } 305 }
267} 306}
268 307
269/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface 308/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface
270void MultiauthConfig::readConfig() 309void 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");
288 int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 331 int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24
289 int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24); 332 int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24);
290 333
291 pcfg->setGroup("SyncMode"); 334 pcfg->setGroup("SyncMode");
292 int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp 335 int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp
293 switch( mode ) { 336 switch( mode ) {
294 case 0x01: 337 case 0x01:
295 m_syncWidget->syncModeCombo->setCurrentItem( 0 ); 338 m_syncWidget->syncModeCombo->setCurrentItem( 0 );
296 break; 339 break;
297 case 0x02: 340 case 0x02:
298 default: 341 default:
299 m_syncWidget->syncModeCombo->setCurrentItem( 1 ); 342 m_syncWidget->syncModeCombo->setCurrentItem( 1 );
300 break; 343 break;
301 case 0x04: 344 case 0x04:
302 m_syncWidget->syncModeCombo->setCurrentItem( 2 ); 345 m_syncWidget->syncModeCombo->setCurrentItem( 2 );
303 break; 346 break;
304 } 347 }
305 /* 348 /*
306 cfg.setGroup("Remote"); 349 cfg.setGroup("Remote");
307 if ( telnetAvailable() ) 350 if ( telnetAvailable() )
308 telnet->setChecked(cfg.readEntry("allow_telnet")); 351 telnet->setChecked(cfg.readEntry("allow_telnet"));
309 else 352 else
310 telnet->hide(); 353 telnet->hide();
311 354
312 if ( sshAvailable() ) 355 if ( sshAvailable() )
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;
320 // indeed, selectNet will open the config file... 363 // indeed, selectNet will open the config file...
321 selectNet(auth_peer,auth_peer_bits,TRUE); 364 selectNet(auth_peer,auth_peer_bits,TRUE);
322 365
323 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), 366 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)),
324 this, SLOT(setSyncNet(const QString&))); 367 this, SLOT(setSyncNet(const QString&)));
325 368
326 369
327 370
328 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 371 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
329 Config loginCfg(configFile,Config::File); 372 Config loginCfg(configFile,Config::File);
330 373
331 loginCfg.setGroup("General"); 374 loginCfg.setGroup("General");
332 autoLoginName=loginCfg.readEntry("AutoLogin",""); 375 autoLoginName=loginCfg.readEntry("AutoLogin","");
333 376
334 if (autoLoginName.stripWhiteSpace().isEmpty()) { 377 if (autoLoginName.stripWhiteSpace().isEmpty()) {
335 autoLogin=false; 378 autoLogin=false;
336 } else { 379 } else {
337 autoLogin=true; 380 autoLogin=true;
338 } 381 }
339 382
340 383
341 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); 384 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool)));
342 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); 385 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int)));
343 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); 386 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults()));
344 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); 387 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry()));
345 388
346 loadUsers(); 389 loadUsers();
347 updateGUI(); 390 updateGUI();
348 391
349} 392}
350 393
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
389 pcfg->setGroup("Sync"); 436 pcfg->setGroup("Sync");
390 int auth_peer=0; 437 int auth_peer=0;
391 int auth_peer_bits; 438 int auth_peer_bits;
392 QString sn = m_syncWidget->syncnet->currentText(); 439 QString sn = m_syncWidget->syncnet->currentText();
393 parseNet(sn,auth_peer,auth_peer_bits); 440 parseNet(sn,auth_peer,auth_peer_bits);
394 441
395 //this is the *selected* (active) net range 442 //this is the *selected* (active) net range
396 pcfg->writeEntry("auth_peer",auth_peer); 443 pcfg->writeEntry("auth_peer",auth_peer);
397 pcfg->writeEntry("auth_peer_bits",auth_peer_bits); 444 pcfg->writeEntry("auth_peer_bits",auth_peer_bits);
398 445
399 //write back all other net ranges in *cleartext* 446 //write back all other net ranges in *cleartext*
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
407#error "Use 0,1,2 and use Launcher" 457#error "Use 0,1,2 and use Launcher"
408#endif 458#endif
409 /* keep the old code so we don't use currentItem directly */ 459 /* keep the old code so we don't use currentItem directly */
410 int value = 0x02; 460 int value = 0x02;
411 switch( m_syncWidget->syncModeCombo->currentItem() ) { 461 switch( m_syncWidget->syncModeCombo->currentItem() ) {
412 case 0: 462 case 0:
413 value = 0x01; 463 value = 0x01;
414 break; 464 break;
415 case 1: 465 case 1:
416 value = 0x02; 466 value = 0x02;
417 break; 467 break;
418 case 2: 468 case 2:
419 value = 0x04; 469 value = 0x04;
420 break; 470 break;
421 } 471 }
422 pcfg->setGroup("SyncMode"); 472 pcfg->setGroup("SyncMode");
423 pcfg->writeEntry( "Mode", value ); 473 pcfg->writeEntry( "Mode", value );
424 474
425 /* 475 /*
426 pcfg->setGroup("Remote"); 476 pcfg->setGroup("Remote");
427 if ( telnetAvailable() ) 477 if ( telnetAvailable() )
428 pcfg->writeEntry("allow_telnet",telnet->isChecked()); 478 pcfg->writeEntry("allow_telnet",telnet->isChecked());
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;
436 486
437 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 487 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
438 Config loginCfg(configFile,Config::File); 488 Config loginCfg(configFile,Config::File);
439 loginCfg.setGroup("General"); 489 loginCfg.setGroup("General");
440 490
441 if (autoLogin) { 491 if (autoLogin) {
442 loginCfg.writeEntry("AutoLogin",autoLoginName); 492 loginCfg.writeEntry("AutoLogin",autoLoginName);
443 } else { 493 } else {
444 loginCfg.removeEntry("AutoLogin"); 494 loginCfg.removeEntry("AutoLogin");
445 } 495 }
446 496
447} 497}
448 498
449/// slot used to record the fact plugins order has been modified 499/// slot used to record the fact plugins order has been modified
450void MultiauthConfig::pluginsChanged() { 500void MultiauthConfig::pluginsChanged() {
451 m_plugins_changed = true; 501 m_plugins_changed = true;
452} 502}
453 503
454/// loads each multiauth plugin 504/// loads each multiauth plugin
455void MultiauthConfig::loadPlugins() { 505void MultiauthConfig::loadPlugins() {
456 506
457 QString path = QPEApplication::qpeDir() + "/plugins/security"; 507 QString path = QPEApplication::qpeDir() + "/plugins/security";
458 QDir dir( path, "lib*.so" ); 508 QDir dir( path, "lib*.so" );
459 509
460 QStringList list = dir.entryList(); 510 QStringList list = dir.entryList();
461 QStringList::Iterator it; 511 QStringList::Iterator it;
462 512
463 // temporary list used to sort plugins 513 // temporary list used to sort plugins
464 QMap<QString, MultiauthPlugin> sortList; 514 QMap<QString, MultiauthPlugin> sortList;
465 515
466 for ( it = list.begin(); it != list.end(); ++it ) { 516 for ( it = list.begin(); it != list.end(); ++it ) {
467 QInterfacePtr<MultiauthPluginInterface> iface; 517 QInterfacePtr<MultiauthPluginInterface> iface;
468 QLibrary *lib = new QLibrary( path + "/" + *it ); 518 QLibrary *lib = new QLibrary( path + "/" + *it );
469 QString libPath(path + "/" + *it); 519 QString libPath(path + "/" + *it);
470 520
471 if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 521 if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
472 MultiauthPlugin plugin; 522 MultiauthPlugin plugin;
473 plugin.library = lib; 523 plugin.library = lib;
474 plugin.iface = iface; 524 plugin.iface = iface;
475 plugin.name = QString(*it); 525 plugin.name = QString(*it);
476 526
477 // find out if plugins should be launched 527 // find out if plugins should be launched
478 if ( m_excludePlugins.grep( *it ).isEmpty() ) { 528 if ( m_excludePlugins.grep( *it ).isEmpty() ) {
479 plugin.active = true; 529 plugin.active = true;
480 } else { 530 } else {
481 plugin.active = false; 531 plugin.active = false;
482 } 532 }
483 533
484 plugin.pluginObject = plugin.iface->plugin(); 534 plugin.pluginObject = plugin.iface->plugin();
485 535
486 // "prebuffer" it in one more list, to get the sorting done 536 // "prebuffer" it in one more list, to get the sorting done
487 sortList.insert( plugin.name, plugin ); 537 sortList.insert( plugin.name, plugin );
488 538
489 // on first start the list is off course empty 539 // on first start the list is off course empty
490 if ( m_allPlugins.isEmpty() ) { 540 if ( m_allPlugins.isEmpty() ) {
491 pluginList.append( plugin ); 541 pluginList.append( plugin );
492 } 542 }
493 // if plugin is not yet in the list, add it to the layout too 543 // if plugin is not yet in the list, add it to the layout too
494 else if ( !m_allPlugins.contains( plugin.name ) ) { 544 else if ( !m_allPlugins.contains( plugin.name ) ) {
495 pluginList.append( plugin ); 545 pluginList.append( plugin );
496 } 546 }
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
@@ -60,85 +60,86 @@
60 60
61/// the "misc" configuration tab, about general Opie Multiauth settings 61/// the "misc" configuration tab, about general Opie Multiauth settings
62class MultiauthGeneralConfig : public QWidget 62class MultiauthGeneralConfig : public QWidget
63{ 63{
64 Q_OBJECT 64 Q_OBJECT
65public: 65public:
66 MultiauthGeneralConfig(QWidget * parent, const char * name); 66 MultiauthGeneralConfig(QWidget * parent, const char * name);
67 ~MultiauthGeneralConfig(); 67 ~MultiauthGeneralConfig();
68protected: 68protected:
69 QCheckBox *onStart, *onResume, *noProtectConfig, *explanScreens, *allowBypass; 69 QCheckBox *onStart, *onResume, *noProtectConfig, *explanScreens, *allowBypass;
70 QSpinBox *nbSuccessMin; 70 QSpinBox *nbSuccessMin;
71private: 71private:
72 friend class MultiauthConfig; 72 friend class MultiauthConfig;
73private slots: 73private slots:
74 void checkBypass(); 74 void checkBypass();
75 void checkScreens(); 75 void checkScreens();
76}; 76};
77 77
78/// the whole configuration dialog 78/// the whole configuration dialog
79class MultiauthConfig : public QDialog 79class MultiauthConfig : public QDialog
80{ 80{
81 Q_OBJECT 81 Q_OBJECT
82 82
83public: 83public:
84 static QString appName() { return QString::fromLatin1("security"); } 84 static QString appName() { return QString::fromLatin1("security"); }
85 MultiauthConfig(QWidget *parent, const char* name, WFlags fl); 85 MultiauthConfig(QWidget *parent, const char* name, WFlags fl);
86 virtual ~MultiauthConfig(); 86 virtual ~MultiauthConfig();
87 void writeConfig(); 87 void writeConfig();
88 QList<Opie::Security::MultiauthConfigWidget> configWidgetList; 88 QList<Opie::Security::MultiauthConfigWidget> configWidgetList;
89 89
90protected slots: 90protected slots:
91 void accept(); 91 void accept();
92 void done(int r); 92 void done(int r);
93 void pluginsChanged(); 93 void pluginsChanged();
94 void moveSelectedUp(); 94 void moveSelectedUp();
95 void moveSelectedDown(); 95 void moveSelectedDown();
96 96
97private slots: 97private slots:
98 // Login and Sync stuff 98 // Login and Sync stuff
99 void setSyncNet(const QString&); 99 void setSyncNet(const QString&);
100 void changeLoginName(int); 100 void changeLoginName(int);
101 void toggleAutoLogin(bool); 101 void toggleAutoLogin(bool);
102 void restoreDefaults(); 102 void restoreDefaults();
103 void insertDefaultRanges(); 103 void insertDefaultRanges();
104 void deleteListEntry(); 104 void deleteListEntry();
105 105
106private: 106private:
107 /// the widget holding all the tabs (or pages) 107 /// the widget holding all the tabs (or pages)
108 Opie::Ui::OTabWidget *m_mainTW; 108 Opie::Ui::OTabWidget *m_mainTW;
109 /// list of authentication plugins in the "Plugins" page 109 /// list of authentication plugins in the "Plugins" page
110 QListView *m_pluginListView; 110 QListView *m_pluginListView;
111 QStringList m_allPlugins, m_excludePlugins; 111 QStringList m_allPlugins, m_excludePlugins;
112 QMap<QString,QCheckListItem*> m_plugins; 112 QMap<QString,QCheckListItem*> m_plugins;
113 /// plugin list page 113 /// plugin list page
114 QWidget *m_pluginListWidget; 114 QWidget *m_pluginListWidget;
115 /// misc config page 115 /// misc config page
116 MultiauthGeneralConfig *m_generalConfig; 116 MultiauthGeneralConfig *m_generalConfig;
117 /// login (root / ...) choice page 117 /// login (root / ...) choice page
118 LoginBase *m_loginWidget; 118 LoginBase *m_loginWidget;
119 /// synchronization settings page 119 /// synchronization settings page
120 SyncBase *m_syncWidget; 120 SyncBase *m_syncWidget;
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();
127 128
128 // Login and Sync stuff 129 // Login and Sync stuff
129 void loadUsers(); 130 void loadUsers();
130 bool telnetAvailable() const; 131 bool telnetAvailable() const;
131 bool sshAvailable() const; 132 bool sshAvailable() const;
132 void updateGUI(); 133 void updateGUI();
133 134
134 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits); 135 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits);
135 void selectNet(int auth_peer,int auth_peer_bits,bool update); 136 void selectNet(int auth_peer,int auth_peer_bits,bool update);
136 137
137 138
138 bool autoLogin; 139 bool autoLogin;
139 QString autoLoginName; 140 QString autoLoginName;
140}; 141};
141 142
142 143
143#endif // MULTIAUTHCONFIG_H 144#endif // MULTIAUTHCONFIG_H
144 145