Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove dependency on libgeoclue.
Re-implement Geoclue plugin using only Qt DBus dropping both the
build-time and run-time dependency on libgeoclue. Allowing the Geoclue
plugin to be build on all platforms that support Qt DBus.

The priority of the Geoclue plugin has been lowered slightly so that
the native position plugin, if available, has precedence.

[ChangeLog][QtPositioning][Position] The Geoclue plugin has been
re-implemented using Qt DBus.

Task-number: QTBUG-40702
Change-Id: Ia06d089bfb46c10769ccffd765c044c361a9b484
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>

Upstream commit SHA1: a3cb74a
  • Loading branch information
amccarthy authored and rainemak committed Jan 15, 2018
1 parent 150659e commit 39d34ad
Show file tree
Hide file tree
Showing 28 changed files with 872 additions and 641 deletions.
6 changes: 0 additions & 6 deletions config.tests/geoclue-satellite/geoclue-satellite.pro

This file was deleted.

49 changes: 0 additions & 49 deletions config.tests/geoclue-satellite/main.cpp

This file was deleted.

6 changes: 0 additions & 6 deletions config.tests/geoclue/geoclue.pro

This file was deleted.

2 changes: 0 additions & 2 deletions qtlocation.pro
@@ -1,6 +1,4 @@
load(configure)
qtCompileTest(geoclue)
qtCompileTest(geoclue-satellite)
qtCompileTest(gypsy)

load(qt_parts)
39 changes: 21 additions & 18 deletions src/plugins/position/geoclue/geoclue.pro
@@ -1,33 +1,36 @@
TARGET = qtposition_geoclue
QT = core positioning
QT = core positioning dbus

PLUGIN_TYPE = position
load(qt_plugin)

HEADERS += \
qgeopositioninfosource_geocluemaster_p.h \
qgeopositioninfosource_geocluemaster.h \
qgeosatelliteinfosource_geocluemaster.h \
qgeopositioninfosourcefactory_geoclue.h \
qgeocluemaster.h
qgeocluemaster.h \
geocluetypes.h

SOURCES += \
qgeopositioninfosource_geocluemaster.cpp \
qgeosatelliteinfosource_geocluemaster.cpp \
qgeopositioninfosourcefactory_geoclue.cpp \
qgeocluemaster.cpp
qgeocluemaster.cpp \
geocluetypes.cpp

QDBUSXML2CPP_INTERFACE_HEADER_FLAGS += "-N -i geocluetypes.h"
DBUS_INTERFACES += \
org.freedesktop.Geoclue.MasterClient.xml \
org.freedesktop.Geoclue.Master.xml \
org.freedesktop.Geoclue.Position.xml \
org.freedesktop.Geoclue.Velocity.xml \
org.freedesktop.Geoclue.Satellite.xml \
org.freedesktop.Geoclue.xml

qtHaveModule(dbus):config_geoclue-satellite {
DEFINES += HAS_SATELLITE

QT *= dbus

HEADERS += qgeosatelliteinfosource_geocluemaster.h
SOURCES += qgeosatelliteinfosource_geocluemaster.cpp
}

INCLUDEPATH += $$QT.location.includes
OTHER_FILES += \
$$DBUS_INTERFACES

CONFIG += link_pkgconfig
PKGCONFIG += geoclue
INCLUDEPATH += $$QT.location.includes $$OUT_PWD

OTHER_FILES += \
plugin.json \
plugin-satellite.json
plugin.json
99 changes: 99 additions & 0 deletions src/plugins/position/geoclue/geocluetypes.cpp
@@ -0,0 +1,99 @@
/****************************************************************************
**
** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "geocluetypes.h"

const QDBusArgument &dbus_argument_helper(const QDBusArgument &arg, Accuracy &accuracy)
{
arg.beginStructure();
qint32 level;
arg >> level;
accuracy.m_level = static_cast<Accuracy::Level>(level);
arg >> accuracy.m_horizontal;
arg >> accuracy.m_vertical;
arg.endStructure();

return arg;
}

QT_BEGIN_NAMESPACE

QDBusArgument &operator<<(QDBusArgument &arg, const Accuracy &accuracy)
{
arg.beginStructure();
arg << qint32(accuracy.level());
arg << accuracy.horizontal();
arg << accuracy.vertical();
arg.endStructure();

return arg;
}

const QDBusArgument &operator>>(const QDBusArgument &arg, Accuracy &accuracy)
{
return dbus_argument_helper(arg, accuracy);
}

const QDBusArgument &operator>>(const QDBusArgument &argument, QGeoSatelliteInfo &si)
{
qint32 a;

argument.beginStructure();
argument >> a;
si.setSatelliteIdentifier(a);
argument >> a;
si.setAttribute(QGeoSatelliteInfo::Elevation, a);
argument >> a;
si.setAttribute(QGeoSatelliteInfo::Azimuth, a);
argument >> a;
si.setSignalStrength(a);
argument.endStructure();
return argument;
}

const QDBusArgument &operator>>(const QDBusArgument &argument, QList<QGeoSatelliteInfo> &sis)
{
sis.clear();

argument.beginArray();
while (!argument.atEnd()) {
QGeoSatelliteInfo si;
argument >> si;
sis.append(si);
}
argument.endArray();

return argument;
}

QT_END_NAMESPACE
Expand Up @@ -3,9 +3,10 @@
** Copyright (C) 2013 Jolla Ltd.
** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtLocation module of the Qt Toolkit.
** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
Expand Down Expand Up @@ -41,16 +42,57 @@
**
****************************************************************************/

