Users dialog files added.
[speedfreak] / Client / maemo5location.cpp
1 /*
2  * Maemo5Location
3  *
4  * @author     Toni Jussila <toni.jussila@fudeco.com>
5  * @copyright  (c) 2010 Speed Freak team
6  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
7  */
8
9 //#ifdef Q_WS_MAEMO_5
10 #include "maemo5locationprivate.h"
11 #include "maemo5location.h"
12 #include <QDebug>
13
14 /**
15   *Default constructor of this class.
16   *@param QObject pointer to parent object. By default the value is NULL.
17   */
18 Maemo5Location::Maemo5Location(QObject* parent):QObject(parent)
19 {
20     qDebug() << "__Maemo5Location";
21     ptr = new Maemo5LocationPrivate(this);
22
23     connect(ptr, SIGNAL(agnss()), this, SIGNAL(agnss()));
24     connect(ptr, SIGNAL(awcp()), this, SIGNAL(awcp()));
25     connect(ptr, SIGNAL(locationUpdated()), this, SIGNAL(locationUpdated()));
26     connect(ptr, SIGNAL(gps_connected()), this, SIGNAL(gps_connected()));
27     connect(ptr, SIGNAL(gps_disconnected()), this, SIGNAL(gps_disconnected()));
28     connect(ptr, SIGNAL(gps_error(int)), this, SIGNAL(gps_error(int)));
29     connect(ptr, SIGNAL(gpsd_running()), this, SIGNAL(gpsd_running()));
30     connect(ptr, SIGNAL(gpsd_stopped()), this, SIGNAL(gpsd_stopped()));
31 }
32
33 /**
34   *Destructor of this class. Should be used to release all allocated resources.
35   */
36 Maemo5Location::~Maemo5Location()
37 {
38     qDebug() << "__~Maemo5Location";
39     if(ptr)
40         delete ptr;
41 }
42
43 /**
44   *Start polling gps.
45   */
46 void Maemo5Location::startPollingGPS()
47 {
48     qDebug() << "__Maemo5Location: startPollingGPS";
49     ptr->get_agnss();
50 }
51
52 /**
53   *Stop polling gps.
54   */
55 void Maemo5Location::stopPollingGPS()
56 {
57     qDebug() << "__Maemo5Location: stopPollingGPS";
58     ptr->stop();
59 }
60
61 /**
62   *Returns number of satellites in use.
63   */
64 int Maemo5Location::getSatellitesInUse()
65 {
66     return ptr->get_satellites_in_use();
67 }
68
69 /**
70   *Returns number of satellites in view.
71   */
72 int Maemo5Location::getSatellitesInView()
73 {
74     return ptr->get_satellites_in_view();
75 }
76
77 /**
78   *Returns average signal strength of satellites which are in use.
79   */
80 int Maemo5Location::getSignalStrength()
81 {
82     return ptr->get_signal_strength();
83 }
84
85 /**
86   *Returns gps online.
87   */
88 bool Maemo5Location::getGpsOnline()
89 {
90     return ptr->get_gps_online();
91 }
92
93 /**
94   *Returns latitude.
95   */
96 double Maemo5Location::getLatitude()
97 {
98     return ptr->get_lat();
99 }
100
101 /**
102   *Returns longitude.
103   */
104 double Maemo5Location::getLongitude()
105 {
106     return ptr->get_lon();
107 }
108
109 /**
110   *Returns timestamp of the update in seconds.
111   */
112 double Maemo5Location::getTime()
113 {
114     return ptr->get_time();
115 }
116
117 /**
118   *Returns time accuracy in seconds.
119   */
120 double Maemo5Location::getEpt()
121 {
122     return ptr->get_ept();
123 }
124
125 /**
126   *Returns horizontal position accuracy in cm.
127   */
128 double Maemo5Location::getEph()
129 {
130     return ptr->get_eph();
131 }
132
133 /**
134   *Returns fix altitude in meters.
135   */
136 double Maemo5Location::getAltitude()
137 {
138     return ptr->get_altitude();
139 }
140
141 /**
142   *Returns altitude accuracy in meters.
143   */
144 double Maemo5Location::getEpv()
145 {
146     return ptr->get_epv();
147 }
148
149 /**
150   *Returns direction of motion in degrees(0-359).
151   */
152 double Maemo5Location::getTrack()
153 {
154     return ptr->get_track();
155 }
156
157 /**
158   *Returns track accuracy in degrees.
159   */
160 double Maemo5Location::getEpd()
161 {
162     return ptr->get_epd();
163 }
164
165 /**
166   *Returns current speed in km/h.
167   */
168 double Maemo5Location::getSpeed()
169 {
170     return ptr->get_speed();
171 }
172
173 /**
174   *Returns speed accuracy in km/h.
175   */
176 double Maemo5Location::getEps()
177 {
178     return ptr->get_eps();
179 }
180
181 /**
182   *Returns current rate of climb in m/s.
183   */
184 double Maemo5Location::getClimb()
185 {
186     return ptr->get_climb();
187 }
188
189 /**
190   *Returns climb accuracy in m/s.
191   */
192 double Maemo5Location::getEpc()
193 {
194     return ptr->get_epc();
195 }
196
197 /**
198   *Returns distance between two points in kilometers.
199   *@param latitude of first point
200   *@param longitude of first point
201   *@param latitude of second point
202   *@param longitude of second point
203   */
204 double Maemo5Location::distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f)
205 {
206     return ptr->distance_between_two_points(latitude_s, longitude_s, latitude_f, longitude_f);
207 }