author | mickeyl <mickeyl> | 2004-05-03 12:47:50 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-03 12:47:50 (UTC) |
commit | 0490226f4ed54fdeef5578255594830659a8d3bd (patch) (unidiff) | |
tree | e960e0d3d8f916927a9c7c911b1b496475b21e07 | |
parent | fb6f93892d4d0e0471d62f5b5ab6d9bdef0a5e76 (diff) | |
download | opie-0490226f4ed54fdeef5578255594830659a8d3bd.zip opie-0490226f4ed54fdeef5578255594830659a8d3bd.tar.gz opie-0490226f4ed54fdeef5578255594830659a8d3bd.tar.bz2 |
write more settings into the .config file and read it
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 89ed24c..ae149e2 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -308,176 +308,185 @@ void WellenreiterConfigWindow::performAction( const QString& type, | |||
308 | } | 308 | } |
309 | else if ( type == "station" ) | 309 | else if ( type == "station" ) |
310 | { | 310 | { |
311 | action = newStationAction->currentItem(); | 311 | action = newStationAction->currentItem(); |
312 | script = newStationScript->text(); | 312 | script = newStationScript->text(); |
313 | } | 313 | } |
314 | else | 314 | else |
315 | { | 315 | { |
316 | owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << type << "'" << oendl; | 316 | owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << type << "'" << oendl; |
317 | return; | 317 | return; |
318 | } | 318 | } |
319 | 319 | ||
320 | 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; |
321 | 321 | ||
322 | switch( action ) | 322 | switch( action ) |
323 | { | 323 | { |
324 | case 0: /* Ignore */ return; | 324 | case 0: /* Ignore */ return; |
325 | case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; | 325 | case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; |
326 | case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; | 326 | case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; |
327 | case 3: /* Blink LED */ break; //FIXME: Implement this | 327 | case 3: /* Blink LED */ break; //FIXME: Implement this |
328 | case 4: /* Run Script */ | 328 | case 4: /* Run Script */ |
329 | { | 329 | { |
330 | /** | 330 | /** |
331 | * | 331 | * |
332 | * Script Substitution Information: | 332 | * Script Substitution Information: |
333 | * | 333 | * |
334 | * $SSID = SSID | 334 | * $SSID = SSID |
335 | * $MAC = MAC | 335 | * $MAC = MAC |
336 | * $WEP = Wep | 336 | * $WEP = Wep |
337 | * $CHAN = Channel | 337 | * $CHAN = Channel |
338 | * | 338 | * |
339 | **/ | 339 | **/ |
340 | script = script.replace( QRegExp( "$SSID" ), essid ); | 340 | script = script.replace( QRegExp( "$SSID" ), essid ); |
341 | script = script.replace( QRegExp( "$MAC" ), mac ); | 341 | script = script.replace( QRegExp( "$MAC" ), mac ); |
342 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); | 342 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); |
343 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); | 343 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); |
344 | 344 | ||
345 | odebug << "going to call script '" << script << "'" << oendl; | 345 | odebug << "going to call script '" << script << "'" << oendl; |
346 | ::system( script ); | 346 | ::system( script ); |
347 | odebug << "script returned." << oendl; | 347 | odebug << "script returned." << oendl; |
348 | return; | 348 | return; |
349 | } | 349 | } |
350 | default: assert( false ); | 350 | default: assert( false ); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | void WellenreiterConfigWindow::load() | 355 | void WellenreiterConfigWindow::load() |
356 | { | 356 | { |
357 | #ifdef Q_WS_X11 | 357 | #ifdef Q_WS_X11 |
358 | #warning Persistent Configuration not yet implemented for standalone X11 build | 358 | #warning Persistent Configuration not yet implemented for standalone X11 build |
359 | performAutodetection(); | 359 | performAutodetection(); |
360 | #else | 360 | #else |
361 | odebug << "loading configuration settings..." << oendl; | 361 | odebug << "loading configuration settings..." << oendl; |
362 | 362 | ||
363 | /* 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! */ |
364 | 364 | ||
365 | OConfig* c = oApp->config(); | 365 | OConfig* c = oApp->config(); |
366 | 366 | ||
367 | c->setGroup( "Interface" ); | 367 | c->setGroup( "Interface" ); |
368 | 368 | ||
369 | QString interface = c->readEntry( "name", "<none>" ); | 369 | QString interface = c->readEntry( "name", "<none>" ); |
370 | if ( interface != "<none>" ) | 370 | if ( interface != "<none>" ) |
371 | { | 371 | { |
372 | #if QT_VERSION < 300 | 372 | #if QT_VERSION < 300 |
373 | interfaceName->insertItem( interface, 0 ); | 373 | interfaceName->insertItem( interface, 0 ); |
374 | interfaceName->setCurrentItem( 0 ); | 374 | interfaceName->setCurrentItem( 0 ); |
375 | #else | 375 | #else |
376 | interfaceName->setCurrentText( interface ); | 376 | interfaceName->setCurrentText( interface ); |
377 | #endif | 377 | #endif |
378 | 378 | ||
379 | QString device = c->readEntry( "type", "<select>" ); | 379 | QString device = c->readEntry( "type", "<select>" ); |
380 | #if QT_VERSION < 300 | 380 | #if QT_VERSION < 300 |
381 | for ( int i = 0; i < deviceType->count(); ++i ) | 381 | for ( int i = 0; i < deviceType->count(); ++i ) |
382 | { | 382 | { |
383 | if ( deviceType->text( i ) == device ) | 383 | if ( deviceType->text( i ) == device ) |
384 | { | 384 | { |
385 | deviceType->setCurrentItem( i ); | 385 | deviceType->setCurrentItem( i ); |
386 | break; | 386 | break; |
387 | } | 387 | } |
388 | } | 388 | } |
389 | #else | 389 | #else |
390 | deviceType->setCurrentText( device ); | 390 | deviceType->setCurrentText( device ); |
391 | #endif | 391 | #endif |
392 | } | 392 | } |
393 | else | 393 | else |
394 | { | 394 | { |
395 | performAutodetection(); | 395 | performAutodetection(); |
396 | } | 396 | } |
397 | 397 | ||
398 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); | 398 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); |
399 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); | 399 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); |
400 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); | 400 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); |
401 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); | 401 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); |
402 | 402 | ||
403 | c->setGroup( "Capture" ); | 403 | c->setGroup( "Capture" ); |
404 | writeCaptureFile->setChecked( c->readBoolEntry( "writeCaptureFile", true ) ); | ||
405 | captureFileName->setEnabled( writeCaptureFile->isChecked() ); | ||
406 | getCaptureFileName->setEnabled( writeCaptureFile->isChecked() ); | ||
404 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); | 407 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); |
408 | hexViewBufferUnlimited->setChecked( c->readBoolEntry( "hexViewBufferUnlimited", true ) ); | ||
409 | hexViewBufferLimited->setChecked( !c->readBoolEntry( "hexViewBufferUnlimited", true ) ); | ||
410 | hexViewBufferSize->setValue( c->readNumEntry( "hexViewBufferSize", 2000 ) ); | ||
405 | 411 | ||
406 | c->setGroup( "UI" ); | 412 | c->setGroup( "UI" ); |
407 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); | 413 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); |
408 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); | 414 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); |
409 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); | 415 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); |
410 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm | 416 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm |
411 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); | 417 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); |
412 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click | 418 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click |
413 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); | 419 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); |
414 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click | 420 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click |
415 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); | 421 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); |
416 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand | 422 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand |
417 | 423 | ||
418 | c->setGroup( "GPS" ); | 424 | c->setGroup( "GPS" ); |
419 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); | 425 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); |
420 | #if QT_VERSION < 300 | 426 | #if QT_VERSION < 300 |
421 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); | 427 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); |
422 | gpsdHost->setCurrentItem( 0 ); | 428 | gpsdHost->setCurrentItem( 0 ); |
423 | #else | 429 | #else |
424 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); | 430 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); |
425 | #endif | 431 | #endif |
426 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); | 432 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); |
427 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); | 433 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); |
428 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); | 434 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); |
429 | 435 | ||
430 | #endif | 436 | #endif |
431 | } | 437 | } |
432 | 438 | ||
433 | 439 | ||
434 | void WellenreiterConfigWindow::save() | 440 | void WellenreiterConfigWindow::save() |
435 | { | 441 | { |
436 | #ifdef Q_WS_X11 | 442 | #ifdef Q_WS_X11 |
437 | #warning Persistent Configuration not yet implemented for standalone X11 build | 443 | #warning Persistent Configuration not yet implemented for standalone X11 build |
438 | #else | 444 | #else |
439 | odebug << "saving configuration settings..." << oendl; | 445 | odebug << "saving configuration settings..." << oendl; |
440 | 446 | ||
441 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 447 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
442 | 448 | ||
443 | OConfig* c = oApp->config(); | 449 | OConfig* c = oApp->config(); |
444 | 450 | ||
445 | c->setGroup( "Interface" ); | 451 | c->setGroup( "Interface" ); |
446 | c->writeEntry( "name", interfaceName->currentText() ); | 452 | c->writeEntry( "name", interfaceName->currentText() ); |
447 | c->writeEntry( "type", deviceType->currentText() ); | 453 | c->writeEntry( "type", deviceType->currentText() ); |
448 | c->writeEntry( "prism", prismHeader->isChecked() ); | 454 | c->writeEntry( "prism", prismHeader->isChecked() ); |
449 | c->writeEntry( "hop", hopChannels->isChecked() ); | 455 | c->writeEntry( "hop", hopChannels->isChecked() ); |
450 | c->writeEntry( "interval", hopInterval->value() ); | 456 | c->writeEntry( "interval", hopInterval->value() ); |
451 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); | 457 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); |
452 | 458 | ||
453 | c->setGroup( "Capture" ); | 459 | c->setGroup( "Capture" ); |
460 | c->writeEntry( "writeCaptureFile", writeCaptureFile->isChecked() ); | ||
454 | c->writeEntry( "filename", captureFileName->text() ); | 461 | c->writeEntry( "filename", captureFileName->text() ); |
462 | c->writeEntry( "hexViewBufferUnlimited", hexViewBufferUnlimited->isChecked() ); | ||
463 | c->writeEntry( "hexViewBufferSize", hexViewBufferSize->value() ); | ||
455 | 464 | ||
456 | c->setGroup( "UI" ); | 465 | c->setGroup( "UI" ); |
457 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); | 466 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); |
458 | c->writeEntry( "openTree", openTree->isChecked() ); | 467 | c->writeEntry( "openTree", openTree->isChecked() ); |
459 | c->writeEntry( "disablePM", disablePM->isChecked() ); | 468 | c->writeEntry( "disablePM", disablePM->isChecked() ); |
460 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); | 469 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); |
461 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); | 470 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); |
462 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); | 471 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); |
463 | c->writeEntry( "newClientScript", newClientScript->text() ); | 472 | c->writeEntry( "newClientScript", newClientScript->text() ); |
464 | c->writeEntry( "newStationAction", newStationAction->currentItem() ); | 473 | c->writeEntry( "newStationAction", newStationAction->currentItem() ); |
465 | c->writeEntry( "newStationScript", newStationScript->text() ); | 474 | c->writeEntry( "newStationScript", newStationScript->text() ); |
466 | 475 | ||
467 | c->setGroup( "GPS" ); | 476 | c->setGroup( "GPS" ); |
468 | c->writeEntry( "use", enableGPS->isChecked() ); | 477 | c->writeEntry( "use", enableGPS->isChecked() ); |
469 | c->writeEntry( "host", gpsdHost->currentText() ); | 478 | c->writeEntry( "host", gpsdHost->currentText() ); |
470 | c->writeEntry( "port", gpsdPort->value() ); | 479 | c->writeEntry( "port", gpsdPort->value() ); |
471 | c->writeEntry( "start", startGPS->isChecked() ); | 480 | c->writeEntry( "start", startGPS->isChecked() ); |
472 | c->writeEntry( "command", commandGPS->text() ); | 481 | c->writeEntry( "command", commandGPS->text() ); |
473 | 482 | ||
474 | c->write(); | 483 | c->write(); |
475 | 484 | ||
476 | #endif | 485 | #endif |
477 | } | 486 | } |
478 | 487 | ||
479 | 488 | ||
480 | int WellenreiterConfigWindow::hexViewBuffer() const | 489 | int WellenreiterConfigWindow::hexViewBuffer() const |
481 | { | 490 | { |
482 | return hexViewBufferUnlimited->isChecked() ? -1 : hexViewBufferSize->value(); | 491 | return hexViewBufferUnlimited->isChecked() ? -1 : hexViewBufferSize->value(); |
483 | } | 492 | } |