Merge branch 'master' into gps
[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 <QGeoPositionInfoSource>
26 #include <QPointF>
27
28 QTM_USE_NAMESPACE
29
30 /**
31 * @brief GPSPosition class use GPS to receive location information.
32 *
33 * @class GPSPosition engine.h "gps/gpsposition.h"
34 */
35 class GPSPosition : public QObject
36 {
37     Q_OBJECT
38
39 public:
40     /**
41     * @brief Start GPS.
42     */
43     GPSPosition(QObject *parent = 0);
44     ~GPSPosition();
45
46 /******************************************************************************
47 * MEMBER FUNCTIONS AND SLOTS
48 ******************************************************************************/
49 public:
50     /**
51     * @brief Checks if GPS is running.
52     *
53     * @return true if GPS running, false otherwise
54     */
55     bool isRunning();
56
57     /**
58     * @brief Start GPS.
59     */
60     void start();
61
62     /**
63     * @brief Stop GPS.
64     */
65     void stop();
66
67     /**
68     * @brief Request GPS update.
69     */
70     void update();
71
72 private slots:
73
74     /**
75     * @brief Slot for received position update.
76     *
77     * @param positionInfo Geo position info.
78     */
79     void positionUpdated(QGeoPositionInfo positionInfo);
80
81     /**
82     * @brief Slot for update timeout.
83     *
84     * Called when request timeout occurs.
85     */
86     void updateTimeout();
87
88 /******************************************************************************
89 * SIGNALS
90 ******************************************************************************/
91 signals:
92     /**
93     * @brief Signal for position information.
94     *
95     * @param latLonCoordinate latitude and longitude values
96     */
97     void position(QPointF latLonCoordinate);
98
99     /**
100     * @brief Signal for timeout.
101     */
102     void timeout();
103
104     /**
105     * @brief Signal for error.
106     *
107     * @param message error message
108     */
109     void error(const QString &message);
110
111 private:
112     QGeoPositionInfoSource *m_gpsSource;        ///< GPS position info source
113     bool m_running;                             ///< GPS is running
114     int m_updateInterval;                       ///< GPS update interval
115 };
116
117 const int DEFAULT_UPDATE_INTERVAL = 5000;   ///< Default update interval
118
119 #endif // GPSPOSITION_H