Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 1341d03..7f39230 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -13,40 +13,44 @@ | |||
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 | /* 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 <opie/odevice.h> | ||
26 | using namespace Opie; | ||
25 | #endif | 27 | #endif |
26 | 28 | ||
27 | /* QT */ | 29 | /* QT */ |
28 | #include <qapplication.h> | 30 | #include <qapplication.h> |
29 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
30 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
31 | #include <qfile.h> | 33 | #include <qfile.h> |
32 | #include <qlineedit.h> | 34 | #include <qlineedit.h> |
33 | #include <qlayout.h> | 35 | #include <qlayout.h> |
34 | #include <qmap.h> | 36 | #include <qmap.h> |
35 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
36 | #include <qtabwidget.h> | 38 | #include <qtabwidget.h> |
37 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
38 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
39 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
40 | 42 | ||
43 | /* POSIX */ | ||
44 | #include <assert.h> | ||
41 | 45 | ||
42 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | 46 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; |
43 | 47 | ||
44 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | 48 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) |
45 | :WellenreiterConfigBase( parent, name, true, f ) | 49 | :WellenreiterConfigBase( parent, name, true, f ) |
46 | { | 50 | { |
47 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; | 51 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; |
48 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; | 52 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; |
49 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; | 53 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; |
50 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; | 54 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; |
51 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; | 55 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; |
52 | _devicetype[ "<file>" ] = DEVTYPE_FILE; | 56 | _devicetype[ "<file>" ] = DEVTYPE_FILE; |
@@ -263,60 +267,88 @@ const QString WellenreiterConfigWindow::gpsHost() const | |||
263 | { | 267 | { |
264 | return useGPS() ? gpsdHost->currentText() : QString::null; | 268 | return useGPS() ? gpsdHost->currentText() : QString::null; |
265 | } | 269 | } |
266 | 270 | ||
267 | 271 | ||
268 | int WellenreiterConfigWindow::gpsPort() const | 272 | int WellenreiterConfigWindow::gpsPort() const |
269 | { | 273 | { |
270 | bool ok; | 274 | bool ok; |
271 | return useGPS() ? gpsdPort->value() : -1; | 275 | return useGPS() ? gpsdPort->value() : -1; |
272 | } | 276 | } |
273 | 277 | ||
274 | 278 | ||
275 | void WellenreiterConfigWindow::performAction( const QString& type ) | 279 | void WellenreiterConfigWindow::performAction( const QString& type, |
280 | const QString& essid, | ||
281 | const QString& mac, | ||
282 | bool wep, | ||
283 | int channel, | ||
284 | int signal | ||
285 | /* , const GpsLocation& loc */ ) | ||
276 | { | 286 | { |
277 | int action; | 287 | int action; |
278 | QString script; | 288 | QString script; |
279 | 289 | ||
280 | if ( type == "network" ) | 290 | if ( type == "network" ) |
281 | { | 291 | { |
282 | action = newNetworkAction->currentItem(); | 292 | action = newNetworkAction->currentItem(); |
283 | script = newNetworkScript->text(); | 293 | script = newNetworkScript->text(); |
284 | } | 294 | } |
285 | else if ( type == "managed" || type == "adhoc" ) | 295 | else if ( type == "managed" || type == "adhoc" ) |
286 | { | 296 | { |
287 | action = newClientAction->currentItem(); | 297 | action = newClientAction->currentItem(); |
288 | script = newClientScript->text(); | 298 | script = newClientScript->text(); |
289 | } | 299 | } |
290 | else if ( type == "station" ) | 300 | else if ( type == "station" ) |
291 | { | 301 | { |
292 | action = newStationAction->currentItem(); | 302 | action = newStationAction->currentItem(); |
293 | script = newStationScript->text(); | 303 | script = newStationScript->text(); |
294 | } | 304 | } |
295 | else | 305 | else |
296 | { | 306 | { |
297 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); | 307 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); |
298 | return; | 308 | return; |
299 | } | 309 | } |
300 | 310 | ||
301 | qDebug( "going to perform action %d (script='%s')", action, (const char*) script ); | 311 | qDebug( "going to perform action %d (script='%s')", action, (const char*) script ); |
302 | 312 | ||
303 | /* | 313 | switch( action ) |
304 | 314 | { | |
305 | if ( sound == "Ignore" ) return; | 315 | case 0: /* Ignore */ return; |
306 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); | 316 | case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; |
307 | else if ( sound == "Key" ) ODevice::inst()->keySound(); | 317 | case 2: /* Play Click */ ODevice::inst()->touchSound(); return; |
308 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); | 318 | case 3: /* Blink LED */ break; //FIXME: Implement this |
309 | 319 | case 4: /* Run Script */ | |
310 | */ | 320 | { |
321 | /** | ||
322 | * | ||
323 | * Script Substitution Information: | ||
324 | * | ||
325 | * $SSID = SSID | ||
326 | * $MAC = MAC | ||
327 | * $WEP = Wep | ||
328 | * $CHAN = Channel | ||
329 | * | ||
330 | **/ | ||
331 | script = script.replace( QRegExp( "$SSID" ), essid ); | ||
332 | script = script.replace( QRegExp( "$MAC" ), mac ); | ||
333 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); | ||
334 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); | ||
335 | |||
336 | qDebug( "going to call script '%s'", (const char*) script ); | ||
337 | ::system( script ); | ||
338 | qDebug( "script returned." ); | ||
339 | return; | ||
340 | } | ||
341 | default: assert( false ); | ||
342 | } | ||
311 | } | 343 | } |
312 | 344 | ||
313 | 345 | ||
314 | void WellenreiterConfigWindow::load() | 346 | void WellenreiterConfigWindow::load() |
315 | { | 347 | { |
316 | #ifdef Q_WS_X11 | 348 | #ifdef Q_WS_X11 |
317 | #warning Persistent Configuration not yet implemented for standalone X11 build | 349 | #warning Persistent Configuration not yet implemented for standalone X11 build |
318 | performAutodetection(); | 350 | performAutodetection(); |
319 | #else | 351 | #else |
320 | qDebug( "loading configuration settings..." ); | 352 | qDebug( "loading configuration settings..." ); |
321 | 353 | ||
322 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 354 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |