summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/gps.cpp66
-rw-r--r--noncore/net/wellenreiter/gui/gps.h13
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp8
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp9
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h2
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp2
6 files changed, 82 insertions, 18 deletions
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp
index 288afee..31f95ce 100644
--- a/noncore/net/wellenreiter/gui/gps.cpp
+++ b/noncore/net/wellenreiter/gui/gps.cpp
@@ -1,69 +1,131 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
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 "gps.h" 16#include "gps.h"
17#include <unistd.h>
18 17
18/* QT */
19#include <qtextstream.h> 19#include <qtextstream.h>
20 20
21/* STD */
22#include <stdlib.h>
23#include <unistd.h>
24
21GPS::GPS( QObject* parent, const char * name ) 25GPS::GPS( QObject* parent, const char * name )
22 :QObject( parent, name ) 26 :QObject( parent, name )
23{ 27{
24 qDebug( "GPS::GPS()" ); 28 qDebug( "GPS::GPS()" );
25 _socket = new QSocket( this, "gpsd commsock" ); 29 _socket = new QSocket( this, "gpsd commsock" );
26} 30}
27 31
28 32
29GPS::~GPS() 33GPS::~GPS()
30{ 34{
31 qDebug( "GPS::~GPS()" ); 35 qDebug( "GPS::~GPS()" );
32} 36}
33 37
34 38
35bool GPS::open( const QString& host, int port ) 39bool GPS::open( const QString& host, int port )
36{ 40{
37 _socket->connectToHost( host, port ); 41 _socket->connectToHost( host, port );
38} 42}
39 43
40 44
41GpsLocation GPS::position() const 45GpsLocation GPS::position() const
42{ 46{
43 char buf[256]; 47 char buf[256];
44 48
45 int result = _socket->writeBlock( "p\r\n", 3 ); 49 int result = _socket->writeBlock( "p\r\n", 3 );
46 _socket->flush(); 50 _socket->flush();
47 if ( result ) 51 if ( result )
48 { 52 {
49 int numAvail = _socket->bytesAvailable(); 53 int numAvail = _socket->bytesAvailable();
50 qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); 54 qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail );
51 if ( numAvail ) 55 if ( numAvail )
52 { 56 {
53 QTextStream stream( _socket ); 57 QTextStream stream( _socket );
54 58
55 QString str; 59 QString str;
56 stream.readRawBytes( &buf[0], 7 ); 60 stream.readRawBytes( &buf[0], 7 );
57 float lat = -111.111; 61 float lat = -111.111;
58 stream >> lat; 62 stream >> lat;
59 stream.skipWhiteSpace(); 63 stream.skipWhiteSpace();
60 float lon = -111.111; 64 float lon = -111.111;
61 stream >> lon; 65 stream >> lon;
62 stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF 66 stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF
63 67
64 return GpsLocation( lat, lon ); 68 return GpsLocation( lat, lon );
65 } 69 }
66 } 70 }
67 return GpsLocation( -1.0, -1.0 ); 71 return GpsLocation( -111.111, -111.111 );
68} 72}
69 73
74
75QString GpsLocation::dmsPosition() const
76{
77 if ( _latitude == -111.111 || _longitude == -111.11 )
78 return "N/A";
79 if ( _latitude == 0.0 && _longitude == 0.0 )
80 return "NULL";
81
82 /* compute latitude */
83
84 QString dms = "N";
85 if ( _latitude >= 0 ) dms.append( "+" );
86
87 int trunc = int( _latitude );
88 float rest = _latitude - trunc;
89
90 float minf = rest * 60;
91 int minutes = int( minf );
92
93 rest = minf - minutes;
94 int seconds = int( rest * 60 );
95
96 dms.append( QString::number( trunc ) );
97 dms.append( "° " );
98 dms.append( QString::number( ::abs( minutes ) ) );
99 dms.append( "' " );
100 dms.append( QString::number( ::abs( seconds ) ) );
101 dms.append( "'' " );
102
103 /* compute longitude */
104
105 dms.append( " | W" );
106 if ( _longitude > 0 ) dms.append( "+" );
107
108 trunc = int( _longitude );
109 rest = _longitude - trunc;
110
111 minf = rest * 60;
112 minutes = int( minf );
113
114 rest = minf - minutes;
115 seconds = int( rest * 60 );
116
117 dms.append( QString::number( trunc ) );
118 dms.append( "° " );
119 dms.append( QString::number( ::abs( minutes ) ) );
120 dms.append( "' " );
121 dms.append( QString::number( ::abs( seconds ) ) );
122 dms.append( "'' " );
123
124 return dms;
125}
126
127
128
129
130
131
diff --git a/noncore/net/wellenreiter/gui/gps.h b/noncore/net/wellenreiter/gui/gps.h
index 8143fe4..cfe1cdb 100644
--- a/noncore/net/wellenreiter/gui/gps.h
+++ b/noncore/net/wellenreiter/gui/gps.h
@@ -1,46 +1,51 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
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#ifndef GPS_H 16#ifndef GPS_H
17#define GPS_H 17#define GPS_H
18 18
19#include <qobject.h> 19#include <qobject.h>
20#include <qsocket.h> 20#include <qsocket.h>
21 21
22struct GpsLocation 22class GpsLocation
23{ 23{
24 GpsLocation( const float& lat, const float& lon ) : latitude(lat), longitude(lon) {}; 24 public:
25 GpsLocation( const float& lat, const float& lon ) : _latitude(lat), _longitude(lon) {};
25 ~GpsLocation() {}; 26 ~GpsLocation() {};
26 float latitude; 27 float latitude() const { return _latitude; };
27 float longitude; 28 float longitude() const { return _longitude; };
29 QString dmsPosition() const;
30 private:
31 float _latitude;
32 float _longitude;
28}; 33};
29 34
30 35
31class GPS : public QObject 36class GPS : public QObject
32{ 37{
33 Q_OBJECT 38 Q_OBJECT
34 39
35 public: 40 public:
36 GPS( QObject* parent = 0, const char * name = "GPS" ); 41 GPS( QObject* parent = 0, const char * name = "GPS" );
37 ~GPS(); 42 ~GPS();
38 43
39 bool open( const QString& host = "localhost", int port = 2947 ); 44 bool open( const QString& host = "localhost", int port = 2947 );
40 GpsLocation position() const; 45 GpsLocation position() const;
41 46
42 private: 47 private:
43 QSocket* _socket; 48 QSocket* _socket;
44}; 49};
45 50
46#endif // GPS_H 51#endif // GPS_H
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index ca9851c..d4e3279 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -179,101 +179,101 @@ void WellenreiterMainWindow::showConfigure()
179 179
180 if ( result ) updateToolButtonState(); 180 if ( result ) updateToolButtonState();
181} 181}
182 182
183 183
184void WellenreiterMainWindow::updateToolButtonState() 184void WellenreiterMainWindow::updateToolButtonState()
185{ 185{
186 const QString& interface = cw->interfaceName->currentText(); 186 const QString& interface = cw->interfaceName->currentText();
187 const int cardtype = cw->driverType(); 187 const int cardtype = cw->driverType();
188 188
189 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 189 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
190 { 190 {
191 startButton->setEnabled( true ); 191 startButton->setEnabled( true );
192 menuBar()->setItemEnabled( startID, true ); 192 menuBar()->setItemEnabled( startID, true );
193 } 193 }
194 else 194 else
195 { 195 {
196 startButton->setEnabled( false ); 196 startButton->setEnabled( false );
197 menuBar()->setItemEnabled( startID, false ); 197 menuBar()->setItemEnabled( startID, false );
198 } 198 }
199} 199}
200 200
201 201
202void WellenreiterMainWindow::changedSniffingState() 202void WellenreiterMainWindow::changedSniffingState()
203{ 203{
204 startButton->setEnabled( !mw->sniffing ); 204 startButton->setEnabled( !mw->sniffing );
205 menuBar()->setItemEnabled( startID, !mw->sniffing ); 205 menuBar()->setItemEnabled( startID, !mw->sniffing );
206 stopButton->setEnabled( mw->sniffing ); 206 stopButton->setEnabled( mw->sniffing );
207 menuBar()->setItemEnabled( stopID, mw->sniffing ); 207 menuBar()->setItemEnabled( stopID, mw->sniffing );
208 208
209 if ( !mw->sniffing ) 209 if ( !mw->sniffing )
210 { 210 {
211 menuBar()->setItemEnabled( uploadID, true ); 211 menuBar()->setItemEnabled( uploadID, true );
212 uploadButton->setEnabled( true ); 212 uploadButton->setEnabled( true );
213 } 213 }
214} 214}
215 215
216 216
217WellenreiterMainWindow::~WellenreiterMainWindow() 217WellenreiterMainWindow::~WellenreiterMainWindow()
218{ 218{
219 qDebug( "Wellenreiter:: bye." ); 219 qDebug( "Wellenreiter:: bye." );
220}; 220};
221 221
222 222
223void WellenreiterMainWindow::demoAddStations() 223void WellenreiterMainWindow::demoAddStations()
224{ 224{
225 //mw = 0; // test SIGSGV handling 225 //mw = 0; // test SIGSGV handling
226 226
227 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) ); 227 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) );
228 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); 228 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) );
229 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); 229 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) );
230 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); 230 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) );
231 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); 231 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) );
232} 232}
233 233
234 234
235QString WellenreiterMainWindow::getFileName( bool save ) 235QString WellenreiterMainWindow::getFileName( bool save )
236{ 236{
237 QMap<QString, QStringList> map; 237 QMap<QString, QStringList> map;
238 map.insert( tr("All"), QStringList() ); 238 map.insert( tr("All"), QStringList() );
239 QStringList text; 239 QStringList text;
240 text << "text/*"; 240 text << "text/*";
241 map.insert( tr("Text"), text ); 241 map.insert( tr("Text"), text );
242 text << "*"; 242 text << "*";
243 map.insert( tr("All"), text ); 243 map.insert( tr("All"), text );
244 244
245 QString str; 245 QString str;
246 if ( save ) 246 if ( save )
247 { 247 {
248 #ifdef QWS 248 #ifdef QWS
249 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); 249 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
250 #else 250 #else
251 str = QFileDialog::getSaveFileName(); 251 str = QFileDialog::getSaveFileName();
252 #endif 252 #endif
253 if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) 253 if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ )
254 return ""; 254 return "";
255 } 255 }
256 else 256 else
257 { 257 {
258 #ifdef QWS 258 #ifdef QWS
259 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); 259 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
260 #else 260 #else
261 str = QFileDialog::getOpenFileName(); 261 str = QFileDialog::getOpenFileName();
262 #endif 262 #endif
263 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) 263 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
264 return ""; 264 return "";
265 } 265 }
266 return str; 266 return str;
267} 267}
268 268
269 269
270void WellenreiterMainWindow::fileSaveLog() 270void WellenreiterMainWindow::fileSaveLog()
271{ 271{
272 QString fname = getFileName( true ); 272 QString fname = getFileName( true );
273 if ( !fname.isEmpty() ) 273 if ( !fname.isEmpty() )
274 { 274 {
275 QFile f( fname ); 275 QFile f( fname );
276 if ( f.open(IO_WriteOnly) ) 276 if ( f.open(IO_WriteOnly) )
277 { 277 {
278 QTextStream t( &f ); 278 QTextStream t( &f );
279 t << mw->logWindow()->getLog(); 279 t << mw->logWindow()->getLog();
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 1cca507..d89c71f 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -144,97 +144,97 @@ void MScanListView::addNewItem( const QString& type,
144 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); 144 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) );
145 #endif 145 #endif
146 item = static_cast<MScanListItem*> ( item->nextSibling() ); 146 item = static_cast<MScanListItem*> ( item->nextSibling() );
147 } 147 }
148 if ( item ) 148 if ( item )
149 { 149 {
150 // we have already seen this net, check all childs if MAC exists 150 // we have already seen this net, check all childs if MAC exists
151 151
152 network = item; 152 network = item;
153 153
154 item = static_cast<MScanListItem*> ( item->firstChild() ); 154 item = static_cast<MScanListItem*> ( item->firstChild() );
155 assert( item ); // this shouldn't fail 155 assert( item ); // this shouldn't fail
156 156
157 while ( item && ( item->text( col_ap ) != macaddr ) ) 157 while ( item && ( item->text( col_ap ) != macaddr ) )
158 { 158 {
159 #ifdef DEBUG 159 #ifdef DEBUG
160 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); 160 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) );
161 #endif 161 #endif
162 item = static_cast<MScanListItem*> ( item->nextSibling() ); 162 item = static_cast<MScanListItem*> ( item->nextSibling() );
163 } 163 }
164 164
165 if ( item ) 165 if ( item )
166 { 166 {
167 // we have already seen this item, it's a dupe 167 // we have already seen this item, it's a dupe
168 #ifdef DEBUG 168 #ifdef DEBUG
169 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 169 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
170 #endif 170 #endif
171 item->receivedBeacon(); 171 item->receivedBeacon();
172 return; 172 return;
173 } 173 }
174 } 174 }
175 else 175 else
176 { 176 {
177 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); 177 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
178 MLogWindow::logwindow()->log( s ); 178 MLogWindow::logwindow()->log( s );
179 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); 179 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 );
180 } 180 }
181 181
182 182
183 // insert new station as child from network 183 // insert new station as child from network
184 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 184 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
185 185
186 #ifdef DEBUG 186 #ifdef DEBUG
187 qDebug( "inserting new station %s", (const char*) macaddr ); 187 qDebug( "inserting new station %s", (const char*) macaddr );
188 #endif 188 #endif
189 189
190 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 190 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
191 station->setManufacturer( mac.manufacturer() ); 191 station->setManufacturer( mac.manufacturer() );
192 station->setLocation( loc.latitude, loc.longitude ); 192 station->setLocation( loc.dmsPosition() );
193 193
194 if ( type == "managed" ) 194 if ( type == "managed" )
195 { 195 {
196 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); 196 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel );
197 } 197 }
198 else 198 else
199 { 199 {
200 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); 200 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel );
201 } 201 }
202 MLogWindow::logwindow()->log( s ); 202 MLogWindow::logwindow()->log( s );
203 203
204} 204}
205 205
206 206
207void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) 207void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
208{ 208{
209 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 209 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
210 210
211 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) 211 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) )
212 { 212 {
213 #ifdef DEBUG 213 #ifdef DEBUG
214 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); 214 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
215 #endif 215 #endif
216 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 216 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
217 } 217 }
218 218
219 if ( subitem ) 219 if ( subitem )
220 { 220 {
221 // we have already seen this item, it's a dupe 221 // we have already seen this item, it's a dupe
222 #ifdef DEBUG 222 #ifdef DEBUG
223 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); 223 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) );
224 #endif 224 #endif
225 subitem->receivedBeacon(); //FIXME: sent data bit 225 subitem->receivedBeacon(); //FIXME: sent data bit
226 return; 226 return;
227 } 227 }
228 228
229 // Hey, it seems to be a new item :-D 229 // Hey, it seems to be a new item :-D
230 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); 230 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 );
231 station->setManufacturer( addr.manufacturer() ); 231 station->setManufacturer( addr.manufacturer() );
232 232
233 QString s; 233 QString s;
234 if ( type == "station" ) 234 if ( type == "station" )
235 { 235 {
236 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 236 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) );
237 } 237 }
238 else 238 else
239 { 239 {
240 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 240 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) );
@@ -488,82 +488,79 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr,
488 (const char*) essid, 488 (const char*) essid,
489 (const char*) macaddr, 489 (const char*) macaddr,
490 channel ); 490 channel );
491 #endif 491 #endif
492 492
493 // set icon for managed or adhoc mode 493 // set icon for managed or adhoc mode
494 QString name; 494 QString name;
495 name.sprintf( "wellenreiter/%s", (const char*) type ); 495 name.sprintf( "wellenreiter/%s", (const char*) type );
496 setPixmap( col_type, Resource::loadPixmap( name ) ); 496 setPixmap( col_type, Resource::loadPixmap( name ) );
497 497
498 // set icon for wep (wireless encryption protocol) 498 // set icon for wep (wireless encryption protocol)
499 if ( wep ) 499 if ( wep )
500 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 500 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
501 501
502 // set channel and signal text 502 // set channel and signal text
503 503
504 if ( signal != -1 ) 504 if ( signal != -1 )
505 setText( col_sig, QString::number( signal ) ); 505 setText( col_sig, QString::number( signal ) );
506 if ( channel != -1 ) 506 if ( channel != -1 )
507 setText( col_channel, QString::number( channel ) ); 507 setText( col_channel, QString::number( channel ) );
508 508
509 setText( col_firstseen, QTime::currentTime().toString() ); 509 setText( col_firstseen, QTime::currentTime().toString() );
510 //setText( col_lastseen, QTime::currentTime().toString() ); 510 //setText( col_lastseen, QTime::currentTime().toString() );
511 511
512 listView()->triggerUpdate(); 512 listView()->triggerUpdate();
513 513
514 this->type = type; 514 this->type = type;
515 _type = type; 515 _type = type;
516 _essid = essid; 516 _essid = essid;
517 _macaddr = macaddr; 517 _macaddr = macaddr;
518 _channel = channel; 518 _channel = channel;
519 _beacons = 1; 519 _beacons = 1;
520 _signal = 0; 520 _signal = 0;
521 521
522 if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) 522 if ( WellenreiterConfigWindow::instance()->openTree->isChecked() )
523 { 523 {
524 listView()->ensureItemVisible( this ); 524 listView()->ensureItemVisible( this );
525 } 525 }
526 526
527} 527}
528 528
529 529
530void MScanListItem::setManufacturer( const QString& manufacturer ) 530void MScanListItem::setManufacturer( const QString& manufacturer )
531{ 531{
532 setText( col_manuf, manufacturer ); 532 setText( col_manuf, manufacturer );
533} 533}
534 534
535 535
536void MScanListItem::setLocation( const float& latitude, const float& longitude ) 536void MScanListItem::setLocation( const QString& location )
537{ 537{
538 if ( latitude == 0.0 || longitude == 0.0 ) 538 setText( col_location, location );
539 setText( col_location, "N/A" );
540 else
541 setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) );
542} 539}
543 540
544 541
545void MScanListItem::playSound( const QString& sound ) const 542void MScanListItem::playSound( const QString& sound ) const
546{ 543{
547 #ifdef QWS 544 #ifdef QWS
548 if ( sound == "Ignore" ) return; 545 if ( sound == "Ignore" ) return;
549 else if ( sound == "Touch" ) ODevice::inst()->touchSound(); 546 else if ( sound == "Touch" ) ODevice::inst()->touchSound();
550 else if ( sound == "Key" ) ODevice::inst()->keySound(); 547 else if ( sound == "Key" ) ODevice::inst()->keySound();
551 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); 548 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound();
552 #endif 549 #endif
553} 550}
554 551
555 552
556void MScanListItem::receivedBeacon() 553void MScanListItem::receivedBeacon()
557{ 554{
558 _beacons++; 555 _beacons++;
559 #ifdef DEBUG 556 #ifdef DEBUG
560 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); 557 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
561 #endif 558 #endif
562 setText( col_sig, QString::number( _beacons ) ); 559 setText( col_sig, QString::number( _beacons ) );
563 setText( col_lastseen, QTime::currentTime().toString() ); 560 setText( col_lastseen, QTime::currentTime().toString() );
564 561
565 MScanListItem* p = (MScanListItem*) parent(); 562 MScanListItem* p = (MScanListItem*) parent();
566 if ( p ) p->receivedBeacon(); 563 if ( p ) p->receivedBeacon();
567 564
568} 565}
569 566
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index a9b74f1..6cd8fc0 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -58,85 +58,85 @@ class MScanListView: public OListView
58 void joinNetwork( const QString&, const QString&, int, const QString& ); 58 void joinNetwork( const QString&, const QString&, int, const QString& );
59 59
60 protected: 60 protected:
61 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); 61 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" );
62 62
63}; 63};
64 64
65//****************************** MScanListItem **************************************************************** 65//****************************** MScanListItem ****************************************************************
66 66
67class MScanListItem: public OListViewItem 67class MScanListItem: public OListViewItem
68{ 68{
69 public: 69 public:
70 MScanListItem::MScanListItem( QListView* parent, 70 MScanListItem::MScanListItem( QListView* parent,
71 QString type = "unknown", 71 QString type = "unknown",
72 QString essid = "unknown", 72 QString essid = "unknown",
73 QString macaddr = "unknown", 73 QString macaddr = "unknown",
74 bool wep = false, 74 bool wep = false,
75 int channel = 0, 75 int channel = 0,
76 int signal = 0 ); 76 int signal = 0 );
77 77
78 MScanListItem::MScanListItem( QListViewItem* parent, 78 MScanListItem::MScanListItem( QListViewItem* parent,
79 QString type = "unknown", 79 QString type = "unknown",
80 QString essid = "unknown", 80 QString essid = "unknown",
81 QString macaddr = "unknown", 81 QString macaddr = "unknown",
82 bool wep = false, 82 bool wep = false,
83 int channel = 0, 83 int channel = 0,
84 int signal = 0 ); 84 int signal = 0 );
85 85
86 86
87 protected: 87 protected:
88 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 88 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
89 89
90 public: 90 public:
91 QString type; 91 QString type;
92 92
93 public: 93 public:
94 //const QString& type() { return _type; }; 94 //const QString& type() { return _type; };
95 const QString& essid() const; 95 const QString& essid() const;
96 const QString& macaddr() { return _macaddr; }; 96 const QString& macaddr() { return _macaddr; };
97 bool wep() { return _wep; }; 97 bool wep() { return _wep; };
98 int channel() { return _channel; }; 98 int channel() { return _channel; };
99 int signal() { return _signal; }; 99 int signal() { return _signal; };
100 int beacons() { return _beacons; }; 100 int beacons() { return _beacons; };
101 101
102 void setSignal( int signal ) { /* TODO */ }; 102 void setSignal( int signal ) { /* TODO */ };
103 void receivedBeacon(); 103 void receivedBeacon();
104 104
105 void setManufacturer( const QString& manufacturer ); 105 void setManufacturer( const QString& manufacturer );
106 void setLocation( const float& latitude, const float& longitude ); 106 void setLocation( const QString& location );
107 107
108 virtual OListViewItem* childFactory(); 108 virtual OListViewItem* childFactory();
109 virtual void serializeTo( QDataStream& s ) const; 109 virtual void serializeTo( QDataStream& s ) const;
110 virtual void serializeFrom( QDataStream& s ); 110 virtual void serializeFrom( QDataStream& s );
111 111
112 protected: 112 protected:
113 void playSound( const QString& ) const; 113 void playSound( const QString& ) const;
114 114
115 private: 115 private:
116 QString _type; 116 QString _type;
117 QString _essid; 117 QString _essid;
118 QString _macaddr; 118 QString _macaddr;
119 bool _wep; 119 bool _wep;
120 int _channel; 120 int _channel;
121 int _signal; 121 int _signal;
122 int _beacons; 122 int _beacons;
123 123
124}; 124};
125 125
126//****************************** MScanListViewFactory **************************************************************** 126//****************************** MScanListViewFactory ****************************************************************
127 127
128/* 128/*
129 129
130class MScanListViewFactory : public OListViewFactory 130class MScanListViewFactory : public OListViewFactory
131{ 131{
132public: 132public:
133 virtual QListView* listViewFactory(); 133 virtual QListView* listViewFactory();
134 virtual QListViewItem* listViewItemFactory( QListView* lv ); 134 virtual QListViewItem* listViewItemFactory( QListView* lv );
135 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); 135 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi );
136 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); 136 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text );
137 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); 137 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text );
138} 138}
139*/ 139*/
140 140
141#endif 141#endif
142 142
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 9255a6d..5575d6e 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -144,97 +144,97 @@ void Wellenreiter::handleNotification( OPacket* p )
144 while ( (o = it.current()) != 0 ) 144 while ( (o = it.current()) != 0 )
145 { 145 {
146 QString name = it.current()->name(); 146 QString name = it.current()->name();
147 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 147 if ( configwindow->parsePackets->isProtocolChecked( name ) )
148 { 148 {
149 QString action = configwindow->parsePackets->protocolAction( name ); 149 QString action = configwindow->parsePackets->protocolAction( name );
150 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 150 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
151 doAction( action, name, p ); 151 doAction( action, name, p );
152 } 152 }
153 else 153 else
154 { 154 {
155 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); 155 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name );
156 } 156 }
157 ++it; 157 ++it;
158 } 158 }
159} 159}
160 160
161 161
162void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 162void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
163{ 163{
164 QString type; 164 QString type;
165 if ( beacon->canIBSS() ) 165 if ( beacon->canIBSS() )
166 { 166 {
167 type = "adhoc"; 167 type = "adhoc";
168 } 168 }
169 else if ( beacon->canESS() ) 169 else if ( beacon->canESS() )
170 { 170 {
171 type = "managed"; 171 type = "managed";
172 } 172 }
173 else 173 else
174 { 174 {
175 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 175 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
176 return; 176 return;
177 } 177 }
178 178
179 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 179 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
180 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 180 QString essid = ssid ? ssid->ID() : QString("<unknown>");
181 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 181 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
182 int channel = ds ? ds->channel() : -1; 182 int channel = ds ? ds->channel() : -1;
183 183
184 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 184 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
185 185
186 GpsLocation loc( 0, 0 ); 186 GpsLocation loc( 0, 0 );
187 if ( configwindow->enableGPS->isChecked() ) 187 if ( configwindow->enableGPS->isChecked() )
188 { 188 {
189 // TODO: add check if GPS is working!? 189 // TODO: add check if GPS is working!?
190 qDebug( "Wellenreiter::gathering GPS data..." ); 190 qDebug( "Wellenreiter::gathering GPS data..." );
191 loc = gps->position(); 191 loc = gps->position();
192 qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); 192 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() );
193 } 193 }
194 194
195 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 195 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
196 196
197 // update graph window 197 // update graph window
198 if ( ds ) 198 if ( ds )
199 { 199 {
200 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 200 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
201 if ( prism ) 201 if ( prism )
202 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 202 graphwindow->traffic( ds->channel(), prism->signalStrength() );
203 else 203 else
204 graphwindow->traffic( ds->channel(), 95 ); 204 graphwindow->traffic( ds->channel(), 95 );
205 } 205 }
206} 206}
207 207
208 208
209void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) 209void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
210{ 210{
211 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 211 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
212 if ( wlan->fromDS() && !wlan->toDS() ) 212 if ( wlan->fromDS() && !wlan->toDS() )
213 { 213 {
214 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 214 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
215 from = wlan->macAddress3(); 215 from = wlan->macAddress3();
216 to = wlan->macAddress2(); 216 to = wlan->macAddress2();
217 } 217 }
218 else if ( !wlan->fromDS() && wlan->toDS() ) 218 else if ( !wlan->fromDS() && wlan->toDS() )
219 { 219 {
220 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 220 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
221 from = wlan->macAddress2(); 221 from = wlan->macAddress2();
222 to = wlan->macAddress3(); 222 to = wlan->macAddress3();
223 } 223 }
224 else if ( wlan->fromDS() && wlan->toDS() ) 224 else if ( wlan->fromDS() && wlan->toDS() )
225 { 225 {
226 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 226 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
227 from = wlan->macAddress4(); 227 from = wlan->macAddress4();
228 to = wlan->macAddress3(); 228 to = wlan->macAddress3();
229 } 229 }
230 else 230 else
231 { 231 {
232 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 232 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
233 from = wlan->macAddress2(); 233 from = wlan->macAddress2();
234 to = wlan->macAddress1(); 234 to = wlan->macAddress1();
235 } 235 }
236} 236}
237 237
238 238
239void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 239void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
240{ 240{