summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/scanlist.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp59
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
@@ -18,7 +18,6 @@
18#include "logwindow.h" 18#include "logwindow.h"
19 19
20#include <assert.h> 20#include <assert.h>
21#include "manufacturers.h"
22#include <qdatetime.h> 21#include <qdatetime.h>
23#include <qtextstream.h> 22#include <qtextstream.h>
24 23
@@ -47,7 +46,7 @@ const int col_firstseen = 8;
47const int col_lastseen = 9; 46const int col_lastseen = 9;
48 47
49MScanListView::MScanListView( QWidget* parent, const char* name ) 48MScanListView::MScanListView( QWidget* parent, const char* name )
50 :OListView( parent, name ), _manufacturerdb( 0 ) 49 :OListView( parent, name )
51{ 50{
52 51
53 setFrameShape( QListView::StyledPanel ); 52 setFrameShape( QListView::StyledPanel );
@@ -77,35 +76,35 @@ MScanListView::MScanListView( QWidget* parent, const char* name )
77 setAllColumnsShowFocus( true ); 76 setAllColumnsShowFocus( true );
78}; 77};
79 78
79
80MScanListView::~MScanListView() 80MScanListView::~MScanListView()
81{ 81{
82}; 82};
83 83
84
84OListViewItem* MScanListView::childFactory() 85OListViewItem* MScanListView::childFactory()
85{ 86{
86 return new MScanListItem( this ); 87 return new MScanListItem( this );
87} 88}
88 89
90
89void MScanListView::serializeTo( QDataStream& s) const 91void MScanListView::serializeTo( QDataStream& s) const
90{ 92{
91 qDebug( "serializing MScanListView" ); 93 qDebug( "serializing MScanListView" );
92 OListView::serializeTo( s ); 94 OListView::serializeTo( s );
93} 95}
94 96
97
95void MScanListView::serializeFrom( QDataStream& s) 98void MScanListView::serializeFrom( QDataStream& s)
96{ 99{
97 qDebug( "serializing MScanListView" ); 100 qDebug( "serializing MScanListView" );
98 OListView::serializeFrom( s ); 101 OListView::serializeFrom( s );
99} 102}
100 103
101void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb )
102{
103 _manufacturerdb = manufacturerdb;
104}
105 104
106void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 105void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal )
107{ 106{
108 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) 107 QString macaddr = mac.toString(true);
109 108
110 #ifdef DEBUG 109 #ifdef DEBUG
111 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, 110 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type,
@@ -168,8 +167,7 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
168 #endif 167 #endif
169 168
170 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 169 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
171 if ( _manufacturerdb ) 170 station->setManufacturer( mac.manufacturer() );
172 station->setManufacturer( _manufacturerdb->lookup( macaddr ) );
173 171
174 if ( type == "managed" ) 172 if ( type == "managed" )
175 { 173 {
@@ -184,11 +182,11 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
184} 182}
185 183
186 184
187void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, const QString& type ) 185void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
188{ 186{
189 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 187 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
190 188
191 while ( subitem && ( subitem->text( col_ap ) != addr ) ) 189 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) )
192 { 190 {
193 #ifdef DEBUG 191 #ifdef DEBUG
194 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); 192 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
@@ -200,16 +198,15 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons
200 { 198 {
201 // we have already seen this item, it's a dupe 199 // we have already seen this item, it's a dupe
202 #ifdef DEBUG 200 #ifdef DEBUG
203 qDebug( "%s is a dupe - ignoring...", (const char*) addr ); 201 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) );
204 #endif 202 #endif
205 subitem->receivedBeacon(); //FIXME: sent data bit 203 subitem->receivedBeacon(); //FIXME: sent data bit
206 return; 204 return;
207 } 205 }
208 206
209 // Hey, it seems to be a new item :-D 207 // Hey, it seems to be a new item :-D
210 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr, false, -1, -1 ); 208 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 );
211 if ( _manufacturerdb ) 209 station->setManufacturer( addr.manufacturer() );
212 station->setManufacturer( _manufacturerdb->lookup( addr ) );
213 210
214 QString s; 211 QString s;
215 if ( type == "station" ) 212 if ( type == "station" )
@@ -224,15 +221,15 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons
224} 221}
225 222
226 223
227void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QString viaTo ) 224void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo )
228{ 225{
229 QString s; 226 QString s;
230 MScanListItem* network; 227 MScanListItem* network;
231 228
232 QListViewItemIterator it( this ); 229 QListViewItemIterator it( this );
233 while ( it.current() && 230 while ( it.current() &&
234 it.current()->text( col_ap ) != viaFrom && 231 it.current()->text( col_ap ) != viaFrom.toString(true) &&
235 it.current()->text( col_ap ) != viaTo ) ++it; 232 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it;
236 233
237 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 234 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
238 235
@@ -249,13 +246,13 @@ void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QStri
249} 246}
250 247
251 248
252void MScanListView::toDStraffic( QString from, QString to, QString via ) 249void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
253{ 250{
254 QString s; 251 QString s;
255 MScanListItem* network; 252 MScanListItem* network;
256 253
257 QListViewItemIterator it( this ); 254 QListViewItemIterator it( this );
258 while ( it.current() && it.current()->text( col_ap ) != via ) ++it; 255 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
259 256
260 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 257 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
261 258
@@ -272,13 +269,13 @@ void MScanListView::toDStraffic( QString from, QString to, QString via )
272} 269}
273 270
274 271
275void MScanListView::fromDStraffic( QString from, QString to, QString via ) 272void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
276{ 273{
277 QString s; 274 QString s;
278 MScanListItem* network; 275 MScanListItem* network;
279 276
280 QListViewItemIterator it( this ); 277 QListViewItemIterator it( this );
281 while ( it.current() && it.current()->text( col_ap ) != via ) ++it; 278 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
282 279
283 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 280 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
284 281
@@ -294,21 +291,21 @@ void MScanListView::fromDStraffic( QString from, QString to, QString via )
294} 291}
295 292
296 293
297void MScanListView::IBSStraffic( QString from, QString to, QString via ) 294void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
298{ 295{
299 qWarning( "D'oh! Not yet implemented..." ); 296 qWarning( "D'oh! Not yet implemented..." );
300 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); 297 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" );
301} 298}
302 299
303 300
304void MScanListView::identify( const QString& macaddr, const QString& ip ) 301void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
305{ 302{
306 qDebug( "identify %s = %s", (const char*) macaddr, (const char*) ip ); 303 qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip );
307 304
308 QListViewItemIterator it( this ); 305 QListViewItemIterator it( this );
309 for ( ; it.current(); ++it ) 306 for ( ; it.current(); ++it )
310 { 307 {
311 if ( it.current()->text( col_ap ) == macaddr ) 308 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
312 { 309 {
313 it.current()->setText( col_ip, ip ); 310 it.current()->setText( col_ip, ip );
314 return; 311 return;
@@ -316,7 +313,7 @@ void MScanListView::identify( const QString& macaddr, const QString& ip )
316 } 313 }
317 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); 314 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
318 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", 315 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!",
319 (const char*) macaddr, (const char*) ip ) ); 316 (const char*) macaddr.toString(), (const char*) ip ) );
320} 317}
321 318
322 319
@@ -450,7 +447,9 @@ void MScanListItem::receivedBeacon()
450 #endif 447 #endif
451 setText( col_sig, QString::number( _beacons ) ); 448 setText( col_sig, QString::number( _beacons ) );
452 setText( col_lastseen, QTime::currentTime().toString() ); 449 setText( col_lastseen, QTime::currentTime().toString() );
453 if ( WellenreiterConfigWindow::instance() ) 450
454 playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); 451 MScanListItem* p = (MScanListItem*) parent();
452 if ( p ) p->receivedBeacon();
453
455} 454}
456 455