Theme download link fixed in web page.
[jspeed] / src / location.h
1 /*
2  * This file is part of jSpeed.
3  *
4  * jSpeed is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * jSpeed is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with jSpeed.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18
19 #ifndef LOCATION_H
20 #define LOCATION_H
21
22 #include <QtCore/QObject>
23 #include <location/location-gps-device.h>
24 #include <location/location-gpsd-control.h>
25
26 class Location : public QObject
27 {
28     Q_OBJECT
29
30 public:
31
32     enum Unit {KM, MILE};
33
34     struct Fix
35     {
36         Unit unit;
37         double kmSpeed;
38         double time;
39         double ept;
40         double latitude;
41         double longitude;
42         double eph;
43         double altitude;
44         double epv;
45         double track;
46         double epd;
47         double speed;
48         double eps;
49         double climb;
50         double epc;
51         Fix();
52     };
53
54     enum Error {USER_REJECTED_DIALOG,
55         USER_REJECTED_SETTINGS,
56         GPS_NOT_AVAILABLE,
57         NOT_ALLOWED_IN_OFFLINE_MODE,
58         SYSTEM_ERROR};
59
60     Location(QObject* parent = 0);
61     ~Location();
62     void start();
63     void end();
64     bool hasFix() const;
65     double getSignalStrength() const;
66     static void setUnit(Unit unit);
67     static Unit getUnit();
68     static double getUnitMultiplier();
69     static double getMeterMultiplier();
70
71 signals:
72     void locationChanged(Location::Fix const& fix);
73     void locationError(Location::Error error);
74
75 private:
76     static void onChanged(LocationGPSDevice *device, gpointer data);
77     static void onError(LocationGPSDControl *control, LocationGPSDControlError error, gpointer data);
78     bool started_;
79     LocationGPSDControl* control_;
80     LocationGPSDevice* device_;
81     static Unit unit_;
82 };
83
84 #endif