summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/scanlist.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp77
1 files changed, 38 insertions, 39 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 3b7120a..a2be782 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -8,59 +8,58 @@
** Foundation and appearing in the file LICENSE.GPL included in the
** 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 <qcursor.h>
-#include <qdatetime.h>
-#include <qpopupmenu.h>
-#include <qcheckbox.h>
-
+/* OPIE */
#ifdef QWS
+#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
-#endif
-
-#ifdef QWS
#include <qpe/resource.h>
#else
#include "resource.h"
#endif
+using namespace Opie::Core;
+using namespace Opie::Ui;
+using namespace Opie::Net;
+
+/* QT */
+#include <qcursor.h>
+#include <qdatetime.h>
+#include <qpopupmenu.h>
+#include <qcheckbox.h>
+
+/* STD */
+#include <assert.h>
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;
const int col_location = 10;
-using namespace Opie::Net;
-using namespace Opie::Ui;
-using namespace Opie::Net;
-using namespace Opie::Ui;
-using namespace Opie::Ui;
-using namespace Opie::Net;
MScanListView::MScanListView( QWidget* parent, const char* name )
: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 );
@@ -97,32 +96,32 @@ MScanListView::~MScanListView()
{
};
OListViewItem* MScanListView::childFactory()
{
return new MScanListItem( this );
}
void MScanListView::serializeTo( QDataStream& s) const
{
- qDebug( "serializing MScanListView" );
+ odebug << "serializing MScanListView" << oendl;
OListView::serializeTo( s );
}
void MScanListView::serializeFrom( QDataStream& s)
{
- qDebug( "serializing MScanListView" );
+ odebug << "serializing MScanListView" << oendl;
OListView::serializeFrom( s );
}
void MScanListView::addNewItem( const QString& type,
const QString& essid,
const OMacAddress& mac,
bool wep,
int channel,
int signal,
const GpsLocation& loc,
bool probe )
@@ -134,68 +133,68 @@ void MScanListView::addNewItem( const QString& 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() );
while ( item && ( item->text( col_essid ) != essid ) )
{
#ifdef DEBUG
- qDebug( "itemtext: %s", (const char*) item->text( col_essid ) );
+ odebug << "itemtext: " << (const char*) item->text( col_essid ) << "" << oendl;
#endif
item = static_cast<MScanListItem*> ( item->nextSibling() );
}
if ( item )
{
// we have already seen this net, check all childs if MAC exists
network = item;
item = static_cast<MScanListItem*> ( item->firstChild() );
assert( item ); // this shouldn't fail
while ( item && ( item->text( col_ap ) != macaddr ) )
{
#ifdef DEBUG
- qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) );
+ odebug << "subitemtext: " << (const char*) item->text( col_ap ) << "" << oendl;
#endif
item = static_cast<MScanListItem*> ( item->nextSibling() );
}
if ( item )
{
// we have already seen this item, it's a dupe
#ifdef DEBUG
- qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
+ odebug << "" << (const char*) macaddr << " is a dupe - ignoring..." << oendl;
#endif
item->receivedBeacon();
return;
}
}
else
{
s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
MLogWindow::logwindow()->log( s );
network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe );
}
// 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 );
+ odebug << "inserting new station " << (const char*) macaddr << "" << oendl;
#endif
MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
station->setManufacturer( mac.manufacturer() );
station->setLocation( loc.dmsPosition() );
if ( type == "managed" )
{
s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel );
}
else
{
@@ -203,196 +202,196 @@ void MScanListView::addNewItem( const QString& type,
}
MLogWindow::logwindow()->log( s );
}
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.toString(true) ) )
{
#ifdef DEBUG
- qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
+ odebug << "subitemtext: " << (const char*) subitem->text( col_ap ) << "" << oendl;
#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.toString(true) );
+ odebug << "" << (const char*) addr.toString(true) << " is a dupe - ignoring..." << oendl;
#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.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( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo )
{
- qDebug( "WDSTraffic: %s and %s seem to form a WDS", (const char*) viaFrom.toString(), (const char*) viaTo.toString() );
+ odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << (const char*) viaTo.toString() << " seem to form a WDS" << oendl;
QString s;
MScanListItem* network;
QListViewItemIterator it( this );
while ( it.current() &&
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" );
+ odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl;
MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" );
}
}
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.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" );
+ odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl;
MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" );
}
}
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.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" );
+ odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl;
MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" );
}
}
void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
{
- qWarning( "D'oh! Not yet implemented..." );
+ owarn << "D'oh! Not yet implemented..." << oendl;
MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" );
}
void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
{
- qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip );
+ odebug << "identify " << (const char*) macaddr.toString() << " = " << (const char*) ip << "" << oendl;
QListViewItemIterator it( this );
for ( ; it.current(); ++it )
{
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!" );
+ odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl;
MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!",
(const char*) macaddr.toString(), (const char*) ip ) );
}
void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip )
{
- qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip );
+ odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << (const char*) ip << "" << oendl;
//TODO: Refactor that out, we need it all over the place.
// Best to do it in a more comfortable abstraction in OListView
// (Hmm, didn't I already start something in this direction?)
QListViewItemIterator it( this );
for ( ; it.current(); ++it )
{
if ( it.current()->text( col_ap ) == macaddr.toString(true) )
{
MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() );
while ( subitem && ( subitem->text( col_essid ) != name ) )
{
#ifdef DEBUG
- qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) );
+ odebug << "subitemtext: " << (const char*) subitem->text( col_essid ) << "" << oendl;
#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*) name );
+ odebug << "" << (const char*) name << " is a dupe - ignoring..." << oendl;
#endif
subitem->receivedBeacon(); //FIXME: sent data bit
return;
}
// never seen that - add new item
MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 );
item->setText( col_essid, name );
return;
}
}
- qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
+ odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl;
MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!",
(const char*) macaddr.toString(), (const char*) ip ) );
}
void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
{
if ( !item ) return;
MScanListItem* itm = static_cast<MScanListItem*>( item );
qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'",
@@ -412,74 +411,74 @@ void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, in
//============================================================
// MScanListItem
//============================================================
MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr,
bool wep, int channel, int signal, bool probed )
:OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
_type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
_channel( channel ), _signal( signal ), _beacons( 1 )
{
#ifdef DEBUG
- qDebug( "creating scanlist item" );
+ odebug << "creating scanlist item" << oendl;
#endif
if ( WellenreiterConfigWindow::instance() )
WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
decorateItem( type, essid, macaddr, wep, channel, signal, probed );
}
MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr,
bool wep, int channel, int signal )
:OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
{
#ifdef DEBUG
- qDebug( "creating scanlist item" );
+ odebug << "creating scanlist item" << oendl;
#endif
if ( WellenreiterConfigWindow::instance() )
WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
decorateItem( type, essid, macaddr, wep, channel, signal, false );
}
const QString& MScanListItem::essid() const
{
if ( type == "network" )
return _essid;
else
return ( (MScanListItem*) parent() )->essid();
}
OListViewItem* MScanListItem::childFactory()
{
return new MScanListItem( this );
}
void MScanListItem::serializeTo( QDataStream& s ) const
{
#ifdef DEBUG
- qDebug( "serializing MScanListItem" );
+ odebug << "serializing MScanListItem" << oendl;
#endif
OListViewItem::serializeTo( s );
s << _type;
s << (Q_UINT8) ( _wep ? 'y' : 'n' );
}
void MScanListItem::serializeFrom( QDataStream& s )
{
#ifdef DEBUG
- qDebug( "serializing MScanListItem" );
+ odebug << "serializing MScanListItem" << oendl;
#endif
OListViewItem::serializeFrom( s );
char wep;
s >> _type;
s >> (Q_UINT8) wep;
_wep = (wep == 'y');
QString name;
name.sprintf( "wellenreiter/%s", (const char*) _type );
setPixmap( col_type, Resource::loadPixmap( name ) );
if ( _wep )
@@ -547,22 +546,22 @@ void MScanListItem::setManufacturer( const QString& manufacturer )
void MScanListItem::setLocation( const QString& location )
{
setText( col_location, location );
}
void MScanListItem::receivedBeacon()
{
_beacons++;
#ifdef DEBUG
- qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
+ odebug << "MScanListItem " << (const char*) _macaddr << ": received beacon #" << _beacons << "" << oendl;
#endif
setText( col_sig, QString::number( _beacons ) );
setText( col_lastseen, QTime::currentTime().toString() );
MScanListItem* p = (MScanListItem*) parent();
if ( p ) p->receivedBeacon();
}