Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 245290d..9d6ed6a 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -294,96 +294,144 @@ void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, | |||
294 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 294 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
295 | { | 295 | { |
296 | QString s; | 296 | QString s; |
297 | MScanListItem* network; | 297 | MScanListItem* network; |
298 | 298 | ||
299 | QListViewItemIterator it( this ); | 299 | QListViewItemIterator it( this ); |
300 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 300 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
301 | 301 | ||
302 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 302 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
303 | 303 | ||
304 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 304 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
305 | { | 305 | { |
306 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 306 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
307 | } | 307 | } |
308 | else | 308 | else |
309 | { | 309 | { |
310 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 310 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
311 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 311 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 316 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
317 | { | 317 | { |
318 | qWarning( "D'oh! Not yet implemented..." ); | 318 | qWarning( "D'oh! Not yet implemented..." ); |
319 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 319 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 323 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
324 | { | 324 | { |
325 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 325 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); |
326 | 326 | ||
327 | QListViewItemIterator it( this ); | 327 | QListViewItemIterator it( this ); |
328 | for ( ; it.current(); ++it ) | 328 | for ( ; it.current(); ++it ) |
329 | { | 329 | { |
330 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 330 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
331 | { | 331 | { |
332 | it.current()->setText( col_ip, ip ); | 332 | it.current()->setText( col_ip, ip ); |
333 | return; | 333 | return; |
334 | } | 334 | } |
335 | } | 335 | } |
336 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 336 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
337 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 337 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
338 | (const char*) macaddr.toString(), (const char*) ip ) ); | 338 | (const char*) macaddr.toString(), (const char*) ip ) ); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | ||
343 | { | ||
344 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | ||
345 | |||
346 | //TODO: Refactor that out, we need it all over the place. | ||
347 | // Best to do it in a more comfortable abstraction in OListView | ||
348 | // (Hmm, didn't I already start something in this direction?) | ||
349 | |||
350 | QListViewItemIterator it( this ); | ||
351 | for ( ; it.current(); ++it ) | ||
352 | { | ||
353 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | ||
354 | { | ||
355 | |||
356 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | ||
357 | |||
358 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | ||
359 | { | ||
360 | #ifdef DEBUG | ||
361 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | ||
362 | #endif | ||
363 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | ||
364 | } | ||
365 | |||
366 | if ( subitem ) | ||
367 | { | ||
368 | // we have already seen this item, it's a dupe | ||
369 | #ifdef DEBUG | ||
370 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | ||
371 | #endif | ||
372 | subitem->receivedBeacon(); //FIXME: sent data bit | ||
373 | return; | ||
374 | } | ||
375 | |||
376 | // never seen that - add new item | ||
377 | |||
378 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", false, -1, -1 ); | ||
379 | item->setText( col_essid, name ); | ||
380 | |||
381 | return; | ||
382 | } | ||
383 | } | ||
384 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | ||
385 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", | ||
386 | (const char*) macaddr.toString(), (const char*) ip ) ); | ||
387 | } | ||
388 | |||
389 | |||
342 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 390 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
343 | { | 391 | { |
344 | if ( !item ) return; | 392 | if ( !item ) return; |
345 | 393 | ||
346 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 394 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
347 | 395 | ||
348 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 396 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
349 | (const char*) itm->text(0), (const char*) itm->type, col ); | 397 | (const char*) itm->text(0), (const char*) itm->type, col ); |
350 | 398 | ||
351 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 399 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
352 | { | 400 | { |
353 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 401 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
354 | 402 | ||
355 | QPopupMenu m( this ); | 403 | QPopupMenu m( this ); |
356 | m.insertItem( entry, 37773, 0 ); | 404 | m.insertItem( entry, 37773, 0 ); |
357 | int result = m.exec( QCursor::pos() ); | 405 | int result = m.exec( QCursor::pos() ); |
358 | if ( result == 37773 ) | 406 | if ( result == 37773 ) |
359 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 407 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
360 | } | 408 | } |
361 | } | 409 | } |
362 | 410 | ||
363 | //============================================================ | 411 | //============================================================ |
364 | // MScanListItem | 412 | // MScanListItem |
365 | //============================================================ | 413 | //============================================================ |
366 | 414 | ||
367 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 415 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
368 | bool wep, int channel, int signal ) | 416 | bool wep, int channel, int signal ) |
369 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 417 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
370 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 418 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
371 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 419 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
372 | { | 420 | { |
373 | #ifdef DEBUG | 421 | #ifdef DEBUG |
374 | qDebug( "creating scanlist item" ); | 422 | qDebug( "creating scanlist item" ); |
375 | #endif | 423 | #endif |
376 | if ( WellenreiterConfigWindow::instance() && type == "network" ) | 424 | if ( WellenreiterConfigWindow::instance() && type == "network" ) |
377 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); | 425 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); |
378 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 426 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
379 | } | 427 | } |
380 | 428 | ||
381 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 429 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
382 | bool wep, int channel, int signal ) | 430 | bool wep, int channel, int signal ) |
383 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 431 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
384 | { | 432 | { |
385 | #ifdef DEBUG | 433 | #ifdef DEBUG |
386 | qDebug( "creating scanlist item" ); | 434 | qDebug( "creating scanlist item" ); |
387 | #endif | 435 | #endif |
388 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 436 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
389 | } | 437 | } |