author | mickeyl <mickeyl> | 2004-01-09 20:01:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-09 20:01:42 (UTC) |
commit | 88af644c534f19e391ebbe8ea0babf3ccf459eb1 (patch) (unidiff) | |
tree | f49e88a6dfc58d3f196e6918bb402a14ee9f0ad0 | |
parent | 56bb9961db1158250bbfe971f4556b56c0bd6581 (diff) | |
download | opie-88af644c534f19e391ebbe8ea0babf3ccf459eb1.zip opie-88af644c534f19e391ebbe8ea0babf3ccf459eb1.tar.gz opie-88af644c534f19e391ebbe8ea0babf3ccf459eb1.tar.bz2 |
save configuration settings in accept(), not in the ~
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 16 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.h | 3 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 3 |
3 files changed, 16 insertions, 6 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 7f39230..9358866 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -47,99 +47,105 @@ WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | |||
47 | 47 | ||
48 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | 48 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) |
49 | :WellenreiterConfigBase( parent, name, true, f ) | 49 | :WellenreiterConfigBase( parent, name, true, f ) |
50 | { | 50 | { |
51 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; | 51 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; |
52 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; | 52 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; |
53 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; | 53 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; |
54 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; | 54 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; |
55 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; | 55 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; |
56 | _devicetype[ "<file>" ] = DEVTYPE_FILE; | 56 | _devicetype[ "<file>" ] = DEVTYPE_FILE; |
57 | 57 | ||
58 | // gather possible interface names from ONetwork | 58 | // gather possible interface names from ONetwork |
59 | ONetwork* net = ONetwork::instance(); | 59 | ONetwork* net = ONetwork::instance(); |
60 | ONetwork::InterfaceIterator it = net->iterator(); | 60 | ONetwork::InterfaceIterator it = net->iterator(); |
61 | while ( it.current() ) | 61 | while ( it.current() ) |
62 | { | 62 | { |
63 | if ( it.current()->isWireless() ) | 63 | if ( it.current()->isWireless() ) |
64 | interfaceName->insertItem( it.current()->name() ); | 64 | interfaceName->insertItem( it.current()->name() ); |
65 | ++it; | 65 | ++it; |
66 | } | 66 | } |
67 | 67 | ||
68 | load(); | 68 | load(); |
69 | 69 | ||
70 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here | 70 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here |
71 | QPushButton* okButton = new QPushButton( "ok", this ); | 71 | QPushButton* okButton = new QPushButton( "ok", this ); |
72 | okButton->show(); | 72 | okButton->show(); |
73 | WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui | 73 | WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui |
74 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); | 74 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | WellenreiterConfigWindow::_instance = this; | 77 | WellenreiterConfigWindow::_instance = this; |
78 | 78 | ||
79 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); | 79 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); |
80 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); | 80 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); |
81 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); | 81 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); |
82 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); | 82 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); |
83 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); | 83 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); |
84 | 84 | ||
85 | // make the checkbox 'channelAll' control all other channels | 85 | // make the checkbox 'channelAll' control all other channels |
86 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); | 86 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); |
87 | 87 | ||
88 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); | 88 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); |
89 | 89 | ||
90 | // hide tab4 (parse) until Wellenreiter 1.2 | 90 | // hide tab4 (parse) until Wellenreiter 1.2 |
91 | tab->removePage( tab_4 ); | 91 | tab->removePage( tab_4 ); |
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | WellenreiterConfigWindow::~WellenreiterConfigWindow() | 95 | void WellenreiterConfigWindow::accept() |
96 | { | 96 | { |
97 | save(); | 97 | save(); |
98 | QDialog::accept(); | ||
99 | } | ||
100 | |||
101 | |||
102 | WellenreiterConfigWindow::~WellenreiterConfigWindow() | ||
103 | { | ||
98 | } | 104 | } |
99 | 105 | ||
100 | 106 | ||
101 | void WellenreiterConfigWindow::performAutodetection() | 107 | void WellenreiterConfigWindow::performAutodetection() |
102 | { | 108 | { |
103 | //TODO: insert modal splash screen here | 109 | //TODO: insert modal splash screen here |
104 | // and sleep a second, so that it looks | 110 | // and sleep a second, so that it looks |
105 | // like we're actually doing something fancy... ;-) | 111 | // like we're actually doing something fancy... ;-) |
106 | 112 | ||
107 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); | 113 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); |
108 | 114 | ||
109 | // try to guess device type | 115 | // try to guess device type |
110 | QFile m( "/proc/modules" ); | 116 | QFile m( "/proc/modules" ); |
111 | if ( m.open( IO_ReadOnly ) ) | 117 | if ( m.open( IO_ReadOnly ) ) |
112 | { | 118 | { |
113 | int devicetype(0); | 119 | int devicetype(0); |
114 | QString line; | 120 | QString line; |
115 | QTextStream modules( &m ); | 121 | QTextStream modules( &m ); |
116 | while( !modules.atEnd() && !devicetype ) | 122 | while( !modules.atEnd() && !devicetype ) |
117 | { | 123 | { |
118 | modules >> line; | 124 | modules >> line; |
119 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | 125 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; |
120 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | 126 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; |
121 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | 127 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; |
122 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | 128 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; |
123 | } | 129 | } |
124 | if ( devicetype ) | 130 | if ( devicetype ) |
125 | { | 131 | { |
126 | deviceType->setCurrentItem( devicetype ); | 132 | deviceType->setCurrentItem( devicetype ); |
127 | _guess = devicetype; | 133 | _guess = devicetype; |
128 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | 134 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); |
129 | } | 135 | } |
130 | } | 136 | } |
131 | } | 137 | } |
132 | 138 | ||
133 | 139 | ||
134 | int WellenreiterConfigWindow::driverType() const | 140 | int WellenreiterConfigWindow::driverType() const |
135 | { | 141 | { |
136 | QString name = deviceType->currentText(); | 142 | QString name = deviceType->currentText(); |
137 | if ( _devicetype.contains( name ) ) | 143 | if ( _devicetype.contains( name ) ) |
138 | { | 144 | { |
139 | return _devicetype[name]; | 145 | return _devicetype[name]; |
140 | } | 146 | } |
141 | else | 147 | else |
142 | { | 148 | { |
143 | return 0; | 149 | return 0; |
144 | } | 150 | } |
145 | }; | 151 | }; |
@@ -263,191 +269,191 @@ bool WellenreiterConfigWindow::useGPS() const | |||
263 | } | 269 | } |
264 | 270 | ||
265 | 271 | ||
266 | const QString WellenreiterConfigWindow::gpsHost() const | 272 | const QString WellenreiterConfigWindow::gpsHost() const |
267 | { | 273 | { |
268 | return useGPS() ? gpsdHost->currentText() : QString::null; | 274 | return useGPS() ? gpsdHost->currentText() : QString::null; |
269 | } | 275 | } |
270 | 276 | ||
271 | 277 | ||
272 | int WellenreiterConfigWindow::gpsPort() const | 278 | int WellenreiterConfigWindow::gpsPort() const |
273 | { | 279 | { |
274 | bool ok; | 280 | bool ok; |
275 | return useGPS() ? gpsdPort->value() : -1; | 281 | return useGPS() ? gpsdPort->value() : -1; |
276 | } | 282 | } |
277 | 283 | ||
278 | 284 | ||
279 | void WellenreiterConfigWindow::performAction( const QString& type, | 285 | void WellenreiterConfigWindow::performAction( const QString& type, |
280 | const QString& essid, | 286 | const QString& essid, |
281 | const QString& mac, | 287 | const QString& mac, |
282 | bool wep, | 288 | bool wep, |
283 | int channel, | 289 | int channel, |
284 | int signal | 290 | int signal |
285 | /* , const GpsLocation& loc */ ) | 291 | /* , const GpsLocation& loc */ ) |
286 | { | 292 | { |
287 | int action; | 293 | int action; |
288 | QString script; | 294 | QString script; |
289 | 295 | ||
290 | if ( type == "network" ) | 296 | if ( type == "network" ) |
291 | { | 297 | { |
292 | action = newNetworkAction->currentItem(); | 298 | action = newNetworkAction->currentItem(); |
293 | script = newNetworkScript->text(); | 299 | script = newNetworkScript->text(); |
294 | } | 300 | } |
295 | else if ( type == "managed" || type == "adhoc" ) | 301 | else if ( type == "managed" || type == "adhoc" ) |
296 | { | 302 | { |
297 | action = newClientAction->currentItem(); | 303 | action = newClientAction->currentItem(); |
298 | script = newClientScript->text(); | 304 | script = newClientScript->text(); |
299 | } | 305 | } |
300 | else if ( type == "station" ) | 306 | else if ( type == "station" ) |
301 | { | 307 | { |
302 | action = newStationAction->currentItem(); | 308 | action = newStationAction->currentItem(); |
303 | script = newStationScript->text(); | 309 | script = newStationScript->text(); |
304 | } | 310 | } |
305 | else | 311 | else |
306 | { | 312 | { |
307 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); | 313 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); |
308 | return; | 314 | return; |
309 | } | 315 | } |
310 | 316 | ||
311 | qDebug( "going to perform action %d (script='%s')", action, (const char*) script ); | 317 | qDebug( "for event '%s' I'm going to perform action %d (script='%s')", (const char*) type, action, (const char*) script ); |
312 | 318 | ||
313 | switch( action ) | 319 | switch( action ) |
314 | { | 320 | { |
315 | case 0: /* Ignore */ return; | 321 | case 0: /* Ignore */ return; |
316 | case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; | 322 | case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; |
317 | case 2: /* Play Click */ ODevice::inst()->touchSound(); return; | 323 | case 2: /* Play Click */ ODevice::inst()->touchSound(); return; |
318 | case 3: /* Blink LED */ break; //FIXME: Implement this | 324 | case 3: /* Blink LED */ break; //FIXME: Implement this |
319 | case 4: /* Run Script */ | 325 | case 4: /* Run Script */ |
320 | { | 326 | { |
321 | /** | 327 | /** |
322 | * | 328 | * |
323 | * Script Substitution Information: | 329 | * Script Substitution Information: |
324 | * | 330 | * |
325 | * $SSID = SSID | 331 | * $SSID = SSID |
326 | * $MAC = MAC | 332 | * $MAC = MAC |
327 | * $WEP = Wep | 333 | * $WEP = Wep |
328 | * $CHAN = Channel | 334 | * $CHAN = Channel |
329 | * | 335 | * |
330 | **/ | 336 | **/ |
331 | script = script.replace( QRegExp( "$SSID" ), essid ); | 337 | script = script.replace( QRegExp( "$SSID" ), essid ); |
332 | script = script.replace( QRegExp( "$MAC" ), mac ); | 338 | script = script.replace( QRegExp( "$MAC" ), mac ); |
333 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); | 339 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); |
334 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); | 340 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); |
335 | 341 | ||
336 | qDebug( "going to call script '%s'", (const char*) script ); | 342 | qDebug( "going to call script '%s'", (const char*) script ); |
337 | ::system( script ); | 343 | ::system( script ); |
338 | qDebug( "script returned." ); | 344 | qDebug( "script returned." ); |
339 | return; | 345 | return; |
340 | } | 346 | } |
341 | default: assert( false ); | 347 | default: assert( false ); |
342 | } | 348 | } |
343 | } | 349 | } |
344 | 350 | ||
345 | 351 | ||
346 | void WellenreiterConfigWindow::load() | 352 | void WellenreiterConfigWindow::load() |
347 | { | 353 | { |
348 | #ifdef Q_WS_X11 | 354 | #ifdef Q_WS_X11 |
349 | #warning Persistent Configuration not yet implemented for standalone X11 build | 355 | #warning Persistent Configuration not yet implemented for standalone X11 build |
350 | performAutodetection(); | 356 | performAutodetection(); |
351 | #else | 357 | #else |
352 | qDebug( "loading configuration settings..." ); | 358 | qDebug( "loading configuration settings..." ); |
353 | 359 | ||
354 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 360 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
355 | 361 | ||
356 | OConfig* c = oApp->config(); | 362 | OConfig* c = oApp->config(); |
357 | 363 | ||
358 | c->setGroup( "Interface" ); | 364 | c->setGroup( "Interface" ); |
359 | 365 | ||
360 | QString interface = c->readEntry( "name", "<none>" ); | 366 | QString interface = c->readEntry( "name", "<none>" ); |
361 | if ( interface != "<none>" ) | 367 | if ( interface != "<none>" ) |
362 | { | 368 | { |
363 | #if QT_VERSION < 300 | 369 | #if QT_VERSION < 300 |
364 | interfaceName->insertItem( interface, 0 ); | 370 | interfaceName->insertItem( interface, 0 ); |
365 | interfaceName->setCurrentItem( 0 ); | 371 | interfaceName->setCurrentItem( 0 ); |
366 | #else | 372 | #else |
367 | interfaceName->setCurrentText( interface ); | 373 | interfaceName->setCurrentText( interface ); |
368 | #endif | 374 | #endif |
369 | 375 | ||
370 | QString device = c->readEntry( "type", "<select>" ); | 376 | QString device = c->readEntry( "type", "<select>" ); |
371 | #if QT_VERSION < 300 | 377 | #if QT_VERSION < 300 |
372 | for ( int i = 0; i < deviceType->count(); ++i ) | 378 | for ( int i = 0; i < deviceType->count(); ++i ) |
373 | { | 379 | { |
374 | if ( deviceType->text( i ) == device ) | 380 | if ( deviceType->text( i ) == device ) |
375 | { | 381 | { |
376 | deviceType->setCurrentItem( i ); | 382 | deviceType->setCurrentItem( i ); |
377 | break; | 383 | break; |
378 | } | 384 | } |
379 | } | 385 | } |
380 | #else | 386 | #else |
381 | deviceType->setCurrentText( device ); | 387 | deviceType->setCurrentText( device ); |
382 | #endif | 388 | #endif |
383 | } | 389 | } |
384 | else | 390 | else |
385 | { | 391 | { |
386 | performAutodetection(); | 392 | performAutodetection(); |
387 | } | 393 | } |
388 | 394 | ||
389 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); | 395 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); |
390 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); | 396 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); |
391 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); | 397 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); |
392 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); | 398 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); |
393 | 399 | ||
394 | c->setGroup( "Capture" ); | 400 | c->setGroup( "Capture" ); |
395 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); | 401 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); |
396 | 402 | ||
397 | c->setGroup( "UI" ); | 403 | c->setGroup( "UI" ); |
398 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); | 404 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); |
399 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); | 405 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); |
400 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); | 406 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); |
401 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 0 ) ); | 407 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm |
402 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); | 408 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); |
403 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 0 ) ); | 409 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click |
404 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); | 410 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); |
405 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 0 ) ); | 411 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click |
406 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); | 412 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); |
407 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand | 413 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand |
408 | 414 | ||
409 | c->setGroup( "GPS" ); | 415 | c->setGroup( "GPS" ); |
410 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); | 416 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); |
411 | #if QT_VERSION < 300 | 417 | #if QT_VERSION < 300 |
412 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); | 418 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); |
413 | gpsdHost->setCurrentItem( 0 ); | 419 | gpsdHost->setCurrentItem( 0 ); |
414 | #else | 420 | #else |
415 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); | 421 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); |
416 | #endif | 422 | #endif |
417 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); | 423 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); |
418 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); | 424 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); |
419 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); | 425 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); |
420 | 426 | ||
421 | #endif | 427 | #endif |
422 | } | 428 | } |
423 | 429 | ||
424 | 430 | ||
425 | void WellenreiterConfigWindow::save() | 431 | void WellenreiterConfigWindow::save() |
426 | { | 432 | { |
427 | #ifdef Q_WS_X11 | 433 | #ifdef Q_WS_X11 |
428 | #warning Persistent Configuration not yet implemented for standalone X11 build | 434 | #warning Persistent Configuration not yet implemented for standalone X11 build |
429 | #else | 435 | #else |
430 | qDebug( "saving configuration settings..." ); | 436 | qDebug( "saving configuration settings..." ); |
431 | 437 | ||
432 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 438 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
433 | 439 | ||
434 | OConfig* c = oApp->config(); | 440 | OConfig* c = oApp->config(); |
435 | 441 | ||
436 | c->setGroup( "Interface" ); | 442 | c->setGroup( "Interface" ); |
437 | c->writeEntry( "name", interfaceName->currentText() ); | 443 | c->writeEntry( "name", interfaceName->currentText() ); |
438 | c->writeEntry( "type", deviceType->currentText() ); | 444 | c->writeEntry( "type", deviceType->currentText() ); |
439 | c->writeEntry( "prism", prismHeader->isChecked() ); | 445 | c->writeEntry( "prism", prismHeader->isChecked() ); |
440 | c->writeEntry( "hop", hopChannels->isChecked() ); | 446 | c->writeEntry( "hop", hopChannels->isChecked() ); |
441 | c->writeEntry( "interval", hopInterval->value() ); | 447 | c->writeEntry( "interval", hopInterval->value() ); |
442 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); | 448 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); |
443 | 449 | ||
444 | c->setGroup( "Capture" ); | 450 | c->setGroup( "Capture" ); |
445 | c->writeEntry( "filename", captureFileName->text() ); | 451 | c->writeEntry( "filename", captureFileName->text() ); |
446 | 452 | ||
447 | c->setGroup( "UI" ); | 453 | c->setGroup( "UI" ); |
448 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); | 454 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); |
449 | c->writeEntry( "openTree", openTree->isChecked() ); | 455 | c->writeEntry( "openTree", openTree->isChecked() ); |
450 | c->writeEntry( "disablePM", disablePM->isChecked() ); | 456 | c->writeEntry( "disablePM", disablePM->isChecked() ); |
451 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); | 457 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); |
452 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); | 458 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); |
453 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); | 459 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); |
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h index 5c998cb..d31d1e8 100644 --- a/noncore/net/wellenreiter/gui/configwindow.h +++ b/noncore/net/wellenreiter/gui/configwindow.h | |||
@@ -23,59 +23,60 @@ | |||
23 | #include <qmap.h> | 23 | #include <qmap.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | 26 | ||
27 | const int DEVTYPE_SELECT = 0; | 27 | const int DEVTYPE_SELECT = 0; |
28 | const int DEVTYPE_CISCO = 1; | 28 | const int DEVTYPE_CISCO = 1; |
29 | const int DEVTYPE_WLAN_NG = 2; | 29 | const int DEVTYPE_WLAN_NG = 2; |
30 | const int DEVTYPE_HOSTAP = 3; | 30 | const int DEVTYPE_HOSTAP = 3; |
31 | const int DEVTYPE_ORINOCO = 4; | 31 | const int DEVTYPE_ORINOCO = 4; |
32 | const int DEVTYPE_MANUAL = 5; | 32 | const int DEVTYPE_MANUAL = 5; |
33 | const int DEVTYPE_FILE = 6; | 33 | const int DEVTYPE_FILE = 6; |
34 | 34 | ||
35 | class WellenreiterConfigWindow; | 35 | class WellenreiterConfigWindow; |
36 | 36 | ||
37 | class WellenreiterConfigWindow : public WellenreiterConfigBase | 37 | class WellenreiterConfigWindow : public WellenreiterConfigBase |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | 40 | ||
41 | public: | 41 | public: |
42 | WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); | 42 | WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); |
43 | ~WellenreiterConfigWindow(); | 43 | ~WellenreiterConfigWindow(); |
44 | 44 | ||
45 | int driverType() const; | 45 | int driverType() const; |
46 | const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ }; | 46 | const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ }; |
47 | const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; | 47 | const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; |
48 | static WellenreiterConfigWindow* instance() { return _instance; }; | 48 | static WellenreiterConfigWindow* instance() { return _instance; }; |
49 | 49 | ||
50 | int hoppingInterval() const; | 50 | int hoppingInterval() const; |
51 | bool usePrismHeader() const; | 51 | bool usePrismHeader() const; |
52 | bool isChannelChecked( int ) const; | 52 | bool isChannelChecked( int ) const; |
53 | 53 | ||
54 | bool useGPS() const; | 54 | bool useGPS() const; |
55 | const QString gpsHost() const; | 55 | const QString gpsHost() const; |
56 | int gpsPort() const; | 56 | int gpsPort() const; |
57 | 57 | ||
58 | void save(); | 58 | void save(); |
59 | void load(); | 59 | void load(); |
60 | 60 | ||
61 | public slots: | 61 | public slots: |
62 | void changedDeviceType(int); | 62 | void changedDeviceType(int); |
63 | void changedNetworkAction(int t); | 63 | void changedNetworkAction(int t); |
64 | void changedClientAction(int t); | 64 | void changedClientAction(int t); |
65 | void changedStationAction(int t); | 65 | void changedStationAction(int t); |
66 | void getCaptureFileNameClicked(); | 66 | void getCaptureFileNameClicked(); |
67 | void performAutodetection(); | 67 | void performAutodetection(); |
68 | void channelAllClicked(int); | 68 | void channelAllClicked(int); |
69 | void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ ); | 69 | void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ ); |
70 | 70 | ||
71 | protected: | 71 | protected slots: |
72 | void synchronizeActionsAndScripts(); | 72 | void synchronizeActionsAndScripts(); |
73 | virtual void accept(); | ||
73 | 74 | ||
74 | protected: | 75 | protected: |
75 | QMap<QString, int> _devicetype; | 76 | QMap<QString, int> _devicetype; |
76 | static WellenreiterConfigWindow* _instance; | 77 | static WellenreiterConfigWindow* _instance; |
77 | int _guess; | 78 | int _guess; |
78 | 79 | ||
79 | }; | 80 | }; |
80 | 81 | ||
81 | #endif | 82 | #endif |
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index fd88b63..10ead53 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -387,96 +387,99 @@ void MScanListView::addService( const QString& name, const OMacAddress& macaddr, | |||
387 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 387 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
388 | { | 388 | { |
389 | if ( !item ) return; | 389 | if ( !item ) return; |
390 | 390 | ||
391 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 391 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
392 | 392 | ||
393 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 393 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
394 | (const char*) itm->text(0), (const char*) itm->type, col ); | 394 | (const char*) itm->text(0), (const char*) itm->type, col ); |
395 | 395 | ||
396 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 396 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
397 | { | 397 | { |
398 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 398 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
399 | 399 | ||
400 | QPopupMenu m( this ); | 400 | QPopupMenu m( this ); |
401 | m.insertItem( entry, 37773, 0 ); | 401 | m.insertItem( entry, 37773, 0 ); |
402 | int result = m.exec( QCursor::pos() ); | 402 | int result = m.exec( QCursor::pos() ); |
403 | if ( result == 37773 ) | 403 | if ( result == 37773 ) |
404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | //============================================================ | 408 | //============================================================ |
409 | // MScanListItem | 409 | // MScanListItem |
410 | //============================================================ | 410 | //============================================================ |
411 | 411 | ||
412 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, | 412 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
413 | bool wep, int channel, int signal, bool probed ) | 413 | bool wep, int channel, int signal, bool probed ) |
414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
416 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 416 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
417 | { | 417 | { |
418 | #ifdef DEBUG | 418 | #ifdef DEBUG |
419 | qDebug( "creating scanlist item" ); | 419 | qDebug( "creating scanlist item" ); |
420 | #endif | 420 | #endif |
421 | 421 | ||
422 | if ( WellenreiterConfigWindow::instance() ) | 422 | if ( WellenreiterConfigWindow::instance() ) |
423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
424 | 424 | ||
425 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); | 425 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
426 | } | 426 | } |
427 | 427 | ||
428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
429 | bool wep, int channel, int signal ) | 429 | bool wep, int channel, int signal ) |
430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
431 | { | 431 | { |
432 | #ifdef DEBUG | 432 | #ifdef DEBUG |
433 | qDebug( "creating scanlist item" ); | 433 | qDebug( "creating scanlist item" ); |
434 | #endif | 434 | #endif |
435 | if ( WellenreiterConfigWindow::instance() ) | ||
436 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | ||
437 | |||
435 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); | 438 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
436 | } | 439 | } |
437 | 440 | ||
438 | const QString& MScanListItem::essid() const | 441 | const QString& MScanListItem::essid() const |
439 | { | 442 | { |
440 | if ( type == "network" ) | 443 | if ( type == "network" ) |
441 | return _essid; | 444 | return _essid; |
442 | else | 445 | else |
443 | return ( (MScanListItem*) parent() )->essid(); | 446 | return ( (MScanListItem*) parent() )->essid(); |
444 | } | 447 | } |
445 | 448 | ||
446 | OListViewItem* MScanListItem::childFactory() | 449 | OListViewItem* MScanListItem::childFactory() |
447 | { | 450 | { |
448 | return new MScanListItem( this ); | 451 | return new MScanListItem( this ); |
449 | } | 452 | } |
450 | 453 | ||
451 | void MScanListItem::serializeTo( QDataStream& s ) const | 454 | void MScanListItem::serializeTo( QDataStream& s ) const |
452 | { | 455 | { |
453 | #ifdef DEBUG | 456 | #ifdef DEBUG |
454 | qDebug( "serializing MScanListItem" ); | 457 | qDebug( "serializing MScanListItem" ); |
455 | #endif | 458 | #endif |
456 | OListViewItem::serializeTo( s ); | 459 | OListViewItem::serializeTo( s ); |
457 | 460 | ||
458 | s << _type; | 461 | s << _type; |
459 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 462 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
460 | } | 463 | } |
461 | 464 | ||
462 | void MScanListItem::serializeFrom( QDataStream& s ) | 465 | void MScanListItem::serializeFrom( QDataStream& s ) |
463 | { | 466 | { |
464 | #ifdef DEBUG | 467 | #ifdef DEBUG |
465 | qDebug( "serializing MScanListItem" ); | 468 | qDebug( "serializing MScanListItem" ); |
466 | #endif | 469 | #endif |
467 | OListViewItem::serializeFrom( s ); | 470 | OListViewItem::serializeFrom( s ); |
468 | 471 | ||
469 | char wep; | 472 | char wep; |
470 | s >> _type; | 473 | s >> _type; |
471 | s >> (Q_UINT8) wep; | 474 | s >> (Q_UINT8) wep; |
472 | _wep = (wep == 'y'); | 475 | _wep = (wep == 'y'); |
473 | 476 | ||
474 | QString name; | 477 | QString name; |
475 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 478 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
476 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 479 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
477 | if ( _wep ) | 480 | if ( _wep ) |
478 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 481 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
479 | listView()->triggerUpdate(); | 482 | listView()->triggerUpdate(); |
480 | } | 483 | } |
481 | 484 | ||
482 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) | 485 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) |