20016ac8db8bf9808ad66890f617b0d4d8fb8ad5
[situare] / src / gps / gpspositionprivatestub.cpp
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 #include <QDebug>
23 #include <QTimer>
24
25 #include "error.h"
26 #include "gpsposition.h"
27 #include "gpspositionprivatestub.h"
28
29 const GeoCoordinate COORDINATE(65.0105, 25.5091);
30
31 GPSPositionPrivate::GPSPositionPrivate(QObject *parent)
32     : QObject(parent),
33       m_running(false)
34 {
35     qDebug() << __PRETTY_FUNCTION__;
36
37     m_parent = static_cast<GPSPosition*>(parent);
38     m_timer = new QTimer(this);
39     connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
40     m_timer->setInterval(5000);
41 }
42
43 bool GPSPositionPrivate::isInitialized() const
44 {
45     qDebug() << __PRETTY_FUNCTION__;
46
47     return true;
48 }
49
50 bool GPSPositionPrivate::isRunning() const
51 {
52     qDebug() << __PRETTY_FUNCTION__;
53
54     return m_running;
55 }
56
57 void GPSPositionPrivate::setUpdateInterval(int interval)
58 {
59     qDebug() << __PRETTY_FUNCTION__;
60
61     Q_UNUSED(interval);
62     m_timer->setInterval(interval);
63 }
64
65 void GPSPositionPrivate::setMode(GPSPosition::Mode mode, const QString &filePath)
66 {
67     qDebug() << __PRETTY_FUNCTION__;
68
69     Q_UNUSED(mode);
70     Q_UNUSED(filePath);
71 }
72
73 void GPSPositionPrivate::setPowerSave(bool enabled)
74 {
75     qDebug() << __PRETTY_FUNCTION__;
76
77     if (enabled)
78         stop();
79     else
80         start();
81 }
82
83 void GPSPositionPrivate::start()
84 {
85     qDebug() << __PRETTY_FUNCTION__;
86
87     m_running = true;
88     m_timer->start();
89 }
90
91 void GPSPositionPrivate::stop()
92 {
93     qDebug() << __PRETTY_FUNCTION__;
94
95     m_running = false;
96     m_timer->stop();
97 }
98
99 void GPSPositionPrivate::timeout()
100 {
101     emit m_parent->position(COORDINATE, 100.0);
102 }
103
104 GeoCoordinate GPSPositionPrivate::lastPosition() const
105 {
106     qDebug() << __PRETTY_FUNCTION__;
107
108     return COORDINATE;
109 }
110
111 void GPSPositionPrivate::requestLastPosition()
112 {
113     qDebug() << __PRETTY_FUNCTION__;
114
115     emit m_parent->position(COORDINATE, 100.0);
116 }
117
118 void GPSPositionPrivate::requestUpdate()
119 {
120     qDebug() << __PRETTY_FUNCTION__;
121
122     start();
123 }