Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index da39113..bfdb20a 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -14,50 +14,46 @@ | |||
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 | /* 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 | using namespace Opie; | 26 | #include <opie2/odebug.h> |
27 | using namespace Opie::Core; | ||
28 | using namespace Opie::Net; | ||
27 | #endif | 29 | #endif |
28 | 30 | ||
29 | /* QT */ | 31 | /* QT */ |
30 | #include <qapplication.h> | 32 | #include <qapplication.h> |
31 | #include <qcheckbox.h> | 33 | #include <qcheckbox.h> |
32 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
33 | #include <qfile.h> | 35 | #include <qfile.h> |
34 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
35 | #include <qlayout.h> | 37 | #include <qlayout.h> |
36 | #include <qmap.h> | 38 | #include <qmap.h> |
37 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
38 | #include <qtabwidget.h> | 40 | #include <qtabwidget.h> |
39 | #include <qtoolbutton.h> | 41 | #include <qtoolbutton.h> |
40 | #include <qspinbox.h> | 42 | #include <qspinbox.h> |
41 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
42 | 44 | ||
43 | /* POSIX */ | 45 | /* STD */ |
44 | #include <assert.h> | 46 | #include <assert.h> |
45 | 47 | ||
46 | using namespace Opie::Core; | ||
47 | using namespace Opie::Net; | ||
48 | using namespace Opie::Core; | ||
49 | using namespace Opie::Net; | ||
50 | using namespace Opie::Core; | ||
51 | using namespace Opie::Net; | ||
52 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | 48 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; |
53 | 49 | ||
54 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | 50 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) |
55 | :WellenreiterConfigBase( parent, name, true, f ) | 51 | :WellenreiterConfigBase( parent, name, true, f ) |
56 | { | 52 | { |
57 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; | 53 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; |
58 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; | 54 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; |
59 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; | 55 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; |
60 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; | 56 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; |
61 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; | 57 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; |
62 | _devicetype[ "<file>" ] = DEVTYPE_FILE; | 58 | _devicetype[ "<file>" ] = DEVTYPE_FILE; |
63 | 59 | ||
@@ -107,46 +103,46 @@ void WellenreiterConfigWindow::accept() | |||
107 | 103 | ||
108 | WellenreiterConfigWindow::~WellenreiterConfigWindow() | 104 | WellenreiterConfigWindow::~WellenreiterConfigWindow() |
109 | { | 105 | { |
110 | } | 106 | } |
111 | 107 | ||
112 | 108 | ||
113 | void WellenreiterConfigWindow::performAutodetection() | 109 | void WellenreiterConfigWindow::performAutodetection() |
114 | { | 110 | { |
115 | //TODO: insert modal splash screen here | 111 | //TODO: insert modal splash screen here |
116 | // and sleep a second, so that it looks | 112 | // and sleep a second, so that it looks |
117 | // like we're actually doing something fancy... ;-) | 113 | // like we're actually doing something fancy... ;-) |
118 | 114 | ||
119 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); | 115 | odebug << "WellenreiterConfigWindow::performAutodetection()" << oendl; |
120 | 116 | ||
121 | // try to guess device type | 117 | // try to guess device type |
122 | QFile m( "/proc/modules" ); | 118 | QFile m( "/proc/modules" ); |
123 | if ( m.open( IO_ReadOnly ) ) | 119 | if ( m.open( IO_ReadOnly ) ) |
124 | { | 120 | { |
125 | int devicetype(0); | 121 | int devicetype(0); |
126 | QString line; | 122 | QString line; |
127 | QTextStream modules( &m ); | 123 | QTextStream modules( &m ); |
128 | while( !modules.atEnd() && !devicetype ) | 124 | while( !modules.atEnd() && !devicetype ) |
129 | { | 125 | { |
130 | modules >> line; | 126 | modules >> line; |
131 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | 127 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; |
132 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | 128 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; |
133 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | 129 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; |
134 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | 130 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; |
135 | } | 131 | } |
136 | if ( devicetype ) | 132 | if ( devicetype ) |
137 | { | 133 | { |
138 | deviceType->setCurrentItem( devicetype ); | 134 | deviceType->setCurrentItem( devicetype ); |
139 | _guess = devicetype; | 135 | _guess = devicetype; |
140 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | 136 | odebug << "Wellenreiter: guessed device type to be #" << devicetype << "" << oendl; |
141 | } | 137 | } |
142 | } | 138 | } |
143 | } | 139 | } |
144 | 140 | ||
145 | 141 | ||
146 | int WellenreiterConfigWindow::driverType() const | 142 | int WellenreiterConfigWindow::driverType() const |
147 | { | 143 | { |
148 | QString name = deviceType->currentText(); | 144 | QString name = deviceType->currentText(); |
149 | if ( _devicetype.contains( name ) ) | 145 | if ( _devicetype.contains( name ) ) |
150 | { | 146 | { |
151 | return _devicetype[name]; | 147 | return _devicetype[name]; |
152 | } | 148 | } |
@@ -232,25 +228,25 @@ void WellenreiterConfigWindow::changedClientAction(int t) | |||
232 | } | 228 | } |
233 | 229 | ||
234 | 230 | ||
235 | void WellenreiterConfigWindow::changedStationAction(int t) | 231 | void WellenreiterConfigWindow::changedStationAction(int t) |
236 | { | 232 | { |
237 | synchronizeActionsAndScripts(); | 233 | synchronizeActionsAndScripts(); |
238 | } | 234 | } |
239 | 235 | ||
240 | 236 | ||
241 | void WellenreiterConfigWindow::getCaptureFileNameClicked() | 237 | void WellenreiterConfigWindow::getCaptureFileNameClicked() |
242 | { | 238 | { |
243 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); | 239 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); |
244 | qDebug( "name = %s", (const char*) name ); | 240 | odebug << "name = " << (const char*) name << "" << oendl; |
245 | if ( !name.isEmpty() ) | 241 | if ( !name.isEmpty() ) |
246 | { | 242 | { |
247 | captureFileName->setText( name ); | 243 | captureFileName->setText( name ); |
248 | } | 244 | } |
249 | } | 245 | } |
250 | 246 | ||
251 | 247 | ||
252 | void WellenreiterConfigWindow::channelAllClicked(int state) | 248 | void WellenreiterConfigWindow::channelAllClicked(int state) |
253 | { | 249 | { |
254 | bool b = state; | 250 | bool b = state; |
255 | channel1->setChecked( b ); | 251 | channel1->setChecked( b ); |
256 | channel2->setChecked( b ); | 252 | channel2->setChecked( b ); |
@@ -307,70 +303,70 @@ void WellenreiterConfigWindow::performAction( const QString& type, | |||
307 | else if ( type == "managed" || type == "adhoc" ) | 303 | else if ( type == "managed" || type == "adhoc" ) |
308 | { | 304 | { |
309 | action = newClientAction->currentItem(); | 305 | action = newClientAction->currentItem(); |
310 | script = newClientScript->text(); | 306 | script = newClientScript->text(); |
311 | } | 307 | } |
312 | else if ( type == "station" ) | 308 | else if ( type == "station" ) |
313 | { | 309 | { |
314 | action = newStationAction->currentItem(); | 310 | action = newStationAction->currentItem(); |
315 | script = newStationScript->text(); | 311 | script = newStationScript->text(); |
316 | } | 312 | } |
317 | else | 313 | else |
318 | { | 314 | { |
319 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); | 315 | owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << (const char*) type << "'" << oendl; |
320 | return; | 316 | return; |
321 | } | 317 | } |
322 | 318 | ||
323 | qDebug( "for event '%s' I'm going to perform action %d (script='%s')", (const char*) type, action, (const char*) script ); | 319 | odebug << "for event '" << (const char*) type << "' I'm going to perform action " << action << " (script='" << (const char*) script << "')" << oendl; |
324 | 320 | ||
325 | switch( action ) | 321 | switch( action ) |
326 | { | 322 | { |
327 | case 0: /* Ignore */ return; | 323 | case 0: /* Ignore */ return; |
328 | case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; | 324 | case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; |
329 | case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; | 325 | case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; |
330 | case 3: /* Blink LED */ break; //FIXME: Implement this | 326 | case 3: /* Blink LED */ break; //FIXME: Implement this |
331 | case 4: /* Run Script */ | 327 | case 4: /* Run Script */ |
332 | { | 328 | { |
333 | /** | 329 | /** |
334 | * | 330 | * |
335 | * Script Substitution Information: | 331 | * Script Substitution Information: |
336 | * | 332 | * |
337 | * $SSID = SSID | 333 | * $SSID = SSID |
338 | * $MAC = MAC | 334 | * $MAC = MAC |
339 | * $WEP = Wep | 335 | * $WEP = Wep |
340 | * $CHAN = Channel | 336 | * $CHAN = Channel |
341 | * | 337 | * |
342 | **/ | 338 | **/ |
343 | script = script.replace( QRegExp( "$SSID" ), essid ); | 339 | script = script.replace( QRegExp( "$SSID" ), essid ); |
344 | script = script.replace( QRegExp( "$MAC" ), mac ); | 340 | script = script.replace( QRegExp( "$MAC" ), mac ); |
345 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); | 341 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); |
346 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); | 342 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); |
347 | 343 | ||
348 | qDebug( "going to call script '%s'", (const char*) script ); | 344 | odebug << "going to call script '" << (const char*) script << "'" << oendl; |
349 | ::system( script ); | 345 | ::system( script ); |
350 | qDebug( "script returned." ); | 346 | odebug << "script returned." << oendl; |
351 | return; | 347 | return; |
352 | } | 348 | } |
353 | default: assert( false ); | 349 | default: assert( false ); |
354 | } | 350 | } |
355 | } | 351 | } |
356 | 352 | ||
357 | 353 | ||
358 | void WellenreiterConfigWindow::load() | 354 | void WellenreiterConfigWindow::load() |
359 | { | 355 | { |
360 | #ifdef Q_WS_X11 | 356 | #ifdef Q_WS_X11 |
361 | #warning Persistent Configuration not yet implemented for standalone X11 build | 357 | #warning Persistent Configuration not yet implemented for standalone X11 build |
362 | performAutodetection(); | 358 | performAutodetection(); |
363 | #else | 359 | #else |
364 | qDebug( "loading configuration settings..." ); | 360 | odebug << "loading configuration settings..." << oendl; |
365 | 361 | ||
366 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 362 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
367 | 363 | ||
368 | OConfig* c = oApp->config(); | 364 | OConfig* c = oApp->config(); |
369 | 365 | ||
370 | c->setGroup( "Interface" ); | 366 | c->setGroup( "Interface" ); |
371 | 367 | ||
372 | QString interface = c->readEntry( "name", "<none>" ); | 368 | QString interface = c->readEntry( "name", "<none>" ); |
373 | if ( interface != "<none>" ) | 369 | if ( interface != "<none>" ) |
374 | { | 370 | { |
375 | #if QT_VERSION < 300 | 371 | #if QT_VERSION < 300 |
376 | interfaceName->insertItem( interface, 0 ); | 372 | interfaceName->insertItem( interface, 0 ); |
@@ -430,25 +426,25 @@ void WellenreiterConfigWindow::load() | |||
430 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); | 426 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); |
431 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); | 427 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); |
432 | 428 | ||
433 | #endif | 429 | #endif |
434 | } | 430 | } |
435 | 431 | ||
436 | 432 | ||
437 | void WellenreiterConfigWindow::save() | 433 | void WellenreiterConfigWindow::save() |
438 | { | 434 | { |
439 | #ifdef Q_WS_X11 | 435 | #ifdef Q_WS_X11 |
440 | #warning Persistent Configuration not yet implemented for standalone X11 build | 436 | #warning Persistent Configuration not yet implemented for standalone X11 build |
441 | #else | 437 | #else |
442 | qDebug( "saving configuration settings..." ); | 438 | odebug << "saving configuration settings..." << oendl; |
443 | 439 | ||
444 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 440 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
445 | 441 | ||
446 | OConfig* c = oApp->config(); | 442 | OConfig* c = oApp->config(); |
447 | 443 | ||
448 | c->setGroup( "Interface" ); | 444 | c->setGroup( "Interface" ); |
449 | c->writeEntry( "name", interfaceName->currentText() ); | 445 | c->writeEntry( "name", interfaceName->currentText() ); |
450 | c->writeEntry( "type", deviceType->currentText() ); | 446 | c->writeEntry( "type", deviceType->currentText() ); |
451 | c->writeEntry( "prism", prismHeader->isChecked() ); | 447 | c->writeEntry( "prism", prismHeader->isChecked() ); |
452 | c->writeEntry( "hop", hopChannels->isChecked() ); | 448 | c->writeEntry( "hop", hopChannels->isChecked() ); |
453 | c->writeEntry( "interval", hopInterval->value() ); | 449 | c->writeEntry( "interval", hopInterval->value() ); |
454 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); | 450 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); |