author | mickeyl <mickeyl> | 2003-10-04 00:30:57 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-04 00:30:57 (UTC) |
commit | e2716e3862915582d0ce48aaacc967f5b0cf6550 (patch) (side-by-side diff) | |
tree | a27e94a9d813f843dcb26c22ee31f7ce21142109 /noncore/net/wellenreiter/gui/configwindow.cpp | |
parent | 120b0fe68c1352ba03ad6e73d26bcbe8452ef6ed (diff) | |
download | opie-e2716e3862915582d0ce48aaacc967f5b0cf6550.zip opie-e2716e3862915582d0ce48aaacc967f5b0cf6550.tar.gz opie-e2716e3862915582d0ce48aaacc967f5b0cf6550.tar.bz2 |
perform autodetection only if no configuration exists or on demand
Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 94 |
1 files changed, 66 insertions, 28 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 84d4c63..3ec190b 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp @@ -48,72 +48,83 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char _devicetype[ "<file>" ] = DEVTYPE_FILE; // gather possible interface names from ONetwork ONetwork* net = ONetwork::instance(); ONetwork::InterfaceIterator it = net->iterator(); while ( it.current() ) { if ( it.current()->isWireless() ) interfaceName->insertItem( it.current()->name() ); ++it; } - if ( !load() ) // no configuration present + load(); + + #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here + QPushButton* okButton = new QPushButton( "ok", this ); + okButton->show(); + WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui + connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); + #endif + + WellenreiterConfigWindow::_instance = this; + + connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); + connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); + + // make the checkbox 'channelAll' control all other channels + connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); + + connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); +}; + + +WellenreiterConfigWindow::~WellenreiterConfigWindow() { + save(); +} + + +void WellenreiterConfigWindow::performAutodetection() +{ + //TODO: insert modal splash screen here + // and sleep a second, so that it looks + // like we're actually doing something fancy... ;-) + + qDebug( "WellenreiterConfigWindow::performAutodetection()" ); + // try to guess device type QFile m( "/proc/modules" ); if ( m.open( IO_ReadOnly ) ) { int devicetype(0); QString line; QTextStream modules( &m ); while( !modules.atEnd() && !devicetype ) { modules >> line; if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; } if ( devicetype ) { deviceType->setCurrentItem( devicetype ); _guess = devicetype; qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); } } } - #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here - QPushButton* okButton = new QPushButton( "ok", this ); - okButton->show(); - WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui - connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); - #endif - - WellenreiterConfigWindow::_instance = this; - - connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); - connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); - - // make the checkbox 'channelAll' control all other channels - connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); -}; - - -WellenreiterConfigWindow::~WellenreiterConfigWindow() -{ - save(); -} - int WellenreiterConfigWindow::driverType() const { QString name = deviceType->currentText(); if ( _devicetype.contains( name ) ) { return _devicetype[name]; } else { return 0; } @@ -212,39 +223,67 @@ const QString WellenreiterConfigWindow::gpsHost() const { return useGPS() ? gpsdHost->currentText() : QString::null; } int WellenreiterConfigWindow::gpsPort() const { bool ok; return useGPS() ? gpsdPort->value() : -1; } -bool WellenreiterConfigWindow::load() +void WellenreiterConfigWindow::load() { #ifdef Q_WS_X11 #warning Persistent Configuration not yet implemented for standalone X11 build - return false; + performAutodetection(); #else qDebug( "loading configuration settings..." ); /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ OConfig* c = oApp->config(); c->setGroup( "Interface" ); - //interfaceName->setCurrentText( c->readEntry( "name" ) ); - //deviceType->setCurrentText( c->readEntry( "type", "<select>" ) ); + + QString interface = c->readEntry( "name", "<none>" ); + if ( interface != "<none>" ) + { +#if QT_VERSION < 300 + interfaceName->insertItem( interface, 0 ); + interfaceName->setCurrentItem( 0 ); +#else + interfaceName->setCurrentText( interface ); +#endif + + QString device = c->readEntry( "type", "<select>" ); +#if QT_VERSION < 300 + for ( int i = 0; i < deviceType->count(); ++i ) + { + if ( deviceType->text( i ) == device ) + { + deviceType->setCurrentItem( i ); + break; + } + } +#else + deviceType->setCurrentText( device ); +#endif + } + else + { + performAutodetection(); + } + prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); hopInterval->setValue( c->readNumEntry( "interval", 100 ) ); adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); c->setGroup( "Capture" ); captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); c->setGroup( "UI" ); lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); openTree->setChecked( c->readBoolEntry( "openTree", true ) ); disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); @@ -252,25 +291,24 @@ bool WellenreiterConfigWindow::load() c->setGroup( "GPS" ); enableGPS->setChecked( c->readBoolEntry( "use", false ) ); #if QT_VERSION < 300 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); gpsdHost->setCurrentItem( 0 ); #else gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); #endif gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); startGPS->setChecked( c->readBoolEntry( "start", false ) ); commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); - return false; // false = perform autodetection; true = use config settings #endif } void WellenreiterConfigWindow::save() { #ifdef Q_WS_X11 #warning Persistent Configuration not yet implemented for standalone X11 build #else qDebug( "saving configuration settings..." ); /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |