Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (ignore 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 | |||
@@ -17,9 +17,8 @@ | |||
17 | #include "configwindow.h" | 17 | #include "configwindow.h" |
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 | ||
25 | #ifdef QWS | 24 | #ifdef QWS |
@@ -46,9 +45,9 @@ const int col_manuf = 7; | |||
46 | const int col_firstseen = 8; | 45 | const int col_firstseen = 8; |
47 | const int col_lastseen = 9; | 46 | 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 | ||
53 | setFrameShape( QListView::StyledPanel ); | 52 | setFrameShape( QListView::StyledPanel ); |
54 | setFrameShadow( QListView::Sunken ); | 53 | setFrameShadow( QListView::Sunken ); |
@@ -76,37 +75,37 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) | |||
76 | setRootIsDecorated( true ); | 75 | setRootIsDecorated( true ); |
77 | setAllColumnsShowFocus( true ); | 76 | setAllColumnsShowFocus( true ); |
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 | { |
86 | return new MScanListItem( this ); | 87 | return new MScanListItem( this ); |
87 | } | 88 | } |
88 | 89 | ||
90 | |||
89 | void MScanListView::serializeTo( QDataStream& s) const | 91 | void 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 | |||
95 | void MScanListView::serializeFrom( QDataStream& s) | 98 | void 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 | ||
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 |
111 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 110 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
112 | (const char*) essid, (const char*) macaddr, channel ); | 111 | (const char*) essid, (const char*) macaddr, channel ); |
@@ -167,10 +166,9 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo | |||
167 | qDebug( "inserting new station %s", (const char*) macaddr ); | 166 | qDebug( "inserting new station %s", (const char*) macaddr ); |
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 | { |
176 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 174 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
@@ -183,13 +181,13 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo | |||
183 | 181 | ||
184 | } | 182 | } |
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 |
194 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 192 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
195 | #endif | 193 | #endif |
@@ -199,18 +197,17 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons | |||
199 | if ( subitem ) | 197 | if ( subitem ) |
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" ) |
216 | { | 213 | { |
@@ -223,17 +220,17 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons | |||
223 | MLogWindow::logwindow()->log( s ); | 220 | MLogWindow::logwindow()->log( s ); |
224 | } | 221 | } |
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; |
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 | ||
239 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 236 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
@@ -248,15 +245,15 @@ void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QStri | |||
248 | } | 245 | } |
249 | } | 246 | } |
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; |
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 | ||
262 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 259 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
@@ -271,15 +268,15 @@ void MScanListView::toDStraffic( QString from, QString to, QString via ) | |||
271 | } | 268 | } |
272 | } | 269 | } |
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; |
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 | ||
285 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 282 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
@@ -293,31 +290,31 @@ void MScanListView::fromDStraffic( QString from, QString to, QString via ) | |||
293 | } | 290 | } |
294 | } | 291 | } |
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..." ); |
300 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 297 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
301 | } | 298 | } |
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 ); |
314 | return; | 311 | return; |
315 | } | 312 | } |
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 | ||
323 | //============================================================ | 320 | //============================================================ |
@@ -449,8 +446,10 @@ void MScanListItem::receivedBeacon() | |||
449 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 446 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
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 | ||