Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 59 |
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 | |||
@@ -19,5 +19,4 @@ | |||
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> |
@@ -48,5 +47,5 @@ const int col_lastseen = 9; | |||
48 | 47 | ||
49 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 48 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
50 | :OListView( parent, name ), _manufacturerdb( 0 ) | 49 | :OListView( parent, name ) |
51 | { | 50 | { |
52 | 51 | ||
@@ -78,8 +77,10 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) | |||
78 | }; | 77 | }; |
79 | 78 | ||
79 | |||
80 | MScanListView::~MScanListView() | 80 | MScanListView::~MScanListView() |
81 | { | 81 | { |
82 | }; | 82 | }; |
83 | 83 | ||
84 | |||
84 | OListViewItem* MScanListView::childFactory() | 85 | OListViewItem* MScanListView::childFactory() |
85 | { | 86 | { |
@@ -87,4 +88,5 @@ OListViewItem* MScanListView::childFactory() | |||
87 | } | 88 | } |
88 | 89 | ||
90 | |||
89 | void MScanListView::serializeTo( QDataStream& s) const | 91 | void MScanListView::serializeTo( QDataStream& s) const |
90 | { | 92 | { |
@@ -93,4 +95,5 @@ void MScanListView::serializeTo( QDataStream& s) const | |||
93 | } | 95 | } |
94 | 96 | ||
97 | |||
95 | void MScanListView::serializeFrom( QDataStream& s) | 98 | void MScanListView::serializeFrom( QDataStream& s) |
96 | { | 99 | { |
@@ -99,12 +102,8 @@ void MScanListView::serializeFrom( QDataStream& s) | |||
99 | } | 102 | } |
100 | 103 | ||
101 | void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) | ||
102 | { | ||
103 | _manufacturerdb = manufacturerdb; | ||
104 | } | ||
105 | 104 | ||
106 | void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 105 | void 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 |
@@ -169,6 +168,5 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo | |||
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" ) |
@@ -185,9 +183,9 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo | |||
185 | 183 | ||
186 | 184 | ||
187 | void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, const QString& type ) | 185 | void 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 |
@@ -201,5 +199,5 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons | |||
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 |
@@ -208,7 +206,6 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons | |||
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; |
@@ -225,5 +222,5 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons | |||
225 | 222 | ||
226 | 223 | ||
227 | void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QString viaTo ) | 224 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
228 | { | 225 | { |
229 | QString s; | 226 | QString s; |
@@ -232,6 +229,6 @@ void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QStri | |||
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() ); |
@@ -250,5 +247,5 @@ void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QStri | |||
250 | 247 | ||
251 | 248 | ||
252 | void MScanListView::toDStraffic( QString from, QString to, QString via ) | 249 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
253 | { | 250 | { |
254 | QString s; | 251 | QString s; |
@@ -256,5 +253,5 @@ void MScanListView::toDStraffic( QString from, QString to, QString via ) | |||
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() ); |
@@ -273,5 +270,5 @@ void MScanListView::toDStraffic( QString from, QString to, QString via ) | |||
273 | 270 | ||
274 | 271 | ||
275 | void MScanListView::fromDStraffic( QString from, QString to, QString via ) | 272 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
276 | { | 273 | { |
277 | QString s; | 274 | QString s; |
@@ -279,5 +276,5 @@ void MScanListView::fromDStraffic( QString from, QString to, QString via ) | |||
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() ); |
@@ -295,5 +292,5 @@ void MScanListView::fromDStraffic( QString from, QString to, QString via ) | |||
295 | 292 | ||
296 | 293 | ||
297 | void MScanListView::IBSStraffic( QString from, QString to, QString via ) | 294 | void 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..." ); |
@@ -302,12 +299,12 @@ void MScanListView::IBSStraffic( QString from, QString to, QString via ) | |||
302 | 299 | ||
303 | 300 | ||
304 | void MScanListView::identify( const QString& macaddr, const QString& ip ) | 301 | void 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 ); |
@@ -317,5 +314,5 @@ void MScanListView::identify( const QString& macaddr, const QString& ip ) | |||
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 | ||
@@ -451,6 +448,8 @@ void MScanListItem::receivedBeacon() | |||
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 | ||