|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qgeosatelliteinfosource_maemo_p.h" |
|
43 |
|
44 QTM_BEGIN_NAMESPACE |
|
45 |
|
46 QGeoSatelliteInfoSourceMaemo::QGeoSatelliteInfoSourceMaemo(QObject *parent) : QGeoSatelliteInfoSource(parent), |
|
47 running(false), satInViewSeen(false) |
|
48 { |
|
49 requestTimer = new QTimer(this); |
|
50 QObject::connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimerExpired())); |
|
51 } |
|
52 |
|
53 |
|
54 int QGeoSatelliteInfoSourceMaemo::init() |
|
55 { |
|
56 dbusComm = new DBusComm(this); |
|
57 int status = dbusComm->init(); |
|
58 |
|
59 if (status == 0) { |
|
60 QObject::connect(dbusComm, SIGNAL(receivedSatellitesInView(const QList<QGeoSatelliteInfo> &)), |
|
61 this, SLOT(newSatellitesInView(const QList<QGeoSatelliteInfo> &))); |
|
62 QObject::connect(dbusComm, SIGNAL(receivedSatellitesInUse(const QList<QGeoSatelliteInfo> &)), |
|
63 this, SLOT(newSatellitesInUse(const QList<QGeoSatelliteInfo> &))); |
|
64 QObject::connect(dbusComm, SIGNAL(serviceConnected()), |
|
65 this, SLOT(onServiceConnect())); |
|
66 QObject::connect(dbusComm, SIGNAL(serviceDisconnected()), |
|
67 this, SLOT(onServiceDisconnect())); |
|
68 } |
|
69 |
|
70 return status; |
|
71 } |
|
72 |
|
73 |
|
74 void QGeoSatelliteInfoSourceMaemo::startUpdates() |
|
75 { |
|
76 if ( !requestTimer->isActive() ) |
|
77 dbusComm->sendConfigRequest(DBusComm::CommandSatStart, 0, 0); |
|
78 running = true; |
|
79 } |
|
80 |
|
81 |
|
82 void QGeoSatelliteInfoSourceMaemo::stopUpdates() |
|
83 { |
|
84 if ( !requestTimer->isActive() ) |
|
85 dbusComm->sendConfigRequest(DBusComm::CommandSatStop, 0, 0); |
|
86 running = false; |
|
87 } |
|
88 |
|
89 |
|
90 void QGeoSatelliteInfoSourceMaemo::requestUpdate(int timeout) |
|
91 { |
|
92 if ( !running ) |
|
93 dbusComm->sendConfigRequest(DBusComm::CommandSatStart, 0, 0); |
|
94 |
|
95 requestTimer->start(timeout); |
|
96 satInViewSeen = false; |
|
97 } |
|
98 |
|
99 |
|
100 void QGeoSatelliteInfoSourceMaemo::newSatellitesInView(const QList<QGeoSatelliteInfo> &update) |
|
101 { |
|
102 if ( requestTimer->isActive() && satInViewSeen ) { |
|
103 requestTimer->stop(); |
|
104 if ( !running ) |
|
105 dbusComm->sendConfigRequest(DBusComm::CommandSatStop, 0, 0); |
|
106 else |
|
107 emit satellitesInViewUpdated(update); |
|
108 } else { |
|
109 emit satellitesInViewUpdated(update); |
|
110 } |
|
111 |
|
112 satInViewSeen = true; |
|
113 } |
|
114 |
|
115 |
|
116 void QGeoSatelliteInfoSourceMaemo::newSatellitesInUse(const QList<QGeoSatelliteInfo> &update) |
|
117 { |
|
118 if ( requestTimer->isActive() ) { |
|
119 requestTimer->stop(); |
|
120 if ( !running ) |
|
121 dbusComm->sendConfigRequest(DBusComm::CommandSatStop, 0, 0); |
|
122 } |
|
123 |
|
124 emit satellitesInUseUpdated(update); |
|
125 } |
|
126 |
|
127 void QGeoSatelliteInfoSourceMaemo::requestTimerExpired() |
|
128 { |
|
129 requestTimer->stop(); |
|
130 |
|
131 if ( !running ) |
|
132 dbusComm->sendConfigRequest(DBusComm::CommandSatStop, 0, 0); |
|
133 |
|
134 emit requestTimeout(); |
|
135 } |
|
136 |
|
137 void QGeoSatelliteInfoSourceMaemo::onServiceDisconnect() |
|
138 { |
|
139 // |
|
140 } |
|
141 |
|
142 |
|
143 void QGeoSatelliteInfoSourceMaemo::onServiceConnect() |
|
144 { |
|
145 if (running) { |
|
146 dbusComm->sendConfigRequest(DBusComm::CommandSatStart, 0, 0); |
|
147 } |
|
148 } |
|
149 |
|
150 |
|
151 #include "moc_qgeosatelliteinfosource_maemo_p.cpp" |
|
152 QTM_END_NAMESPACE |
|
153 |