summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/configwindow.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index 279b39c..89ed24c 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -16,51 +16,52 @@
16/* LOCAL */ 16/* LOCAL */
17#include "configwindow.h" 17#include "configwindow.h"
18#include "mainwindow.h" 18#include "mainwindow.h"
19 19
20/* OPIE */ 20/* OPIE */
21#include <opie2/onetwork.h> 21#include <opie2/onetwork.h>
22#ifdef QWS 22#ifdef QWS
23#include <opie2/oapplication.h> 23#include <opie2/oapplication.h>
24#include <opie2/oconfig.h> 24#include <opie2/oconfig.h>
25#include <opie2/odevice.h> 25#include <opie2/odevice.h>
26#include <opie2/odebug.h> 26#include <opie2/odebug.h>
27using namespace Opie::Core; 27using namespace Opie::Core;
28using namespace Opie::Net; 28using namespace Opie::Net;
29#endif 29#endif
30 30
31/* QT */ 31/* QT */
32#include <qapplication.h> 32#include <qapplication.h>
33#include <qcheckbox.h> 33#include <qcheckbox.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qlayout.h> 37#include <qlayout.h>
38#include <qmap.h> 38#include <qmap.h>
39#include <qpushbutton.h> 39#include <qpushbutton.h>
40#include <qradiobutton.h>
41#include <qspinbox.h>
40#include <qtabwidget.h> 42#include <qtabwidget.h>
41#include <qtoolbutton.h> 43#include <qtoolbutton.h>
42#include <qspinbox.h>
43#include <qtextstream.h> 44#include <qtextstream.h>
44 45
45/* STD */ 46/* STD */
46#include <assert.h> 47#include <assert.h>
47 48
48WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 49WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
49 50
50WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 51WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
51 :WellenreiterConfigBase( parent, name, true, f ) 52 :WellenreiterConfigBase( parent, name, true, f )
52{ 53{
53 _devicetype[ "cisco" ] = DEVTYPE_CISCO; 54 _devicetype[ "cisco" ] = DEVTYPE_CISCO;
54 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; 55 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
55 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; 56 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
56 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; 57 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
57 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; 58 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
58 _devicetype[ "<file>" ] = DEVTYPE_FILE; 59 _devicetype[ "<file>" ] = DEVTYPE_FILE;
59 60
60 // gather possible interface names from ONetwork 61 // gather possible interface names from ONetwork
61 ONetwork* net = ONetwork::instance(); 62 ONetwork* net = ONetwork::instance();
62 ONetwork::InterfaceIterator it = net->iterator(); 63 ONetwork::InterfaceIterator it = net->iterator();
63 while ( it.current() ) 64 while ( it.current() )
64 { 65 {
65 if ( it.current()->isWireless() ) 66 if ( it.current()->isWireless() )
66 interfaceName->insertItem( it.current()->name() ); 67 interfaceName->insertItem( it.current()->name() );
@@ -91,70 +92,70 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
91 92
92 // hide tab4 (parse) until Wellenreiter 1.2 93 // hide tab4 (parse) until Wellenreiter 1.2
93 tab->removePage( tab_4 ); 94 tab->removePage( tab_4 );
94}; 95};
95 96
96 97
97void WellenreiterConfigWindow::accept() 98void WellenreiterConfigWindow::accept()
98{ 99{
99 save(); 100 save();
100 QDialog::accept(); 101 QDialog::accept();
101} 102}
102 103
103 104
104WellenreiterConfigWindow::~WellenreiterConfigWindow() 105WellenreiterConfigWindow::~WellenreiterConfigWindow()
105{ 106{
106} 107}
107 108
108 109
109void WellenreiterConfigWindow::performAutodetection() 110void WellenreiterConfigWindow::performAutodetection()
110{ 111{
111 //TODO: insert modal splash screen here 112 //TODO: insert modal splash screen here
112 // and sleep a second, so that it looks 113 // and sleep a second, so that it looks
113 // like we're actually doing something fancy... ;-) 114 // like we're actually doing something fancy... ;-)
114 115
115 odebug << "WellenreiterConfigWindow::performAutodetection()" << oendl; 116 odebug << "WellenreiterConfigWindow::performAutodetection()" << oendl;
116 117
117 // try to guess device type 118 // try to guess device type
118 QFile m( "/proc/modules" ); 119 QFile m( "/proc/modules" );
119 if ( m.open( IO_ReadOnly ) ) 120 if ( m.open( IO_ReadOnly ) )
120 { 121 {
121 int devicetype(0); 122 int devicetype(0);
122 QString line; 123 QString line;
123 QTextStream modules( &m ); 124 QTextStream modules( &m );
124 while( !modules.atEnd() && !devicetype ) 125 while( !modules.atEnd() && !devicetype )
125 { 126 {
126 modules >> line; 127 modules >> line;
127 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; 128 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
128 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; 129 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
129 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; 130 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
130 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; 131 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
131 } 132 }
132 if ( devicetype ) 133 if ( devicetype )
133 { 134 {
134 deviceType->setCurrentItem( devicetype ); 135 deviceType->setCurrentItem( devicetype );
135 _guess = devicetype; 136 _guess = devicetype;
136 odebug << "Wellenreiter: guessed device type to be #" << devicetype << "" << oendl; 137 odebug << "Wellenreiter: guessed device type to be #" << devicetype << "" << oendl;
137 } 138 }
138 } 139 }
139} 140}
140 141
141 142
142int WellenreiterConfigWindow::driverType() const 143int WellenreiterConfigWindow::driverType() const
143{ 144{
144 QString name = deviceType->currentText(); 145 QString name = deviceType->currentText();
145 if ( _devicetype.contains( name ) ) 146 if ( _devicetype.contains( name ) )
146 { 147 {
147 return _devicetype[name]; 148 return _devicetype[name];
148 } 149 }
149 else 150 else
150 { 151 {
151 return 0; 152 return 0;
152 } 153 }
153}; 154};
154 155
155 156
156int WellenreiterConfigWindow::hoppingInterval() const 157int WellenreiterConfigWindow::hoppingInterval() const
157{ 158{
158 return hopInterval->cleanText().toInt(); 159 return hopInterval->cleanText().toInt();
159} 160}
160 161
@@ -216,49 +217,49 @@ void WellenreiterConfigWindow::synchronizeActionsAndScripts()
216} 217}
217 218
218 219
219void WellenreiterConfigWindow::changedNetworkAction(int t) 220void WellenreiterConfigWindow::changedNetworkAction(int t)
220{ 221{
221 synchronizeActionsAndScripts(); 222 synchronizeActionsAndScripts();
222} 223}
223 224
224 225
225void WellenreiterConfigWindow::changedClientAction(int t) 226void WellenreiterConfigWindow::changedClientAction(int t)
226{ 227{
227 synchronizeActionsAndScripts(); 228 synchronizeActionsAndScripts();
228} 229}
229 230
230 231
231void WellenreiterConfigWindow::changedStationAction(int t) 232void WellenreiterConfigWindow::changedStationAction(int t)
232{ 233{
233 synchronizeActionsAndScripts(); 234 synchronizeActionsAndScripts();
234} 235}
235 236
236 237
237void WellenreiterConfigWindow::getCaptureFileNameClicked() 238void WellenreiterConfigWindow::getCaptureFileNameClicked()
238{ 239{
239 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); 240 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true);
240 odebug << "name = " << name << "" << oendl; 241 odebug << "name = " << name << "" << oendl;
241 if ( !name.isEmpty() ) 242 if ( !name.isEmpty() )
242 { 243 {
243 captureFileName->setText( name ); 244 captureFileName->setText( name );
244 } 245 }
245} 246}
246 247
247 248
248void WellenreiterConfigWindow::channelAllClicked(int state) 249void WellenreiterConfigWindow::channelAllClicked(int state)
249{ 250{
250 bool b = state; 251 bool b = state;
251 channel1->setChecked( b ); 252 channel1->setChecked( b );
252 channel2->setChecked( b ); 253 channel2->setChecked( b );
253 channel3->setChecked( b ); 254 channel3->setChecked( b );
254 channel4->setChecked( b ); 255 channel4->setChecked( b );
255 channel5->setChecked( b ); 256 channel5->setChecked( b );
256 channel6->setChecked( b ); 257 channel6->setChecked( b );
257 channel7->setChecked( b ); 258 channel7->setChecked( b );
258 channel8->setChecked( b ); 259 channel8->setChecked( b );
259 channel9->setChecked( b ); 260 channel9->setChecked( b );
260 channel10->setChecked( b ); 261 channel10->setChecked( b );
261 channel11->setChecked( b ); 262 channel11->setChecked( b );
262 channel12->setChecked( b ); 263 channel12->setChecked( b );
263 channel13->setChecked( b ); 264 channel13->setChecked( b );
264 channel14->setChecked( b ); 265 channel14->setChecked( b );
@@ -291,94 +292,94 @@ void WellenreiterConfigWindow::performAction( const QString& type,
291 int channel, 292 int channel,
292 int signal 293 int signal
293 /* , const GpsLocation& loc */ ) 294 /* , const GpsLocation& loc */ )
294{ 295{
295 int action; 296 int action;
296 QString script; 297 QString script;
297 298
298 if ( type == "network" ) 299 if ( type == "network" )
299 { 300 {
300 action = newNetworkAction->currentItem(); 301 action = newNetworkAction->currentItem();
301 script = newNetworkScript->text(); 302 script = newNetworkScript->text();
302 } 303 }
303 else if ( type == "managed" || type == "adhoc" ) 304 else if ( type == "managed" || type == "adhoc" )
304 { 305 {
305 action = newClientAction->currentItem(); 306 action = newClientAction->currentItem();
306 script = newClientScript->text(); 307 script = newClientScript->text();
307 } 308 }
308 else if ( type == "station" ) 309 else if ( type == "station" )
309 { 310 {
310 action = newStationAction->currentItem(); 311 action = newStationAction->currentItem();
311 script = newStationScript->text(); 312 script = newStationScript->text();
312 } 313 }
313 else 314 else
314 { 315 {
315 owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << type << "'" << oendl; 316 owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << type << "'" << oendl;
316 return; 317 return;
317 } 318 }
318 319
319 odebug << "for event '" << (const char*) type << "' I'm going to perform action " << action << " (script='" << script << "')" << oendl; 320 odebug << "for event '" << (const char*) type << "' I'm going to perform action " << action << " (script='" << script << "')" << oendl;
320 321
321 switch( action ) 322 switch( action )
322 { 323 {
323 case 0: /* Ignore */ return; 324 case 0: /* Ignore */ return;
324 case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; 325 case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return;
325 case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; 326 case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return;
326 case 3: /* Blink LED */ break; //FIXME: Implement this 327 case 3: /* Blink LED */ break; //FIXME: Implement this
327 case 4: /* Run Script */ 328 case 4: /* Run Script */
328 { 329 {
329 /** 330 /**
330 * 331 *
331 * Script Substitution Information: 332 * Script Substitution Information:
332 * 333 *
333 * $SSID = SSID 334 * $SSID = SSID
334 * $MAC = MAC 335 * $MAC = MAC
335 * $WEP = Wep 336 * $WEP = Wep
336 * $CHAN = Channel 337 * $CHAN = Channel
337 * 338 *
338 **/ 339 **/
339 script = script.replace( QRegExp( "$SSID" ), essid ); 340 script = script.replace( QRegExp( "$SSID" ), essid );
340 script = script.replace( QRegExp( "$MAC" ), mac ); 341 script = script.replace( QRegExp( "$MAC" ), mac );
341 script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); 342 script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) );
342 script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); 343 script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) );
343 344
344 odebug << "going to call script '" << script << "'" << oendl; 345 odebug << "going to call script '" << script << "'" << oendl;
345 ::system( script ); 346 ::system( script );
346 odebug << "script returned." << oendl; 347 odebug << "script returned." << oendl;
347 return; 348 return;
348 } 349 }
349 default: assert( false ); 350 default: assert( false );
350 } 351 }
351} 352}
352 353
353 354
354void WellenreiterConfigWindow::load() 355void WellenreiterConfigWindow::load()
355{ 356{
356#ifdef Q_WS_X11 357#ifdef Q_WS_X11
357 #warning Persistent Configuration not yet implemented for standalone X11 build 358 #warning Persistent Configuration not yet implemented for standalone X11 build
358 performAutodetection(); 359 performAutodetection();
359#else 360#else
360 odebug << "loading configuration settings..." << oendl; 361 odebug << "loading configuration settings..." << oendl;
361 362
362 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ 363 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
363 364
364 OConfig* c = oApp->config(); 365 OConfig* c = oApp->config();
365 366
366 c->setGroup( "Interface" ); 367 c->setGroup( "Interface" );
367 368
368 QString interface = c->readEntry( "name", "<none>" ); 369 QString interface = c->readEntry( "name", "<none>" );
369 if ( interface != "<none>" ) 370 if ( interface != "<none>" )
370 { 371 {
371#if QT_VERSION < 300 372#if QT_VERSION < 300
372 interfaceName->insertItem( interface, 0 ); 373 interfaceName->insertItem( interface, 0 );
373 interfaceName->setCurrentItem( 0 ); 374 interfaceName->setCurrentItem( 0 );
374#else 375#else
375 interfaceName->setCurrentText( interface ); 376 interfaceName->setCurrentText( interface );
376#endif 377#endif
377 378
378 QString device = c->readEntry( "type", "<select>" ); 379 QString device = c->readEntry( "type", "<select>" );
379#if QT_VERSION < 300 380#if QT_VERSION < 300
380 for ( int i = 0; i < deviceType->count(); ++i ) 381 for ( int i = 0; i < deviceType->count(); ++i )
381 { 382 {
382 if ( deviceType->text( i ) == device ) 383 if ( deviceType->text( i ) == device )
383 { 384 {
384 deviceType->setCurrentItem( i ); 385 deviceType->setCurrentItem( i );
@@ -414,63 +415,69 @@ void WellenreiterConfigWindow::load()
414 newStationScript->setText( c->readEntry( "newStationScript", "" ) ); 415 newStationScript->setText( c->readEntry( "newStationScript", "" ) );
415 synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand 416 synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand
416 417
417 c->setGroup( "GPS" ); 418 c->setGroup( "GPS" );
418 enableGPS->setChecked( c->readBoolEntry( "use", false ) ); 419 enableGPS->setChecked( c->readBoolEntry( "use", false ) );
419#if QT_VERSION < 300 420#if QT_VERSION < 300
420 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); 421 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 );
421 gpsdHost->setCurrentItem( 0 ); 422 gpsdHost->setCurrentItem( 0 );
422#else 423#else
423 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); 424 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) );
424#endif 425#endif
425 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); 426 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) );
426 startGPS->setChecked( c->readBoolEntry( "start", false ) ); 427 startGPS->setChecked( c->readBoolEntry( "start", false ) );
427 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); 428 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) );
428 429
429#endif 430#endif
430} 431}
431 432
432 433
433void WellenreiterConfigWindow::save() 434void WellenreiterConfigWindow::save()
434{ 435{
435#ifdef Q_WS_X11 436#ifdef Q_WS_X11
436 #warning Persistent Configuration not yet implemented for standalone X11 build 437 #warning Persistent Configuration not yet implemented for standalone X11 build
437#else 438#else
438 odebug << "saving configuration settings..." << oendl; 439 odebug << "saving configuration settings..." << oendl;
439 440
440 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ 441 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
441 442
442 OConfig* c = oApp->config(); 443 OConfig* c = oApp->config();
443 444
444 c->setGroup( "Interface" ); 445 c->setGroup( "Interface" );
445 c->writeEntry( "name", interfaceName->currentText() ); 446 c->writeEntry( "name", interfaceName->currentText() );
446 c->writeEntry( "type", deviceType->currentText() ); 447 c->writeEntry( "type", deviceType->currentText() );
447 c->writeEntry( "prism", prismHeader->isChecked() ); 448 c->writeEntry( "prism", prismHeader->isChecked() );
448 c->writeEntry( "hop", hopChannels->isChecked() ); 449 c->writeEntry( "hop", hopChannels->isChecked() );
449 c->writeEntry( "interval", hopInterval->value() ); 450 c->writeEntry( "interval", hopInterval->value() );
450 c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); 451 c->writeEntry( "adaptive", adaptiveHopping->isChecked() );
451 452
452 c->setGroup( "Capture" ); 453 c->setGroup( "Capture" );
453 c->writeEntry( "filename", captureFileName->text() ); 454 c->writeEntry( "filename", captureFileName->text() );
454 455
455 c->setGroup( "UI" ); 456 c->setGroup( "UI" );
456 c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); 457 c->writeEntry( "lookupVendor", lookupVendor->isChecked() );
457 c->writeEntry( "openTree", openTree->isChecked() ); 458 c->writeEntry( "openTree", openTree->isChecked() );
458 c->writeEntry( "disablePM", disablePM->isChecked() ); 459 c->writeEntry( "disablePM", disablePM->isChecked() );
459 c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); 460 c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() );
460 c->writeEntry( "newNetworkScript", newNetworkScript->text() ); 461 c->writeEntry( "newNetworkScript", newNetworkScript->text() );
461 c->writeEntry( "newClientAction", newClientAction->currentItem() ); 462 c->writeEntry( "newClientAction", newClientAction->currentItem() );
462 c->writeEntry( "newClientScript", newClientScript->text() ); 463 c->writeEntry( "newClientScript", newClientScript->text() );
463 c->writeEntry( "newStationAction", newStationAction->currentItem() ); 464 c->writeEntry( "newStationAction", newStationAction->currentItem() );
464 c->writeEntry( "newStationScript", newStationScript->text() ); 465 c->writeEntry( "newStationScript", newStationScript->text() );
465 466
466 c->setGroup( "GPS" ); 467 c->setGroup( "GPS" );
467 c->writeEntry( "use", enableGPS->isChecked() ); 468 c->writeEntry( "use", enableGPS->isChecked() );
468 c->writeEntry( "host", gpsdHost->currentText() ); 469 c->writeEntry( "host", gpsdHost->currentText() );
469 c->writeEntry( "port", gpsdPort->value() ); 470 c->writeEntry( "port", gpsdPort->value() );
470 c->writeEntry( "start", startGPS->isChecked() ); 471 c->writeEntry( "start", startGPS->isChecked() );
471 c->writeEntry( "command", commandGPS->text() ); 472 c->writeEntry( "command", commandGPS->text() );
472 473
473 c->write(); 474 c->write();
474 475
475#endif 476#endif
476} 477}
478
479
480int WellenreiterConfigWindow::hexViewBuffer() const
481{
482 return hexViewBufferUnlimited->isChecked() ? -1 : hexViewBufferSize->value();
483}