summaryrefslogtreecommitdiff
authordrw <drw>2005-05-04 22:04:34 (UTC)
committer drw <drw>2005-05-04 22:04:34 (UTC)
commit6378f86d96d8d0003cdb9242871066b2db640cec (patch) (unidiff)
treef4f8e0bd169a49fc38121c5f6937812fa7b7fb0b
parenta829bcb3e78882cf9070a75dfacf9906931e8e80 (diff)
downloadopie-6378f86d96d8d0003cdb9242871066b2db640cec.zip
opie-6378f86d96d8d0003cdb9242871066b2db640cec.tar.gz
opie-6378f86d96d8d0003cdb9242871066b2db640cec.tar.bz2
Resource -> OResource and add missing lib dependencies
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/security/multiauthconfig.cpp7
-rw-r--r--core/settings/security/opie-security.control2
2 files changed, 5 insertions, 4 deletions
diff --git a/core/settings/security/multiauthconfig.cpp b/core/settings/security/multiauthconfig.cpp
index da99804..43b453f 100644
--- a/core/settings/security/multiauthconfig.cpp
+++ b/core/settings/security/multiauthconfig.cpp
@@ -1,743 +1,744 @@
1#include <opie2/odebug.h> 1#include <opie2/odebug.h>
2#include <opie2/oresource.h>
2#include <opie2/multiauthpassword.h> 3#include <opie2/multiauthpassword.h>
3 4
4#include <qgroupbox.h> 5#include <qgroupbox.h>
5#include <qvgroupbox.h> 6#include <qvgroupbox.h>
6#include <qpe/resource.h>
7#include <qlayout.h> 7#include <qlayout.h>
8#include <qlabel.h> 8#include <qlabel.h>
9#include <qhbox.h> 9#include <qhbox.h>
10#include <qheader.h> 10#include <qheader.h>
11#include <qvbox.h> 11#include <qvbox.h>
12#include <qwhatsthis.h> 12#include <qwhatsthis.h>
13#include <qtoolbutton.h> 13#include <qtoolbutton.h>
14#include <qstringlist.h> 14#include <qstringlist.h>
15#include <qdir.h> 15#include <qdir.h>
16#include <qpe/qlibrary.h> 16#include <qpe/qlibrary.h>
17#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
18 18
19#include "multiauthconfig.h" 19#include "multiauthconfig.h"
20 20
21 21
22using Opie::Security::MultiauthPluginInterface; 22using Opie::Security::MultiauthPluginInterface;
23using Opie::Security::MultiauthPluginObject; 23using Opie::Security::MultiauthPluginObject;
24using Opie::Security::MultiauthConfigWidget; 24using Opie::Security::MultiauthConfigWidget;
25/// keeps information about MultiauthPluginObject plugins 25/// keeps information about MultiauthPluginObject plugins
26struct MultiauthPlugin { 26struct MultiauthPlugin {
27 MultiauthPlugin() : library( 0 ), iface( 0 ), pluginObject( 0 ) {} 27 MultiauthPlugin() : library( 0 ), iface( 0 ), pluginObject( 0 ) {}
28 /// plugin file 28 /// plugin file
29 QLibrary *library; 29 QLibrary *library;
30 /// the plugin object interface 30 /// the plugin object interface
31 QInterfacePtr<MultiauthPluginInterface> iface; 31 QInterfacePtr<MultiauthPluginInterface> iface;
32 /// the plugin object itself 32 /// the plugin object itself
33 MultiauthPluginObject *pluginObject; 33 MultiauthPluginObject *pluginObject;
34 /// name of the plugin file 34 /// name of the plugin file
35 QString name; 35 QString name;
36 /// should the plugin be launched during authentication or not 36 /// should the plugin be launched during authentication or not
37 bool active; 37 bool active;
38 /// order of the plugin, in the pluginListWidget and during authentication 38 /// order of the plugin, in the pluginListWidget and during authentication
39 int pos; 39 int pos;
40}; 40};
41 41
42/// list of available MultiauthPlugin objects 42/// list of available MultiauthPlugin objects
43static QValueList<MultiauthPlugin> pluginList; 43static QValueList<MultiauthPlugin> pluginList;
44 44
45 45
46/// 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)
47class ToolButton : public QToolButton { 47class ToolButton : public QToolButton {
48 48
49 public: 49 public:
50 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 )
51 : QToolButton( parent, name ) { 51 : QToolButton( parent, name ) {
52 setPixmap( Resource::loadPixmap( icon ) ); 52 setPixmap( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) );
53 setAutoRaise( TRUE ); 53 setAutoRaise( TRUE );
54 setFocusPolicy( QWidget::NoFocus ); 54 setFocusPolicy( QWidget::NoFocus );
55 setToggleButton( t ); 55 setToggleButton( t );
56 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 56 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
57 } 57 }
58}; 58};
59 59
60 MultiauthGeneralConfig::MultiauthGeneralConfig(MultiauthConfig * parentConfig, 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")
61: QWidget(parent, name), m_onStart(0), m_onResume(0), m_noProtectConfig(0), m_explanScreens(0), m_nbSuccessMin(0), m_tryButton(0) 61: QWidget(parent, name), m_onStart(0), m_onResume(0), m_noProtectConfig(0), m_explanScreens(0), m_nbSuccessMin(0), m_tryButton(0)
62{ 62{
63 // keep track of the MultiauthConfig parent in one of our attributes 63 // keep track of the MultiauthConfig parent in one of our attributes
64 m_parentConfig = parentConfig; 64 m_parentConfig = parentConfig;
65 QVBoxLayout *vb = new QVBoxLayout(this); 65 QVBoxLayout *vb = new QVBoxLayout(this);
66 vb->setSpacing(11); 66 vb->setSpacing(11);
67 vb->setMargin(11); 67 vb->setMargin(11);
68 vb->setAlignment( Qt::AlignTop ); 68 vb->setAlignment( Qt::AlignTop );
69 69
70 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");
71 vb->addWidget(lockBox); 71 vb->addWidget(lockBox);
72 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() ); 72 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() );
73 m_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");
74 m_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");
75 boxLayout->addWidget(m_onStart, 0, 0); 75 boxLayout->addWidget(m_onStart, 0, 0);
76 boxLayout->addWidget(m_onResume, 0, 1); 76 boxLayout->addWidget(m_onResume, 0, 1);
77 77
78 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");
79 vb->addWidget(nbBox); 79 vb->addWidget(nbBox);
80 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() ); 80 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() );
81 m_nbSuccessMin = new QSpinBox(nbBox); 81 m_nbSuccessMin = new QSpinBox(nbBox);
82 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox); 82 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox);
83 nbBoxLayout->addWidget(m_nbSuccessMin, 0, 0); 83 nbBoxLayout->addWidget(m_nbSuccessMin, 0, 0);
84 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1); 84 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1);
85 m_nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor 85 m_nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor
86 86
87 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Options"), this, "dev box"); 87 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Options"), this, "dev box");
88 vb->addWidget(devBox); 88 vb->addWidget(devBox);
89 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() ); 89 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() );
90 m_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");
91 m_explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens"); 91 m_explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens");
92 devBoxLayout->addWidget(m_noProtectConfig, 0, 0); 92 devBoxLayout->addWidget(m_noProtectConfig, 0, 0);
93 devBoxLayout->addWidget(m_explanScreens, 1, 0); 93 devBoxLayout->addWidget(m_explanScreens, 1, 0);
94 94
95 QVGroupBox *tryBox = new QVGroupBox(tr("Testing"), this, "try box"); 95 QVGroupBox *tryBox = new QVGroupBox(tr("Testing"), this, "try box");
96 vb->addWidget(tryBox); 96 vb->addWidget(tryBox);
97 m_tryButton = new QPushButton( tr("Test the authentication now"), tryBox, "try button"); 97 m_tryButton = new QPushButton( tr("Test the authentication now"), tryBox, "try button");
98 connect( m_tryButton, SIGNAL(clicked()), this, SLOT(tryAuth()) ); 98 connect( m_tryButton, SIGNAL(clicked()), this, SLOT(tryAuth()) );
99 99
100} 100}
101 101
102/// nothing to do 102/// nothing to do
103MultiauthGeneralConfig::~MultiauthGeneralConfig() 103MultiauthGeneralConfig::~MultiauthGeneralConfig()
104{} 104{}
105 105
106/// launches the authentication process, as configured, with the option to bypass it 106/// launches the authentication process, as configured, with the option to bypass it
107void MultiauthGeneralConfig::tryAuth() 107void MultiauthGeneralConfig::tryAuth()
108{ 108{
109 QMessageBox confirmSave( 109 QMessageBox confirmSave(
110 tr("Attention"), 110 tr("Attention"),
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>" + 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>" +
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>", 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>",
113 QMessageBox::Warning, 113 QMessageBox::Warning,
114 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, 114 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
115 0, QString::null, TRUE, WStyle_StaysOnTop); 115 0, QString::null, TRUE, WStyle_StaysOnTop);
116 confirmSave.setButtonText(QMessageBox::Cancel, tr("Cancel")); 116 confirmSave.setButtonText(QMessageBox::Cancel, tr("Cancel"));
117 confirmSave.setButtonText(QMessageBox::Yes, tr("OK")); 117 confirmSave.setButtonText(QMessageBox::Yes, tr("OK"));
118 118
119 if ( confirmSave.exec() == QMessageBox::Yes) 119 if ( confirmSave.exec() == QMessageBox::Yes)
120 { 120 {
121 owarn << "writing config as user accepted" << oendl; 121 owarn << "writing config as user accepted" << oendl;
122 m_parentConfig->writeConfigs(); 122 m_parentConfig->writeConfigs();
123 owarn << "testing authentication" << oendl; 123 owarn << "testing authentication" << oendl;
124 // launch the authentication in testing mode 124 // launch the authentication in testing mode
125 Opie::Security::MultiauthPassword::authenticate(Opie::Security::TestNow); 125 Opie::Security::MultiauthPassword::authenticate(Opie::Security::TestNow);
126 } 126 }
127} 127}
128 128
129 129
130/// Builds and displays the Opie multi-authentication configuration dialog 130/// Builds and displays the Opie multi-authentication configuration dialog
131static void test_and_start() { 131static void test_and_start() {
132 Config pcfg("Security"); 132 Config pcfg("Security");
133 pcfg.setGroup( "Misc" ); 133 pcfg.setGroup( "Misc" );
134 bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true); 134 bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true);
135 135
136 if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) { 136 if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) {
137 owarn << "authentication failed, not showing opie-security" << oendl; 137 owarn << "authentication failed, not showing opie-security" << oendl;
138 exit( -1 ); 138 exit( -1 );
139 } 139 }
140} 140}
141 141
142 142
143 143
144 MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0) 144 MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0)
145: QDialog(par, w, TRUE, f), 145: QDialog(par, w, TRUE, f),
146 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0), 146 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0),
147 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0), 147 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0),
148 m_nbSuccessReq(0), m_plugins_changed(false) 148 m_nbSuccessReq(0), m_plugins_changed(false)
149{ 149{
150 /* Initializes the global configuration window 150 /* Initializes the global configuration window
151 */ 151 */
152 test_and_start(); 152 test_and_start();
153 153
154 /* Checks (and memorizes) if any authentication plugins are 154 /* Checks (and memorizes) if any authentication plugins are
155 * installed on the system 155 * installed on the system
156 */ 156 */
157 QString path = QPEApplication::qpeDir() + "plugins/security"; 157 QString path = QPEApplication::qpeDir() + "plugins/security";
158 QDir dir( path, "lib*.so" ); 158 QDir dir( path, "lib*.so" );
159 QStringList list = dir.entryList(); 159 QStringList list = dir.entryList();
160 160
161 m_pluginsInstalled = ! list.isEmpty(); 161 m_pluginsInstalled = ! list.isEmpty();
162 if (m_pluginsInstalled == false) 162 if (m_pluginsInstalled == false)
163 owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl; 163 owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl;
164 164
165 setCaption( tr( "Security configuration" ) ); 165 setCaption( tr( "Security configuration" ) );
166 QVBoxLayout *layout = new QVBoxLayout( this ); 166 QVBoxLayout *layout = new QVBoxLayout( this );
167 m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" ); 167 m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" );
168 layout->addWidget(m_mainTW); 168 layout->addWidget(m_mainTW);
169 169
170 if (m_pluginsInstalled) 170 if (m_pluginsInstalled)
171 { 171 {
172 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget"); 172 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget");
173 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); 173 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
174 pluginListLayout->setSpacing(6); 174 pluginListLayout->setSpacing(6);
175 pluginListLayout->setMargin(11); 175 pluginListLayout->setMargin(11);
176 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget ); 176 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget );
177 pluginListLayout->addWidget(pluginListTitle); 177 pluginListLayout->addWidget(pluginListTitle);
178 QHBox * pluginListHB = new QHBox(m_pluginListWidget); 178 QHBox * pluginListHB = new QHBox(m_pluginListWidget);
179 pluginListLayout->addWidget(pluginListHB); 179 pluginListLayout->addWidget(pluginListHB);
180 180
181 m_pluginListView = new QListView(pluginListHB); 181 m_pluginListView = new QListView(pluginListHB);
182 m_pluginListView->addColumn("PluginList"); 182 m_pluginListView->addColumn("PluginList");
183 m_pluginListView->header()->hide(); 183 m_pluginListView->header()->hide();
184 m_pluginListView->setSorting(-1); 184 m_pluginListView->setSorting(-1);
185 QWhatsThis::add(m_pluginListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the order they will appear in" )); 185 QWhatsThis::add(m_pluginListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the order they will appear in" ));
186 186
187 QVBox * pluginListVB = new QVBox(pluginListHB); 187 QVBox * pluginListVB = new QVBox(pluginListHB);
188 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); 188 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
189 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); 189 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
190 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) ); 190 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) );
191 191
192 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) ); 192 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) );
193 193
194 // general Opie multi-authentication configuration tab 194 // general Opie multi-authentication configuration tab
195 m_generalConfig = new MultiauthGeneralConfig(this, m_mainTW); 195 m_generalConfig = new MultiauthGeneralConfig(this, m_mainTW);
196 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") ); 196 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") );
197 197
198 } 198 }
199 // login settings page 199 // login settings page
200 m_loginWidget = new LoginBase(m_mainTW, "login config widget"); 200 m_loginWidget = new LoginBase(m_mainTW, "login config widget");
201 m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") ); 201 m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") );
202 202
203 // sync settings page 203 // sync settings page
204 m_syncWidget = new SyncBase( m_mainTW, "sync config widget" ); 204 m_syncWidget = new SyncBase( m_mainTW, "sync config widget" );
205 m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") ); 205 m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") );
206 206
207 // read the "Security" Config file and update our UI 207 // read the "Security" Config file and update our UI
208 readConfig(); 208 readConfig();
209 209
210 210
211 if (m_pluginsInstalled) 211 if (m_pluginsInstalled)
212 { 212 {
213 /* loads plugins configuration widgets in mainTW tabs and in pluginListView 213 /* loads plugins configuration widgets in mainTW tabs and in pluginListView
214 */ 214 */
215 215
216 loadPlugins(); 216 loadPlugins();
217 217
218 for ( int i = pluginList.count() - 1; i >= 0; i-- ) { 218 for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
219 MultiauthPlugin plugin = pluginList[i]; 219 MultiauthPlugin plugin = pluginList[i];
220 220
221 // load the config widgets in the tabs 221 // load the config widgets in the tabs
222 // (configWidget will return 0l if there is no configuration GUI) 222 // (configWidget will return 0l if there is no configuration GUI)
223 MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW); 223 MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW);
224 if ( widget != 0l ) { 224 if ( widget != 0l ) {
225 odebug << "plugin " << plugin.name << " has a configuration widget" << oendl; 225 odebug << "plugin " << plugin.name << " has a configuration widget" << oendl;
226 configWidgetList.append(widget); 226 configWidgetList.append(widget);
227 m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(), 227 m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(),
228 plugin.pluginObject->pluginName() ); 228 plugin.pluginObject->pluginName() );
229 } 229 }
230 // set the order/activate tab 230 // set the order/activate tab
231 QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() ); 231 QPixmap icon = Opie::Core::OResource::loadPixmap( plugin.pluginObject->pixmapNameWidget(),
232 Opie::Core::OResource::SmallIcon );
232 QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox ); 233 QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox );
233 if ( !icon.isNull() ) { 234 if ( !icon.isNull() ) {
234 item->setPixmap( 0, icon ); 235 item->setPixmap( 0, icon );
235 } 236 }
236 if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) { 237 if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) {
237 item->setOn( TRUE ); 238 item->setOn( TRUE );
238 } 239 }
239 m_plugins[plugin.name] = item; 240 m_plugins[plugin.name] = item;
240 } 241 }
241 242
242 // set the first tab as default. 243 // set the first tab as default.
243 m_mainTW->setCurrentTab(m_pluginListWidget); 244 m_mainTW->setCurrentTab(m_pluginListWidget);
244 245
245 // put the number of plugins as the max number of req. auth. 246 // put the number of plugins as the max number of req. auth.
246 m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() ); 247 m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() );
247 } 248 }
248 else 249 else
249 { 250 {
250 /* we don't have any installed plugin there. Let's tell 251 /* we don't have any installed plugin there. Let's tell
251 * that to the user in a third tab, using the m_pluginListWidget widget 252 * that to the user in a third tab, using the m_pluginListWidget widget
252 */ 253 */
253 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)"); 254 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)");
254 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); 255 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
255 pluginListLayout->setSpacing(11); 256 pluginListLayout->setSpacing(11);
256 pluginListLayout->setMargin(11); 257 pluginListLayout->setMargin(11);
257 pluginListLayout->setAlignment( Qt::AlignTop ); 258 pluginListLayout->setAlignment( Qt::AlignTop );
258 QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box"); 259 QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box");
259 pluginListLayout->addWidget(warningBox); 260 pluginListLayout->addWidget(warningBox);
260 QLabel * warningText = new QLabel( "<p>" + tr("To be able to protect your PDA with one or more authentication plugins (for example, a simple PIN authentication), you must install at least one <em>opie-securityplugin-*</em> package! Once you have done that, you will be able to configure your PDA protection here.") + "</p>", warningBox ); 261 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-securityplugin-*</em> package! Once you have done that, you will be able to configure your PDA protection here.") + "</p>", warningBox );
261 262
262 m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") ); 263 m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") );
263 264
264 // set the first tab as default. 265 // set the first tab as default.
265 m_mainTW->setCurrentTab(m_loginWidget); 266 m_mainTW->setCurrentTab(m_loginWidget);
266 } 267 }
267 268
268 showMaximized(); 269 showMaximized();
269} 270}
270 271
271/// nothing to do 272/// nothing to do
272MultiauthConfig::~MultiauthConfig() 273MultiauthConfig::~MultiauthConfig()
273{ 274{
274} 275}
275 276
276/// saves the general and plugin(s) configurations 277/// saves the general and plugin(s) configurations
277void MultiauthConfig::writeConfigs() { 278void MultiauthConfig::writeConfigs() {
278 MultiauthConfigWidget* confWidget = 0; 279 MultiauthConfigWidget* confWidget = 0;
279 for ( confWidget = configWidgetList.first(); confWidget != 0; 280 for ( confWidget = configWidgetList.first(); confWidget != 0;
280 confWidget = configWidgetList.next() ) 281 confWidget = configWidgetList.next() )
281 confWidget->writeConfig(); 282 confWidget->writeConfig();
282 283
283 writeConfig(); 284 writeConfig();
284} 285}
285 286
286/// on QDialog::accept, we save all the configurations and exit the QDialog normally 287/// on QDialog::accept, we save all the configurations and exit the QDialog normally
287void MultiauthConfig::accept() { 288void MultiauthConfig::accept() {
288 writeConfigs(); 289 writeConfigs();
289 QDialog::accept(); 290 QDialog::accept();
290} 291}
291 292
292void MultiauthConfig::done( int r ) { 293void MultiauthConfig::done( int r ) {
293 QDialog::done( r ); 294 QDialog::done( r );
294 close(); 295 close();
295} 296}
296 297
297/// moves up the selected plugin 298/// moves up the selected plugin
298void MultiauthConfig::moveSelectedUp() 299void MultiauthConfig::moveSelectedUp()
299{ 300{
300 QListViewItem *item = m_pluginListView->selectedItem(); 301 QListViewItem *item = m_pluginListView->selectedItem();
301 if ( item && item->itemAbove() ) { 302 if ( item && item->itemAbove() ) {
302 item->itemAbove()->moveItem( item ); 303 item->itemAbove()->moveItem( item );
303 } 304 }
304} 305}
305 306
306/// moves down the selected plugin 307/// moves down the selected plugin
307void MultiauthConfig::moveSelectedDown() 308void MultiauthConfig::moveSelectedDown()
308{ 309{
309 QListViewItem *item = m_pluginListView->selectedItem(); 310 QListViewItem *item = m_pluginListView->selectedItem();
310 if ( item && item->itemBelow() ) { 311 if ( item && item->itemBelow() ) {
311 item->moveItem( item->itemBelow() ); 312 item->moveItem( item->itemBelow() );
312 } 313 }
313} 314}
314 315
315/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface 316/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface
316void MultiauthConfig::readConfig() 317void MultiauthConfig::readConfig()
317{ 318{
318 // pointer, so we release this Config when we want 319 // pointer, so we release this Config when we want
319 Config* pcfg = new Config("Security"); 320 Config* pcfg = new Config("Security");
320 321
321 if (m_pluginsInstalled) 322 if (m_pluginsInstalled)
322 { 323 {
323 pcfg->setGroup( "Misc" ); 324 pcfg->setGroup( "Misc" );
324 m_generalConfig->m_onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); 325 m_generalConfig->m_onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) );
325 m_generalConfig->m_onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); 326 m_generalConfig->m_onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) );
326 m_generalConfig->m_nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); 327 m_generalConfig->m_nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) );
327 m_generalConfig->m_noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); 328 m_generalConfig->m_noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) );
328 m_generalConfig->m_explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); 329 m_generalConfig->m_explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) );
329 330
330 pcfg->setGroup( "Plugins" ); 331 pcfg->setGroup( "Plugins" );
331 m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' ); 332 m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' );
332 m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' ); 333 m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' );
333 } 334 }
334 335
335 /* Login and Sync stuff */ 336 /* Login and Sync stuff */
336 pcfg->setGroup("Sync"); 337 pcfg->setGroup("Sync");
337 int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 338 int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24
338 int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24); 339 int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24);
339 340
340 pcfg->setGroup("SyncMode"); 341 pcfg->setGroup("SyncMode");
341 int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp 342 int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp
342 switch( mode ) { 343 switch( mode ) {
343 case 0x01: 344 case 0x01:
344 m_syncWidget->syncModeCombo->setCurrentItem( 0 ); 345 m_syncWidget->syncModeCombo->setCurrentItem( 0 );
345 break; 346 break;
346 case 0x02: 347 case 0x02:
347 default: 348 default:
348 m_syncWidget->syncModeCombo->setCurrentItem( 1 ); 349 m_syncWidget->syncModeCombo->setCurrentItem( 1 );
349 break; 350 break;
350 case 0x04: 351 case 0x04:
351 m_syncWidget->syncModeCombo->setCurrentItem( 2 ); 352 m_syncWidget->syncModeCombo->setCurrentItem( 2 );
352 break; 353 break;
353 } 354 }
354 /* 355 /*
355 cfg.setGroup("Remote"); 356 cfg.setGroup("Remote");
356 if ( telnetAvailable() ) 357 if ( telnetAvailable() )
357 telnet->setChecked(cfg.readEntry("allow_telnet")); 358 telnet->setChecked(cfg.readEntry("allow_telnet"));
358 else 359 else
359 telnet->hide(); 360 telnet->hide();
360 361
361 if ( sshAvailable() ) 362 if ( sshAvailable() )
362 ssh->setChecked(cfg.readEntry("allow_ssh")); 363 ssh->setChecked(cfg.readEntry("allow_ssh"));
363 else 364 else
364 ssh->hide(); 365 ssh->hide();
365 */ 366 */
366 367
367 // release the Config handler 368 // release the Config handler
368 delete pcfg; 369 delete pcfg;
369 // indeed, selectNet will open the config file... 370 // indeed, selectNet will open the config file...
370 selectNet(auth_peer,auth_peer_bits,TRUE); 371 selectNet(auth_peer,auth_peer_bits,TRUE);
371 372
372 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), 373 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)),
373 this, SLOT(setSyncNet(const QString&))); 374 this, SLOT(setSyncNet(const QString&)));
374 375
375 376
376 377
377 QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; 378 QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf";
378 Config loginCfg(configFile,Config::File); 379 Config loginCfg(configFile,Config::File);
379 380
380 loginCfg.setGroup("General"); 381 loginCfg.setGroup("General");
381 autoLoginName=loginCfg.readEntry("AutoLogin",""); 382 autoLoginName=loginCfg.readEntry("AutoLogin","");
382 383
383 if (autoLoginName.stripWhiteSpace().isEmpty()) { 384 if (autoLoginName.stripWhiteSpace().isEmpty()) {
384 autoLogin=false; 385 autoLogin=false;
385 } else { 386 } else {
386 autoLogin=true; 387 autoLogin=true;
387 } 388 }
388 389
389 390
390 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); 391 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool)));
391 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); 392 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int)));
392 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); 393 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults()));
393 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); 394 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry()));
394 395
395 loadUsers(); 396 loadUsers();
396 updateGUI(); 397 updateGUI();
397 398
398} 399}
399 400
400void MultiauthConfig::writeConfig() 401void MultiauthConfig::writeConfig()
401{ 402{
402 Config pcfg("Security"); 403 Config pcfg("Security");
403 404
404 if (m_pluginsInstalled) 405 if (m_pluginsInstalled)
405 { 406 {
406 pcfg.setGroup( "Plugins" ); 407 pcfg.setGroup( "Plugins" );
407 QStringList exclude; 408 QStringList exclude;
408 QStringList include; 409 QStringList include;
409 QStringList allPlugins; 410 QStringList allPlugins;
410 411
411 QListViewItemIterator list_it( m_pluginListView ); 412 QListViewItemIterator list_it( m_pluginListView );
412 413
413 // this makes sure the names get saved in the order selected 414 // this makes sure the names get saved in the order selected
414 for ( ; list_it.current(); ++list_it ) { 415 for ( ; list_it.current(); ++list_it ) {
415 QMap <QString, QCheckListItem *>::Iterator it; 416 QMap <QString, QCheckListItem *>::Iterator it;
416 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { 417 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) {
417 if ( list_it.current() == (*it) && !(*it)-> isOn () ) { 418 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
418 exclude << it.key(); 419 exclude << it.key();
419 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ 420 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
420 include << it.key(); 421 include << it.key();
421 } 422 }
422 if ( list_it.current() == (*it) ) { 423 if ( list_it.current() == (*it) ) {
423 allPlugins << it.key(); 424 allPlugins << it.key();
424 } 425 }
425 } 426 }
426 } 427 }
427 pcfg.writeEntry( "ExcludePlugins", exclude, ',' ); 428 pcfg.writeEntry( "ExcludePlugins", exclude, ',' );
428 pcfg.writeEntry( "IncludePlugins", include, ',' ); 429 pcfg.writeEntry( "IncludePlugins", include, ',' );
429 pcfg.writeEntry( "AllPlugins", allPlugins, ',' ); 430 pcfg.writeEntry( "AllPlugins", allPlugins, ',' );
430 431
431 pcfg.setGroup( "Misc" ); 432 pcfg.setGroup( "Misc" );
432 pcfg.writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() ); 433 pcfg.writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() );
433 pcfg.writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() ); 434 pcfg.writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() );
434 pcfg.writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() ); 435 pcfg.writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() );
435 pcfg.writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() ); 436 pcfg.writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() );
436 pcfg.writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() ); 437 pcfg.writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() );
437 } 438 }
438 439
439 /* Login and Sync stuff */ 440 /* Login and Sync stuff */
440 441
441 pcfg.setGroup("Sync"); 442 pcfg.setGroup("Sync");
442 int auth_peer=0; 443 int auth_peer=0;
443 int auth_peer_bits; 444 int auth_peer_bits;
444 QString sn = m_syncWidget->syncnet->currentText(); 445 QString sn = m_syncWidget->syncnet->currentText();
445 parseNet(sn,auth_peer,auth_peer_bits); 446 parseNet(sn,auth_peer,auth_peer_bits);
446 447
447 //this is the *selected* (active) net range 448 //this is the *selected* (active) net range
448 pcfg.writeEntry("auth_peer",auth_peer); 449 pcfg.writeEntry("auth_peer",auth_peer);
449 pcfg.writeEntry("auth_peer_bits",auth_peer_bits); 450 pcfg.writeEntry("auth_peer_bits",auth_peer_bits);
450 451
451 //write back all other net ranges in *cleartext* 452 //write back all other net ranges in *cleartext*
452 for (int i=0; i<10; i++) { 453 for (int i=0; i<10; i++) {
453 QString target; 454 QString target;
454 target.sprintf("net%d", i); 455 target.sprintf("net%d", i);
455 if ( i < m_syncWidget->syncnet->count() ) 456 if ( i < m_syncWidget->syncnet->count() )
456 pcfg.writeEntry(target, m_syncWidget->syncnet->text(i)); 457 pcfg.writeEntry(target, m_syncWidget->syncnet->text(i));
457 else // no more entry in the syncnet list -> we clear the line 458 else // no more entry in the syncnet list -> we clear the line
458 pcfg.writeEntry(target, ""); 459 pcfg.writeEntry(target, "");
459 } 460 }
460 461
461#ifdef ODP 462#ifdef ODP
462#error "Use 0,1,2 and use Launcher" 463#error "Use 0,1,2 and use Launcher"
463#endif 464#endif
464 /* keep the old code so we don't use currentItem directly */ 465 /* keep the old code so we don't use currentItem directly */
465 int value = 0x02; 466 int value = 0x02;
466 switch( m_syncWidget->syncModeCombo->currentItem() ) { 467 switch( m_syncWidget->syncModeCombo->currentItem() ) {
467 case 0: 468 case 0:
468 value = 0x01; 469 value = 0x01;
469 break; 470 break;
470 case 1: 471 case 1:
471 value = 0x02; 472 value = 0x02;
472 break; 473 break;
473 case 2: 474 case 2:
474 value = 0x04; 475 value = 0x04;
475 break; 476 break;
476 } 477 }
477 pcfg.setGroup("SyncMode"); 478 pcfg.setGroup("SyncMode");
478 pcfg.writeEntry( "Mode", value ); 479 pcfg.writeEntry( "Mode", value );
479 480
480 /* 481 /*
481 pcfg.setGroup("Remote"); 482 pcfg.setGroup("Remote");
482 if ( telnetAvailable() ) 483 if ( telnetAvailable() )
483 pcfg.writeEntry("allow_telnet",telnet->isChecked()); 484 pcfg.writeEntry("allow_telnet",telnet->isChecked());
484 if ( sshAvailable() ) 485 if ( sshAvailable() )
485 pcfg.writeEntry("allow_ssh",ssh->isChecked()); 486 pcfg.writeEntry("allow_ssh",ssh->isChecked());
486 // ### write ssh/telnet sys config files 487 // ### write ssh/telnet sys config files
487 */ 488 */
488 489
489 //release the Config handler 490 //release the Config handler
490 pcfg.write(); 491 pcfg.write();
491 492
492 QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; 493 QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf";
493 Config loginCfg(configFile,Config::File); 494 Config loginCfg(configFile,Config::File);
494 loginCfg.setGroup("General"); 495 loginCfg.setGroup("General");
495 496
496 if (autoLogin) { 497 if (autoLogin) {
497 loginCfg.writeEntry("AutoLogin",autoLoginName); 498 loginCfg.writeEntry("AutoLogin",autoLoginName);
498 } else { 499 } else {
499 loginCfg.removeEntry("AutoLogin"); 500 loginCfg.removeEntry("AutoLogin");
500 } 501 }
501 502
502} 503}
503 504
504/// slot used to record the fact plugins order has been modified 505/// slot used to record the fact plugins order has been modified
505void MultiauthConfig::pluginsChanged() { 506void MultiauthConfig::pluginsChanged() {
506 m_plugins_changed = true; 507 m_plugins_changed = true;
507} 508}
508 509
509/// loads each multiauth plugin 510/// loads each multiauth plugin
510void MultiauthConfig::loadPlugins() { 511void MultiauthConfig::loadPlugins() {
511 512
512 QString path = QPEApplication::qpeDir() + "plugins/security"; 513 QString path = QPEApplication::qpeDir() + "plugins/security";
513 QDir dir( path, "lib*.so" ); 514 QDir dir( path, "lib*.so" );
514 515
515 QStringList list = dir.entryList(); 516 QStringList list = dir.entryList();
516 QStringList::Iterator it; 517 QStringList::Iterator it;
517 518
518 // temporary list used to sort plugins 519 // temporary list used to sort plugins
519 QMap<QString, MultiauthPlugin> sortList; 520 QMap<QString, MultiauthPlugin> sortList;
520 521
521 for ( it = list.begin(); it != list.end(); ++it ) { 522 for ( it = list.begin(); it != list.end(); ++it ) {
522 QInterfacePtr<MultiauthPluginInterface> iface; 523 QInterfacePtr<MultiauthPluginInterface> iface;
523 QLibrary *lib = new QLibrary( path + "/" + *it ); 524 QLibrary *lib = new QLibrary( path + "/" + *it );
524 QString libPath(path + "/" + *it); 525 QString libPath(path + "/" + *it);
525 526
526 if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 527 if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
527 MultiauthPlugin plugin; 528 MultiauthPlugin plugin;
528 plugin.library = lib; 529 plugin.library = lib;
529 plugin.iface = iface; 530 plugin.iface = iface;
530 plugin.name = QString(*it); 531 plugin.name = QString(*it);
531 532
532 // find out if plugins should be launched 533 // find out if plugins should be launched
533 if ( m_excludePlugins.grep( *it ).isEmpty() ) { 534 if ( m_excludePlugins.grep( *it ).isEmpty() ) {
534 plugin.active = true; 535 plugin.active = true;
535 } else { 536 } else {
536 plugin.active = false; 537 plugin.active = false;
537 } 538 }
538 539
539 plugin.pluginObject = plugin.iface->plugin(); 540 plugin.pluginObject = plugin.iface->plugin();
540 541
541 // "prebuffer" it in one more list, to get the sorting done 542 // "prebuffer" it in one more list, to get the sorting done
542 sortList.insert( plugin.name, plugin ); 543 sortList.insert( plugin.name, plugin );
543 544
544 // on first start the list is off course empty 545 // on first start the list is off course empty
545 if ( m_allPlugins.isEmpty() ) { 546 if ( m_allPlugins.isEmpty() ) {
546 pluginList.append( plugin ); 547 pluginList.append( plugin );
547 } 548 }
548 // if plugin is not yet in the list, add it to the layout too 549 // if plugin is not yet in the list, add it to the layout too
549 else if ( !m_allPlugins.contains( plugin.name ) ) { 550 else if ( !m_allPlugins.contains( plugin.name ) ) {
550 pluginList.append( plugin ); 551 pluginList.append( plugin );
551 } 552 }
552 553
553 } else { 554 } else {
554 delete lib; 555 delete lib;
555 } 556 }
556 557
557 } // end for 558 } // end for
558 559
559 // put m_allPlugins tempPlugin objects into pluginList 560 // put m_allPlugins tempPlugin objects into pluginList
560 if ( !m_allPlugins.isEmpty() ) { 561 if ( !m_allPlugins.isEmpty() ) {
561 MultiauthPlugin tempPlugin; 562 MultiauthPlugin tempPlugin;
562 QStringList::Iterator stringit; 563 QStringList::Iterator stringit;
563 for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) { 564 for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) {
564 tempPlugin = ( sortList.find( *stringit ) ).data(); 565 tempPlugin = ( sortList.find( *stringit ) ).data();
565 if ( !( (tempPlugin.name).isEmpty() ) ) { 566 if ( !( (tempPlugin.name).isEmpty() ) ) {
566 pluginList.append( tempPlugin ); 567 pluginList.append( tempPlugin );
567 } 568 }
568 } 569 }
569 } 570 }
570 571
571} 572}
572 573
573void MultiauthConfig::deleteListEntry() 574void MultiauthConfig::deleteListEntry()
574{ 575{
575 m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem()); 576 m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem());
576} 577}
577 578
578void MultiauthConfig::restoreDefaults() 579void MultiauthConfig::restoreDefaults()
579{ 580{
580 QMessageBox unrecbox( 581 QMessageBox unrecbox(
581 tr("Attention"), 582 tr("Attention"),
582 "<p>" + tr("All user-defined net ranges will be lost.") + "</p>", 583 "<p>" + tr("All user-defined net ranges will be lost.") + "</p>",
583 QMessageBox::Warning, 584 QMessageBox::Warning,
584 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, 585 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
585 0, QString::null, TRUE, WStyle_StaysOnTop); 586 0, QString::null, TRUE, WStyle_StaysOnTop);
586 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); 587 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel"));
587 unrecbox.setButtonText(QMessageBox::Yes, tr("OK")); 588 unrecbox.setButtonText(QMessageBox::Yes, tr("OK"));
588 589
589 if ( unrecbox.exec() == QMessageBox::Yes) 590 if ( unrecbox.exec() == QMessageBox::Yes)
590 { 591 {
591 m_syncWidget->syncnet->clear(); 592 m_syncWidget->syncnet->clear();
592 insertDefaultRanges(); 593 insertDefaultRanges();
593 } 594 }
594 m_syncWidget->syncModeCombo->setCurrentItem( 2 ); 595 m_syncWidget->syncModeCombo->setCurrentItem( 2 );
595} 596}
596 597
597void MultiauthConfig::insertDefaultRanges() 598void MultiauthConfig::insertDefaultRanges()
598{ 599{
599 m_syncWidget->syncnet->insertItem( "192.168.129.0/24" ); 600 m_syncWidget->syncnet->insertItem( "192.168.129.0/24" );
600 m_syncWidget->syncnet->insertItem( "192.168.1.0/24" ); 601 m_syncWidget->syncnet->insertItem( "192.168.1.0/24" );
601 m_syncWidget->syncnet->insertItem( "192.168.0.0/16" ); 602 m_syncWidget->syncnet->insertItem( "192.168.0.0/16" );
602 m_syncWidget->syncnet->insertItem( "172.16.0.0/12" ); 603 m_syncWidget->syncnet->insertItem( "172.16.0.0/12" );
603 m_syncWidget->syncnet->insertItem( "10.0.0.0/8" ); 604 m_syncWidget->syncnet->insertItem( "10.0.0.0/8" );
604 m_syncWidget->syncnet->insertItem( "1.0.0.0/8" ); 605 m_syncWidget->syncnet->insertItem( "1.0.0.0/8" );
605 m_syncWidget->syncnet->insertItem( tr( "Any" ) ); 606 m_syncWidget->syncnet->insertItem( tr( "Any" ) );
606 m_syncWidget->syncnet->insertItem( tr( "None" ) ); 607 m_syncWidget->syncnet->insertItem( tr( "None" ) );
607} 608}
608 609
609void MultiauthConfig::updateGUI() 610void MultiauthConfig::updateGUI()
610{ 611{
611 m_loginWidget->autologinToggle->setChecked(autoLogin); 612 m_loginWidget->autologinToggle->setChecked(autoLogin);
612 m_loginWidget->userlist->setEnabled(autoLogin); 613 m_loginWidget->userlist->setEnabled(autoLogin);
613} 614}
614 615
615void MultiauthConfig::selectNet(int auth_peer,int auth_peer_bits, bool update) 616void MultiauthConfig::selectNet(int auth_peer,int auth_peer_bits, bool update)
616{ 617{
617 QString sn; 618 QString sn;
618 if ( auth_peer_bits == 0 && auth_peer == 0 ) { 619 if ( auth_peer_bits == 0 && auth_peer == 0 ) {
619 sn = tr("Any"); 620 sn = tr("Any");
620 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { 621 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) {
621 sn = tr("None"); 622 sn = tr("None");
622 } else { 623 } else {
623 sn = 624 sn =
624 QString::number((auth_peer>>24)&0xff) + "." 625 QString::number((auth_peer>>24)&0xff) + "."
625 + QString::number((auth_peer>>16)&0xff) + "." 626 + QString::number((auth_peer>>16)&0xff) + "."
626 + QString::number((auth_peer>>8)&0xff) + "." 627 + QString::number((auth_peer>>8)&0xff) + "."
627 + QString::number((auth_peer>>0)&0xff) + "/" 628 + QString::number((auth_peer>>0)&0xff) + "/"
628 + QString::number(auth_peer_bits); 629 + QString::number(auth_peer_bits);
629 } 630 }
630 631
631 //insert user-defined list of netranges upon start 632 //insert user-defined list of netranges upon start
632 if (update) { 633 if (update) {
633 //User selected/active netrange first 634 //User selected/active netrange first
634 m_syncWidget->syncnet->insertItem( tr(sn) ); 635 m_syncWidget->syncnet->insertItem( tr(sn) );
635 Config cfg("Security"); 636 Config cfg("Security");
636 cfg.setGroup("Sync"); 637 cfg.setGroup("Sync");
637 638
638 //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe 639 //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe
639 QString test = cfg.readEntry("net0",""); 640 QString test = cfg.readEntry("net0","");
640 if (test.isEmpty()) { 641 if (test.isEmpty()) {
641 insertDefaultRanges(); 642 insertDefaultRanges();
642 } else { 643 } else {
643 // 10 ought to be enough for everybody... :) 644 // 10 ought to be enough for everybody... :)
644 // If you need more, don't forget to edit applySecurity() as well 645 // If you need more, don't forget to edit applySecurity() as well
645 bool already_there=FALSE; 646 bool already_there=FALSE;
646 for (int i=0; i<10; i++) { 647 for (int i=0; i<10; i++) {
647 QString target, netrange; 648 QString target, netrange;
648 target.sprintf("net%d", i); 649 target.sprintf("net%d", i);
649 netrange = cfg.readEntry(target,""); 650 netrange = cfg.readEntry(target,"");
650 if (! netrange.isEmpty()){ 651 if (! netrange.isEmpty()){
651 //make sure we have no "twin" entries 652 //make sure we have no "twin" entries
652 for (int i=0; i<m_syncWidget->syncnet->count(); i++) { 653 for (int i=0; i<m_syncWidget->syncnet->count(); i++) {
653 if ( m_syncWidget->syncnet->text(i) == netrange ) { 654 if ( m_syncWidget->syncnet->text(i) == netrange ) {
654 already_there=TRUE; 655 already_there=TRUE;
655 } 656 }
656 } 657 }
657 if (! already_there) { 658 if (! already_there) {
658 m_syncWidget->syncnet->insertItem( netrange ); 659 m_syncWidget->syncnet->insertItem( netrange );
659 } else { 660 } else {
660 already_there=FALSE; 661 already_there=FALSE;
661 } 662 }
662 } 663 }
663 } 664 }
664 } 665 }
665 } 666 }
666 667
667 for (int i=0; i<m_syncWidget->syncnet->count(); i++) { 668 for (int i=0; i<m_syncWidget->syncnet->count(); i++) {
668 if ( m_syncWidget->syncnet->text(i).left(sn.length()) == sn ) { 669 if ( m_syncWidget->syncnet->text(i).left(sn.length()) == sn ) {
669 m_syncWidget->syncnet->setCurrentItem(i); 670 m_syncWidget->syncnet->setCurrentItem(i);
670 return; 671 return;
671 } 672 }
672 } 673 }
673 odebug << "No match for \"" << sn << "\"" << oendl; 674 odebug << "No match for \"" << sn << "\"" << oendl;
674} 675}
675 676
676void MultiauthConfig::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) 677void MultiauthConfig::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
677{ 678{
678 auth_peer=0; 679 auth_peer=0;
679 if ( sn == tr("Any") ) { 680 if ( sn == tr("Any") ) {
680 auth_peer = 0; 681 auth_peer = 0;
681 auth_peer_bits = 0; 682 auth_peer_bits = 0;
682 } else if ( sn == tr("None") ) { 683 } else if ( sn == tr("None") ) {
683 auth_peer = 0; 684 auth_peer = 0;
684 auth_peer_bits = 32; 685 auth_peer_bits = 32;
685 } else { 686 } else {
686 int x=0; 687 int x=0;
687 for (int i=0; i<4; i++) { 688 for (int i=0; i<4; i++) {
688 int nx = sn.find(QChar(i==3 ? '/' : '.'),x); 689 int nx = sn.find(QChar(i==3 ? '/' : '.'),x);
689 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); 690 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt();
690 x = nx+1; 691 x = nx+1;
691 } 692 }
692 uint n = (uint)sn.find(' ',x)-x; 693 uint n = (uint)sn.find(' ',x)-x;
693 auth_peer_bits = sn.mid(x,n).toInt(); 694 auth_peer_bits = sn.mid(x,n).toInt();
694 } 695 }
695} 696}
696 697
697void MultiauthConfig::loadUsers() 698void MultiauthConfig::loadUsers()
698{ 699{
699 QFile passwd("/etc/passwd"); 700 QFile passwd("/etc/passwd");
700 if ( passwd.open(IO_ReadOnly) ) { 701 if ( passwd.open(IO_ReadOnly) ) {
701 QTextStream t( &passwd ); 702 QTextStream t( &passwd );
702 QString s; 703 QString s;
703 QStringList account; 704 QStringList account;
704 while ( !t.eof() ) { 705 while ( !t.eof() ) {
705 account = QStringList::split(':',t.readLine()); 706 account = QStringList::split(':',t.readLine());
706 // Hide disabled accounts and some special accounts 707 // Hide disabled accounts and some special accounts
707 if (*account.at(1)!="*" && *account.at(0)!="ppp" && *account.at(0)!="messagebus") { 708 if (*account.at(1)!="*" && *account.at(0)!="ppp" && *account.at(0)!="messagebus") {
708 709
709 m_loginWidget->userlist->insertItem(*account.at(0)); 710 m_loginWidget->userlist->insertItem(*account.at(0));
710 // Highlight this item if it is set to m_loginWidget->autologinToggle 711 // Highlight this item if it is set to m_loginWidget->autologinToggle
711 if ( *account.at(0) == autoLoginName) 712 if ( *account.at(0) == autoLoginName)
712 m_loginWidget->userlist->setCurrentItem(m_loginWidget->userlist->count()-1); 713 m_loginWidget->userlist->setCurrentItem(m_loginWidget->userlist->count()-1);
713 } 714 }
714 } 715 }
715 passwd.close(); 716 passwd.close();
716 } 717 }
717 718
718} 719}
719 720
720void MultiauthConfig::toggleAutoLogin(bool val) 721void MultiauthConfig::toggleAutoLogin(bool val)
721{ 722{
722 autoLogin=val; 723 autoLogin=val;
723 m_loginWidget->userlist->setEnabled(val); 724 m_loginWidget->userlist->setEnabled(val);
724 // if autoLogin is true, we will set by default the login currently visible in the userlist 725 // if autoLogin is true, we will set by default the login currently visible in the userlist
725 if (autoLogin) 726 if (autoLogin)
726 autoLoginName=m_loginWidget->userlist->currentText(); 727 autoLoginName=m_loginWidget->userlist->currentText();
727} 728}
728 729
729 730
730 731
731 732
732void MultiauthConfig::setSyncNet(const QString& sn) 733void MultiauthConfig::setSyncNet(const QString& sn)
733{ 734{
734 int auth_peer,auth_peer_bits; 735 int auth_peer,auth_peer_bits;
735 parseNet(sn,auth_peer,auth_peer_bits); 736 parseNet(sn,auth_peer,auth_peer_bits);
736 selectNet(auth_peer,auth_peer_bits,FALSE); 737 selectNet(auth_peer,auth_peer_bits,FALSE);
737} 738}
738 739
739void MultiauthConfig::changeLoginName( int idx ) 740void MultiauthConfig::changeLoginName( int idx )
740{ 741{
741 autoLoginName = m_loginWidget->userlist->text(idx);; 742 autoLoginName = m_loginWidget->userlist->text(idx);;
742 updateGUI(); 743 updateGUI();
743} 744}
diff --git a/core/settings/security/opie-security.control b/core/settings/security/opie-security.control
index ab08c05..7d393a8 100644
--- a/core/settings/security/opie-security.control
+++ b/core/settings/security/opie-security.control
@@ -1,10 +1,10 @@
1Package: opie-security 1Package: opie-security
2Files: plugins/application/libsecurity.so* bin/security apps/Settings/security.desktop pics/security/sync.png pics/security/users.png pics/security/Security.png 2Files: plugins/application/libsecurity.so* bin/security apps/Settings/security.desktop pics/security/sync.png pics/security/users.png pics/security/Security.png
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal, libopiecore2, libopieui2, libopiesecurity2
8Recommends: opie-lockapplet, opie-multiauth 8Recommends: opie-lockapplet, opie-multiauth
9Description: Security settings dialog for the Opie environment. 9Description: Security settings dialog for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION