author | mickeyl <mickeyl> | 2003-05-10 17:03:50 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-10 17:03:50 (UTC) |
commit | e858fffe853c2893775c202c52ba1d4898e723bc (patch) (side-by-side diff) | |
tree | 6d5bbe5ff471d12c89fd1e6d04458477fb1292d3 /noncore/net/wellenreiter/gui/scanlist.cpp | |
parent | e9195d3c80eca6ca41893ddcfef46683da6c5627 (diff) | |
download | opie-e858fffe853c2893775c202c52ba1d4898e723bc.zip opie-e858fffe853c2893775c202c52ba1d4898e723bc.tar.gz opie-e858fffe853c2893775c202c52ba1d4898e723bc.tar.bz2 |
- use OManufacturerDB instead of ManufacturerDB
- misc fixes
Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index d5665b4..809d0bd 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -9,25 +9,24 @@ ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "scanlist.h" #include "configwindow.h" #include "logwindow.h" #include <assert.h> -#include "manufacturers.h" #include <qdatetime.h> #include <qtextstream.h> #ifdef QWS #include <opie/odevice.h> using namespace Opie; #endif #ifdef QWS #include <qpe/resource.h> #else @@ -38,25 +37,25 @@ const int col_type = 0; const int col_essid = 0; const int col_sig = 1; const int col_ap = 2; const int col_channel = 3; const int col_wep = 4; const int col_traffic = 5; const int col_ip = 6; const int col_manuf = 7; const int col_firstseen = 8; const int col_lastseen = 9; MScanListView::MScanListView( QWidget* parent, const char* name ) - :OListView( parent, name ), _manufacturerdb( 0 ) + :OListView( parent, name ) { setFrameShape( QListView::StyledPanel ); setFrameShadow( QListView::Sunken ); addColumn( tr( "Net/Station" ) ); setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); addColumn( tr( "#" ) ); setColumnAlignment( col_sig, AlignCenter ); addColumn( tr( "MAC" ) ); setColumnAlignment( col_ap, AlignCenter ); addColumn( tr( "Chn" ) ); @@ -68,53 +67,53 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) addColumn( tr( "IP" ) ); setColumnAlignment( col_ip, AlignCenter ); addColumn( tr( "Manufacturer" ) ); setColumnAlignment( col_manuf, AlignCenter ); addColumn( tr( "First Seen" ) ); setColumnAlignment( col_firstseen, AlignCenter ); addColumn( tr( "Last Seen" ) ); setColumnAlignment( col_lastseen, AlignCenter ); setRootIsDecorated( true ); setAllColumnsShowFocus( true ); }; + MScanListView::~MScanListView() { }; + OListViewItem* MScanListView::childFactory() { return new MScanListItem( this ); } + void MScanListView::serializeTo( QDataStream& s) const { qDebug( "serializing MScanListView" ); OListView::serializeTo( s ); } + void MScanListView::serializeFrom( QDataStream& s) { qDebug( "serializing MScanListView" ); OListView::serializeFrom( s ); } -void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) -{ - _manufacturerdb = manufacturerdb; -} -void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) +void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) { - // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) + QString macaddr = mac.toString(true); #ifdef DEBUG qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, (const char*) essid, (const char*) macaddr, channel ); #endif // search, if we already have seen this net QString s; MScanListItem* network; MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); @@ -159,173 +158,171 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); } // insert new station as child from network // no essid to reduce clutter, maybe later we have a nick or stationname to display!? #ifdef DEBUG qDebug( "inserting new station %s", (const char*) macaddr ); #endif MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); - if ( _manufacturerdb ) - station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); + station->setManufacturer( mac.manufacturer() ); if ( type == "managed" ) { s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); } else { s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); } MLogWindow::logwindow()->log( s ); } -void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, const QString& type ) +void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) { MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); - while ( subitem && ( subitem->text( col_ap ) != addr ) ) + while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) { #ifdef DEBUG qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); #endif subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); } if ( subitem ) { // we have already seen this item, it's a dupe #ifdef DEBUG - qDebug( "%s is a dupe - ignoring...", (const char*) addr ); + qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); #endif subitem->receivedBeacon(); //FIXME: sent data bit return; } // Hey, it seems to be a new item :-D - MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr, false, -1, -1 ); - if ( _manufacturerdb ) - station->setManufacturer( _manufacturerdb->lookup( addr ) ); + MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); + station->setManufacturer( addr.manufacturer() ); QString s; if ( type == "station" ) { s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); } else { s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); } MLogWindow::logwindow()->log( s ); } -void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QString viaTo ) +void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) { QString s; MScanListItem* network; QListViewItemIterator it( this ); while ( it.current() && - it.current()->text( col_ap ) != viaFrom && - it.current()->text( col_ap ) != viaTo ) ++it; + it.current()->text( col_ap ) != viaFrom.toString(true) && + it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; MScanListItem* item = static_cast<MScanListItem*>( it.current() ); if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations { addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); } else { qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); } } -void MScanListView::toDStraffic( QString from, QString to, QString via ) +void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) { QString s; MScanListItem* network; QListViewItemIterator it( this ); - while ( it.current() && it.current()->text( col_ap ) != via ) ++it; + while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; MScanListItem* item = static_cast<MScanListItem*>( it.current() ); if ( item ) // AP has shown up yet, so just add our new "from" - station { addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); } else { qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); } } -void MScanListView::fromDStraffic( QString from, QString to, QString via ) +void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) { QString s; MScanListItem* network; QListViewItemIterator it( this ); - while ( it.current() && it.current()->text( col_ap ) != via ) ++it; + while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; MScanListItem* item = static_cast<MScanListItem*>( it.current() ); if ( item ) // AP has shown up yet, so just add our new "from" - station { addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); } else { qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); } } -void MScanListView::IBSStraffic( QString from, QString to, QString via ) +void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) { qWarning( "D'oh! Not yet implemented..." ); MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); } -void MScanListView::identify( const QString& macaddr, const QString& ip ) +void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) { - qDebug( "identify %s = %s", (const char*) macaddr, (const char*) ip ); + qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); QListViewItemIterator it( this ); for ( ; it.current(); ++it ) { - if ( it.current()->text( col_ap ) == macaddr ) + if ( it.current()->text( col_ap ) == macaddr.toString(true) ) { it.current()->setText( col_ip, ip ); return; } } qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", - (const char*) macaddr, (const char*) ip ) ); + (const char*) macaddr.toString(), (const char*) ip ) ); } //============================================================ // MScanListItem //============================================================ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), _channel( channel ), _signal( signal ), _beacons( 1 ) @@ -441,16 +438,18 @@ void MScanListItem::playSound( const QString& sound ) const #endif } void MScanListItem::receivedBeacon() { _beacons++; #ifdef DEBUG qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); #endif setText( col_sig, QString::number( _beacons ) ); setText( col_lastseen, QTime::currentTime().toString() ); - if ( WellenreiterConfigWindow::instance() ) - playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); + + MScanListItem* p = (MScanListItem*) parent(); + if ( p ) p->receivedBeacon(); + } |