From e2716e3862915582d0ce48aaacc967f5b0cf6550 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sat, 04 Oct 2003 00:30:57 +0000 Subject: perform autodetection only if no configuration exists or on demand --- diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index d7ab3bb..4fc8ea1 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -11,8 +11,8 @@ 0 0 - 303 - 287 + 286 + 345 @@ -56,57 +56,306 @@ title Interface - + margin - 5 + 11 spacing - 3 + 6 - - QLabel + + QLayoutWidget + + name + Layout7 + + + + margin + 0 + + + spacing + 6 + + + QComboBox + + + text + <select> + + + + + text + cisco + + + + + text + wlan-ng + + + + + text + hostap + + + + + text + orinoco + + + + + text + <manual> + + + + + text + <file> + + + + name + deviceType + + + enabled + true + + + sizePolicy + + 7 + 0 + + + + whatsThis + Choose the type of driver used for sniffing. + + + + QLabel + + name + TextLabel2_3 + + + enabled + true + + + text + Driver: + + + + QComboBox + + name + interfaceName + + + enabled + true + + + sizePolicy + + 7 + 0 + + + + editable + false + + + whatsThis + Choose the interface used for sniffing. + + + + QLabel + + name + TextLabel1_2 + + + enabled + true + + + text + Name: + + + + + + QLayoutWidget name - TextLabel1_2 + Layout5 + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + autodetect + + + text + Perform Autodetection + + + + + + QCheckBox - enabled - true + name + prismHeader text - Name: + Use additional PRISM header - - QLabel - + + name - TextLabel2_3 + Spacer4 - enabled - true + orientation + Vertical - text - Driver: + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout6 + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + hopChannels + + + text + Hop Channels + + + checked + true + + + + QLabel + + name + TextLabel1 + + + text + every + + + + QSpinBox + + name + hopInterval + + + enabled + true + + + suffix + ms + + + maxValue + 2000 + + + minValue + 100 + + + lineStep + 100 + + + value + 1000 + + + whatsThis + Choose the channel hop interval. + + + - + QCheckBox name - prismHeader + adaptiveHopping + + + enabled + false text - Use additional PRISM header + Use Adaptive(TM) Hop Scheme - + QGroupBox name @@ -302,180 +551,7 @@ - - QComboBox - - name - interfaceName - - - enabled - true - - - editable - false - - - whatsThis - Choose the interface used for sniffing. - - - - QComboBox - - - text - <select> - - - - - text - cisco - - - - - text - wlan-ng - - - - - text - hostap - - - - - text - orinoco - - - - - text - <manual> - - - - - text - <file> - - - - name - deviceType - - - enabled - true - - - whatsThis - Choose the type of driver used for sniffing. - - - - - name - Spacer4 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QLabel - - name - TextLabel1 - - - text - every - - - - QCheckBox - - name - hopChannels - - - text - Hop Channels - - - checked - true - - - - QSpinBox - - name - hopInterval - - - enabled - true - - - suffix - ms - - - maxValue - 2000 - - - minValue - 100 - - - lineStep - 100 - - - value - 1000 - - - whatsThis - Choose the channel hop interval. - - - - QCheckBox - - name - adaptiveHopping - - - enabled - false - - - text - Use Adaptive(TM) Hop Scheme - - - + QWidget 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 @@ -57,31 +57,7 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char ++it; } - if ( !load() ) // no configuration present - { - // 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 ); - } - } - } + load(); #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here QPushButton* okButton = new QPushButton( "ok", this ); @@ -97,6 +73,8 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char // make the checkbox 'channelAll' control all other channels connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); + + connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); }; @@ -106,6 +84,39 @@ WellenreiterConfigWindow::~WellenreiterConfigWindow() } +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 ); + } + } +} + + int WellenreiterConfigWindow::driverType() const { QString name = deviceType->currentText(); @@ -221,11 +232,11 @@ int WellenreiterConfigWindow::gpsPort() const } -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..." ); @@ -234,8 +245,36 @@ bool WellenreiterConfigWindow::load() OConfig* c = oApp->config(); c->setGroup( "Interface" ); - //interfaceName->setCurrentText( c->readEntry( "name" ) ); - //deviceType->setCurrentText( c->readEntry( "type", "" ); +#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 ) ); @@ -261,7 +300,6 @@ bool WellenreiterConfigWindow::load() 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 } diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h index 2986320..80b4d2b 100644 --- a/noncore/net/wellenreiter/gui/configwindow.h +++ b/noncore/net/wellenreiter/gui/configwindow.h @@ -38,7 +38,7 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase public: WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); ~WellenreiterConfigWindow(); - + int driverType() const; const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ }; const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; @@ -53,12 +53,12 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase int gpsPort() const; void save(); - bool load(); + void load(); public slots: void changedDeviceType(int); void getCaptureFileNameClicked(); - + void performAutodetection(); void channelAllClicked(int); protected: -- cgit v0.9.0.2