summaryrefslogtreecommitdiff
authorzecke <zecke>2004-07-17 20:29:06 (UTC)
committer zecke <zecke>2004-07-17 20:29:06 (UTC)
commit872d24ff104d9ea9a7ea8ef68c8b3f98531ed677 (patch) (unidiff)
treec889395e77601bdebe3ba21b5230640501c7e083
parentd68baedc489a7ab4ab1419144608d28d5336a884 (diff)
downloadopie-872d24ff104d9ea9a7ea8ef68c8b3f98531ed677.zip
opie-872d24ff104d9ea9a7ea8ef68c8b3f98531ed677.tar.gz
opie-872d24ff104d9ea9a7ea8ef68c8b3f98531ed677.tar.bz2
Be less verbose
clean ups
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/security/main.cpp4
-rw-r--r--core/settings/security/multiauthconfig.cpp6
-rw-r--r--noncore/securityplugins/blueping/bluepingplugin.cpp3
-rw-r--r--noncore/securityplugins/notice/noticeConfigWidget.cpp4
-rw-r--r--noncore/securityplugins/notice/noticeConfigWidget.h4
-rw-r--r--noncore/securityplugins/notice/noticeplugin.cpp2
6 files changed, 7 insertions, 16 deletions
diff --git a/core/settings/security/main.cpp b/core/settings/security/main.cpp
index f161109..7f24490 100644
--- a/core/settings/security/main.cpp
+++ b/core/settings/security/main.cpp
@@ -1,46 +1,44 @@
1#include "multiauthconfig.h" 1#include "multiauthconfig.h"
2#include <opie2/oapplication.h> 2#include <opie2/oapplication.h>
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4 4
5 5
6 6
7int main(int argc, char **argv) { 7int main(int argc, char **argv) {
8 Opie::Core::OApplication app(argc, argv, "MultiAuthentication Config"); 8 Opie::Core::OApplication app(argc, argv, "MultiAuthentication Config");
9 // protect this dialog if option set 9 // protect this dialog if option set
10 Config* pcfg = new Config("Security"); 10 Config* pcfg = new Config("Security");
11 pcfg->setGroup( "Misc" ); 11 pcfg->setGroup( "Misc" );
12 bool protectConfigDialog = ! pcfg->readBoolEntry("noProtectConfig", true); 12 bool protectConfigDialog = ! pcfg->readBoolEntry("noProtectConfig", true);
13 delete pcfg; 13 delete pcfg;
14 bool show = true; 14 bool show = true;
15 if ( protectConfigDialog ) 15 if ( protectConfigDialog )
16 { 16 {
17 if (Opie::Security::Internal::runPlugins() != 0) 17 if (Opie::Security::Internal::runPlugins() != 0)
18 { 18 {
19 // authentication failed 19 // authentication failed
20 show = false; 20 show = false;
21 } 21 }
22 } 22 }
23 if ( show == true ) 23 if ( show == true ){
24 {
25 printf("building dialog\n");
26 MultiauthConfig dialog; 24 MultiauthConfig dialog;
27 app.setMainWidget(&dialog); 25 app.setMainWidget(&dialog);
28 26
29 if ( dialog.exec() == QDialog::Accepted ) { 27 if ( dialog.exec() == QDialog::Accepted ) {
30 // write the general, login and sync config 28 // write the general, login and sync config
31 dialog.writeConfig(); 29 dialog.writeConfig();
32 // call writeConfig() on each plugin config widget 30 // call writeConfig() on each plugin config widget
33 Opie::Security::MultiauthConfigWidget *confWidget; 31 Opie::Security::MultiauthConfigWidget *confWidget;
34 for ( confWidget = dialog.configWidgetList.first(); confWidget != 0; 32 for ( confWidget = dialog.configWidgetList.first(); confWidget != 0;
35 confWidget = dialog.configWidgetList.next() ) { 33 confWidget = dialog.configWidgetList.next() ) {
36 confWidget->writeConfig(); 34 confWidget->writeConfig();
37 } 35 }
38 } 36 }
39 dialog.close(); 37 dialog.close();
40 app.quit(); 38 app.quit();
41 return 0; 39 return 0;
42 } else { 40 } else {
43 owarn << "authentication failed, not showing opie-security" << oendl; 41 owarn << "authentication failed, not showing opie-security" << oendl;
44 return 1; 42 return 1;
45 } 43 }
46} 44}
diff --git a/core/settings/security/multiauthconfig.cpp b/core/settings/security/multiauthconfig.cpp
index 0ce4542..93e73c3 100644
--- a/core/settings/security/multiauthconfig.cpp
+++ b/core/settings/security/multiauthconfig.cpp
@@ -1,665 +1,659 @@
1#include "multiauthconfig.h" 1#include "multiauthconfig.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4 4
5#include <qgroupbox.h> 5#include <qgroupbox.h>
6#include <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 19
20using Opie::Security::MultiauthPluginInterface; 20using Opie::Security::MultiauthPluginInterface;
21using Opie::Security::MultiauthPluginObject; 21using Opie::Security::MultiauthPluginObject;
22using Opie::Security::MultiauthConfigWidget; 22using Opie::Security::MultiauthConfigWidget;
23/// keeps information about MultiauthPluginObject plugins 23/// keeps information about MultiauthPluginObject plugins
24struct MultiauthPlugin { 24struct MultiauthPlugin {
25 MultiauthPlugin() : library( 0 ), iface( 0 ), pluginObject( 0 ) {} 25 MultiauthPlugin() : library( 0 ), iface( 0 ), pluginObject( 0 ) {}
26 /// plugin file 26 /// plugin file
27 QLibrary *library; 27 QLibrary *library;
28 /// the plugin object interface 28 /// the plugin object interface
29 QInterfacePtr<MultiauthPluginInterface> iface; 29 QInterfacePtr<MultiauthPluginInterface> iface;
30 /// the plugin object itself 30 /// the plugin object itself
31 MultiauthPluginObject *pluginObject; 31 MultiauthPluginObject *pluginObject;
32 /// name of the plugin file 32 /// name of the plugin file
33 QString name; 33 QString name;
34 /// should the plugin be launched during authentication or not 34 /// should the plugin be launched during authentication or not
35 bool active; 35 bool active;
36 /// order of the plugin, in the pluginListWidget and during authentication 36 /// order of the plugin, in the pluginListWidget and during authentication
37 int pos; 37 int pos;
38}; 38};
39 39
40/// list of available MultiauthPlugin objects 40/// list of available MultiauthPlugin objects
41static QValueList<MultiauthPlugin> pluginList; 41static QValueList<MultiauthPlugin> pluginList;
42 42
43 43
44/// extension of QToolButton that adds signals, icons and stuff (taken from todayconfig.cpp) 44/// extension of QToolButton that adds signals, icons and stuff (taken from todayconfig.cpp)
45class ToolButton : public QToolButton { 45class ToolButton : public QToolButton {
46 46
47 public: 47 public:
48 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 48 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
49 : QToolButton( parent, name ) { 49 : QToolButton( parent, name ) {
50 setPixmap( Resource::loadPixmap( icon ) ); 50 setPixmap( Resource::loadPixmap( icon ) );
51 setAutoRaise( TRUE ); 51 setAutoRaise( TRUE );
52 setFocusPolicy( QWidget::NoFocus ); 52 setFocusPolicy( QWidget::NoFocus );
53 setToggleButton( t ); 53 setToggleButton( t );
54 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 54 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
55 } 55 }
56}; 56};
57 57
58MultiauthGeneralConfig::MultiauthGeneralConfig(QWidget * parent, const char * name = "general Opie-multiauthentication config widget") 58MultiauthGeneralConfig::MultiauthGeneralConfig(QWidget * parent, const char * name = "general Opie-multiauthentication config widget")
59 : QWidget(parent, name), onStart(0), onResume(0), nbSuccessMin(0) 59 : QWidget(parent, name), onStart(0), onResume(0), nbSuccessMin(0)
60{ 60{
61 QVBoxLayout *vb = new QVBoxLayout(this); 61 QVBoxLayout *vb = new QVBoxLayout(this);
62 vb->setSpacing(11); 62 vb->setSpacing(11);
63 vb->setMargin(11); 63 vb->setMargin(11);
64 vb->setAlignment( Qt::AlignTop ); 64 vb->setAlignment( Qt::AlignTop );
65 65
66 QGroupBox *lockBox = new QGroupBox(0, Qt::Vertical, tr("When to lock Opie"), this, "lock box"); 66 QGroupBox *lockBox = new QGroupBox(0, Qt::Vertical, tr("When to lock Opie"), this, "lock box");
67 vb->addWidget(lockBox); 67 vb->addWidget(lockBox);
68 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() ); 68 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() );
69 onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start"); 69 onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start");
70 onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume"); 70 onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume");
71 boxLayout->addWidget(onStart, 0, 0); 71 boxLayout->addWidget(onStart, 0, 0);
72 boxLayout->addWidget(onResume, 0, 1); 72 boxLayout->addWidget(onResume, 0, 1);
73 73
74 QGroupBox *nbBox = new QGroupBox(0, Qt::Vertical, tr("Multiple plugins authentication"), this, "nb box"); 74 QGroupBox *nbBox = new QGroupBox(0, Qt::Vertical, tr("Multiple plugins authentication"), this, "nb box");
75 vb->addWidget(nbBox); 75 vb->addWidget(nbBox);
76 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() ); 76 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() );
77 nbSuccessMin = new QSpinBox(nbBox); 77 nbSuccessMin = new QSpinBox(nbBox);
78 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox); 78 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox);
79 nbBoxLayout->addWidget(nbSuccessMin, 0, 0); 79 nbBoxLayout->addWidget(nbSuccessMin, 0, 0);
80 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1); 80 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1);
81 nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor 81 nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor
82 82
83 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Debug options"), this, "dev box"); 83 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Debug options"), this, "dev box");
84 vb->addWidget(devBox); 84 vb->addWidget(devBox);
85 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() ); 85 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() );
86 noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config"); 86 noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config");
87 explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens"); 87 explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens");
88 allowBypass = new QCheckBox( tr("Allow to bypass authentication"), devBox, "AllowBypass"); 88 allowBypass = new QCheckBox( tr("Allow to bypass authentication"), devBox, "AllowBypass");
89 QLabel *logicNote = new QLabel( "<p>" + tr("Note: the third option implies the second one") + "</p>", devBox ); 89 QLabel *logicNote = new QLabel( "<p>" + tr("Note: the third option implies the second one") + "</p>", devBox );
90 devBoxLayout->addWidget(noProtectConfig, 0, 0); 90 devBoxLayout->addWidget(noProtectConfig, 0, 0);
91 devBoxLayout->addWidget(explanScreens, 1, 0); 91 devBoxLayout->addWidget(explanScreens, 1, 0);
92 devBoxLayout->addWidget(allowBypass, 2, 0); 92 devBoxLayout->addWidget(allowBypass, 2, 0);
93 devBoxLayout->addMultiCellWidget(logicNote, 3, 3, 0, 1); 93 devBoxLayout->addMultiCellWidget(logicNote, 3, 3, 0, 1);
94 94
95 connect( explanScreens, SIGNAL(toggled(bool)), this, SLOT(checkBypass()) ); 95 connect( explanScreens, SIGNAL(toggled(bool)), this, SLOT(checkBypass()) );
96 connect( allowBypass, SIGNAL(toggled(bool)), this, SLOT(checkScreens()) ); 96 connect( allowBypass, SIGNAL(toggled(bool)), this, SLOT(checkScreens()) );
97} 97}
98 98
99/// nothing to do 99/// nothing to do
100MultiauthGeneralConfig::~MultiauthGeneralConfig() 100MultiauthGeneralConfig::~MultiauthGeneralConfig()
101{} 101{}
102 102
103/// Be sure that explanScreens is checked if allowBypass is 103/// Be sure that explanScreens is checked if allowBypass is
104void MultiauthGeneralConfig::checkScreens() 104void MultiauthGeneralConfig::checkScreens()
105{ 105{
106 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) ) 106 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) )
107 explanScreens->setChecked(true); 107 explanScreens->setChecked(true);
108} 108}
109 109
110/// Be sure that allowBypass is not checked if explanScreens is not 110/// Be sure that allowBypass is not checked if explanScreens is not
111void MultiauthGeneralConfig::checkBypass() 111void MultiauthGeneralConfig::checkBypass()
112{ 112{
113 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) ) 113 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) )
114 allowBypass->setChecked(false); 114 allowBypass->setChecked(false);
115} 115}
116 116
117/// Builds and displays the Opie multi-authentication configuration dialog 117/// Builds and displays the Opie multi-authentication configuration dialog
118MultiauthConfig::MultiauthConfig() : QDialog(0, 0, TRUE), 118MultiauthConfig::MultiauthConfig() : QDialog(0, 0, TRUE),
119 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0), 119 m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0),
120 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0), 120 m_generalConfig(0), m_loginWidget(0), m_syncWidget(0),
121 m_nbSuccessReq(0), m_plugins_changed(false) 121 m_nbSuccessReq(0), m_plugins_changed(false)
122{ 122{
123 /* Initializes the global configuration window 123 /* Initializes the global configuration window
124 */ 124 */
125 setCaption( tr( "Security configuration" ) ); 125 setCaption( tr( "Security configuration" ) );
126 QVBoxLayout *layout = new QVBoxLayout( this ); 126 QVBoxLayout *layout = new QVBoxLayout( this );
127 m_mainTW = new Opie::Ui::OTabWidget( this ); 127 m_mainTW = new Opie::Ui::OTabWidget( this );
128 layout->addWidget(m_mainTW); 128 layout->addWidget(m_mainTW);
129 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget"); 129 m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget");
130 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); 130 QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget);
131 pluginListLayout->setSpacing(6); 131 pluginListLayout->setSpacing(6);
132 pluginListLayout->setMargin(11); 132 pluginListLayout->setMargin(11);
133 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget ); 133 QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget );
134 pluginListLayout->addWidget(pluginListTitle); 134 pluginListLayout->addWidget(pluginListTitle);
135 QHBox * pluginListHB = new QHBox(m_pluginListWidget); 135 QHBox * pluginListHB = new QHBox(m_pluginListWidget);
136 pluginListLayout->addWidget(pluginListHB); 136 pluginListLayout->addWidget(pluginListHB);
137 137
138 m_pluginListView = new QListView(pluginListHB); 138 m_pluginListView = new QListView(pluginListHB);
139 m_pluginListView->addColumn("PluginList"); 139 m_pluginListView->addColumn("PluginList");
140 m_pluginListView->header()->hide(); 140 m_pluginListView->header()->hide();
141 m_pluginListView->setSorting(-1); 141 m_pluginListView->setSorting(-1);
142 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" )); 142 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" ));
143 143
144 QVBox * pluginListVB = new QVBox(pluginListHB); 144 QVBox * pluginListVB = new QVBox(pluginListHB);
145 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); 145 new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
146 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); 146 new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
147 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) ); 147 m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) );
148 148
149 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) ); 149 connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) );
150 150
151 // general Opie multi-authentication configuration tab 151 // general Opie multi-authentication configuration tab
152 m_generalConfig = new MultiauthGeneralConfig(m_mainTW); 152 m_generalConfig = new MultiauthGeneralConfig(m_mainTW);
153 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") ); 153 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") );
154 154
155 // login settings page 155 // login settings page
156 m_loginWidget = new LoginBase(m_mainTW, "login config widget"); 156 m_loginWidget = new LoginBase(m_mainTW, "login config widget");
157 m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") ); 157 m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") );
158 158
159 // sync settings page 159 // sync settings page
160 m_syncWidget = new SyncBase( m_mainTW, "sync config widget" ); 160 m_syncWidget = new SyncBase( m_mainTW, "sync config widget" );
161 m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") ); 161 m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") );
162 162
163 // read the "Security" Config file and update our UI 163 // read the "Security" Config file and update our UI
164 readConfig(); 164 readConfig();
165 165
166 /* loads plugins configuration widgets in mainTW tabs and in pluginListView 166 /* loads plugins configuration widgets in mainTW tabs and in pluginListView
167 */ 167 */
168 168
169 loadPlugins(); 169 loadPlugins();
170 170
171 for ( int i = pluginList.count() - 1; i >= 0; i-- ) { 171 for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
172 MultiauthPlugin plugin = pluginList[i]; 172 MultiauthPlugin plugin = pluginList[i];
173 173
174 // load the config widgets in the tabs 174 // load the config widgets in the tabs
175 // (configWidget will return 0l if there is no configuration GUI) 175 // (configWidget will return 0l if there is no configuration GUI)
176 MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW); 176 MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW);
177 if ( widget != 0l ) { 177 if ( widget != 0l ) {
178 odebug << "plugin " << plugin.name << " has a configuration widget" << oendl; 178 odebug << "plugin " << plugin.name << " has a configuration widget" << oendl;
179 configWidgetList.append(widget); 179 configWidgetList.append(widget);
180 m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(), 180 m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(),
181 plugin.pluginObject->pluginName() ); 181 plugin.pluginObject->pluginName() );
182 } 182 }
183 // set the order/activate tab 183 // set the order/activate tab
184 QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() ); 184 QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() );
185 QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox ); 185 QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox );
186 if ( !icon.isNull() ) { 186 if ( !icon.isNull() ) {
187 item->setPixmap( 0, icon ); 187 item->setPixmap( 0, icon );
188 } 188 }
189 if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) { 189 if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) {
190 item->setOn( TRUE ); 190 item->setOn( TRUE );
191 } 191 }
192 m_plugins[plugin.name] = item; 192 m_plugins[plugin.name] = item;
193 } 193 }
194 194
195 // set the first tab as default. 195 // set the first tab as default.
196 m_mainTW->setCurrentTab(m_pluginListWidget); 196 m_mainTW->setCurrentTab(m_pluginListWidget);
197 197
198 // put the number of plugins as the max number of req. auth. 198 // put the number of plugins as the max number of req. auth.
199 m_generalConfig->nbSuccessMin->setMaxValue( pluginList.count() ); 199 m_generalConfig->nbSuccessMin->setMaxValue( pluginList.count() );
200 200
201 showMaximized(); 201 showMaximized();
202} 202}
203 203
204/// nothing to do 204/// nothing to do
205MultiauthConfig::~MultiauthConfig() 205MultiauthConfig::~MultiauthConfig()
206{ 206{
207} 207}
208 208
209/// moves up the selected plugin 209/// moves up the selected plugin
210void MultiauthConfig::moveSelectedUp() 210void MultiauthConfig::moveSelectedUp()
211{ 211{
212 QListViewItem *item = m_pluginListView->selectedItem(); 212 QListViewItem *item = m_pluginListView->selectedItem();
213 if ( item && item->itemAbove() ) { 213 if ( item && item->itemAbove() ) {
214 item->itemAbove()->moveItem( item ); 214 item->itemAbove()->moveItem( item );
215 } 215 }
216} 216}
217 217
218/// moves down the selected plugin 218/// moves down the selected plugin
219void MultiauthConfig::moveSelectedDown() 219void MultiauthConfig::moveSelectedDown()
220{ 220{
221 QListViewItem *item = m_pluginListView->selectedItem(); 221 QListViewItem *item = m_pluginListView->selectedItem();
222 if ( item && item->itemBelow() ) { 222 if ( item && item->itemBelow() ) {
223 item->moveItem( item->itemBelow() ); 223 item->moveItem( item->itemBelow() );
224 } 224 }
225} 225}
226 226
227/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface 227/// reads the <code>Security.conf</code> Config file, and updates parts of the user interface
228void MultiauthConfig::readConfig() 228void MultiauthConfig::readConfig()
229{ 229{
230 // pointer, so we release this Config when we want 230 // pointer, so we release this Config when we want
231 Config* pcfg = new Config("Security"); 231 Config* pcfg = new Config("Security");
232 pcfg->setGroup( "Misc" ); 232 pcfg->setGroup( "Misc" );
233 m_generalConfig->onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); 233 m_generalConfig->onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) );
234 m_generalConfig->onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); 234 m_generalConfig->onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) );
235 m_generalConfig->nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); 235 m_generalConfig->nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) );
236 m_generalConfig->noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); 236 m_generalConfig->noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) );
237 m_generalConfig->explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); 237 m_generalConfig->explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) );
238 m_generalConfig->allowBypass->setChecked( pcfg->readBoolEntry( "allowBypass", false ) ); 238 m_generalConfig->allowBypass->setChecked( pcfg->readBoolEntry( "allowBypass", false ) );
239 239
240 pcfg->setGroup( "Plugins" ); 240 pcfg->setGroup( "Plugins" );
241 m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' ); 241 m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' );
242 m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' ); 242 m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' );
243 243
244 /* Login and Sync stuff */ 244 /* Login and Sync stuff */
245 pcfg->setGroup("Sync"); 245 pcfg->setGroup("Sync");
246 int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 246 int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24
247 int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24); 247 int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24);
248 248
249 pcfg->setGroup("SyncMode"); 249 pcfg->setGroup("SyncMode");
250 int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp 250 int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp
251 switch( mode ) { 251 switch( mode ) {
252 case 0x01: 252 case 0x01:
253 m_syncWidget->syncModeCombo->setCurrentItem( 0 ); 253 m_syncWidget->syncModeCombo->setCurrentItem( 0 );
254 break; 254 break;
255 case 0x02: 255 case 0x02:
256 default: 256 default:
257 m_syncWidget->syncModeCombo->setCurrentItem( 1 ); 257 m_syncWidget->syncModeCombo->setCurrentItem( 1 );
258 break; 258 break;
259 case 0x04: 259 case 0x04:
260 m_syncWidget->syncModeCombo->setCurrentItem( 2 ); 260 m_syncWidget->syncModeCombo->setCurrentItem( 2 );
261 break; 261 break;
262 } 262 }
263 /* 263 /*
264 cfg.setGroup("Remote"); 264 cfg.setGroup("Remote");
265 if ( telnetAvailable() ) 265 if ( telnetAvailable() )
266 telnet->setChecked(cfg.readEntry("allow_telnet")); 266 telnet->setChecked(cfg.readEntry("allow_telnet"));
267 else 267 else
268 telnet->hide(); 268 telnet->hide();
269 269
270 if ( sshAvailable() ) 270 if ( sshAvailable() )
271 ssh->setChecked(cfg.readEntry("allow_ssh")); 271 ssh->setChecked(cfg.readEntry("allow_ssh"));
272 else 272 else
273 ssh->hide(); 273 ssh->hide();
274 */ 274 */
275 275
276 // release the Config handler 276 // release the Config handler
277 delete pcfg; 277 delete pcfg;
278 // indeed, selectNet will open the config file... 278 // indeed, selectNet will open the config file...
279 selectNet(auth_peer,auth_peer_bits,TRUE); 279 selectNet(auth_peer,auth_peer_bits,TRUE);
280 280
281 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), 281 connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)),
282 this, SLOT(setSyncNet(const QString&))); 282 this, SLOT(setSyncNet(const QString&)));
283 283
284 284
285 285
286 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 286 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
287 Config loginCfg(configFile,Config::File); 287 Config loginCfg(configFile,Config::File);
288 288
289 loginCfg.setGroup("General"); 289 loginCfg.setGroup("General");
290 autoLoginName=loginCfg.readEntry("AutoLogin",""); 290 autoLoginName=loginCfg.readEntry("AutoLogin","");
291 291
292 if (autoLoginName.stripWhiteSpace().isEmpty()) { 292 if (autoLoginName.stripWhiteSpace().isEmpty()) {
293 autoLogin=false; 293 autoLogin=false;
294 } else { 294 } else {
295 autoLogin=true; 295 autoLogin=true;
296 } 296 }
297 297
298 298
299 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); 299 connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool)));
300 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); 300 connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int)));
301 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); 301 connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults()));
302 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); 302 connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry()));
303 303
304 loadUsers(); 304 loadUsers();
305 updateGUI(); 305 updateGUI();
306 306
307} 307}
308 308
309void MultiauthConfig::writeConfig() 309void MultiauthConfig::writeConfig()
310{ 310{
311 Config* pcfg = new Config("Security"); 311 Config* pcfg = new Config("Security");
312 pcfg->setGroup( "Plugins" ); 312 pcfg->setGroup( "Plugins" );
313 QStringList exclude; 313 QStringList exclude;
314 QStringList include; 314 QStringList include;
315 QStringList allPlugins; 315 QStringList allPlugins;
316 316
317 QListViewItemIterator list_it( m_pluginListView ); 317 QListViewItemIterator list_it( m_pluginListView );
318 318
319 // this makes sure the names get saved in the order selected 319 // this makes sure the names get saved in the order selected
320 for ( ; list_it.current(); ++list_it ) { 320 for ( ; list_it.current(); ++list_it ) {
321 QMap <QString, QCheckListItem *>::Iterator it; 321 QMap <QString, QCheckListItem *>::Iterator it;
322 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { 322 for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) {
323 if ( list_it.current() == (*it) && !(*it)-> isOn () ) { 323 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
324 exclude << it.key(); 324 exclude << it.key();
325 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ 325 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
326 include << it.key(); 326 include << it.key();
327 } 327 }
328 if ( list_it.current() == (*it) ) { 328 if ( list_it.current() == (*it) ) {
329 allPlugins << it.key(); 329 allPlugins << it.key();
330 } 330 }
331 } 331 }
332 } 332 }
333 pcfg->writeEntry( "ExcludePlugins", exclude, ',' ); 333 pcfg->writeEntry( "ExcludePlugins", exclude, ',' );
334 pcfg->writeEntry( "IncludePlugins", include, ',' ); 334 pcfg->writeEntry( "IncludePlugins", include, ',' );
335 pcfg->writeEntry( "AllPlugins", allPlugins, ',' ); 335 pcfg->writeEntry( "AllPlugins", allPlugins, ',' );
336 336
337 pcfg->setGroup( "Misc" ); 337 pcfg->setGroup( "Misc" );
338 pcfg->writeEntry( "onStart", m_generalConfig->onStart->isChecked() ); 338 pcfg->writeEntry( "onStart", m_generalConfig->onStart->isChecked() );
339 pcfg->writeEntry( "onResume", m_generalConfig->onResume->isChecked() ); 339 pcfg->writeEntry( "onResume", m_generalConfig->onResume->isChecked() );
340 pcfg->writeEntry( "nbSuccessMin", m_generalConfig->nbSuccessMin->text() ); 340 pcfg->writeEntry( "nbSuccessMin", m_generalConfig->nbSuccessMin->text() );
341 pcfg->writeEntry( "noProtectConfig", m_generalConfig->noProtectConfig->isChecked() ); 341 pcfg->writeEntry( "noProtectConfig", m_generalConfig->noProtectConfig->isChecked() );
342 pcfg->writeEntry( "explanScreens", m_generalConfig->explanScreens->isChecked() ); 342 pcfg->writeEntry( "explanScreens", m_generalConfig->explanScreens->isChecked() );
343 pcfg->writeEntry( "allowBypass", m_generalConfig->allowBypass->isChecked() ); 343 pcfg->writeEntry( "allowBypass", m_generalConfig->allowBypass->isChecked() );
344 344
345 /* Login and Sync stuff */ 345 /* Login and Sync stuff */
346 346
347 pcfg->setGroup("Sync"); 347 pcfg->setGroup("Sync");
348 int auth_peer=0; 348 int auth_peer=0;
349 int auth_peer_bits; 349 int auth_peer_bits;
350 QString sn = m_syncWidget->syncnet->currentText(); 350 QString sn = m_syncWidget->syncnet->currentText();
351 parseNet(sn,auth_peer,auth_peer_bits); 351 parseNet(sn,auth_peer,auth_peer_bits);
352 352
353 //this is the *selected* (active) net range 353 //this is the *selected* (active) net range
354 pcfg->writeEntry("auth_peer",auth_peer); 354 pcfg->writeEntry("auth_peer",auth_peer);
355 pcfg->writeEntry("auth_peer_bits",auth_peer_bits); 355 pcfg->writeEntry("auth_peer_bits",auth_peer_bits);
356 356
357 //write back all other net ranges in *cleartext* 357 //write back all other net ranges in *cleartext*
358 for (int i=0; i<10; i++) { 358 for (int i=0; i<10; i++) {
359 QString target; 359 QString target;
360 target.sprintf("net%d", i); 360 target.sprintf("net%d", i);
361 pcfg->writeEntry(target,m_syncWidget->syncnet->text(i)); 361 pcfg->writeEntry(target,m_syncWidget->syncnet->text(i));
362 } 362 }
363 363
364#ifdef ODP 364#ifdef ODP
365#error "Use 0,1,2 and use Launcher" 365#error "Use 0,1,2 and use Launcher"
366#endif 366#endif
367 /* keep the old code so we don't use currentItem directly */ 367 /* keep the old code so we don't use currentItem directly */
368 int value = 0x02; 368 int value = 0x02;
369 switch( m_syncWidget->syncModeCombo->currentItem() ) { 369 switch( m_syncWidget->syncModeCombo->currentItem() ) {
370 case 0: 370 case 0:
371 value = 0x01; 371 value = 0x01;
372 break; 372 break;
373 case 1: 373 case 1:
374 value = 0x02; 374 value = 0x02;
375 break; 375 break;
376 case 2: 376 case 2:
377 value = 0x04; 377 value = 0x04;
378 break; 378 break;
379 } 379 }
380 pcfg->setGroup("SyncMode"); 380 pcfg->setGroup("SyncMode");
381 pcfg->writeEntry( "Mode", value ); 381 pcfg->writeEntry( "Mode", value );
382 382
383 /* 383 /*
384 pcfg->setGroup("Remote"); 384 pcfg->setGroup("Remote");
385 if ( telnetAvailable() ) 385 if ( telnetAvailable() )
386 pcfg->writeEntry("allow_telnet",telnet->isChecked()); 386 pcfg->writeEntry("allow_telnet",telnet->isChecked());
387 if ( sshAvailable() ) 387 if ( sshAvailable() )
388 pcfg->writeEntry("allow_ssh",ssh->isChecked()); 388 pcfg->writeEntry("allow_ssh",ssh->isChecked());
389 // ### write ssh/telnet sys config files 389 // ### write ssh/telnet sys config files
390 */ 390 */
391 391
392 //release the Config handler 392 //release the Config handler
393 delete pcfg; 393 delete pcfg;
394 394
395 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 395 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
396 Config loginCfg(configFile,Config::File); 396 Config loginCfg(configFile,Config::File);
397 loginCfg.setGroup("General"); 397 loginCfg.setGroup("General");
398 398
399 if (autoLogin) { 399 if (autoLogin) {
400 loginCfg.writeEntry("AutoLogin",autoLoginName); 400 loginCfg.writeEntry("AutoLogin",autoLoginName);
401 } else { 401 } else {
402 loginCfg.removeEntry("AutoLogin"); 402 loginCfg.removeEntry("AutoLogin");
403 } 403 }
404 404
405} 405}
406 406
407/// slot used to record the fact plugins order has been modified 407/// slot used to record the fact plugins order has been modified
408void MultiauthConfig::pluginsChanged() { 408void MultiauthConfig::pluginsChanged() {
409 m_plugins_changed = true; 409 m_plugins_changed = true;
410} 410}
411 411
412/// loads each multiauth plugin 412/// loads each multiauth plugin
413void MultiauthConfig::loadPlugins() { 413void MultiauthConfig::loadPlugins() {
414 414
415 odebug << "loading plugins..." << oendl;
416 QString path = QPEApplication::qpeDir() + "/plugins/security"; 415 QString path = QPEApplication::qpeDir() + "/plugins/security";
417 QDir dir( path, "lib*.so" ); 416 QDir dir( path, "lib*.so" );
418 417
419 QStringList list = dir.entryList(); 418 QStringList list = dir.entryList();
420 QStringList::Iterator it; 419 QStringList::Iterator it;
421 420
422 // temporary list used to sort plugins 421 // temporary list used to sort plugins
423 QMap<QString, MultiauthPlugin> sortList; 422 QMap<QString, MultiauthPlugin> sortList;
424 423
425 for ( it = list.begin(); it != list.end(); ++it ) { 424 for ( it = list.begin(); it != list.end(); ++it ) {
426 QInterfacePtr<MultiauthPluginInterface> iface; 425 QInterfacePtr<MultiauthPluginInterface> iface;
427 QLibrary *lib = new QLibrary( path + "/" + *it ); 426 QLibrary *lib = new QLibrary( path + "/" + *it );
428 QString libPath(path + "/" + *it); 427 QString libPath(path + "/" + *it);
429 odebug << "library path: " << libPath << oendl;
430 428
431 odebug << "querying: " << QString( path + "/" + *it ) << oendl;
432 if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 429 if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
433 odebug << "accepted: " << QString( path + "/" + *it ) << oendl;
434
435 MultiauthPlugin plugin; 430 MultiauthPlugin plugin;
436 plugin.library = lib; 431 plugin.library = lib;
437 plugin.iface = iface; 432 plugin.iface = iface;
438 plugin.name = QString(*it); 433 plugin.name = QString(*it);
439 434
440 // find out if plugins should be launched 435 // find out if plugins should be launched
441 if ( m_excludePlugins.grep( *it ).isEmpty() ) { 436 if ( m_excludePlugins.grep( *it ).isEmpty() ) {
442 plugin.active = true; 437 plugin.active = true;
443 } else { 438 } else {
444 plugin.active = false; 439 plugin.active = false;
445 } 440 }
446 441
447 plugin.pluginObject = plugin.iface->plugin(); 442 plugin.pluginObject = plugin.iface->plugin();
448 443
449 // "prebuffer" it in one more list, to get the sorting done 444 // "prebuffer" it in one more list, to get the sorting done
450 sortList.insert( plugin.name, plugin ); 445 sortList.insert( plugin.name, plugin );
451 446
452 // on first start the list is off course empty 447 // on first start the list is off course empty
453 if ( m_allPlugins.isEmpty() ) { 448 if ( m_allPlugins.isEmpty() ) {
454 pluginList.append( plugin ); 449 pluginList.append( plugin );
455 } 450 }
456 // if plugin is not yet in the list, add it to the layout too 451 // if plugin is not yet in the list, add it to the layout too
457 else if ( !m_allPlugins.contains( plugin.name ) ) { 452 else if ( !m_allPlugins.contains( plugin.name ) ) {
458 pluginList.append( plugin ); 453 pluginList.append( plugin );
459 } 454 }
460 455
461 } else { 456 } else {
462 odebug << "could not recognize " << QString( path + "/" + *it ) << oendl;
463 delete lib; 457 delete lib;
464 } 458 }
465 459
466 } // end for 460 } // end for
467 461
468 // put m_allPlugins tempPlugin objects into pluginList 462 // put m_allPlugins tempPlugin objects into pluginList
469 if ( !m_allPlugins.isEmpty() ) { 463 if ( !m_allPlugins.isEmpty() ) {
470 MultiauthPlugin tempPlugin; 464 MultiauthPlugin tempPlugin;
471 QStringList::Iterator stringit; 465 QStringList::Iterator stringit;
472 for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) { 466 for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) {
473 tempPlugin = ( sortList.find( *stringit ) ).data(); 467 tempPlugin = ( sortList.find( *stringit ) ).data();
474 if ( !( (tempPlugin.name).isEmpty() ) ) { 468 if ( !( (tempPlugin.name).isEmpty() ) ) {
475 pluginList.append( tempPlugin ); 469 pluginList.append( tempPlugin );
476 } 470 }
477 } 471 }
478 } 472 }
479 473
480} 474}
481 475
482void MultiauthConfig::deleteListEntry() 476void MultiauthConfig::deleteListEntry()
483{ 477{
484 m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem()); 478 m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem());
485} 479}
486 480
487void MultiauthConfig::restoreDefaults() 481void MultiauthConfig::restoreDefaults()
488{ 482{
489 QMessageBox unrecbox( 483 QMessageBox unrecbox(
490 tr("Attention"), 484 tr("Attention"),
491 tr( "<p>All user-defined net ranges will be lost."), 485 tr( "<p>All user-defined net ranges will be lost."),
492 QMessageBox::Warning, 486 QMessageBox::Warning,
493 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, 487 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
494 0, QString::null, TRUE, WStyle_StaysOnTop); 488 0, QString::null, TRUE, WStyle_StaysOnTop);
495 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); 489 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel"));
496 unrecbox.setButtonText(QMessageBox::Yes, tr("Ok")); 490 unrecbox.setButtonText(QMessageBox::Yes, tr("Ok"));
497 491
498 if ( unrecbox.exec() == QMessageBox::Yes) 492 if ( unrecbox.exec() == QMessageBox::Yes)
499 { 493 {
500 m_syncWidget->syncnet->clear(); 494 m_syncWidget->syncnet->clear();
501 insertDefaultRanges(); 495 insertDefaultRanges();
502 } 496 }
503 m_syncWidget->syncModeCombo->setCurrentItem( 2 ); 497 m_syncWidget->syncModeCombo->setCurrentItem( 2 );
504} 498}
505 499
506void MultiauthConfig::insertDefaultRanges() 500void MultiauthConfig::insertDefaultRanges()
507{ 501{
508 m_syncWidget->syncnet->insertItem( tr( "192.168.129.0/24" ) ); 502 m_syncWidget->syncnet->insertItem( tr( "192.168.129.0/24" ) );
509 m_syncWidget->syncnet->insertItem( tr( "192.168.1.0/24" ) ); 503 m_syncWidget->syncnet->insertItem( tr( "192.168.1.0/24" ) );
510 m_syncWidget->syncnet->insertItem( tr( "192.168.0.0/16" ) ); 504 m_syncWidget->syncnet->insertItem( tr( "192.168.0.0/16" ) );
511 m_syncWidget->syncnet->insertItem( tr( "172.16.0.0/12" ) ); 505 m_syncWidget->syncnet->insertItem( tr( "172.16.0.0/12" ) );
512 m_syncWidget->syncnet->insertItem( tr( "10.0.0.0/8" ) ); 506 m_syncWidget->syncnet->insertItem( tr( "10.0.0.0/8" ) );
513 m_syncWidget->syncnet->insertItem( tr( "1.0.0.0/8" ) ); 507 m_syncWidget->syncnet->insertItem( tr( "1.0.0.0/8" ) );
514 m_syncWidget->syncnet->insertItem( tr( "Any" ) ); 508 m_syncWidget->syncnet->insertItem( tr( "Any" ) );
515 m_syncWidget->syncnet->insertItem( tr( "None" ) ); 509 m_syncWidget->syncnet->insertItem( tr( "None" ) );
516} 510}
517 511
518void MultiauthConfig::updateGUI() 512void MultiauthConfig::updateGUI()
519{ 513{
520 m_loginWidget->autologinToggle->setChecked(autoLogin); 514 m_loginWidget->autologinToggle->setChecked(autoLogin);
521 m_loginWidget->userlist->setEnabled(autoLogin); 515 m_loginWidget->userlist->setEnabled(autoLogin);
522} 516}
523 517
524void MultiauthConfig::selectNet(int auth_peer,int auth_peer_bits, bool update) 518void MultiauthConfig::selectNet(int auth_peer,int auth_peer_bits, bool update)
525{ 519{
526 QString sn; 520 QString sn;
527 if ( auth_peer_bits == 0 && auth_peer == 0 ) { 521 if ( auth_peer_bits == 0 && auth_peer == 0 ) {
528 sn = tr("Any"); 522 sn = tr("Any");
529 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { 523 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) {
530 sn = tr("None"); 524 sn = tr("None");
531 } else { 525 } else {
532 sn = 526 sn =
533 QString::number((auth_peer>>24)&0xff) + "." 527 QString::number((auth_peer>>24)&0xff) + "."
534 + QString::number((auth_peer>>16)&0xff) + "." 528 + QString::number((auth_peer>>16)&0xff) + "."
535 + QString::number((auth_peer>>8)&0xff) + "." 529 + QString::number((auth_peer>>8)&0xff) + "."
536 + QString::number((auth_peer>>0)&0xff) + "/" 530 + QString::number((auth_peer>>0)&0xff) + "/"
537 + QString::number(auth_peer_bits); 531 + QString::number(auth_peer_bits);
538 } 532 }
539 533
540 //insert user-defined list of netranges upon start 534 //insert user-defined list of netranges upon start
541 if (update) { 535 if (update) {
542 //User selected/active netrange first 536 //User selected/active netrange first
543 m_syncWidget->syncnet->insertItem( tr(sn) ); 537 m_syncWidget->syncnet->insertItem( tr(sn) );
544 Config cfg("Security"); 538 Config cfg("Security");
545 cfg.setGroup("Sync"); 539 cfg.setGroup("Sync");
546 540
547 //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe 541 //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe
548 QString test = cfg.readEntry("net0",""); 542 QString test = cfg.readEntry("net0","");
549 if (test.isEmpty()) { 543 if (test.isEmpty()) {
550 insertDefaultRanges(); 544 insertDefaultRanges();
551 } else { 545 } else {
552 // 10 ought to be enough for everybody... :) 546 // 10 ought to be enough for everybody... :)
553 // If you need more, don't forget to edit applySecurity() as well 547 // If you need more, don't forget to edit applySecurity() as well
554 bool already_there=FALSE; 548 bool already_there=FALSE;
555 for (int i=0; i<10; i++) { 549 for (int i=0; i<10; i++) {
556 QString target, netrange; 550 QString target, netrange;
557 target.sprintf("net%d", i); 551 target.sprintf("net%d", i);
558 netrange = cfg.readEntry(target,""); 552 netrange = cfg.readEntry(target,"");
559 if (! netrange.isEmpty()){ 553 if (! netrange.isEmpty()){
560 //make sure we have no "twin" entries 554 //make sure we have no "twin" entries
561 for (int i=0; i<m_syncWidget->syncnet->count(); i++) { 555 for (int i=0; i<m_syncWidget->syncnet->count(); i++) {
562 if ( m_syncWidget->syncnet->text(i) == netrange ) { 556 if ( m_syncWidget->syncnet->text(i) == netrange ) {
563 already_there=TRUE; 557 already_there=TRUE;
564 } 558 }
565 } 559 }
566 if (! already_there) { 560 if (! already_there) {
567 m_syncWidget->syncnet->insertItem( tr( netrange ) ); 561 m_syncWidget->syncnet->insertItem( tr( netrange ) );
568 } else { 562 } else {
569 already_there=FALSE; 563 already_there=FALSE;
570 } 564 }
571 } 565 }
572 } 566 }
573 } 567 }
574 } 568 }
575 569
576 for (int i=0; i<m_syncWidget->syncnet->count(); i++) { 570 for (int i=0; i<m_syncWidget->syncnet->count(); i++) {
577 if ( m_syncWidget->syncnet->text(i).left(sn.length()) == sn ) { 571 if ( m_syncWidget->syncnet->text(i).left(sn.length()) == sn ) {
578 m_syncWidget->syncnet->setCurrentItem(i); 572 m_syncWidget->syncnet->setCurrentItem(i);
579 return; 573 return;
580 } 574 }
581 } 575 }
582 odebug << "No match for \"" << sn << "\"" << oendl; 576 odebug << "No match for \"" << sn << "\"" << oendl;
583} 577}
584 578
585void MultiauthConfig::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) 579void MultiauthConfig::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
586{ 580{
587 auth_peer=0; 581 auth_peer=0;
588 if ( sn == tr("Any") ) { 582 if ( sn == tr("Any") ) {
589 auth_peer = 0; 583 auth_peer = 0;
590 auth_peer_bits = 0; 584 auth_peer_bits = 0;
591 } else if ( sn == tr("None") ) { 585 } else if ( sn == tr("None") ) {
592 auth_peer = 0; 586 auth_peer = 0;
593 auth_peer_bits = 32; 587 auth_peer_bits = 32;
594 } else { 588 } else {
595 int x=0; 589 int x=0;
596 for (int i=0; i<4; i++) { 590 for (int i=0; i<4; i++) {
597 int nx = sn.find(QChar(i==3 ? '/' : '.'),x); 591 int nx = sn.find(QChar(i==3 ? '/' : '.'),x);
598 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); 592 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt();
599 x = nx+1; 593 x = nx+1;
600 } 594 }
601 uint n = (uint)sn.find(' ',x)-x; 595 uint n = (uint)sn.find(' ',x)-x;
602 auth_peer_bits = sn.mid(x,n).toInt(); 596 auth_peer_bits = sn.mid(x,n).toInt();
603 } 597 }
604} 598}
605 599
606void MultiauthConfig::loadUsers() 600void MultiauthConfig::loadUsers()
607{ 601{
608 QFile passwd("/etc/passwd"); 602 QFile passwd("/etc/passwd");
609 if ( passwd.open(IO_ReadOnly) ) { 603 if ( passwd.open(IO_ReadOnly) ) {
610 QTextStream t( &passwd ); 604 QTextStream t( &passwd );
611 QString s; 605 QString s;
612 QStringList account; 606 QStringList account;
613 while ( !t.eof() ) { 607 while ( !t.eof() ) {
614 account = QStringList::split(':',t.readLine()); 608 account = QStringList::split(':',t.readLine());
615 // Hide disabled accounts and some special accounts 609 // Hide disabled accounts and some special accounts
616 if (*account.at(1)!="*" && *account.at(0)!="ppp" && *account.at(0)!="messagebus") { 610 if (*account.at(1)!="*" && *account.at(0)!="ppp" && *account.at(0)!="messagebus") {
617 611
618 m_loginWidget->userlist->insertItem(*account.at(0)); 612 m_loginWidget->userlist->insertItem(*account.at(0));
619 // Highlight this item if it is set to m_loginWidget->autologinToggle 613 // Highlight this item if it is set to m_loginWidget->autologinToggle
620 if ( *account.at(0) == autoLoginName) 614 if ( *account.at(0) == autoLoginName)
621 m_loginWidget->userlist->setCurrentItem(m_loginWidget->userlist->count()-1); 615 m_loginWidget->userlist->setCurrentItem(m_loginWidget->userlist->count()-1);
622 } 616 }
623 } 617 }
624 passwd.close(); 618 passwd.close();
625 } 619 }
626 620
627} 621}
628 622
629void MultiauthConfig::toggleAutoLogin(bool val) 623void MultiauthConfig::toggleAutoLogin(bool val)
630{ 624{
631 autoLogin=val; 625 autoLogin=val;
632 m_loginWidget->userlist->setEnabled(val); 626 m_loginWidget->userlist->setEnabled(val);
633 // if autoLogin is true, we will set by default the login currently visible in the userlist 627 // if autoLogin is true, we will set by default the login currently visible in the userlist
634 if (autoLogin) 628 if (autoLogin)
635 autoLoginName=m_loginWidget->userlist->currentText(); 629 autoLoginName=m_loginWidget->userlist->currentText();
636} 630}
637 631
638 632
639 633
640 634
641void MultiauthConfig::setSyncNet(const QString& sn) 635void MultiauthConfig::setSyncNet(const QString& sn)
642{ 636{
643 int auth_peer,auth_peer_bits; 637 int auth_peer,auth_peer_bits;
644 parseNet(sn,auth_peer,auth_peer_bits); 638 parseNet(sn,auth_peer,auth_peer_bits);
645 selectNet(auth_peer,auth_peer_bits,FALSE); 639 selectNet(auth_peer,auth_peer_bits,FALSE);
646} 640}
647 641
648void MultiauthConfig::changeLoginName( int idx ) 642void MultiauthConfig::changeLoginName( int idx )
649{ 643{
650 autoLoginName = m_loginWidget->userlist->text(idx);; 644 autoLoginName = m_loginWidget->userlist->text(idx);;
651 updateGUI(); 645 updateGUI();
652} 646}
653 647
654/// \todo do implement that? who? how? 648/// \todo do implement that? who? how?
655bool MultiauthConfig::telnetAvailable() const 649bool MultiauthConfig::telnetAvailable() const
656{ 650{
657 return FALSE; 651 return FALSE;
658} 652}
659 653
660/// \todo do implement that? who? how? 654/// \todo do implement that? who? how?
661bool MultiauthConfig::sshAvailable() const 655bool MultiauthConfig::sshAvailable() const
662{ 656{
663 return FALSE; 657 return FALSE;
664} 658}
665 659
diff --git a/noncore/securityplugins/blueping/bluepingplugin.cpp b/noncore/securityplugins/blueping/bluepingplugin.cpp
index f4c5e95..05fd3c2 100644
--- a/noncore/securityplugins/blueping/bluepingplugin.cpp
+++ b/noncore/securityplugins/blueping/bluepingplugin.cpp
@@ -1,201 +1,200 @@
1#include "bluepingplugin.h" 1#include "bluepingplugin.h"
2 2
3#include <opie2/oapplication.h> 3#include <opie2/oapplication.h>
4#include <opie2/odebug.h> 4#include <opie2/odebug.h>
5#include <opie2/odevice.h> 5#include <opie2/odevice.h>
6 6
7#include <qdialog.h> 7#include <qdialog.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qhbox.h> 9#include <qhbox.h>
10#include <qlabel.h> 10#include <qlabel.h>
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qtimer.h> 12#include <qtimer.h>
13 13
14using namespace Opie::Core; 14using namespace Opie::Core;
15using Opie::Security::MultiauthPluginObject; 15using Opie::Security::MultiauthPluginObject;
16using Opie::Security::MultiauthConfigWidget; 16using Opie::Security::MultiauthConfigWidget;
17 17
18 18
19/// creates and initializes the m_config Config object 19/// creates and initializes the m_config Config object
20BluepingPlugin::BluepingPlugin() : MultiauthPluginObject(), m_ping(0) { 20BluepingPlugin::BluepingPlugin() : MultiauthPluginObject(), m_ping(0) {
21 m_config = new Config("Security"); 21 m_config = new Config("Security");
22 m_config->setGroup("BluepingPlugin"); 22 m_config->setGroup("BluepingPlugin");
23 bluetoothAlreadyRestarted = false; 23 bluetoothAlreadyRestarted = false;
24} 24}
25 25
26/// deletes the m_config Config object and noticeW if necessary 26/// deletes the m_config Config object and noticeW if necessary
27BluepingPlugin::~BluepingPlugin() { 27BluepingPlugin::~BluepingPlugin() {
28 delete m_config; 28 delete m_config;
29 if (m_ping != 0) 29 delete m_ping;
30 delete m_ping;
31} 30}
32 31
33/// Simply return its name (Blueping plugin) 32/// Simply return its name (Blueping plugin)
34QString BluepingPlugin::pluginName() const { 33QString BluepingPlugin::pluginName() const {
35 return "Blueping plugin"; 34 return "Blueping plugin";
36} 35}
37 36
38/// no configuration widget for the moment 37/// no configuration widget for the moment
39MultiauthConfigWidget * BluepingPlugin::configWidget(QWidget * parent) { 38MultiauthConfigWidget * BluepingPlugin::configWidget(QWidget * parent) {
40 return 0l; 39 return 0l;
41} 40}
42QString BluepingPlugin::pixmapNameWidget() const { 41QString BluepingPlugin::pixmapNameWidget() const {
43 return "security/bluepingplugin"; 42 return "security/bluepingplugin";
44} 43}
45QString BluepingPlugin::pixmapNameConfig() const { 44QString BluepingPlugin::pixmapNameConfig() const {
46 return 0l; 45 return 0l;
47} 46}
48 47
49/// Emit the MultiauthPluginObject::Success emitCode 48/// Emit the MultiauthPluginObject::Success emitCode
50void BluepingPlugin::success() { 49void BluepingPlugin::success() {
51 emit emitCode(MultiauthPluginObject::Success); 50 emit emitCode(MultiauthPluginObject::Success);
52} 51}
53 52
54/// Emit the MultiauthPluginObject::Failure emitCode 53/// Emit the MultiauthPluginObject::Failure emitCode
55void BluepingPlugin::failure() { 54void BluepingPlugin::failure() {
56 emit emitCode(MultiauthPluginObject::Failure); 55 emit emitCode(MultiauthPluginObject::Failure);
57} 56}
58 57
59/// Emit the MultiauthPluginObject::Skip emitCode 58/// Emit the MultiauthPluginObject::Skip emitCode
60void BluepingPlugin::skip() { 59void BluepingPlugin::skip() {
61 emit emitCode(MultiauthPluginObject::Skip); 60 emit emitCode(MultiauthPluginObject::Skip);
62} 61}
63 62
64/// do the actual ping 63/// do the actual ping
65void BluepingPlugin::ping() { 64void BluepingPlugin::ping() {
66 m_ping = new OProcess(); 65 m_ping = new OProcess();
67 odebug << "pinging device: " << macToPing << oendl; 66 odebug << "pinging device: " << macToPing << oendl;
68 *m_ping << "l2ping" << "-c 1" << macToPing; 67 *m_ping << "l2ping" << "-c 1" << macToPing;
69 68
70 // starting to ping in the background 69 // starting to ping in the background
71 /// \todo as soon as ping is launched, check RSSI (signal strength) and check 70 /// \todo as soon as ping is launched, check RSSI (signal strength) and check
72 /// it's high enough, meaning the device is close enough? 71 /// it's high enough, meaning the device is close enough?
73 /// \todo make it optionally pollable, so don't finish the ping and call 72 /// \todo make it optionally pollable, so don't finish the ping and call
74 /// Opie suspend if l2ping timeouts? 73 /// Opie suspend if l2ping timeouts?
75 if ( !m_ping->start() ) { 74 if ( !m_ping->start() ) {
76 oerr << "could not start l2ping" << oendl; 75 oerr << "could not start l2ping" << oendl;
77 this->skip(); 76 this->skip();
78 } 77 }
79 QObject::connect(m_ping, SIGNAL(processExited(Opie::Core::OProcess*)), 78 QObject::connect(m_ping, SIGNAL(processExited(Opie::Core::OProcess*)),
80 this, SLOT(pingFinished(Opie::Core::OProcess*)) ); 79 this, SLOT(pingFinished(Opie::Core::OProcess*)) );
81} 80}
82 81
83/// Deals with m_ping result 82/// Deals with m_ping result
84 void BluepingPlugin::pingFinished(OProcess * ping) { 83 void BluepingPlugin::pingFinished(OProcess * ping) {
85 if ( ping->normalExit() && (ping->exitStatus() == 0) ) 84 if ( ping->normalExit() && (ping->exitStatus() == 0) )
86 { 85 {
87 odebug << "Successful Bluetooth ping!" << oendl; 86 odebug << "Successful Bluetooth ping!" << oendl;
88 success(); 87 success();
89 } 88 }
90 else 89 else
91 { 90 {
92 odebug << "Failed Bluetooth ping..." << oendl; 91 odebug << "Failed Bluetooth ping..." << oendl;
93 failure(); 92 failure();
94 } 93 }
95 } 94 }
96 95
97/// Make one authentication attempt with this plugin 96/// Make one authentication attempt with this plugin
98/** 97/**
99 * (very simple "success" / "failure" buttons in a dialog) 98 * (very simple "success" / "failure" buttons in a dialog)
100 * \return The outcome code of this authentication 99 * \return The outcome code of this authentication
101 */ 100 */
102int BluepingPlugin::authenticate() { 101int BluepingPlugin::authenticate() {
103 102
104 Config cfg("Security"); 103 Config cfg("Security");
105 cfg.setGroup("BluepingPlugin"); 104 cfg.setGroup("BluepingPlugin");
106 macToPing = cfg.readEntry("mac"); 105 macToPing = cfg.readEntry("mac");
107 if (!macToPing.isEmpty()) 106 if (!macToPing.isEmpty())
108 { 107 {
109 /* Standard, inescapable authentication dialog 108 /* Standard, inescapable authentication dialog
110 */ 109 */
111 QDialog bluepingDialog(0, 110 QDialog bluepingDialog(0,
112 "Blueping dialog", 111 "Blueping dialog",
113 TRUE, 112 TRUE,
114 Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); 113 Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop);
115 114
116 QRect desk = oApp->desktop()->geometry(); 115 QRect desk = oApp->desktop()->geometry();
117 bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() ); 116 bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() );
118 117
119 // Creation of the particular widgets of our Blueping user interface 118 // Creation of the particular widgets of our Blueping user interface
120 QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog); 119 QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog);
121 layout->setSpacing(11); 120 layout->setSpacing(11);
122 layout->setMargin(11); 121 layout->setMargin(11);
123 layout->setAlignment( Qt::AlignTop ); 122 layout->setAlignment( Qt::AlignTop );
124 123
125 QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog); 124 QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog);
126 QLabel subTitle("<center><h2>Trying to reach your configured bluetooth device...</h2></center>", &bluepingDialog); 125 QLabel subTitle("<center><h2>Trying to reach your configured bluetooth device...</h2></center>", &bluepingDialog);
127 QLabel subTitle2("<center>You can skip this step and use another authentication way with the following button</center>", &bluepingDialog); 126 QLabel subTitle2("<center>You can skip this step and use another authentication way with the following button</center>", &bluepingDialog);
128 QPushButton pbSkip("Skip", &bluepingDialog); 127 QPushButton pbSkip("Skip", &bluepingDialog);
129 layout->addWidget(&title); 128 layout->addWidget(&title);
130 layout->addWidget(&subTitle); 129 layout->addWidget(&subTitle);
131 layout->addWidget(&subTitle2); 130 layout->addWidget(&subTitle2);
132 layout->addWidget(&pbSkip, 0, Qt::AlignHCenter); 131 layout->addWidget(&pbSkip, 0, Qt::AlignHCenter);
133 132
134 // connect the skip button to the skip signal emitting function 133 // connect the skip button to the skip signal emitting function
135 QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip())); 134 QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip()));
136 // connect the signal emitting functions to the bluepingDialog done(int) finishing function 135 // connect the signal emitting functions to the bluepingDialog done(int) finishing function
137 QObject::connect(this, SIGNAL(emitCode(int)), &bluepingDialog, SLOT(done(int))); 136 QObject::connect(this, SIGNAL(emitCode(int)), &bluepingDialog, SLOT(done(int)));
138 137
139 if (!bluetoothAlreadyRestarted) 138 if (!bluetoothAlreadyRestarted)
140 { 139 {
141 // we have just started or resumed the device, so Bluetooth has to be (re)started 140 // we have just started or resumed the device, so Bluetooth has to be (re)started
142 OProcess killB; 141 OProcess killB;
143 killB << "killall" << "hciattach"; 142 killB << "killall" << "hciattach";
144 odebug << "killing Bluetooth..." << oendl; 143 odebug << "killing Bluetooth..." << oendl;
145 if ( !killB.start(OProcess::Block) ) { 144 if ( !killB.start(OProcess::Block) ) {
146 oerr << "could not kill bluetooth" << oendl; 145 oerr << "could not kill bluetooth" << oendl;
147 } 146 }
148 147
149 OProcess startB; 148 OProcess startB;
150 switch ( ODevice::inst()->model() ) { 149 switch ( ODevice::inst()->model() ) {
151 case Model_iPAQ_H39xx: 150 case Model_iPAQ_H39xx:
152 startB << "/sbin/hciattach" << "/dev/tts/1" << "bcsp" << "921600"; 151 startB << "/sbin/hciattach" << "/dev/tts/1" << "bcsp" << "921600";
153 break; 152 break;
154 153
155 case Model_iPAQ_H5xxx: 154 case Model_iPAQ_H5xxx:
156 startB << "/sbin/hciattach" << "/dev/tts/1" << "any" << "921600"; 155 startB << "/sbin/hciattach" << "/dev/tts/1" << "any" << "921600";
157 break; 156 break;
158 157
159 default: 158 default:
160 startB << "/sbin/hciattach" << "/dev/ttySB0" << "bcsp" << "230400"; 159 startB << "/sbin/hciattach" << "/dev/ttySB0" << "bcsp" << "230400";
161 break; 160 break;
162 } // end switch on device models 161 } // end switch on device models
163 162
164 if ( !startB.start(OProcess::Block) ) { 163 if ( !startB.start(OProcess::Block) ) {
165 oerr << "could not (re)start bluetooth" << oendl; 164 oerr << "could not (re)start bluetooth" << oendl;
166 return MultiauthPluginObject::Skip; 165 return MultiauthPluginObject::Skip;
167 } 166 }
168 else 167 else
169 { 168 {
170 if ( startB.normalExit() && (startB.exitStatus() == 0) ) 169 if ( startB.normalExit() && (startB.exitStatus() == 0) )
171 { 170 {
172 odebug << "hciattach exited normally."<< oendl; 171 odebug << "hciattach exited normally."<< oendl;
173 bluetoothAlreadyRestarted = true; 172 bluetoothAlreadyRestarted = true;
174 // 500 ms timer, so l2ping won't try to find a route before bluetooth has \em really started 173 // 500 ms timer, so l2ping won't try to find a route before bluetooth has \em really started
175 QTimer::singleShot( 500, this, SLOT(ping()) ); 174 QTimer::singleShot( 500, this, SLOT(ping()) );
176 } 175 }
177 else 176 else
178 { 177 {
179 owarn << "hciattach exited anormally (error code: " << startB.exitStatus() << ")" << oendl; 178 owarn << "hciattach exited anormally (error code: " << startB.exitStatus() << ")" << oendl;
180 } // end if startBluetooth exit status == 0 179 } // end if startBluetooth exit status == 0
181 } // end if startBluetooth started 180 } // end if startBluetooth started
182 } 181 }
183 else 182 else
184 { 183 {
185 // we don't need to wait, since bluetooth has been started long enough ago 184 // we don't need to wait, since bluetooth has been started long enough ago
186 ping(); 185 ping();
187 } // end if bluetooth not restarted 186 } // end if bluetooth not restarted
188 187
189 188
190 // start the dialog event loop, while the ping is starting (or will start soon) in the background 189 // start the dialog event loop, while the ping is starting (or will start soon) in the background
191 return bluepingDialog.exec(); 190 return bluepingDialog.exec();
192 191
193 192
194 } 193 }
195 else 194 else
196 { 195 {
197 owarn << "No Bluetooth device has been set!" << oendl; 196 owarn << "No Bluetooth device has been set!" << oendl;
198 owarn << "We will consider it as a successful authentication though." << oendl; 197 owarn << "We will consider it as a successful authentication though." << oendl;
199 return MultiauthPluginObject::Success; 198 return MultiauthPluginObject::Success;
200 } // end if mac defined 199 } // end if mac defined
201} 200}
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.cpp b/noncore/securityplugins/notice/noticeConfigWidget.cpp
index e532232..e0468a7 100644
--- a/noncore/securityplugins/notice/noticeConfigWidget.cpp
+++ b/noncore/securityplugins/notice/noticeConfigWidget.cpp
@@ -1,83 +1,83 @@
1#include "noticeConfigWidget.h" 1#include "noticeConfigWidget.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4 4
5#include <qwidget.h> 5#include <qwidget.h>
6#include <qlayout.h> 6#include <qlayout.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qregexp.h> 8#include <qregexp.h>
9#include <qgroupbox.h> 9#include <qgroupbox.h>
10 10
11using Opie::Security::MultiauthConfigWidget; 11using Opie::Security::MultiauthConfigWidget;
12 12
13/// constructs the widget, filling the noticeMLE QMultiLineEdit with the "noticeText" entry 13/// constructs the widget, filling the noticeMLE QMultiLineEdit with the "noticeText" entry
14NoticeConfigWidget::NoticeConfigWidget(QWidget* parent = 0, const char* name = "Notice configuration widget") : MultiauthConfigWidget(parent, name) 14NoticeConfigWidget::NoticeConfigWidget(QWidget* parent = 0, const char* name = "Notice configuration widget") : MultiauthConfigWidget(parent, name)
15{ 15{
16 QVBoxLayout *baseLayout = new QVBoxLayout( this); 16 QVBoxLayout *baseLayout = new QVBoxLayout( this);
17 baseLayout->setSpacing(11); 17 baseLayout->setSpacing(11);
18 baseLayout->setMargin(6); 18 baseLayout->setMargin(6);
19 baseLayout->setAlignment( Qt::AlignTop ); 19 baseLayout->setAlignment( Qt::AlignTop );
20 20
21 QGroupBox *configBox = new QGroupBox(0, Qt::Vertical, tr("Set the message the user must accept"), this); 21 QGroupBox *configBox = new QGroupBox(0, Qt::Vertical, tr("Set the message the user must accept"), this);
22 baseLayout->addWidget(configBox); 22 baseLayout->addWidget(configBox);
23 QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() ); 23 QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() );
24 24
25 QLabel * comment1 = new QLabel("<p><em>" + tr("You may want to consult your legal department for proper wording here.") + "</em></p>", configBox); 25 QLabel * comment1 = new QLabel("<p><em>" + tr("You may want to consult your legal department for proper wording here.") + "</em></p>", configBox);
26 boxLayout->addWidget(comment1); 26 boxLayout->addWidget(comment1);
27 27
28 // Set the multilineedit box text to getNoticeText() 28 // Set the multilineedit box text to getNoticeText()
29 noticeMLE = new QMultiLineEdit(configBox, "notice text"); 29 noticeMLE = new QMultiLineEdit(configBox, "notice text");
30 noticeMLE->setWordWrap(QMultiLineEdit::WidgetWidth); 30 noticeMLE->setWordWrap(QMultiLineEdit::WidgetWidth);
31 noticeMLE->setFocus(); 31 noticeMLE->setFocus();
32 noticeMLE->setText(getNoticeText()); 32 noticeMLE->setText(getNoticeText());
33 boxLayout->addWidget(noticeMLE); 33 boxLayout->addWidget(noticeMLE);
34 34
35 resetNoticeButton = new QPushButton( tr("Reset notice to default"), configBox, "reset Notice Button" ); 35 resetNoticeButton = new QPushButton( tr("Reset notice to default"), configBox, "reset Notice Button" );
36 connect(resetNoticeButton, SIGNAL( clicked() ), this, SLOT( resetNotice() )); 36 connect(resetNoticeButton, SIGNAL( clicked() ), this, SLOT( resetNotice() ));
37 boxLayout->addWidget(resetNoticeButton, 0, Qt::AlignHCenter); 37 boxLayout->addWidget(resetNoticeButton, 0, Qt::AlignHCenter);
38 38
39 QLabel * comment2 = new QLabel("<p>" + tr("Note: you can use HTML tags to improve its layout (example: text between &lt;em&gt; and &lt;/em&gt; will be <em>emphasized</em>)") + "</p>", configBox); 39 QLabel * comment2 = new QLabel("<p>" + tr("Note: you can use HTML tags to improve its layout (example: text between &lt;em&gt; and &lt;/em&gt; will be <em>emphasized</em>)") + "</p>", configBox);
40 boxLayout->addWidget(comment2); 40 boxLayout->addWidget(comment2);
41 41
42} 42}
43 43
44/// nothing to do 44/// nothing to do
45NoticeConfigWidget::~NoticeConfigWidget() 45NoticeConfigWidget::~NoticeConfigWidget()
46{} 46{}
47 47
48/// write the notice text in the multiauth.conf Config file 48/// write the notice text in the multiauth.conf Config file
49void NoticeConfigWidget::writeConfig() 49void NoticeConfigWidget::writeConfig()
50{ 50{
51 if ( noticeMLE->edited() ) { 51 if ( noticeMLE->edited() ) {
52 odebug << "writing new notice text in Security.conf" << oendl; 52 odebug << "writing new notice text in Security.conf" << oendl;
53 setNoticeText(noticeMLE->text()); 53 setNoticeText(noticeMLE->text());
54 } 54 }
55} 55}
56 56
57/// reset the notice text to the hard-coded example defaultNoticeText 57/// reset the notice text to the hard-coded example defaultNoticeText
58void NoticeConfigWidget::resetNotice() 58void NoticeConfigWidget::resetNotice()
59{ 59{
60 noticeMLE->setText(defaultNoticeText); 60 noticeMLE->setText(QObject::tr(defaultNoticeText));
61} 61}
62 62
63/// get the notice text from the config file (with true new lines) 63/// get the notice text from the config file (with true new lines)
64/** 64/**
65 * if no text has been defined yet returns defaultNoticeText 65 * if no text has been defined yet returns defaultNoticeText
66 */ 66 */
67QString NoticeConfigWidget::getNoticeText() { 67QString NoticeConfigWidget::getNoticeText() {
68 m_config = new Config("Security"); 68 m_config = new Config("Security");
69 m_config->setGroup("NoticePlugin"); 69 m_config->setGroup("NoticePlugin");
70 // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp 70 // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
71 QString noticeText = m_config->readEntry("noticeText", defaultNoticeText).replace( QRegExp("\\\\n"), "\n" ); 71 QString noticeText = m_config->readEntry("noticeText", QObject::tr(defaultNoticeText) ).replace( QRegExp("\\\\n"), "\n" );
72 delete m_config; 72 delete m_config;
73 return noticeText; 73 return noticeText;
74} 74}
75 75
76/// set the notice text in our m_config config file (escaping new lines) 76/// set the notice text in our m_config config file (escaping new lines)
77void NoticeConfigWidget::setNoticeText(QString noticeText) { 77void NoticeConfigWidget::setNoticeText(QString noticeText) {
78 m_config = new Config("Security"); 78 m_config = new Config("Security");
79 m_config->setGroup("NoticePlugin"); 79 m_config->setGroup("NoticePlugin");
80 // since Config files do not allow true newlines, we replace them with litteral "\n" 80 // since Config files do not allow true newlines, we replace them with litteral "\n"
81 m_config->writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" )); 81 m_config->writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" ));
82 delete m_config; 82 delete m_config;
83} 83}
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.h b/noncore/securityplugins/notice/noticeConfigWidget.h
index c90484c..f8847e4 100644
--- a/noncore/securityplugins/notice/noticeConfigWidget.h
+++ b/noncore/securityplugins/notice/noticeConfigWidget.h
@@ -1,72 +1,72 @@
1/** 1/**
2 * \file noticeConfigWidget.h 2 * \file noticeConfigWidget.h
3 * \brief Notice plugin configuration widget 3 * \brief Notice plugin configuration widget
4 * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) 4 * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
5 */ 5 */
6/* 6/*
7 =. This file is part of the Opie Project 7 =. This file is part of the Opie Project
8 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> 8 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
9 .>+-= 9 .>+-=
10 _;:, .> :=|. This library is free software; you can 10 _;:, .> :=|. This library is free software; you can
11.> <`_, > . <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 12:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
13.="- .-=="i, .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - . .-<_> .<> Foundation; either version 2 of the License, 14 - . .-<_> .<> Foundation; either version 2 of the License,
15 ._= =} : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16 .%`+i> _;_. 16 .%`+i> _;_.
17 .i_,=:_. -<s. This library is distributed in the hope that 17 .i_,=:_. -<s. This library is distributed in the hope that
18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19 : .. .:, . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.= = ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++= -. .` .: details. 23++= -. .` .: details.
24 : = ...= . :.=- 24 : = ...= . :.=-
25 -. .:....=;==+<; You should have received a copy of the GNU 25 -. .:....=;==+<; You should have received a copy of the GNU
26 -_. . . )=. = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27 -- :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef NOTICECONFIGWIDGET_H 34#ifndef NOTICECONFIGWIDGET_H
35#define NOTICECONFIGWIDGET_H 35#define NOTICECONFIGWIDGET_H
36 36
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qmultilineedit.h> 38#include <qmultilineedit.h>
39#include <qpe/config.h> 39#include <qpe/config.h>
40 40
41#include <opie2/multiauthconfigwidget.h> 41#include <opie2/multiauthconfigwidget.h>
42 42
43static char defaultNoticeText [] = "<h2>NOTICE TO USERS</h2>\n" 43static char defaultNoticeText [] = QT_TRANSLATE_NOOP( "QObject", "<h2>NOTICE TO USERS</h2>\n"
44 "<p>This is a private computer system and is the property of " 44 "<p>This is a private computer system and is the property of "
45 "the company XXX / Mr or Ms X. It is for authorized " 45 "the company XXX / Mr or Ms X. It is for authorized "
46 "use only. Users have no expectation of privacy.</p>\n" 46 "use only. Users have no expectation of privacy.</p>\n"
47 "<p><strong>Unauthorized or improper use of this system may result in " 47 "<p><strong>Unauthorized or improper use of this system may result in "
48 "disciplinary action and civil and criminal penalties. <em>By continuing to use " 48 "disciplinary action and civil and criminal penalties. <em>By continuing to use "
49 "this system you indicate your awareness of and consent to these " 49 "this system you indicate your awareness of and consent to these "
50 "terms. LOG OFF IMMEDIATELY if you do not agree to them.</em></strong></p>"; 50 "terms. LOG OFF IMMEDIATELY if you do not agree to them.</em></strong></p>");
51 51
52class NoticeConfigWidget : public Opie::Security::MultiauthConfigWidget { 52class NoticeConfigWidget : public Opie::Security::MultiauthConfigWidget {
53 53
54 Q_OBJECT 54 Q_OBJECT
55 55
56public: 56public:
57 NoticeConfigWidget(QWidget* parent, const char* name); 57 NoticeConfigWidget(QWidget* parent, const char* name);
58 virtual ~NoticeConfigWidget(); 58 virtual ~NoticeConfigWidget();
59 virtual void writeConfig(); 59 virtual void writeConfig();
60private: 60private:
61 QMultiLineEdit * noticeMLE; 61 QMultiLineEdit * noticeMLE;
62 QPushButton * resetNoticeButton; 62 QPushButton * resetNoticeButton;
63private slots: 63private slots:
64 void resetNotice(); 64 void resetNotice();
65private: 65private:
66 Config * m_config; 66 Config * m_config;
67 QString getNoticeText(); 67 QString getNoticeText();
68 void setNoticeText(QString noticeText); 68 void setNoticeText(QString noticeText);
69}; 69};
70 70
71#endif // NOTICECONFIGWIDGET_H 71#endif // NOTICECONFIGWIDGET_H
72 72
diff --git a/noncore/securityplugins/notice/noticeplugin.cpp b/noncore/securityplugins/notice/noticeplugin.cpp
index 25a452a..1da260a 100644
--- a/noncore/securityplugins/notice/noticeplugin.cpp
+++ b/noncore/securityplugins/notice/noticeplugin.cpp
@@ -1,86 +1,86 @@
1#include "noticeplugin.h" 1#include "noticeplugin.h"
2 2
3#include <opie2/oapplication.h> 3#include <opie2/oapplication.h>
4 4
5#include <qmessagebox.h> 5#include <qmessagebox.h>
6#include <qregexp.h> 6#include <qregexp.h>
7 7
8using Opie::Security::MultiauthPluginObject; 8using Opie::Security::MultiauthPluginObject;
9using Opie::Security::MultiauthConfigWidget; 9using Opie::Security::MultiauthConfigWidget;
10 10
11/// creates and initializes the m_config Config object 11/// creates and initializes the m_config Config object
12NoticePlugin::NoticePlugin() : MultiauthPluginObject(), noticeW(0) { 12NoticePlugin::NoticePlugin() : MultiauthPluginObject(), noticeW(0) {
13 m_config = new Config("Security"); 13 m_config = new Config("Security");
14 m_config->setGroup("NoticePlugin"); 14 m_config->setGroup("NoticePlugin");
15} 15}
16 16
17/// deletes the m_config Config object and noticeW if necessary 17/// deletes the m_config Config object and noticeW if necessary
18NoticePlugin::~NoticePlugin() { 18NoticePlugin::~NoticePlugin() {
19 delete m_config; 19 delete m_config;
20 if (noticeW != 0) 20 if (noticeW != 0)
21 delete noticeW; 21 delete noticeW;
22} 22}
23 23
24/// Simply return its name (Notice plugin) 24/// Simply return its name (Notice plugin)
25QString NoticePlugin::pluginName() const { 25QString NoticePlugin::pluginName() const {
26 return "Notice plugin"; 26 return "Notice plugin";
27} 27}
28 28
29/// return the Notice widget configuration widget 29/// return the Notice widget configuration widget
30/** 30/**
31 * \return noticeW, the NoticeConfigWidget 31 * \return noticeW, the NoticeConfigWidget
32 */ 32 */
33MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) { 33MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) {
34 if (noticeW == 0) 34 if (noticeW == 0)
35 noticeW = new NoticeConfigWidget(parent, "Notice configuration widget"); 35 noticeW = new NoticeConfigWidget(parent, "Notice configuration widget");
36 return noticeW; 36 return noticeW;
37} 37}
38 38
39/// return the path of the small tab icon 39/// return the path of the small tab icon
40QString NoticePlugin::pixmapNameConfig() const { 40QString NoticePlugin::pixmapNameConfig() const {
41 return "security/noticeplugin_small"; 41 return "security/noticeplugin_small";
42} 42}
43 43
44/// return the path of the big icon for the active/order checklist 44/// return the path of the big icon for the active/order checklist
45QString NoticePlugin::pixmapNameWidget() const { 45QString NoticePlugin::pixmapNameWidget() const {
46 return "security/noticeplugin"; 46 return "security/noticeplugin";
47} 47}
48 48
49/// Displays the configured message and an 'Accept' button 49/// Displays the configured message and an 'Accept' button
50/** 50/**
51 * \return the outcome code of this authentication (can be only success) 51 * \return the outcome code of this authentication (can be only success)
52 */ 52 */
53int NoticePlugin::authenticate() { 53int NoticePlugin::authenticate() {
54 QMessageBox noticeDialog("Notice plugin", 54 QMessageBox noticeDialog("Notice plugin",
55 getNoticeText(), 55 getNoticeText(),
56 QMessageBox::Warning, 56 QMessageBox::Warning,
57 QMessageBox::Yes, 57 QMessageBox::Yes,
58 0, 58 0,
59 0, 59 0,
60 0, 60 0,
61 "notice plugin dialog", 61 "notice plugin dialog",
62 true, 62 true,
63 Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); 63 Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop);
64 64
65 noticeDialog.setButtonText(QMessageBox::Yes, tr("I accept")); 65 noticeDialog.setButtonText(QMessageBox::Yes, tr("I accept"));
66 66
67 QRect desk = oApp->desktop()->geometry(); 67 QRect desk = oApp->desktop()->geometry();
68 noticeDialog.setGeometry( 0, 0, desk.width(), desk.height() ); 68 noticeDialog.setGeometry( 0, 0, desk.width(), desk.height() );
69 69
70 switch (noticeDialog.exec()) 70 switch (noticeDialog.exec())
71 { 71 {
72 case QMessageBox::Yes: 72 case QMessageBox::Yes:
73 return MultiauthPluginObject::Success; 73 return MultiauthPluginObject::Success;
74 } 74 }
75 return 255; //should not be returned anyway 75 return 255; //should not be returned anyway
76} 76}
77 77
78/// get the notice text from our m_config config file (with true new lines) 78/// get the notice text from our m_config config file (with true new lines)
79/** 79/**
80 * if no text has been defined yet returns defaultNoticeText 80 * if no text has been defined yet returns defaultNoticeText
81 */ 81 */
82QString NoticePlugin::getNoticeText() { 82QString NoticePlugin::getNoticeText() {
83 // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp 83 // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
84 return m_config->readEntry("noticeText", defaultNoticeText).replace( QRegExp("\\\\n"), "\n" ); 84 return m_config->readEntry("noticeText", QObject::tr(defaultNoticeText)).replace( QRegExp("\\\\n"), "\n" );
85} 85}
86 86