Merge lp:~thomas-voss/qtubuntu-sensors/add-position-plugin-in-preparation-for-dropping-qtlocation-distro-patch into lp:qtubuntu-sensors

Proposed by Thomas Voß
Status: Merged
Approved by: Timo Jyrinki
Approved revision: 53
Merged at revision: 44
Proposed branch: lp:~thomas-voss/qtubuntu-sensors/add-position-plugin-in-preparation-for-dropping-qtlocation-distro-patch
Merge into: lp:qtubuntu-sensors
Diff against target: 449 lines (+393/-0)
8 files modified
debian/control (+3/-0)
plugins/plugins.pro (+1/-0)
plugins/position/core_geo_position_info_source.cpp (+229/-0)
plugins/position/core_geo_position_info_source.h (+52/-0)
plugins/position/core_geo_position_info_source_factory.cpp (+32/-0)
plugins/position/core_geo_position_info_source_factory.h (+43/-0)
plugins/position/plugin.json (+7/-0)
plugins/position/position.pro (+26/-0)
To merge this branch: bzr merge lp:~thomas-voss/qtubuntu-sensors/add-position-plugin-in-preparation-for-dropping-qtlocation-distro-patch
Reviewer Review Type Date Requested Status
Timo Jyrinki Approve
Didier Roche-Tolomelli Approve
Martin Pitt Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+200703@code.launchpad.net

Commit message

Add the position plugin for QtLocation.

Description of the change

Add the position plugin for QtLocation.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
52. By Thomas Voß

Add Breaks for libqt5location5-plugins.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Martin Pitt (pitti) wrote :

> 16 +Breaks: libqt5location5-plugins (<< 5.0~git20130805-0ubuntu4)

This needs a corresponding Replaces: too (with the exact same value), otherwise apt might have trouble upgrading.

review: Needs Fixing
53. By Thomas Voß

Add missing Replaces in debian/control.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomas Voß (thomas-voss) wrote :

> > 16 +Breaks: libqt5location5-plugins (<< 5.0~git20130805-0ubuntu4)
>
> This needs a corresponding Replaces: too (with the exact same value),
> otherwise apt might have trouble upgrading.

Fixed.

Revision history for this message
Martin Pitt (pitti) wrote :

> Fixed.

Thanks, packaging ack. (I don't feel qualified to review the upstream additions).

review: Approve
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Based on IRC information, packaging ack as well. Need someone to review upstream code ;)

