author | mickeyl <mickeyl> | 2002-12-31 14:59:35 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2002-12-31 14:59:35 (UTC) |
commit | 76ec681931f01609969b92e75908418d9e8e92d5 (patch) (side-by-side diff) | |
tree | 8230634998f17c66ebb4eb1acd82112cdb77c944 /noncore/net | |
parent | 3f35e5918b5f508139e189d2428d01d6c2933a50 (diff) | |
download | opie-76ec681931f01609969b92e75908418d9e8e92d5.zip opie-76ec681931f01609969b92e75908418d9e8e92d5.tar.gz opie-76ec681931f01609969b92e75908418d9e8e92d5.tar.bz2 |
- catch with latest changes in libwellenreiter
- GUI now identifies and displays device manufacturers
- GUI now displays the number of received beacons for each device
-rw-r--r-- | noncore/net/wellenreiter/gui/manufacturers.cpp | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/manufacturers.h | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 36 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 7 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.cpp | 19 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.h | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 27 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 19 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 18 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro | 2 |
10 files changed, 109 insertions, 33 deletions
diff --git a/noncore/net/wellenreiter/gui/manufacturers.cpp b/noncore/net/wellenreiter/gui/manufacturers.cpp index d235989..dad2753 100644 --- a/noncore/net/wellenreiter/gui/manufacturers.cpp +++ b/noncore/net/wellenreiter/gui/manufacturers.cpp @@ -41,5 +41,7 @@ ManufacturerDB::ManufacturerDB( const QString& filename ) s.skipWhiteSpace(); manu = s.readLine(); + #ifdef DEBUG qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu ); + #endif manufacturers.insert( addr, manu ); @@ -53,5 +55,5 @@ ManufacturerDB::~ManufacturerDB() } -QString ManufacturerDB::lookup( const QString& macaddr ) +const QString& ManufacturerDB::lookup( const QString& macaddr ) const { return manufacturers[macaddr.upper().left(8)]; diff --git a/noncore/net/wellenreiter/gui/manufacturers.h b/noncore/net/wellenreiter/gui/manufacturers.h index d69977a..67afe21 100644 --- a/noncore/net/wellenreiter/gui/manufacturers.h +++ b/noncore/net/wellenreiter/gui/manufacturers.h @@ -26,5 +26,5 @@ class ManufacturerDB ManufacturerDB( const QString& filename ); virtual ~ManufacturerDB(); - QString lookup( const QString& macaddr ); + const QString& lookup( const QString& macaddr ) const; private: diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 6d032aa..ab19701 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -19,7 +19,29 @@ #include <assert.h> +#include "manufacturers.h" + MScanListView::MScanListView( QWidget* parent, const char* name ) - :QListView( parent, name ) + :QListView( parent, name ), _manufacturerdb( 0 ) { + + setFrameShape( QListView::StyledPanel ); + setFrameShadow( QListView::Sunken ); + + addColumn( tr( "Net/Station" ) ); + setColumnAlignment( 0, AlignLeft || AlignVCenter ); + addColumn( tr( "B" ) ); + setColumnAlignment( 1, AlignCenter ); + addColumn( tr( "AP" ) ); + setColumnAlignment( 2, AlignCenter ); + addColumn( tr( "Chn" ) ); + setColumnAlignment( 3, AlignCenter ); + addColumn( tr( "W" ) ); + setColumnAlignment( 4, AlignCenter ); + addColumn( tr( "T" ) ); + setColumnAlignment( 5, AlignCenter ); + addColumn( tr( "Manufacturer" ) ); + setColumnAlignment( 6, AlignCenter ); + setRootIsDecorated( true ); + setAllColumnsShowFocus( true ); }; @@ -28,4 +50,9 @@ MScanListView::~MScanListView() }; +void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) +{ + _manufacturerdb = manufacturerdb; +} + void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) { @@ -85,5 +112,8 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo { // we have already seen this item, it's a dupe + #ifdef DEBUG qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); + #endif + item->receivedBeacon(); return; } @@ -103,5 +133,7 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo qDebug( "inserting new station %s", (const char*) macaddr ); - new MScanListItem( network, type, "", macaddr, wep, channel, signal ); + MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); + if ( _manufacturerdb ) + station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); if ( type == "managed" ) diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 6fe6930..9a35a82 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -21,4 +21,6 @@ class QString; +class ManufacturerDB; + class MScanListView: public QListView { @@ -29,6 +31,11 @@ class MScanListView: public QListView virtual ~MScanListView(); + void setManufacturerDB( ManufacturerDB* manufacturerdb ); + public slots: void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); + + private: + ManufacturerDB* _manufacturerdb; }; diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp index f4b43a6..15aef0c 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.cpp +++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp @@ -31,8 +31,11 @@ const int col_channel = 3; const int col_wep = 4; const int col_traffic = 5; +const int col_manuf = 6; MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) - :QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) + :QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), + _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), + _channel( channel ), _signal( signal ), _beacons( 0 ) { qDebug( "creating scanlist item" ); @@ -78,2 +81,16 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, } +void MScanListItem::setManufacturer( const QString& manufacturer ) +{ + setText( col_manuf, manufacturer ); +} + +void MScanListItem::receivedBeacon() +{ + _beacons++; + #ifdef DEBUG + qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); + #endif + setText( col_sig, QString::number( _beacons ) ); +} + diff --git a/noncore/net/wellenreiter/gui/scanlistitem.h b/noncore/net/wellenreiter/gui/scanlistitem.h index 47a5a4e..c3c6255 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.h +++ b/noncore/net/wellenreiter/gui/scanlistitem.h @@ -58,8 +58,10 @@ class MScanListItem: public QListViewItem int channel() { return _channel; }; int signal() { return _signal; }; - int received() { return _received; }; + int beacons() { return _beacons; }; void setSignal( int signal ) { /* TODO */ }; - void incReceived() { _received++; }; + void receivedBeacon(); + + void setManufacturer( const QString& manufacturer ); private: @@ -70,5 +72,5 @@ class MScanListItem: public QListViewItem int _channel; int _signal; - int _received; + int _beacons; }; diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 9068e3a..b22c5cc 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -25,4 +25,5 @@ #ifdef QWS +#include <qpe/qpeapplication.h> #include <qpe/global.h> #endif @@ -56,10 +57,11 @@ using namespace Opie; #include "manufacturers.h" +#include <daemon/source/config.hh> +#include <libwellenreiter/source/wl_types.hh> #include <libwellenreiter/source/wl_sock.hh> #include <libwellenreiter/source/wl_proto.hh> -#include <daemon/source/config.hh> Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) - : WellenreiterBase( parent, name, fl ), daemonRunning( false ) + : WellenreiterBase( parent, name, fl ), daemonRunning( false ), manufacturerdb( 0 ) { @@ -70,5 +72,5 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) QString manufile; #ifdef QWS - manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) qApp.qpeDir() ); + manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); #else manufile.sprintf( "/home/mickey/work/opie/share/wellenreiter/manufacturers.dat" ); @@ -93,5 +95,6 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) // - daemon_fd = wl_setupsock( GUIADDR, GUIPORT ); + // struct sockaddr_in sockaddr; + daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr ); if ( daemon_fd == -1 ) { @@ -112,4 +115,7 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) button->setEnabled( false ); netview->setColumnWidthMode( 1, QListView::Manual ); + + if ( manufacturerdb ) + netview->setManufacturerDB( manufacturerdb ); } @@ -128,15 +134,22 @@ void Wellenreiter::handleMessage() qDebug( "received message from daemon." ); - char buffer[10000]; - memset( &buffer, 0, sizeof( buffer ) ); + /*char buffer[10000]; + memset( &buffer, 0, sizeof( buffer ) );*/ + + char buffer[WL_SOCKBUF]; // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); + /* + struct sockaddr from; socklen_t len; int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); - qDebug( "received %d from recv [%d bytes]", result, len ); + + */ + + int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF ); if ( result == -1 ) diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 9715983..0ddc72c 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -24,4 +24,20 @@ using namespace Opie; #endif +// ugly... not here! + +#include <assert.h> +#include <errno.h> +#include <unistd.h> +#include <string.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <stdlib.h> +#include <fcntl.h> +#include <daemon/source/config.hh> +#include <libwellenreiter/source/wl_types.hh> +#include <libwellenreiter/source/wl_sock.hh> +#include <libwellenreiter/source/wl_proto.hh> + + class QTimerEvent; class QPixmap; @@ -52,4 +68,5 @@ private: ManufacturerDB* manufacturerdb; + struct sockaddr_in sockaddr; //void readConfig(); @@ -57,3 +74,5 @@ private: }; + + #endif diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index d6b9891..a93c684 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp @@ -73,21 +73,5 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f //--------- NETVIEW TAB -------------- - netview = new MScanListView( ap ); - netview->addColumn( tr( "SSID" ) ); - netview->setColumnAlignment( 0, AlignLeft || AlignVCenter ); - netview->addColumn( tr( "Sig" ) ); - netview->setColumnAlignment( 1, AlignCenter ); - netview->addColumn( tr( "AP" ) ); - netview->setColumnAlignment( 2, AlignCenter ); - netview->addColumn( tr( "Chn" ) ); - netview->setColumnAlignment( 3, AlignCenter ); - netview->addColumn( tr( "W" ) ); - netview->setColumnAlignment( 4, AlignCenter ); - netview->addColumn( tr( "T" ) ); - netview->setColumnAlignment( 5, AlignCenter ); - - netview->setFrameShape( QListView::StyledPanel ); - netview->setFrameShadow( QListView::Sunken ); - netview->setRootIsDecorated( TRUE ); + netview = new MScanListView( ap ); apLayout->addWidget( netview ); diff --git a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro b/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro index 9cf717e..8a6ed36 100644 --- a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro +++ b/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro @@ -2,5 +2,5 @@ TEMPLATE = lib CONFIG = warn_on debug VERSION = 0.2 -HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh +HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh source/wl_types.hh SOURCES = source/cardmode.cc source/wl_log.cc source/wl_proto.cc source/sniff.cc source/wl_sock.cc |