summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/scanlist.cpp
Unidiff
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
@@ -14,12 +14,10 @@
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "scanlist.h" 16#include "scanlist.h"
17#include "scanlistitem.h"
18 17
19#include <assert.h> 18#include <assert.h>
20
21#include "manufacturers.h" 19#include "manufacturers.h"
22 20#include <qdatetime.h>
23#include <qtextstream.h> 21#include <qtextstream.h>
24 22
25MScanListView::MScanListView( QWidget* parent, const char* name ) 23MScanListView::MScanListView( QWidget* parent, const char* name )
@@ -50,11 +48,23 @@ MScanListView::MScanListView( QWidget* parent, const char* name )
50 setRootIsDecorated( true ); 48 setRootIsDecorated( true );
51 setAllColumnsShowFocus( true ); 49 setAllColumnsShowFocus( true );
52}; 50};
53 51
54MScanListView::~MScanListView() 52MScanListView::~MScanListView()
55{ 53{
56}; 54};
57 55
56void MScanListView::serializeTo( QDataStream& s) const
57{
58 qDebug( "serializing MScanListView" );
59 OListView::serializeTo( s );
60}
61
62void MScanListView::serializeFrom( QDataStream& s)
63{
64 qDebug( "serializing MScanListView" );
65 OListView::serializeFrom( s );
66}
67
58void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) 68void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb )
59{ 69{
60 _manufacturerdb = manufacturerdb; 70 _manufacturerdb = manufacturerdb;
@@ -69,9 +79,9 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
69 (const char*) essid, 79 (const char*) essid,
70 (const char*) macaddr, 80 (const char*) macaddr,
71 channel ); 81 channel );
72 82
73 // search, if we already have seen this net 83 // search, if we already have seen this net
74 84
75 QString s; 85 QString s;
76 MScanListItem* network; 86 MScanListItem* network;
77 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 87 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
@@ -98,9 +108,9 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
98 else if ( pixmap == ani4 ) 108 else if ( pixmap == ani4 )
99 nextpixmap = ani1; 109 nextpixmap = ani1;
100 item->setPixmap( 0, *nextpixmap ); */ 110 item->setPixmap( 0, *nextpixmap ); */
101 111
102 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); 112 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap );
103 113
104 // we have already seen this net, check all childs if MAC exists 114 // we have already seen this net, check all childs if MAC exists
105 115
106 network = item; 116 network = item;
@@ -113,7 +123,7 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
113 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); 123 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
114 item = static_cast<MScanListItem*> ( item->itemBelow() ); 124 item = static_cast<MScanListItem*> ( item->itemBelow() );
115 } 125 }
116 126
117 if ( item ) 127 if ( item )
118 { 128 {
119 // we have already seen this item, it's a dupe 129 // we have already seen this item, it's a dupe
@@ -153,15 +163,101 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
153 163
154} 164}
155 165
156void MScanListView::dump( QTextStream& t ) const 166#ifdef QWS
167#include <qpe/resource.h>
168#else
169#include "resource.h"
170#endif
171
172const int col_type = 0;
173const int col_essid = 0;
174const int col_sig = 1;
175const int col_ap = 2;
176const int col_channel = 3;
177const int col_wep = 4;
178const int col_traffic = 5;
179const int col_manuf = 6;
180const int col_firstseen = 7;
181const int col_lastseen = 8;
182
183MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
184 bool wep, int channel, int signal )
185 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
186 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
187 _channel( channel ), _signal( signal ), _beacons( 0 )
157{ 188{
158 qDebug( "dumping scanlist..." ); 189 qDebug( "creating scanlist item" );
190 decorateItem( type, essid, macaddr, wep, channel, signal );
191}
159 192
160 QListViewItemIterator it( const_cast<MScanListView*>( this ) ); 193MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
161 for ( ; it.current(); ++it ) 194 bool wep, int channel, int signal )
162 { 195 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
163 static_cast<MScanListItem*>( it.current() )->dump( t ); 196{
164 } 197 qDebug( "creating scanlist item" );
198 decorateItem( type, essid, macaddr, wep, channel, signal );
199}
165 200
166 qDebug( "dump finished." ); 201void MScanListItem::serializeTo( QDataStream& s ) const
202{
203 OListViewItem::serializeTo( s );
204}
205
206void MScanListItem::serializeFrom( QDataStream& s )
207{
208 OListViewItem::serializeFrom( s );
167} 209}
210
211void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
212{
213 qDebug( "decorating scanlist item %s / %s / %s [%d]",
214 (const char*) type,
215 (const char*) essid,
216 (const char*) macaddr,
217 channel );
218
219 // set icon for managed or adhoc mode
220 QString name;
221 name.sprintf( "wellenreiter/%s", (const char*) type );
222 setPixmap( col_type, Resource::loadPixmap( name ) );
223
224 // set icon for wep (wireless encryption protocol)
225 if ( wep )
226 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
227
228 // set channel and signal text
229
230 if ( signal != -1 )
231 setText( col_sig, QString::number( signal ) );
232 if ( channel != -1 )
233 setText( col_channel, QString::number( channel ) );
234
235 setText( col_firstseen, QTime::currentTime().toString() );
236 //setText( col_lastseen, QTime::currentTime().toString() );
237
238 listView()->triggerUpdate();
239
240 this->type = type;
241 _type = type;
242 _essid = essid;
243 _macaddr = macaddr;
244 _channel = channel;
245 _beacons = 0;
246 _signal = 0;
247}
248
249void MScanListItem::setManufacturer( const QString& manufacturer )
250{
251 setText( col_manuf, manufacturer );
252}
253
254void MScanListItem::receivedBeacon()
255{
256 _beacons++;
257 #ifdef DEBUG
258 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
259 #endif
260 setText( col_sig, QString::number( _beacons ) );
261 setText( col_lastseen, QTime::currentTime().toString() );
262}
263