review: Approve
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Excellent, this is worth moving from a patch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-10-24 20:13:46 +0000
3+++ debian/control 2014-01-09 17:43:06 +0000
4@@ -8,6 +8,7 @@
5 qt5-default,
6 qtbase5-dev,
7 qtfeedback5-dev,
8+ qtlocation5-dev,
9 qtsensors5-dev,
10 Standards-Version: 3.9.4
11 Homepage: https://launchpad.net/qtubuntu-sensors
12@@ -23,5 +24,7 @@
13 Multi-Arch: same
14 Depends: ${misc:Depends},
15 ${shlibs:Depends},
16+Breaks: libqt5location5-plugins (<< 5.0~git20130805-0ubuntu4)
17+Replaces: libqt5location5-plugins (<< 5.0~git20130805-0ubuntu4)
18 Description: QtSensors plugins for Android sensors
19 QtSensors plugins for the qtubuntu (hybris) sensors backend
20
21=== modified file 'plugins/plugins.pro'
22--- plugins/plugins.pro 2014-01-07 10:35:49 +0000
23+++ plugins/plugins.pro 2014-01-09 17:43:06 +0000
24@@ -2,4 +2,5 @@
25
26 SUBDIRS += \
27 feedback \
28+ position \
29 sensors
30
31=== added directory 'plugins/position'
32=== added file 'plugins/position/core_geo_position_info_source.cpp'
33--- plugins/position/core_geo_position_info_source.cpp 1970-01-01 00:00:00 +0000
34+++ plugins/position/core_geo_position_info_source.cpp 2014-01-09 17:43:06 +0000
35@@ -0,0 +1,229 @@
36+/*
37+ * Copyright 2013 Canonical Ltd.
38+ *
39+ * This program is free software; you can redistribute it and/or modify
40+ * it under the terms of the GNU Lesser General Public License as published by
41+ * the Free Software Foundation; version 3.
42+ *
43+ * This program is distributed in the hope that it will be useful,
44+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
45+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46+ * GNU Lesser General Public License for more details.
47+ *
48+ * You should have received a copy of the GNU Lesser General Public License
49+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
50+ *
51+ * Author: Thomas Voß <thomas.voss@canonical.com>
52+ */
53+
54+#include "core_geo_position_info_source.h"
55+
56+#include <QtCore>
57+
58+#include <ubuntu/application/location/service.h>
59+#include <ubuntu/application/location/session.h>
60+
61+#include <ubuntu/application/location/heading_update.h>
62+#include <ubuntu/application/location/position_update.h>
63+#include <ubuntu/application/location/velocity_update.h>
64+
65+struct core::GeoPositionInfoSource::Private
66+{
67+ static const unsigned int empty_creation_flags = 0;
68+
69+ static void processPositionUpdate(
70+ UALocationPositionUpdate* position,
71+ void* context)
72+ {
73+ if (!position)
74+ return;
75+
76+ Private* thiz = static_cast<Private*>(context);
77+
78+ if (!thiz)
79+ return;
80+
81+ thiz->handlePositionUpdate(position);
82+ }
83+
84+ static void processHeadingUpdate(
85+ UALocationHeadingUpdate* heading,
86+ void* context)
87+ {
88+ if (!heading)
89+ return;
90+
91+ Private* thiz = static_cast<Private*>(context);
92+
93+ if (!thiz)
94+ return;
95+
96+ thiz->handleHeadingUpdate(heading);
97+ }
98+
99+ static void processVelocityUpdate(
100+ UALocationVelocityUpdate* velocity,
101+ void* context)
102+ {
103+ if (!velocity)
104+ return;
105+
106+ Private* thiz = static_cast<Private*>(context);
107+
108+ if (!thiz)
109+ return;
110+
111+ thiz->handleVelocityUpdate(velocity);
112+ }
113+
114+ void handlePositionUpdate(UALocationPositionUpdate* position)
115+ {
116+ QGeoCoordinate coord(
117+ ua_location_position_update_get_latitude_in_degree(position),
118+ ua_location_position_update_get_longitude_in_degree(position),
119+ ua_location_position_update_has_altitude(position) ? ua_location_position_update_get_altitude_in_meter(position) : 0);
120+
121+ lastKnownPosition.setCoordinate(coord);
122+ lastKnownPosition.setTimestamp(
123+ QDateTime::fromMSecsSinceEpoch(
124+ ua_location_position_update_get_timestamp(position)/1000));
125+
126+ QMetaObject::invokeMethod(
127+ parent,
128+ "positionUpdated",
129+ Qt::QueuedConnection,
130+ Q_ARG(QGeoPositionInfo, lastKnownPosition));
131+ }
132+
133+ void handleHeadingUpdate(UALocationHeadingUpdate* heading)
134+ {
135+ lastKnownPosition.setAttribute(
136+ QGeoPositionInfo::Direction,
137+ ua_location_heading_update_get_heading_in_degree(heading));
138+
139+ lastKnownPosition.setTimestamp(
140+ QDateTime::fromMSecsSinceEpoch(
141+ ua_location_heading_update_get_timestamp(heading)/1000));
142+
143+ QMetaObject::invokeMethod(
144+ parent,
145+ "positionUpdated",
146+ Qt::QueuedConnection,
147+ Q_ARG(QGeoPositionInfo, lastKnownPosition));
148+ };
149+
150+ void handleVelocityUpdate(UALocationVelocityUpdate* velocity)
151+ {
152+ lastKnownPosition.setAttribute(
153+ QGeoPositionInfo::GroundSpeed,
154+ ua_location_velocity_update_get_velocity_in_meters_per_second(velocity));
155+
156+ lastKnownPosition.setTimestamp(
157+ QDateTime::fromMSecsSinceEpoch(
158+ ua_location_velocity_update_get_timestamp(velocity)/1000));
159+
160+ QMetaObject::invokeMethod(
161+ parent,
162+ "positionUpdated",
163+ Qt::QueuedConnection,
164+ Q_ARG(QGeoPositionInfo, lastKnownPosition));
165+ };
166+
167+ Private(core::GeoPositionInfoSource* parent)
168+ : parent(parent),
169+ session(ua_location_service_create_session_for_high_accuracy(empty_creation_flags))
170+ {
171+ qRegisterMetaType<QGeoPositionInfo>("QGeoPositionInfo");
172+
173+ ua_location_service_session_set_position_updates_handler(
174+ session,
175+ processPositionUpdate,
176+ this);
177+
178+ ua_location_service_session_set_heading_updates_handler(
179+ session,
180+ processHeadingUpdate,
181+ this);
182+
183+ ua_location_service_session_set_velocity_updates_handler(
184+ session,
185+ processVelocityUpdate,
186+ this);
187+ }
188+
189+ ~Private()
190+ {
191+ ua_location_service_session_unref(session);
192+ }
193+
194+ core::GeoPositionInfoSource* parent;
195+ UALocationServiceSession* session;
196+ QGeoPositionInfo lastKnownPosition;
197+ QTimer timer;
198+};
199+
200+core::GeoPositionInfoSource::GeoPositionInfoSource(QObject *parent)
201+ : QGeoPositionInfoSource(parent), d(new Private(this))
202+{
203+ d->timer.setSingleShot(true);
204+ QObject::connect(&d->timer, SIGNAL(timeout()), this, SLOT(updateTimeout()));
205+}
206+
207+core::GeoPositionInfoSource::~GeoPositionInfoSource()
208+{
209+}
210+
211+void core::GeoPositionInfoSource::setUpdateInterval(int msec)
212+{
213+ (void) msec;
214+}
215+
216+void core::GeoPositionInfoSource::setPreferredPositioningMethods(PositioningMethods methods)
217+{
218+ QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
219+}
220+
221+QGeoPositionInfo core::GeoPositionInfoSource::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
222+{
223+ Q_UNUSED(fromSatellitePositioningMethodsOnly);
224+ return d->lastKnownPosition;
225+}
226+
227+QGeoPositionInfoSource::PositioningMethods core::GeoPositionInfoSource::supportedPositioningMethods() const
228+{
229+ return AllPositioningMethods;
230+}
231+
232+void core::GeoPositionInfoSource::startUpdates()
233+{
234+ ua_location_service_session_start_position_updates(d->session);
235+ ua_location_service_session_start_heading_updates(d->session);
236+ ua_location_service_session_start_velocity_updates(d->session);
237+}
238+
239+int core::GeoPositionInfoSource::minimumUpdateInterval() const {
240+ return 500;
241+}
242+
243+void core::GeoPositionInfoSource::stopUpdates()
244+{
245+ ua_location_service_session_stop_position_updates(d->session);
246+ ua_location_service_session_stop_heading_updates(d->session);
247+ ua_location_service_session_stop_velocity_updates(d->session);
248+}
249+
250+void core::GeoPositionInfoSource::requestUpdate(int timeout)
251+{
252+ if (d->timer.isActive())
253+ {
254+ return;
255+ }
256+
257+ startUpdates();
258+ d->timer.start(timeout);
259+}
260+
261+QGeoPositionInfoSource::Error core::GeoPositionInfoSource::error() const
262+{
263+ return UnknownSourceError;
264+}
265
266=== added file 'plugins/position/core_geo_position_info_source.h'
267--- plugins/position/core_geo_position_info_source.h 1970-01-01 00:00:00 +0000
268+++ plugins/position/core_geo_position_info_source.h 2014-01-09 17:43:06 +0000
269@@ -0,0 +1,52 @@
270+/*
271+ * Copyright 2013 Canonical Ltd.
272+ *
273+ * This program is free software; you can redistribute it and/or modify
274+ * it under the terms of the GNU Lesser General Public License as published by
275+ * the Free Software Foundation; version 3.
276+ *
277+ * This program is distributed in the hope that it will be useful,
278+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
279+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
280+ * GNU Lesser General Public License for more details.
281+ *
282+ * You should have received a copy of the GNU Lesser General Public License
283+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
284+ *
285+ * Author: Thomas Voß <thomas.voss@canonical.com>
286+ */
287+
288+#ifndef CORE_GEO_POSITION_INFO_SOURCE_H
289+#define CORE_GEO_POSITION_INFO_SOURCE_H
290+
291+#include <qgeopositioninfosource.h>
292+
293+namespace core
294+{
295+class GeoPositionInfoSource : public QGeoPositionInfoSource
296+{
297+ Q_OBJECT
298+public:
299+ GeoPositionInfoSource(QObject *parent = 0);
300+ ~GeoPositionInfoSource();
301+
302+ // From QGeoPositionInfoSource
303+ void setUpdateInterval(int msec);
304+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
305+ PositioningMethods supportedPositioningMethods() const;
306+ void setPreferredPositioningMethods(PositioningMethods methods);
307+ int minimumUpdateInterval() const;
308+ Error error() const;
309+
310+public slots:
311+ virtual void startUpdates();
312+ virtual void stopUpdates();
313+ virtual void requestUpdate(int timeout = 5000);
314+
315+private:
316+ struct Private;
317+ QScopedPointer<Private> d;
318+};
319+}
320+
321+#endif // CORE_GEO_POSITION_INFO_SOURCE_H
322
323=== added file 'plugins/position/core_geo_position_info_source_factory.cpp'
324--- plugins/position/core_geo_position_info_source_factory.cpp 1970-01-01 00:00:00 +0000
325+++ plugins/position/core_geo_position_info_source_factory.cpp 2014-01-09 17:43:06 +0000
326@@ -0,0 +1,32 @@
327+/*
328+ * Copyright 2013 Canonical Ltd.
329+ *
330+ * This program is free software; you can redistribute it and/or modify
331+ * it under the terms of the GNU Lesser General Public License as published by
332+ * the Free Software Foundation; version 3.
333+ *
334+ * This program is distributed in the hope that it will be useful,
335+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
336+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
337+ * GNU Lesser General Public License for more details.
338+ *
339+ * You should have received a copy of the GNU Lesser General Public License
340+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
341+ *
342+ * Author: Thomas Voß <thomas.voss@canonical.com>
343+ */
344+
345+#include "core_geo_position_info_source_factory.h"
346+#include "core_geo_position_info_source.h"
347+
348+QGeoPositionInfoSource *core::GeoPositionInfoSourceFactory::positionInfoSource(QObject *parent)
349+{
350+ core::GeoPositionInfoSource *src = new core::GeoPositionInfoSource(parent);
351+ return src;
352+}
353+
354+QGeoSatelliteInfoSource *core::GeoPositionInfoSourceFactory::satelliteInfoSource(QObject *parent)
355+{
356+ Q_UNUSED(parent);
357+ return 0;
358+}
359
360=== added file 'plugins/position/core_geo_position_info_source_factory.h'
361--- plugins/position/core_geo_position_info_source_factory.h 1970-01-01 00:00:00 +0000
362+++ plugins/position/core_geo_position_info_source_factory.h 2014-01-09 17:43:06 +0000
363@@ -0,0 +1,43 @@
364+/*
365+ * Copyright 2013 Canonical Ltd.
366+ *
367+ * This program is free software; you can redistribute it and/or modify
368+ * it under the terms of the GNU Lesser General Public License as published by
369+ * the Free Software Foundation; version 3.
370+ *
371+ * This program is distributed in the hope that it will be useful,
372+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
373+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
374+ * GNU Lesser General Public License for more details.
375+ *
376+ * You should have received a copy of the GNU Lesser General Public License
377+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
378+ *
379+ * Author: Thomas Voß <thomas.voss@canonical.com>
380+ */
381+
382+#ifndef CORE_GEO_POSITION_INFO_SOURCE_FACTORY_H
383+#define CORE_GEO_POSITION_INFO_SOURCE_FACTORY_H
384+
385+#include <QObject>
386+#include "qgeopositioninfosource.h"
387+#include "qgeopositioninfosourcefactory.h"
388+
389+namespace core
390+{
391+class GeoPositionInfoSourceFactory
392+ : public QObject,
393+ public QGeoPositionInfoSourceFactory
394+{
395+ Q_OBJECT
396+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/5.0"
397+ FILE "plugin.json")
398+ Q_INTERFACES(QGeoPositionInfoSourceFactory)
399+
400+public:
401+ QGeoPositionInfoSource *positionInfoSource(QObject *parent);
402+ QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
403+};
404+}
405+
406+#endif // CORE_GEO_POSITION_INFO_SOURCE_FACTORY_H
407
408=== added file 'plugins/position/plugin.json'
409--- plugins/position/plugin.json 1970-01-01 00:00:00 +0000
410+++ plugins/position/plugin.json 2014-01-09 17:43:06 +0000
411@@ -0,0 +1,7 @@
412+{
413+ "Keys": ["ubuntu"],
414+ "Provider": "ubuntu",
415+ "Position": true,
416+ "Satellite": false,
417+ "Priority": 2000
418+}
419
420=== added file 'plugins/position/position.pro'
421--- plugins/position/position.pro 1970-01-01 00:00:00 +0000
422+++ plugins/position/position.pro 2014-01-09 17:43:06 +0000
423@@ -0,0 +1,26 @@
424+QT += location core
425+
426+TEMPLATE = lib
427+CONFIG += link_pkgconfig plugin
428+TARGET = $$qtLibraryTarget(qtposition_ubuntu)
429+PLUGIN_TYPE = position
430+
431+QT = location core
432+
433+HEADERS += \
434+ core_geo_position_info_source.h \
435+ core_geo_position_info_source_factory.h
436+
437+SOURCES += \
438+ core_geo_position_info_source.cpp \
439+ core_geo_position_info_source_factory.cpp
440+
441+INCLUDEPATH += $$PWD/
442+
443+PKGCONFIG += ubuntu-platform-api
444+LIBS += -lubuntu_application_api
445+
446+target.path += $$[QT_INSTALL_PLUGINS]/position
447+INSTALLS += target
448+
449+OTHER_FILES += plugin.json

Subscribers

People subscribed via source and target branches