Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 9e907d8..fa1d724 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -22,25 +22,27 @@ | |||
22 | #include <opie2/odebug.h> | 22 | #include <opie2/odebug.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #else | 25 | #else |
26 | #include "resource.h" | 26 | #include "resource.h" |
27 | #endif | 27 | #endif |
28 | using namespace Opie::Core; | 28 | |
29 | using namespace Opie::Ui; | ||
30 | using namespace Opie::Net; | ||
31 | 29 | ||
32 | /* QT */ | 30 | /* QT */ |
33 | #include <qcursor.h> | 31 | #include <qcursor.h> |
34 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
35 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
36 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
37 | 35 | ||
38 | /* STD */ | 36 | /* STD */ |
39 | #include <assert.h> | 37 | #include <assert.h> |
40 | 38 | ||
39 | using namespace Opie::Core; | ||
40 | using namespace Opie::Ui; | ||
41 | using namespace Opie::Net; | ||
42 | |||
41 | const int col_type = 0; | 43 | const int col_type = 0; |
42 | const int col_essid = 0; | 44 | const int col_essid = 0; |
43 | const int col_sig = 1; | 45 | const int col_sig = 1; |
44 | const int col_ap = 2; | 46 | const int col_ap = 2; |
45 | const int col_channel = 3; | 47 | const int col_channel = 3; |
46 | const int col_wep = 4; | 48 | const int col_wep = 4; |
@@ -48,12 +50,14 @@ const int col_traffic = 5; | |||
48 | const int col_ip = 6; | 50 | const int col_ip = 6; |
49 | const int col_manuf = 7; | 51 | const int col_manuf = 7; |
50 | const int col_firstseen = 8; | 52 | const int col_firstseen = 8; |
51 | const int col_lastseen = 9; | 53 | const int col_lastseen = 9; |
52 | const int col_location = 10; | 54 | const int col_location = 10; |
53 | 55 | ||
56 | #define DEBUG | ||
57 | |||
54 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 58 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
55 | :OListView( parent, name ) | 59 | :OListView( parent, name ) |
56 | { | 60 | { |
57 | setFrameShape( QListView::StyledPanel ); | 61 | setFrameShape( QListView::StyledPanel ); |
58 | setFrameShadow( QListView::Sunken ); | 62 | setFrameShadow( QListView::Sunken ); |
59 | 63 | ||
@@ -173,13 +177,13 @@ void MScanListView::addNewItem( const QString& type, | |||
173 | item->receivedBeacon(); | 177 | item->receivedBeacon(); |
174 | return; | 178 | return; |
175 | } | 179 | } |
176 | } | 180 | } |
177 | else | 181 | else |
178 | { | 182 | { |
179 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 183 | s = QString( "(i) New network: ESSID '%1'" ).arg( essid ); |
180 | MLogWindow::logwindow()->log( s ); | 184 | MLogWindow::logwindow()->log( s ); |
181 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); | 185 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
182 | } | 186 | } |
183 | 187 | ||
184 | 188 | ||
185 | // insert new station as child from network | 189 | // insert new station as child from network |
@@ -192,17 +196,17 @@ void MScanListView::addNewItem( const QString& type, | |||
192 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 196 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
193 | station->setManufacturer( mac.manufacturer() ); | 197 | station->setManufacturer( mac.manufacturer() ); |
194 | station->setLocation( loc.dmsPosition() ); | 198 | station->setLocation( loc.dmsPosition() ); |
195 | 199 | ||
196 | if ( type == "managed" ) | 200 | if ( type == "managed" ) |
197 | { | 201 | { |
198 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 202 | s = QString( "(i) New Access Point in '%1' [%2]" ).arg( essid ).arg( channel ); |
199 | } | 203 | } |
200 | else | 204 | else |
201 | { | 205 | { |
202 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 206 | s = QString( "(i) New AdHoc station in '%1' [%2]" ).arg( essid ).arg( channel ); |
203 | } | 207 | } |
204 | MLogWindow::logwindow()->log( s ); | 208 | MLogWindow::logwindow()->log( s ); |
205 | } | 209 | } |
206 | 210 | ||
207 | 211 | ||
208 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 212 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
@@ -231,27 +235,27 @@ void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& | |||
231 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); | 235 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
232 | station->setManufacturer( addr.manufacturer() ); | 236 | station->setManufacturer( addr.manufacturer() ); |
233 | 237 | ||
234 | QString s; | 238 | QString s; |
235 | if ( type == "station" ) | 239 | if ( type == "station" ) |
236 | { | 240 | { |
237 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 241 | s = QString( "(i) New Station in '%1' [xx]" ).arg( network->text( col_essid ) ); |
238 | } | 242 | } |
239 | else | 243 | else |
240 | { | 244 | { |
241 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 245 | s = QString( "(i) New Wireless Station in '%1' [xx]" ).arg( network->text( col_essid ) ); |
242 | } | 246 | } |
243 | MLogWindow::logwindow()->log( s ); | 247 | MLogWindow::logwindow()->log( s ); |
244 | } | 248 | } |
245 | 249 | ||
246 | 250 | ||
247 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 251 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
248 | { | 252 | { |
249 | odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl; | 253 | odebug << "WDSTraffic: " << viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl; |
250 | QString s; | 254 | QString s; |
251 | MScanListItem* network; | 255 | // MScanListItem* network; |
252 | 256 | ||
253 | QListViewItemIterator it( this ); | 257 | QListViewItemIterator it( this ); |
254 | while ( it.current() && | 258 | while ( it.current() && |
255 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 259 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
256 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 260 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
257 | 261 | ||
@@ -267,16 +271,16 @@ void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, | |||
267 | odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl; | 271 | 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!" ); | 272 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
269 | } | 273 | } |
270 | } | 274 | } |
271 | 275 | ||
272 | 276 | ||
273 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 277 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) |
274 | { | 278 | { |
275 | QString s; | 279 | QString s; |
276 | MScanListItem* network; | 280 | // MScanListItem* network; |
277 | 281 | ||
278 | QListViewItemIterator it( this ); | 282 | QListViewItemIterator it( this ); |
279 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 283 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
280 | 284 | ||
281 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 285 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
282 | 286 | ||
@@ -290,16 +294,16 @@ void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, | |||
290 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 294 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
291 | 295 | ||
292 | } | 296 | } |
293 | } | 297 | } |
294 | 298 | ||
295 | 299 | ||
296 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 300 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) |
297 | { | 301 | { |
298 | QString s; | 302 | QString s; |
299 | MScanListItem* network; | 303 | // MScanListItem* network; |
300 | 304 | ||
301 | QListViewItemIterator it( this ); | 305 | QListViewItemIterator it( this ); |
302 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 306 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
303 | 307 | ||
304 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 308 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
305 | 309 | ||
@@ -312,41 +316,41 @@ void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& t | |||
312 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; | 316 | 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!" ); | 317 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
314 | } | 318 | } |
315 | } | 319 | } |
316 | 320 | ||
317 | 321 | ||
318 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 322 | void MScanListView::IBSStraffic( const OMacAddress& /*from*/, const OMacAddress& /*to*/, const OMacAddress& /*via*/ ) |
319 | { | 323 | { |
320 | owarn << "D'oh! Not yet implemented..." << oendl; | 324 | owarn << "D'oh! Not yet implemented..." << oendl; |
321 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 325 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
322 | } | 326 | } |
323 | 327 | ||
324 | 328 | ||
325 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 329 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
326 | { | 330 | { |
327 | odebug << "identify " << (const char*) macaddr.toString() << " = " << ip << "" << oendl; | 331 | odebug << "identify " << macaddr.toString() << " = " << ip << "" << oendl; |
328 | 332 | ||
329 | QListViewItemIterator it( this ); | 333 | QListViewItemIterator it( this ); |
330 | for ( ; it.current(); ++it ) | 334 | for ( ; it.current(); ++it ) |
331 | { | 335 | { |
332 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 336 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
333 | { | 337 | { |
334 | it.current()->setText( col_ip, ip ); | 338 | it.current()->setText( col_ip, ip ); |
335 | return; | 339 | return; |
336 | } | 340 | } |
337 | } | 341 | } |
338 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; | 342 | 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!", | 343 | MLogWindow::logwindow()->log( QString( "WARNING: Unhandled identification %1 = %2!" ) |
340 | (const char*) macaddr.toString(), (const char*) ip ) ); | 344 | .arg( macaddr.toString() ).arg( ip ) ); |
341 | } | 345 | } |
342 | 346 | ||
343 | 347 | ||
344 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 348 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
345 | { | 349 | { |
346 | odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << ip << "" << oendl; | 350 | odebug << "addService '" << name << "', Server = " << macaddr.toString() << " = " << ip << "" << oendl; |
347 | 351 | ||
348 | //TODO: Refactor that out, we need it all over the place. | 352 | //TODO: Refactor that out, we need it all over the place. |
349 | // Best to do it in a more comfortable abstraction in OListView | 353 | // Best to do it in a more comfortable abstraction in OListView |
350 | // (Hmm, didn't I already start something in this direction?) | 354 | // (Hmm, didn't I already start something in this direction?) |
351 | 355 | ||
352 | QListViewItemIterator it( this ); | 356 | QListViewItemIterator it( this ); |
@@ -381,29 +385,29 @@ void MScanListView::addService( const QString& name, const OMacAddress& macaddr, | |||
381 | item->setText( col_essid, name ); | 385 | item->setText( col_essid, name ); |
382 | 386 | ||
383 | return; | 387 | return; |
384 | } | 388 | } |
385 | } | 389 | } |
386 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; | 390 | 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!", | 391 | MLogWindow::logwindow()->log( QString("WARNING: Unhandled service addition %s = %s!") |
388 | (const char*) macaddr.toString(), (const char*) ip ) ); | 392 | .arg( macaddr.toString() ).arg( ip ) ); |
389 | } | 393 | } |
390 | 394 | ||
391 | 395 | ||
392 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 396 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
393 | { | 397 | { |
394 | if ( !item ) return; | 398 | if ( !item ) return; |
395 | 399 | ||
396 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 400 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
397 | 401 | ||
398 | odebug << "contextMenuRequested on item '" << (const char*) itm->text(0) << "' (" | 402 | odebug << "contextMenuRequested on item '" << itm->text(0) << "' (" |
399 | << (const char*) itm->type << ") in column: '" << col << "'" << oendl; | 403 | << itm->type << ") in column: '" << col << "'" << oendl; |
400 | 404 | ||
401 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 405 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
402 | { | 406 | { |
403 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 407 | QString entry = QString( "&Join %1 Net '%2'..." ).arg( itm->type ).arg( itm->essid() ); |
404 | 408 | ||
405 | QPopupMenu m( this ); | 409 | QPopupMenu m( this ); |
406 | m.insertItem( entry, 37773, 0 ); | 410 | m.insertItem( entry, 37773, 0 ); |
407 | int result = m.exec( QCursor::pos() ); | 411 | int result = m.exec( QCursor::pos() ); |
408 | if ( result == 37773 ) | 412 | if ( result == 37773 ) |
409 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 413 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
@@ -476,31 +480,30 @@ void MScanListItem::serializeFrom( QDataStream& s ) | |||
476 | 480 | ||
477 | Q_UINT8 wep; | 481 | Q_UINT8 wep; |
478 | s >> _type; | 482 | s >> _type; |
479 | s >> wep; | 483 | s >> wep; |
480 | _wep = (wep == 'y'); | 484 | _wep = (wep == 'y'); |
481 | 485 | ||
482 | QString name; | 486 | QString name = QString( "wellenreiter/"+ _type ); |
483 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | ||
484 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 487 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
485 | if ( _wep ) | 488 | if ( _wep ) |
486 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 489 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
487 | listView()->triggerUpdate(); | 490 | listView()->triggerUpdate(); |
488 | } | 491 | } |
489 | 492 | ||
490 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) | 493 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) |
491 | { | 494 | { |
492 | #ifdef DEBUG | 495 | #ifdef DEBUG |
493 | odebug << "decorating scanlist item " << (const char*) type << " / " | 496 | odebug << "decorating scanlist item " << type << " / " |
494 | << (const char*) essid << " / " << (const char*) macaddr | 497 | << essid << " / " << macaddr |
495 | << "[" << channel << "]" << oendl; | 498 | << "[" << channel << "]" << oendl; |
496 | #endif | 499 | #endif |
497 | 500 | ||
498 | // set icon for managed or adhoc mode | 501 | // set icon for managed or adhoc mode |
499 | QString name; | 502 | QString name; |
500 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 503 | name.sprintf( "wellenreiter/"+ type ); |
501 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 504 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
502 | 505 | ||
503 | // special case for probed networks FIXME: This is ugly at present | 506 | // special case for probed networks FIXME: This is ugly at present |
504 | if ( type == "network" && probed ) | 507 | if ( type == "network" && probed ) |
505 | { | 508 | { |
506 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); | 509 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); |