From 13e8e8cbaede72948d3901a1a903eba43854d770 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Mon, 31 Mar 2003 14:30:17 +0000 Subject: - initial attempt to autodetect driver - add possibility to play sounds when receiving beacon and/or found a new network --- (limited to 'noncore/net/wellenreiter') diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index fa727f9..dda7ba0 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -11,8 +11,8 @@ 0 0 - 212 - 267 + 220 + 306 @@ -28,7 +28,7 @@ margin - 4 + 3 spacing @@ -325,91 +325,136 @@ + QCheckBox + + name + groupNetworks + + + enabled + false + + + text + Group Detected Networks + + + + QCheckBox + + name + enableActivity + + + enabled + false + + + text + Enable Activity Display + + + QLayoutWidget name Layout5 - - layoutSpacing - - + margin 0 spacing - -1 + 6 - - QCheckBox + + QLabel name - groupNetworks - - - enabled - false + TextLabel1 text - Group Detected Networks + sound on new net - - QCheckBox + + QComboBox + + + text + Ignore + + + + + text + Touch + + + + + text + Key + + + + + text + Alarm + + name - enableActivity - - - enabled - false - - - text - Enable Activity Display + beaconSound - - QCheckBox + + QComboBox + + + text + Ignore + + + + + text + Touch + + + + + text + Key + + + + + text + Alarm + + name - beepOnFound + netSound + + + QLabel - enabled - false + name + TextLabel1_3 text - Beep on new network + sound on beacon - + - - - name - Spacer2 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 6dd862f..e287b47 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp @@ -17,15 +17,19 @@ #include "configwindow.h" /* QT */ -#include #include +#include +#include +#include #include #include -#include +#include /* OPIE */ #include +WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; + WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) :WellenreiterConfigBase( parent, name, true, f ) { @@ -45,12 +49,36 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char ++it; } + // 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 = 1; + else if ( line.contains( "wlan" ) ) devicetype = 2; + else if ( line.contains( "hostap" ) ) devicetype = 3; + else if ( line.contains( "orinoco" ) ) devicetype = 4; + } + if ( devicetype ) + { + deviceType->setCurrentItem( 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(); Layout5_2->addWidget( okButton ); //FIXME: rename this in configbase.ui connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); #endif + + WellenreiterConfigWindow::_instance = this; }; int WellenreiterConfigWindow::daemonDeviceType() diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h index c627901..5fd0327 100644 --- a/noncore/net/wellenreiter/gui/configwindow.h +++ b/noncore/net/wellenreiter/gui/configwindow.h @@ -18,6 +18,10 @@ #include "configbase.h" #include +#include +#include + +class WellenreiterConfigWindow; class WellenreiterConfigWindow : public WellenreiterConfigBase { @@ -26,9 +30,13 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); int daemonDeviceType(); int daemonHopInterval(); + const QString soundOnNetwork() const { return netSound->currentText(); }; + const QString soundOnBeacon() const { return beaconSound->currentText(); }; + static WellenreiterConfigWindow* instance() { return _instance; }; protected: QMap _devicetype; + static WellenreiterConfigWindow* _instance; }; diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index be1245e..a006a3c 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -14,12 +14,18 @@ **********************************************************************/ #include "scanlist.h" +#include "configwindow.h" #include #include "manufacturers.h" #include #include +#ifdef QWS +#include +using namespace Opie; +#endif + MScanListView::MScanListView( QWidget* parent, const char* name ) :OListView( parent, name ), _manufacturerdb( 0 ) { @@ -142,7 +148,6 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo else { s.sprintf( "(i) new network: '%s'", (const char*) essid ); - network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); } @@ -192,6 +197,8 @@ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QS _channel( channel ), _signal( signal ), _beacons( 0 ) { qDebug( "creating scanlist item" ); + if ( WellenreiterConfigWindow::instance() && type == "networks" ) + playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); decorateItem( type, essid, macaddr, wep, channel, signal ); } @@ -271,11 +278,24 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, _signal = 0; } + void MScanListItem::setManufacturer( const QString& manufacturer ) { setText( col_manuf, manufacturer ); } + +void MScanListItem::playSound( const QString& sound ) const +{ + #ifdef QWS + if ( sound == "Ignore" ) return; + else if ( sound == "Touch" ) ODevice::inst()->touchSound(); + else if ( sound == "Key" ) ODevice::inst()->keySound(); + else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); + #endif +} + + void MScanListItem::receivedBeacon() { _beacons++; @@ -284,5 +304,7 @@ void MScanListItem::receivedBeacon() #endif setText( col_sig, QString::number( _beacons ) ); setText( col_lastseen, QTime::currentTime().toString() ); + if ( WellenreiterConfigWindow::instance() ) + playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); } diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index da9369f..01db172 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -91,6 +91,9 @@ class MScanListItem: public OListViewItem virtual void serializeTo( QDataStream& s ) const; virtual void serializeFrom( QDataStream& s ); + protected: + void playSound( const QString& ) const; + private: QString _type; QString _essid; diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 41ffdcc..d1dd73a 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -110,9 +110,6 @@ void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) void Wellenreiter::receivePacket(OPacket* p) { - logwindow->log( "(d) Received data from daemon" ); - //TODO - // check if we received a beacon frame // static_cast is justified here OWaveLanManagementPacket* beacon = static_cast( p->child( "802.11 Management" ) ); @@ -163,19 +160,10 @@ void Wellenreiter::startStopClicked() // switch off promisc flag iface->setPromiscuousMode( false ); - //TODO: Display "please wait..." (use owait?) - - /* - - QString cmdline; - cmdline.sprintf( "ifdown %s; sleep 1; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); - system( cmdline ); //FIXME: Use OProcess - - */ + system( "cardctl reset; sleep 1; dhclient; udhcpc" ); //FIXME: Use OProcess // message the user - - //QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); + QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); } else -- cgit v0.9.0.2