summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-07-29 18:10:32 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-30 09:10:14 +0000
commitffcfc067242de73fa276b448055b2b890678d840 (patch)
tree07390faeab525b9f660ddd9d5dd5d990c49e8d9d
parent981a3b86b221d46f1657407193f011934dead94c (diff)
downloadqtlocation-ffcfc067242de73fa276b448055b2b890678d840.tar.gz
GeoClue v2: do not use env variables and update docs
There is no need in using the environment variable to set the desktop id parameter. This patch introduces parsing of the desktop id parameter from the provided plugin parameters. It also introduces a separate page with the plugin documentation. Task-number: QTBUG-74995 Change-Id: Ie59e2410709dc9517b305f0b490d35c6718ce9ba Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 9a6f7a2d31829b541b688b68cff85ffaa1ee2d1c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp29
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h5
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp2
-rw-r--r--src/positioning/doc/src/external-resources.qdoc10
-rw-r--r--src/positioning/doc/src/plugins/geoclue2.qdoc86
-rw-r--r--src/positioning/doc/src/qtpositioning-plugins.qdoc5
6 files changed, 123 insertions, 14 deletions
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
index 34a1a035..3c78a075 100644
--- a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
+++ b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
@@ -68,6 +68,7 @@ enum GClueAccuracyLevel {
const char GEOCLUE2_SERVICE_NAME[] = "org.freedesktop.GeoClue2";
const int MINIMUM_UPDATE_INTERVAL = 1000;
const int UPDATE_TIMEOUT_COLD_START = 120000;
+static const auto desktopIdParameter = "desktopId";
static QString lastPositionFilePath()
{
@@ -77,7 +78,8 @@ static QString lastPositionFilePath()
} // namespace
-QGeoPositionInfoSourceGeoclue2::QGeoPositionInfoSourceGeoclue2(QObject *parent)
+QGeoPositionInfoSourceGeoclue2::QGeoPositionInfoSourceGeoclue2(const QVariantMap &parameters,
+ QObject *parent)
: QGeoPositionInfoSource(parent)
, m_requestTimer(new QTimer(this))
, m_manager(QLatin1String(GEOCLUE2_SERVICE_NAME),
@@ -85,6 +87,8 @@ QGeoPositionInfoSourceGeoclue2::QGeoPositionInfoSourceGeoclue2(QObject *parent)
QDBusConnection::systemBus(),
this)
{
+ parseParameters(parameters);
+
qDBusRegisterMetaType<Timestamp>();
restoreLastPosition();
@@ -347,19 +351,15 @@ bool QGeoPositionInfoSourceGeoclue2::configureClient()
if (!m_client)
return false;
- auto desktopId = QString::fromUtf8(qgetenv("QT_GEOCLUE_APP_DESKTOP_ID"));
- if (desktopId.isEmpty())
- desktopId = QCoreApplication::applicationName();
- if (desktopId.isEmpty()) {
- qCCritical(lcPositioningGeoclue2) << "Unable to configure the client "
- "due to the application desktop id "
- "is not set via QT_GEOCLUE_APP_DESKTOP_ID "
- "envirorment variable or QCoreApplication::applicationName";
+ if (m_desktopId.isEmpty()) {
+ qCCritical(lcPositioningGeoclue2)
+ << "Unable to configure the client due to the desktop id is not set via"
+ << desktopIdParameter << "plugin parameter or QCoreApplication::applicationName";
setError(AccessError);
return false;
}
- m_client->setDesktopId(desktopId);
+ m_client->setDesktopId(m_desktopId);
const auto msecs = updateInterval();
const uint secs = qMax(uint(msecs), 0u) / 1000u;
@@ -446,4 +446,13 @@ void QGeoPositionInfoSourceGeoclue2::handleNewLocation(const QDBusObjectPath &ol
stopClient();
}
+void QGeoPositionInfoSourceGeoclue2::parseParameters(const QVariantMap &parameters)
+{
+ if (parameters.contains(desktopIdParameter))
+ m_desktopId = parameters.value(desktopIdParameter).toString();
+
+ if (m_desktopId.isEmpty())
+ m_desktopId = QCoreApplication::applicationName();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h
index 16f5b9a1..f5ec2b06 100644
--- a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h
+++ b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h
@@ -55,7 +55,8 @@ class QGeoPositionInfoSourceGeoclue2 : public QGeoPositionInfoSource
Q_OBJECT
public:
- explicit QGeoPositionInfoSourceGeoclue2(QObject *parent = nullptr);
+ explicit QGeoPositionInfoSourceGeoclue2(const QVariantMap &parameters,
+ QObject *parent = nullptr);
~QGeoPositionInfoSourceGeoclue2();
// From QGeoPositionInfoSource
@@ -82,6 +83,7 @@ private:
void requestUpdateTimeout();
void handleNewLocation(const QDBusObjectPath &oldLocation,
const QDBusObjectPath &newLocation);
+ void parseParameters(const QVariantMap &parameters);
QTimer *m_requestTimer = nullptr;
OrgFreedesktopGeoClue2ManagerInterface m_manager;
@@ -90,6 +92,7 @@ private:
bool m_lastPositionFromSatellite = false;
QGeoPositionInfoSource::Error m_error = NoError;
QGeoPositionInfo m_lastPosition;
+ QString m_desktopId;
};
QT_END_NAMESPACE
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp b/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp
index 68caba3a..68161f41 100644
--- a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp
+++ b/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryGeoclue2::positionInfoSource(QObject *parent, const QVariantMap &parameters)
{
Q_UNUSED(parameters)
- return new QGeoPositionInfoSourceGeoclue2(parent);
+ return new QGeoPositionInfoSourceGeoclue2(parameters, parent);
}
QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryGeoclue2::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
diff --git a/src/positioning/doc/src/external-resources.qdoc b/src/positioning/doc/src/external-resources.qdoc
index 3c71d1f5..41da9bb1 100644
--- a/src/positioning/doc/src/external-resources.qdoc
+++ b/src/positioning/doc/src/external-resources.qdoc
@@ -44,3 +44,13 @@
\externalpage https://developer.android.com/training/location/background
\title Access Location in the Background
*/
+
+/*!
+\externalpage https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home
+\title GeoClue service
+*/
+
+/*!
+\externalpage https://www.freedesktop.org/software/geoclue/docs/gdbus-org.freedesktop.GeoClue2.Client.html#gdbus-property-org-freedesktop-GeoClue2-Client.DesktopId
+\title GeoClue DesktopId property
+*/
diff --git a/src/positioning/doc/src/plugins/geoclue2.qdoc b/src/positioning/doc/src/plugins/geoclue2.qdoc
new file mode 100644
index 00000000..13ba2d2d
--- /dev/null
+++ b/src/positioning/doc/src/plugins/geoclue2.qdoc
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page position-plugin-geoclue2.html
+\title Qt Positioning GeoClue v2 plugin
+\ingroup QtPositioning-plugins
+
+\brief Uses the GeoClue v2 library to provide positioning updates
+
+\section1 Overview
+
+This plugin is an interface to the \l {GeoClue service}{GeoClue v2} library.
+It requires this library to be installed on the system to function.
+
+The plugin uses D-Bus to establish communication with the GeoClue v2 D-Bus
+service and to provide positioning information.
+
+The plugin can be used to receive only the positioning information.
+It \e {does not} provide satellite information.
+
+The plugin can be loaded by using the provider name \b geoclue2.
+
+\section1 Parameters
+
+The following table lists parameters that \e can be passed to the geoclue2
+plugin.
+
+\table
+\header
+ \li Parameter
+ \li Description
+\row
+ \li desktopId
+ \li The \l {GeoClue DesktopId property}{Desktop Id} property used by the
+ D-Bus service. If the parameter is not specified, the application name
+ provided by \l QCoreApplication::applicationName() is used.
+\endtable
+
+\section1 Usage example
+
+The following examples show how to create a \b geoclue2 PositionSource from
+C++ and QML.
+
+\section2 QML
+
+\code
+PositionSource {
+ name: "geoclue2"
+ PluginParameter { name: "desktopId"; value: "SomeIdentifierString" }
+}
+\endcode
+
+\section2 C++
+
+\code
+QVariantMap params;
+params["desktopId"] = "SomeIdentifierString";
+QGeoPositionInfoSource *positionSource = QGeoPositionInfoSource::createSource("geoclue2", params, this);
+\endcode
+
+*/
diff --git a/src/positioning/doc/src/qtpositioning-plugins.qdoc b/src/positioning/doc/src/qtpositioning-plugins.qdoc
index 54ec100a..c87a6d01 100644
--- a/src/positioning/doc/src/qtpositioning-plugins.qdoc
+++ b/src/positioning/doc/src/qtpositioning-plugins.qdoc
@@ -45,7 +45,8 @@ Some plugins already ship with Qt. These are:
\li Wraps iOS and macOS positioning subsystems. Available only on Apple platforms supporting corelocation.
\row
\li \b geoclue2
- \li Interfaces with \l{https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home}{GeoClue} v2. Requires GeoClue v2 to be present to function.
+ \li A \l {Qt Positioning GeoClue v2 plugin}{GeoClue v2} backend that
+ provides an interface to the GeoClue v2 D-Bus service.
\row
\li \b gypsy
\li Interfaces with \l{https://gypsy.freedesktop.org/wiki/}{Gypsy} daemon. Requires Gypsy to be present to function.
@@ -54,7 +55,7 @@ Some plugins already ship with Qt. These are:
\li Wraps WinRT positioning subsystem. Available only on WinRT and Windows10.
\row
\li \b nmea
- \li A \l {Qt Positioning NMEA plugin}{NMEA} backend that parses NMEA
+ \li An \l {Qt Positioning NMEA plugin}{NMEA} backend that parses NMEA
streams from a GPS receiver to provide position updates. This plugin can
use serial port, socket or file as a source.
\row