Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 3b7120a..a2be782 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -16,23 +16,28 @@ | |||
16 | #include "scanlist.h" | 16 | #include "scanlist.h" |
17 | #include "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | 19 | ||
20 | #include <assert.h> | 20 | /* OPIE */ |
21 | #include <qcursor.h> | ||
22 | #include <qdatetime.h> | ||
23 | #include <qpopupmenu.h> | ||
24 | #include <qcheckbox.h> | ||
25 | |||
26 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <opie2/odebug.h> | ||
27 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
28 | #endif | ||
29 | |||
30 | #ifdef QWS | ||
31 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
32 | #else | 25 | #else |
33 | #include "resource.h" | 26 | #include "resource.h" |
34 | #endif | 27 | #endif |
28 | using namespace Opie::Core; | ||
29 | using namespace Opie::Ui; | ||
30 | using namespace Opie::Net; | ||
31 | |||
32 | /* QT */ | ||
33 | #include <qcursor.h> | ||
34 | #include <qdatetime.h> | ||
35 | #include <qpopupmenu.h> | ||
36 | #include <qcheckbox.h> | ||
37 | |||
38 | /* STD */ | ||
39 | #include <assert.h> | ||
35 | 40 | ||
36 | const int col_type = 0; | 41 | const int col_type = 0; |
37 | const int col_essid = 0; | 42 | const int col_essid = 0; |
38 | const int col_sig = 1; | 43 | const int col_sig = 1; |
@@ -45,14 +50,8 @@ const int col_manuf = 7; | |||
45 | const int col_firstseen = 8; | 50 | const int col_firstseen = 8; |
46 | const int col_lastseen = 9; | 51 | const int col_lastseen = 9; |
47 | const int col_location = 10; | 52 | const int col_location = 10; |
48 | 53 | ||
49 | using namespace Opie::Net; | ||
50 | using namespace Opie::Ui; | ||
51 | using namespace Opie::Net; | ||
52 | using namespace Opie::Ui; | ||
53 | using namespace Opie::Ui; | ||
54 | using namespace Opie::Net; | ||
55 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 54 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
56 | :OListView( parent, name ) | 55 | :OListView( parent, name ) |
57 | { | 56 | { |
58 | setFrameShape( QListView::StyledPanel ); | 57 | setFrameShape( QListView::StyledPanel ); |
@@ -105,16 +104,16 @@ OListViewItem* MScanListView::childFactory() | |||
105 | 104 | ||
106 | 105 | ||
107 | void MScanListView::serializeTo( QDataStream& s) const | 106 | void MScanListView::serializeTo( QDataStream& s) const |
108 | { | 107 | { |
109 | qDebug( "serializing MScanListView" ); | 108 | odebug << "serializing MScanListView" << oendl; |
110 | OListView::serializeTo( s ); | 109 | OListView::serializeTo( s ); |
111 | } | 110 | } |
112 | 111 | ||
113 | 112 | ||
114 | void MScanListView::serializeFrom( QDataStream& s) | 113 | void MScanListView::serializeFrom( QDataStream& s) |
115 | { | 114 | { |
116 | qDebug( "serializing MScanListView" ); | 115 | odebug << "serializing MScanListView" << oendl; |
117 | OListView::serializeFrom( s ); | 116 | OListView::serializeFrom( s ); |
118 | } | 117 | } |
119 | 118 | ||
120 | 119 | ||
@@ -142,9 +141,9 @@ void MScanListView::addNewItem( const QString& type, | |||
142 | 141 | ||
143 | while ( item && ( item->text( col_essid ) != essid ) ) | 142 | while ( item && ( item->text( col_essid ) != essid ) ) |
144 | { | 143 | { |
145 | #ifdef DEBUG | 144 | #ifdef DEBUG |
146 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 145 | odebug << "itemtext: " << (const char*) item->text( col_essid ) << "" << oendl; |
147 | #endif | 146 | #endif |
148 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 147 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
149 | } | 148 | } |
150 | if ( item ) | 149 | if ( item ) |
@@ -158,18 +157,18 @@ void MScanListView::addNewItem( const QString& type, | |||
158 | 157 | ||
159 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 158 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
160 | { | 159 | { |
161 | #ifdef DEBUG | 160 | #ifdef DEBUG |
162 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 161 | odebug << "subitemtext: " << (const char*) item->text( col_ap ) << "" << oendl; |
163 | #endif | 162 | #endif |
164 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 163 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
165 | } | 164 | } |
166 | 165 | ||
167 | if ( item ) | 166 | if ( item ) |
168 | { | 167 | { |
169 | // we have already seen this item, it's a dupe | 168 | // we have already seen this item, it's a dupe |
170 | #ifdef DEBUG | 169 | #ifdef DEBUG |
171 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 170 | odebug << "" << (const char*) macaddr << " is a dupe - ignoring..." << oendl; |
172 | #endif | 171 | #endif |
173 | item->receivedBeacon(); | 172 | item->receivedBeacon(); |
174 | return; | 173 | return; |
175 | } | 174 | } |
@@ -185,9 +184,9 @@ void MScanListView::addNewItem( const QString& type, | |||
185 | // insert new station as child from network | 184 | // insert new station as child from network |
186 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 185 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
187 | 186 | ||
188 | #ifdef DEBUG | 187 | #ifdef DEBUG |
189 | qDebug( "inserting new station %s", (const char*) macaddr ); | 188 | odebug << "inserting new station " << (const char*) macaddr << "" << oendl; |
190 | #endif | 189 | #endif |
191 | 190 | ||
192 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 191 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
193 | station->setManufacturer( mac.manufacturer() ); | 192 | station->setManufacturer( mac.manufacturer() ); |
@@ -211,18 +210,18 @@ void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& | |||
211 | 210 | ||
212 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
213 | { | 212 | { |
214 | #ifdef DEBUG | 213 | #ifdef DEBUG |
215 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 214 | odebug << "subitemtext: " << (const char*) subitem->text( col_ap ) << "" << oendl; |
216 | #endif | 215 | #endif |
217 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
218 | } | 217 | } |
219 | 218 | ||
220 | if ( subitem ) | 219 | if ( subitem ) |
221 | { | 220 | { |
222 | // we have already seen this item, it's a dupe | 221 | // we have already seen this item, it's a dupe |
223 | #ifdef DEBUG | 222 | #ifdef DEBUG |
224 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 223 | odebug << "" << (const char*) addr.toString(true) << " is a dupe - ignoring..." << oendl; |
225 | #endif | 224 | #endif |
226 | subitem->receivedBeacon(); //FIXME: sent data bit | 225 | subitem->receivedBeacon(); //FIXME: sent data bit |
227 | return; | 226 | return; |
228 | } | 227 | } |
@@ -245,9 +244,9 @@ void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& | |||
245 | 244 | ||
246 | 245 | ||
247 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 246 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
248 | { | 247 | { |
249 | qDebug( "WDSTraffic: %s and %s seem to form a WDS", (const char*) viaFrom.toString(), (const char*) viaTo.toString() ); | 248 | odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << (const char*) viaTo.toString() << " seem to form a WDS" << oendl; |
250 | QString s; | 249 | QString s; |
251 | MScanListItem* network; | 250 | MScanListItem* network; |
252 | 251 | ||
253 | QListViewItemIterator it( this ); | 252 | QListViewItemIterator it( this ); |
@@ -263,9 +262,9 @@ void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, | |||
263 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 262 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
264 | } | 263 | } |
265 | else | 264 | else |
266 | { | 265 | { |
267 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 266 | odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl; |
268 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 267 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
269 | } | 268 | } |
270 | } | 269 | } |
271 | 270 | ||
@@ -285,9 +284,9 @@ void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, | |||
285 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 284 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
286 | } | 285 | } |
287 | else | 286 | else |
288 | { | 287 | { |
289 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 288 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; |
290 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 289 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
291 | 290 | ||
292 | } | 291 | } |
293 | } | 292 | } |
@@ -308,24 +307,24 @@ void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& t | |||
308 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 307 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
309 | } | 308 | } |
310 | else | 309 | else |
311 | { | 310 | { |
312 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 311 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; |
313 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 312 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
314 | } | 313 | } |
315 | } | 314 | } |
316 | 315 | ||
317 | 316 | ||
318 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 317 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
319 | { | 318 | { |
320 | qWarning( "D'oh! Not yet implemented..." ); | 319 | owarn << "D'oh! Not yet implemented..." << oendl; |
321 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 320 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
322 | } | 321 | } |
323 | 322 | ||
324 | 323 | ||
325 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 324 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
326 | { | 325 | { |
327 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 326 | odebug << "identify " << (const char*) macaddr.toString() << " = " << (const char*) ip << "" << oendl; |
328 | 327 | ||
329 | QListViewItemIterator it( this ); | 328 | QListViewItemIterator it( this ); |
330 | for ( ; it.current(); ++it ) | 329 | for ( ; it.current(); ++it ) |
331 | { | 330 | { |
@@ -334,17 +333,17 @@ void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | |||
334 | it.current()->setText( col_ip, ip ); | 333 | it.current()->setText( col_ip, ip ); |
335 | return; | 334 | return; |
336 | } | 335 | } |
337 | } | 336 | } |
338 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 337 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; |
339 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 338 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
340 | (const char*) macaddr.toString(), (const char*) ip ) ); | 339 | (const char*) macaddr.toString(), (const char*) ip ) ); |
341 | } | 340 | } |
342 | 341 | ||
343 | 342 | ||
344 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 343 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
345 | { | 344 | { |
346 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | 345 | odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << (const char*) ip << "" << oendl; |
347 | 346 | ||
348 | //TODO: Refactor that out, we need it all over the place. | 347 | //TODO: Refactor that out, we need it all over the place. |
349 | // Best to do it in a more comfortable abstraction in OListView | 348 | // Best to do it in a more comfortable abstraction in OListView |
350 | // (Hmm, didn't I already start something in this direction?) | 349 | // (Hmm, didn't I already start something in this direction?) |
@@ -359,18 +358,18 @@ void MScanListView::addService( const QString& name, const OMacAddress& macaddr, | |||
359 | 358 | ||
360 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 359 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
361 | { | 360 | { |
362 | #ifdef DEBUG | 361 | #ifdef DEBUG |
363 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | 362 | odebug << "subitemtext: " << (const char*) subitem->text( col_essid ) << "" << oendl; |
364 | #endif | 363 | #endif |
365 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 364 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
366 | } | 365 | } |
367 | 366 | ||
368 | if ( subitem ) | 367 | if ( subitem ) |
369 | { | 368 | { |
370 | // we have already seen this item, it's a dupe | 369 | // we have already seen this item, it's a dupe |
371 | #ifdef DEBUG | 370 | #ifdef DEBUG |
372 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | 371 | odebug << "" << (const char*) name << " is a dupe - ignoring..." << oendl; |
373 | #endif | 372 | #endif |
374 | subitem->receivedBeacon(); //FIXME: sent data bit | 373 | subitem->receivedBeacon(); //FIXME: sent data bit |
375 | return; | 374 | return; |
376 | } | 375 | } |
@@ -382,9 +381,9 @@ void MScanListView::addService( const QString& name, const OMacAddress& macaddr, | |||
382 | 381 | ||
383 | return; | 382 | return; |
384 | } | 383 | } |
385 | } | 384 | } |
386 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 385 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; |
387 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", | 386 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", |
388 | (const char*) macaddr.toString(), (const char*) ip ) ); | 387 | (const char*) macaddr.toString(), (const char*) ip ) ); |
389 | } | 388 | } |
390 | 389 | ||
@@ -420,9 +419,9 @@ MScanListItem::MScanListItem( QListView* parent, const QString& type, const QStr | |||
420 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 419 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
421 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 420 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
422 | { | 421 | { |
423 | #ifdef DEBUG | 422 | #ifdef DEBUG |
424 | qDebug( "creating scanlist item" ); | 423 | odebug << "creating scanlist item" << oendl; |
425 | #endif | 424 | #endif |
426 | 425 | ||
427 | if ( WellenreiterConfigWindow::instance() ) | 426 | if ( WellenreiterConfigWindow::instance() ) |
428 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 427 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
@@ -434,9 +433,9 @@ MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const | |||
434 | bool wep, int channel, int signal ) | 433 | bool wep, int channel, int signal ) |
435 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 434 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
436 | { | 435 | { |
437 | #ifdef DEBUG | 436 | #ifdef DEBUG |
438 | qDebug( "creating scanlist item" ); | 437 | odebug << "creating scanlist item" << oendl; |
439 | #endif | 438 | #endif |
440 | if ( WellenreiterConfigWindow::instance() ) | 439 | if ( WellenreiterConfigWindow::instance() ) |
441 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 440 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
442 | 441 | ||
@@ -458,9 +457,9 @@ OListViewItem* MScanListItem::childFactory() | |||
458 | 457 | ||
459 | void MScanListItem::serializeTo( QDataStream& s ) const | 458 | void MScanListItem::serializeTo( QDataStream& s ) const |
460 | { | 459 | { |
461 | #ifdef DEBUG | 460 | #ifdef DEBUG |
462 | qDebug( "serializing MScanListItem" ); | 461 | odebug << "serializing MScanListItem" << oendl; |
463 | #endif | 462 | #endif |
464 | OListViewItem::serializeTo( s ); | 463 | OListViewItem::serializeTo( s ); |
465 | 464 | ||
466 | s << _type; | 465 | s << _type; |
@@ -469,9 +468,9 @@ void MScanListItem::serializeTo( QDataStream& s ) const | |||
469 | 468 | ||
470 | void MScanListItem::serializeFrom( QDataStream& s ) | 469 | void MScanListItem::serializeFrom( QDataStream& s ) |
471 | { | 470 | { |
472 | #ifdef DEBUG | 471 | #ifdef DEBUG |
473 | qDebug( "serializing MScanListItem" ); | 472 | odebug << "serializing MScanListItem" << oendl; |
474 | #endif | 473 | #endif |
475 | OListViewItem::serializeFrom( s ); | 474 | OListViewItem::serializeFrom( s ); |
476 | 475 | ||
477 | char wep; | 476 | char wep; |
@@ -555,9 +554,9 @@ void MScanListItem::setLocation( const QString& location ) | |||
555 | void MScanListItem::receivedBeacon() | 554 | void MScanListItem::receivedBeacon() |
556 | { | 555 | { |
557 | _beacons++; | 556 | _beacons++; |
558 | #ifdef DEBUG | 557 | #ifdef DEBUG |
559 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 558 | odebug << "MScanListItem " << (const char*) _macaddr << ": received beacon #" << _beacons << "" << oendl; |
560 | #endif | 559 | #endif |
561 | setText( col_sig, QString::number( _beacons ) ); | 560 | setText( col_sig, QString::number( _beacons ) ); |
562 | setText( col_lastseen, QTime::currentTime().toString() ); | 561 | setText( col_lastseen, QTime::currentTime().toString() ); |
563 | 562 | ||