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
@@ -11,16 +11,20 @@
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}
@@ -61,9 +65,67 @@ GpsLocation GPS::position() const
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
@@ -16,18 +16,23 @@
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
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
@@ -221,17 +221,17 @@ WellenreiterMainWindow::~WellenreiterMainWindow()
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;
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
@@ -186,13 +186,13 @@ void MScanListView::addNewItem( const QString& type,
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
@@ -530,18 +530,15 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr,
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
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
@@ -100,13 +100,13 @@ class MScanListItem: public OListViewItem
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:
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
@@ -186,13 +186,13 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
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 )