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.cpp130
1 files changed, 113 insertions, 17 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index cdc2c48..58a04fb 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -5,30 +5,28 @@
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** 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 "scanlistitem.h"
#include <assert.h>
-
#include "manufacturers.h"
-
+#include <qdatetime.h>
#include <qtextstream.h>
MScanListView::MScanListView( QWidget* parent, const char* name )
:OListView( parent, name ), _manufacturerdb( 0 )
{
setFrameShape( QListView::StyledPanel );
setFrameShadow( QListView::Sunken );
addColumn( tr( "Net/Station" ) );
setColumnAlignment( 0, AlignLeft || AlignVCenter );
addColumn( tr( "B" ) );
@@ -41,46 +39,58 @@ MScanListView::MScanListView( QWidget* parent, const char* name )
setColumnAlignment( 4, AlignCenter );
addColumn( tr( "T" ) );
setColumnAlignment( 5, AlignCenter );
addColumn( tr( "Manufacturer" ) );
setColumnAlignment( 6, AlignCenter );
addColumn( tr( "First Seen" ) );
setColumnAlignment( 7, AlignCenter );
addColumn( tr( "Last Seen" ) );
setColumnAlignment( 8, AlignCenter );
setRootIsDecorated( true );
setAllColumnsShowFocus( true );
};
-
+
MScanListView::~MScanListView()
{
};
+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 )
{
// FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
qDebug( "MScanList::addNewItem( %s / %s / %s [%d]",
(const char*) type,
(const char*) essid,
(const char*) macaddr,
channel );
-
+
// search, if we already have seen this net
-
+
QString s;
MScanListItem* network;
MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
while ( item && ( item->text( 0 ) != essid ) )
{
qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
item = static_cast<MScanListItem*> ( item->itemBelow() );
}
if ( item )
{
// animate the item
@@ -89,40 +99,40 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
const QPixmap* pixmap = item->pixmap( 0 );
const QPixmap* nextpixmap = ani2;
if ( pixmap == ani1 )
nextpixmap = ani2;
else if ( pixmap == ani2 )
nextpixmap = ani3;
else if ( pixmap == ani3 )
nextpixmap = ani4;
else if ( pixmap == ani4 )
nextpixmap = ani1;
item->setPixmap( 0, *nextpixmap ); */
-
+
//qDebug( "current pixmap %d, next %d", pixmap, nextpixmap );
-
+
// 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( 2 ) != macaddr ) )
{
qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
item = static_cast<MScanListItem*> ( item->itemBelow() );
}
-
+
if ( item )
{
// 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;
}
}
else
{
@@ -144,24 +154,110 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
if ( type == "managed" )
{
s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
}
else
{
s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
}
}
-void MScanListView::dump( QTextStream& t ) const
+#ifdef QWS
+#include <qpe/resource.h>
+#else
+#include "resource.h"
+#endif
+
+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_manuf = 6;
+const int col_firstseen = 7;
+const int col_lastseen = 8;
+
+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( 0 )
{
- qDebug( "dumping scanlist..." );
+ qDebug( "creating scanlist item" );
+ decorateItem( type, essid, macaddr, wep, channel, signal );
+}
- QListViewItemIterator it( const_cast<MScanListView*>( this ) );
- for ( ; it.current(); ++it )
- {
- static_cast<MScanListItem*>( it.current() )->dump( t );
- }
+MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
+ bool wep, int channel, int signal )
+ :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
+{
+ qDebug( "creating scanlist item" );
+ decorateItem( type, essid, macaddr, wep, channel, signal );
+}
- qDebug( "dump finished." );
+void MScanListItem::serializeTo( QDataStream& s ) const
+{
+ OListViewItem::serializeTo( s );
+}
+
+void MScanListItem::serializeFrom( QDataStream& s )
+{
+ OListViewItem::serializeFrom( s );
}
+
+void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
+{
+ qDebug( "decorating scanlist item %s / %s / %s [%d]",
+ (const char*) type,
+ (const char*) essid,
+ (const char*) macaddr,
+ channel );
+
+ // set icon for managed or adhoc mode
+ QString name;
+ name.sprintf( "wellenreiter/%s", (const char*) type );
+ setPixmap( col_type, Resource::loadPixmap( name ) );
+
+ // set icon for wep (wireless encryption protocol)
+ if ( wep )
+ setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
+
+ // set channel and signal text
+
+ if ( signal != -1 )
+ setText( col_sig, QString::number( signal ) );
+ if ( channel != -1 )
+ setText( col_channel, QString::number( channel ) );
+
+ setText( col_firstseen, QTime::currentTime().toString() );
+ //setText( col_lastseen, QTime::currentTime().toString() );
+
+ listView()->triggerUpdate();
+
+ this->type = type;
+ _type = type;
+ _essid = essid;
+ _macaddr = macaddr;
+ _channel = channel;
+ _beacons = 0;
+ _signal = 0;
+}
+
+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 ) );
+ setText( col_lastseen, QTime::currentTime().toString() );
+}
+