Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 809d0bd..085eec4 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -11,26 +11,28 @@ | |||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
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 | #include <assert.h> |
21 | #include <qdatetime.h> | 21 | #include <qdatetime.h> |
22 | #include <qtextstream.h> | 22 | #include <qtextstream.h> |
23 | #include <qpopupmenu.h> | ||
23 | 24 | ||
24 | #ifdef QWS | 25 | #ifdef QWS |
26 | #include <qpe/qpeapplication.h> | ||
25 | #include <opie/odevice.h> | 27 | #include <opie/odevice.h> |
26 | using namespace Opie; | 28 | using namespace Opie; |
27 | #endif | 29 | #endif |
28 | 30 | ||
29 | 31 | ||
30 | #ifdef QWS | 32 | #ifdef QWS |
31 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
32 | #else | 34 | #else |
33 | #include "resource.h" | 35 | #include "resource.h" |
34 | #endif | 36 | #endif |
35 | 37 | ||
36 | const int col_type = 0; | 38 | const int col_type = 0; |
@@ -65,24 +67,32 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) | |||
65 | addColumn( tr( "T" ) ); | 67 | addColumn( tr( "T" ) ); |
66 | setColumnAlignment( col_traffic, AlignCenter ); | 68 | setColumnAlignment( col_traffic, AlignCenter ); |
67 | addColumn( tr( "IP" ) ); | 69 | addColumn( tr( "IP" ) ); |
68 | setColumnAlignment( col_ip, AlignCenter ); | 70 | setColumnAlignment( col_ip, AlignCenter ); |
69 | addColumn( tr( "Manufacturer" ) ); | 71 | addColumn( tr( "Manufacturer" ) ); |
70 | setColumnAlignment( col_manuf, AlignCenter ); | 72 | setColumnAlignment( col_manuf, AlignCenter ); |
71 | addColumn( tr( "First Seen" ) ); | 73 | addColumn( tr( "First Seen" ) ); |
72 | setColumnAlignment( col_firstseen, AlignCenter ); | 74 | setColumnAlignment( col_firstseen, AlignCenter ); |
73 | addColumn( tr( "Last Seen" ) ); | 75 | addColumn( tr( "Last Seen" ) ); |
74 | setColumnAlignment( col_lastseen, AlignCenter ); | 76 | setColumnAlignment( col_lastseen, AlignCenter ); |
75 | setRootIsDecorated( true ); | 77 | setRootIsDecorated( true ); |
76 | setAllColumnsShowFocus( true ); | 78 | setAllColumnsShowFocus( true ); |
79 | |||
80 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), | ||
81 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | ||
82 | |||
83 | #ifdef QWS | ||
84 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | ||
85 | #endif | ||
86 | |||
77 | }; | 87 | }; |
78 | 88 | ||
79 | 89 | ||
80 | MScanListView::~MScanListView() | 90 | MScanListView::~MScanListView() |
81 | { | 91 | { |
82 | }; | 92 | }; |
83 | 93 | ||
84 | 94 | ||
85 | OListViewItem* MScanListView::childFactory() | 95 | OListViewItem* MScanListView::childFactory() |
86 | { | 96 | { |
87 | return new MScanListItem( this ); | 97 | return new MScanListItem( this ); |
88 | } | 98 | } |
@@ -308,24 +318,45 @@ void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | |||
308 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 318 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
309 | { | 319 | { |
310 | it.current()->setText( col_ip, ip ); | 320 | it.current()->setText( col_ip, ip ); |
311 | return; | 321 | return; |
312 | } | 322 | } |
313 | } | 323 | } |
314 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 324 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
315 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 325 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
316 | (const char*) macaddr.toString(), (const char*) ip ) ); | 326 | (const char*) macaddr.toString(), (const char*) ip ) ); |
317 | } | 327 | } |
318 | 328 | ||
319 | 329 | ||
330 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | ||
331 | { | ||
332 | if ( !item ) return; | ||
333 | |||
334 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | ||
335 | |||
336 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | ||
337 | (const char*) itm->text(0), (const char*) itm->type, col ); | ||
338 | |||
339 | if ( itm->type == "adhoc" || itm->type == "managed" ) | ||
340 | { | ||
341 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | ||
342 | |||
343 | QPopupMenu m( this ); | ||
344 | m.insertItem( entry, 37773, 0 ); | ||
345 | int result = m.exec( QCursor::pos() ); | ||
346 | if ( result == 37773 ) | ||
347 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | ||
348 | } | ||
349 | } | ||
350 | |||
320 | //============================================================ | 351 | //============================================================ |
321 | // MScanListItem | 352 | // MScanListItem |
322 | //============================================================ | 353 | //============================================================ |
323 | 354 | ||
324 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 355 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
325 | bool wep, int channel, int signal ) | 356 | bool wep, int channel, int signal ) |
326 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 357 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
327 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 358 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
328 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 359 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
329 | { | 360 | { |
330 | #ifdef DEBUG | 361 | #ifdef DEBUG |
331 | qDebug( "creating scanlist item" ); | 362 | qDebug( "creating scanlist item" ); |
@@ -336,24 +367,32 @@ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QS | |||
336 | } | 367 | } |
337 | 368 | ||
338 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 369 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
339 | bool wep, int channel, int signal ) | 370 | bool wep, int channel, int signal ) |
340 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 371 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
341 | { | 372 | { |
342 | #ifdef DEBUG | 373 | #ifdef DEBUG |
343 | qDebug( "creating scanlist item" ); | 374 | qDebug( "creating scanlist item" ); |
344 | #endif | 375 | #endif |
345 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 376 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
346 | } | 377 | } |
347 | 378 | ||
379 | const QString& MScanListItem::essid() const | ||
380 | { | ||
381 | if ( type == "network" ) | ||
382 | return _essid; | ||
383 | else | ||
384 | return ( (MScanListItem*) parent() )->essid(); | ||
385 | } | ||
386 | |||
348 | OListViewItem* MScanListItem::childFactory() | 387 | OListViewItem* MScanListItem::childFactory() |
349 | { | 388 | { |
350 | return new MScanListItem( this ); | 389 | return new MScanListItem( this ); |
351 | } | 390 | } |
352 | 391 | ||
353 | void MScanListItem::serializeTo( QDataStream& s ) const | 392 | void MScanListItem::serializeTo( QDataStream& s ) const |
354 | { | 393 | { |
355 | #ifdef DEBUG | 394 | #ifdef DEBUG |
356 | qDebug( "serializing MScanListItem" ); | 395 | qDebug( "serializing MScanListItem" ); |
357 | #endif | 396 | #endif |
358 | OListViewItem::serializeTo( s ); | 397 | OListViewItem::serializeTo( s ); |
359 | 398 | ||