summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index f82c088..68da712 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -1,345 +1,345 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16/* LOCAL */ 16/* LOCAL */
17#include "configwindow.h" 17#include "configwindow.h"
18#include "mainwindow.h" 18#include "mainwindow.h"
19 19
20/* QT */ 20/* QT */
21#include <qapplication.h> 21#include <qapplication.h>
22#include <qcheckbox.h> 22#include <qcheckbox.h>
23#include <qcombobox.h> 23#include <qcombobox.h>
24#include <qfile.h> 24#include <qfile.h>
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qmap.h> 27#include <qmap.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qspinbox.h> 30#include <qspinbox.h>
31#include <qtextstream.h> 31#include <qtextstream.h>
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/onetwork.h> 34#include <opie2/onetwork.h>
35 35
36#ifdef QWS 36#ifdef QWS
37#include <opie2/oapplication.h> 37#include <opie2/oapplication.h>
38#include <opie2/oconfig.h> 38#include <opie2/oconfig.h>
39#endif 39#endif
40 40
41WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 41WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
42 42
43WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 43WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
44 :WellenreiterConfigBase( parent, name, true, f ) 44 :WellenreiterConfigBase( parent, name, true, f )
45{ 45{
46 _devicetype[ "cisco" ] = DEVTYPE_CISCO; 46 _devicetype[ "cisco" ] = DEVTYPE_CISCO;
47 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; 47 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
48 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; 48 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
49 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; 49 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
50 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; 50 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
51 _devicetype[ "<file>" ] = DEVTYPE_FILE; 51 _devicetype[ "<file>" ] = DEVTYPE_FILE;
52 52
53 // gather possible interface names from ONetwork 53 // gather possible interface names from ONetwork
54 ONetwork* net = ONetwork::instance(); 54 ONetwork* net = ONetwork::instance();
55 ONetwork::InterfaceIterator it = net->iterator(); 55 ONetwork::InterfaceIterator it = net->iterator();
56 while ( it.current() ) 56 while ( it.current() )
57 { 57 {
58 if ( it.current()->isWireless() ) 58 if ( it.current()->isWireless() )
59 interfaceName->insertItem( it.current()->name() ); 59 interfaceName->insertItem( it.current()->name() );
60 ++it; 60 ++it;
61 } 61 }
62 62
63 load(); 63 load();
64 64
65 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here 65 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
66 QPushButton* okButton = new QPushButton( "ok", this ); 66 QPushButton* okButton = new QPushButton( "ok", this );
67 okButton->show(); 67 okButton->show();
68 WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui 68 WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui
69 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); 69 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
70 #endif 70 #endif
71 71
72 WellenreiterConfigWindow::_instance = this; 72 WellenreiterConfigWindow::_instance = this;
73 73
74 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); 74 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) );
75 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); 75 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) );
76 76
77 // make the checkbox 'channelAll' control all other channels 77 // make the checkbox 'channelAll' control all other channels
78 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); 78 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) );
79 79
80 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); 80 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) );
81}; 81};
82 82
83 83
84WellenreiterConfigWindow::~WellenreiterConfigWindow() 84WellenreiterConfigWindow::~WellenreiterConfigWindow()
85{ 85{
86 save(); 86 save();
87} 87}
88 88
89 89
90void WellenreiterConfigWindow::performAutodetection() 90void WellenreiterConfigWindow::performAutodetection()
91{ 91{
92 //TODO: insert modal splash screen here 92 //TODO: insert modal splash screen here
93 // and sleep a second, so that it looks 93 // and sleep a second, so that it looks
94 // like we're actually doing something fancy... ;-) 94 // like we're actually doing something fancy... ;-)
95 95
96 qDebug( "WellenreiterConfigWindow::performAutodetection()" ); 96 qDebug( "WellenreiterConfigWindow::performAutodetection()" );
97 97
98 // try to guess device type 98 // try to guess device type
99 QFile m( "/proc/modules" ); 99 QFile m( "/proc/modules" );
100 if ( m.open( IO_ReadOnly ) ) 100 if ( m.open( IO_ReadOnly ) )
101 { 101 {
102 int devicetype(0); 102 int devicetype(0);
103 QString line; 103 QString line;
104 QTextStream modules( &m ); 104 QTextStream modules( &m );
105 while( !modules.atEnd() && !devicetype ) 105 while( !modules.atEnd() && !devicetype )
106 { 106 {
107 modules >> line; 107 modules >> line;
108 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; 108 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
109 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; 109 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
110 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; 110 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
111 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; 111 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
112 } 112 }
113 if ( devicetype ) 113 if ( devicetype )
114 { 114 {
115 deviceType->setCurrentItem( devicetype ); 115 deviceType->setCurrentItem( devicetype );
116 _guess = devicetype; 116 _guess = devicetype;
117 qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); 117 qDebug( "Wellenreiter: guessed device type to be #%d", devicetype );
118 } 118 }
119 } 119 }
120} 120}
121 121
122 122
123int WellenreiterConfigWindow::driverType() const 123int WellenreiterConfigWindow::driverType() const
124{ 124{
125 QString name = deviceType->currentText(); 125 QString name = deviceType->currentText();
126 if ( _devicetype.contains( name ) ) 126 if ( _devicetype.contains( name ) )
127 { 127 {
128 return _devicetype[name]; 128 return _devicetype[name];
129 } 129 }
130 else 130 else
131 { 131 {
132 return 0; 132 return 0;
133 } 133 }
134}; 134};
135 135
136 136
137int WellenreiterConfigWindow::hoppingInterval() const 137int WellenreiterConfigWindow::hoppingInterval() const
138{ 138{
139 return hopInterval->cleanText().toInt(); 139 return hopInterval->cleanText().toInt();
140} 140}
141 141
142 142
143bool WellenreiterConfigWindow::usePrismHeader() const 143bool WellenreiterConfigWindow::usePrismHeader() const
144{ 144{
145 return prismHeader->isChecked(); 145 return prismHeader->isChecked();
146} 146}
147 147
148 148
149bool WellenreiterConfigWindow::isChannelChecked( int channel ) const 149bool WellenreiterConfigWindow::isChannelChecked( int channel ) const
150{ 150{
151 switch ( channel ) 151 switch ( channel )
152 { 152 {
153 case 1: return channel1->isOn(); 153 case 1: return channel1->isOn();
154 case 2: return channel2->isOn(); 154 case 2: return channel2->isOn();
155 case 3: return channel3->isOn(); 155 case 3: return channel3->isOn();
156 case 4: return channel4->isOn(); 156 case 4: return channel4->isOn();
157 case 5: return channel5->isOn(); 157 case 5: return channel5->isOn();
158 case 6: return channel6->isOn(); 158 case 6: return channel6->isOn();
159 case 7: return channel7->isOn(); 159 case 7: return channel7->isOn();
160 case 8: return channel8->isOn(); 160 case 8: return channel8->isOn();
161 case 9: return channel9->isOn(); 161 case 9: return channel9->isOn();
162 case 10: return channel10->isOn(); 162 case 10: return channel10->isOn();
163 case 11: return channel11->isOn(); 163 case 11: return channel11->isOn();
164 case 12: return channel12->isOn(); 164 case 12: return channel12->isOn();
165 case 13: return channel13->isOn(); 165 case 13: return channel13->isOn();
166 case 14: return channel14->isOn(); 166 case 14: return channel14->isOn();
167 } 167 }
168} 168}
169 169
170 170
171void WellenreiterConfigWindow::changedDeviceType(int t) 171void WellenreiterConfigWindow::changedDeviceType(int t)
172{ 172{
173 if ( t != DEVTYPE_FILE ) return; 173 if ( t != DEVTYPE_FILE ) return;
174 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); 174 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false);
175 if ( !name.isEmpty() && QFile::exists( name ) ) 175 if ( !name.isEmpty() && QFile::exists( name ) )
176 { 176 {
177 interfaceName->insertItem( name ); 177 interfaceName->insertItem( name );
178 interfaceName->setCurrentItem( interfaceName->count()-1 ); 178 interfaceName->setCurrentItem( interfaceName->count()-1 );
179 } 179 }
180 else 180 else
181 { 181 {
182 deviceType->setCurrentItem( _guess ); 182 deviceType->setCurrentItem( _guess );
183 } 183 }
184 184
185} 185}
186 186
187 187
188void WellenreiterConfigWindow::getCaptureFileNameClicked() 188void WellenreiterConfigWindow::getCaptureFileNameClicked()
189{ 189{
190 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); 190 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true);
191 qDebug( "name = %s", (const char*) name ); 191 qDebug( "name = %s", (const char*) name );
192 if ( !name.isEmpty() ) 192 if ( !name.isEmpty() )
193 { 193 {
194 captureFileName->setText( name ); 194 captureFileName->setText( name );
195 } 195 }
196} 196}
197 197
198 198
199void WellenreiterConfigWindow::channelAllClicked(int state) 199void WellenreiterConfigWindow::channelAllClicked(int state)
200{ 200{
201 bool b = state; 201 bool b = state;
202 channel1->setChecked( b ); 202 channel1->setChecked( b );
203 channel2->setChecked( b ); 203 channel2->setChecked( b );
204 channel3->setChecked( b ); 204 channel3->setChecked( b );
205 channel4->setChecked( b ); 205 channel4->setChecked( b );
206 channel5->setChecked( b ); 206 channel5->setChecked( b );
207 channel6->setChecked( b ); 207 channel6->setChecked( b );
208 channel7->setChecked( b ); 208 channel7->setChecked( b );
209 channel8->setChecked( b ); 209 channel8->setChecked( b );
210 channel9->setChecked( b ); 210 channel9->setChecked( b );
211 channel10->setChecked( b ); 211 channel10->setChecked( b );
212 channel11->setChecked( b ); 212 channel11->setChecked( b );
213 channel12->setChecked( b ); 213 channel12->setChecked( b );
214 channel13->setChecked( b ); 214 channel13->setChecked( b );
215 channel14->setChecked( b ); 215 channel14->setChecked( b );
216} 216}
217 217
218 218
219bool WellenreiterConfigWindow::useGPS() const 219bool WellenreiterConfigWindow::useGPS() const
220{ 220{
221 return enableGPS->isChecked(); 221 return enableGPS->isChecked();
222} 222}
223 223
224 224
225const QString WellenreiterConfigWindow::gpsHost() const 225const QString WellenreiterConfigWindow::gpsHost() const
226{ 226{
227 return useGPS() ? gpsdHost->currentText() : QString::null; 227 return useGPS() ? gpsdHost->currentText() : QString::null;
228} 228}
229 229
230 230
231int WellenreiterConfigWindow::gpsPort() const 231int WellenreiterConfigWindow::gpsPort() const
232{ 232{
233 bool ok; 233 bool ok;
234 return useGPS() ? gpsdPort->value() : -1; 234 return useGPS() ? gpsdPort->value() : -1;
235} 235}
236 236
237 237
238void WellenreiterConfigWindow::load() 238void WellenreiterConfigWindow::load()
239{ 239{
240#ifdef Q_WS_X11 240#ifdef Q_WS_X11
241 #warning Persistent Configuration not yet implemented for standalone X11 build 241 #warning Persistent Configuration not yet implemented for standalone X11 build
242 performAutodetection(); 242 performAutodetection();
243#else 243#else
244 qDebug( "loading configuration settings..." ); 244 qDebug( "loading configuration settings..." );
245 245
246 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ 246 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
247 247
248 OConfig* c = oApp->config(); 248 OConfig* c = oApp->config();
249 249
250 c->setGroup( "Interface" ); 250 c->setGroup( "Interface" );
251 251
252 QString interface = c->readEntry( "name", "<none>" ); 252 QString interface = c->readEntry( "name", "<none>" );
253 if ( interface != "<none>" ) 253 if ( interface != "<none>" )
254 { 254 {
255#if QT_VERSION < 300 255#if QT_VERSION < 300
256 interfaceName->insertItem( interface, 0 ); 256 interfaceName->insertItem( interface, 0 );
257 interfaceName->setCurrentItem( 0 ); 257 interfaceName->setCurrentItem( 0 );
258#else 258#else
259 interfaceName->setCurrentText( interface ); 259 interfaceName->setCurrentText( interface );
260#endif 260#endif
261 261
262 QString device = c->readEntry( "type", "<select>" ); 262 QString device = c->readEntry( "type", "<select>" );
263#if QT_VERSION < 300 263#if QT_VERSION < 300
264 for ( int i = 0; i < deviceType->count(); ++i ) 264 for ( int i = 0; i < deviceType->count(); ++i )
265 { 265 {
266 if ( deviceType->text( i ) == device ) 266 if ( deviceType->text( i ) == device )
267 { 267 {
268 deviceType->setCurrentItem( i ); 268 deviceType->setCurrentItem( i );
269 break; 269 break;
270 } 270 }
271 } 271 }
272#else 272#else
273 deviceType->setCurrentText( device ); 273 deviceType->setCurrentText( device );
274#endif 274#endif
275 } 275 }
276 else 276 else
277 { 277 {
278 performAutodetection(); 278 performAutodetection();
279 } 279 }
280 280
281 prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); 281 prismHeader->setChecked( c->readBoolEntry( "prism", false ) );
282 hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); 282 hopChannels->setChecked( c->readBoolEntry( "hop", true ) );
283 hopInterval->setValue( c->readNumEntry( "interval", 100 ) ); 283 hopInterval->setValue( c->readNumEntry( "interval", 250 ) );
284 adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); 284 adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) );
285 285
286 c->setGroup( "Capture" ); 286 c->setGroup( "Capture" );
287 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); 287 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) );
288 288
289 c->setGroup( "UI" ); 289 c->setGroup( "UI" );
290 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); 290 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) );
291 openTree->setChecked( c->readBoolEntry( "openTree", true ) ); 291 openTree->setChecked( c->readBoolEntry( "openTree", true ) );
292 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); 292 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) );
293 293
294 c->setGroup( "GPS" ); 294 c->setGroup( "GPS" );
295 enableGPS->setChecked( c->readBoolEntry( "use", false ) ); 295 enableGPS->setChecked( c->readBoolEntry( "use", false ) );
296#if QT_VERSION < 300 296#if QT_VERSION < 300
297 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); 297 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 );
298 gpsdHost->setCurrentItem( 0 ); 298 gpsdHost->setCurrentItem( 0 );
299#else 299#else
300 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); 300 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) );
301#endif 301#endif
302 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); 302 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) );
303 startGPS->setChecked( c->readBoolEntry( "start", false ) ); 303 startGPS->setChecked( c->readBoolEntry( "start", false ) );
304 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); 304 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) );
305 305
306#endif 306#endif
307} 307}
308 308
309 309
310void WellenreiterConfigWindow::save() 310void WellenreiterConfigWindow::save()
311{ 311{
312#ifdef Q_WS_X11 312#ifdef Q_WS_X11
313 #warning Persistent Configuration not yet implemented for standalone X11 build 313 #warning Persistent Configuration not yet implemented for standalone X11 build
314#else 314#else
315 qDebug( "saving configuration settings..." ); 315 qDebug( "saving configuration settings..." );
316 316
317 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ 317 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
318 318
319 OConfig* c = oApp->config(); 319 OConfig* c = oApp->config();
320 320
321 c->setGroup( "Interface" ); 321 c->setGroup( "Interface" );
322 c->writeEntry( "name", interfaceName->currentText() ); 322 c->writeEntry( "name", interfaceName->currentText() );
323 c->writeEntry( "type", deviceType->currentText() ); 323 c->writeEntry( "type", deviceType->currentText() );
324 c->writeEntry( "prism", prismHeader->isChecked() ); 324 c->writeEntry( "prism", prismHeader->isChecked() );
325 c->writeEntry( "hop", hopChannels->isChecked() ); 325 c->writeEntry( "hop", hopChannels->isChecked() );
326 c->writeEntry( "interval", hopInterval->value() ); 326 c->writeEntry( "interval", hopInterval->value() );
327 c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); 327 c->writeEntry( "adaptive", adaptiveHopping->isChecked() );
328 328
329 c->setGroup( "Capture" ); 329 c->setGroup( "Capture" );
330 c->writeEntry( "filename", captureFileName->text() ); 330 c->writeEntry( "filename", captureFileName->text() );
331 331
332 c->setGroup( "UI" ); 332 c->setGroup( "UI" );
333 c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); 333 c->writeEntry( "lookupVendor", lookupVendor->isChecked() );
334 c->writeEntry( "openTree", openTree->isChecked() ); 334 c->writeEntry( "openTree", openTree->isChecked() );
335 c->writeEntry( "disablePM", disablePM->isChecked() ); 335 c->writeEntry( "disablePM", disablePM->isChecked() );
336 336
337 c->setGroup( "GPS" ); 337 c->setGroup( "GPS" );
338 c->writeEntry( "use", enableGPS->isChecked() ); 338 c->writeEntry( "use", enableGPS->isChecked() );
339 c->writeEntry( "host", gpsdHost->currentText() ); 339 c->writeEntry( "host", gpsdHost->currentText() );
340 c->writeEntry( "port", gpsdPort->value() ); 340 c->writeEntry( "port", gpsdPort->value() );
341 c->writeEntry( "start", startGPS->isChecked() ); 341 c->writeEntry( "start", startGPS->isChecked() );
342 c->writeEntry( "command", commandGPS->text() ); 342 c->writeEntry( "command", commandGPS->text() );
343 343
344#endif 344#endif
345} 345}