diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2021-07-29 18:10:32 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-30 09:10:14 +0000 |
commit | ffcfc067242de73fa276b448055b2b890678d840 (patch) | |
tree | 07390faeab525b9f660ddd9d5dd5d990c49e8d9d /src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp | |
parent | 981a3b86b221d46f1657407193f011934dead94c (diff) | |
download | qtlocation-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>
Diffstat (limited to 'src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp')
-rw-r--r-- | src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp | 29 |
1 files changed, 19 insertions, 10 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 ¶meters, + 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 ¶meters) +{ + if (parameters.contains(desktopIdParameter)) + m_desktopId = parameters.value(desktopIdParameter).toString(); + + if (m_desktopId.isEmpty()) + m_desktopId = QCoreApplication::applicationName(); +} + QT_END_NAMESPACE |