summaryrefslogtreecommitdiff
path: root/noncore
authormickeyl <mickeyl>2004-01-03 18:27:07 (UTC)
committer mickeyl <mickeyl>2004-01-03 18:27:07 (UTC)
commit3889c8f853aa2d128f54389b17f08fc7b9150788 (patch) (unidiff)
tree692bf0541e19d19f9ac93059463e4c4eb2e43e5f /noncore
parentc69a2abd7718d8acddb4ce96a1909b33056e2dcd (diff)
downloadopie-3889c8f853aa2d128f54389b17f08fc7b9150788.zip
opie-3889c8f853aa2d128f54389b17f08fc7b9150788.tar.gz
opie-3889c8f853aa2d128f54389b17f08fc7b9150788.tar.bz2
show GPS coordinates in the more common DMS format
Diffstat (limited to 'noncore') (more/less context) (show 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
@@ -5,28 +5,32 @@
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}
@@ -55,15 +59,73 @@ GpsLocation GPS::position() const
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
@@ -10,30 +10,35 @@
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 );
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
@@ -215,29 +215,29 @@ void WellenreiterMainWindow::changedSniffingState()
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 );
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
@@ -180,25 +180,25 @@ void MScanListView::addNewItem( const QString& type,
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}
@@ -524,30 +524,27 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr,
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}
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
@@ -94,25 +94,25 @@ class MScanListItem: public OListViewItem
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;
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
@@ -180,25 +180,25 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
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 );