Modified route arrow icons.
[situare] / src / gps / gpsposition.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jussi Laitinen - jussi.laitinen@ixonos.com
6
7    Situare is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as published by the Free Software Foundation.
10
11    Situare is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with Situare; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19    USA.
20 */
21
22 #ifndef GPSPOSITION_H
23 #define GPSPOSITION_H
24
25 #include <QObject>
26
27 #include "coordinates/geocoordinate.h"
28
29 class GPSPositionPrivate;
30
31 /**
32 * @brief GPSPosition class is an interface for GPS.
33 */
34 class GPSPosition : public QObject
35 {
36     Q_OBJECT
37
38 public:
39     /**
40     * @brief Friend class for GPSPosition.
41     */
42     friend class GPSPositionPrivate;
43
44     /**
45     * @brief Constructor.
46     *
47     * @param parent QObject
48     */
49     GPSPosition(QObject *parent = 0);
50
51     /**
52     * @brief GPS position mode.
53     */
54     enum Mode {Default, Simulation};
55
56 /******************************************************************************
57 * MEMBER FUNCTIONS AND SLOTS
58 ******************************************************************************/
59 public:
60     /**
61     * @brief Enables power save mode.
62     *
63     * Starts GPS for position update and then stops it.
64     */
65     void enablePowerSave(bool enabled);
66
67     /**
68     * @brief Returns is GPS initialized.
69     *
70     * @return true if initialized, false otherwise
71     */
72     bool isInitialized() const;
73
74     /**
75     * @brief Checks if GPS is running.
76     *
77     * @return true if GPS running, false otherwise
78     */
79     bool isRunning() const;
80
81     /**
82     * @brief Return last known position.
83     */
84     GeoCoordinate lastPosition() const;
85
86     /**
87     * @brief Informs gps to emit last known position.
88     */
89     void requestLastPosition();
90
91     /**
92     * @brief Requests update from GPS.
93     *
94     * Enables GPS if it is disabled
95     */
96     void requestUpdate();
97
98     /**
99     * @brief Set GPS mode.
100     *
101     * Modes: default and simulation.
102     * @param mode GPS mode
103     * @param filePath file path to NMEA file if simulation mode is used
104     */
105     void setMode(Mode mode, const QString &filePath = 0);
106
107     /**
108     * @brief Set GPS update interval
109     *
110     * @return interval interval in milliseconds
111     */
112     void setUpdateInterval(int interval);
113
114     /**
115     * @brief Start GPS.
116     */
117     void start();
118
119     /**
120     * @brief Stop GPS.
121     */
122     void stop();
123
124 /******************************************************************************
125 * SIGNALS
126 ******************************************************************************/
127 signals:
128     /**
129     * @brief Signals error
130     *
131     * @param context error context
132     * @param error error code
133     */
134     void error(const int context, const int error);
135
136     /**
137     * @brief Signal for position information.
138     *
139     * @param coordinate latitude and longitude values
140     * @param accuracy accuracy in metres
141     */
142     void position(GeoCoordinate coordinate, qreal accuracy);
143
144     /**
145     * @brief Signal for timeout.
146     */
147     void timeout();
148
149 /*******************************************************************************
150 * DATA MEMBERS
151 *******************************************************************************/
152 private:
153     GPSPositionPrivate *m_gpsPositionPrivate;   ///< GPSPositionPrivate object
154 };
155
156 #endif // GPSPOSITIONINTERFACE_H