author | drw <drw> | 2005-03-04 21:21:09 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-04 21:21:09 (UTC) |
commit | 9df83023cf5db974ba78b7b562be019791052f2f (patch) (unidiff) | |
tree | c1937d3c62d384a635425b9639342da035f23579 | |
parent | 21138e806b94a8ddce6ee14222542257426f5dc1 (diff) | |
download | opie-9df83023cf5db974ba78b7b562be019791052f2f.zip opie-9df83023cf5db974ba78b7b562be019791052f2f.tar.gz opie-9df83023cf5db974ba78b7b562be019791052f2f.tar.bz2 |
Fix name of plugins in label - patch courtesy of Gints
-rw-r--r-- | core/settings/security/multiauthconfig.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/settings/security/multiauthconfig.cpp b/core/settings/security/multiauthconfig.cpp index 7a5f7b9..da99804 100644 --- a/core/settings/security/multiauthconfig.cpp +++ b/core/settings/security/multiauthconfig.cpp | |||
@@ -1,666 +1,666 @@ | |||
1 | #include <opie2/odebug.h> | 1 | #include <opie2/odebug.h> |
2 | #include <opie2/multiauthpassword.h> | 2 | #include <opie2/multiauthpassword.h> |
3 | 3 | ||
4 | #include <qgroupbox.h> | 4 | #include <qgroupbox.h> |
5 | #include <qvgroupbox.h> | 5 | #include <qvgroupbox.h> |
6 | #include <qpe/resource.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 | ||
22 | using Opie::Security::MultiauthPluginInterface; | 22 | using Opie::Security::MultiauthPluginInterface; |
23 | using Opie::Security::MultiauthPluginObject; | 23 | using Opie::Security::MultiauthPluginObject; |
24 | using Opie::Security::MultiauthConfigWidget; | 24 | using Opie::Security::MultiauthConfigWidget; |
25 | /// keeps information about MultiauthPluginObject plugins | 25 | /// keeps information about MultiauthPluginObject plugins |
26 | struct MultiauthPlugin { | 26 | struct 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 |
43 | static QValueList<MultiauthPlugin> pluginList; | 43 | static 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) |
47 | class ToolButton : public QToolButton { | 47 | class 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( Resource::loadPixmap( icon ) ); |
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 |
103 | MultiauthGeneralConfig::~MultiauthGeneralConfig() | 103 | MultiauthGeneralConfig::~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 |
107 | void MultiauthGeneralConfig::tryAuth() | 107 | void 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 |
131 | static void test_and_start() { | 131 | static 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 = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() ); |
232 | QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox ); | 232 | QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox ); |
233 | if ( !icon.isNull() ) { | 233 | if ( !icon.isNull() ) { |
234 | item->setPixmap( 0, icon ); | 234 | item->setPixmap( 0, icon ); |
235 | } | 235 | } |
236 | if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) { | 236 | if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) { |
237 | item->setOn( TRUE ); | 237 | item->setOn( TRUE ); |
238 | } | 238 | } |
239 | m_plugins[plugin.name] = item; | 239 | m_plugins[plugin.name] = item; |
240 | } | 240 | } |
241 | 241 | ||
242 | // set the first tab as default. | 242 | // set the first tab as default. |
243 | m_mainTW->setCurrentTab(m_pluginListWidget); | 243 | m_mainTW->setCurrentTab(m_pluginListWidget); |
244 | 244 | ||
245 | // put the number of plugins as the max number of req. auth. | 245 | // put the number of plugins as the max number of req. auth. |
246 | m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() ); | 246 | m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() ); |
247 | } | 247 | } |
248 | else | 248 | else |
249 | { | 249 | { |
250 | /* we don't have any installed plugin there. Let's tell | 250 | /* we don't have any installed plugin there. Let's tell |
251 | * that to the user in a third tab, using the m_pluginListWidget widget | 251 | * that to the user in a third tab, using the m_pluginListWidget widget |
252 | */ | 252 | */ |
253 | m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)"); | 253 | m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)"); |
254 | QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); | 254 | QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); |
255 | pluginListLayout->setSpacing(11); | 255 | pluginListLayout->setSpacing(11); |
256 | pluginListLayout->setMargin(11); | 256 | pluginListLayout->setMargin(11); |
257 | pluginListLayout->setAlignment( Qt::AlignTop ); | 257 | pluginListLayout->setAlignment( Qt::AlignTop ); |
258 | QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box"); | 258 | QVGroupBox *warningBox = new QVGroupBox(tr("Important notice"), m_pluginListWidget, "noPlugins warning box"); |
259 | pluginListLayout->addWidget(warningBox); | 259 | pluginListLayout->addWidget(warningBox); |
260 | QLabel * warningText = new QLabel( "<p>" + tr("To be able to protect your PDA with one or more authentication plugins (for example, a simple PIN authentication), you must install at least one <em>opie-multiauth-*</em> package! Once you have done that, you will be able to configure your PDA protection here.") + "</p>", warningBox ); | 260 | QLabel * warningText = new QLabel( "<p>" + tr("To be able to protect your PDA with one or more authentication plugins (for example, a simple PIN authentication), you must install at least one <em>opie-securityplugin-*</em> package! Once you have done that, you will be able to configure your PDA protection here.") + "</p>", warningBox ); |
261 | 261 | ||
262 | m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") ); | 262 | m_mainTW->addTab(m_pluginListWidget, "security/Security", tr( "Locking") ); |
263 | 263 | ||
264 | // set the first tab as default. | 264 | // set the first tab as default. |
265 | m_mainTW->setCurrentTab(m_loginWidget); | 265 | m_mainTW->setCurrentTab(m_loginWidget); |
266 | } | 266 | } |
267 | 267 | ||
268 | showMaximized(); | 268 | showMaximized(); |
269 | } | 269 | } |
270 | 270 | ||
271 | /// nothing to do | 271 | /// nothing to do |
272 | MultiauthConfig::~MultiauthConfig() | 272 | MultiauthConfig::~MultiauthConfig() |
273 | { | 273 | { |
274 | } | 274 | } |
275 | 275 | ||
276 | /// saves the general and plugin(s) configurations | 276 | /// saves the general and plugin(s) configurations |
277 | void MultiauthConfig::writeConfigs() { | 277 | void MultiauthConfig::writeConfigs() { |
278 | MultiauthConfigWidget* confWidget = 0; | 278 | MultiauthConfigWidget* confWidget = 0; |
279 | for ( confWidget = configWidgetList.first(); confWidget != 0; | 279 | for ( confWidget = configWidgetList.first(); confWidget != 0; |
280 | confWidget = configWidgetList.next() ) | 280 | confWidget = configWidgetList.next() ) |
281 | confWidget->writeConfig(); | 281 | confWidget->writeConfig(); |
282 | 282 | ||
283 | writeConfig(); | 283 | writeConfig(); |
284 | } | 284 | } |
285 | 285 | ||
286 | /// on QDialog::accept, we save all the configurations and exit the QDialog normally | 286 | /// on QDialog::accept, we save all the configurations and exit the QDialog normally |
287 | void MultiauthConfig::accept() { | 287 | void MultiauthConfig::accept() { |
288 | writeConfigs(); | 288 | writeConfigs(); |
289 | QDialog::accept(); | 289 | QDialog::accept(); |
290 | } | 290 | } |
291 | 291 | ||
292 | void MultiauthConfig::done( int r ) { | 292 | void MultiauthConfig::done( int r ) { |
293 | QDialog::done( r ); | 293 | QDialog::done( r ); |
294 | close(); | 294 | close(); |
295 | } | 295 | } |
296 | 296 | ||
297 | /// moves up the selected plugin | 297 | /// moves up the selected plugin |
298 | void MultiauthConfig::moveSelectedUp() | 298 | void MultiauthConfig::moveSelectedUp() |
299 | { | 299 | { |
300 | QListViewItem *item = m_pluginListView->selectedItem(); | 300 | QListViewItem *item = m_pluginListView->selectedItem(); |
301 | if ( item && item->itemAbove() ) { | 301 | if ( item && item->itemAbove() ) { |
302 | item->itemAbove()->moveItem( item ); | 302 | item->itemAbove()->moveItem( item ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | /// moves down the selected plugin | 306 | /// moves down the selected plugin |
307 | void MultiauthConfig::moveSelectedDown() | 307 | void MultiauthConfig::moveSelectedDown() |
308 | { | 308 | { |
309 | QListViewItem *item = m_pluginListView->selectedItem(); | 309 | QListViewItem *item = m_pluginListView->selectedItem(); |
310 | if ( item && item->itemBelow() ) { | 310 | if ( item && item->itemBelow() ) { |
311 | item->moveItem( item->itemBelow() ); | 311 | item->moveItem( item->itemBelow() ); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | /// reads the <code>Security.conf</code> Config file, and updates parts of the user interface | 315 | /// reads the <code>Security.conf</code> Config file, and updates parts of the user interface |
316 | void MultiauthConfig::readConfig() | 316 | void MultiauthConfig::readConfig() |
317 | { | 317 | { |
318 | // pointer, so we release this Config when we want | 318 | // pointer, so we release this Config when we want |
319 | Config* pcfg = new Config("Security"); | 319 | Config* pcfg = new Config("Security"); |
320 | 320 | ||
321 | if (m_pluginsInstalled) | 321 | if (m_pluginsInstalled) |
322 | { | 322 | { |
323 | pcfg->setGroup( "Misc" ); | 323 | pcfg->setGroup( "Misc" ); |
324 | m_generalConfig->m_onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); | 324 | m_generalConfig->m_onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); |
325 | m_generalConfig->m_onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); | 325 | m_generalConfig->m_onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); |
326 | m_generalConfig->m_nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); | 326 | m_generalConfig->m_nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); |
327 | m_generalConfig->m_noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); | 327 | m_generalConfig->m_noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); |
328 | m_generalConfig->m_explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); | 328 | m_generalConfig->m_explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); |
329 | 329 | ||
330 | pcfg->setGroup( "Plugins" ); | 330 | pcfg->setGroup( "Plugins" ); |
331 | m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' ); | 331 | m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' ); |
332 | m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' ); | 332 | m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' ); |
333 | } | 333 | } |
334 | 334 | ||
335 | /* Login and Sync stuff */ | 335 | /* Login and Sync stuff */ |
336 | pcfg->setGroup("Sync"); | 336 | pcfg->setGroup("Sync"); |
337 | int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 | 337 | 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); | 338 | int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24); |
339 | 339 | ||
340 | pcfg->setGroup("SyncMode"); | 340 | pcfg->setGroup("SyncMode"); |
341 | int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp | 341 | int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp |
342 | switch( mode ) { | 342 | switch( mode ) { |
343 | case 0x01: | 343 | case 0x01: |
344 | m_syncWidget->syncModeCombo->setCurrentItem( 0 ); | 344 | m_syncWidget->syncModeCombo->setCurrentItem( 0 ); |
345 | break; | 345 | break; |
346 | case 0x02: | 346 | case 0x02: |
347 | default: | 347 | default: |
348 | m_syncWidget->syncModeCombo->setCurrentItem( 1 ); | 348 | m_syncWidget->syncModeCombo->setCurrentItem( 1 ); |
349 | break; | 349 | break; |
350 | case 0x04: | 350 | case 0x04: |
351 | m_syncWidget->syncModeCombo->setCurrentItem( 2 ); | 351 | m_syncWidget->syncModeCombo->setCurrentItem( 2 ); |
352 | break; | 352 | break; |
353 | } | 353 | } |
354 | /* | 354 | /* |
355 | cfg.setGroup("Remote"); | 355 | cfg.setGroup("Remote"); |
356 | if ( telnetAvailable() ) | 356 | if ( telnetAvailable() ) |
357 | telnet->setChecked(cfg.readEntry("allow_telnet")); | 357 | telnet->setChecked(cfg.readEntry("allow_telnet")); |
358 | else | 358 | else |
359 | telnet->hide(); | 359 | telnet->hide(); |
360 | 360 | ||
361 | if ( sshAvailable() ) | 361 | if ( sshAvailable() ) |
362 | ssh->setChecked(cfg.readEntry("allow_ssh")); | 362 | ssh->setChecked(cfg.readEntry("allow_ssh")); |
363 | else | 363 | else |
364 | ssh->hide(); | 364 | ssh->hide(); |
365 | */ | 365 | */ |
366 | 366 | ||
367 | // release the Config handler | 367 | // release the Config handler |
368 | delete pcfg; | 368 | delete pcfg; |
369 | // indeed, selectNet will open the config file... | 369 | // indeed, selectNet will open the config file... |
370 | selectNet(auth_peer,auth_peer_bits,TRUE); | 370 | selectNet(auth_peer,auth_peer_bits,TRUE); |
371 | 371 | ||
372 | connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), | 372 | connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), |
373 | this, SLOT(setSyncNet(const QString&))); | 373 | this, SLOT(setSyncNet(const QString&))); |
374 | 374 | ||
375 | 375 | ||
376 | 376 | ||
377 | QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; | 377 | QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; |
378 | Config loginCfg(configFile,Config::File); | 378 | Config loginCfg(configFile,Config::File); |
379 | 379 | ||
380 | loginCfg.setGroup("General"); | 380 | loginCfg.setGroup("General"); |
381 | autoLoginName=loginCfg.readEntry("AutoLogin",""); | 381 | autoLoginName=loginCfg.readEntry("AutoLogin",""); |
382 | 382 | ||
383 | if (autoLoginName.stripWhiteSpace().isEmpty()) { | 383 | if (autoLoginName.stripWhiteSpace().isEmpty()) { |
384 | autoLogin=false; | 384 | autoLogin=false; |
385 | } else { | 385 | } else { |
386 | autoLogin=true; | 386 | autoLogin=true; |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); | 390 | connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); |
391 | connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); | 391 | connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); |
392 | connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); | 392 | connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); |
393 | connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); | 393 | connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); |
394 | 394 | ||
395 | loadUsers(); | 395 | loadUsers(); |
396 | updateGUI(); | 396 | updateGUI(); |
397 | 397 | ||
398 | } | 398 | } |
399 | 399 | ||
400 | void MultiauthConfig::writeConfig() | 400 | void MultiauthConfig::writeConfig() |
401 | { | 401 | { |
402 | Config pcfg("Security"); | 402 | Config pcfg("Security"); |
403 | 403 | ||
404 | if (m_pluginsInstalled) | 404 | if (m_pluginsInstalled) |
405 | { | 405 | { |
406 | pcfg.setGroup( "Plugins" ); | 406 | pcfg.setGroup( "Plugins" ); |
407 | QStringList exclude; | 407 | QStringList exclude; |
408 | QStringList include; | 408 | QStringList include; |
409 | QStringList allPlugins; | 409 | QStringList allPlugins; |
410 | 410 | ||
411 | QListViewItemIterator list_it( m_pluginListView ); | 411 | QListViewItemIterator list_it( m_pluginListView ); |
412 | 412 | ||
413 | // this makes sure the names get saved in the order selected | 413 | // this makes sure the names get saved in the order selected |
414 | for ( ; list_it.current(); ++list_it ) { | 414 | for ( ; list_it.current(); ++list_it ) { |
415 | QMap <QString, QCheckListItem *>::Iterator it; | 415 | QMap <QString, QCheckListItem *>::Iterator it; |
416 | for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { | 416 | for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { |
417 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { | 417 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { |
418 | exclude << it.key(); | 418 | exclude << it.key(); |
419 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ | 419 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ |
420 | include << it.key(); | 420 | include << it.key(); |
421 | } | 421 | } |
422 | if ( list_it.current() == (*it) ) { | 422 | if ( list_it.current() == (*it) ) { |
423 | allPlugins << it.key(); | 423 | allPlugins << it.key(); |
424 | } | 424 | } |
425 | } | 425 | } |
426 | } | 426 | } |
427 | pcfg.writeEntry( "ExcludePlugins", exclude, ',' ); | 427 | pcfg.writeEntry( "ExcludePlugins", exclude, ',' ); |
428 | pcfg.writeEntry( "IncludePlugins", include, ',' ); | 428 | pcfg.writeEntry( "IncludePlugins", include, ',' ); |
429 | pcfg.writeEntry( "AllPlugins", allPlugins, ',' ); | 429 | pcfg.writeEntry( "AllPlugins", allPlugins, ',' ); |
430 | 430 | ||
431 | pcfg.setGroup( "Misc" ); | 431 | pcfg.setGroup( "Misc" ); |
432 | pcfg.writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() ); | 432 | pcfg.writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() ); |
433 | pcfg.writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() ); | 433 | pcfg.writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() ); |
434 | pcfg.writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() ); | 434 | pcfg.writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() ); |
435 | pcfg.writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() ); | 435 | pcfg.writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() ); |
436 | pcfg.writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() ); | 436 | pcfg.writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() ); |
437 | } | 437 | } |
438 | 438 | ||
439 | /* Login and Sync stuff */ | 439 | /* Login and Sync stuff */ |
440 | 440 | ||
441 | pcfg.setGroup("Sync"); | 441 | pcfg.setGroup("Sync"); |
442 | int auth_peer=0; | 442 | int auth_peer=0; |
443 | int auth_peer_bits; | 443 | int auth_peer_bits; |
444 | QString sn = m_syncWidget->syncnet->currentText(); | 444 | QString sn = m_syncWidget->syncnet->currentText(); |
445 | parseNet(sn,auth_peer,auth_peer_bits); | 445 | parseNet(sn,auth_peer,auth_peer_bits); |
446 | 446 | ||
447 | //this is the *selected* (active) net range | 447 | //this is the *selected* (active) net range |
448 | pcfg.writeEntry("auth_peer",auth_peer); | 448 | pcfg.writeEntry("auth_peer",auth_peer); |
449 | pcfg.writeEntry("auth_peer_bits",auth_peer_bits); | 449 | pcfg.writeEntry("auth_peer_bits",auth_peer_bits); |
450 | 450 | ||
451 | //write back all other net ranges in *cleartext* | 451 | //write back all other net ranges in *cleartext* |
452 | for (int i=0; i<10; i++) { | 452 | for (int i=0; i<10; i++) { |
453 | QString target; | 453 | QString target; |
454 | target.sprintf("net%d", i); | 454 | target.sprintf("net%d", i); |
455 | if ( i < m_syncWidget->syncnet->count() ) | 455 | if ( i < m_syncWidget->syncnet->count() ) |
456 | pcfg.writeEntry(target, m_syncWidget->syncnet->text(i)); | 456 | pcfg.writeEntry(target, m_syncWidget->syncnet->text(i)); |
457 | else // no more entry in the syncnet list -> we clear the line | 457 | else // no more entry in the syncnet list -> we clear the line |
458 | pcfg.writeEntry(target, ""); | 458 | pcfg.writeEntry(target, ""); |
459 | } | 459 | } |
460 | 460 | ||
461 | #ifdef ODP | 461 | #ifdef ODP |
462 | #error "Use 0,1,2 and use Launcher" | 462 | #error "Use 0,1,2 and use Launcher" |
463 | #endif | 463 | #endif |
464 | /* keep the old code so we don't use currentItem directly */ | 464 | /* keep the old code so we don't use currentItem directly */ |
465 | int value = 0x02; | 465 | int value = 0x02; |
466 | switch( m_syncWidget->syncModeCombo->currentItem() ) { | 466 | switch( m_syncWidget->syncModeCombo->currentItem() ) { |
467 | case 0: | 467 | case 0: |
468 | value = 0x01; | 468 | value = 0x01; |
469 | break; | 469 | break; |
470 | case 1: | 470 | case 1: |
471 | value = 0x02; | 471 | value = 0x02; |
472 | break; | 472 | break; |
473 | case 2: | 473 | case 2: |
474 | value = 0x04; | 474 | value = 0x04; |
475 | break; | 475 | break; |
476 | } | 476 | } |
477 | pcfg.setGroup("SyncMode"); | 477 | pcfg.setGroup("SyncMode"); |
478 | pcfg.writeEntry( "Mode", value ); | 478 | pcfg.writeEntry( "Mode", value ); |
479 | 479 | ||
480 | /* | 480 | /* |
481 | pcfg.setGroup("Remote"); | 481 | pcfg.setGroup("Remote"); |
482 | if ( telnetAvailable() ) | 482 | if ( telnetAvailable() ) |
483 | pcfg.writeEntry("allow_telnet",telnet->isChecked()); | 483 | pcfg.writeEntry("allow_telnet",telnet->isChecked()); |
484 | if ( sshAvailable() ) | 484 | if ( sshAvailable() ) |
485 | pcfg.writeEntry("allow_ssh",ssh->isChecked()); | 485 | pcfg.writeEntry("allow_ssh",ssh->isChecked()); |
486 | // ### write ssh/telnet sys config files | 486 | // ### write ssh/telnet sys config files |
487 | */ | 487 | */ |
488 | 488 | ||
489 | //release the Config handler | 489 | //release the Config handler |
490 | pcfg.write(); | 490 | pcfg.write(); |
491 | 491 | ||
492 | QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; | 492 | QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; |
493 | Config loginCfg(configFile,Config::File); | 493 | Config loginCfg(configFile,Config::File); |
494 | loginCfg.setGroup("General"); | 494 | loginCfg.setGroup("General"); |
495 | 495 | ||
496 | if (autoLogin) { | 496 | if (autoLogin) { |
497 | loginCfg.writeEntry("AutoLogin",autoLoginName); | 497 | loginCfg.writeEntry("AutoLogin",autoLoginName); |
498 | } else { | 498 | } else { |
499 | loginCfg.removeEntry("AutoLogin"); | 499 | loginCfg.removeEntry("AutoLogin"); |
500 | } | 500 | } |
501 | 501 | ||
502 | } | 502 | } |
503 | 503 | ||
504 | /// slot used to record the fact plugins order has been modified | 504 | /// slot used to record the fact plugins order has been modified |
505 | void MultiauthConfig::pluginsChanged() { | 505 | void MultiauthConfig::pluginsChanged() { |
506 | m_plugins_changed = true; | 506 | m_plugins_changed = true; |
507 | } | 507 | } |
508 | 508 | ||
509 | /// loads each multiauth plugin | 509 | /// loads each multiauth plugin |
510 | void MultiauthConfig::loadPlugins() { | 510 | void MultiauthConfig::loadPlugins() { |
511 | 511 | ||
512 | QString path = QPEApplication::qpeDir() + "plugins/security"; | 512 | QString path = QPEApplication::qpeDir() + "plugins/security"; |
513 | QDir dir( path, "lib*.so" ); | 513 | QDir dir( path, "lib*.so" ); |
514 | 514 | ||
515 | QStringList list = dir.entryList(); | 515 | QStringList list = dir.entryList(); |
516 | QStringList::Iterator it; | 516 | QStringList::Iterator it; |
517 | 517 | ||
518 | // temporary list used to sort plugins | 518 | // temporary list used to sort plugins |
519 | QMap<QString, MultiauthPlugin> sortList; | 519 | QMap<QString, MultiauthPlugin> sortList; |
520 | 520 | ||
521 | for ( it = list.begin(); it != list.end(); ++it ) { | 521 | for ( it = list.begin(); it != list.end(); ++it ) { |
522 | QInterfacePtr<MultiauthPluginInterface> iface; | 522 | QInterfacePtr<MultiauthPluginInterface> iface; |
523 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 523 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
524 | QString libPath(path + "/" + *it); | 524 | QString libPath(path + "/" + *it); |
525 | 525 | ||
526 | if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 526 | if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
527 | MultiauthPlugin plugin; | 527 | MultiauthPlugin plugin; |
528 | plugin.library = lib; | 528 | plugin.library = lib; |
529 | plugin.iface = iface; | 529 | plugin.iface = iface; |
530 | plugin.name = QString(*it); | 530 | plugin.name = QString(*it); |
531 | 531 | ||
532 | // find out if plugins should be launched | 532 | // find out if plugins should be launched |
533 | if ( m_excludePlugins.grep( *it ).isEmpty() ) { | 533 | if ( m_excludePlugins.grep( *it ).isEmpty() ) { |
534 | plugin.active = true; | 534 | plugin.active = true; |
535 | } else { | 535 | } else { |
536 | plugin.active = false; | 536 | plugin.active = false; |
537 | } | 537 | } |
538 | 538 | ||
539 | plugin.pluginObject = plugin.iface->plugin(); | 539 | plugin.pluginObject = plugin.iface->plugin(); |
540 | 540 | ||
541 | // "prebuffer" it in one more list, to get the sorting done | 541 | // "prebuffer" it in one more list, to get the sorting done |
542 | sortList.insert( plugin.name, plugin ); | 542 | sortList.insert( plugin.name, plugin ); |
543 | 543 | ||
544 | // on first start the list is off course empty | 544 | // on first start the list is off course empty |
545 | if ( m_allPlugins.isEmpty() ) { | 545 | if ( m_allPlugins.isEmpty() ) { |
546 | pluginList.append( plugin ); | 546 | pluginList.append( plugin ); |
547 | } | 547 | } |
548 | // if plugin is not yet in the list, add it to the layout too | 548 | // if plugin is not yet in the list, add it to the layout too |
549 | else if ( !m_allPlugins.contains( plugin.name ) ) { | 549 | else if ( !m_allPlugins.contains( plugin.name ) ) { |
550 | pluginList.append( plugin ); | 550 | pluginList.append( plugin ); |
551 | } | 551 | } |
552 | 552 | ||
553 | } else { | 553 | } else { |
554 | delete lib; | 554 | delete lib; |
555 | } | 555 | } |
556 | 556 | ||
557 | } // end for | 557 | } // end for |
558 | 558 | ||
559 | // put m_allPlugins tempPlugin objects into pluginList | 559 | // put m_allPlugins tempPlugin objects into pluginList |
560 | if ( !m_allPlugins.isEmpty() ) { | 560 | if ( !m_allPlugins.isEmpty() ) { |
561 | MultiauthPlugin tempPlugin; | 561 | MultiauthPlugin tempPlugin; |
562 | QStringList::Iterator stringit; | 562 | QStringList::Iterator stringit; |
563 | for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) { | 563 | for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) { |
564 | tempPlugin = ( sortList.find( *stringit ) ).data(); | 564 | tempPlugin = ( sortList.find( *stringit ) ).data(); |
565 | if ( !( (tempPlugin.name).isEmpty() ) ) { | 565 | if ( !( (tempPlugin.name).isEmpty() ) ) { |
566 | pluginList.append( tempPlugin ); | 566 | pluginList.append( tempPlugin ); |
567 | } | 567 | } |
568 | } | 568 | } |
569 | } | 569 | } |
570 | 570 | ||
571 | } | 571 | } |
572 | 572 | ||
573 | void MultiauthConfig::deleteListEntry() | 573 | void MultiauthConfig::deleteListEntry() |
574 | { | 574 | { |
575 | m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem()); | 575 | m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem()); |
576 | } | 576 | } |
577 | 577 | ||
578 | void MultiauthConfig::restoreDefaults() | 578 | void MultiauthConfig::restoreDefaults() |
579 | { | 579 | { |
580 | QMessageBox unrecbox( | 580 | QMessageBox unrecbox( |
581 | tr("Attention"), | 581 | tr("Attention"), |
582 | "<p>" + tr("All user-defined net ranges will be lost.") + "</p>", | 582 | "<p>" + tr("All user-defined net ranges will be lost.") + "</p>", |
583 | QMessageBox::Warning, | 583 | QMessageBox::Warning, |
584 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, | 584 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, |
585 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 585 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
586 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); | 586 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); |
587 | unrecbox.setButtonText(QMessageBox::Yes, tr("OK")); | 587 | unrecbox.setButtonText(QMessageBox::Yes, tr("OK")); |
588 | 588 | ||
589 | if ( unrecbox.exec() == QMessageBox::Yes) | 589 | if ( unrecbox.exec() == QMessageBox::Yes) |
590 | { | 590 | { |
591 | m_syncWidget->syncnet->clear(); | 591 | m_syncWidget->syncnet->clear(); |
592 | insertDefaultRanges(); | 592 | insertDefaultRanges(); |
593 | } | 593 | } |
594 | m_syncWidget->syncModeCombo->setCurrentItem( 2 ); | 594 | m_syncWidget->syncModeCombo->setCurrentItem( 2 ); |
595 | } | 595 | } |
596 | 596 | ||
597 | void MultiauthConfig::insertDefaultRanges() | 597 | void MultiauthConfig::insertDefaultRanges() |
598 | { | 598 | { |
599 | m_syncWidget->syncnet->insertItem( "192.168.129.0/24" ); | 599 | m_syncWidget->syncnet->insertItem( "192.168.129.0/24" ); |
600 | m_syncWidget->syncnet->insertItem( "192.168.1.0/24" ); | 600 | m_syncWidget->syncnet->insertItem( "192.168.1.0/24" ); |
601 | m_syncWidget->syncnet->insertItem( "192.168.0.0/16" ); | 601 | m_syncWidget->syncnet->insertItem( "192.168.0.0/16" ); |
602 | m_syncWidget->syncnet->insertItem( "172.16.0.0/12" ); | 602 | m_syncWidget->syncnet->insertItem( "172.16.0.0/12" ); |
603 | m_syncWidget->syncnet->insertItem( "10.0.0.0/8" ); | 603 | m_syncWidget->syncnet->insertItem( "10.0.0.0/8" ); |
604 | m_syncWidget->syncnet->insertItem( "1.0.0.0/8" ); | 604 | m_syncWidget->syncnet->insertItem( "1.0.0.0/8" ); |
605 | m_syncWidget->syncnet->insertItem( tr( "Any" ) ); | 605 | m_syncWidget->syncnet->insertItem( tr( "Any" ) ); |
606 | m_syncWidget->syncnet->insertItem( tr( "None" ) ); | 606 | m_syncWidget->syncnet->insertItem( tr( "None" ) ); |
607 | } | 607 | } |
608 | 608 | ||
609 | void MultiauthConfig::updateGUI() | 609 | void MultiauthConfig::updateGUI() |
610 | { | 610 | { |
611 | m_loginWidget->autologinToggle->setChecked(autoLogin); | 611 | m_loginWidget->autologinToggle->setChecked(autoLogin); |
612 | m_loginWidget->userlist->setEnabled(autoLogin); | 612 | m_loginWidget->userlist->setEnabled(autoLogin); |
613 | } | 613 | } |
614 | 614 | ||
615 | void MultiauthConfig::selectNet(int auth_peer,int auth_peer_bits, bool update) | 615 | void MultiauthConfig::selectNet(int auth_peer,int auth_peer_bits, bool update) |
616 | { | 616 | { |
617 | QString sn; | 617 | QString sn; |
618 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { | 618 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { |
619 | sn = tr("Any"); | 619 | sn = tr("Any"); |
620 | } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { | 620 | } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { |
621 | sn = tr("None"); | 621 | sn = tr("None"); |
622 | } else { | 622 | } else { |
623 | sn = | 623 | sn = |
624 | QString::number((auth_peer>>24)&0xff) + "." | 624 | QString::number((auth_peer>>24)&0xff) + "." |
625 | + QString::number((auth_peer>>16)&0xff) + "." | 625 | + QString::number((auth_peer>>16)&0xff) + "." |
626 | + QString::number((auth_peer>>8)&0xff) + "." | 626 | + QString::number((auth_peer>>8)&0xff) + "." |
627 | + QString::number((auth_peer>>0)&0xff) + "/" | 627 | + QString::number((auth_peer>>0)&0xff) + "/" |
628 | + QString::number(auth_peer_bits); | 628 | + QString::number(auth_peer_bits); |
629 | } | 629 | } |
630 | 630 | ||
631 | //insert user-defined list of netranges upon start | 631 | //insert user-defined list of netranges upon start |
632 | if (update) { | 632 | if (update) { |
633 | //User selected/active netrange first | 633 | //User selected/active netrange first |
634 | m_syncWidget->syncnet->insertItem( tr(sn) ); | 634 | m_syncWidget->syncnet->insertItem( tr(sn) ); |
635 | Config cfg("Security"); | 635 | Config cfg("Security"); |
636 | cfg.setGroup("Sync"); | 636 | cfg.setGroup("Sync"); |
637 | 637 | ||
638 | //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe | 638 | //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe |
639 | QString test = cfg.readEntry("net0",""); | 639 | QString test = cfg.readEntry("net0",""); |
640 | if (test.isEmpty()) { | 640 | if (test.isEmpty()) { |
641 | insertDefaultRanges(); | 641 | insertDefaultRanges(); |
642 | } else { | 642 | } else { |
643 | // 10 ought to be enough for everybody... :) | 643 | // 10 ought to be enough for everybody... :) |
644 | // If you need more, don't forget to edit applySecurity() as well | 644 | // If you need more, don't forget to edit applySecurity() as well |
645 | bool already_there=FALSE; | 645 | bool already_there=FALSE; |
646 | for (int i=0; i<10; i++) { | 646 | for (int i=0; i<10; i++) { |
647 | QString target, netrange; | 647 | QString target, netrange; |
648 | target.sprintf("net%d", i); | 648 | target.sprintf("net%d", i); |
649 | netrange = cfg.readEntry(target,""); | 649 | netrange = cfg.readEntry(target,""); |
650 | if (! netrange.isEmpty()){ | 650 | if (! netrange.isEmpty()){ |
651 | //make sure we have no "twin" entries | 651 | //make sure we have no "twin" entries |
652 | for (int i=0; i<m_syncWidget->syncnet->count(); i++) { | 652 | for (int i=0; i<m_syncWidget->syncnet->count(); i++) { |
653 | if ( m_syncWidget->syncnet->text(i) == netrange ) { | 653 | if ( m_syncWidget->syncnet->text(i) == netrange ) { |
654 | already_there=TRUE; | 654 | already_there=TRUE; |
655 | } | 655 | } |
656 | } | 656 | } |
657 | if (! already_there) { | 657 | if (! already_there) { |
658 | m_syncWidget->syncnet->insertItem( netrange ); | 658 | m_syncWidget->syncnet->insertItem( netrange ); |
659 | } else { | 659 | } else { |
660 | already_there=FALSE; | 660 | already_there=FALSE; |
661 | } | 661 | } |
662 | } | 662 | } |
663 | } | 663 | } |
664 | } | 664 | } |
665 | } | 665 | } |
666 | 666 | ||