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) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp61
1 files changed, 32 insertions, 29 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 9e907d8..fa1d724 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -22,25 +22,27 @@
#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#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>
+using namespace Opie::Core;
+using namespace Opie::Ui;
+using namespace Opie::Net;
+
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;
@@ -48,12 +50,14 @@ 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;
+#define DEBUG
+
MScanListView::MScanListView( QWidget* parent, const char* name )
:OListView( parent, name )
{
setFrameShape( QListView::StyledPanel );
setFrameShadow( QListView::Sunken );
@@ -173,13 +177,13 @@ void MScanListView::addNewItem( const QString& type,
item->receivedBeacon();
return;
}
}
else
{
- s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
+ s = QString( "(i) New network: ESSID '%1'" ).arg( essid );
MLogWindow::logwindow()->log( s );
network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe );
}
// insert new station as child from network
@@ -192,17 +196,17 @@ void MScanListView::addNewItem( const QString& type,
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 );
+ s = QString( "(i) New Access Point in '%1' [%2]" ).arg( essid ).arg( channel );
}
else
{
- s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel );
+ s = QString( "(i) New AdHoc station in '%1' [%2]" ).arg( essid ).arg( channel );
}
MLogWindow::logwindow()->log( s );
}
void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
@@ -231,27 +235,27 @@ void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress&
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 ) );
+ s = QString( "(i) New Station in '%1' [xx]" ).arg( network->text( col_essid ) );
}
else
{
- s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) );
+ s = QString( "(i) New Wireless Station in '%1' [xx]" ).arg( network->text( col_essid ) );
}
MLogWindow::logwindow()->log( s );
}
void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo )
{
- odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl;
+ odebug << "WDSTraffic: " << viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl;
QString s;
- MScanListItem* network;
+// 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;
@@ -267,16 +271,16 @@ void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to,
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 )
+void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via )
{
QString s;
- MScanListItem* network;
+// MScanListItem* network;
QListViewItemIterator it( this );
while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
MScanListItem* item = static_cast<MScanListItem*>( it.current() );
@@ -290,16 +294,16 @@ void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to,
MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" );
}
}
-void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
+void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via )
{
QString s;
- MScanListItem* network;
+// MScanListItem* network;
QListViewItemIterator it( this );
while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
MScanListItem* item = static_cast<MScanListItem*>( it.current() );
@@ -312,41 +316,41 @@ void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& t
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 )
+void MScanListView::IBSStraffic( const OMacAddress& /*from*/, const OMacAddress& /*to*/, const OMacAddress& /*via*/ )
{
owarn << "D'oh! Not yet implemented..." << oendl;
MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" );
}
void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
{
- odebug << "identify " << (const char*) macaddr.toString() << " = " << ip << "" << oendl;
+ odebug << "identify " << macaddr.toString() << " = " << 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;
}
}
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 ) );
+ MLogWindow::logwindow()->log( QString( "WARNING: Unhandled identification %1 = %2!" )
+ .arg( macaddr.toString() ).arg( ip ) );
}
void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip )
{
- odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << ip << "" << oendl;
+ odebug << "addService '" << name << "', Server = " << macaddr.toString() << " = " << 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 );
@@ -381,29 +385,29 @@ void MScanListView::addService( const QString& name, const OMacAddress& macaddr,
item->setText( col_essid, name );
return;
}
}
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 ) );
+ MLogWindow::logwindow()->log( QString("WARNING: Unhandled service addition %s = %s!")
+ .arg( macaddr.toString() ).arg( ip ) );
}
void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
{
if ( !item ) return;
MScanListItem* itm = static_cast<MScanListItem*>( item );
- odebug << "contextMenuRequested on item '" << (const char*) itm->text(0) << "' ("
- << (const char*) itm->type << ") in column: '" << col << "'" << oendl;
+ odebug << "contextMenuRequested on item '" << itm->text(0) << "' ("
+ << itm->type << ") in column: '" << col << "'" << oendl;
if ( itm->type == "adhoc" || itm->type == "managed" )
{
- QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() );
+ QString entry = QString( "&Join %1 Net '%2'..." ).arg( itm->type ).arg( itm->essid() );
QPopupMenu m( this );
m.insertItem( entry, 37773, 0 );
int result = m.exec( QCursor::pos() );
if ( result == 37773 )
emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() );
@@ -476,31 +480,30 @@ void MScanListItem::serializeFrom( QDataStream& s )
Q_UINT8 wep;
s >> _type;
s >> wep;
_wep = (wep == 'y');
- QString name;
- name.sprintf( "wellenreiter/%s", (const char*) _type );
+ QString name = QString( "wellenreiter/"+ _type );
setPixmap( col_type, Resource::loadPixmap( name ) );
if ( _wep )
setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
listView()->triggerUpdate();
}
void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed )
{
#ifdef DEBUG
- odebug << "decorating scanlist item " << (const char*) type << " / "
- << (const char*) essid << " / " << (const char*) macaddr
+ odebug << "decorating scanlist item " << type << " / "
+ << essid << " / " << macaddr
<< "[" << channel << "]" << oendl;
#endif
// set icon for managed or adhoc mode
QString name;
- name.sprintf( "wellenreiter/%s", (const char*) type );
+ name.sprintf( "wellenreiter/"+ type );
setPixmap( col_type, Resource::loadPixmap( name ) );
// special case for probed networks FIXME: This is ugly at present
if ( type == "network" && probed )
{
setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) );