#include <geoclue/geoclue-position.h>
#include <geoclue/geoclue-velocity.h>
#ifndef GEOCLUETYPES_H
#define GEOCLUETYPES_H

int main()
#include <QtDBus/QDBusArgument>
#include <QtPositioning/QGeoSatelliteInfo>

class Accuracy
{
GType type = geoclue_position_get_type();
GeocluePosition position;
public:
enum Level {
None = 0,
Country,
Region,
Locality,
PostalCode,
Street,
Detailed
};

Accuracy()
: m_level(None), m_horizontal(0), m_vertical(0)
{
}

inline Level level() const { return m_level; }
inline double horizontal() const { return m_horizontal; }
inline double vertical() const { return m_vertical; }

private:
Level m_level;
double m_horizontal;
double m_vertical;

friend const QDBusArgument &dbus_argument_helper(const QDBusArgument &arg, Accuracy &accuracy);
};

Q_DECLARE_METATYPE(Accuracy)
Q_DECLARE_METATYPE(QList<QGeoSatelliteInfo>)


QT_BEGIN_NAMESPACE

Q_DECLARE_TYPEINFO(Accuracy, Q_MOVABLE_TYPE);

QDBusArgument &operator<<(QDBusArgument &arg, const Accuracy &accuracy);
const QDBusArgument &operator>>(const QDBusArgument &arg, Accuracy &accuracy);

const QDBusArgument &operator>>(const QDBusArgument &arg, QGeoSatelliteInfo &si);
const QDBusArgument &operator>>(const QDBusArgument &arg, QList<QGeoSatelliteInfo> &sis);

QT_END_NAMESPACE

type = geoclue_velocity_get_type();
GeoclueVelocity velocity;
#endif // GEOCLUETYPES_H

return 0;
}
10 changes: 10 additions & 0 deletions src/plugins/position/geoclue/org.freedesktop.Geoclue.Master.xml
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.Geoclue.Master">
<method name="Create">
<arg name="path" type="o" direction="out"/>
</method>
</interface>
</node>

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.Geoclue.MasterClient">
<method name="GetPositionProvider">
<arg name="name" type="s" direction="out"/>
<arg name="description" type="s" direction="out"/>
<arg name="service" type="s" direction="out"/>
<arg name="path" type="s" direction="out"/>
</method>
<method name="GetAddressProvider">
<arg name="name" type="s" direction="out"/>
<arg name="description" type="s" direction="out"/>
<arg name="service" type="s" direction="out"/>
<arg name="path" type="s" direction="out"/>
</method>
<method name="PositionStart">
</method>
<method name="AddressStart">
</method>
<method name="SetRequirements">
<arg name="accuracyLevel" type="i" direction="in"/>
<arg name="time" type="i" direction="in"/>
<arg name="requireUpdates" type="b" direction="in"/>
<arg name="allowedResources" type="i" direction="in"/>
</method>
<signal name="PositionProviderChanged">
<arg name="name" type="s"/>
<arg name="description" type="s"/>
<arg name="service" type="s"/>
<arg name="path" type="s"/>
</signal>
<signal name="AddressProviderChanged">
<arg name="name" type="s"/>
<arg name="description" type="s"/>
<arg name="service" type="s"/>
<arg name="path" type="s"/>
</signal>
</interface>
</node>

25 changes: 25 additions & 0 deletions src/plugins/position/geoclue/org.freedesktop.Geoclue.Position.xml
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.Geoclue.Position">
<method name="GetPosition">
<arg name="fields" type="i" direction="out"/>
<arg name="timestamp" type="i" direction="out"/>
<arg name="latitude" type="d" direction="out"/>
<arg name="longitude" type="d" direction="out"/>
<arg name="altitude" type="d" direction="out"/>
<arg name="accuracy" type="(idd)" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out5" value="Accuracy"/>
</method>
<signal name="PositionChanged">
<arg name="fields" type="i"/>
<arg name="timestamp" type="i"/>
<arg name="latitude" type="d"/>
<arg name="longitude" type="d"/>
<arg name="altitude" type="d"/>
<arg name="accuracy" type="(idd)"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In5" value="Accuracy"/>
</signal>
</interface>
</node>

0 comments on commit 39d34ad

Please sign in to comment.