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 | |
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
-rw-r--r-- | noncore/net/wellenreiter/gui/configbase.ui | 470 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 98 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.h | 6 |
3 files changed, 344 insertions, 230 deletions
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 @@ -1,133 +1,382 @@ <!DOCTYPE UI><UI> <class>WellenreiterConfigBase</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>WellenreiterConfigBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>303</width> - <height>287</height> + <width>286</width> + <height>345</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Wellenreiter II COnfiguration Dialog</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="0" column="0" > <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Interface</string> </attribute> - <grid> + <vbox> <property stdset="1"> <name>margin</name> - <number>5</number> + <number>11</number> </property> <property stdset="1"> <name>spacing</name> - <number>3</number> + <number>6</number> </property> - <widget row="0" column="0" > - <class>QLabel</class> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout7</cstring> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="1" column="1" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string><select></string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>cisco</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>wlan-ng</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>hostap</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>orinoco</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string><manual></string> + </property> + </item> + <item> + <property> + <name>text</name> + <string><file></string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>deviceType</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property> + <name>whatsThis</name> + <string>Choose the type of driver used for sniffing.</string> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_3</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>text</name> + <string>Driver:</string> + </property> + </widget> + <widget row="0" column="1" > + <class>QComboBox</class> + <property stdset="1"> + <name>name</name> + <cstring>interfaceName</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>editable</name> + <bool>false</bool> + </property> + <property> + <name>whatsThis</name> + <string>Choose the interface used for sniffing.</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_2</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>text</name> + <string>Name:</string> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1_2</cstring> + <cstring>Layout5</cstring> </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>autodetect</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Perform Autodetection</string> + </property> + </widget> + </hbox> + </widget> + <widget> + <class>QCheckBox</class> <property stdset="1"> - <name>enabled</name> - <bool>true</bool> + <name>name</name> + <cstring>prismHeader</cstring> </property> <property stdset="1"> <name>text</name> - <string>Name:</string> + <string>Use additional PRISM header</string> </property> </widget> - <widget row="1" column="0" > - <class>QLabel</class> - <property stdset="1"> + <spacer> + <property> <name>name</name> - <cstring>TextLabel2_3</cstring> + <cstring>Spacer4</cstring> </property> <property stdset="1"> - <name>enabled</name> - <bool>true</bool> + <name>orientation</name> + <enum>Vertical</enum> </property> <property stdset="1"> - <name>text</name> - <string>Driver:</string> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout6</cstring> </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>hopChannels</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Hop Channels</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>every</string> + </property> + </widget> + <widget> + <class>QSpinBox</class> + <property stdset="1"> + <name>name</name> + <cstring>hopInterval</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>suffix</name> + <string> ms</string> + </property> + <property stdset="1"> + <name>maxValue</name> + <number>2000</number> + </property> + <property stdset="1"> + <name>minValue</name> + <number>100</number> + </property> + <property stdset="1"> + <name>lineStep</name> + <number>100</number> + </property> + <property stdset="1"> + <name>value</name> + <number>1000</number> + </property> + <property> + <name>whatsThis</name> + <string>Choose the channel hop interval.</string> + </property> + </widget> + </hbox> </widget> - <widget row="2" column="0" rowspan="1" colspan="4" > + <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>prismHeader</cstring> + <cstring>adaptiveHopping</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> </property> <property stdset="1"> <name>text</name> - <string>Use additional PRISM header</string> + <string>Use Adaptive(TM) Hop Scheme</string> </property> </widget> - <widget row="6" column="0" rowspan="1" colspan="4" > + <widget> <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox1</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>title</name> <string>Scan on channel</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>4</number> </property> @@ -281,222 +530,49 @@ <widget row="2" column="3" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel13</cstring> </property> <property stdset="1"> <name>text</name> <string>13</string> </property> </widget> <widget row="2" column="4" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel14</cstring> </property> <property stdset="1"> <name>text</name> <string>14</string> </property> </widget> </grid> </widget> - <widget row="0" column="1" rowspan="1" colspan="3" > - <class>QComboBox</class> - <property stdset="1"> - <name>name</name> - <cstring>interfaceName</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>editable</name> - <bool>false</bool> - </property> - <property> - <name>whatsThis</name> - <string>Choose the interface used for sniffing.</string> - </property> - </widget> - <widget row="1" column="1" rowspan="1" colspan="3" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string><select></string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>cisco</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>wlan-ng</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>hostap</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>orinoco</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string><manual></string> - </property> - </item> - <item> - <property> - <name>text</name> - <string><file></string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>deviceType</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>true</bool> - </property> - <property> - <name>whatsThis</name> - <string>Choose the type of driver used for sniffing.</string> - </property> - </widget> - <spacer row="3" column="0" > - <property> - <name>name</name> - <cstring>Spacer4</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <widget row="4" column="2" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>every</string> - </property> - </widget> - <widget row="4" column="0" rowspan="1" colspan="2" > - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>hopChannels</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Hop Channels</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> - </property> - </widget> - <widget row="4" column="3" > - <class>QSpinBox</class> - <property stdset="1"> - <name>name</name> - <cstring>hopInterval</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>suffix</name> - <string> ms</string> - </property> - <property stdset="1"> - <name>maxValue</name> - <number>2000</number> - </property> - <property stdset="1"> - <name>minValue</name> - <number>100</number> - </property> - <property stdset="1"> - <name>lineStep</name> - <number>100</number> - </property> - <property stdset="1"> - <name>value</name> - <number>1000</number> - </property> - <property> - <name>whatsThis</name> - <string>Choose the channel hop interval.</string> - </property> - </widget> - <widget row="5" column="0" rowspan="1" colspan="4" > - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>adaptiveHopping</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> - </property> - <property stdset="1"> - <name>text</name> - <string>Use Adaptive(TM) Hop Scheme</string> - </property> - </widget> - </grid> + </vbox> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Capture</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="2" column="0" rowspan="1" colspan="3" > <class>ProtocolListView</class> <property stdset="1"> <name>name</name> 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 @@ -36,97 +36,108 @@ #include <opie2/oconfig.h> WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) :WellenreiterConfigBase( parent, name, true, f ) { _devicetype[ "cisco" ] = DEVTYPE_CISCO; _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; _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 - { - // 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 ); 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 ); + } + } +} + + int WellenreiterConfigWindow::driverType() const { QString name = deviceType->currentText(); if ( _devicetype.contains( name ) ) { return _devicetype[name]; } else { return 0; } }; int WellenreiterConfigWindow::hoppingInterval() const { return hopInterval->cleanText().toInt(); } bool WellenreiterConfigWindow::usePrismHeader() const { return prismHeader->isChecked(); } @@ -200,89 +211,116 @@ void WellenreiterConfigWindow::channelAllClicked(int state) channel13->setChecked( b ); channel14->setChecked( b ); } bool WellenreiterConfigWindow::useGPS() const { return enableGPS->isChecked(); } 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 ) ); 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! */ OConfig* c = oApp->config(); c->setGroup( "Interface" ); c->writeEntry( "name", interfaceName->currentText() ); c->writeEntry( "type", deviceType->currentText() ); c->writeEntry( "prism", prismHeader->isChecked() ); c->writeEntry( "hop", hopChannels->isChecked() ); c->writeEntry( "interval", hopInterval->value() ); c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); c->setGroup( "Capture" ); 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 @@ -17,55 +17,55 @@ #define WELLENREITERCONFIGWINDOW_H #include "configbase.h" #include <qmap.h> #include <qcombobox.h> #include <qstring.h> const int DEVTYPE_SELECT = 0; const int DEVTYPE_CISCO = 1; const int DEVTYPE_WLAN_NG = 2; const int DEVTYPE_HOSTAP = 3; const int DEVTYPE_ORINOCO = 4; const int DEVTYPE_MANUAL = 5; const int DEVTYPE_FILE = 6; class WellenreiterConfigWindow; class WellenreiterConfigWindow : public WellenreiterConfigBase { Q_OBJECT 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();*/ }; static WellenreiterConfigWindow* instance() { return _instance; }; int hoppingInterval() const; bool usePrismHeader() const; bool isChannelChecked( int ) const; bool useGPS() const; const QString gpsHost() const; int gpsPort() const; void save(); - bool load(); + void load(); public slots: void changedDeviceType(int); void getCaptureFileNameClicked(); - + void performAutodetection(); void channelAllClicked(int); protected: QMap<QString, int> _devicetype; static WellenreiterConfigWindow* _instance; int _guess; }; #endif |