Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index aea7eb6..fd88b63 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -111,25 +111,26 @@ void MScanListView::serializeFrom( QDataStream& s) | |||
111 | { | 111 | { |
112 | qDebug( "serializing MScanListView" ); | 112 | qDebug( "serializing MScanListView" ); |
113 | OListView::serializeFrom( s ); | 113 | OListView::serializeFrom( s ); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void MScanListView::addNewItem( const QString& type, | 117 | void MScanListView::addNewItem( const QString& type, |
118 | const QString& essid, | 118 | const QString& essid, |
119 | const OMacAddress& mac, | 119 | const OMacAddress& mac, |
120 | bool wep, | 120 | bool wep, |
121 | int channel, | 121 | int channel, |
122 | int signal, | 122 | int signal, |
123 | const GpsLocation& loc ) | 123 | const GpsLocation& loc, |
124 | bool probe ) | ||
124 | { | 125 | { |
125 | QString macaddr = mac.toString(true); | 126 | QString macaddr = mac.toString(true); |
126 | 127 | ||
127 | #ifdef DEBUG | 128 | #ifdef DEBUG |
128 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 129 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
129 | (const char*) essid, (const char*) macaddr, channel ); | 130 | (const char*) essid, (const char*) macaddr, channel ); |
130 | #endif | 131 | #endif |
131 | 132 | ||
132 | // search, if we already have seen this net | 133 | // search, if we already have seen this net |
133 | 134 | ||
134 | QString s; | 135 | QString s; |
135 | MScanListItem* network; | 136 | MScanListItem* network; |
@@ -164,49 +165,48 @@ void MScanListView::addNewItem( const QString& type, | |||
164 | // we have already seen this item, it's a dupe | 165 | // we have already seen this item, it's a dupe |
165 | #ifdef DEBUG | 166 | #ifdef DEBUG |
166 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 167 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
167 | #endif | 168 | #endif |
168 | item->receivedBeacon(); | 169 | item->receivedBeacon(); |
169 | return; | 170 | return; |
170 | } | 171 | } |
171 | } | 172 | } |
172 | else | 173 | else |
173 | { | 174 | { |
174 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 175 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
175 | MLogWindow::logwindow()->log( s ); | 176 | MLogWindow::logwindow()->log( s ); |
176 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); | 177 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
177 | } | 178 | } |
178 | 179 | ||
179 | 180 | ||
180 | // insert new station as child from network | 181 | // insert new station as child from network |
181 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 182 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
182 | 183 | ||
183 | #ifdef DEBUG | 184 | #ifdef DEBUG |
184 | qDebug( "inserting new station %s", (const char*) macaddr ); | 185 | qDebug( "inserting new station %s", (const char*) macaddr ); |
185 | #endif | 186 | #endif |
186 | 187 | ||
187 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 188 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
188 | station->setManufacturer( mac.manufacturer() ); | 189 | station->setManufacturer( mac.manufacturer() ); |
189 | station->setLocation( loc.dmsPosition() ); | 190 | station->setLocation( loc.dmsPosition() ); |
190 | 191 | ||
191 | if ( type == "managed" ) | 192 | if ( type == "managed" ) |
192 | { | 193 | { |
193 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 194 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
194 | } | 195 | } |
195 | else | 196 | else |
196 | { | 197 | { |
197 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 198 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
198 | } | 199 | } |
199 | MLogWindow::logwindow()->log( s ); | 200 | MLogWindow::logwindow()->log( s ); |
200 | |||
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 204 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
205 | { | 205 | { |
206 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 206 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
207 | 207 | ||
208 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 208 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
209 | { | 209 | { |
210 | #ifdef DEBUG | 210 | #ifdef DEBUG |
211 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 211 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
212 | #endif | 212 | #endif |
@@ -401,47 +401,47 @@ void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, in | |||
401 | m.insertItem( entry, 37773, 0 ); | 401 | m.insertItem( entry, 37773, 0 ); |
402 | int result = m.exec( QCursor::pos() ); | 402 | int result = m.exec( QCursor::pos() ); |
403 | if ( result == 37773 ) | 403 | if ( result == 37773 ) |
404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | //============================================================ | 408 | //============================================================ |
409 | // MScanListItem | 409 | // MScanListItem |
410 | //============================================================ | 410 | //============================================================ |
411 | 411 | ||
412 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, | 412 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
413 | bool wep, int channel, int signal ) | 413 | bool wep, int channel, int signal, bool probed ) |
414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
416 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 416 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
417 | { | 417 | { |
418 | #ifdef DEBUG | 418 | #ifdef DEBUG |
419 | qDebug( "creating scanlist item" ); | 419 | qDebug( "creating scanlist item" ); |
420 | #endif | 420 | #endif |
421 | 421 | ||
422 | if ( WellenreiterConfigWindow::instance() ) | 422 | if ( WellenreiterConfigWindow::instance() ) |
423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
424 | 424 | ||
425 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 425 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
426 | } | 426 | } |
427 | 427 | ||
428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
429 | bool wep, int channel, int signal ) | 429 | bool wep, int channel, int signal ) |
430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
431 | { | 431 | { |
432 | #ifdef DEBUG | 432 | #ifdef DEBUG |
433 | qDebug( "creating scanlist item" ); | 433 | qDebug( "creating scanlist item" ); |
434 | #endif | 434 | #endif |
435 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 435 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
436 | } | 436 | } |
437 | 437 | ||
438 | const QString& MScanListItem::essid() const | 438 | const QString& MScanListItem::essid() const |
439 | { | 439 | { |
440 | if ( type == "network" ) | 440 | if ( type == "network" ) |
441 | return _essid; | 441 | return _essid; |
442 | else | 442 | else |
443 | return ( (MScanListItem*) parent() )->essid(); | 443 | return ( (MScanListItem*) parent() )->essid(); |
444 | } | 444 | } |
445 | 445 | ||
446 | OListViewItem* MScanListItem::childFactory() | 446 | OListViewItem* MScanListItem::childFactory() |
447 | { | 447 | { |
@@ -470,39 +470,45 @@ void MScanListItem::serializeFrom( QDataStream& s ) | |||
470 | s >> _type; | 470 | s >> _type; |
471 | s >> (Q_UINT8) wep; | 471 | s >> (Q_UINT8) wep; |
472 | _wep = (wep == 'y'); | 472 | _wep = (wep == 'y'); |
473 | 473 | ||
474 | QString name; | 474 | QString name; |
475 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 475 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
476 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 476 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
477 | if ( _wep ) | 477 | if ( _wep ) |
478 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 478 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
479 | listView()->triggerUpdate(); | 479 | listView()->triggerUpdate(); |
480 | } | 480 | } |
481 | 481 | ||
482 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 482 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) |
483 | { | 483 | { |
484 | #ifdef DEBUG | 484 | #ifdef DEBUG |
485 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 485 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
486 | (const char*) type, | 486 | (const char*) type, |
487 | (const char*) essid, | 487 | (const char*) essid, |
488 | (const char*) macaddr, | 488 | (const char*) macaddr, |
489 | channel ); | 489 | channel ); |
490 | #endif | 490 | #endif |
491 | 491 | ||
492 | // set icon for managed or adhoc mode | 492 | // set icon for managed or adhoc mode |
493 | QString name; | 493 | QString name; |
494 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 494 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
495 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 495 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
496 | 496 | ||
497 | // special case for probed networks FIXME: This is ugly at present | ||
498 | if ( type == "network" && probed ) | ||
499 | { | ||
500 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); | ||
501 | } | ||
502 | |||
497 | // set icon for wep (wireless encryption protocol) | 503 | // set icon for wep (wireless encryption protocol) |
498 | if ( wep ) | 504 | if ( wep ) |
499 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 505 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
500 | 506 | ||
501 | // set channel and signal text | 507 | // set channel and signal text |
502 | 508 | ||
503 | if ( signal != -1 ) | 509 | if ( signal != -1 ) |
504 | setText( col_sig, QString::number( signal ) ); | 510 | setText( col_sig, QString::number( signal ) ); |
505 | if ( channel != -1 ) | 511 | if ( channel != -1 ) |
506 | setText( col_channel, QString::number( channel ) ); | 512 | setText( col_channel, QString::number( channel ) ); |
507 | 513 | ||
508 | setText( col_firstseen, QTime::currentTime().toString() ); | 514 | setText( col_firstseen, QTime::currentTime().toString() ); |