summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/scanlist.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index f4cfe52..d695c17 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -26,115 +26,124 @@
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <opie/odevice.h> 28#include <opie/odevice.h>
29using namespace Opie; 29using namespace Opie;
30#endif 30#endif
31 31
32 32
33#ifdef QWS 33#ifdef QWS
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#else 35#else
36#include "resource.h" 36#include "resource.h"
37#endif 37#endif
38 38
39const int col_type = 0; 39const int col_type = 0;
40const int col_essid = 0; 40const int col_essid = 0;
41const int col_sig = 1; 41const int col_sig = 1;
42const int col_ap = 2; 42const int col_ap = 2;
43const int col_channel = 3; 43const int col_channel = 3;
44const int col_wep = 4; 44const int col_wep = 4;
45const int col_traffic = 5; 45const int col_traffic = 5;
46const int col_ip = 6; 46const int col_ip = 6;
47const int col_manuf = 7; 47const int col_manuf = 7;
48const int col_firstseen = 8; 48const int col_firstseen = 8;
49const int col_lastseen = 9; 49const int col_lastseen = 9;
50const int col_location = 10;
50 51
51MScanListView::MScanListView( QWidget* parent, const char* name ) 52MScanListView::MScanListView( QWidget* parent, const char* name )
52 :OListView( parent, name ) 53 :OListView( parent, name )
53{ 54{
54 55
55 setFrameShape( QListView::StyledPanel ); 56 setFrameShape( QListView::StyledPanel );
56 setFrameShadow( QListView::Sunken ); 57 setFrameShadow( QListView::Sunken );
57 58
58 addColumn( tr( "Net/Station" ) ); 59 addColumn( tr( "Net/Station" ) );
59 setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); 60 setColumnAlignment( col_essid, AlignLeft || AlignVCenter );
60 addColumn( tr( "#" ) ); 61 addColumn( tr( "#" ) );
61 setColumnAlignment( col_sig, AlignCenter ); 62 setColumnAlignment( col_sig, AlignCenter );
62 addColumn( tr( "MAC" ) ); 63 addColumn( tr( "MAC" ) );
63 setColumnAlignment( col_ap, AlignCenter ); 64 setColumnAlignment( col_ap, AlignCenter );
64 addColumn( tr( "Chn" ) ); 65 addColumn( tr( "Chn" ) );
65 setColumnAlignment( col_channel, AlignCenter ); 66 setColumnAlignment( col_channel, AlignCenter );
66 addColumn( tr( "W" ) ); 67 addColumn( tr( "W" ) );
67 setColumnAlignment( col_wep, AlignCenter ); 68 setColumnAlignment( col_wep, AlignCenter );
68 addColumn( tr( "T" ) ); 69 addColumn( tr( "T" ) );
69 setColumnAlignment( col_traffic, AlignCenter ); 70 setColumnAlignment( col_traffic, AlignCenter );
70 addColumn( tr( "IP" ) ); 71 addColumn( tr( "IP" ) );
71 setColumnAlignment( col_ip, AlignCenter ); 72 setColumnAlignment( col_ip, AlignCenter );
72 addColumn( tr( "Manufacturer" ) ); 73 addColumn( tr( "Manufacturer" ) );
73 setColumnAlignment( col_manuf, AlignCenter ); 74 setColumnAlignment( col_manuf, AlignCenter );
74 addColumn( tr( "First Seen" ) ); 75 addColumn( tr( "First Seen" ) );
75 setColumnAlignment( col_firstseen, AlignCenter ); 76 setColumnAlignment( col_firstseen, AlignCenter );
76 addColumn( tr( "Last Seen" ) ); 77 addColumn( tr( "Last Seen" ) );
77 setColumnAlignment( col_lastseen, AlignCenter ); 78 setColumnAlignment( col_lastseen, AlignCenter );
79 addColumn( tr( "Location" ) );
80 setColumnAlignment( col_location, AlignCenter );
78 setRootIsDecorated( true ); 81 setRootIsDecorated( true );
79 setAllColumnsShowFocus( true ); 82 setAllColumnsShowFocus( true );
80 83
81 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), 84 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
82 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); 85 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
83 86
84 #ifdef QWS 87 #ifdef QWS
85 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 88 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
86 #endif 89 #endif
87 90
88}; 91};
89 92
90 93
91MScanListView::~MScanListView() 94MScanListView::~MScanListView()
92{ 95{
93}; 96};
94 97
95 98
96OListViewItem* MScanListView::childFactory() 99OListViewItem* MScanListView::childFactory()
97{ 100{
98 return new MScanListItem( this ); 101 return new MScanListItem( this );
99} 102}
100 103
101 104
102void MScanListView::serializeTo( QDataStream& s) const 105void MScanListView::serializeTo( QDataStream& s) const
103{ 106{
104 qDebug( "serializing MScanListView" ); 107 qDebug( "serializing MScanListView" );
105 OListView::serializeTo( s ); 108 OListView::serializeTo( s );
106} 109}
107 110
108 111
109void MScanListView::serializeFrom( QDataStream& s) 112void MScanListView::serializeFrom( QDataStream& s)
110{ 113{
111 qDebug( "serializing MScanListView" ); 114 qDebug( "serializing MScanListView" );
112 OListView::serializeFrom( s ); 115 OListView::serializeFrom( s );
113} 116}
114 117
115 118
116void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) 119void MScanListView::addNewItem( const QString& type,
120 const QString& essid,
121 const OMacAddress& mac,
122 bool wep,
123 int channel,
124 int signal,
125 const GpsLocation& loc )
117{ 126{
118 QString macaddr = mac.toString(true); 127 QString macaddr = mac.toString(true);
119 128
120 #ifdef DEBUG 129 #ifdef DEBUG
121 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, 130 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type,
122 (const char*) essid, (const char*) macaddr, channel ); 131 (const char*) essid, (const char*) macaddr, channel );
123 #endif 132 #endif
124 133
125 // search, if we already have seen this net 134 // search, if we already have seen this net
126 135
127 QString s; 136 QString s;
128 MScanListItem* network; 137 MScanListItem* network;
129 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 138 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
130 139
131 while ( item && ( item->text( col_essid ) != essid ) ) 140 while ( item && ( item->text( col_essid ) != essid ) )
132 { 141 {
133 #ifdef DEBUG 142 #ifdef DEBUG
134 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); 143 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) );
135 #endif 144 #endif
136 item = static_cast<MScanListItem*> ( item->nextSibling() ); 145 item = static_cast<MScanListItem*> ( item->nextSibling() );
137 } 146 }
138 if ( item ) 147 if ( item )
139 { 148 {
140 // we have already seen this net, check all childs if MAC exists 149 // we have already seen this net, check all childs if MAC exists
@@ -158,48 +167,49 @@ void MScanListView::addNewItem( const QString& type, const QString& essid, const
158 #ifdef DEBUG 167 #ifdef DEBUG
159 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 168 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
160 #endif 169 #endif
161 item->receivedBeacon(); 170 item->receivedBeacon();
162 return; 171 return;
163 } 172 }
164 } 173 }
165 else 174 else
166 { 175 {
167 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); 176 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
168 MLogWindow::logwindow()->log( s ); 177 MLogWindow::logwindow()->log( s );
169 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); 178 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 );
170 } 179 }
171 180
172 181
173 // insert new station as child from network 182 // insert new station as child from network
174 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 183 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
175 184
176 #ifdef DEBUG 185 #ifdef DEBUG
177 qDebug( "inserting new station %s", (const char*) macaddr ); 186 qDebug( "inserting new station %s", (const char*) macaddr );
178 #endif 187 #endif
179 188
180 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 189 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
181 station->setManufacturer( mac.manufacturer() ); 190 station->setManufacturer( mac.manufacturer() );
191 station->setLocation( loc.latitude, loc.longitude );
182 192
183 if ( type == "managed" ) 193 if ( type == "managed" )
184 { 194 {
185 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); 195 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel );
186 } 196 }
187 else 197 else
188 { 198 {
189 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); 199 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel );
190 } 200 }
191 MLogWindow::logwindow()->log( s ); 201 MLogWindow::logwindow()->log( s );
192 202
193} 203}
194 204
195 205
196void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) 206void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
197{ 207{
198 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 208 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
199 209
200 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) 210 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) )
201 { 211 {
202 #ifdef DEBUG 212 #ifdef DEBUG
203 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); 213 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
204 #endif 214 #endif
205 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 215 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
@@ -447,48 +457,57 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr,
447 if ( channel != -1 ) 457 if ( channel != -1 )
448 setText( col_channel, QString::number( channel ) ); 458 setText( col_channel, QString::number( channel ) );
449 459
450 setText( col_firstseen, QTime::currentTime().toString() ); 460 setText( col_firstseen, QTime::currentTime().toString() );
451 //setText( col_lastseen, QTime::currentTime().toString() ); 461 //setText( col_lastseen, QTime::currentTime().toString() );
452 462
453 listView()->triggerUpdate(); 463 listView()->triggerUpdate();
454 464
455 this->type = type; 465 this->type = type;
456 _type = type; 466 _type = type;
457 _essid = essid; 467 _essid = essid;
458 _macaddr = macaddr; 468 _macaddr = macaddr;
459 _channel = channel; 469 _channel = channel;
460 _beacons = 1; 470 _beacons = 1;
461 _signal = 0; 471 _signal = 0;
462} 472}
463 473
464 474
465void MScanListItem::setManufacturer( const QString& manufacturer ) 475void MScanListItem::setManufacturer( const QString& manufacturer )
466{ 476{
467 setText( col_manuf, manufacturer ); 477 setText( col_manuf, manufacturer );
468} 478}
469 479
470 480
481void MScanListItem::setLocation( const float& latitude, const float& longitude )
482{
483 if ( latitude == 0.0 || longitude == 0.0 )
484 setText( col_location, "N/A" );
485 else
486 setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) );
487}
488
489
471void MScanListItem::playSound( const QString& sound ) const 490void MScanListItem::playSound( const QString& sound ) const
472{ 491{
473 #ifdef QWS 492 #ifdef QWS
474 if ( sound == "Ignore" ) return; 493 if ( sound == "Ignore" ) return;
475 else if ( sound == "Touch" ) ODevice::inst()->touchSound(); 494 else if ( sound == "Touch" ) ODevice::inst()->touchSound();
476 else if ( sound == "Key" ) ODevice::inst()->keySound(); 495 else if ( sound == "Key" ) ODevice::inst()->keySound();
477 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); 496 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound();
478 #endif 497 #endif
479} 498}
480 499
481 500
482void MScanListItem::receivedBeacon() 501void MScanListItem::receivedBeacon()
483{ 502{
484 _beacons++; 503 _beacons++;
485 #ifdef DEBUG 504 #ifdef DEBUG
486 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); 505 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
487 #endif 506 #endif
488 setText( col_sig, QString::number( _beacons ) ); 507 setText( col_sig, QString::number( _beacons ) );
489 setText( col_lastseen, QTime::currentTime().toString() ); 508 setText( col_lastseen, QTime::currentTime().toString() );
490 509
491 MScanListItem* p = (MScanListItem*) parent(); 510 MScanListItem* p = (MScanListItem*) parent();
492 if ( p ) p->receivedBeacon(); 511 if ( p ) p->receivedBeacon();
493 512
494} 513}