summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/security/multiauthconfig.cpp129
-rw-r--r--core/settings/security/multiauthconfig.h18
-rw-r--r--libopie2/opiesecurity/multiauthmainwindow.cpp29
-rw-r--r--libopie2/opiesecurity/multiauthmainwindow.h2
4 files changed, 106 insertions, 72 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,751 +1,770 @@
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>
10#include <qhbox.h> 9#include <qhbox.h>
11#include <qheader.h> 10#include <qheader.h>
12#include <qvbox.h> 11#include <qvbox.h>
13#include <qwhatsthis.h> 12#include <qwhatsthis.h>
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 {
26 MultiauthPlugin() : library( 0 ), iface( 0 ), pluginObject( 0 ) {} 27 MultiauthPlugin() : library( 0 ), iface( 0 ), pluginObject( 0 ) {}
27 /// plugin file 28 /// plugin file
28 QLibrary *library; 29 QLibrary *library;
29 /// the plugin object interface 30 /// the plugin object interface
30 QInterfacePtr<MultiauthPluginInterface> iface; 31 QInterfacePtr<MultiauthPluginInterface> iface;
31 /// the plugin object itself 32 /// the plugin object itself
32 MultiauthPluginObject *pluginObject; 33 MultiauthPluginObject *pluginObject;
33 /// name of the plugin file 34 /// name of the plugin file
34 QString name; 35 QString name;
35 /// should the plugin be launched during authentication or not 36 /// should the plugin be launched during authentication or not
36 bool active; 37 bool active;
37 /// order of the plugin, in the pluginListWidget and during authentication 38 /// order of the plugin, in the pluginListWidget and during authentication
38 int pos; 39 int pos;
39}; 40};
40 41
41/// list of available MultiauthPlugin objects 42/// list of available MultiauthPlugin objects
42static QValueList<MultiauthPlugin> pluginList; 43static QValueList<MultiauthPlugin> pluginList;
43 44
44 45
45/// extension of QToolButton that adds signals, icons and stuff (taken from todayconfig.cpp) 46/// extension of QToolButton that adds signals, icons and stuff (taken from todayconfig.cpp)
46class ToolButton : public QToolButton { 47class ToolButton : public QToolButton {
47 48
48 public: 49 public:
49 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 50 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
50 : QToolButton( parent, name ) { 51 : QToolButton( parent, name ) {
51 setPixmap( Resource::loadPixmap( icon ) ); 52 setPixmap( Resource::loadPixmap( icon ) );
52 setAutoRaise( TRUE ); 53 setAutoRaise( TRUE );
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");
95 98 connect( m_tryButton, SIGNAL(clicked()), this, SLOT(tryAuth()) );
96 connect( explanScreens, SIGNAL(toggled(bool)), this, SLOT(checkBypass()) ); 99
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>" +
110 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>",
111/// Be sure that allowBypass is not checked if explanScreens is not 113 QMessageBox::Warning,
112void MultiauthGeneralConfig::checkBypass() 114 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
113{ 115 0, QString::null, TRUE, WStyle_StaysOnTop);
114 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) ) 116 confirmSave.setButtonText(QMessageBox::Cancel, tr("Cancel"));
115 allowBypass->setChecked(false); 117 confirmSave.setButtonText(QMessageBox::Yes, tr("OK"));
116}
117
118
119 118
119 if ( confirmSave.exec() == QMessageBox::Yes)
120 {
121 owarn << "writing config as user accepted" << oendl;
122 m_parentConfig->writeConfigs();
123 owarn << "testing authentication" << oendl;
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" );
132 bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true); 148 bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true);
133 149
134 if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) { 150 if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) {
135 owarn << "authentication failed, not showing opie-security" << oendl; 151 owarn << "authentication failed, not showing opie-security" << oendl;
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
149 */ 165 */
150 test_and_start(); 166 test_and_start();
151 167
152 /* Checks (and memorizes) if any authentication plugins are 168 /* Checks (and memorizes) if any authentication plugins are
153 * installed on the system 169 * installed on the system
154 */ 170 */
155 QString path = QPEApplication::qpeDir() + "/plugins/security"; 171 QString path = QPEApplication::qpeDir() + "/plugins/security";
156 QDir dir( path, "lib*.so" ); 172 QDir dir( path, "lib*.so" );
157 QStringList list = dir.entryList(); 173 QStringList list = dir.entryList();
158 174
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);
172 pluginListLayout->setSpacing(6); 188 pluginListLayout->setSpacing(6);
173 pluginListLayout->setMargin(11); 189 pluginListLayout->setMargin(11);
174 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget ); 190 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget );
175 pluginListLayout->addWidget(pluginListTitle); 191 pluginListLayout->addWidget(pluginListTitle);
176 QHBox * pluginListHB = new QHBox(m_pluginListWidget); 192 QHBox * pluginListHB = new QHBox(m_pluginListWidget);
177 pluginListLayout->addWidget(pluginListHB); 193 pluginListLayout->addWidget(pluginListHB);
178 194
179 m_pluginListView = new QListView(pluginListHB); 195 m_pluginListView = new QListView(pluginListHB);
180 m_pluginListView->addColumn("PluginList"); 196 m_pluginListView->addColumn("PluginList");
181 m_pluginListView->header()->hide(); 197 m_pluginListView->header()->hide();
182 m_pluginListView->setSorting(-1); 198 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" )); 199 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 200
185 QVBox * pluginListVB = new QVBox(pluginListHB); 201 QVBox * pluginListVB = new QVBox(pluginListHB);
186 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); 202 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
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") );
200 216
201 // sync settings page 217 // sync settings page
202 m_syncWidget = new SyncBase( m_mainTW, "sync config widget" ); 218 m_syncWidget = new SyncBase( m_mainTW, "sync config widget" );
203 m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") ); 219 m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") );
204 220
205 // read the "Security" Config file and update our UI 221 // read the "Security" Config file and update our UI
206 readConfig(); 222 readConfig();
207 223
208 224
209 if (m_pluginsInstalled) 225 if (m_pluginsInstalled)
210 { 226 {
211 /* loads plugins configuration widgets in mainTW tabs and in pluginListView 227 /* loads plugins configuration widgets in mainTW tabs and in pluginListView
212 */ 228 */
213 229
214 loadPlugins(); 230 loadPlugins();
215 231
216 for ( int i = pluginList.count() - 1; i >= 0; i-- ) { 232 for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
217 MultiauthPlugin plugin = pluginList[i]; 233 MultiauthPlugin plugin = pluginList[i];
218 234
219 // load the config widgets in the tabs 235 // load the config widgets in the tabs
220 // (configWidget will return 0l if there is no configuration GUI) 236 // (configWidget will return 0l if there is no configuration GUI)
221 MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW); 237 MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW);
222 if ( widget != 0l ) { 238 if ( widget != 0l ) {
223 odebug << "plugin " << plugin.name << " has a configuration widget" << oendl; 239 odebug << "plugin " << plugin.name << " has a configuration widget" << oendl;
224 configWidgetList.append(widget); 240 configWidgetList.append(widget);
225 m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(), 241 m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(),
226 plugin.pluginObject->pluginName() ); 242 plugin.pluginObject->pluginName() );
227 } 243 }
228 // set the order/activate tab 244 // set the order/activate tab
229 QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() ); 245 QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() );
230 QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox ); 246 QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox );
231 if ( !icon.isNull() ) { 247 if ( !icon.isNull() ) {
232 item->setPixmap( 0, icon ); 248 item->setPixmap( 0, icon );
233 } 249 }
234 if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) { 250 if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) {
235 item->setOn( TRUE ); 251 item->setOn( TRUE );
236 } 252 }
237 m_plugins[plugin.name] = item; 253 m_plugins[plugin.name] = item;
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 */
251 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)"); 267 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)");
252 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); 268 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
253 pluginListLayout->setSpacing(11); 269 pluginListLayout->setSpacing(11);
254 pluginListLayout->setMargin(11); 270 pluginListLayout->setMargin(11);
255 pluginListLayout->setAlignment( Qt::AlignTop ); 271 pluginListLayout->setAlignment( Qt::AlignTop );
256 QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box"); 272 QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box");
257 pluginListLayout->addWidget(warningBox); 273 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 ); 274 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 275
260 m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") ); 276 m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") );
261 277
262 // set the first tab as default. 278 // set the first tab as default.
263 m_mainTW->setCurrentTab(m_loginWidget); 279 m_mainTW->setCurrentTab(m_loginWidget);
264 } 280 }
265 281
266 showMaximized(); 282 showMaximized();
267} 283}
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();
288} 309}
289 310
290/// moves up the selected plugin 311/// moves up the selected plugin
291void MultiauthConfig::moveSelectedUp() 312void MultiauthConfig::moveSelectedUp()
292{ 313{
293 QListViewItem *item = m_pluginListView->selectedItem(); 314 QListViewItem *item = m_pluginListView->selectedItem();
294 if ( item && item->itemAbove() ) { 315 if ( item && item->itemAbove() ) {
295 item->itemAbove()->moveItem( item ); 316 item->itemAbove()->moveItem( item );
296 } 317 }
297} 318}
298 319
299/// moves down the selected plugin 320/// moves down the selected plugin
300void MultiauthConfig::moveSelectedDown() 321void MultiauthConfig::moveSelectedDown()
301{ 322{
302 QListViewItem *item = m_pluginListView->selectedItem(); 323 QListViewItem *item = m_pluginListView->selectedItem();
303 if ( item && item->itemBelow() ) { 324 if ( item && item->itemBelow() ) {
304 item->moveItem( item->itemBelow() ); 325 item->moveItem( item->itemBelow() );
305 } 326 }
306} 327}
307 328
308/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface 329/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface
309void MultiauthConfig::readConfig() 330void MultiauthConfig::readConfig()
310{ 331{
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
329 /* Login and Sync stuff */ 349 /* Login and Sync stuff */
330 pcfg->setGroup("Sync"); 350 pcfg->setGroup("Sync");
331 int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 351 int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24
332 int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24); 352 int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24);
333 353
334 pcfg->setGroup("SyncMode"); 354 pcfg->setGroup("SyncMode");
335 int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp 355 int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp
336 switch( mode ) { 356 switch( mode ) {
337 case 0x01: 357 case 0x01:
338 m_syncWidget->syncModeCombo->setCurrentItem( 0 ); 358 m_syncWidget->syncModeCombo->setCurrentItem( 0 );
339 break; 359 break;
340 case 0x02: 360 case 0x02:
341 default: 361 default:
342 m_syncWidget->syncModeCombo->setCurrentItem( 1 ); 362 m_syncWidget->syncModeCombo->setCurrentItem( 1 );
343 break; 363 break;
344 case 0x04: 364 case 0x04:
345 m_syncWidget->syncModeCombo->setCurrentItem( 2 ); 365 m_syncWidget->syncModeCombo->setCurrentItem( 2 );
346 break; 366 break;
347 } 367 }
348 /* 368 /*
349 cfg.setGroup("Remote"); 369 cfg.setGroup("Remote");
350 if ( telnetAvailable() ) 370 if ( telnetAvailable() )
351 telnet->setChecked(cfg.readEntry("allow_telnet")); 371 telnet->setChecked(cfg.readEntry("allow_telnet"));
352 else 372 else
353 telnet->hide(); 373 telnet->hide();
354 374
355 if ( sshAvailable() ) 375 if ( sshAvailable() )
356 ssh->setChecked(cfg.readEntry("allow_ssh")); 376 ssh->setChecked(cfg.readEntry("allow_ssh"));
357 else 377 else
358 ssh->hide(); 378 ssh->hide();
359 */ 379 */
360 380
361 // release the Config handler 381 // release the Config handler
362 delete pcfg; 382 delete pcfg;
363 // indeed, selectNet will open the config file... 383 // indeed, selectNet will open the config file...
364 selectNet(auth_peer,auth_peer_bits,TRUE); 384 selectNet(auth_peer,auth_peer_bits,TRUE);
365 385
366 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), 386 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)),
367 this, SLOT(setSyncNet(const QString&))); 387 this, SLOT(setSyncNet(const QString&)));
368 388
369 389
370 390
371 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 391 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
372 Config loginCfg(configFile,Config::File); 392 Config loginCfg(configFile,Config::File);
373 393
374 loginCfg.setGroup("General"); 394 loginCfg.setGroup("General");
375 autoLoginName=loginCfg.readEntry("AutoLogin",""); 395 autoLoginName=loginCfg.readEntry("AutoLogin","");
376 396
377 if (autoLoginName.stripWhiteSpace().isEmpty()) { 397 if (autoLoginName.stripWhiteSpace().isEmpty()) {
378 autoLogin=false; 398 autoLogin=false;
379 } else { 399 } else {
380 autoLogin=true; 400 autoLogin=true;
381 } 401 }
382 402
383 403
384 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); 404 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool)));
385 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); 405 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int)));
386 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); 406 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults()));
387 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); 407 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry()));
388 408
389 loadUsers(); 409 loadUsers();
390 updateGUI(); 410 updateGUI();
391 411
392} 412}
393 413
394void MultiauthConfig::writeConfig() 414void MultiauthConfig::writeConfig()
395{ 415{
396 Config* pcfg = new Config("Security"); 416 Config* pcfg = new Config("Security");
397 417
398 if (m_pluginsInstalled) 418 if (m_pluginsInstalled)
399 { 419 {
400 pcfg->setGroup( "Plugins" ); 420 pcfg->setGroup( "Plugins" );
401 QStringList exclude; 421 QStringList exclude;
402 QStringList include; 422 QStringList include;
403 QStringList allPlugins; 423 QStringList allPlugins;
404 424
405 QListViewItemIterator list_it( m_pluginListView ); 425 QListViewItemIterator list_it( m_pluginListView );
406 426
407 // this makes sure the names get saved in the order selected 427 // this makes sure the names get saved in the order selected
408 for ( ; list_it.current(); ++list_it ) { 428 for ( ; list_it.current(); ++list_it ) {
409 QMap <QString, QCheckListItem *>::Iterator it; 429 QMap <QString, QCheckListItem *>::Iterator it;
410 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { 430 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) {
411 if ( list_it.current() == (*it) && !(*it)-> isOn () ) { 431 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
412 exclude << it.key(); 432 exclude << it.key();
413 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ 433 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
414 include << it.key(); 434 include << it.key();
415 } 435 }
416 if ( list_it.current() == (*it) ) { 436 if ( list_it.current() == (*it) ) {
417 allPlugins << it.key(); 437 allPlugins << it.key();
418 } 438 }
419 } 439 }
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;
438 int auth_peer_bits; 457 int auth_peer_bits;
439 QString sn = m_syncWidget->syncnet->currentText(); 458 QString sn = m_syncWidget->syncnet->currentText();
440 parseNet(sn,auth_peer,auth_peer_bits); 459 parseNet(sn,auth_peer,auth_peer_bits);
441 460
442 //this is the *selected* (active) net range 461 //this is the *selected* (active) net range
443 pcfg->writeEntry("auth_peer",auth_peer); 462 pcfg->writeEntry("auth_peer",auth_peer);
444 pcfg->writeEntry("auth_peer_bits",auth_peer_bits); 463 pcfg->writeEntry("auth_peer_bits",auth_peer_bits);
445 464
446 //write back all other net ranges in *cleartext* 465 //write back all other net ranges in *cleartext*
447 for (int i=0; i<10; i++) { 466 for (int i=0; i<10; i++) {
448 QString target; 467 QString target;
449 target.sprintf("net%d", i); 468 target.sprintf("net%d", i);
450 if ( i < m_syncWidget->syncnet->count() ) 469 if ( i < m_syncWidget->syncnet->count() )
451 pcfg->writeEntry(target, m_syncWidget->syncnet->text(i)); 470 pcfg->writeEntry(target, m_syncWidget->syncnet->text(i));
452 else // no more entry in the syncnet list -> we clear the line 471 else // no more entry in the syncnet list -> we clear the line
453 pcfg->writeEntry(target, ""); 472 pcfg->writeEntry(target, "");
454 } 473 }
455 474
456#ifdef ODP 475#ifdef ODP
457#error "Use 0,1,2 and use Launcher" 476#error "Use 0,1,2 and use Launcher"
458#endif 477#endif
459 /* keep the old code so we don't use currentItem directly */ 478 /* keep the old code so we don't use currentItem directly */
460 int value = 0x02; 479 int value = 0x02;
461 switch( m_syncWidget->syncModeCombo->currentItem() ) { 480 switch( m_syncWidget->syncModeCombo->currentItem() ) {
462 case 0: 481 case 0:
463 value = 0x01; 482 value = 0x01;
464 break; 483 break;
465 case 1: 484 case 1:
466 value = 0x02; 485 value = 0x02;
467 break; 486 break;
468 case 2: 487 case 2:
469 value = 0x04; 488 value = 0x04;
470 break; 489 break;
471 } 490 }
472 pcfg->setGroup("SyncMode"); 491 pcfg->setGroup("SyncMode");
473 pcfg->writeEntry( "Mode", value ); 492 pcfg->writeEntry( "Mode", value );
474 493
475 /* 494 /*
476 pcfg->setGroup("Remote"); 495 pcfg->setGroup("Remote");
477 if ( telnetAvailable() ) 496 if ( telnetAvailable() )
478 pcfg->writeEntry("allow_telnet",telnet->isChecked()); 497 pcfg->writeEntry("allow_telnet",telnet->isChecked());
479 if ( sshAvailable() ) 498 if ( sshAvailable() )
480 pcfg->writeEntry("allow_ssh",ssh->isChecked()); 499 pcfg->writeEntry("allow_ssh",ssh->isChecked());
481 // ### write ssh/telnet sys config files 500 // ### write ssh/telnet sys config files
482 */ 501 */
483 502
484 //release the Config handler 503 //release the Config handler
485 delete pcfg; 504 delete pcfg;
486 505
487 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 506 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
488 Config loginCfg(configFile,Config::File); 507 Config loginCfg(configFile,Config::File);
489 loginCfg.setGroup("General"); 508 loginCfg.setGroup("General");
490 509
491 if (autoLogin) { 510 if (autoLogin) {
492 loginCfg.writeEntry("AutoLogin",autoLoginName); 511 loginCfg.writeEntry("AutoLogin",autoLoginName);
493 } else { 512 } else {
494 loginCfg.removeEntry("AutoLogin"); 513 loginCfg.removeEntry("AutoLogin");
495 } 514 }
496 515
497} 516}
498 517
499/// slot used to record the fact plugins order has been modified 518/// slot used to record the fact plugins order has been modified
500void MultiauthConfig::pluginsChanged() { 519void MultiauthConfig::pluginsChanged() {
501 m_plugins_changed = true; 520 m_plugins_changed = true;
502} 521}
503 522
504/// loads each multiauth plugin 523/// loads each multiauth plugin
505void MultiauthConfig::loadPlugins() { 524void MultiauthConfig::loadPlugins() {
506 525
507 QString path = QPEApplication::qpeDir() + "/plugins/security"; 526 QString path = QPEApplication::qpeDir() + "/plugins/security";
508 QDir dir( path, "lib*.so" ); 527 QDir dir( path, "lib*.so" );
509 528
510 QStringList list = dir.entryList(); 529 QStringList list = dir.entryList();
511 QStringList::Iterator it; 530 QStringList::Iterator it;
512 531
513 // temporary list used to sort plugins 532 // temporary list used to sort plugins
514 QMap<QString, MultiauthPlugin> sortList; 533 QMap<QString, MultiauthPlugin> sortList;
515 534
516 for ( it = list.begin(); it != list.end(); ++it ) { 535 for ( it = list.begin(); it != list.end(); ++it ) {
517 QInterfacePtr<MultiauthPluginInterface> iface; 536 QInterfacePtr<MultiauthPluginInterface> iface;
518 QLibrary *lib = new QLibrary( path + "/" + *it ); 537 QLibrary *lib = new QLibrary( path + "/" + *it );
519 QString libPath(path + "/" + *it); 538 QString libPath(path + "/" + *it);
520 539
521 if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 540 if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
522 MultiauthPlugin plugin; 541 MultiauthPlugin plugin;
523 plugin.library = lib; 542 plugin.library = lib;
524 plugin.iface = iface; 543 plugin.iface = iface;
525 plugin.name = QString(*it); 544 plugin.name = QString(*it);
526 545
527 // find out if plugins should be launched 546 // find out if plugins should be launched
528 if ( m_excludePlugins.grep( *it ).isEmpty() ) { 547 if ( m_excludePlugins.grep( *it ).isEmpty() ) {
529 plugin.active = true; 548 plugin.active = true;
530 } else { 549 } else {
531 plugin.active = false; 550 plugin.active = false;
532 } 551 }
533 552
534 plugin.pluginObject = plugin.iface->plugin(); 553 plugin.pluginObject = plugin.iface->plugin();
535 554
536 // "prebuffer" it in one more list, to get the sorting done 555 // "prebuffer" it in one more list, to get the sorting done
537 sortList.insert( plugin.name, plugin ); 556 sortList.insert( plugin.name, plugin );
538 557
539 // on first start the list is off course empty 558 // on first start the list is off course empty
540 if ( m_allPlugins.isEmpty() ) { 559 if ( m_allPlugins.isEmpty() ) {
541 pluginList.append( plugin ); 560 pluginList.append( plugin );
542 } 561 }
543 // if plugin is not yet in the list, add it to the layout too 562 // if plugin is not yet in the list, add it to the layout too
544 else if ( !m_allPlugins.contains( plugin.name ) ) { 563 else if ( !m_allPlugins.contains( plugin.name ) ) {
545 pluginList.append( plugin ); 564 pluginList.append( plugin );
546 } 565 }
547 566
548 } else { 567 } else {
549 delete lib; 568 delete lib;
550 } 569 }
551 570
552 } // end for 571 } // end for
553 572
554 // put m_allPlugins tempPlugin objects into pluginList 573 // put m_allPlugins tempPlugin objects into pluginList
555 if ( !m_allPlugins.isEmpty() ) { 574 if ( !m_allPlugins.isEmpty() ) {
556 MultiauthPlugin tempPlugin; 575 MultiauthPlugin tempPlugin;
557 QStringList::Iterator stringit; 576 QStringList::Iterator stringit;
558 for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) { 577 for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) {
559 tempPlugin = ( sortList.find( *stringit ) ).data(); 578 tempPlugin = ( sortList.find( *stringit ) ).data();
560 if ( !( (tempPlugin.name).isEmpty() ) ) { 579 if ( !( (tempPlugin.name).isEmpty() ) ) {
561 pluginList.append( tempPlugin ); 580 pluginList.append( tempPlugin );
562 } 581 }
563 } 582 }
564 } 583 }
565 584
566} 585}
567 586
568void MultiauthConfig::deleteListEntry() 587void MultiauthConfig::deleteListEntry()
569{ 588{
570 m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem()); 589 m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem());
571} 590}
572 591
573void MultiauthConfig::restoreDefaults() 592void MultiauthConfig::restoreDefaults()
574{ 593{
575 QMessageBox unrecbox( 594 QMessageBox unrecbox(
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 }
589 m_syncWidget->syncModeCombo->setCurrentItem( 2 ); 608 m_syncWidget->syncModeCombo->setCurrentItem( 2 );
590} 609}
591 610
592void MultiauthConfig::insertDefaultRanges() 611void MultiauthConfig::insertDefaultRanges()
593{ 612{
594 m_syncWidget->syncnet->insertItem( "192.168.129.0/24" ); 613 m_syncWidget->syncnet->insertItem( "192.168.129.0/24" );
595 m_syncWidget->syncnet->insertItem( "192.168.1.0/24" ); 614 m_syncWidget->syncnet->insertItem( "192.168.1.0/24" );
596 m_syncWidget->syncnet->insertItem( "192.168.0.0/16" ); 615 m_syncWidget->syncnet->insertItem( "192.168.0.0/16" );
597 m_syncWidget->syncnet->insertItem( "172.16.0.0/12" ); 616 m_syncWidget->syncnet->insertItem( "172.16.0.0/12" );
598 m_syncWidget->syncnet->insertItem( "10.0.0.0/8" ); 617 m_syncWidget->syncnet->insertItem( "10.0.0.0/8" );
599 m_syncWidget->syncnet->insertItem( "1.0.0.0/8" ); 618 m_syncWidget->syncnet->insertItem( "1.0.0.0/8" );
600 m_syncWidget->syncnet->insertItem( tr( "Any" ) ); 619 m_syncWidget->syncnet->insertItem( tr( "Any" ) );
601 m_syncWidget->syncnet->insertItem( tr( "None" ) ); 620 m_syncWidget->syncnet->insertItem( tr( "None" ) );
602} 621}
603 622
604void MultiauthConfig::updateGUI() 623void MultiauthConfig::updateGUI()
605{ 624{
606 m_loginWidget->autologinToggle->setChecked(autoLogin); 625 m_loginWidget->autologinToggle->setChecked(autoLogin);
607 m_loginWidget->userlist->setEnabled(autoLogin); 626 m_loginWidget->userlist->setEnabled(autoLogin);
608} 627}
609 628
610void MultiauthConfig::selectNet(int auth_peer,int auth_peer_bits, bool update) 629void MultiauthConfig::selectNet(int auth_peer,int auth_peer_bits, bool update)
611{ 630{
612 QString sn; 631 QString sn;
613 if ( auth_peer_bits == 0 && auth_peer == 0 ) { 632 if ( auth_peer_bits == 0 && auth_peer == 0 ) {
614 sn = tr("Any"); 633 sn = tr("Any");
615 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { 634 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) {
616 sn = tr("None"); 635 sn = tr("None");
617 } else { 636 } else {
618 sn = 637 sn =
619 QString::number((auth_peer>>24)&0xff) + "." 638 QString::number((auth_peer>>24)&0xff) + "."
620 + QString::number((auth_peer>>16)&0xff) + "." 639 + QString::number((auth_peer>>16)&0xff) + "."
621 + QString::number((auth_peer>>8)&0xff) + "." 640 + QString::number((auth_peer>>8)&0xff) + "."
622 + QString::number((auth_peer>>0)&0xff) + "/" 641 + QString::number((auth_peer>>0)&0xff) + "/"
623 + QString::number(auth_peer_bits); 642 + QString::number(auth_peer_bits);
624 } 643 }
625 644
626 //insert user-defined list of netranges upon start 645 //insert user-defined list of netranges upon start
627 if (update) { 646 if (update) {
628 //User selected/active netrange first 647 //User selected/active netrange first
629 m_syncWidget->syncnet->insertItem( tr(sn) ); 648 m_syncWidget->syncnet->insertItem( tr(sn) );
630 Config cfg("Security"); 649 Config cfg("Security");
631 cfg.setGroup("Sync"); 650 cfg.setGroup("Sync");
632 651
633 //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe 652 //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe
634 QString test = cfg.readEntry("net0",""); 653 QString test = cfg.readEntry("net0","");
635 if (test.isEmpty()) { 654 if (test.isEmpty()) {
636 insertDefaultRanges(); 655 insertDefaultRanges();
637 } else { 656 } else {
638 // 10 ought to be enough for everybody... :) 657 // 10 ought to be enough for everybody... :)
639 // If you need more, don't forget to edit applySecurity() as well 658 // If you need more, don't forget to edit applySecurity() as well
640 bool already_there=FALSE; 659 bool already_there=FALSE;
641 for (int i=0; i<10; i++) { 660 for (int i=0; i<10; i++) {
642 QString target, netrange; 661 QString target, netrange;
643 target.sprintf("net%d", i); 662 target.sprintf("net%d", i);
644 netrange = cfg.readEntry(target,""); 663 netrange = cfg.readEntry(target,"");
645 if (! netrange.isEmpty()){ 664 if (! netrange.isEmpty()){
646 //make sure we have no "twin" entries 665 //make sure we have no "twin" entries
647 for (int i=0; i<m_syncWidget->syncnet->count(); i++) { 666 for (int i=0; i<m_syncWidget->syncnet->count(); i++) {
648 if ( m_syncWidget->syncnet->text(i) == netrange ) { 667 if ( m_syncWidget->syncnet->text(i) == netrange ) {
649 already_there=TRUE; 668 already_there=TRUE;
650 } 669 }
651 } 670 }
652 if (! already_there) { 671 if (! already_there) {
653 m_syncWidget->syncnet->insertItem( netrange ); 672 m_syncWidget->syncnet->insertItem( netrange );
654 } else { 673 } else {
655 already_there=FALSE; 674 already_there=FALSE;
656 } 675 }
657 } 676 }
658 } 677 }
659 } 678 }
660 } 679 }
661 680
662 for (int i=0; i<m_syncWidget->syncnet->count(); i++) { 681 for (int i=0; i<m_syncWidget->syncnet->count(); i++) {
663 if ( m_syncWidget->syncnet->text(i).left(sn.length()) == sn ) { 682 if ( m_syncWidget->syncnet->text(i).left(sn.length()) == sn ) {
664 m_syncWidget->syncnet->setCurrentItem(i); 683 m_syncWidget->syncnet->setCurrentItem(i);
665 return; 684 return;
666 } 685 }
667 } 686 }
668 odebug << "No match for \"" << sn << "\"" << oendl; 687 odebug << "No match for \"" << sn << "\"" << oendl;
669} 688}
670 689
671void MultiauthConfig::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) 690void MultiauthConfig::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
672{ 691{
673 auth_peer=0; 692 auth_peer=0;
674 if ( sn == tr("Any") ) { 693 if ( sn == tr("Any") ) {
675 auth_peer = 0; 694 auth_peer = 0;
676 auth_peer_bits = 0; 695 auth_peer_bits = 0;
677 } else if ( sn == tr("None") ) { 696 } else if ( sn == tr("None") ) {
678 auth_peer = 0; 697 auth_peer = 0;
679 auth_peer_bits = 32; 698 auth_peer_bits = 32;
680 } else { 699 } else {
681 int x=0; 700 int x=0;
682 for (int i=0; i<4; i++) { 701 for (int i=0; i<4; i++) {
683 int nx = sn.find(QChar(i==3 ? '/' : '.'),x); 702 int nx = sn.find(QChar(i==3 ? '/' : '.'),x);
684 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); 703 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt();
685 x = nx+1; 704 x = nx+1;
686 } 705 }
687 uint n = (uint)sn.find(' ',x)-x; 706 uint n = (uint)sn.find(' ',x)-x;
688 auth_peer_bits = sn.mid(x,n).toInt(); 707 auth_peer_bits = sn.mid(x,n).toInt();
689 } 708 }
690} 709}
691 710
692void MultiauthConfig::loadUsers() 711void MultiauthConfig::loadUsers()
693{ 712{
694 QFile passwd("/etc/passwd"); 713 QFile passwd("/etc/passwd");
695 if ( passwd.open(IO_ReadOnly) ) { 714 if ( passwd.open(IO_ReadOnly) ) {
696 QTextStream t( &passwd ); 715 QTextStream t( &passwd );
697 QString s; 716 QString s;
698 QStringList account; 717 QStringList account;
699 while ( !t.eof() ) { 718 while ( !t.eof() ) {
700 account = QStringList::split(':',t.readLine()); 719 account = QStringList::split(':',t.readLine());
701 // Hide disabled accounts and some special accounts 720 // Hide disabled accounts and some special accounts
702 if (*account.at(1)!="*" && *account.at(0)!="ppp" && *account.at(0)!="messagebus") { 721 if (*account.at(1)!="*" && *account.at(0)!="ppp" && *account.at(0)!="messagebus") {
703 722
704 m_loginWidget->userlist->insertItem(*account.at(0)); 723 m_loginWidget->userlist->insertItem(*account.at(0));
705 // Highlight this item if it is set to m_loginWidget->autologinToggle 724 // Highlight this item if it is set to m_loginWidget->autologinToggle
706 if ( *account.at(0) == autoLoginName) 725 if ( *account.at(0) == autoLoginName)
707 m_loginWidget->userlist->setCurrentItem(m_loginWidget->userlist->count()-1); 726 m_loginWidget->userlist->setCurrentItem(m_loginWidget->userlist->count()-1);
708 } 727 }
709 } 728 }
710 passwd.close(); 729 passwd.close();
711 } 730 }
712 731
713} 732}
714 733
715void MultiauthConfig::toggleAutoLogin(bool val) 734void MultiauthConfig::toggleAutoLogin(bool val)
716{ 735{
717 autoLogin=val; 736 autoLogin=val;
718 m_loginWidget->userlist->setEnabled(val); 737 m_loginWidget->userlist->setEnabled(val);
719 // if autoLogin is true, we will set by default the login currently visible in the userlist 738 // if autoLogin is true, we will set by default the login currently visible in the userlist
720 if (autoLogin) 739 if (autoLogin)
721 autoLoginName=m_loginWidget->userlist->currentText(); 740 autoLoginName=m_loginWidget->userlist->currentText();
722} 741}
723 742
724 743
725 744
726 745
727void MultiauthConfig::setSyncNet(const QString& sn) 746void MultiauthConfig::setSyncNet(const QString& sn)
728{ 747{
729 int auth_peer,auth_peer_bits; 748 int auth_peer,auth_peer_bits;
730 parseNet(sn,auth_peer,auth_peer_bits); 749 parseNet(sn,auth_peer,auth_peer_bits);
731 selectNet(auth_peer,auth_peer_bits,FALSE); 750 selectNet(auth_peer,auth_peer_bits,FALSE);
732} 751}
733 752
734void MultiauthConfig::changeLoginName( int idx ) 753void MultiauthConfig::changeLoginName( int idx )
735{ 754{
736 autoLoginName = m_loginWidget->userlist->text(idx);; 755 autoLoginName = m_loginWidget->userlist->text(idx);;
737 updateGUI(); 756 updateGUI();
738} 757}
739 758
740/// \todo do implement that? who? how? 759/// \todo do implement that? who? how?
741bool MultiauthConfig::telnetAvailable() const 760bool MultiauthConfig::telnetAvailable() const
742{ 761{
743 return FALSE; 762 return FALSE;
744} 763}
745 764
746/// \todo do implement that? who? how? 765/// \todo do implement that? who? how?
747bool MultiauthConfig::sshAvailable() const 766bool MultiauthConfig::sshAvailable() const
748{ 767{
749 return FALSE; 768 return FALSE;
750} 769}
751 770
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
@@ -1,145 +1,151 @@
1/** 1/**
2 * \file multiauthconfig.h 2 * \file multiauthconfig.h
3 * \brief Configuration GUI for Opie multiauth. framework, login and sync 3 * \brief Configuration GUI for Opie multiauth. framework, login and sync
4 * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) 4 * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
5 */ 5 */
6/* 6/*
7 =. This file is part of the Opie Project 7 =. This file is part of the Opie Project
8 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> 8 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
9 .>+-= 9 .>+-=
10 _;:, .> :=|. This library is free software; you can 10 _;:, .> :=|. This library is free software; you can
11.> <`_, > . <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 12:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
13.="- .-=="i, .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - . .-<_> .<> Foundation; either version 2 of the License, 14 - . .-<_> .<> Foundation; either version 2 of the License,
15 ._= =} : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16 .%`+i> _;_. 16 .%`+i> _;_.
17 .i_,=:_. -<s. This library is distributed in the hope that 17 .i_,=:_. -<s. This library is distributed in the hope that
18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19 : .. .:, . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.= = ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++= -. .` .: details. 23++= -. .` .: details.
24 : = ...= . :.=- 24 : = ...= . :.=-
25 -. .:....=;==+<; You should have received a copy of the GNU 25 -. .:....=;==+<; You should have received a copy of the GNU
26 -_. . . )=. = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27 -- :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef MULTIAUTHCONFIG_H 34#ifndef MULTIAUTHCONFIG_H
35#define MULTIAUTHCONFIG_H 35#define MULTIAUTHCONFIG_H
36 36
37#include <opie2/multiauthplugininterface.h> 37#include <opie2/multiauthplugininterface.h>
38#include <opie2/multiauthcommon.h> 38#include <opie2/multiauthcommon.h>
39 39
40/* OPIE */ 40/* OPIE */
41#include <opie2/otabwidget.h> 41#include <opie2/otabwidget.h>
42 42
43/* QT */ 43/* QT */
44#include <qdialog.h> 44#include <qdialog.h>
45#include <qwidget.h> 45#include <qwidget.h>
46#include <qcheckbox.h> 46#include <qcheckbox.h>
47#include <qspinbox.h> 47#include <qspinbox.h>
48#include <qpe/config.h> 48#include <qpe/config.h>
49#include <qlistview.h> 49#include <qlistview.h>
50#include <qmap.h> 50#include <qmap.h>
51#include <qcombobox.h> 51#include <qcombobox.h>
52#include <qpushbutton.h> 52#include <qpushbutton.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
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;
113 /// plugin list page 118 /// plugin list page
114 QWidget *m_pluginListWidget; 119 QWidget *m_pluginListWidget;
115 /// misc config page 120 /// misc config page
116 MultiauthGeneralConfig *m_generalConfig; 121 MultiauthGeneralConfig *m_generalConfig;
117 /// login (root / ...) choice page 122 /// login (root / ...) choice page
118 LoginBase *m_loginWidget; 123 LoginBase *m_loginWidget;
119 /// synchronization settings page 124 /// synchronization settings page
120 SyncBase *m_syncWidget; 125 SyncBase *m_syncWidget;
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;
133 void updateGUI(); 139 void updateGUI();
134 140
135 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits); 141 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits);
136 void selectNet(int auth_peer,int auth_peer_bits,bool update); 142 void selectNet(int auth_peer,int auth_peer_bits,bool update);
137 143
138 144
139 bool autoLogin; 145 bool autoLogin;
140 QString autoLoginName; 146 QString autoLoginName;
141}; 147};
142 148
143 149
144#endif // MULTIAUTHCONFIG_H 150#endif // MULTIAUTHCONFIG_H
145 151
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
@@ -1,135 +1,144 @@
1#include "multiauthmainwindow.h" 1#include "multiauthmainwindow.h"
2 2
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
20 Config *pcfg = new Config("Security"); 23 if (allowBypass == true)
21 pcfg->setGroup("Misc"); 24 explanScreens = true;
22 explanScreens = pcfg->readBoolEntry("explanScreens", true); 25 else
23 allowBypass = pcfg->readBoolEntry("allowBypass", false); 26 {
24 delete pcfg; 27 Config *pcfg = new Config("Security");
28 pcfg->setGroup("Misc");
29 explanScreens = pcfg->readBoolEntry("explanScreens", true);
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
31 // if explanScreens is false, we don't show any text in the QDialog, 38 // if explanScreens is false, we don't show any text in the QDialog,
32 // and we proceed directly 39 // and we proceed directly
33 if ( explanScreens == true ) 40 if ( explanScreens == true )
34 { 41 {
35 title = new QLabel("<center><h1>" + tr("Welcome to Opie Multi-authentication Framework") + "</h1></center>", this); 42 title = new QLabel("<center><h1>" + tr("Welcome to Opie Multi-authentication Framework") + "</h1></center>", this);
36 message = new QLabel("<center><h3>" + tr("Launching authentication plugins...") + "</h3></center>", this); 43 message = new QLabel("<center><h3>" + tr("Launching authentication plugins...") + "</h3></center>", this);
37 } else { 44 } else {
38 title = new QLabel("", this); 45 title = new QLabel("", this);
39 message = new QLabel("", this); 46 message = new QLabel("", this);
40 } 47 }
41 48
42 layout->addWidget(title); 49 layout->addWidget(title);
43 layout->addWidget(message); 50 layout->addWidget(message);
44 proceedButton = new QPushButton(tr("Proceed..."), this); 51 proceedButton = new QPushButton(tr("Proceed..."), this);
45 layout->addWidget(proceedButton, 0, Qt::AlignHCenter); 52 layout->addWidget(proceedButton, 0, Qt::AlignHCenter);
46 53
47 QObject::connect(proceedButton, SIGNAL(clicked()), this, SLOT(proceed())); 54 QObject::connect(proceedButton, SIGNAL(clicked()), this, SLOT(proceed()));
48 55
49 if ( explanScreens == true ) 56 if ( explanScreens == true )
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();
63 } 70 }
64 71
65 } 72 }
66 else 73 else
67 { 74 {
68 // we will need this button only if runPlugins() fails in proceed() 75 // we will need this button only if runPlugins() fails in proceed()
69 proceedButton->hide(); 76 proceedButton->hide();
70 // let's proceed now 77 // let's proceed now
71 proceed(); 78 proceed();
72 } 79 }
73} 80}
74 81
75/// nothing to do 82/// nothing to do
76MultiauthMainWindow::~MultiauthMainWindow() { 83MultiauthMainWindow::~MultiauthMainWindow() {
77} 84}
78 85
79/// launch the authentication 86/// launch the authentication
80void MultiauthMainWindow::proceed() { 87void MultiauthMainWindow::proceed() {
81 int result = Internal::runPlugins(); 88 int result = Internal::runPlugins();
82 89
83 90
84 if ( (result == 0) && !explanScreens ) 91 if ( (result == 0) && !explanScreens )
85 { 92 {
86 // the authentication has succeeded, we can exit directly 93 // the authentication has succeeded, we can exit directly
87 // this will work if we haven't been called by the constructor of MultiauthMainWindow 94 // this will work if we haven't been called by the constructor of MultiauthMainWindow
88 close(); 95 close();
89 // and if we've been called by this constructor, we use this variable to tell our 96 // and if we've been called by this constructor, we use this variable to tell our
90 // caller we're already done 97 // caller we're already done
91 alreadyDone = true; 98 alreadyDone = true;
92 return; 99 return;
93 } 100 }
94 else 101 else
95 { 102 {
96 103
97 proceedButton->setText("Another try?"); 104 proceedButton->setText("Another try?");
98 QString resultMessage; 105 QString resultMessage;
99 106
100 if (result == 0) 107 if (result == 0)
101 { 108 {
102 // authentication has succeeded, adapt interface then 109 // authentication has succeeded, adapt interface then
103 message->setText( "<center><h3>" + tr("Congratulations! Your authentication has been successful.") + "</h3></center>" ); 110 message->setText( "<center><h3>" + tr("Congratulations! Your authentication has been successful.") + "</h3></center>" );
104 quit->setText("Enter Opie"); 111 quit->setText("Enter Opie");
105 if ( quit->isHidden() ) 112 if ( quit->isHidden() )
106 { 113 {
107 // that means we don't allow to bypass, but now we can show and connect this button 114 // that means we don't allow to bypass, but now we can show and connect this button
108 QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close())); 115 QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close()));
109 quit->show(); 116 quit->show();
110 } else { 117 } else {
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
127 * (through this function) authentication has already been succeeded.. 136 * (through this function) authentication has already been succeeded..
128 * \todo try to avoid this hack? 137 * \todo try to avoid this hack?
129 */ 138 */
130bool MultiauthMainWindow::isAlreadyDone() { 139bool MultiauthMainWindow::isAlreadyDone() {
131 return alreadyDone; 140 return alreadyDone;
132} 141}
133 142
134} 143}
135} 144}
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
@@ -1,84 +1,84 @@
1/** 1/**
2 * \file multiauthmainwindow.h 2 * \file multiauthmainwindow.h
3 * \brief Defines the Opie multiauth main window. 3 * \brief Defines the Opie multiauth main window.
4 * 4 *
5 * This implementation was derived from the today plugins implementation. 5 * This implementation was derived from the today plugins implementation.
6 * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) 6 * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
7 */ 7 */
8/* 8/*
9 =. This file is part of the Opie Project 9 =. This file is part of the Opie Project
10 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> 10 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
11 .>+-= 11 .>+-=
12 _;:, .> :=|. This library is free software; you can 12 _;:, .> :=|. This library is free software; you can
13.> <`_, > . <= redistribute it and/or modify it under 13.> <`_, > . <= redistribute it and/or modify it under
14:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 14:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
15.="- .-=="i, .._ License as published by the Free Software 15.="- .-=="i, .._ License as published by the Free Software
16 - . .-<_> .<> Foundation; either version 2 of the License, 16 - . .-<_> .<> Foundation; either version 2 of the License,
17 ._= =} : or (at your option) any later version. 17 ._= =} : or (at your option) any later version.
18 .%`+i> _;_. 18 .%`+i> _;_.
19 .i_,=:_. -<s. This library is distributed in the hope that 19 .i_,=:_. -<s. This library is distributed in the hope that
20 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 20 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
21 : .. .:, . . . without even the implied warranty of 21 : .. .:, . . . without even the implied warranty of
22 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 22 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
23 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 23 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
24..}^=.= = ; Library General Public License for more 24..}^=.= = ; Library General Public License for more
25++= -. .` .: details. 25++= -. .` .: details.
26 : = ...= . :.=- 26 : = ...= . :.=-
27 -. .:....=;==+<; You should have received a copy of the GNU 27 -. .:....=;==+<; You should have received a copy of the GNU
28 -_. . . )=. = Library General Public License along with 28 -_. . . )=. = Library General Public License along with
29 -- :-=` this library; see the file COPYING.LIB. 29 -- :-=` this library; see the file COPYING.LIB.
30 If not, write to the Free Software Foundation, 30 If not, write to the Free Software Foundation,
31 Inc., 59 Temple Place - Suite 330, 31 Inc., 59 Temple Place - Suite 330,
32 Boston, MA 02111-1307, USA. 32 Boston, MA 02111-1307, USA.
33 33
34*/ 34*/
35 35
36#ifndef MULTIAUTHMAINWINDOW_H 36#ifndef MULTIAUTHMAINWINDOW_H
37#define MULTIAUTHMAINWINDOW_H 37#define MULTIAUTHMAINWINDOW_H
38 38
39#include <qdialog.h> 39#include <qdialog.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qlabel.h> 42#include <qlabel.h>
43 43
44 44
45namespace Opie { 45namespace Opie {
46namespace Security { 46namespace Security {
47 47
48/// Multiauth main window 48/// Multiauth main window
49/** 49/**
50 * This QDialog window displays some information and an exit button, 50 * This QDialog window displays some information and an exit button,
51 * and completely hides the desktop, preventing user interactions 51 * and completely hides the desktop, preventing user interactions
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;
65 QPushButton * proceedButton, * quit; 65 QPushButton * proceedButton, * quit;
66 /// whether to show explanatory screens before and after the authentication plugins 66 /// whether to show explanatory screens before and after the authentication plugins
67 bool explanScreens; 67 bool explanScreens;
68 /// allow to bypass authnentication via 'exit' buttons on both explan. screens 68 /// allow to bypass authnentication via 'exit' buttons on both explan. screens
69 bool allowBypass; 69 bool allowBypass;
70 /// true when the authentication has been done successfully 70 /// true when the authentication has been done successfully
71 bool alreadyDone; 71 bool alreadyDone;
72 72
73 private slots: 73 private slots:
74 void proceed(); 74 void proceed();
75 private: 75 private:
76 struct Private; 76 struct Private;
77 Private *d; 77 Private *d;
78}; 78};
79 79
80} 80}
81} 81}
82 82
83#endif // MULTIAUTHMAINWINDOW_H 83#endif // MULTIAUTHMAINWINDOW_H
84 84