summaryrefslogtreecommitdiffstats
path: root/src/plugins/position
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/position')
-rw-r--r--src/plugins/position/CMakeLists.txt21
-rw-r--r--src/plugins/position/android/CMakeLists.txt4
-rw-r--r--src/plugins/position/android/android.pro2
-rw-r--r--src/plugins/position/android/jar/AndroidManifest.xml6
-rw-r--r--src/plugins/position/android/jar/CMakeLists.txt17
-rw-r--r--src/plugins/position/android/jar/jar.pro16
-rw-r--r--src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java658
-rw-r--r--src/plugins/position/android/src/CMakeLists.txt23
-rw-r--r--src/plugins/position/android/src/jnipositioning.cpp741
-rw-r--r--src/plugins/position/android/src/jnipositioning.h64
-rw-r--r--src/plugins/position/android/src/plugin.json9
-rw-r--r--src/plugins/position/android/src/positionfactory_android.cpp63
-rw-r--r--src/plugins/position/android/src/positionfactory_android.h58
-rw-r--r--src/plugins/position/android/src/qgeopositioninfosource_android.cpp296
-rw-r--r--src/plugins/position/android/src/qgeopositioninfosource_android_p.h102
-rw-r--r--src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp223
-rw-r--r--src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h98
-rw-r--r--src/plugins/position/android/src/src.pro21
-rw-r--r--src/plugins/position/corelocation/CMakeLists.txt36
-rw-r--r--src/plugins/position/corelocation/corelocation.pro24
-rw-r--r--src/plugins/position/corelocation/plugin.json9
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosource_cl.mm336
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h106
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h58
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm61
-rw-r--r--src/plugins/position/geoclue2/CMakeLists.txt31
-rw-r--r--src/plugins/position/geoclue2/geoclue2.pro30
-rw-r--r--src/plugins/position/geoclue2/geocluetypes.cpp62
-rw-r--r--src/plugins/position/geoclue2/geocluetypes.h63
-rw-r--r--src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Client.xml122
-rw-r--r--src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Location.xml96
-rw-r--r--src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Manager.xml60
-rw-r--r--src/plugins/position/geoclue2/plugin.json9
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp458
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h100
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp69
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.h68
-rw-r--r--src/plugins/position/gypsy/CMakeLists.txt24
-rw-r--r--src/plugins/position/gypsy/gypsy.pro20
-rw-r--r--src/plugins/position/gypsy/plugin.json9
-rw-r--r--src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp66
-rw-r--r--src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h59
-rw-r--r--src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp442
-rw-r--r--src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h143
-rw-r--r--src/plugins/position/nmea/CMakeLists.txt22
-rw-r--r--src/plugins/position/nmea/nmea.pro16
-rw-r--r--src/plugins/position/nmea/plugin.json9
-rw-r--r--src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.cpp505
-rw-r--r--src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.h63
-rw-r--r--src/plugins/position/nmea/qiopipe.cpp207
-rw-r--r--src/plugins/position/nmea/qiopipe_p.h114
-rw-r--r--src/plugins/position/position.pro13
-rw-r--r--src/plugins/position/positionpoll/CMakeLists.txt20
-rw-r--r--src/plugins/position/positionpoll/plugin.json9
-rw-r--r--src/plugins/position/positionpoll/positionpoll.pro18
-rw-r--r--src/plugins/position/positionpoll/positionpollfactory.cpp65
-rw-r--r--src/plugins/position/positionpoll/positionpollfactory.h58
-rw-r--r--src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp508
-rw-r--r--src/plugins/position/positionpoll/qgeoareamonitor_polling.h100
-rw-r--r--src/plugins/position/winrt/CMakeLists.txt29
-rw-r--r--src/plugins/position/winrt/plugin.json9
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp675
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h124
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp70
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h59
-rw-r--r--src/plugins/position/winrt/winrt.pro16
66 files changed, 0 insertions, 7692 deletions
diff --git a/src/plugins/position/CMakeLists.txt b/src/plugins/position/CMakeLists.txt
deleted file mode 100644
index ceb4fe27..00000000
--- a/src/plugins/position/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Generated from position.pro.
-
-add_subdirectory(positionpoll)
-if(FREEBSD OR LINUX OR OPENBSD OR (NETBSD AND TARGET Qt::DBus))
- add_subdirectory(geoclue2)
-endif()
-if(QT_FEATURE_gypsy)
- add_subdirectory(gypsy)
-endif()
-if(QT_FEATURE_winrt_geolocation)
- add_subdirectory(winrt)
-endif()
-if(IOS OR MACOS OR TVOS)
- add_subdirectory(corelocation)
-endif()
-if(ANDROID)
- add_subdirectory(android)
-endif()
-if(TARGET Qt::SerialPort AND TARGET Qt::Network)
- add_subdirectory(nmea)
-endif()
diff --git a/src/plugins/position/android/CMakeLists.txt b/src/plugins/position/android/CMakeLists.txt
deleted file mode 100644
index 22fe2b6b..00000000
--- a/src/plugins/position/android/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from android.pro.
-
-add_subdirectory(jar)
-add_subdirectory(src)
diff --git a/src/plugins/position/android/android.pro b/src/plugins/position/android/android.pro
deleted file mode 100644
index 0dc6a3fc..00000000
--- a/src/plugins/position/android/android.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += jar src
diff --git a/src/plugins/position/android/jar/AndroidManifest.xml b/src/plugins/position/android/jar/AndroidManifest.xml
deleted file mode 100644
index 2e847fd1..00000000
--- a/src/plugins/position/android/jar/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.qtproject.qt.android.positioning"
- android:versionCode="1"
- android:versionName="1.0" >
- <supports-screens android:smallScreens="true" android:largeScreens="true" android:anyDensity="true" android:normalScreens="true"/>
-</manifest>
diff --git a/src/plugins/position/android/jar/CMakeLists.txt b/src/plugins/position/android/jar/CMakeLists.txt
deleted file mode 100644
index 8eadc79c..00000000
--- a/src/plugins/position/android/jar/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# Generated from jar.pro.
-
-set(java_sources
- src/org/qtproject/qt/android/positioning/QtPositioning.java # special case
-)
-
-qt_internal_add_jar(Qt${QtLocation_VERSION_MAJOR}AndroidPositioning # special case
- INCLUDE_JARS ${QT_ANDROID_JAR}
- SOURCES ${java_sources}
- OUTPUT_DIR "${QT_BUILD_DIR}/jar"
-)
-
-install_jar(Qt${QtLocation_VERSION_MAJOR}AndroidPositioning # special case
- DESTINATION jar
- COMPONENT Devel
-)
-
diff --git a/src/plugins/position/android/jar/jar.pro b/src/plugins/position/android/jar/jar.pro
deleted file mode 100644
index fae1f855..00000000
--- a/src/plugins/position/android/jar/jar.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = Qt$${QT_MAJOR_VERSION}AndroidPositioning
-
-load(qt_build_paths)
-
-CONFIG += java
-DESTDIR = $$MODULE_BASE_OUTDIR/jar
-
-JAVACLASSPATH += $$PWD/src
-
-JAVASOURCES += \
- $$PWD/src/org/qtproject/qt/android/positioning/QtPositioning.java
-
-# install
-target.path = $$[QT_INSTALL_PREFIX]/jar
-INSTALLS += target
-
diff --git a/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java b/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java
deleted file mode 100644
index 18ef40a2..00000000
--- a/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java
+++ /dev/null
@@ -1,658 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-package org.qtproject.qt.android.positioning;
-
-import android.content.Context;
-import android.location.GpsSatellite;
-import android.location.GpsStatus;
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
-import android.location.GnssStatus;
-import android.location.GnssStatus.Callback;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Build;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import android.util.Log;
-
-public class QtPositioning implements LocationListener
-{
-
- private static final String TAG = "qt.positioning.android";
- static LocationManager locationManager = null;
- static Object m_syncObject = new Object();
- static HashMap<Integer, QtPositioning> runningListeners = new HashMap<Integer, QtPositioning>();
-
- /*
- The positionInfo instance to which this
- QtPositioning instance is attached to.
- */
- private int nativeClassReference = 0;
-
- /*
- The provider type requested by Qt
- */
- private int expectedProviders = 0;
-
- public static final int QT_GPS_PROVIDER = 1;
- public static final int QT_NETWORK_PROVIDER = 2;
-
- /* The following values must match the corresponding error enums in the Qt API*/
- public static final int QT_ACCESS_ERROR = 0;
- public static final int QT_CLOSED_ERROR = 1;
- public static final int QT_POSITION_UNKNOWN_SOURCE_ERROR = 2;
- public static final int QT_POSITION_NO_ERROR = 3;
- public static final int QT_SATELLITE_NO_ERROR = 2;
- public static final int QT_SATELLITE_UNKNOWN_SOURCE_ERROR = -1;
-
- /* True, if updates were caused by requestUpdate() */
- private boolean isSingleUpdate = false;
- /* The length requested for regular intervals in msec. */
- private int updateIntervalTime = 0;
-
- /* The last received GPS update */
- private Location lastGps = null;
- /* The last received network update */
- private Location lastNetwork = null;
- /* If true this class acts as satellite signal monitor rather than location monitor */
- private boolean isSatelliteUpdate = false;
-
- private PositioningLooperBase looperThread;
-
- private boolean isLocationProvidersDisabledInvoked = false;
-
- static public void setContext(Context context)
- {
- try {
- locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- static private int[] providerList()
- {
- if (locationManager == null) {
- Log.w(TAG, "No locationManager available in QtPositioning");
- return new int[0];
- }
- List<String> providers = locationManager.getProviders(true);
- int retList[] = new int[providers.size()];
- for (int i = 0; i < providers.size(); i++) {
- if (providers.get(i).equals(LocationManager.GPS_PROVIDER)) {
- //must be in sync with AndroidPositioning::PositionProvider::PROVIDER_GPS
- retList[i] = 0;
- } else if (providers.get(i).equals(LocationManager.NETWORK_PROVIDER)) {
- //must be in sync with AndroidPositioning::PositionProvider::PROVIDER_NETWORK
- retList[i] = 1;
- } else if (providers.get(i).equals(LocationManager.PASSIVE_PROVIDER)) {
- //must be in sync with AndroidPositioning::PositionProvider::PROVIDER_PASSIVE
- retList[i] = 2;
- } else {
- retList[i] = -1;
- }
- }
- return retList;
- }
-
- static public Location lastKnownPosition(boolean fromSatelliteOnly)
- {
- Location gps = null;
- Location network = null;
- try {
- gps = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
- if (!fromSatelliteOnly)
- network = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
- } catch(Exception e) {
- e.printStackTrace();
- gps = network = null;
- }
-
- if (gps != null && network != null) {
- //we return the most recent location but slightly prefer GPS
- //prefer GPS if it is max 4 hrs older than network
- long delta = network.getTime() - gps.getTime();
- if (delta < 4*60*60*1000) {
- return gps;
- } else {
- return network;
- }
- } else if (gps != null ) {
- return gps;
- } else if (network != null) {
- return network;
- }
-
- return null;
- }
-
- /* Returns true if at least on of the given providers is enabled. */
- static private boolean expectedProvidersAvailable(int desiredProviders)
- {
- List<String> enabledProviders = locationManager.getProviders(true);
- if ((desiredProviders & QT_GPS_PROVIDER) > 0) { //gps desired
- if (enabledProviders.contains(LocationManager.GPS_PROVIDER)) {
- return true;
- }
- }
- if ((desiredProviders & QT_NETWORK_PROVIDER) > 0) { //network desired
- if (enabledProviders.contains(LocationManager.NETWORK_PROVIDER)) {
- return true;
- }
- }
-
- return false;
- }
-
-
- static private void addActiveListener(QtPositioning listener, String provider)
- {
- int androidClassKey = listener.nativeClassReference;
- //start update thread
- listener.setActiveLooper(true);
-
- if (runningListeners.containsKey(androidClassKey) && runningListeners.get(androidClassKey) != listener) {
- removeActiveListener(androidClassKey);
- }
-
- locationManager.requestSingleUpdate(provider,
- listener,
- listener.looper());
-
- runningListeners.put(androidClassKey, listener);
- }
-
-
- static private void addActiveListener(QtPositioning listener, String provider, long minTime, float minDistance)
- {
- int androidClassKey = listener.nativeClassReference;
- //start update thread
- listener.setActiveLooper(true);
-
- if (runningListeners.containsKey(androidClassKey) && runningListeners.get(androidClassKey) != listener) {
- removeActiveListener(androidClassKey);
- }
-
- locationManager.requestLocationUpdates(provider,
- minTime, minDistance,
- listener,
- listener.looper());
-
- runningListeners.put(androidClassKey, listener);
- }
-
-
- static private void removeActiveListener(QtPositioning listener)
- {
- removeActiveListener(listener.nativeClassReference);
- }
-
-
- static private void removeActiveListener(int androidClassKey)
- {
- QtPositioning listener = runningListeners.remove(androidClassKey);
-
- if (listener != null) {
- locationManager.removeUpdates(listener);
- listener.setActiveLooper(false);
- }
- }
-
-
- static public int startUpdates(int androidClassKey, int locationProvider, int updateInterval)
- {
- synchronized (m_syncObject) {
- try {
- boolean exceptionOccurred = false;
- QtPositioning positioningListener = new QtPositioning();
- positioningListener.nativeClassReference = androidClassKey;
- positioningListener.expectedProviders = locationProvider;
- positioningListener.isSatelliteUpdate = false;
-
- if (updateInterval == 0)
- updateInterval = 50; //don't update more often than once per 50ms
-
- positioningListener.updateIntervalTime = updateInterval;
- if ((locationProvider & QT_GPS_PROVIDER) > 0) {
- Log.d(TAG, "Regular updates using GPS " + updateInterval);
- try {
- addActiveListener(positioningListener,
- LocationManager.GPS_PROVIDER,
- updateInterval, 0);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
- }
-
- if ((locationProvider & QT_NETWORK_PROVIDER) > 0) {
- Log.d(TAG, "Regular updates using network " + updateInterval);
- try {
- addActiveListener(positioningListener,
- LocationManager.NETWORK_PROVIDER,
- updateInterval, 0);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
- }
- if (exceptionOccurred) {
- removeActiveListener(positioningListener);
- return QT_ACCESS_ERROR;
- }
-
- if (!expectedProvidersAvailable(locationProvider)) {
- //all location providers unavailbe -> when they come back we resume automatically
- return QT_CLOSED_ERROR;
- }
-
- } catch(Exception e) {
- e.printStackTrace();
- return QT_POSITION_UNKNOWN_SOURCE_ERROR;
- }
-
- return QT_POSITION_NO_ERROR;
- }
- }
-
- static public void stopUpdates(int androidClassKey)
- {
- synchronized (m_syncObject) {
- try {
- Log.d(TAG, "Stopping updates");
- removeActiveListener(androidClassKey);
- } catch(Exception e) {
- e.printStackTrace();
- return;
- }
- }
- }
-
- static public int requestUpdate(int androidClassKey, int locationProvider)
- {
- synchronized (m_syncObject) {
- try {
- boolean exceptionOccurred = false;
- QtPositioning positioningListener = new QtPositioning();
- positioningListener.nativeClassReference = androidClassKey;
- positioningListener.isSingleUpdate = true;
- positioningListener.expectedProviders = locationProvider;
- positioningListener.isSatelliteUpdate = false;
-
- if ((locationProvider & QT_GPS_PROVIDER) > 0) {
- Log.d(TAG, "Single update using GPS");
- try {
- addActiveListener(positioningListener, LocationManager.GPS_PROVIDER);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
- }
-
- if ((locationProvider & QT_NETWORK_PROVIDER) > 0) {
- Log.d(TAG, "Single update using network");
- try {
- addActiveListener(positioningListener, LocationManager.NETWORK_PROVIDER);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
- }
- if (exceptionOccurred) {
- removeActiveListener(positioningListener);
- return QT_ACCESS_ERROR;
- }
-
- if (!expectedProvidersAvailable(locationProvider)) {
- //all location providers unavailable -> when they come back we resume automatically
- //in the mean time return ClosedError
- return QT_CLOSED_ERROR;
- }
-
- } catch(Exception e) {
- e.printStackTrace();
- return QT_POSITION_UNKNOWN_SOURCE_ERROR;
- }
-
- return QT_POSITION_NO_ERROR;
- }
- }
-
- static public int startSatelliteUpdates(int androidClassKey, int updateInterval, boolean isSingleRequest)
- {
- synchronized (m_syncObject) {
- try {
- boolean exceptionOccurred = false;
- QtPositioning positioningListener = new QtPositioning();
- positioningListener.isSatelliteUpdate = true;
- positioningListener.nativeClassReference = androidClassKey;
- positioningListener.expectedProviders = 1; //always satellite provider
- positioningListener.isSingleUpdate = isSingleRequest;
-
- if (updateInterval == 0)
- updateInterval = 50; //don't update more often than once per 50ms
-
- if (isSingleRequest)
- Log.d(TAG, "Single update for Satellites " + updateInterval);
- else
- Log.d(TAG, "Regular updates for Satellites " + updateInterval);
- try {
- addActiveListener(positioningListener, LocationManager.GPS_PROVIDER,
- updateInterval, 0);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
-
- if (exceptionOccurred) {
- removeActiveListener(positioningListener);
- return QT_ACCESS_ERROR;
- }
-
- if (!expectedProvidersAvailable(positioningListener.expectedProviders)) {
- //all location providers unavailable -> when they come back we resume automatically
- //in the mean time return ClosedError
- return QT_CLOSED_ERROR;
- }
-
- } catch(Exception e) {
- e.printStackTrace();
- return QT_SATELLITE_UNKNOWN_SOURCE_ERROR;
- }
-
- return QT_SATELLITE_NO_ERROR;
- }
- }
-
- public QtPositioning()
- {
- // Use GpsStatus for API Level <= 23 (version M and below) and
- // GnssStatus for other API levels.
- if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M)
- looperThread = new PositioningLooperGps();
- else
- looperThread = new PositioningLooperGnss();
- }
-
- public Looper looper()
- {
- return looperThread.looper();
- }
-
- private void setActiveLooper(boolean setActive)
- {
- try{
- if (setActive) {
- if (looperThread.isAlive())
- return;
-
- if (isSatelliteUpdate)
- looperThread.isSatelliteListener(true);
-
- long start = System.currentTimeMillis();
- looperThread.start();
-
- //busy wait but lasts ~20-30 ms only
- while (!looperThread.isReady());
-
- long stop = System.currentTimeMillis();
- Log.d(TAG, "Looper Thread startup time in ms: " + (stop-start));
- } else {
- looperThread.quitLooper();
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- private abstract class PositioningLooperBase extends Thread
- {
- private boolean looperRunning;
- private Looper posLooper;
- private boolean isSatelliteLooper = false;
-
- abstract protected void addSatelliteInfoListener();
- abstract protected void removeSatelliteInfoListener();
-
- private PositioningLooperBase()
- {
- looperRunning = false;
- }
-
- public void run()
- {
- Looper.prepare();
- Handler handler = new Handler();
-
- if (isSatelliteLooper)
- addSatelliteInfoListener();
-
- posLooper = Looper.myLooper();
- synchronized (this) {
- looperRunning = true;
- }
- Looper.loop();
- synchronized (this) {
- looperRunning = false;
- }
- }
-
- public void quitLooper()
- {
- if (isSatelliteLooper)
- removeSatelliteInfoListener();
- looper().quit();
- }
-
- public synchronized boolean isReady()
- {
- return looperRunning;
- }
-
- public void isSatelliteListener(boolean isListener)
- {
- isSatelliteLooper = isListener;
- }
-
- public Looper looper()
- {
- return posLooper;
- }
-
- }
-
- private class PositioningLooperGps extends PositioningLooperBase implements GpsStatus.Listener
- {
- @Override
- protected void addSatelliteInfoListener()
- {
- try {
- locationManager.addGpsStatusListener(this);
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- @Override
- protected void removeSatelliteInfoListener()
- {
- locationManager.removeGpsStatusListener(this);
- }
-
- @Override
- public void onGpsStatusChanged(int event) {
- switch (event) {
- case GpsStatus.GPS_EVENT_FIRST_FIX:
- break;
- case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
- GpsStatus status = locationManager.getGpsStatus(null);
- Iterable<GpsSatellite> iterable = status.getSatellites();
- Iterator<GpsSatellite> it = iterable.iterator();
-
- ArrayList<GpsSatellite> list = new ArrayList<GpsSatellite>();
- while (it.hasNext()) {
- GpsSatellite sat = (GpsSatellite) it.next();
- list.add(sat);
- }
- GpsSatellite[] sats = list.toArray(new GpsSatellite[list.size()]);
- satelliteGpsUpdated(sats, nativeClassReference, isSingleUpdate);
-
- break;
- case GpsStatus.GPS_EVENT_STARTED:
- break;
- case GpsStatus.GPS_EVENT_STOPPED:
- break;
- }
- }
- }
-
- private class PositioningGnssListener extends GnssStatus.Callback
- {
- @Override
- public void onSatelliteStatusChanged(GnssStatus status)
- {
- satelliteGnssUpdated(status, nativeClassReference, isSingleUpdate);
- }
- }
-
- private class PositioningLooperGnss extends PositioningLooperBase
- {
- private PositioningGnssListener gnssListener;
-
- private PositioningLooperGnss()
- {
- gnssListener = new PositioningGnssListener();
- }
-
- @Override
- protected void addSatelliteInfoListener()
- {
- try {
- locationManager.registerGnssStatusCallback(gnssListener);
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- @Override
- protected void removeSatelliteInfoListener()
- {
- locationManager.unregisterGnssStatusCallback(gnssListener);
- }
- }
-
- public static native void positionUpdated(Location update, int androidClassKey, boolean isSingleUpdate);
- public static native void locationProvidersDisabled(int androidClassKey);
- public static native void locationProvidersChanged(int androidClassKey);
- public static native void satelliteGpsUpdated(GpsSatellite[] update, int androidClassKey, boolean isSingleUpdate);
- public static native void satelliteGnssUpdated(GnssStatus update, int androidClassKey, boolean isSingleUpdate);
-
- @Override
- public void onLocationChanged(Location location) {
- //Log.d(TAG, "**** Position Update ****: " + location.toString() + " " + isSingleUpdate);
- if (location == null)
- return;
-
- if (isSatelliteUpdate) //we are a QGeoSatelliteInfoSource -> ignore
- return;
-
- if (isSingleUpdate || expectedProviders < 3) {
- positionUpdated(location, nativeClassReference, isSingleUpdate);
- return;
- }
-
- /*
- We can use GPS and Network, pick the better location provider.
- Generally we prefer GPS data due to their higher accurancy but we
- let Network data pass until GPS fix is available
- */
-
- if (location.getProvider().equals(LocationManager.GPS_PROVIDER)) {
- lastGps = location;
-
- // assumption: GPS always better -> pass it on
- positionUpdated(location, nativeClassReference, isSingleUpdate);
- } else if (location.getProvider().equals(LocationManager.NETWORK_PROVIDER)) {
- lastNetwork = location;
-
- if (lastGps == null) { //no GPS fix yet use network location
- positionUpdated(location, nativeClassReference, isSingleUpdate);
- return;
- }
-
- long delta = location.getTime() - lastGps.getTime();
-
- // Ignore if network update is older than last GPS (delta < 0)
- // Ignore if gps update still has time to provide next location (delta < updateInterval)
- if (delta < updateIntervalTime)
- return;
-
- // Use network data -> GPS has timed out on updateInterval
- positionUpdated(location, nativeClassReference, isSingleUpdate);
- }
- }
-
- @Override
- public void onStatusChanged(String provider, int status, Bundle extras) {}
-
- @Override
- public void onProviderEnabled(String provider) {
- Log.d(TAG, "Enabled provider: " + provider);
- locationProvidersChanged(nativeClassReference);
- if (isLocationProvidersDisabledInvoked && expectedProvidersAvailable(expectedProviders))
- isLocationProvidersDisabledInvoked = false;
- }
-
- @Override
- public void onProviderDisabled(String provider) {
- Log.d(TAG, "Disabled provider: " + provider);
- locationProvidersChanged(nativeClassReference);
- if (!isLocationProvidersDisabledInvoked && !expectedProvidersAvailable(expectedProviders)) {
- isLocationProvidersDisabledInvoked = true;
- locationProvidersDisabled(nativeClassReference);
- }
- }
-}
diff --git a/src/plugins/position/android/src/CMakeLists.txt b/src/plugins/position/android/src/CMakeLists.txt
deleted file mode 100644
index b91181f4..00000000
--- a/src/plugins/position/android/src/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-# Generated from src.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryAndroid Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryAndroidPlugin
- OUTPUT_NAME qtposition_android
- CLASS_NAME QGeoPositionInfoSourceFactoryAndroid
- PLUGIN_TYPE position
- SOURCES
- jnipositioning.cpp jnipositioning.h
- positionfactory_android.cpp positionfactory_android.h
- qgeopositioninfosource_android.cpp qgeopositioninfosource_android_p.h
- qgeosatelliteinfosource_android.cpp qgeosatelliteinfosource_android_p.h
- LIBRARIES
- Qt::Core
- Qt::CorePrivate
- Qt::Positioning
-)
-
-#### Keys ignored in scope 1:.:.:src.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp
deleted file mode 100644
index 5f87d08b..00000000
--- a/src/plugins/position/android/src/jnipositioning.cpp
+++ /dev/null
@@ -1,741 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDateTime>
-#include <QMap>
-#include <QRandomGenerator>
-#include <QGeoPositionInfo>
-#include <QJniEnvironment>
-#include <QJniObject>
-#include <QtCore/private/qandroidextras_p.h>
-#include <QCoreApplication>
-#include <android/log.h>
-#include "qgeopositioninfosource_android_p.h"
-#include "qgeosatelliteinfosource_android_p.h"
-#include "jnipositioning.h"
-
-class GlobalClassRefWrapper
-{
-public:
- GlobalClassRefWrapper() = default;
- ~GlobalClassRefWrapper()
- {
- if (m_classRef) {
- QJniEnvironment env;
- if (env.jniEnv())
- env->DeleteGlobalRef(m_classRef);
- }
- }
-
- bool init(const char *className)
- {
- QJniEnvironment env;
- if (env.jniEnv()) {
- if (m_classRef) {
- env->DeleteGlobalRef(m_classRef);
- m_classRef = nullptr;
- }
-
- m_classRef = env.findClass(className); // it returns global ref!
- }
- return m_classRef != nullptr;
- }
-
- jclass operator()() { return m_classRef; }
-
-private:
- jclass m_classRef = nullptr;
-};
-
-static GlobalClassRefWrapper positioningClass;
-
-static jmethodID providerListMethodId;
-static jmethodID lastKnownPositionMethodId;
-static jmethodID startUpdatesMethodId;
-static jmethodID stopUpdatesMethodId;
-static jmethodID requestUpdateMethodId;
-static jmethodID startSatelliteUpdatesMethodId;
-
-static const char logTag[] = "qt.positioning.android";
-static const char methodErrorMsg[] = "Can't find method \"%s%s\"";
-
-Q_LOGGING_CATEGORY(lcPositioning, logTag)
-
-namespace {
-
-/*!
- \internal
- This class encapsulates satellite system types, as defined by Android
- GnssStatus API. Initialize during JNI_OnLoad() by the init() method, from
- the Java side, rather than hard-coding.
-*/
-class ConstellationMapper
-{
-public:
- static bool init()
- {
- m_gnssStatusObject = nullptr;
- if (QNativeInterface::QAndroidApplication::sdkVersion() > 23) {
- m_gnssStatusObject = QJniEnvironment().findClass("android/location/GnssStatus");
- if (!m_gnssStatusObject)
- return false;
- }
- // no need to query it for API level <= 23
- return true;
- }
-
- static QGeoSatelliteInfo::SatelliteSystem toSatelliteSystem(int constellationType)
- {
- if (!m_gnssStatusObject)
- return QGeoSatelliteInfo::Undefined;
-
- static const int gps =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_GPS");
- static const int glonass =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_GLONASS");
- static const int galileo =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_GALILEO");
- static const int beidou =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_BEIDOU");
- static const int qzss =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_QZSS");
-
- if (constellationType == gps) {
- return QGeoSatelliteInfo::GPS;
- } else if (constellationType == glonass) {
- return QGeoSatelliteInfo::GLONASS;
- } else if (constellationType == galileo) {
- return QGeoSatelliteInfo::GALILEO;
- } else if (constellationType == beidou) {
- return QGeoSatelliteInfo::BEIDOU;
- } else if (constellationType == qzss){
- return QGeoSatelliteInfo::QZSS;
- } else {
- qCWarning(lcPositioning) << "Unknown satellite system" << constellationType;
- return QGeoSatelliteInfo::Undefined;
- }
- }
-
-private:
- static jclass m_gnssStatusObject;
-};
-
-jclass ConstellationMapper::m_gnssStatusObject = nullptr;
-
-} // anonymous namespace
-
-namespace AndroidPositioning {
- typedef QMap<int, QGeoPositionInfoSourceAndroid * > PositionSourceMap;
- typedef QMap<int, QGeoSatelliteInfoSourceAndroid * > SatelliteSourceMap;
-
- Q_GLOBAL_STATIC(PositionSourceMap, idToPosSource)
-
- Q_GLOBAL_STATIC(SatelliteSourceMap, idToSatSource)
-
- int registerPositionInfoSource(QObject *obj)
- {
- int key = -1;
- if (obj->inherits("QGeoPositionInfoSource")) {
- QGeoPositionInfoSourceAndroid *src = qobject_cast<QGeoPositionInfoSourceAndroid *>(obj);
- Q_ASSERT(src);
- do {
- key = qAbs(int(QRandomGenerator::global()->generate()));
- } while (idToPosSource()->contains(key));
-
- idToPosSource()->insert(key, src);
- } else if (obj->inherits("QGeoSatelliteInfoSource")) {
- QGeoSatelliteInfoSourceAndroid *src = qobject_cast<QGeoSatelliteInfoSourceAndroid *>(obj);
- Q_ASSERT(src);
- do {
- key = qAbs(int(QRandomGenerator::global()->generate()));
- } while (idToSatSource()->contains(key));
-
- idToSatSource()->insert(key, src);
- }
-
- return key;
- }
-
- void unregisterPositionInfoSource(int key)
- {
- idToPosSource()->remove(key);
- idToSatSource()->remove(key);
- }
-
- enum PositionProvider
- {
- PROVIDER_GPS = 0,
- PROVIDER_NETWORK = 1,
- PROVIDER_PASSIVE = 2
- };
-
-
- QGeoPositionInfoSource::PositioningMethods availableProviders()
- {
- QGeoPositionInfoSource::PositioningMethods ret = QGeoPositionInfoSource::NoPositioningMethods;
- QJniEnvironment env;
- if (!env.jniEnv())
- return ret;
- QJniObject jniProvidersObj =
- QJniObject::callStaticObjectMethod(positioningClass(), providerListMethodId);
- jintArray jProviders = jniProvidersObj.object<jintArray>();
- jint *providers = env->GetIntArrayElements(jProviders, nullptr);
- const int size = env->GetArrayLength(jProviders);
- for (int i = 0; i < size; i++) {
- switch (providers[i]) {
- case PROVIDER_GPS:
- ret |= QGeoPositionInfoSource::SatellitePositioningMethods;
- break;
- case PROVIDER_NETWORK:
- ret |= QGeoPositionInfoSource::NonSatellitePositioningMethods;
- break;
- case PROVIDER_PASSIVE:
- //we ignore as Qt doesn't have interface for it right now
- break;
- default:
- __android_log_print(ANDROID_LOG_INFO, logTag, "Unknown positioningMethod");
- }
- }
-
- env->ReleaseIntArrayElements(jProviders, providers, 0);
-
- return ret;
- }
-
- QGeoPositionInfo positionInfoFromJavaLocation(const jobject &location)
- {
- QGeoPositionInfo info;
-
- QJniObject jniObject(location);
- if (!jniObject.isValid())
- return QGeoPositionInfo();
-
- const jdouble latitude = jniObject.callMethod<jdouble>("getLatitude");
- const jdouble longitude = jniObject.callMethod<jdouble>("getLongitude");
-
- QGeoCoordinate coordinate(latitude, longitude);
-
- // altitude
- jboolean attributeExists = jniObject.callMethod<jboolean>("hasAltitude");
- if (attributeExists) {
- const jdouble value = jniObject.callMethod<jdouble>("getAltitude");
- if (!qFuzzyIsNull(value))
- coordinate.setAltitude(value);
- }
-
- info.setCoordinate(coordinate);
-
- // time stamp
- const jlong timestamp = jniObject.callMethod<jlong>("getTime");
- info.setTimestamp(QDateTime::fromMSecsSinceEpoch(timestamp, Qt::UTC));
-
- // horizontal accuracy
- attributeExists = jniObject.callMethod<jboolean>("hasAccuracy");
- if (attributeExists) {
- const jfloat accuracy = jniObject.callMethod<jfloat>("getAccuracy");
- if (!qFuzzyIsNull(accuracy))
- info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, qreal(accuracy));
- }
-
- // vertical accuracy
- // The check for method existence happens inside QJniObject. If the
- // method is not found, 0 (or 0.0, or false) is returned, so we do not
- // need to handle it specially.
- attributeExists = jniObject.callMethod<jboolean>("hasVerticalAccuracy");
- if (attributeExists) {
- const jfloat accuracy = jniObject.callMethod<jfloat>("getVerticalAccuracyMeters");
- if (!qFuzzyIsNull(accuracy))
- info.setAttribute(QGeoPositionInfo::VerticalAccuracy, qreal(accuracy));
- }
-
- // ground speed
- attributeExists = jniObject.callMethod<jboolean>("hasSpeed");
- if (attributeExists) {
- const jfloat speed = jniObject.callMethod<jfloat>("getSpeed");
- if (!qFuzzyIsNull(speed))
- info.setAttribute(QGeoPositionInfo::GroundSpeed, qreal(speed));
- }
-
- // bearing
- attributeExists = jniObject.callMethod<jboolean>("hasBearing");
- if (attributeExists) {
- const jfloat bearing = jniObject.callMethod<jfloat>("getBearing");
- if (!qFuzzyIsNull(bearing))
- info.setAttribute(QGeoPositionInfo::Direction, qreal(bearing));
- }
-
- return info;
- }
-
- QList<QGeoSatelliteInfo> satelliteInfoFromJavaLocation(JNIEnv *jniEnv,
- jobjectArray satellites,
- QList<QGeoSatelliteInfo>* usedInFix)
- {
- QList<QGeoSatelliteInfo> sats;
- jsize length = jniEnv->GetArrayLength(satellites);
- for (int i = 0; i<length; i++) {
- jobject element = jniEnv->GetObjectArrayElement(satellites, i);
- if (QJniEnvironment::checkAndClearExceptions(jniEnv)) {
- qCWarning(lcPositioning) << "Cannot process all satellite data due to exception.";
- break;
- }
-
- QJniObject jniObj = QJniObject::fromLocalRef(element);
- if (!jniObj.isValid())
- continue;
-
- QGeoSatelliteInfo info;
-
- // signal strength
- const jfloat snr = jniObj.callMethod<jfloat>("getSnr");
- info.setSignalStrength(int(snr));
-
- // ignore any satellite with no signal whatsoever
- if (qFuzzyIsNull(snr))
- continue;
-
- // prn
- const jint prn = jniObj.callMethod<jint>("getPrn");
- info.setSatelliteIdentifier(prn);
-
- if (prn >= 1 && prn <= 32)
- info.setSatelliteSystem(QGeoSatelliteInfo::GPS);
- else if (prn >= 65 && prn <= 96)
- info.setSatelliteSystem(QGeoSatelliteInfo::GLONASS);
- else if (prn >= 193 && prn <= 200)
- info.setSatelliteSystem(QGeoSatelliteInfo::QZSS);
- else if ((prn >= 201 && prn <= 235) || (prn >= 401 && prn <= 437))
- info.setSatelliteSystem(QGeoSatelliteInfo::BEIDOU);
- else if (prn >= 301 && prn <= 336)
- info.setSatelliteSystem(QGeoSatelliteInfo::GALILEO);
-
- // azimuth
- const jfloat azimuth = jniObj.callMethod<jfloat>("getAzimuth");
- info.setAttribute(QGeoSatelliteInfo::Azimuth, qreal(azimuth));
-
- // elevation
- const jfloat elevation = jniObj.callMethod<jfloat>("getElevation");
- info.setAttribute(QGeoSatelliteInfo::Elevation, qreal(elevation));
-
- // Used in fix - true if this satellite is actually used in
- // determining the position.
- const jboolean inFix = jniObj.callMethod<jboolean>("usedInFix");
-
- sats.append(info);
-
- if (inFix)
- usedInFix->append(info);
- }
-
- return sats;
- }
-
- QList<QGeoSatelliteInfo> satelliteInfoFromJavaGnssStatus(jobject gnssStatus,
- QList<QGeoSatelliteInfo>* usedInFix)
- {
- QJniObject jniStatus(gnssStatus);
- QList<QGeoSatelliteInfo> sats;
-
- const int satellitesCount = jniStatus.callMethod<jint>("getSatelliteCount");
- for (int i = 0; i < satellitesCount; ++i) {
- QGeoSatelliteInfo info;
-
- // signal strength - this is actually a carrier-to-noise density,
- // but the values are very close to what was previously returned by
- // getSnr() method of the GpsSatellite API.
- const jfloat cn0 = jniStatus.callMethod<jfloat>("getCn0DbHz", "(I)F", i);
- info.setSignalStrength(static_cast<int>(cn0));
-
- // satellite system
- const jint constellationType =
- jniStatus.callMethod<jint>("getConstellationType", "(I)I", i);
- info.setSatelliteSystem(ConstellationMapper::toSatelliteSystem(constellationType));
-
- // satellite identifier
- const jint svId = jniStatus.callMethod<jint>("getSvid", "(I)I", i);
- info.setSatelliteIdentifier(svId);
-
- // azimuth
- const jfloat azimuth = jniStatus.callMethod<jfloat>("getAzimuthDegrees", "(I)F", i);
- info.setAttribute(QGeoSatelliteInfo::Azimuth, static_cast<qreal>(azimuth));
-
- // elevation
- const jfloat elevation = jniStatus.callMethod<jfloat>("getElevationDegrees", "(I)F", i);
- info.setAttribute(QGeoSatelliteInfo::Elevation, static_cast<qreal>(elevation));
-
- // Used in fix - true if this satellite is actually used in
- // determining the position.
- const jboolean inFix = jniStatus.callMethod<jboolean>("usedInFix", "(I)Z", i);
-
- sats.append(info);
-
- if (inFix)
- usedInFix->append(info);
- }
-
- return sats;
- }
-
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly)
- {
- QJniEnvironment env;
- if (!env.jniEnv())
- return QGeoPositionInfo();
-
- if (!requestionPositioningPermissions())
- return {};
-
- QJniObject locationObj = QJniObject::callStaticObjectMethod(
- positioningClass(), lastKnownPositionMethodId, fromSatellitePositioningMethodsOnly);
- jobject location = locationObj.object();
- if (location == nullptr)
- return QGeoPositionInfo();
-
- const QGeoPositionInfo info = positionInfoFromJavaLocation(location);
-
- return info;
- }
-
- inline int positioningMethodToInt(QGeoPositionInfoSource::PositioningMethods m)
- {
- int providerSelection = 0;
- if (m & QGeoPositionInfoSource::SatellitePositioningMethods)
- providerSelection |= 1;
- if (m & QGeoPositionInfoSource::NonSatellitePositioningMethods)
- providerSelection |= 2;
-
- return providerSelection;
- }
-
- QGeoPositionInfoSource::Error startUpdates(int androidClassKey)
- {
- QJniEnvironment env;
- if (!env.jniEnv())
- return QGeoPositionInfoSource::UnknownSourceError;
-
- QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
-
- if (source) {
- if (!requestionPositioningPermissions())
- return QGeoPositionInfoSource::AccessError;
-
- int errorCode = QJniObject::callStaticMethod<jint>(
- positioningClass(), startUpdatesMethodId, androidClassKey,
- positioningMethodToInt(source->preferredPositioningMethods()),
- source->updateInterval());
- switch (errorCode) {
- case 0:
- case 1:
- case 2:
- case 3:
- return static_cast<QGeoPositionInfoSource::Error>(errorCode);
- default:
- break;
- }
- }
-
- return QGeoPositionInfoSource::UnknownSourceError;
- }
-
- //used for stopping regular and single updates
- void stopUpdates(int androidClassKey)
- {
- QJniObject::callStaticMethod<void>(positioningClass(), stopUpdatesMethodId,
- androidClassKey);
- }
-
- QGeoPositionInfoSource::Error requestUpdate(int androidClassKey)
- {
- QJniEnvironment env;
- if (!env.jniEnv())
- return QGeoPositionInfoSource::UnknownSourceError;
-
- QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
-
- if (source) {
- if (!requestionPositioningPermissions())
- return QGeoPositionInfoSource::AccessError;
-
- int errorCode = QJniObject::callStaticMethod<jint>(
- positioningClass(), requestUpdateMethodId, androidClassKey,
- positioningMethodToInt(source->preferredPositioningMethods()));
- switch (errorCode) {
- case 0:
- case 1:
- case 2:
- case 3:
- return static_cast<QGeoPositionInfoSource::Error>(errorCode);
- default:
- break;
- }
- }
- return QGeoPositionInfoSource::UnknownSourceError;
- }
-
- QGeoSatelliteInfoSource::Error startSatelliteUpdates(int androidClassKey, bool isSingleRequest, int requestTimeout)
- {
- QJniEnvironment env;
- if (!env.jniEnv())
- return QGeoSatelliteInfoSource::UnknownSourceError;
-
- QGeoSatelliteInfoSourceAndroid *source = AndroidPositioning::idToSatSource()->value(androidClassKey);
-
- if (source) {
- if (!requestionPositioningPermissions())
- return QGeoSatelliteInfoSource::AccessError;
-
- int interval = source->updateInterval();
- if (isSingleRequest)
- interval = requestTimeout;
- int errorCode = QJniObject::callStaticMethod<jint>(positioningClass(),
- startSatelliteUpdatesMethodId,
- androidClassKey, interval,
- isSingleRequest);
- switch (errorCode) {
- case -1:
- case 0:
- case 1:
- case 2:
- return static_cast<QGeoSatelliteInfoSource::Error>(errorCode);
- default:
- qCWarning(lcPositioning)
- << "startSatelliteUpdates: Unknown error code" << errorCode;
- break;
- }
- }
- return QGeoSatelliteInfoSource::UnknownSourceError;
- }
-
- bool requestionPositioningPermissions()
- {
- // If the code is running as a service, we can't request permissions.
- // We can only check if we have the needed permissions. Also make sure
- // to request the background location permissions.
- if (!QNativeInterface::QAndroidApplication::isActivityContext()) {
- const auto permission = QtAndroidPrivate::PreciseBackgroundLocation;
- const auto result = QtAndroidPrivate::checkPermission(permission).result();
- if (result != QtAndroidPrivate::Authorized) {
- qCWarning(lcPositioning)
- << "Position data not available due to missing permission" << permission;
- }
- return result == QtAndroidPrivate::Authorized;
- } else {
- // Running from a normal Activity. Checking and requesting the
- // permissions if necessary.
-
- // Android v23+ requires runtime permission check and requests
- const auto permission = QtAndroidPrivate::PreciseLocation;
- auto checkFuture = QtAndroidPrivate::checkPermission(permission);
- if (checkFuture.result() == QtAndroidPrivate::Denied) {
- auto requestFuture = QtAndroidPrivate::requestPermission(permission);
- if (requestFuture.result() != QtAndroidPrivate::Authorized) {
- qCWarning(lcPositioning)
- << "Position data not available due to missing permission"
- << permission;
- return false;
- }
- }
-
- return true;
- }
- }
-}
-
-static void positionUpdated(JNIEnv *env, jobject thiz, jobject location,
- jint androidClassKey, jboolean isSingleUpdate)
-{
- Q_UNUSED(env);
- Q_UNUSED(thiz);
- QGeoPositionInfo info = AndroidPositioning::positionInfoFromJavaLocation(location);
-
- QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
- if (!source) {
- qCWarning(lcPositioning) << "positionUpdated: source == 0";
- return;
- }
-
- //we need to invoke indirectly as the Looper thread is likely to be not the same thread
- if (!isSingleUpdate)
- QMetaObject::invokeMethod(source, "processPositionUpdate", Qt::AutoConnection,
- Q_ARG(QGeoPositionInfo, info));
- else
- QMetaObject::invokeMethod(source, "processSinglePositionUpdate", Qt::AutoConnection,
- Q_ARG(QGeoPositionInfo, info));
-}
-
-static void locationProvidersDisabled(JNIEnv *env, jobject thiz, jint androidClassKey)
-{
- Q_UNUSED(env);
- Q_UNUSED(thiz);
- QObject *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
- if (!source)
- source = AndroidPositioning::idToSatSource()->value(androidClassKey);
- if (!source) {
- qCWarning(lcPositioning) << "locationProvidersDisabled: source == 0";
- return;
- }
-
- QMetaObject::invokeMethod(source, "locationProviderDisabled", Qt::AutoConnection);
-}
-
-static void locationProvidersChanged(JNIEnv *env, jobject thiz, jint androidClassKey)
-{
- Q_UNUSED(env);
- Q_UNUSED(thiz);
- QObject *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
- if (!source) {
- qCWarning(lcPositioning) << "locationProvidersChanged: source == 0";
- return;
- }
-
- QMetaObject::invokeMethod(source, "locationProvidersChanged", Qt::AutoConnection);
-}
-
-static void notifySatelliteInfoUpdated(const QList<QGeoSatelliteInfo> &inView,
- const QList<QGeoSatelliteInfo> &inUse,
- jint androidClassKey, jboolean isSingleUpdate)
-{
- QGeoSatelliteInfoSourceAndroid *source = AndroidPositioning::idToSatSource()->value(androidClassKey);
- if (!source) {
- qCWarning(lcPositioning) << "notifySatelliteInfoUpdated: source == 0";
- return;
- }
-
- QMetaObject::invokeMethod(source, "processSatelliteUpdateInView", Qt::AutoConnection,
- Q_ARG(QList<QGeoSatelliteInfo>, inView), Q_ARG(bool, isSingleUpdate));
-
- QMetaObject::invokeMethod(source, "processSatelliteUpdateInUse", Qt::AutoConnection,
- Q_ARG(QList<QGeoSatelliteInfo>, inUse), Q_ARG(bool, isSingleUpdate));
-}
-
-static void satelliteGpsUpdated(JNIEnv *env, jobject thiz, jobjectArray satellites,
- jint androidClassKey, jboolean isSingleUpdate)
-{
- Q_UNUSED(thiz);
- QList<QGeoSatelliteInfo> inUse;
- QList<QGeoSatelliteInfo> sats =
- AndroidPositioning::satelliteInfoFromJavaLocation(env, satellites, &inUse);
-
- notifySatelliteInfoUpdated(sats, inUse, androidClassKey, isSingleUpdate);
-}
-
-static void satelliteGnssUpdated(JNIEnv *env, jobject thiz, jobject gnssStatus,
- jint androidClassKey, jboolean isSingleUpdate)
-{
- Q_UNUSED(env);
- Q_UNUSED(thiz);
-
- QList<QGeoSatelliteInfo> inUse;
- QList<QGeoSatelliteInfo> sats =
- AndroidPositioning::satelliteInfoFromJavaGnssStatus(gnssStatus, &inUse);
-
- notifySatelliteInfoUpdated(sats, inUse, androidClassKey, isSingleUpdate);
-}
-
-#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
- VAR = env.findStaticMethod(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
- if (!VAR) { \
- __android_log_print(ANDROID_LOG_FATAL, logTag, methodErrorMsg, METHOD_NAME, \
- METHOD_SIGNATURE); \
- return false; \
- }
-
-static bool registerNatives()
-{
- const JNINativeMethod methods[] = {
- {"positionUpdated", "(Landroid/location/Location;IZ)V", (void *)positionUpdated},
- {"locationProvidersDisabled", "(I)V", (void *) locationProvidersDisabled},
- {"satelliteGpsUpdated", "([Landroid/location/GpsSatellite;IZ)V", (void *)satelliteGpsUpdated},
- {"locationProvidersChanged", "(I)V", (void *) locationProvidersChanged},
- {"satelliteGnssUpdated", "(Landroid/location/GnssStatus;IZ)V", (void *)satelliteGnssUpdated}
- };
-
- QJniEnvironment env;
- if (!env.jniEnv()) {
- __android_log_print(ANDROID_LOG_FATAL, logTag, "Failed to create environment");
- return false;
- }
-
- if (!positioningClass.init("org/qtproject/qt/android/positioning/QtPositioning")) {
- __android_log_print(ANDROID_LOG_FATAL, logTag, "Failed to create global class ref");
- return false;
- }
-
- if (!env.registerNativeMethods(positioningClass(), methods,
- sizeof(methods) / sizeof(methods[0]))) {
- __android_log_print(ANDROID_LOG_FATAL, logTag, "Failed to register native methods");
- return false;
- }
-
- GET_AND_CHECK_STATIC_METHOD(providerListMethodId, positioningClass(), "providerList", "()[I");
- GET_AND_CHECK_STATIC_METHOD(lastKnownPositionMethodId, positioningClass(), "lastKnownPosition",
- "(Z)Landroid/location/Location;");
- GET_AND_CHECK_STATIC_METHOD(startUpdatesMethodId, positioningClass(), "startUpdates", "(III)I");
- GET_AND_CHECK_STATIC_METHOD(stopUpdatesMethodId, positioningClass(), "stopUpdates", "(I)V");
- GET_AND_CHECK_STATIC_METHOD(requestUpdateMethodId, positioningClass(), "requestUpdate",
- "(II)I");
- GET_AND_CHECK_STATIC_METHOD(startSatelliteUpdatesMethodId, positioningClass(),
- "startSatelliteUpdates", "(IIZ)I");
-
- return true;
-}
-
-Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM * /*vm*/, void * /*reserved*/)
-{
- static bool initialized = false;
- if (initialized)
- return JNI_VERSION_1_6;
- initialized = true;
-
- __android_log_print(ANDROID_LOG_INFO, logTag, "Positioning start");
-
- if (!registerNatives()) {
- __android_log_print(ANDROID_LOG_FATAL, logTag, "registerNatives() failed");
- return -1;
- }
-
- if (!ConstellationMapper::init()) {
- __android_log_print(ANDROID_LOG_ERROR, logTag,
- "Failed to extract constellation type constants. "
- "Satellite system will be undefined!");
- }
-
- return JNI_VERSION_1_6;
-}
-
diff --git a/src/plugins/position/android/src/jnipositioning.h b/src/plugins/position/android/src/jnipositioning.h
deleted file mode 100644
index a9a72ecb..00000000
--- a/src/plugins/position/android/src/jnipositioning.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef JNIPOSITIONING_H
-#define JNIPOSITIONING_H
-
-#include <QGeoPositionInfoSource>
-#include <QGeoSatelliteInfoSource>
-
-namespace AndroidPositioning
-{
- int registerPositionInfoSource(QObject *obj);
- void unregisterPositionInfoSource(int key);
-
- QGeoPositionInfoSource::PositioningMethods availableProviders();
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly);
-
- QGeoPositionInfoSource::Error startUpdates(int androidClassKey);
- void stopUpdates(int androidClassKey);
- QGeoPositionInfoSource::Error requestUpdate(int androidClassKey);
-
- QGeoSatelliteInfoSource::Error startSatelliteUpdates(int androidClassKey,
- bool isSingleRequest,
- int updateRequestTimeout);
- bool requestionPositioningPermissions();
-}
-
-#endif // JNIPOSITIONING_H
diff --git a/src/plugins/position/android/src/plugin.json b/src/plugins/position/android/src/plugin.json
deleted file mode 100644
index 4fd87892..00000000
--- a/src/plugins/position/android/src/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["android"],
- "Provider": "android",
- "Position": true,
- "Satellite": true,
- "Monitor": false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/android/src/positionfactory_android.cpp b/src/plugins/position/android/src/positionfactory_android.cpp
deleted file mode 100644
index 436b1df6..00000000
--- a/src/plugins/position/android/src/positionfactory_android.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "positionfactory_android.h"
-#include "qgeopositioninfosource_android_p.h"
-#include "qgeosatelliteinfosource_android_p.h"
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryAndroid::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- QGeoPositionInfoSourceAndroid *src = new QGeoPositionInfoSourceAndroid(parent);
- return src;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryAndroid::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- QGeoSatelliteInfoSourceAndroid *src = new QGeoSatelliteInfoSourceAndroid(parent);
- return src;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryAndroid::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
diff --git a/src/plugins/position/android/src/positionfactory_android.h b/src/plugins/position/android/src/positionfactory_android.h
deleted file mode 100644
index 0494b533..00000000
--- a/src/plugins/position/android/src/positionfactory_android.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef POSITIONPOLLFACTORY_H
-#define POSITIONPOLLFACTORY_H
-
-#include <QObject>
-#include <QGeoPositionInfoSourceFactory>
-
-class QGeoPositionInfoSourceFactoryAndroid : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-#endif // POSITIONPOLLFACTORY_H
diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
deleted file mode 100644
index b1a41e92..00000000
--- a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_android_p.h"
-#include "jnipositioning.h"
-#include <QGeoPositionInfo>
-
-static constexpr int kUpdateFromColdStart = 2 * 60 * 1000;
-static constexpr int kRegularUpdatesTimerInterval = 30 * 1000;
-
-QGeoPositionInfoSourceAndroid::QGeoPositionInfoSourceAndroid(QObject *parent) :
- QGeoPositionInfoSource(parent)
-{
- androidClassKeyForUpdate = AndroidPositioning::registerPositionInfoSource(this);
- androidClassKeyForSingleRequest = AndroidPositioning::registerPositionInfoSource(this);
-
- //by default use all methods
- setPreferredPositioningMethods(AllPositioningMethods);
-
- m_requestTimer.setSingleShot(true);
- connect(&m_requestTimer, &QTimer::timeout, this,
- &QGeoPositionInfoSourceAndroid::requestTimeout);
-
- m_regularUpdatesTimer.setSingleShot(false);
- connect(&m_regularUpdatesTimer, &QTimer::timeout, this,
- &QGeoPositionInfoSourceAndroid::regularUpdatesTimeout);
-}
-
-QGeoPositionInfoSourceAndroid::~QGeoPositionInfoSourceAndroid()
-{
- stopUpdates();
-
- if (m_requestTimer.isActive()) {
- m_requestTimer.stop();
- AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
- }
-
- AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForUpdate);
- AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForSingleRequest);
-}
-
-void QGeoPositionInfoSourceAndroid::setUpdateInterval(int msec)
-{
- int previousInterval = updateInterval();
- msec = (((msec > 0) && (msec < minimumUpdateInterval())) || msec < 0)? minimumUpdateInterval() : msec;
-
- if (msec == previousInterval)
- return;
-
- QGeoPositionInfoSource::setUpdateInterval(msec);
-
- if (updatesRunning)
- reconfigureRunningSystem();
-}
-
-QGeoPositionInfo QGeoPositionInfoSourceAndroid::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- return AndroidPositioning::lastKnownPosition(fromSatellitePositioningMethodsOnly);
-}
-
-QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceAndroid::supportedPositioningMethods() const
-{
- return AndroidPositioning::availableProviders();
-}
-
-void QGeoPositionInfoSourceAndroid::setPreferredPositioningMethods(QGeoPositionInfoSource::PositioningMethods methods)
-{
- PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods();
- QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
- if (previousPreferredPositioningMethods == preferredPositioningMethods())
- return;
-
- if (updatesRunning)
- reconfigureRunningSystem();
-}
-
-int QGeoPositionInfoSourceAndroid::minimumUpdateInterval() const
-{
- return 50;
-}
-
-QGeoPositionInfoSource::Error QGeoPositionInfoSourceAndroid::error() const
-{
- return m_error;
-}
-
-void QGeoPositionInfoSourceAndroid::setError(Error error)
-{
- m_error = error;
- if (error != QGeoPositionInfoSource::NoError)
- emit QGeoPositionInfoSource::errorOccurred(m_error);
-}
-
-void QGeoPositionInfoSourceAndroid::startUpdates()
-{
- if (updatesRunning)
- return;
-
- m_error = QGeoPositionInfoSource::NoError;
-
- if (preferredPositioningMethods() == 0) {
- setError(UnknownSourceError);
- return;
- }
-
- updatesRunning = true;
- // Start calculating updates from now.
- m_lastUpdateTime = QDateTime::currentMSecsSinceEpoch();
- m_regularUpdatesErrorRaised = false;
- QGeoPositionInfoSource::Error error = AndroidPositioning::startUpdates(androidClassKeyForUpdate);
- if (error != QGeoPositionInfoSource::NoError) {
- updatesRunning = false;
- setError(error);
- } else {
- m_regularUpdatesTimer.start(kRegularUpdatesTimerInterval);
- }
-}
-
-void QGeoPositionInfoSourceAndroid::stopUpdates()
-{
- if (!updatesRunning)
- return;
-
- updatesRunning = false;
- m_regularUpdatesTimer.stop();
- AndroidPositioning::stopUpdates(androidClassKeyForUpdate);
-}
-
-void QGeoPositionInfoSourceAndroid::requestUpdate(int timeout)
-{
- if (m_requestTimer.isActive())
- return;
-
- m_error = QGeoPositionInfoSource::NoError;
-
- if (timeout != 0 && timeout < minimumUpdateInterval()) {
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- return;
- }
-
- if (timeout == 0)
- timeout = kUpdateFromColdStart;
-
- m_requestTimer.start(timeout);
-
- // if updates already running with interval equal to timeout
- // then we wait for next update coming through
- // assume that a single update will not be quicker than regular updates anyway
- if (updatesRunning && updateInterval() <= timeout)
- return;
-
- QGeoPositionInfoSource::Error error = AndroidPositioning::requestUpdate(androidClassKeyForSingleRequest);
- if (error != QGeoPositionInfoSource::NoError) {
- m_requestTimer.stop();
- setError(error);
- }
-}
-
-void QGeoPositionInfoSourceAndroid::processPositionUpdate(const QGeoPositionInfo &pInfo)
-{
- //single update request and served as part of regular update
- if (m_requestTimer.isActive())
- m_requestTimer.stop();
-
- m_lastUpdateTime = QDateTime::currentMSecsSinceEpoch();
- m_regularUpdatesErrorRaised = false;
-
- emit positionUpdated(pInfo);
-}
-
-// Might still be called multiple times (once for each provider)
-void QGeoPositionInfoSourceAndroid::processSinglePositionUpdate(const QGeoPositionInfo &pInfo)
-{
- //timeout but we received a late update -> ignore
- if (!m_requestTimer.isActive())
- return;
-
- queuedSingleUpdates.append(pInfo);
-}
-
-void QGeoPositionInfoSourceAndroid::locationProviderDisabled()
-{
- if (updatesRunning && !m_regularUpdatesErrorRaised) {
- m_regularUpdatesErrorRaised = true;
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- }
-
- setError(QGeoPositionInfoSource::ClosedError);
-}
-
-void QGeoPositionInfoSourceAndroid::locationProvidersChanged()
-{
- emit supportedPositioningMethodsChanged();
-}
-
-void QGeoPositionInfoSourceAndroid::requestTimeout()
-{
- AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
- //no queued update to process -> timeout
- const int count = queuedSingleUpdates.count();
-
- if (!count) {
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- return;
- }
-
- //pick best
- QGeoPositionInfo best = queuedSingleUpdates[0];
- for (int i = 1; i < count; i++) {
- const QGeoPositionInfo info = queuedSingleUpdates[i];
-
- //anything newer by 20s is always better
- const qint64 timeDelta = best.timestamp().secsTo(info.timestamp());
- if (abs(timeDelta) > 20) {
- if (timeDelta > 0)
- best = info;
- continue;
- }
-
- //compare accuracy
- if (info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy) &&
- best.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
- {
- best = info.attribute(QGeoPositionInfo::HorizontalAccuracy) <
- best.attribute(QGeoPositionInfo::HorizontalAccuracy) ? info : best;
- continue;
- }
-
- //prefer info with accuracy information
- if (info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
- best = info;
- }
-
- queuedSingleUpdates.clear();
- emit positionUpdated(best);
-}
-
-void QGeoPositionInfoSourceAndroid::regularUpdatesTimeout()
-{
- if (!m_regularUpdatesErrorRaised) {
- const auto now = QDateTime::currentMSecsSinceEpoch();
- if ((now - m_lastUpdateTime) > (updateInterval() + kUpdateFromColdStart)) {
- m_regularUpdatesErrorRaised = true;
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- }
- }
-}
-
-/*
- Updates the system assuming that updateInterval
- and/or preferredPositioningMethod have changed.
- */
-void QGeoPositionInfoSourceAndroid::reconfigureRunningSystem()
-{
- if (!updatesRunning)
- return;
-
- stopUpdates();
- startUpdates();
-}
diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android_p.h b/src/plugins/position/android/src/qgeopositioninfosource_android_p.h
deleted file mode 100644
index 44cb2799..00000000
--- a/src/plugins/position/android/src/qgeopositioninfosource_android_p.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCE_ANDROID_P_H
-#define QGEOPOSITIONINFOSOURCE_ANDROID_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QGeoPositionInfoSource>
-#include <QTimer>
-
-class QGeoPositionInfoSourceAndroid : public QGeoPositionInfoSource
-{
- Q_OBJECT
-public:
- QGeoPositionInfoSourceAndroid(QObject *parent = 0);
- ~QGeoPositionInfoSourceAndroid();
-
- // From QGeoPositionInfoSource
- void setUpdateInterval(int msec) override;
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
- PositioningMethods supportedPositioningMethods() const override;
- void setPreferredPositioningMethods(PositioningMethods methods) override;
- int minimumUpdateInterval() const override;
- Error error() const override;
-
-public Q_SLOTS:
- virtual void startUpdates() override;
- virtual void stopUpdates() override;
-
- virtual void requestUpdate(int timeout = 0) override;
-
- void processPositionUpdate(const QGeoPositionInfo& pInfo);
- void processSinglePositionUpdate(const QGeoPositionInfo& pInfo);
-
- void locationProviderDisabled();
- void locationProvidersChanged();
-private Q_SLOTS:
- void requestTimeout();
- void regularUpdatesTimeout();
-
-private:
- void reconfigureRunningSystem();
- void setError(Error error);
-
- bool updatesRunning = false;
- int androidClassKeyForUpdate;
- int androidClassKeyForSingleRequest;
- QList<QGeoPositionInfo> queuedSingleUpdates;
- Error m_error = NoError;
- QTimer m_requestTimer;
- QTimer m_regularUpdatesTimer;
- qint64 m_lastUpdateTime = 0;
- bool m_regularUpdatesErrorRaised = false;
-};
-
-#endif // QGEOPOSITIONINFOSOURCE_ANDROID_P_H
diff --git a/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp b/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp
deleted file mode 100644
index 13c09680..00000000
--- a/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-
-#include "qgeosatelliteinfosource_android_p.h"
-#include "jnipositioning.h"
-
-Q_DECLARE_METATYPE(QList<QGeoSatelliteInfo>)
-
-#define UPDATE_FROM_COLD_START 2*60*1000
-
-QGeoSatelliteInfoSourceAndroid::QGeoSatelliteInfoSourceAndroid(QObject *parent) :
- QGeoSatelliteInfoSource(parent), m_error(NoError), updatesRunning(false)
-{
- qRegisterMetaType< QGeoSatelliteInfo >();
- qRegisterMetaType< QList<QGeoSatelliteInfo> >();
- androidClassKeyForUpdate = AndroidPositioning::registerPositionInfoSource(this);
- androidClassKeyForSingleRequest = AndroidPositioning::registerPositionInfoSource(this);
-
- requestTimer.setSingleShot(true);
- QObject::connect(&requestTimer, SIGNAL(timeout()),
- this, SLOT(requestTimeout()));
-}
-
-QGeoSatelliteInfoSourceAndroid::~QGeoSatelliteInfoSourceAndroid()
-{
- stopUpdates();
-
- if (requestTimer.isActive()) {
- requestTimer.stop();
- AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
- }
-
- AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForUpdate);
- AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForSingleRequest);
-}
-
-
-void QGeoSatelliteInfoSourceAndroid::setUpdateInterval(int msec)
-{
- int previousInterval = updateInterval();
- msec = (((msec > 0) && (msec < minimumUpdateInterval())) || msec < 0)? minimumUpdateInterval() : msec;
-
- if (msec == previousInterval)
- return;
-
- QGeoSatelliteInfoSource::setUpdateInterval(msec);
-
- if (updatesRunning)
- reconfigureRunningSystem();
-}
-
-int QGeoSatelliteInfoSourceAndroid::minimumUpdateInterval() const
-{
- return 50;
-}
-
-QGeoSatelliteInfoSource::Error QGeoSatelliteInfoSourceAndroid::error() const
-{
- return m_error;
-}
-
-void QGeoSatelliteInfoSourceAndroid::startUpdates()
-{
- if (updatesRunning)
- return;
-
- updatesRunning = true;
-
- m_error = QGeoSatelliteInfoSource::NoError;
-
- QGeoSatelliteInfoSource::Error error = AndroidPositioning::startSatelliteUpdates(
- androidClassKeyForUpdate, false, updateInterval());
- if (error != QGeoSatelliteInfoSource::NoError) {
- updatesRunning = false;
- setError(error);
- }
-}
-
-void QGeoSatelliteInfoSourceAndroid::stopUpdates()
-{
- if (!updatesRunning)
- return;
-
- updatesRunning = false;
- AndroidPositioning::stopUpdates(androidClassKeyForUpdate);
-}
-
-void QGeoSatelliteInfoSourceAndroid::requestUpdate(int timeout)
-{
- if (requestTimer.isActive())
- return;
-
- m_error = QGeoSatelliteInfoSource::NoError;
-
- if (timeout != 0 && timeout < minimumUpdateInterval()) {
- setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
- return;
- }
-
- if (timeout == 0)
- timeout = UPDATE_FROM_COLD_START;
-
- requestTimer.start(timeout);
-
- // if updates already running with interval equal or less then timeout
- // then we wait for next update coming through
- // assume that a single update will not be quicker than regular updates anyway
- if (updatesRunning && updateInterval() <= timeout)
- return;
-
- QGeoSatelliteInfoSource::Error error = AndroidPositioning::startSatelliteUpdates(
- androidClassKeyForSingleRequest, true, timeout);
- if (error != QGeoSatelliteInfoSource::NoError) {
- requestTimer.stop();
- setError(error);
- }
-}
-
-void QGeoSatelliteInfoSourceAndroid::processSatelliteUpdateInView(const QList<QGeoSatelliteInfo> &satsInView, bool isSingleUpdate)
-{
- if (!isSingleUpdate) {
- //if requested while regular updates were running
- if (requestTimer.isActive())
- requestTimer.stop();
- emit QGeoSatelliteInfoSource::satellitesInViewUpdated(satsInView);
- return;
- }
-
- m_satsInView = satsInView;
-}
-
-void QGeoSatelliteInfoSourceAndroid::processSatelliteUpdateInUse(const QList<QGeoSatelliteInfo> &satsInUse, bool isSingleUpdate)
-{
- if (!isSingleUpdate) {
- //if requested while regular updates were running
- if (requestTimer.isActive())
- requestTimer.stop();
- emit QGeoSatelliteInfoSource::satellitesInUseUpdated(satsInUse);
- return;
- }
-
- m_satsInUse = satsInUse;
-}
-
-void QGeoSatelliteInfoSourceAndroid::requestTimeout()
-{
- AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
-
- const int count = m_satsInView.count();
- if (!count) {
- setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
- return;
- }
-
- emit QGeoSatelliteInfoSource::satellitesInViewUpdated(m_satsInView);
- emit QGeoSatelliteInfoSource::satellitesInUseUpdated(m_satsInUse);
-
- m_satsInUse.clear();
- m_satsInView.clear();
-}
-
-/*
- Updates the system assuming that updateInterval
- and/or preferredPositioningMethod have changed.
- */
-void QGeoSatelliteInfoSourceAndroid::reconfigureRunningSystem()
-{
- if (!updatesRunning)
- return;
-
- stopUpdates();
- startUpdates();
-}
-
-void QGeoSatelliteInfoSourceAndroid::setError(QGeoSatelliteInfoSource::Error error)
-{
- m_error = error;
- if (m_error != QGeoSatelliteInfoSource::NoError)
- emit QGeoSatelliteInfoSource::errorOccurred(m_error);
-}
-
-void QGeoSatelliteInfoSourceAndroid::locationProviderDisabled()
-{
- setError(QGeoSatelliteInfoSource::ClosedError);
-}
diff --git a/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h b/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h
deleted file mode 100644
index 19b7b577..00000000
--- a/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef QGEOSATELLITEINFOSOURCEANDROID_H
-#define QGEOSATELLITEINFOSOURCEANDROID_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QGeoSatelliteInfoSource>
-#include <QTimer>
-
-class QGeoSatelliteInfoSourceAndroid : public QGeoSatelliteInfoSource
-{
- Q_OBJECT
-public:
- explicit QGeoSatelliteInfoSourceAndroid(QObject *parent = 0);
- ~QGeoSatelliteInfoSourceAndroid();
-
- //From QGeoSatelliteInfoSource
- void setUpdateInterval(int msec) override;
- int minimumUpdateInterval() const override;
-
- Error error() const override;
-
-public Q_SLOTS:
- void startUpdates() override;
- void stopUpdates() override;
- void requestUpdate(int timeout = 0) override;
-
- void processSatelliteUpdateInView(const QList<QGeoSatelliteInfo> &satsInView, bool isSingleUpdate);
- void processSatelliteUpdateInUse(const QList<QGeoSatelliteInfo> &satsInUse, bool isSingleUpdate);
-
- void locationProviderDisabled();
-private Q_SLOTS:
- void requestTimeout();
-
-private:
- void reconfigureRunningSystem();
- void setError(QGeoSatelliteInfoSource::Error error);
-
- Error m_error;
- int androidClassKeyForUpdate;
- int androidClassKeyForSingleRequest;
- bool updatesRunning;
-
- QTimer requestTimer;
- QList<QGeoSatelliteInfo> m_satsInUse;
- QList<QGeoSatelliteInfo> m_satsInView;
-
-};
-
-#endif // QGEOSATELLITEINFOSOURCEANDROID_H
diff --git a/src/plugins/position/android/src/src.pro b/src/plugins/position/android/src/src.pro
deleted file mode 100644
index 36facc55..00000000
--- a/src/plugins/position/android/src/src.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-TARGET = qtposition_android
-
-QT = core core-private positioning
-
-HEADERS = \
- positionfactory_android.h \
- qgeopositioninfosource_android_p.h \
- jnipositioning.h \
- qgeosatelliteinfosource_android_p.h
-
-SOURCES = \
- positionfactory_android.cpp \
- qgeopositioninfosource_android.cpp \
- jnipositioning.cpp \
- qgeosatelliteinfosource_android.cpp
-
-OTHER_FILES = plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryAndroid
-load(qt_plugin)
diff --git a/src/plugins/position/corelocation/CMakeLists.txt b/src/plugins/position/corelocation/CMakeLists.txt
deleted file mode 100644
index 0126aa65..00000000
--- a/src/plugins/position/corelocation/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated from corelocation.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryCL Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryCLPlugin
- OUTPUT_NAME qtposition_cl
- CLASS_NAME QGeoPositionInfoSourceFactoryCL
- PLUGIN_TYPE position
- SOURCES
- qgeopositioninfosource_cl.mm qgeopositioninfosource_cl_p.h
- qgeopositioninfosourcefactory_cl.h qgeopositioninfosourcefactory_cl.mm
- LIBRARIES
- ${FWCoreLocation}
- ${FWFoundation}
- Qt::Core
- Qt::CorePrivate
- Qt::Positioning
-)
-
-# special case begin
-set_target_properties(QGeoPositionInfoSourceFactoryCLPlugin
- PROPERTIES
- DISABLE_PRECOMPILE_HEADERS ON
-)
-# special case end
-
-#### Keys ignored in scope 1:.:.:corelocation.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 2:.:.:corelocation.pro:NOT APPLE:
-# DISTFILES = "$$OBJECTIVE_SOURCES"
diff --git a/src/plugins/position/corelocation/corelocation.pro b/src/plugins/position/corelocation/corelocation.pro
deleted file mode 100644
index 6b7ba82c..00000000
--- a/src/plugins/position/corelocation/corelocation.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-TARGET = qtposition_cl
-
-QT = core core-private positioning
-
-OBJECTIVE_SOURCES += \
- qgeopositioninfosource_cl.mm \
- qgeopositioninfosourcefactory_cl.mm
-
-HEADERS += \
- qgeopositioninfosource_cl_p.h \
- qgeopositioninfosourcefactory_cl.h
-
-OTHER_FILES += \
- plugin.json
-
-LIBS += -framework Foundation -framework CoreLocation
-
-!darwin {
- DISTFILES += $$OBJECTIVE_SOURCES
-}
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryCL
-load(qt_plugin)
diff --git a/src/plugins/position/corelocation/plugin.json b/src/plugins/position/corelocation/plugin.json
deleted file mode 100644
index 58e3acd0..00000000
--- a/src/plugins/position/corelocation/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["corelocation"],
- "Provider": "corelocation",
- "Position": true,
- "Satellite": false,
- "Monitor" : false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm
deleted file mode 100644
index c7e02443..00000000
--- a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm
+++ /dev/null
@@ -1,336 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTimerEvent>
-#include <QDebug>
-#include <QtCore/qglobal.h>
-#include <QtCore/private/qglobal_p.h>
-
-#include "qgeopositioninfosource_cl_p.h"
-
-#define MINIMUM_UPDATE_INTERVAL 1000
-
-@interface PositionLocationDelegate : NSObject <CLLocationManagerDelegate>
-@end
-
-@implementation PositionLocationDelegate
-{
- QGeoPositionInfoSourceCL *m_positionInfoSource;
-}
-
-- (instancetype)initWithInfoSource:(QGeoPositionInfoSourceCL*) positionInfoSource
-{
- if ((self = [self init])) {
- m_positionInfoSource = positionInfoSource;
- }
- return self;
-}
-- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
-{
- Q_UNUSED(manager);
- if (status == kCLAuthorizationStatusNotDetermined)
- m_positionInfoSource->requestUpdate(MINIMUM_UPDATE_INTERVAL);
-}
-
-- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
-{
- Q_UNUSED(manager);
- Q_UNUSED(oldLocation);
-
- // Convert location timestamp to QDateTime
- NSTimeInterval locationTimeStamp = [newLocation.timestamp timeIntervalSince1970];
- const QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(qRound64(locationTimeStamp * 1000), Qt::UTC);
-
- // Construct position info from location data
- QGeoPositionInfo location(QGeoCoordinate(newLocation.coordinate.latitude,
- newLocation.coordinate.longitude,
- newLocation.altitude),
- timeStamp);
- if (newLocation.horizontalAccuracy >= 0)
- location.setAttribute(QGeoPositionInfo::HorizontalAccuracy, newLocation.horizontalAccuracy);
- if (newLocation.verticalAccuracy >= 0)
- location.setAttribute(QGeoPositionInfo::VerticalAccuracy, newLocation.verticalAccuracy);
-#ifndef Q_OS_TVOS
- if (newLocation.course >= 0)
- location.setAttribute(QGeoPositionInfo::Direction, newLocation.course);
- if (newLocation.speed >= 0)
- location.setAttribute(QGeoPositionInfo::GroundSpeed, newLocation.speed);
-#endif
-
- m_positionInfoSource->locationDataAvailable(location);
-}
-
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
-{
- Q_UNUSED(manager);
- m_positionInfoSource->setError(QGeoPositionInfoSource::AccessError);
-
- qWarning() << QString::fromNSString([error localizedDescription]);
-
- if ([error code] == 0
- && QString::fromNSString([error domain]) == QStringLiteral("kCLErrorDomain"))
- qWarning() << "(is Wi-Fi turned on?)";
-}
-@end
-
-QT_BEGIN_NAMESPACE
-
-QGeoPositionInfoSourceCL::QGeoPositionInfoSourceCL(QObject *parent)
- : QGeoPositionInfoSource(parent)
- , m_locationManager(0)
- , m_started(false)
- , m_updateTimer(0)
- , m_updateTimeout(0)
- , m_positionError(QGeoPositionInfoSource::NoError)
-{
-}
-
-QGeoPositionInfoSourceCL::~QGeoPositionInfoSourceCL()
-{
- stopUpdates();
- [m_locationManager release];
-}
-
-void QGeoPositionInfoSourceCL::setUpdateInterval(int msec)
-{
- // If msec is 0 we send updates as data becomes available, otherwise we force msec to be equal
- // to or larger than the minimum update interval.
- if (msec != 0 && msec < minimumUpdateInterval())
- msec = minimumUpdateInterval();
-
- QGeoPositionInfoSource::setUpdateInterval(msec);
-
- // Must timeout if update takes longer than specified interval
- m_updateTimeout = msec;
- if (m_started) setTimeoutInterval(m_updateTimeout);
-}
-
-bool QGeoPositionInfoSourceCL::enableLocationManager()
-{
- if (!m_locationManager) {
- if ([CLLocationManager locationServicesEnabled]) {
- // Location Services Are Enabled
- switch ([CLLocationManager authorizationStatus]) {
- case kCLAuthorizationStatusNotDetermined:
- // User has not yet made a choice with regards to this application
- break;
- case kCLAuthorizationStatusRestricted:
- // This application is not authorized to use location services. Due
- // to active restrictions on location services, the user cannot change
- // this status, and may not have personally denied authorization
- return false;
- case kCLAuthorizationStatusDenied:
- // User has explicitly denied authorization for this application, or
- // location services are disabled in Settings
- return false;
- case kCLAuthorizationStatusAuthorizedAlways:
- // This app is authorized to start location services at any time.
- break;
-#ifndef Q_OS_MACOS
- case kCLAuthorizationStatusAuthorizedWhenInUse:
- // This app is authorized to start most location services while running in the foreground.
- break;
-#endif
- default:
- // By default, try to enable it
- break;
- }
- } else {
- // Location Services Disabled
- return false;
- }
-
- m_locationManager = [[CLLocationManager alloc] init];
-
-#if defined(Q_OS_IOS) || defined(Q_OS_WATCHOS)
- if (__builtin_available(watchOS 4.0, *)) {
- NSDictionary<NSString *, id> *infoDict = [[NSBundle mainBundle] infoDictionary];
- if (id value = [infoDict objectForKey:@"UIBackgroundModes"]) {
- if ([value isKindOfClass:[NSArray class]]) {
- NSArray *modes = static_cast<NSArray *>(value);
- for (id mode in modes) {
- if ([@"location" isEqualToString:mode]) {
- m_locationManager.allowsBackgroundLocationUpdates = YES;
- break;
- }
- }
- }
- }
- }
-#endif
-
- m_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
- m_locationManager.delegate = [[PositionLocationDelegate alloc] initWithInfoSource:this];
-
- // -requestAlwaysAuthorization is available on iOS (>= 8.0) and watchOS (>= 2.0).
- // This method requires both NSLocationAlwaysAndWhenInUseUsageDescription and
- // NSLocationWhenInUseUsageDescription entries present in Info.plist (otherwise,
- // while probably a noop, the call generates a warning).
- // -requestWhenInUseAuthorization only requires NSLocationWhenInUseUsageDescription
- // entry in Info.plist (available on iOS (>= 8.0), tvOS (>= 9.0) and watchOS (>= 2.0).
- }
-
-#ifndef Q_OS_MACOS
- NSDictionary<NSString *, id> *infoDict = NSBundle.mainBundle.infoDictionary;
- const bool hasAlwaysUseUsage = !![infoDict objectForKey:@"NSLocationAlwaysAndWhenInUseUsageDescription"];
- const bool hasWhenInUseUsage = !![infoDict objectForKey:@"NSLocationWhenInUseUsageDescription"];
-#ifndef Q_OS_TVOS
- if (hasAlwaysUseUsage && hasWhenInUseUsage)
- [m_locationManager requestAlwaysAuthorization];
- else
-#endif // !Q_OS_TVOS
- if (hasWhenInUseUsage)
- [m_locationManager requestWhenInUseAuthorization];
-#endif // !Q_OS_MACOS
-
- return (m_locationManager != nullptr);
-}
-
-void QGeoPositionInfoSourceCL::setTimeoutInterval(int msec)
-{
- // Start timeout timer
- if (m_updateTimer) killTimer(m_updateTimer);
- if (msec > 0) m_updateTimer = startTimer(msec);
- else m_updateTimer = 0;
-}
-
-void QGeoPositionInfoSourceCL::startUpdates()
-{
- m_positionError = QGeoPositionInfoSource::NoError;
- if (enableLocationManager()) {
-#ifdef Q_OS_TVOS
- [m_locationManager requestLocation]; // service will run long enough for one location update
-#else
- [m_locationManager startUpdatingLocation];
-#endif
- m_started = true;
-
- setTimeoutInterval(m_updateTimeout);
- } else setError(QGeoPositionInfoSource::AccessError);
-}
-
-void QGeoPositionInfoSourceCL::stopUpdates()
-{
- if (m_locationManager) {
- [m_locationManager stopUpdatingLocation];
- m_started = false;
-
- // Stop timeout timer
- setTimeoutInterval(0);
- } else setError(QGeoPositionInfoSource::AccessError);
-}
-
-void QGeoPositionInfoSourceCL::requestUpdate(int timeout)
-{
- // Get a single update within timeframe
- m_positionError = QGeoPositionInfoSource::NoError;
- if (timeout < minimumUpdateInterval() && timeout != 0)
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- else if (enableLocationManager()) {
- // This will force LM to generate a new update
- [m_locationManager stopUpdatingLocation];
-#ifdef Q_OS_TVOS
- [m_locationManager requestLocation]; // service will run long enough for one location update
-#else
- [m_locationManager startUpdatingLocation];
-#endif
-
- setTimeoutInterval(timeout);
- } else setError(QGeoPositionInfoSource::AccessError);
-}
-
-void QGeoPositionInfoSourceCL::timerEvent( QTimerEvent * event )
-{
- // Update timed out?
- if (event->timerId() == m_updateTimer) {
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
-
- // Only timeout once since last data
- setTimeoutInterval(0);
-
- // Started for single update?
- if (!m_started) stopUpdates();
- }
-}
-
-QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceCL::supportedPositioningMethods() const
-{
- // CoreLocation doesn't say which positioning method(s) it used
- return QGeoPositionInfoSource::AllPositioningMethods;
-}
-
-int QGeoPositionInfoSourceCL::minimumUpdateInterval() const
-{
- return MINIMUM_UPDATE_INTERVAL;
-}
-
-void QGeoPositionInfoSourceCL::locationDataAvailable(QGeoPositionInfo location)
-{
- // Signal position data available
- m_lastUpdate = location;
- emit positionUpdated(location);
-
- // Started for single update?
- if (!m_started) stopUpdates();
- // ...otherwise restart timeout timer
- else setTimeoutInterval(m_updateTimeout);
-}
-
-QGeoPositionInfo QGeoPositionInfoSourceCL::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- Q_UNUSED(fromSatellitePositioningMethodsOnly);
-
- return m_lastUpdate;
-}
-
-QGeoPositionInfoSource::Error QGeoPositionInfoSourceCL::error() const
-{
- return m_positionError;
-}
-
-void QGeoPositionInfoSourceCL::setError(QGeoPositionInfoSource::Error positionError)
-{
- m_positionError = positionError;
- if (m_positionError != QGeoPositionInfoSource::NoError)
- emit QGeoPositionInfoSource::errorOccurred(positionError);
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qgeopositioninfosource_cl_p.cpp"
diff --git a/src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h b/src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h
deleted file mode 100644
index d38e7c3b..00000000
--- a/src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCECL_H
-#define QGEOPOSITIONINFOSOURCECL_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#import <CoreLocation/CoreLocation.h>
-
-#include "qgeopositioninfosource.h"
-#include "qgeopositioninfo.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourceCL : public QGeoPositionInfoSource
-{
- Q_OBJECT
-public:
- QGeoPositionInfoSourceCL(QObject *parent = 0);
- ~QGeoPositionInfoSourceCL();
-
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
- PositioningMethods supportedPositioningMethods() const override;
-
- void setUpdateInterval(int msec) override;
- int minimumUpdateInterval() const override;
- Error error() const override;
-
- void locationDataAvailable(QGeoPositionInfo location);
- void setError(QGeoPositionInfoSource::Error positionError);
-
-private:
- bool enableLocationManager();
- void setTimeoutInterval(int msec);
-
-public Q_SLOTS:
- void startUpdates() override;
- void stopUpdates() override;
-
- void requestUpdate(int timeout = 0) override;
-
-protected:
- void timerEvent(QTimerEvent *event) override;
-
-private:
- Q_DISABLE_COPY(QGeoPositionInfoSourceCL);
- CLLocationManager *m_locationManager;
- bool m_started;
-
- QGeoPositionInfo m_lastUpdate;
-
- int m_updateTimer;
- int m_updateTimeout;
-
- QGeoPositionInfoSource::Error m_positionError;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCECL_H
diff --git a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h b/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h
deleted file mode 100644
index 7e14e31f..00000000
--- a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_CL_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_CL_H
-
-#include <QObject>
-#include <QGeoPositionInfoSourceFactory>
-
-class QGeoPositionInfoSourceFactoryCL : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-#endif // QGEOPOSITIONINFOSOURCEFACTORY_CL_H
diff --git a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm
deleted file mode 100644
index e7d2a116..00000000
--- a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_cl_p.h"
-#include "qgeopositioninfosourcefactory_cl.h"
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryCL::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- return new QGeoPositionInfoSourceCL(parent);
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryCL::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryCL::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
diff --git a/src/plugins/position/geoclue2/CMakeLists.txt b/src/plugins/position/geoclue2/CMakeLists.txt
deleted file mode 100644
index c573ee1d..00000000
--- a/src/plugins/position/geoclue2/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Generated from geoclue2.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryGeoclue2 Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryGeoclue2Plugin
- OUTPUT_NAME qtposition_geoclue2
- CLASS_NAME QGeoPositionInfoSourceFactoryGeoclue2
- PLUGIN_TYPE position
- SOURCES
- geocluetypes.cpp geocluetypes.h
- qgeopositioninfosource_geoclue2.cpp qgeopositioninfosource_geoclue2_p.h
- qgeopositioninfosourcefactory_geoclue2.cpp qgeopositioninfosourcefactory_geoclue2.h
- DBUS_INTERFACE_SOURCES
- org.freedesktop.GeoClue2.Client.xml
- org.freedesktop.GeoClue2.Location.xml
- org.freedesktop.GeoClue2.Manager.xml
- DBUS_INTERFACE_FLAGS
- -N -i geocluetypes.h # special case
- INCLUDE_DIRECTORIES
- ${CMAKE_CURRENT_BINARY_DIR}
- core.location.includes
- LIBRARIES
- Qt::Core
- Qt::DBus
- Qt::Positioning
-)
-
-#### Keys ignored in scope 1:.:.:geoclue2.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/geoclue2/geoclue2.pro b/src/plugins/position/geoclue2/geoclue2.pro
deleted file mode 100644
index 1bd129d5..00000000
--- a/src/plugins/position/geoclue2/geoclue2.pro
+++ /dev/null
@@ -1,30 +0,0 @@
-TARGET = qtposition_geoclue2
-
-QT = core positioning dbus
-
-HEADERS += \
- qgeopositioninfosource_geoclue2_p.h \
- qgeopositioninfosourcefactory_geoclue2.h \
- geocluetypes.h
-
-SOURCES += \
- qgeopositioninfosource_geoclue2.cpp \
- qgeopositioninfosourcefactory_geoclue2.cpp \
- geocluetypes.cpp
-
-QDBUSXML2CPP_INTERFACE_HEADER_FLAGS += \
- "-N -i geocluetypes.h"
-
-DBUS_INTERFACES += \
- org.freedesktop.GeoClue2.Manager.xml \
- org.freedesktop.GeoClue2.Client.xml \
- org.freedesktop.GeoClue2.Location.xml
-
-INCLUDEPATH += $$QT.location.includes $$OUT_PWD
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryGeoclue2
-load(qt_plugin)
diff --git a/src/plugins/position/geoclue2/geocluetypes.cpp b/src/plugins/position/geoclue2/geocluetypes.cpp
deleted file mode 100644
index dec55d3c..00000000
--- a/src/plugins/position/geoclue2/geocluetypes.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "geocluetypes.h"
-
-QT_BEGIN_NAMESPACE
-
-QDBusArgument &operator<<(QDBusArgument &arg, const Timestamp &ts)
-{
- arg.beginStructure();
- arg << ts.m_seconds;
- arg << ts.m_microseconds;
- arg.endStructure();
- return arg;
-}
-
-const QDBusArgument &operator>>(const QDBusArgument &arg, Timestamp &ts)
-{
- arg.beginStructure();
- arg >> ts.m_seconds;
- arg >> ts.m_microseconds;
- arg.endStructure();
- return arg;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/geoclue2/geocluetypes.h b/src/plugins/position/geoclue2/geocluetypes.h
deleted file mode 100644
index 2fc3ca2d..00000000
--- a/src/plugins/position/geoclue2/geocluetypes.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GEOCLUETYPES_H
-#define GEOCLUETYPES_H
-
-#include <QtDBus/QDBusArgument>
-
-class Timestamp
-{
-public:
- quint64 m_seconds = 0;
- quint64 m_microseconds = 0;
-};
-
-QT_BEGIN_NAMESPACE
-
-Q_DECLARE_TYPEINFO(Timestamp, Q_RELOCATABLE_TYPE);
-
-QDBusArgument &operator<<(QDBusArgument &arg, const Timestamp &ts);
-const QDBusArgument &operator>>(const QDBusArgument &arg, Timestamp &ts);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(Timestamp)
-
-#endif // GEOCLUETYPES_H
diff --git a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Client.xml b/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Client.xml
deleted file mode 100644
index 4a9399b7..00000000
--- a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Client.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<!--
- GeoClue 2.0 Interface Specification
-
- Copyright 2013 Red Hat, Inc.
--->
-
-<node>
-
- <!--
- org.freedesktop.GeoClue2.Client:
- @short_description: The Application-specific client API
-
- This is the interface you use to retrieve location information and receive
- location update signals from GeoClue service. You get the client object to
- use this interface on from org.freedesktop.GeoClue2.Manager.GetClient()
- method.
- -->
- <interface name="org.freedesktop.GeoClue2.Client">
- <!--
- Location:
-
- Current location as path to a #org.freedesktop.GeoClue2.Location object.
- Please note that this property will be set to "/" (D-Bus equivalent of
- null) initially, until Geoclue finds user's location. You want to delay
- reading this property until your callback to
- #org.freedesktop.GeoClue2.Client::LocationUpdated signal is called for
- the first time after starting the client.
- -->
- <property name="Location" type="o" access="read"/>
-
- <!--
- DistanceThreshold:
-
- Contains the current distance threshold in meters. This value is used
- by the service when it gets new location info. If the distance moved is
- below the threshold, it won't emit the LocationUpdated signal.
- The default value is 0. When TimeThreshold is zero, it always emits
- the signal.
- -->
- <property name="DistanceThreshold" type="u" access="readwrite">
- <annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/>
- </property>
-
- <!--
- TimeThreshold:
-
- Contains the current time threshold in seconds. This value is used
- by the service when it gets new location info. If the time since the
- last update is below the threshold, it won't emit the LocationUpdated
- signal. The default value is 0. When TimeThreshold is zero, it always
- emits the signal.
- -->
- <property name="TimeThreshold" type="u" access="readwrite">
- <annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/>
- </property>
-
- <!--
- DesktopId:
-
- The desktop file id (the basename of the desktop file). This property
- must be set by applications for authorization to work.
- -->
- <property name="DesktopId" type="s" access="readwrite"/>
-
- <!--
- RequestedAccuracyLevel:
-
- The level of accuracy requested by client, as
- <link linkend="GClueAccuracyLevel">GClueAccuracyLevel</link>.
-
- Please keep in mind that the actual accuracy of location information is
- dependent on available hardware on your machine, external resources
- and/or how much accuracy user agrees to be confortable with.
- -->
- <property name="RequestedAccuracyLevel" type="u" access="readwrite"/>
-
- <!--
- Active:
-
- If client is active, i-e started successfully using
- org.freedesktop.GeoClue2.Client.Start() and receiving location updates.
-
- Please keep in mind that geoclue can at any time stop and start the
- client on user (agent) request. Applications that are interested in
- in these changes, should watch for changes in this property.
- -->
- <property name="Active" type="b" access="read"/>
-
- <!--
- Start:
-
- Start receiving events about the current location. Applications should
- hook-up to #org.freedesktop.GeoClue2.Client::LocationUpdated signal
- before calling this method.
- -->
- <method name="Start"/>
-
- <!--
- Stop:
-
- Stop receiving events about the current location.
- -->
- <method name="Stop"/>
-
- <!--
- LocationUpdated:
- @old: old location as path to a #org.freedesktop.GeoClue2.Location object
- @new: new location as path to a #org.freedesktop.GeoClue2.Location object
-
- The signal is emitted every time the location changes.
- The client should set the DistanceThreshold property to control how
- often this signal is emitted.
- -->
- <signal name="LocationUpdated">
- <arg name="oldLocation" type="o"/>
- <arg name="newLocation" type="o"/>
- </signal>
- </interface>
-</node>
diff --git a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Location.xml b/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Location.xml
deleted file mode 100644
index ebf2ea6b..00000000
--- a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Location.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<!--
- GeoClue 2.0 Interface Specification
-
- Copyright 2013 Red Hat, Inc.
--->
-
-<node>
-
- <!--
- org.freedesktop.GeoClue2.Location:
- @short_description: The Location interface
-
- This is the interface you use on location objects.
- -->
- <interface name="org.freedesktop.GeoClue2.Location">
-
- <!--
- Latitude:
-
- The latitude of the location, in degrees.
- -->
- <property name="Latitude" type="d" access="read"/>
-
- <!--
- Longitude:
-
- The longitude of the location, in degrees.
- -->
- <property name="Longitude" type="d" access="read"/>
-
- <!--
- Accuracy:
-
- The accuracy of the location fix, in meters.
- -->
- <property name="Accuracy" type="d" access="read"/>
-
- <!--
- Altitude:
-
- The altitude of the location fix, in meters. When unknown, its set to
- minimum double value, -1.7976931348623157e+308.
- -->
- <property name="Altitude" type="d" access="read"/>
-
- <!--
- Speed:
-
- The speed in meters per second. When unknown, it's set to -1.0.
- -->
- <property name="Speed" type="d" access="read"/>
-
- <!--
- Heading:
-
- The heading direction in degrees with respect to North direction, in
- clockwise order. That means North becomes 0 degree, East: 90 degrees,
- South: 180 degrees, West: 270 degrees and so on. When unknown,
- it's set to -1.0.
- -->
- <property name="Heading" type="d" access="read"/>
-
- <!--
- Description:
-
- A human-readable description of the location, if available.
-
- WARNING: Applications should not rely on this property since not all
- sources provide a description. If you really need a description (or
- more details) about current location, use a reverse-geocoding API, e.g
- geocode-glib.
- -->
- <property name="Description" type="s" access="read"/>
-
-
- <!--
- Timestamp:
-
- The timestamp when the location was determined, in seconds and
- microseconds since the Epoch. This is the time of measurement if the
- backend provided that information, otherwise the time when GeoClue
- received the new location.
-
- Note that GeoClue can't guarantee that the timestamp will always
- monotonically increase, as a backend may not respect that.
- Also note that a timestamp can be very old, e.g. because of a cached
- location.
- -->
- <property name="Timestamp" type="(tt)" access="read">
- <annotation name="org.qtproject.QtDBus.QtTypeName" value="Timestamp"/>
- </property>
- </interface>
-</node>
diff --git a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Manager.xml b/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Manager.xml
deleted file mode 100644
index cf9590f6..00000000
--- a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Manager.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<!--
- GeoClue 2.0 Interface Specification
-
- Copyright 2013 Red Hat, Inc.
--->
-
-<node>
-
- <!--
- org.freedesktop.GeoClue2.Manager:
- @short_description: The GeoClue service manager
-
- This is the interface you use to talk to main GeoClue2 manager object at
- path "/org/freedesktop/GeoClue2/Manager". The only thing you do with this
- interface is to call org.freedesktop.GeoClue2.Manager.GetClient() on it
- to get your application specific client object.
- -->
- <interface name="org.freedesktop.GeoClue2.Manager">
- <!--
- InUse:
-
- Whether service is currently is use by any application.
- -->
- <property name="InUse" type="b" access="read"/>
-
- <!--
- AvailableAccuracyLevel:
-
- The level of available accuracy, as
- <link linkend="GClueAccuracyLevel">GClueAccuracyLevel</link>.
- -->
- <property name="AvailableAccuracyLevel" type="u" access="read"/>
-
- <!--
- GetClient:
- @client: The path for newly created client object
-
- Retrieves a client object which can only be used by the calling
- application only.
- -->
- <method name="GetClient">
- <arg name="client" type="o" direction="out"/>
- </method>
-
- <!--
- AddAgent:
- @id: The Desktop ID (excluding .desktop) of the agent
-
- An API for user authorization agents to register themselves. Each agent
- is responsible for the user it is running as. Application developers
- can and should simply ignore this API.
- -->
- <method name="AddAgent">
- <arg name="id" type="s" direction="in"/>
- </method>
- </interface>
-</node>
diff --git a/src/plugins/position/geoclue2/plugin.json b/src/plugins/position/geoclue2/plugin.json
deleted file mode 100644
index c23d40e0..00000000
--- a/src/plugins/position/geoclue2/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["geoclue2"],
- "Provider": "geoclue2",
- "Position": true,
- "Satellite": false,
- "Monitor": false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
deleted file mode 100644
index 3c78a075..00000000
--- a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
+++ /dev/null
@@ -1,458 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_geoclue2_p.h"
-
-#include <QtCore/QLoggingCategory>
-#include <QtCore/QSaveFile>
-#include <QtCore/QScopedPointer>
-#include <QtCore/QTimer>
-#include <QtDBus/QDBusPendingCallWatcher>
-
-// Auto-generated D-Bus files.
-#include <client_interface.h>
-#include <location_interface.h>
-
-Q_DECLARE_LOGGING_CATEGORY(lcPositioningGeoclue2)
-
-QT_BEGIN_NAMESPACE
-
-namespace {
-
-// NOTE: Copied from the /usr/include/libgeoclue-2.0/gclue-client.h
-enum GClueAccuracyLevel {
- GCLUE_ACCURACY_LEVEL_NONE = 0,
- GCLUE_ACCURACY_LEVEL_COUNTRY = 1,
- GCLUE_ACCURACY_LEVEL_CITY = 4,
- GCLUE_ACCURACY_LEVEL_NEIGHBORHOOD = 5,
- GCLUE_ACCURACY_LEVEL_STREET = 6,
- GCLUE_ACCURACY_LEVEL_EXACT = 8
-};
-
-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()
-{
- return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
- + QStringLiteral("/qtposition-geoclue2");
-}
-
-} // namespace
-
-QGeoPositionInfoSourceGeoclue2::QGeoPositionInfoSourceGeoclue2(const QVariantMap &parameters,
- QObject *parent)
- : QGeoPositionInfoSource(parent)
- , m_requestTimer(new QTimer(this))
- , m_manager(QLatin1String(GEOCLUE2_SERVICE_NAME),
- QStringLiteral("/org/freedesktop/GeoClue2/Manager"),
- QDBusConnection::systemBus(),
- this)
-{
- parseParameters(parameters);
-
- qDBusRegisterMetaType<Timestamp>();
-
- restoreLastPosition();
-
- m_requestTimer->setSingleShot(true);
- connect(m_requestTimer, &QTimer::timeout,
- this, &QGeoPositionInfoSourceGeoclue2::requestUpdateTimeout);
-}
-
-QGeoPositionInfoSourceGeoclue2::~QGeoPositionInfoSourceGeoclue2()
-{
- saveLastPosition();
-}
-
-void QGeoPositionInfoSourceGeoclue2::setUpdateInterval(int msec)
-{
- QGeoPositionInfoSource::setUpdateInterval(msec);
- configureClient();
-}
-
-QGeoPositionInfo QGeoPositionInfoSourceGeoclue2::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- if (fromSatellitePositioningMethodsOnly && !m_lastPositionFromSatellite)
- return QGeoPositionInfo();
- return m_lastPosition;
-}
-
-QGeoPositionInfoSourceGeoclue2::PositioningMethods QGeoPositionInfoSourceGeoclue2::supportedPositioningMethods() const
-{
- bool ok;
- const auto accuracy = m_manager.property("AvailableAccuracyLevel").toUInt(&ok);
- if (!ok) {
- const_cast<QGeoPositionInfoSourceGeoclue2 *>(this)->setError(AccessError);
- return NoPositioningMethods;
- }
-
- switch (accuracy) {
- case GCLUE_ACCURACY_LEVEL_COUNTRY:
- case GCLUE_ACCURACY_LEVEL_CITY:
- case GCLUE_ACCURACY_LEVEL_NEIGHBORHOOD:
- case GCLUE_ACCURACY_LEVEL_STREET:
- return NonSatellitePositioningMethods;
- case GCLUE_ACCURACY_LEVEL_EXACT:
- return AllPositioningMethods;
- case GCLUE_ACCURACY_LEVEL_NONE:
- default:
- return NoPositioningMethods;
- }
-}
-
-void QGeoPositionInfoSourceGeoclue2::setPreferredPositioningMethods(PositioningMethods methods)
-{
- QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
- configureClient();
-}
-
-int QGeoPositionInfoSourceGeoclue2::minimumUpdateInterval() const
-{
- return MINIMUM_UPDATE_INTERVAL;
-}
-
-QGeoPositionInfoSource::Error QGeoPositionInfoSourceGeoclue2::error() const
-{
- return m_error;
-}
-
-void QGeoPositionInfoSourceGeoclue2::startUpdates()
-{
- if (m_running) {
- qCWarning(lcPositioningGeoclue2) << "Already running";
- return;
- }
-
- qCDebug(lcPositioningGeoclue2) << "Starting updates";
-
- m_error = QGeoPositionInfoSource::NoError;
-
- m_running = true;
-
- startClient();
-
- if (m_lastPosition.isValid()) {
- QMetaObject::invokeMethod(this, "positionUpdated", Qt::QueuedConnection,
- Q_ARG(QGeoPositionInfo, m_lastPosition));
- }
-}
-
-void QGeoPositionInfoSourceGeoclue2::stopUpdates()
-{
- if (!m_running) {
- qCWarning(lcPositioningGeoclue2) << "Already stopped";
- return;
- }
-
- qCDebug(lcPositioningGeoclue2) << "Stopping updates";
- m_running = false;
-
- stopClient();
-}
-
-void QGeoPositionInfoSourceGeoclue2::requestUpdate(int timeout)
-{
- if (m_requestTimer->isActive()) {
- qCDebug(lcPositioningGeoclue2) << "Request timer was active, ignoring startUpdates";
- return;
- }
-
- m_error = QGeoPositionInfoSource::NoError;
-
- if (timeout < minimumUpdateInterval() && timeout != 0) {
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- return;
- }
-
- m_requestTimer->start(timeout ? timeout : UPDATE_TIMEOUT_COLD_START);
- startClient();
-}
-
-void QGeoPositionInfoSourceGeoclue2::setError(QGeoPositionInfoSource::Error error)
-{
- m_error = error;
- if (m_error != QGeoPositionInfoSource::NoError)
- emit QGeoPositionInfoSource::errorOccurred(m_error);
-}
-
-void QGeoPositionInfoSourceGeoclue2::restoreLastPosition()
-{
-#if !defined(QT_NO_DATASTREAM)
- const auto filePath = lastPositionFilePath();
- QFile file(filePath);
- if (file.open(QIODevice::ReadOnly)) {
- QDataStream out(&file);
- out >> m_lastPosition;
- }
-#endif
-}
-
-void QGeoPositionInfoSourceGeoclue2::saveLastPosition()
-{
-#if !defined(QT_NO_DATASTREAM) && QT_CONFIG(temporaryfile)
- if (!m_lastPosition.isValid())
- return;
-
- const auto filePath = lastPositionFilePath();
- QSaveFile file(filePath);
- if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
- QDataStream out(&file);
- // Only save position and timestamp.
- out << QGeoPositionInfo(m_lastPosition.coordinate(), m_lastPosition.timestamp());
- file.commit();
- }
-#endif
-}
-
-void QGeoPositionInfoSourceGeoclue2::createClient()
-{
- const QDBusPendingReply<QDBusObjectPath> reply = m_manager.GetClient();
- const auto watcher = new QDBusPendingCallWatcher(reply, this);
- connect(watcher, &QDBusPendingCallWatcher::finished,
- [this](QDBusPendingCallWatcher *watcher) {
- const QScopedPointer<QDBusPendingCallWatcher, QScopedPointerDeleteLater>
- scopedWatcher(watcher);
- const QDBusPendingReply<QDBusObjectPath> reply = *scopedWatcher;
- if (reply.isError()) {
- const auto error = reply.error();
- qCWarning(lcPositioningGeoclue2) << "Unable to obtain the client patch:"
- << error.name() + error.message();
- setError(AccessError);
- } else {
- const QString clientPath = reply.value().path();
- qCDebug(lcPositioningGeoclue2) << "Client path is:"
- << clientPath;
- delete m_client;
- m_client = new OrgFreedesktopGeoClue2ClientInterface(
- QLatin1String(GEOCLUE2_SERVICE_NAME),
- clientPath,
- QDBusConnection::systemBus(),
- this);
- if (!m_client->isValid()) {
- const auto error = m_client->lastError();
- qCCritical(lcPositioningGeoclue2) << "Unable to create the client object:"
- << error.name() << error.message();
- setError(AccessError);
- delete m_client;
- } else {
- connect(m_client.data(), &OrgFreedesktopGeoClue2ClientInterface::LocationUpdated,
- this, &QGeoPositionInfoSourceGeoclue2::handleNewLocation);
-
- if (configureClient())
- startClient();
- }
- }
- });
-}
-
-void QGeoPositionInfoSourceGeoclue2::startClient()
-{
- // only start the client if someone asked for it already
- if (!m_running && !m_requestTimer->isActive())
- return;
-
- if (!m_client) {
- createClient();
- return;
- }
-
- const QDBusPendingReply<> reply = m_client->Start();
- const auto watcher = new QDBusPendingCallWatcher(reply, this);
- connect(watcher, &QDBusPendingCallWatcher::finished,
- [this](QDBusPendingCallWatcher *watcher) {
- const QScopedPointer<QDBusPendingCallWatcher, QScopedPointerDeleteLater>
- scopedWatcher(watcher);
- const QDBusPendingReply<> reply = *scopedWatcher;
- if (reply.isError()) {
- const auto error = reply.error();
- qCCritical(lcPositioningGeoclue2) << "Unable to start the client:"
- << error.name() << error.message();
- setError(AccessError);
- delete m_client;
- } else {
- qCDebug(lcPositioningGeoclue2) << "Client successfully started";
-
- const QDBusObjectPath location = m_client->location();
- const QString path = location.path();
- if (path.isEmpty() || path == QLatin1String("/"))
- return;
-
- handleNewLocation({}, location);
- }
- });
-}
-
-void QGeoPositionInfoSourceGeoclue2::stopClient()
-{
- // Only stop client if updates are no longer wanted.
- if (m_requestTimer->isActive() || m_running || !m_client)
- return;
-
- const QDBusPendingReply<> reply = m_client->Stop();
- const auto watcher = new QDBusPendingCallWatcher(reply, this);
- connect(watcher, &QDBusPendingCallWatcher::finished,
- [this](QDBusPendingCallWatcher *watcher) {
- const QScopedPointer<QDBusPendingCallWatcher, QScopedPointerDeleteLater>
- scopedWatcher(watcher);
- const QDBusPendingReply<> reply = *scopedWatcher;
- if (reply.isError()) {
- const auto error = reply.error();
- qCCritical(lcPositioningGeoclue2) << "Unable to stop the client:"
- << error.name() << error.message();
- setError(AccessError);
- } else {
- qCDebug(lcPositioningGeoclue2) << "Client successfully stopped";
- }
- delete m_client;
- });
-}
-
-bool QGeoPositionInfoSourceGeoclue2::configureClient()
-{
- if (!m_client)
- return false;
-
- 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(m_desktopId);
-
- const auto msecs = updateInterval();
- const uint secs = qMax(uint(msecs), 0u) / 1000u;
- m_client->setTimeThreshold(secs);
-
- const auto methods = preferredPositioningMethods();
- switch (methods) {
- case SatellitePositioningMethods:
- m_client->setRequestedAccuracyLevel(GCLUE_ACCURACY_LEVEL_EXACT);
- break;
- case NonSatellitePositioningMethods:
- m_client->setRequestedAccuracyLevel(GCLUE_ACCURACY_LEVEL_STREET);
- break;
- case AllPositioningMethods:
- m_client->setRequestedAccuracyLevel(GCLUE_ACCURACY_LEVEL_EXACT);
- break;
- default:
- m_client->setRequestedAccuracyLevel(GCLUE_ACCURACY_LEVEL_NONE);
- break;
- }
-
- return true;
-}
-
-void QGeoPositionInfoSourceGeoclue2::requestUpdateTimeout()
-{
- qCDebug(lcPositioningGeoclue2) << "Request update timeout occurred";
-
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
-
- stopClient();
-}
-
-void QGeoPositionInfoSourceGeoclue2::handleNewLocation(const QDBusObjectPath &oldLocation,
- const QDBusObjectPath &newLocation)
-{
- if (m_requestTimer->isActive())
- m_requestTimer->stop();
-
- const auto oldPath = oldLocation.path();
- const auto newPath = newLocation.path();
- qCDebug(lcPositioningGeoclue2) << "Old location object path:" << oldPath;
- qCDebug(lcPositioningGeoclue2) << "New location object path:" << newPath;
-
- OrgFreedesktopGeoClue2LocationInterface location(
- QLatin1String(GEOCLUE2_SERVICE_NAME),
- newPath,
- QDBusConnection::systemBus(),
- this);
- if (!location.isValid()) {
- const auto error = location.lastError();
- qCCritical(lcPositioningGeoclue2) << "Unable to create the location object:"
- << error.name() << error.message();
- } else {
- QGeoCoordinate coordinate(location.latitude(),
- location.longitude());
- if (const auto altitude = location.altitude() > std::numeric_limits<double>::min())
- coordinate.setAltitude(altitude);
-
- const Timestamp ts = location.timestamp();
- if (ts.m_seconds == 0 && ts.m_microseconds == 0) {
- const auto dt = QDateTime::currentDateTime();
- m_lastPosition = QGeoPositionInfo(coordinate, dt);
- } else {
- auto dt = QDateTime::fromSecsSinceEpoch(qint64(ts.m_seconds));
- dt = dt.addMSecs(ts.m_microseconds / 1000);
- m_lastPosition = QGeoPositionInfo(coordinate, dt);
- }
-
- const auto accuracy = location.accuracy();
- // We assume that an accuracy as 0.0 means that it comes from a sattelite.
- m_lastPositionFromSatellite = qFuzzyCompare(accuracy, 0.0);
-
- m_lastPosition.setAttribute(QGeoPositionInfo::HorizontalAccuracy, accuracy);
- if (const auto speed = location.speed() >= 0.0)
- m_lastPosition.setAttribute(QGeoPositionInfo::GroundSpeed, speed);
- if (const auto heading = location.heading() >= 0.0)
- m_lastPosition.setAttribute(QGeoPositionInfo::Direction, heading);
-
- emit positionUpdated(m_lastPosition);
- qCDebug(lcPositioningGeoclue2) << "New position:" << m_lastPosition;
- }
-
- 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
deleted file mode 100644
index f5ec2b06..00000000
--- a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCE_GEOCLUE2_P_H
-#define QGEOPOSITIONINFOSOURCE_GEOCLUE2_P_H
-
-#include <QtPositioning/QGeoPositionInfoSource>
-#include <QtCore/QPointer>
-#include <manager_interface.h>
-
-class OrgFreedesktopGeoClue2ClientInterface;
-
-QT_BEGIN_NAMESPACE
-class QDBusObjectPath;
-class QTimer;
-
-class QGeoPositionInfoSourceGeoclue2 : public QGeoPositionInfoSource
-{
- Q_OBJECT
-
-public:
- explicit QGeoPositionInfoSourceGeoclue2(const QVariantMap &parameters,
- QObject *parent = nullptr);
- ~QGeoPositionInfoSourceGeoclue2();
-
- // From QGeoPositionInfoSource
- void setUpdateInterval(int msec) override;
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
- PositioningMethods supportedPositioningMethods() const override;
- void setPreferredPositioningMethods(PositioningMethods methods) override;
- int minimumUpdateInterval() const override;
-
- Error error() const override;
-
- void startUpdates() override;
- void stopUpdates() override;
- void requestUpdate(int timeout = 5000) override;
-
-private:
- void setError(QGeoPositionInfoSource::Error error);
- void restoreLastPosition();
- void saveLastPosition();
- void createClient();
- bool configureClient();
- void startClient();
- void stopClient();
- void requestUpdateTimeout();
- void handleNewLocation(const QDBusObjectPath &oldLocation,
- const QDBusObjectPath &newLocation);
- void parseParameters(const QVariantMap &parameters);
-
- QTimer *m_requestTimer = nullptr;
- OrgFreedesktopGeoClue2ManagerInterface m_manager;
- QPointer<OrgFreedesktopGeoClue2ClientInterface> m_client;
- bool m_running = false;
- bool m_lastPositionFromSatellite = false;
- QGeoPositionInfoSource::Error m_error = NoError;
- QGeoPositionInfo m_lastPosition;
- QString m_desktopId;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCE_GEOCLUE2_P_H
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp b/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp
deleted file mode 100644
index 68161f41..00000000
--- a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_geoclue2_p.h"
-#include "qgeopositioninfosourcefactory_geoclue2.h"
-
-#include <QtCore/QLoggingCategory>
-
-Q_LOGGING_CATEGORY(lcPositioningGeoclue2, "qt.positioning.geoclue2")
-
-QT_BEGIN_NAMESPACE
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryGeoclue2::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- return new QGeoPositionInfoSourceGeoclue2(parameters, parent);
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryGeoclue2::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryGeoclue2::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.h b/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.h
deleted file mode 100644
index 1cd72fff..00000000
--- a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_GEOCLUE2_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_GEOCLUE2_H
-
-#include <QtCore/QObject>
-#include <QtPositioning/QGeoPositionInfoSourceFactory>
-
-QT_BEGIN_NAMESPACE
-
-/*
- Qt Positioning plugin for Geoclue. This plugin supports Geoclue version 2.x.
-*/
-class QGeoPositionInfoSourceFactoryGeoclue2 : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
-
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
-
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCEFACTORY_GEOCLUE2_H
diff --git a/src/plugins/position/gypsy/CMakeLists.txt b/src/plugins/position/gypsy/CMakeLists.txt
deleted file mode 100644
index 1791bdcc..00000000
--- a/src/plugins/position/gypsy/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-# Generated from gypsy.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryGypsy Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryGypsyPlugin
- OUTPUT_NAME qtposition_gypsy
- CLASS_NAME QGeoPositionInfoSourceFactoryGypsy
- PLUGIN_TYPE position
- SOURCES
- qgeopositioninfosourcefactory_gypsy.cpp qgeopositioninfosourcefactory_gypsy.h
- qgeosatelliteinfosource_gypsy.cpp qgeosatelliteinfosource_gypsy_p.h
-# special case begin
- LIBRARIES
- Gypsy::Gypsy
- Gconf::Gconf
- Qt::Core
- Qt::Positioning
-# special case end
-)
-
-#### Keys ignored in scope 1:.:.:gypsy.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/gypsy/gypsy.pro b/src/plugins/position/gypsy/gypsy.pro
deleted file mode 100644
index c7b74325..00000000
--- a/src/plugins/position/gypsy/gypsy.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGET = qtposition_gypsy
-
-QT = core positioning-private
-
-HEADERS += \
- qgeosatelliteinfosource_gypsy_p.h \
- qgeopositioninfosourcefactory_gypsy.h
-
-SOURCES += \
- qgeosatelliteinfosource_gypsy.cpp \
- qgeopositioninfosourcefactory_gypsy.cpp
-
-QMAKE_USE_PRIVATE += gypsy
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryGypsy
-load(qt_plugin)
diff --git a/src/plugins/position/gypsy/plugin.json b/src/plugins/position/gypsy/plugin.json
deleted file mode 100644
index 9cef03f8..00000000
--- a/src/plugins/position/gypsy/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["gypsy"],
- "Provider": "gypsy",
- "Position": false,
- "Satellite": true,
- "Monitor" : false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp b/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp
deleted file mode 100644
index be7634cd..00000000
--- a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosourcefactory_gypsy.h"
-#include "qgeosatelliteinfosource_gypsy_p.h"
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryGypsy::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryGypsy::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- QGeoSatelliteInfoSourceGypsy *src = new QGeoSatelliteInfoSourceGypsy(parent);
- if (src->init(parameters) < 0) {
- delete src;
- src = nullptr;
- }
- return src;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryGypsy::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
diff --git a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h b/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h
deleted file mode 100644
index 495301fd..00000000
--- a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_GYPSY_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_GYPSY_H
-
-#include <QObject>
-#include <qgeopositioninfosourcefactory.h>
-
-class QGeoPositionInfoSourceFactoryGypsy : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-#endif
diff --git a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp
deleted file mode 100644
index b7f91131..00000000
--- a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp
+++ /dev/null
@@ -1,442 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeosatelliteinfosource_gypsy_p.h"
-
-#ifdef Q_LOCATION_GYPSY_DEBUG
-#include <QDebug>
-#endif
-#include <QFile>
-#include <QVariantMap>
-
-QT_BEGIN_NAMESPACE
-
-#define UPDATE_TIMEOUT_COLD_START 120000
-
-static const auto deviceNameParameter = "deviceName";
-static const auto gconfKeyParameter = "gconfKey";
-static const auto defaultGconfKey = "/apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice";
-
-// Callback function for 'satellites-changed' -signal
-static void satellites_changed (GypsySatellite *satellite,
- GPtrArray *satellites,
- gpointer userdata)
-{
-#ifdef Q_LOCATION_GYPSY_DEBUG
- qDebug() << "QGeoSatelliteInfoSourceGypsy Gypsy satellites-changed -signal received.";
-#endif
- ((QGeoSatelliteInfoSourceGypsy *)userdata)->satellitesChanged(satellite, satellites);
-}
-
-SatelliteGypsyEngine::SatelliteGypsyEngine(QGeoSatelliteInfoSource *parent) :
- m_owner(parent)
-{
-}
-SatelliteGypsyEngine::~SatelliteGypsyEngine()
-{
-}
-
-// Glib symbols
-gulong SatelliteGypsyEngine::eng_g_signal_connect(gpointer instance,
- const gchar *detailed_signal,
- GCallback c_handler,
- gpointer data)
-{
- return ::g_signal_connect(instance, detailed_signal, c_handler, data);
-}
-guint SatelliteGypsyEngine::eng_g_signal_handlers_disconnect_by_func (gpointer instance,
- gpointer func,
- gpointer data)
-{
- return ::g_signal_handlers_disconnect_by_func(instance, func, data);
-}
-
-void SatelliteGypsyEngine::eng_g_free(gpointer mem)
-{
- return ::g_free(mem);
-}
-// Gypsy symbols
-GypsyControl *SatelliteGypsyEngine::eng_gypsy_control_get_default (void)
-{
- return ::gypsy_control_get_default();
-}
-char *SatelliteGypsyEngine::eng_gypsy_control_create (GypsyControl *control, const char *device_name, GError **error)
-{
- return ::gypsy_control_create(control, device_name, error);
-}
-GypsyDevice *SatelliteGypsyEngine::eng_gypsy_device_new (const char *object_path)
-{
- return ::gypsy_device_new(object_path);
-}
-GypsySatellite *SatelliteGypsyEngine::eng_gypsy_satellite_new (const char *object_path)
-{
- return ::gypsy_satellite_new (object_path);
-}
-gboolean SatelliteGypsyEngine::eng_gypsy_device_start (GypsyDevice *device, GError **error)
-{
- return ::gypsy_device_start(device, error);
-}
-gboolean SatelliteGypsyEngine::eng_gypsy_device_stop (GypsyDevice *device, GError **error)
-{
- // Unfortunately this cannot be done; calling this will stop the GPS device
- // (basically makes gypsy-daemon unusable for anyone), regardless of applications
- // using it (see bug http://bugs.meego.com/show_bug.cgi?id=11707).
- Q_UNUSED(device);
- Q_UNUSED(error);
- return true;
- //return ::gypsy_device_stop (device, error);
-}
-GypsyDeviceFixStatus SatelliteGypsyEngine::eng_gypsy_device_get_fix_status (GypsyDevice *device, GError **error)
-{
- return ::gypsy_device_get_fix_status (device, error);
-}
-GPtrArray *SatelliteGypsyEngine::eng_gypsy_satellite_get_satellites (GypsySatellite *satellite, GError **error)
-{
- return ::gypsy_satellite_get_satellites (satellite, error);
-}
-void SatelliteGypsyEngine::eng_gypsy_satellite_free_satellite_array (GPtrArray *satellites)
-{
- return ::gypsy_satellite_free_satellite_array(satellites);
-}
-// GConf symbols (mockability due to X11 requirement)
-GConfClient *SatelliteGypsyEngine::eng_gconf_client_get_default(void)
-{
- return ::gconf_client_get_default();
-}
-gchar *SatelliteGypsyEngine::eng_gconf_client_get_string(GConfClient *client, const gchar *key, GError** err)
-{
- return ::gconf_client_get_string(client, key, err);
-}
-
-QGeoSatelliteInfoSourceGypsy::QGeoSatelliteInfoSourceGypsy(QObject *parent)
- : QGeoSatelliteInfoSource(parent), m_engine(0), m_satellite(0), m_device(0),
- m_requestTimer(this), m_updatesOngoing(false), m_requestOngoing(false)
-{
- m_requestTimer.setSingleShot(true);
- QObject::connect(&m_requestTimer, SIGNAL(timeout()), this, SLOT(requestUpdateTimeout()));
-}
-
-void QGeoSatelliteInfoSourceGypsy::createEngine()
-{
- delete m_engine;
- m_engine = new SatelliteGypsyEngine(this);
-}
-
-QGeoSatelliteInfoSourceGypsy::~QGeoSatelliteInfoSourceGypsy()
-{
- GError *error = NULL;
- if (m_device) {
- m_engine->eng_gypsy_device_stop (m_device, &error);
- g_object_unref(m_device);
- }
- if (m_satellite)
- g_object_unref(m_satellite);
- if (m_control)
- g_object_unref(m_control);
- if (error)
- g_error_free(error);
- delete m_engine;
-}
-
-static QGeoSatelliteInfo::SatelliteSystem idToSystem(int prn)
-{
- if (prn >= 1 && prn <= 32)
- return QGeoSatelliteInfo::GPS;
- else if (prn >= 65 && prn <= 96)
- return QGeoSatelliteInfo::GLONASS;
- else if (prn >= 193 && prn <= 200)
- return QGeoSatelliteInfo::QZSS;
- else if ((prn >= 201 && prn <= 235) || (prn >= 401 && prn <= 437))
- return QGeoSatelliteInfo::BEIDOU;
- else if (prn >= 301 && prn <= 336)
- return QGeoSatelliteInfo::GALILEO;
- return QGeoSatelliteInfo::Undefined;
-}
-
-void QGeoSatelliteInfoSourceGypsy::satellitesChanged(GypsySatellite *satellite,
- GPtrArray *satellites)
-{
- if (!satellite || !satellites)
- return;
- // We have satellite data and assume it is valid.
- // If a single updateRequest was active, send signals right away.
- // If a periodic timer was running (meaning that the client wishes
- // to have updates at defined intervals), store the data for later sending.
- QList<QGeoSatelliteInfo> lastSatellitesInView;
- QList<QGeoSatelliteInfo> lastSatellitesInUse;
-
- unsigned int i;
- for (i = 0; i < satellites->len; i++) {
- GypsySatelliteDetails *details = (GypsySatelliteDetails *)satellites->pdata[i];
- QGeoSatelliteInfo info;
- info.setSatelliteIdentifier(details->satellite_id);
- info.setSatelliteSystem(idToSystem(details->satellite_id));
- info.setAttribute(QGeoSatelliteInfo::Elevation, details->elevation);
- info.setAttribute(QGeoSatelliteInfo::Azimuth, details->azimuth);
- info.setSignalStrength(details->snr);
- if (details->in_use)
- lastSatellitesInUse.append(info);
- lastSatellitesInView.append(info);
- }
- bool sendUpdates(false);
- // If a single updateRequest() has been issued:
- if (m_requestOngoing) {
- sendUpdates = true;
- m_requestTimer.stop();
- m_requestOngoing = false;
- // If there is no regular updates ongoing, disconnect now.
- if (!m_updatesOngoing) {
- m_engine->eng_g_signal_handlers_disconnect_by_func(G_OBJECT(m_satellite), (void *)satellites_changed, this);
- }
- }
- // If regular updates are to be delivered as they come:
- if (m_updatesOngoing)
- sendUpdates = true;
-
- if (sendUpdates) {
- emit satellitesInUseUpdated(lastSatellitesInUse);
- emit satellitesInViewUpdated(lastSatellitesInView);
- }
-}
-
-QString QGeoSatelliteInfoSourceGypsy::extractDeviceNameFromParameters(const QVariantMap &parameters) const
-{
- // The logic is as follows:
- // 1. If the deviceNameParameter is specified, its value is used to get the
- // device name.
- // 2. If the gconfKeyParameter is specified, its value is used as a key to
- // extract the device name from GConf.
- // 3. If nothing is specified, defaultGconfKey is used as a key to extract
- // the device name from GConf.
- if (parameters.contains(deviceNameParameter))
- return parameters.value(deviceNameParameter).toString();
-
- QString gconfKey = parameters.value(gconfKeyParameter).toString();
- if (gconfKey.isEmpty())
- gconfKey = defaultGconfKey;
-
- if (!m_engine)
- return QString();
-
- GConfClient *client = m_engine->eng_gconf_client_get_default();
- if (!client)
- return QString();
-
- gchar *device_name = m_engine->eng_gconf_client_get_string(client,
- gconfKey.toLatin1().constData(),
- nullptr);
- g_object_unref(client);
-
- const QString deviceName = QString::fromLatin1(device_name);
- m_engine->eng_g_free(device_name);
-
- return deviceName;
-}
-
-int QGeoSatelliteInfoSourceGypsy::init(const QVariantMap parameters)
-{
- GError *error = NULL;
- char *path;
-
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init (); // this function was deprecated in glib 2.36
-#endif
- createEngine();
-
- const QString deviceName = extractDeviceNameFromParameters(parameters);
-
- if (deviceName.isEmpty() ||
- (deviceName.trimmed().at(0) == '/' && !QFile::exists(deviceName.trimmed()))) {
- qWarning ("QGeoSatelliteInfoSourceGypsy Empty/nonexistent GPS device name detected.");
- qWarning("Use '%s' plugin parameter to specify device name directly", deviceNameParameter);
- qWarning("or use '%s' plugin parameter to specify a GConf key to extract the device name.",
- gconfKeyParameter);
- qWarning ("If the GConf key is used, the gconftool-2 tool can be used to set device name "
- "for the selected key, e.g. on terminal:");
- qWarning ("gconftool-2 -t string -s %s /dev/ttyUSB0", gconfKeyParameter);
- return -1;
- }
- m_control = m_engine->eng_gypsy_control_get_default();
- if (!m_control) {
- qWarning("QGeoSatelliteInfoSourceGypsy unable to create Gypsy control.");
- return -1;
- }
- // (path is the DBus path)
- path = m_engine->eng_gypsy_control_create(m_control, deviceName.toLatin1().constData(), &error);
- if (!path) {
- qWarning ("QGeoSatelliteInfoSourceGypsy error creating client.");
- if (error) {
- qWarning ("error message: %s", error->message);
- g_error_free (error);
- }
- return -1;
- }
- m_device = m_engine->eng_gypsy_device_new (path);
- m_satellite = m_engine->eng_gypsy_satellite_new (path);
- m_engine->eng_g_free(path);
- if (!m_device || !m_satellite) {
- qWarning ("QGeoSatelliteInfoSourceGypsy error creating satellite device.");
- qWarning ("Please check that the GPS device is specified correctly.");
- qWarning("Use '%s' plugin parameter to specify device name directly", deviceNameParameter);
- qWarning("or use '%s' plugin parameter to specify a GConf key to extract the device name.",
- gconfKeyParameter);
- qWarning ("If the GConf key is used, the gconftool-2 tool can be used to set device name "
- "for the selected key, e.g. on terminal:");
- qWarning ("gconftool-2 -t string -s %s /dev/ttyUSB0", gconfKeyParameter);
- if (m_device)
- g_object_unref(m_device);
- if (m_satellite)
- g_object_unref(m_satellite);
- return -1;
- }
- m_engine->eng_gypsy_device_start (m_device, &error);
- if (error) {
- qWarning ("QGeoSatelliteInfoSourceGypsy error starting device: %s ",
- error->message);
- g_error_free(error);
- g_object_unref(m_device);
- g_object_unref(m_satellite);
- return -1;
- }
- return 0;
-}
-
-int QGeoSatelliteInfoSourceGypsy::minimumUpdateInterval() const
-{
- return 1;
-}
-
-QGeoSatelliteInfoSource::Error QGeoSatelliteInfoSourceGypsy::error() const
-{
- return m_error;
-}
-
-void QGeoSatelliteInfoSourceGypsy::startUpdates()
-{
- if (m_updatesOngoing)
- return;
-
- m_error = QGeoSatelliteInfoSource::NoError;
-
- // If there is a request timer ongoing, we've connected to the signal already
- if (!m_requestTimer.isActive()) {
- m_engine->eng_g_signal_connect (m_satellite, "satellites-changed",
- G_CALLBACK (satellites_changed), this);
- }
- m_updatesOngoing = true;
-}
-
-void QGeoSatelliteInfoSourceGypsy::stopUpdates()
-{
- if (!m_updatesOngoing)
- return;
- m_updatesOngoing = false;
- // Disconnect only if there is no single update request ongoing. Once single update request
- // is completed and it notices that there is no active update ongoing, it will disconnect
- // the signal.
- if (!m_requestTimer.isActive())
- m_engine->eng_g_signal_handlers_disconnect_by_func(G_OBJECT(m_satellite), (void *)satellites_changed, this);
-}
-
-void QGeoSatelliteInfoSourceGypsy::requestUpdate(int timeout)
-{
- if (m_requestOngoing)
- return;
-
- m_error = QGeoSatelliteInfoSource::NoError;
-
- if (timeout < 0) {
- setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
- return;
- }
- m_requestOngoing = true;
- GError *error = 0;
- // If GPS has a fix a already, request current data.
- GypsyDeviceFixStatus fixStatus = m_engine->eng_gypsy_device_get_fix_status(m_device, &error);
- if (!error && (fixStatus != GYPSY_DEVICE_FIX_STATUS_INVALID &&
- fixStatus != GYPSY_DEVICE_FIX_STATUS_NONE)) {
-#ifdef Q_LOCATION_GYPSY_DEBUG
- qDebug() << "QGeoSatelliteInfoSourceGypsy fix available, requesting current satellite data";
-#endif
- GPtrArray *satelliteData = m_engine->eng_gypsy_satellite_get_satellites(m_satellite, &error);
- if (!error) {
- // The fix was available and we have satellite data to deliver right away.
- satellitesChanged(m_satellite, satelliteData);
- m_engine->eng_gypsy_satellite_free_satellite_array(satelliteData);
- return;
- }
- }
- // No fix is available. If updates are not ongoing already, start them.
- m_requestTimer.setInterval(timeout == 0? UPDATE_TIMEOUT_COLD_START: timeout);
- if (!m_updatesOngoing) {
- m_engine->eng_g_signal_connect (m_satellite, "satellites-changed",
- G_CALLBACK (satellites_changed), this);
- }
- m_requestTimer.start();
- if (error) {
-#ifdef Q_LOCATION_GYPSY_DEBUG
- qDebug() << "QGeoSatelliteInfoSourceGypsy error asking fix status or satellite data: " << error->message;
-#endif
- g_error_free(error);
- }
-}
-
-void QGeoSatelliteInfoSourceGypsy::requestUpdateTimeout()
-{
-#ifdef Q_LOCATION_GYPSY_DEBUG
- qDebug("QGeoSatelliteInfoSourceGypsy request update timeout occurred.");
-#endif
- // If we end up here, there has not been valid satellite update.
- // Emit timeout and disconnect from signal if regular updates are not
- // ongoing (as we were listening just for one single requestUpdate).
- if (!m_updatesOngoing) {
- m_engine->eng_g_signal_handlers_disconnect_by_func(G_OBJECT(m_satellite), (void *)satellites_changed, this);
- }
- m_requestOngoing = false;
- setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
-}
-
-void QGeoSatelliteInfoSourceGypsy::setError(QGeoSatelliteInfoSource::Error error)
-{
- m_error = error;
- if (m_error != QGeoSatelliteInfoSource::NoError)
- emit QGeoSatelliteInfoSource::errorOccurred(m_error);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h
deleted file mode 100644
index c9d1de71..00000000
--- a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOSATELLITEINFOSOURCE_GYPSY_H
-#define QGEOSATELLITEINFOSOURCE_GYPSY_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeosatelliteinfosource.h"
-#include "qgeosatelliteinfo.h"
-#include <gypsy/gypsy-satellite.h>
-#include <gypsy/gypsy-control.h>
-#include <gypsy/gypsy-device.h>
-#include <gconf/gconf-client.h>
-#include <QTimer>
-
-// #define Q_LOCATION_GYPSY_DEBUG
-
-QT_BEGIN_NAMESPACE
-
-// An engine that encapsulates all symbols we want
-// to be able to mock (for unit/autotest purposes).
-class SatelliteGypsyEngine
-{
-public:
- SatelliteGypsyEngine(QGeoSatelliteInfoSource *parent = 0);
- virtual ~SatelliteGypsyEngine();
- // Glib symbols
- virtual gulong eng_g_signal_connect(gpointer instance,
- const gchar *detailed_signal,
- GCallback c_handler,
- gpointer data);
- virtual guint eng_g_signal_handlers_disconnect_by_func(gpointer instance,
- gpointer func,
- gpointer data);
- virtual void eng_g_free(gpointer mem);
- // Gypsy symbols
- virtual GypsyControl *eng_gypsy_control_get_default (void);
- virtual char *eng_gypsy_control_create (GypsyControl *control, const char *device_name, GError **error);
- virtual GypsyDevice *eng_gypsy_device_new (const char *object_path);
- virtual GypsySatellite *eng_gypsy_satellite_new (const char *object_path);
- virtual gboolean eng_gypsy_device_start (GypsyDevice *device, GError **error);
- virtual gboolean eng_gypsy_device_stop (GypsyDevice *device, GError **error);
- virtual GypsyDeviceFixStatus eng_gypsy_device_get_fix_status (GypsyDevice *device, GError **error);
- virtual GPtrArray *eng_gypsy_satellite_get_satellites (GypsySatellite *satellite, GError **error);
- virtual void eng_gypsy_satellite_free_satellite_array (GPtrArray *satellites);
- // GConf symbols (mockability due to X11 requirement)
- virtual GConfClient *eng_gconf_client_get_default(void);
- virtual gchar *eng_gconf_client_get_string(GConfClient *client, const gchar *key, GError** err);
-protected:
- QGeoSatelliteInfoSource *m_owner;
-};
-
-class QGeoSatelliteInfoSourceGypsy : public QGeoSatelliteInfoSource
- {
- Q_OBJECT
-
-public:
- explicit QGeoSatelliteInfoSourceGypsy(QObject *parent = 0);
- ~QGeoSatelliteInfoSourceGypsy();
- int init(const QVariantMap parameters);
-
- int minimumUpdateInterval() const override;
- Error error() const override;
-
-public slots:
- virtual void startUpdates() override;
- void stopUpdates() override;
- void requestUpdate(int timeout = 5000) override;
- void satellitesChanged(GypsySatellite *satellite, GPtrArray *satellites);
-
-private slots:
- void requestUpdateTimeout();
-
-private:
- void setError(QGeoSatelliteInfoSource::Error error);
- QString extractDeviceNameFromParameters(const QVariantMap &parameters) const;
-
-protected:
- // Creates an engine which encapsulates all used symbols
- // that we want to be also able to mock.
- virtual void createEngine();
- SatelliteGypsyEngine *m_engine;
-
-private:
- Q_DISABLE_COPY(QGeoSatelliteInfoSourceGypsy)
- GypsySatellite *m_satellite;
- GypsyDevice *m_device;
- QTimer m_requestTimer;
- bool m_updatesOngoing;
- bool m_requestOngoing;
- QGeoSatelliteInfoSource::Error m_error = QGeoSatelliteInfoSource::NoError;
- GypsyControl *m_control = nullptr;
- };
-
-QT_END_NAMESPACE
-
-#endif // QGEOSATELLITEINFOSOURCE_GYPSY_H
diff --git a/src/plugins/position/nmea/CMakeLists.txt b/src/plugins/position/nmea/CMakeLists.txt
deleted file mode 100644
index 73c5a3b1..00000000
--- a/src/plugins/position/nmea/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# Generated from nmea.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryNmea Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryNmeaPlugin
- OUTPUT_NAME qtposition_nmea
- CLASS_NAME QGeoPositionInfoSourceFactoryNmea
- PLUGIN_TYPE position
- SOURCES
- qgeopositioninfosourcefactory_nmea.cpp qgeopositioninfosourcefactory_nmea.h
- qiopipe.cpp qiopipe_p.h
- LIBRARIES
- Qt::CorePrivate
- Qt::Positioning
- Qt::SerialPort
- Qt::Network
-)
-
-#### Keys ignored in scope 1:.:.:serialnmea.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/nmea/nmea.pro b/src/plugins/position/nmea/nmea.pro
deleted file mode 100644
index f52d8812..00000000
--- a/src/plugins/position/nmea/nmea.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qtposition_nmea
-
-QT = core-private positioning-private serialport
-
-HEADERS += \
- qgeopositioninfosourcefactory_nmea.h qiopipe_p.h
-
-SOURCES += \
- qgeopositioninfosourcefactory_nmea.cpp qiopipe.cpp
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryNmea
-load(qt_plugin)
diff --git a/src/plugins/position/nmea/plugin.json b/src/plugins/position/nmea/plugin.json
deleted file mode 100644
index 15d22f1f..00000000
--- a/src/plugins/position/nmea/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["nmea"],
- "Provider": "nmea",
- "Position": true,
- "Satellite": false,
- "Monitor" : false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.cpp b/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.cpp
deleted file mode 100644
index 15460062..00000000
--- a/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.cpp
+++ /dev/null
@@ -1,505 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosourcefactory_nmea.h"
-#include <QtPositioning/QNmeaPositionInfoSource>
-#include <QtPositioning/QNmeaSatelliteInfoSource>
-#include <QtSerialPort/QSerialPort>
-#include <QtSerialPort/QSerialPortInfo>
-#include <QtNetwork/QTcpSocket>
-#include <QLoggingCategory>
-#include <QSet>
-#include <QUrl>
-#include <QFile>
-#include <QSharedPointer>
-#include "qiopipe_p.h"
-
-Q_LOGGING_CATEGORY(lcNmea, "qt.positioning.nmea")
-
-QT_BEGIN_NAMESPACE
-
-static const auto sourceParameterName = QStringLiteral("nmea.source");
-static const auto socketScheme = QStringLiteral("socket:");
-static const auto serialScheme = QStringLiteral("serial:");
-
-// This class is used only for SerialPort devices, because we can't open the
-// same serial port twice.
-// In case of files and sockets it's easier to explicitly create a QIODevice for
-// each new instance of Nmea*InfoSource.
-// Also QFile can't be directly used with QIOPipe, because QFile is not a
-// sequential device.
-// TcpSocket could be used with QIOPipe, but it complicates error handling
-// dramatically, as we would need to somehow forward socket errors through
-// QIOPipes to the clients.
-class IODeviceContainer
-{
-public:
- IODeviceContainer() {}
- IODeviceContainer(IODeviceContainer const&) = delete;
- void operator=(IODeviceContainer const&) = delete;
-
- QSharedPointer<QIOPipe> serial(const QString &portName)
- {
- if (m_serialPorts.contains(portName)) {
- m_serialPorts[portName].refs++;
- QIOPipe *endPipe = new QIOPipe(m_serialPorts[portName].proxy);
- m_serialPorts[portName].proxy->addChildPipe(endPipe);
- return QSharedPointer<QIOPipe>(endPipe);
- }
- IODevice device;
- QSerialPort *port = new QSerialPort(portName);
- port->setBaudRate(4800);
- qCDebug(lcNmea) << "Opening serial port" << portName;
- if (!port->open(QIODevice::ReadOnly)) {
- qWarning("nmea: Failed to open %s", qPrintable(portName));
- delete port;
- return {};
- }
- qCDebug(lcNmea) << "Opened successfully";
- device.device = port;
- device.refs = 1;
- device.proxy = new QIOPipe(port, QIOPipe::ProxyPipe);
- m_serialPorts[portName] = device;
- QIOPipe *endPipe = new QIOPipe(device.proxy);
- device.proxy->addChildPipe(endPipe);
- return QSharedPointer<QIOPipe>(endPipe);
- }
-
- void releaseSerial(const QString &portName, QSharedPointer<QIOPipe> &pipe)
- {
- if (!m_serialPorts.contains(portName))
- return;
-
- pipe.clear(); // make sure to release the pipe returned by getSerial, or else, if there are still refs, data will be leaked through it
- IODevice &device = m_serialPorts[portName];
- if (device.refs > 1) {
- device.refs--;
- return;
- }
-
- IODevice taken = m_serialPorts.take(portName);
- taken.device->deleteLater();
- }
-
-private:
-
- struct IODevice {
- QIODevice *device = nullptr;
- QIOPipe *proxy = nullptr; // adding client pipes as children of proxy
- // allows to dynamically add clients to one device.
- unsigned int refs = 1;
- };
-
- QMap<QString, IODevice> m_serialPorts;
-};
-
-Q_GLOBAL_STATIC(IODeviceContainer, deviceContainer)
-
-// We use a string prefix to distinguish between the different data sources.
-// "socket:" means that we use a socket connection
-// "serial:" means that we use a serial port connection
-// "file:///", "qrc:///" and just plain strings mean that we try to use local
-// file.
-// Note: if we do not specify anything, or specify "serial:" without specifying
-// the port name, then we will try to search for a well-known serial port
-// device.
-class NmeaSource : public QNmeaPositionInfoSource
-{
- Q_OBJECT
-public:
- NmeaSource(QObject *parent, const QVariantMap &parameters);
- NmeaSource(QObject *parent, const QString &fileName);
- ~NmeaSource() override;
- bool isValid() const
- {
- return !m_dataSource.isNull() || !m_fileSource.isNull() || !m_socket.isNull();
- }
-
-private slots:
- void onSocketError(QAbstractSocket::SocketError error);
-
-private:
- void parseSourceParameter(const QString &source);
- void addSerialDevice(const QString &requestedPort);
- void setFileName(const QString &fileName);
- void connectSocket(const QString &source);
-
- QSharedPointer<QIOPipe> m_dataSource;
- QScopedPointer<QFile> m_fileSource;
- QScopedPointer<QTcpSocket> m_socket;
- QString m_sourceName;
-};
-
-NmeaSource::NmeaSource(QObject *parent, const QVariantMap &parameters)
- : QNmeaPositionInfoSource(RealTimeMode, parent)
-{
- const QString source = parameters.value(sourceParameterName).toString();
- parseSourceParameter(source);
-}
-
-NmeaSource::NmeaSource(QObject *parent, const QString &fileName)
- : QNmeaPositionInfoSource(SimulationMode, parent)
-{
- setFileName(fileName);
-}
-
-NmeaSource::~NmeaSource()
-{
- deviceContainer->releaseSerial(m_sourceName, m_dataSource);
-}
-
-void NmeaSource::onSocketError(QAbstractSocket::SocketError error)
-{
- m_socket->close();
-
- switch (error) {
- case QAbstractSocket::UnknownSocketError:
- setError(QGeoPositionInfoSource::UnknownSourceError);
- break;
- case QAbstractSocket::SocketAccessError:
- setError(QGeoPositionInfoSource::AccessError);
- break;
- case QAbstractSocket::RemoteHostClosedError:
- setError(QGeoPositionInfoSource::ClosedError);
- break;
- default:
- qWarning() << "Connection failed! QAbstractSocket::SocketError" << error;
- // TODO - introduce new type of error. TransportError?
- setError(QGeoPositionInfoSource::UnknownSourceError);
- break;
- }
-}
-
-void NmeaSource::parseSourceParameter(const QString &source)
-{
- if (source.startsWith(socketScheme)) {
- // This is a socket
- connectSocket(source);
- } else {
- // Last chance - this can be serial device.
- // Note: File is handled in a separate case.
- addSerialDevice(source);
- }
-}
-
-static QString tryFindSerialDevice(const QString &requestedPort)
-{
- QString portName;
- if (requestedPort.isEmpty()) {
- const QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
- qCDebug(lcNmea) << "Found" << ports.count() << "serial ports";
- if (ports.isEmpty()) {
- qWarning("nmea: No serial ports found");
- return portName;
- }
-
- // Try to find a well-known device.
- QSet<int> supportedDevices;
- supportedDevices << 0x67b; // GlobalSat (BU-353S4 and probably others)
- supportedDevices << 0xe8d; // Qstarz MTK II
- for (const QSerialPortInfo& port : ports) {
- if (port.hasVendorIdentifier() && supportedDevices.contains(port.vendorIdentifier())) {
- portName = port.portName();
- break;
- }
- }
-
- if (portName.isEmpty()) {
- qWarning("nmea: No known GPS device found.");
- }
- } else {
- portName = requestedPort;
- if (portName.startsWith(serialScheme))
- portName.remove(0, 7);
- }
- return portName;
-}
-
-void NmeaSource::addSerialDevice(const QString &requestedPort)
-{
- m_sourceName = tryFindSerialDevice(requestedPort);
- if (m_sourceName.isEmpty())
- return;
-
- m_dataSource = deviceContainer->serial(m_sourceName);
- if (!m_dataSource)
- return;
-
- setDevice(m_dataSource.data());
-}
-
-void NmeaSource::setFileName(const QString &fileName)
-{
- m_sourceName = fileName;
-
- m_fileSource.reset(new QFile(fileName));
- qCDebug(lcNmea) << "Opening file" << fileName;
- if (!m_fileSource->open(QIODevice::ReadOnly)) {
- qWarning("nmea: failed to open file %s", qPrintable(fileName));
- m_fileSource.reset();
- }
-
- if (!m_fileSource)
- return;
-
- qCDebug(lcNmea) << "Opened successfully";
-
- setDevice(m_fileSource.data());
-}
-
-void NmeaSource::connectSocket(const QString &source)
-{
- const QUrl url(source);
- const QString host = url.host();
- const int port = url.port();
- if (!host.isEmpty() && (port > 0)) {
- m_socket.reset(new QTcpSocket);
- // no need to explicitly connect to connected() signal
- connect(m_socket.get(), &QTcpSocket::errorOccurred, this, &NmeaSource::onSocketError);
- m_socket->connectToHost(host, port, QTcpSocket::ReadOnly);
- m_sourceName = source;
-
- setDevice(m_socket.data());
- } else {
- qWarning("nmea: incorrect socket parameters %s:%d", qPrintable(host), port);
- }
-}
-
-class NmeaSatelliteSource : public QNmeaSatelliteInfoSource
-{
- Q_OBJECT
-public:
- NmeaSatelliteSource(QObject *parent, const QVariantMap &parameters);
- NmeaSatelliteSource(QObject *parent, const QString &fileName, const QVariantMap &parameters);
- ~NmeaSatelliteSource();
-
- bool isValid() const { return !m_port.isNull() || !m_file.isNull() || !m_socket.isNull(); }
-
-private slots:
- void onSocketError(QAbstractSocket::SocketError error);
-
-private:
- void parseRealtimeSource(const QString &source);
- void parseSimulationSource(const QString &localFileName);
-
- QSharedPointer<QIOPipe> m_port;
- QScopedPointer<QFile> m_file;
- QScopedPointer<QTcpSocket> m_socket;
- QString m_sourceName;
-};
-
-NmeaSatelliteSource::NmeaSatelliteSource(QObject *parent, const QVariantMap &parameters)
- : QNmeaSatelliteInfoSource(QNmeaSatelliteInfoSource::UpdateMode::RealTimeMode, parent)
-{
- const QString source = parameters.value(sourceParameterName).toString();
- parseRealtimeSource(source);
-}
-
-// We can use a QNmeaSatelliteInfoSource::SimulationUpdateInterval parameter to
-// set the file read frequency in simulation mode. We use setBackendProperty()
-// for it. The value can't be smaller than minimumUpdateInterval().
-// This check is done on the QNmeaSatelliteInfoSource level
-NmeaSatelliteSource::NmeaSatelliteSource(QObject *parent, const QString &fileName,
- const QVariantMap &parameters)
- : QNmeaSatelliteInfoSource(QNmeaSatelliteInfoSource::UpdateMode::SimulationMode, parent)
-{
- bool ok = false;
- const int interval =
- parameters.value(QNmeaSatelliteInfoSource::SimulationUpdateInterval).toInt(&ok);
- if (ok)
- setBackendProperty(QNmeaSatelliteInfoSource::SimulationUpdateInterval, interval);
- parseSimulationSource(fileName);
-}
-
-NmeaSatelliteSource::~NmeaSatelliteSource()
-{
- deviceContainer->releaseSerial(m_sourceName, m_port);
-}
-
-void NmeaSatelliteSource::onSocketError(QAbstractSocket::SocketError error)
-{
- m_socket->close();
-
- switch (error) {
- case QAbstractSocket::UnknownSocketError:
- setError(QGeoSatelliteInfoSource::UnknownSourceError);
- break;
- case QAbstractSocket::SocketAccessError:
- setError(QGeoSatelliteInfoSource::AccessError);
- break;
- case QAbstractSocket::RemoteHostClosedError:
- setError(QGeoSatelliteInfoSource::ClosedError);
- break;
- default:
- qWarning() << "Connection failed! QAbstractSocket::SocketError" << error;
- // TODO - introduce new type of error. TransportError?
- setError(QGeoSatelliteInfoSource::UnknownSourceError);
- break;
- }
-}
-
-void NmeaSatelliteSource::parseRealtimeSource(const QString &source)
-{
- if (source.startsWith(socketScheme)) {
- // This is a socket.
- const QUrl url(source);
- const QString host = url.host();
- const int port = url.port();
- if (!host.isEmpty() && (port > 0)) {
- m_socket.reset(new QTcpSocket);
- // no need to explicitly connect to connected() signal
- connect(m_socket.get(), &QTcpSocket::errorOccurred,
- this, &NmeaSatelliteSource::onSocketError);
- m_socket->connectToHost(host, port, QTcpSocket::ReadOnly);
- m_sourceName = source;
-
- setDevice(m_socket.data());
- } else {
- qWarning("nmea: incorrect socket parameters %s:%d", qPrintable(host), port);
- }
- } else {
- // Last chance - this can be serial device.
- m_sourceName = tryFindSerialDevice(source);
- if (m_sourceName.isEmpty())
- return;
-
- m_port = deviceContainer->serial(m_sourceName);
- if (!m_port)
- return;
-
- setDevice(m_port.data());
- }
-}
-
-void NmeaSatelliteSource::parseSimulationSource(const QString &localFileName)
-{
- // This is a text file.
- m_sourceName = localFileName;
-
- qCDebug(lcNmea) << "Opening file" << localFileName;
- m_file.reset(new QFile(localFileName));
- if (!m_file->open(QIODevice::ReadOnly)) {
- qWarning("nmea: failed to open file %s", qPrintable(localFileName));
- m_file.reset();
- return;
- }
- qCDebug(lcNmea) << "Opened successfully";
-
- setDevice(m_file.data());
-}
-
-/*!
- \internal
- Returns a local file name if \a source represents it.
- The returned value can be different from \a source, as the method tries to
- modify the path
-*/
-static QString checkSourceIsFile(const QString &source)
-{
- if (source.isEmpty())
- return QString();
-
- QString localFileName = source;
-
- if (!QFile::exists(localFileName)) {
- if (localFileName.startsWith(QStringLiteral("qrc:///")))
- localFileName.remove(0, 7);
- else if (localFileName.startsWith(QStringLiteral("file:///")))
- localFileName.remove(0, 7);
- else if (localFileName.startsWith(QStringLiteral("qrc:/")))
- localFileName.remove(0, 5);
-
- if (!QFile::exists(localFileName) && localFileName.startsWith(QLatin1Char('/')))
- localFileName.remove(0, 1);
- }
- if (!QFile::exists(localFileName))
- localFileName.prepend(QLatin1Char(':'));
-
- const bool isLocalFile = QFile::exists(localFileName);
- return isLocalFile ? localFileName : QString();
-}
-
-/*!
- \internal
- Returns a local file name if file exists, or an empty string otherwise
-*/
-static QString extractLocalFileName(const QVariantMap &parameters)
-{
- QString localFileName = parameters.value(sourceParameterName).toString();
- return checkSourceIsFile(localFileName);
-}
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryNmea::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- std::unique_ptr<NmeaSource> src = nullptr;
-
- const QString localFileName = extractLocalFileName(parameters);
- if (localFileName.isEmpty())
- src = std::make_unique<NmeaSource>(parent, parameters); // use RealTimeMode
- else
- src = std::make_unique<NmeaSource>(parent, localFileName); // use SimulationMode
-
- return (src && src->isValid()) ? src.release() : nullptr;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryNmea::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- std::unique_ptr<NmeaSatelliteSource> src = nullptr;
-
- const QString localFileName = extractLocalFileName(parameters);
- if (localFileName.isEmpty()) {
- // use RealTimeMode
- src = std::make_unique<NmeaSatelliteSource>(parent, parameters);
- } else {
- // use SimulationMode
- src = std::make_unique<NmeaSatelliteSource>(parent, localFileName, parameters);
- }
- return (src && src->isValid()) ? src.release() : nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryNmea::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent);
- Q_UNUSED(parameters);
- return nullptr;
-}
-
-QT_END_NAMESPACE
-
-#include "qgeopositioninfosourcefactory_nmea.moc"
diff --git a/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.h b/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.h
deleted file mode 100644
index d7ac98aa..00000000
--- a/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_NMEA_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_NMEA_H
-
-#include <QObject>
-#include <QtPositioning/QGeoPositionInfoSourceFactory>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourceFactoryNmea : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/position/nmea/qiopipe.cpp b/src/plugins/position/nmea/qiopipe.cpp
deleted file mode 100644
index 75cd923c..00000000
--- a/src/plugins/position/nmea/qiopipe.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qiopipe_p.h"
-#include <QtCore/qmetaobject.h>
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*
- proxying means do *not* emit readyRead, and instead pump data
- into child pipes directly in a zero-copy fashion.
-*/
-QIOPipePrivate::QIOPipePrivate(QIODevice *iodevice, bool proxying)
- : m_proxying(proxying), source(iodevice)
-{
-}
-
-QIOPipePrivate::~QIOPipePrivate()
-{
-}
-
-void QIOPipePrivate::initialize()
-{
- const QIOPipe *parentPipe = qobject_cast<QIOPipe *>(source);
- if (parentPipe && parentPipe->d_func()->m_proxying) // with proxying parent,
- return; // don't do anything
-
- // read available data, does not emit.
- readAvailableData();
- // connect readyRead to onReadyRead
- QObjectPrivate::connect(source, &QIODevice::readyRead, this, &QIOPipePrivate::_q_onReadyRead);
-}
-
-bool QIOPipePrivate::readAvailableData() {
- if (!source)
- return false;
- QByteArray ba = source->readAll();
- if (!ba.size())
- return false;
-
- pumpData(ba);
- return true;
-}
-
-void QIOPipePrivate::pumpData(const QByteArray &ba)
-{
- if (m_proxying) {
- QList<int> toRemove;
- for (int i = 0; i < childPipes.size(); ++i) {
- const QPointer<QIOPipe> &cp = childPipes.at(i);
- if (!cp) {
- toRemove.append(i);
- continue;
- }
- QIOPipePrivate *cpp = cp->d_func();
- cpp->pushData(ba);
- }
- for (int i = toRemove.size() - 1; i >= 0; --i) {
- childPipes.remove(i);
- }
- } else {
- for (int i = 0; i < readBuffers.size(); i++)
- readBuffers[i].append(ba);
- }
-}
-
-void QIOPipePrivate::pushData(const QByteArray &ba)
-{
- Q_Q(QIOPipe);
- if (!ba.size())
- return;
-
- pumpData(ba);
- if (!m_proxying)
- emit q->readyRead();
-}
-
-void QIOPipePrivate::_q_onReadyRead()
-{
- Q_Q(QIOPipe);
- if (readAvailableData() && !m_proxying)
- emit q->readyRead();
-}
-
-void QIOPipePrivate::addChildPipe(QIOPipe *childPipe)
-{
- if (childPipes.contains(childPipe))
- return;
- childPipes.append(childPipe);
-}
-
-void QIOPipePrivate::removeChildPipe(QIOPipe *childPipe)
-{
- childPipes.removeOne(childPipe);
-}
-
-QIOPipe::QIOPipe(QIODevice *parent, Mode mode)
- : QIODevice(*new QIOPipePrivate(parent, mode == ProxyPipe), parent)
-{
- this->d_func()->initialize();
- if (!parent->isOpen() && !parent->open(QIODevice::ReadOnly)) {
- qWarning() << "QIOPipe: Failed to open " << parent;
- return;
- }
- open(ReadOnly);
-}
-
-QIOPipe::~QIOPipe()
-{
-
-}
-
-bool QIOPipe::open(QIODevice::OpenMode mode)
-{
- if (isOpen())
- return true;
-
- static const OpenMode supportedOpenMode = ReadOnly; // Currently limit it to read only
- if (!(mode & supportedOpenMode)) {
- qFatal("Unsupported open mode");
- return false;
- }
-
- return QIODevice::open(mode);
-}
-
-bool QIOPipe::isSequential() const
-{
- return true;
-}
-
-void QIOPipe::setReadChannelCount(int count)
-{
- Q_D(QIOPipe);
- d->setReadChannelCount(qMax(count, 1));
-}
-
-void QIOPipe::addChildPipe(QIOPipe *childPipe)
-{
- Q_D(QIOPipe);
- d->addChildPipe(childPipe);
-}
-
-/*!
- \reimp
-
- \omit
- This function does not really read anything, as we use QIODevicePrivate's
- buffer. The buffer will be read inside of QIODevice before this
- method will be called.
- See QIODevicePrivate::read, buffer.read(data, maxSize).
- \endomit
-*/
-qint64 QIOPipe::readData(char *data, qint64 maxlen)
-{
- Q_UNUSED(data);
- Q_UNUSED(maxlen);
-
- // return 0 indicating there may be more data in the future
- // Returning -1 means no more data in the future (end of stream).
- return qint64(0);
-}
-
-qint64 QIOPipe::writeData(const char * /*data*/, qint64 /*len*/)
-{
- qFatal("QIOPipe is a read-only device");
- return qint64(0);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/nmea/qiopipe_p.h b/src/plugins/position/nmea/qiopipe_p.h
deleted file mode 100644
index dd83588a..00000000
--- a/src/plugins/position/nmea/qiopipe_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QIOPIPE_P_H
-#define QIOPIPE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qiodevice.h>
-#include <QtCore/qbytearray.h>
-#include <QtCore/private/qiodevice_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-class QIOPipePrivate;
-
-class QIOPipe : public QIODevice
-{
- Q_OBJECT
-
-public:
- enum Mode {
- EndPipe = 0x0000,
- ProxyPipe = 0x0001
- };
-
- explicit QIOPipe(QIODevice *parent, Mode mode = EndPipe);
- ~QIOPipe() override;
-
- bool open(OpenMode openMode) override;
- bool isSequential() const override;
- void setReadChannelCount(int count);
- void addChildPipe(QIOPipe *childPipe);
-
-protected:
- qint64 readData(char *data, qint64 maxlen) override;
- qint64 writeData(const char *data, qint64 len) override;
-
-private:
- Q_DECLARE_PRIVATE(QIOPipe)
- Q_DISABLE_COPY(QIOPipe)
-};
-
-class QIOPipePrivate : public QIODevicePrivate
-{
- Q_DECLARE_PUBLIC(QIOPipe)
-
-public:
- explicit QIOPipePrivate(QIODevice *iodevice, bool proxying);
- ~QIOPipePrivate() override;
-
- void initialize();
- bool readAvailableData();
- void pumpData(const QByteArray &ba);
- void pushData(const QByteArray &ba);
- void _q_onReadyRead();
- void addChildPipe(QIOPipe *childPipe);
- void removeChildPipe(QIOPipe *childPipe);
-
- bool m_proxying = false;
- QPointer<QIODevice> source;
- QList<QPointer<QIOPipe>> childPipes;
-};
-
-QT_END_NAMESPACE
-
-#endif // QIOPIPE_P_H
-
diff --git a/src/plugins/position/position.pro b/src/plugins/position/position.pro
deleted file mode 100644
index 145150ee..00000000
--- a/src/plugins/position/position.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = subdirs
-
-QT_FOR_CONFIG += positioning-private
-
-linux|freebsd|openbsd|netbsd:qtHaveModule(dbus):SUBDIRS += geoclue2
-qtConfig(gypsy):SUBDIRS += gypsy
-qtConfig(winrt_geolocation):SUBDIRS += winrt
-osx|ios|tvos:SUBDIRS += corelocation
-android:SUBDIRS += android
-qtHaveModule(serialport):SUBDIRS += serialnmea
-
-SUBDIRS += \
- positionpoll
diff --git a/src/plugins/position/positionpoll/CMakeLists.txt b/src/plugins/position/positionpoll/CMakeLists.txt
deleted file mode 100644
index 59810be1..00000000
--- a/src/plugins/position/positionpoll/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated from positionpoll.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryPoll Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryPollPlugin
- OUTPUT_NAME qtposition_positionpoll
- CLASS_NAME QGeoPositionInfoSourceFactoryPoll
- PLUGIN_TYPE position
- SOURCES
- positionpollfactory.cpp positionpollfactory.h
- qgeoareamonitor_polling.cpp qgeoareamonitor_polling.h
- LIBRARIES
- Qt::Core
- Qt::Positioning
-)
-
-#### Keys ignored in scope 1:.:.:positionpoll.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/positionpoll/plugin.json b/src/plugins/position/positionpoll/plugin.json
deleted file mode 100644
index df1f47de..00000000
--- a/src/plugins/position/positionpoll/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["positionpoll"],
- "Provider": "positionpoll",
- "Position": false,
- "Satellite": false,
- "Monitor": true,
- "Priority": 1000,
- "Testable": true
-}
diff --git a/src/plugins/position/positionpoll/positionpoll.pro b/src/plugins/position/positionpoll/positionpoll.pro
deleted file mode 100644
index be60bf43..00000000
--- a/src/plugins/position/positionpoll/positionpoll.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TARGET = qtposition_positionpoll
-
-QT = core positioning
-
-SOURCES += \
- qgeoareamonitor_polling.cpp \
- positionpollfactory.cpp
-
-HEADERS += \
- qgeoareamonitor_polling.h \
- positionpollfactory.h
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryPoll
-load(qt_plugin)
diff --git a/src/plugins/position/positionpoll/positionpollfactory.cpp b/src/plugins/position/positionpoll/positionpollfactory.cpp
deleted file mode 100644
index a47b2b10..00000000
--- a/src/plugins/position/positionpoll/positionpollfactory.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "positionpollfactory.h"
-#include "qgeoareamonitor_polling.h"
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryPoll::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryPoll::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryPoll::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- QGeoAreaMonitorPolling *ret = new QGeoAreaMonitorPolling(parent);
- if (ret && ret->isValid())
- return ret;
- delete ret;
- return nullptr;
-}
diff --git a/src/plugins/position/positionpoll/positionpollfactory.h b/src/plugins/position/positionpoll/positionpollfactory.h
deleted file mode 100644
index 570b3b21..00000000
--- a/src/plugins/position/positionpoll/positionpollfactory.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef POSITIONPOLLFACTORY_H
-#define POSITIONPOLLFACTORY_H
-
-#include <QObject>
-#include <QtPositioning/qgeopositioninfosourcefactory.h>
-
-class QGeoPositionInfoSourceFactoryPoll : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-#endif // POSITIONPOLLFACTORY_H
diff --git a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
deleted file mode 100644
index e69516c8..00000000
--- a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
+++ /dev/null
@@ -1,508 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeoareamonitor_polling.h"
-#include <QtPositioning/qgeocoordinate.h>
-#include <QtPositioning/qgeorectangle.h>
-#include <QtPositioning/qgeocircle.h>
-
-#include <QtCore/qmetaobject.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qmutex.h>
-
-#include <mutex>
-
-#define UPDATE_INTERVAL_5S 5000
-
-typedef QHash<QString, QGeoAreaMonitorInfo> MonitorTable;
-
-
-static QMetaMethod areaEnteredSignal()
-{
- static QMetaMethod signal = QMetaMethod::fromSignal(&QGeoAreaMonitorPolling::areaEntered);
- return signal;
-}
-
-static QMetaMethod areaExitedSignal()
-{
- static QMetaMethod signal = QMetaMethod::fromSignal(&QGeoAreaMonitorPolling::areaExited);
- return signal;
-}
-
-static QMetaMethod monitorExpiredSignal()
-{
- static QMetaMethod signal = QMetaMethod::fromSignal(&QGeoAreaMonitorPolling::monitorExpired);
- return signal;
-}
-
-class QGeoAreaMonitorPollingPrivate : public QObject
-{
- Q_OBJECT
-public:
- QGeoAreaMonitorPollingPrivate()
- {
- nextExpiryTimer = new QTimer(this);
- nextExpiryTimer->setSingleShot(true);
- connect(nextExpiryTimer, SIGNAL(timeout()),
- this, SLOT(timeout()));
- }
-
- void startMonitoring(const QGeoAreaMonitorInfo &monitor)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- activeMonitorAreas.insert(monitor.identifier(), monitor);
- singleShotTrigger.remove(monitor.identifier());
-
- checkStartStop();
- setupNextExpiryTimeout();
- }
-
- void requestUpdate(const QGeoAreaMonitorInfo &monitor, int signalId)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- activeMonitorAreas.insert(monitor.identifier(), monitor);
- singleShotTrigger.insert(monitor.identifier(), signalId);
-
- checkStartStop();
- setupNextExpiryTimeout();
- }
-
- QGeoAreaMonitorInfo stopMonitoring(const QGeoAreaMonitorInfo &monitor)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- QGeoAreaMonitorInfo mon = activeMonitorAreas.take(monitor.identifier());
-
- checkStartStop();
- setupNextExpiryTimeout();
-
- return mon;
- }
-
- void registerClient(QGeoAreaMonitorPolling *client)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- connect(this, SIGNAL(timeout(QGeoAreaMonitorInfo)),
- client, SLOT(timeout(QGeoAreaMonitorInfo)));
-
- connect(this, SIGNAL(positionError(QGeoPositionInfoSource::Error)),
- client, SLOT(positionError(QGeoPositionInfoSource::Error)));
-
- connect(this, SIGNAL(areaEventDetected(QGeoAreaMonitorInfo,QGeoPositionInfo,bool)),
- client, SLOT(processAreaEvent(QGeoAreaMonitorInfo,QGeoPositionInfo,bool)));
-
- registeredClients.append(client);
- }
-
- void deregisterClient(QGeoAreaMonitorPolling *client)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- registeredClients.removeAll(client);
- if (registeredClients.isEmpty())
- checkStartStop();
- }
-
- void setPositionSource(QGeoPositionInfoSource *newSource)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- if (newSource == source)
- return;
-
- if (source)
- delete source;
-
- source = newSource;
-
- if (source) {
- source->setParent(this);
- source->moveToThread(this->thread());
- if (source->updateInterval() == 0)
- source->setUpdateInterval(UPDATE_INTERVAL_5S);
- disconnect(source, 0, 0, 0); //disconnect all
- connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),
- this, SLOT(positionUpdated(QGeoPositionInfo)));
- connect(source, SIGNAL(errorOccurred(QGeoPositionInfoSource::Error)),
- this, SIGNAL(positionError(QGeoPositionInfoSource::Error)));
- checkStartStop();
- }
- }
-
- QGeoPositionInfoSource* positionSource() const
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
- return source;
- }
-
- MonitorTable activeMonitors() const
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- return activeMonitorAreas;
- }
-
- void checkStartStop()
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- bool signalsConnected = false;
- foreach (const QGeoAreaMonitorPolling *client, registeredClients) {
- if (client->hasConnections()) {
- signalsConnected = true;
- break;
- }
- }
-
- if (signalsConnected && !activeMonitorAreas.isEmpty()) {
- if (source)
- source->startUpdates();
- else
- //translated to InsufficientPositionInfo
- emit positionError(QGeoPositionInfoSource::ClosedError);
- } else {
- if (source)
- source->stopUpdates();
- }
- }
-
-private:
- void setupNextExpiryTimeout()
- {
- nextExpiryTimer->stop();
- activeExpiry.first = QDateTime();
- activeExpiry.second = QString();
-
- foreach (const QGeoAreaMonitorInfo &info, activeMonitors()) {
- if (info.expiration().isValid()) {
- if (!activeExpiry.first.isValid()) {
- activeExpiry.first = info.expiration();
- activeExpiry.second = info.identifier();
- continue;
- }
- if (info.expiration() < activeExpiry.first) {
- activeExpiry.first = info.expiration();
- activeExpiry.second = info.identifier();
- }
- }
- }
-
- if (activeExpiry.first.isValid())
- nextExpiryTimer->start(QDateTime::currentDateTime().msecsTo(activeExpiry.first));
- }
-
-
- //returns true if areaEntered should be emitted
- bool processInsideArea(const QString &monitorIdent)
- {
- if (!insideArea.contains(monitorIdent)) {
- if (singleShotTrigger.value(monitorIdent, -1) == areaEnteredSignal().methodIndex()) {
- //this is the finishing singleshot event
- singleShotTrigger.remove(monitorIdent);
- activeMonitorAreas.remove(monitorIdent);
- setupNextExpiryTimeout();
- } else {
- insideArea.insert(monitorIdent);
- }
- return true;
- }
-
- return false;
- }
-
- //returns true if areaExited should be emitted
- bool processOutsideArea(const QString &monitorIdent)
- {
- if (insideArea.contains(monitorIdent)) {
- if (singleShotTrigger.value(monitorIdent, -1) == areaExitedSignal().methodIndex()) {
- //this is the finishing singleShot event
- singleShotTrigger.remove(monitorIdent);
- activeMonitorAreas.remove(monitorIdent);
- setupNextExpiryTimeout();
- } else {
- insideArea.remove(monitorIdent);
- }
- return true;
- }
- return false;
- }
-
-
-
-Q_SIGNALS:
- void timeout(const QGeoAreaMonitorInfo &info);
- void positionError(const QGeoPositionInfoSource::Error error);
- void areaEventDetected(const QGeoAreaMonitorInfo &minfo,
- const QGeoPositionInfo &pinfo, bool isEnteredEvent);
-private Q_SLOTS:
- void timeout()
- {
- /*
- * Don't block timer firing even if monitorExpiredSignal is not connected.
- * This allows us to continue to remove the existing monitors as they expire.
- **/
- const QGeoAreaMonitorInfo info = activeMonitorAreas.take(activeExpiry.second);
- setupNextExpiryTimeout();
- emit timeout(info);
-
- }
-
- void positionUpdated(const QGeoPositionInfo &info)
- {
- foreach (const QGeoAreaMonitorInfo &monInfo, activeMonitors()) {
- const QString identifier = monInfo.identifier();
- if (monInfo.area().contains(info.coordinate())) {
- if (processInsideArea(identifier))
- emit areaEventDetected(monInfo, info, true);
- } else {
- if (processOutsideArea(identifier))
- emit areaEventDetected(monInfo, info, false);
- }
- }
- }
-
-private:
- QPair<QDateTime, QString> activeExpiry;
- QHash<QString, int> singleShotTrigger;
- QTimer* nextExpiryTimer;
- QSet<QString> insideArea;
-
- MonitorTable activeMonitorAreas;
-
- QGeoPositionInfoSource* source = nullptr;
- QList<QGeoAreaMonitorPolling*> registeredClients;
- mutable QRecursiveMutex mutex;
-};
-
-Q_GLOBAL_STATIC(QGeoAreaMonitorPollingPrivate, pollingPrivate)
-
-QGeoAreaMonitorPolling::QGeoAreaMonitorPolling(QObject *parent) : QGeoAreaMonitorSource(parent)
-{
- d = pollingPrivate();
- d->registerClient(this);
- //hookup to default source if existing
- if (!positionInfoSource())
- setPositionInfoSource(QGeoPositionInfoSource::createDefaultSource(this));
-}
-
-QGeoAreaMonitorPolling::~QGeoAreaMonitorPolling()
-{
- d->deregisterClient(this);
-}
-
-QGeoPositionInfoSource* QGeoAreaMonitorPolling::positionInfoSource() const
-{
- return d->positionSource();
-}
-
-void QGeoAreaMonitorPolling::setPositionInfoSource(QGeoPositionInfoSource *source)
-{
- d->setPositionSource(source);
-}
-
-QGeoAreaMonitorSource::Error QGeoAreaMonitorPolling::error() const
-{
- return lastError;
-}
-
-bool QGeoAreaMonitorPolling::startMonitoring(const QGeoAreaMonitorInfo &monitor)
-{
- if (!monitor.isValid())
- return false;
-
- //reject an expiry in the past
- if (monitor.expiration().isValid() &&
- (monitor.expiration() < QDateTime::currentDateTime()))
- return false;
-
- //don't accept persistent monitor since we don't support it
- if (monitor.isPersistent())
- return false;
-
- lastError = QGeoAreaMonitorSource::NoError;
-
- //update or insert
- d->startMonitoring(monitor);
-
- return true;
-}
-
-int QGeoAreaMonitorPolling::idForSignal(const char *signal)
-{
- const QByteArray sig = QMetaObject::normalizedSignature(signal + 1);
- const QMetaObject * const mo = metaObject();
-
- return mo->indexOfSignal(sig.constData());
-}
-
-bool QGeoAreaMonitorPolling::hasConnections() const
-{
- // This method is internal and requires the mutex to be already locked.
- return signalConnections > 0;
-}
-
-bool QGeoAreaMonitorPolling::requestUpdate(const QGeoAreaMonitorInfo &monitor, const char *signal)
-{
- if (!monitor.isValid())
- return false;
- //reject an expiry in the past
- if (monitor.expiration().isValid() &&
- (monitor.expiration() < QDateTime::currentDateTime()))
- return false;
-
- //don't accept persistent monitor since we don't support it
- if (monitor.isPersistent())
- return false;
-
- if (!signal)
- return false;
-
- const int signalId = idForSignal(signal);
- if (signalId < 0)
- return false;
-
- //only accept area entered or exit signal
- if (signalId != areaEnteredSignal().methodIndex() &&
- signalId != areaExitedSignal().methodIndex())
- {
- return false;
- }
-
- lastError = QGeoAreaMonitorSource::NoError;
-
- d->requestUpdate(monitor, signalId);
-
- return true;
-}
-
-bool QGeoAreaMonitorPolling::stopMonitoring(const QGeoAreaMonitorInfo &monitor)
-{
- QGeoAreaMonitorInfo info = d->stopMonitoring(monitor);
-
- return info.isValid();
-}
-
-QList<QGeoAreaMonitorInfo> QGeoAreaMonitorPolling::activeMonitors() const
-{
- return d->activeMonitors().values();
-}
-
-QList<QGeoAreaMonitorInfo> QGeoAreaMonitorPolling::activeMonitors(const QGeoShape &region) const
-{
- QList<QGeoAreaMonitorInfo> results;
- if (region.isEmpty())
- return results;
-
- const MonitorTable list = d->activeMonitors();
- foreach (const QGeoAreaMonitorInfo &monitor, list) {
- if (region.contains(monitor.area().center()))
- results.append(monitor);
- }
-
- return results;
-}
-
-QGeoAreaMonitorSource::AreaMonitorFeatures QGeoAreaMonitorPolling::supportedAreaMonitorFeatures() const
-{
- return {};
-}
-
-void QGeoAreaMonitorPolling::connectNotify(const QMetaMethod &signal)
-{
- QMutexLocker locker(&connectionMutex);
- if (signal == areaEnteredSignal() || signal == areaExitedSignal()) {
- const bool alreadyConnected = hasConnections();
- signalConnections++;
- if (!alreadyConnected)
- d->checkStartStop();
- }
-}
-
-void QGeoAreaMonitorPolling::disconnectNotify(const QMetaMethod &signal)
-{
- QMutexLocker locker(&connectionMutex);
- if (signal == areaEnteredSignal() || signal == areaExitedSignal()) {
- if (hasConnections())
- signalConnections--;
- if (!hasConnections())
- d->checkStartStop();
- }
-}
-
-void QGeoAreaMonitorPolling::positionError(const QGeoPositionInfoSource::Error error)
-{
- switch (error) {
- case QGeoPositionInfoSource::AccessError:
- lastError = QGeoAreaMonitorSource::AccessError;
- break;
- case QGeoPositionInfoSource::UnknownSourceError:
- lastError = QGeoAreaMonitorSource::UnknownSourceError;
- break;
- case QGeoPositionInfoSource::ClosedError:
- case QGeoPositionInfoSource::UpdateTimeoutError:
- lastError = QGeoAreaMonitorSource::InsufficientPositionInfo;
- break;
- case QGeoPositionInfoSource::NoError:
- return;
- }
-
- emit QGeoAreaMonitorSource::errorOccurred(lastError);
-}
-
-void QGeoAreaMonitorPolling::timeout(const QGeoAreaMonitorInfo& monitor)
-{
- if (isSignalConnected(monitorExpiredSignal()))
- emit monitorExpired(monitor);
-}
-
-void QGeoAreaMonitorPolling::processAreaEvent(const QGeoAreaMonitorInfo &minfo,
- const QGeoPositionInfo &pinfo, bool isEnteredEvent)
-{
- if (isEnteredEvent)
- emit areaEntered(minfo, pinfo);
- else
- emit areaExited(minfo, pinfo);
-}
-
-#include "qgeoareamonitor_polling.moc"
-#include "moc_qgeoareamonitor_polling.cpp"
diff --git a/src/plugins/position/positionpoll/qgeoareamonitor_polling.h b/src/plugins/position/positionpoll/qgeoareamonitor_polling.h
deleted file mode 100644
index 38a685d4..00000000
--- a/src/plugins/position/positionpoll/qgeoareamonitor_polling.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOAREAMONITORPOLLING_H
-#define QGEOAREAMONITORPOLLING_H
-
-#include <QtPositioning/qgeoareamonitorsource.h>
-#include <QtPositioning/qgeopositioninfosource.h>
-#include <QtCore/qmutex.h>
-
-/**
- * QGeoAreaMonitorPolling
- *
- */
-
-class QGeoAreaMonitorPollingPrivate;
-class QGeoAreaMonitorPolling : public QGeoAreaMonitorSource
-{
- Q_OBJECT
-public :
- explicit QGeoAreaMonitorPolling(QObject *parent = 0);
- ~QGeoAreaMonitorPolling();
-
- void setPositionInfoSource(QGeoPositionInfoSource *source) override;
- QGeoPositionInfoSource* positionInfoSource() const override;
-
- Error error() const override;
-
- bool startMonitoring(const QGeoAreaMonitorInfo &monitor) override;
- bool requestUpdate(const QGeoAreaMonitorInfo &monitor,
- const char *signal) override;
- bool stopMonitoring(const QGeoAreaMonitorInfo &monitor) override;
-
- QList<QGeoAreaMonitorInfo> activeMonitors() const override;
- QList<QGeoAreaMonitorInfo> activeMonitors(const QGeoShape &region) const override;
-
- QGeoAreaMonitorSource::AreaMonitorFeatures supportedAreaMonitorFeatures() const override;
-
- inline bool isValid() { return positionInfoSource(); }
-
-private Q_SLOTS:
- void positionError(QGeoPositionInfoSource::Error error);
- void timeout(const QGeoAreaMonitorInfo &monitor);
- void processAreaEvent(const QGeoAreaMonitorInfo &minfo, const QGeoPositionInfo &pinfo, bool isEnteredEvent);
-
-private:
- QGeoAreaMonitorPollingPrivate* d;
- QGeoAreaMonitorSource::Error lastError = QGeoAreaMonitorSource::NoError;
- friend class QGeoAreaMonitorPollingPrivate;
-
- int signalConnections = 0;
- // connectNotify() and disconnectNotify() can be called from a different
- // thread, so we need to synchronize the access to signalConnections
- QMutex connectionMutex;
-
- void connectNotify(const QMetaMethod &signal) override;
- void disconnectNotify(const QMetaMethod &signal) override;
-
- int idForSignal(const char *signal);
-
- bool hasConnections() const;
-};
-
-#endif // QGEOAREAMONITORPOLLING_H
diff --git a/src/plugins/position/winrt/CMakeLists.txt b/src/plugins/position/winrt/CMakeLists.txt
deleted file mode 100644
index 44de9655..00000000
--- a/src/plugins/position/winrt/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-# Generated from winrt.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryWinRT Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryWinRTPlugin
- OUTPUT_NAME qtposition_winrt
- CLASS_NAME QGeoPositionInfoSourceFactoryWinRT
- PLUGIN_TYPE position
- SOURCES
- qgeopositioninfosource_winrt.cpp qgeopositioninfosource_winrt_p.h
- qgeopositioninfosourcefactory_winrt.cpp qgeopositioninfosourcefactory_winrt.h
- LIBRARIES
- Qt::Core
- Qt::CorePrivate
- Qt::Positioning
-)
-
-#### Keys ignored in scope 1:.:.:winrt.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
-
-## Scopes:
-#####################################################################
-
-qt_internal_extend_target(QGeoPositionInfoSourceFactoryWinRTPlugin CONDITION MSVC AND NOT WINRT
- LIBRARIES
- runtimeobject.lib
-)
diff --git a/src/plugins/position/winrt/plugin.json b/src/plugins/position/winrt/plugin.json
deleted file mode 100644
index 0696cb0a..00000000
--- a/src/plugins/position/winrt/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["winrt"],
- "Provider": "winrt",
- "Position": true,
- "Satellite": false,
- "Monitor" : false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
deleted file mode 100644
index a8e9816f..00000000
--- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
+++ /dev/null
@@ -1,675 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** 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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_winrt_p.h"
-
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/private/qfunctions_winrt_p.h>
-#include <QtCore/qloggingcategory.h>
-#include <QtCore/qmutex.h>
-#ifdef Q_OS_WINRT
-#include <QtCore/private/qeventdispatcher_winrt_p.h>
-#endif
-
-#include <functional>
-#include <windows.system.h>
-#include <windows.devices.geolocation.h>
-#include <windows.foundation.h>
-#include <windows.foundation.collections.h>
-
-using namespace Microsoft::WRL;
-using namespace Microsoft::WRL::Wrappers;
-using namespace ABI::Windows::Devices::Geolocation;
-using namespace ABI::Windows::Foundation;
-using namespace ABI::Windows::Foundation::Collections;
-
-typedef ITypedEventHandler<Geolocator *, PositionChangedEventArgs *> GeoLocatorPositionHandler;
-typedef ITypedEventHandler<Geolocator *, StatusChangedEventArgs *> GeoLocatorStatusHandler;
-typedef IAsyncOperationCompletedHandler<Geoposition*> PositionHandler;
-typedef IAsyncOperationCompletedHandler<GeolocationAccessStatus> AccessHandler;
-
-Q_DECLARE_LOGGING_CATEGORY(lcPositioningWinRT)
-
-Q_DECLARE_METATYPE(QGeoPositionInfoSource::Error)
-
-QT_BEGIN_NAMESPACE
-
-#ifndef Q_OS_WINRT
-namespace QEventDispatcherWinRT {
-HRESULT runOnXamlThread(const std::function<HRESULT ()> &delegate, bool waitForRun = true)
-{
- Q_UNUSED(waitForRun);
- return delegate();
-}
-}
-
-static inline HRESULT await(const ComPtr<IAsyncOperation<GeolocationAccessStatus>> &asyncOp,
- GeolocationAccessStatus *result)
-{
- ComPtr<IAsyncInfo> asyncInfo;
- HRESULT hr = asyncOp.As(&asyncInfo);
- if (FAILED(hr))
- return hr;
-
- AsyncStatus status;
- while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started)
- QThread::yieldCurrentThread();
-
- if (FAILED(hr) || status != AsyncStatus::Completed) {
- HRESULT ec;
- hr = asyncInfo->get_ErrorCode(&ec);
- if (FAILED(hr))
- return hr;
- hr = asyncInfo->Close();
- if (FAILED(hr))
- return hr;
- return ec;
- }
-
- if (FAILED(hr))
- return hr;
-
- return asyncOp->GetResults(result);
-}
-#endif // !Q_OS_WINRT
-
-enum class InitializationState {
- Uninitialized,
- Initializing,
- Initialized
-};
-
-class QGeoPositionInfoSourceWinRTPrivate {
-public:
- ComPtr<IGeolocator> locator;
- mutable ComPtr<IGeolocatorStatics> statics;
- QTimer periodicTimer;
- QTimer singleUpdateTimer;
- QGeoPositionInfo lastPosition;
- QGeoPositionInfoSource::Error positionError = QGeoPositionInfoSource::NoError;
- EventRegistrationToken statusToken;
- EventRegistrationToken positionToken;
- QMutex mutex;
- bool updatesOngoing = false;
- int minimumUpdateInterval = -1;
- int updateInterval = -1;
- InitializationState initState = InitializationState::Uninitialized;
-
- PositionStatus positionStatus = PositionStatus_NotInitialized;
-};
-
-QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent)
- : QGeoPositionInfoSource(parent)
- , d_ptr(new QGeoPositionInfoSourceWinRTPrivate)
-{
- qRegisterMetaType<QGeoPositionInfoSource::Error>();
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
- Q_D(QGeoPositionInfoSourceWinRT);
- d->positionError = QGeoPositionInfoSource::NoError;
- d->updatesOngoing = false;
- d->positionToken.value = 0;
- d->statusToken.value = 0;
-}
-
-QGeoPositionInfoSourceWinRT::~QGeoPositionInfoSourceWinRT()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- CoUninitialize();
-}
-
-int QGeoPositionInfoSourceWinRT::init()
-{
- Q_D(QGeoPositionInfoSourceWinRT);
- Q_ASSERT(d->initState != InitializationState::Initializing);
- if (d->initState == InitializationState::Initialized)
- return 0;
-
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- d->initState = InitializationState::Initializing;
- if (!requestAccess()) {
- d->initState = InitializationState::Uninitialized;
- setError(QGeoPositionInfoSource::AccessError);
- qWarning ("Location access failed.");
- return -1;
- }
- HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, d]() {
- HRESULT hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Devices_Geolocation_Geolocator).Get(),
- &d->locator);
- RETURN_HR_IF_FAILED("Could not initialize native location services.");
-
- if (d->minimumUpdateInterval == -1) {
- UINT32 interval;
- hr = d->locator->get_ReportInterval(&interval);
- RETURN_HR_IF_FAILED("Could not retrieve report interval.");
- d->minimumUpdateInterval = static_cast<int>(interval);
- }
- if (d->updateInterval == -1)
- d->updateInterval = d->minimumUpdateInterval;
- setUpdateInterval(d->updateInterval);
-
- return hr;
- });
- if (FAILED(hr)) {
- d->initState = InitializationState::Uninitialized;
- setError(QGeoPositionInfoSource::UnknownSourceError);
- return -1;
- }
-
- d->periodicTimer.setSingleShot(true);
- connect(&d->periodicTimer, &QTimer::timeout, this, &QGeoPositionInfoSourceWinRT::virtualPositionUpdate);
-
- d->singleUpdateTimer.setSingleShot(true);
- connect(&d->singleUpdateTimer, &QTimer::timeout, this, &QGeoPositionInfoSourceWinRT::singleUpdateTimeOut);
-
- QGeoPositionInfoSource::PositioningMethods preferredMethods = preferredPositioningMethods();
- if (preferredMethods == QGeoPositionInfoSource::NoPositioningMethods)
- preferredMethods = QGeoPositionInfoSource::AllPositioningMethods;
- setPreferredPositioningMethods(preferredMethods);
-
- connect(this, &QGeoPositionInfoSourceWinRT::nativePositionUpdate, this, &QGeoPositionInfoSourceWinRT::updateSynchronized);
- d->initState = InitializationState::Initialized;
- return 0;
-}
-
-QGeoPositionInfo QGeoPositionInfoSourceWinRT::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(const QGeoPositionInfoSourceWinRT);
- Q_UNUSED(fromSatellitePositioningMethodsOnly);
- return d->lastPosition;
-}
-
-QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceWinRT::supportedPositioningMethods() const
-{
- return requestAccess() ? QGeoPositionInfoSource::AllPositioningMethods
- : QGeoPositionInfoSource::NoPositioningMethods;
-}
-
-void QGeoPositionInfoSourceWinRT::setPreferredPositioningMethods(QGeoPositionInfoSource::PositioningMethods methods)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << methods;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods();
- QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
- if (previousPreferredPositioningMethods == preferredPositioningMethods()
- || d->initState == InitializationState::Uninitialized) {
- return;
- }
-
- const bool needsRestart = d->positionToken.value != 0 || d->statusToken.value != 0;
-
- if (needsRestart)
- stopHandler();
-
- PositionAccuracy acc = methods & PositioningMethod::SatellitePositioningMethods ?
- PositionAccuracy::PositionAccuracy_High :
- PositionAccuracy::PositionAccuracy_Default;
- HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d, acc]() {
- return d->locator->put_DesiredAccuracy(acc);
- });
- RETURN_VOID_IF_FAILED("Could not set positioning accuracy.");
-
- if (needsRestart)
- startHandler();
-}
-
-void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << msec;
- Q_D(QGeoPositionInfoSourceWinRT);
- if (d->initState == InitializationState::Uninitialized) {
- d->updateInterval = msec;
- return;
- }
-
- // minimumUpdateInterval is initialized to the lowest possible update interval in init().
- // Passing 0 will cause an error on Windows 10.
- // See https://docs.microsoft.com/en-us/uwp/api/windows.devices.geolocation.geolocator.reportinterval
- if (msec != 0 && msec < minimumUpdateInterval())
- msec = minimumUpdateInterval();
-
- const bool needsRestart = d->positionToken.value != 0 || d->statusToken.value != 0;
-
- if (needsRestart)
- stopHandler();
-
- HRESULT hr = d->locator->put_ReportInterval(static_cast<UINT32>(msec));
- if (FAILED(hr)) {
- setError(QGeoPositionInfoSource::UnknownSourceError);
- qErrnoWarning(hr, "Failed to set update interval");
- return;
- }
-
- d->updateInterval = msec;
- d->periodicTimer.setInterval(d->updateInterval);
-
- QGeoPositionInfoSource::setUpdateInterval(d->updateInterval);
-
- if (needsRestart)
- startHandler();
-}
-
-int QGeoPositionInfoSourceWinRT::minimumUpdateInterval() const
-{
- Q_D(const QGeoPositionInfoSourceWinRT);
- return d->minimumUpdateInterval == -1 ? 1000 : d->minimumUpdateInterval;
-}
-
-void QGeoPositionInfoSourceWinRT::startUpdates()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- setError(QGeoPositionInfoSource::NoError);
- if (init() < 0)
- return;
-
- if (d->updatesOngoing)
- return;
-
- if (!startHandler())
- return;
- d->updatesOngoing = true;
- d->periodicTimer.start();
-}
-
-void QGeoPositionInfoSourceWinRT::stopUpdates()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- if (init() < 0)
- return;
-
- stopHandler();
- d->updatesOngoing = false;
- d->periodicTimer.stop();
-}
-
-bool QGeoPositionInfoSourceWinRT::startHandler()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- // Check if already attached
- if (d->positionToken.value != 0)
- return true;
-
- if (preferredPositioningMethods() == QGeoPositionInfoSource::NoPositioningMethods) {
- setError(QGeoPositionInfoSource::UnknownSourceError);
- return false;
- }
-
- if (!requestAccess()) {
- setError(QGeoPositionInfoSource::AccessError);
- return false;
- }
-
- HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, d]() {
- HRESULT hr;
-
- // We need to call this at least once on Windows 10 Mobile.
- // Unfortunately this operation does not have a completion handler
- // registered. That could have helped in the single update case
- ComPtr<IAsyncOperation<Geoposition*>> op;
- hr = d->locator->GetGeopositionAsync(&op);
- RETURN_HR_IF_FAILED("Could not start position operation");
-
- hr = d->locator->add_PositionChanged(Callback<GeoLocatorPositionHandler>(this,
- &QGeoPositionInfoSourceWinRT::onPositionChanged).Get(),
- &d->positionToken);
- RETURN_HR_IF_FAILED("Could not add position handler");
-
- hr = d->locator->add_StatusChanged(Callback<GeoLocatorStatusHandler>(this,
- &QGeoPositionInfoSourceWinRT::onStatusChanged).Get(),
- &d->statusToken);
- RETURN_HR_IF_FAILED("Could not add status handler");
- return hr;
- });
- if (FAILED(hr)) {
- setError(QGeoPositionInfoSource::UnknownSourceError);
- return false;
- }
-
- return true;
-}
-
-void QGeoPositionInfoSourceWinRT::stopHandler()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- if (!d->positionToken.value)
- return;
- QEventDispatcherWinRT::runOnXamlThread([d]() {
- d->locator->remove_PositionChanged(d->positionToken);
- d->locator->remove_StatusChanged(d->statusToken);
- return S_OK;
- });
- d->positionToken.value = 0;
- d->statusToken.value = 0;
-}
-
-void QGeoPositionInfoSourceWinRT::requestUpdate(int timeout)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << timeout;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- if (init() < 0)
- return;
-
- setError(QGeoPositionInfoSource::NoError);
- if (timeout != 0 && timeout < minimumUpdateInterval()) {
- d->positionError = QGeoPositionInfoSource::UpdateTimeoutError;
- emit QGeoPositionInfoSource::errorOccurred(d->positionError);
- return;
- }
-
- if (timeout == 0)
- timeout = 2*60*1000; // Maximum time for cold start (see Android)
-
- startHandler();
- d->singleUpdateTimer.start(timeout);
-}
-
-void QGeoPositionInfoSourceWinRT::virtualPositionUpdate()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
- QMutexLocker locker(&d->mutex);
-
- // The operating system did not provide information in time
- // Hence we send a virtual position update to keep same behavior
- // between backends.
- // This only applies to the periodic timer, not for single requests
- // We can only do this if we received a valid position before
- if (d->lastPosition.isValid()) {
- QGeoPositionInfo sent = d->lastPosition;
- sent.setTimestamp(sent.timestamp().addMSecs(updateInterval()));
- d->lastPosition = sent;
- emit positionUpdated(sent);
- }
- d->periodicTimer.start();
-}
-
-void QGeoPositionInfoSourceWinRT::singleUpdateTimeOut()
-{
- Q_D(QGeoPositionInfoSourceWinRT);
- QMutexLocker locker(&d->mutex);
-
- if (d->singleUpdateTimer.isActive()) {
- d->positionError = QGeoPositionInfoSource::UpdateTimeoutError;
- emit QGeoPositionInfoSource::errorOccurred(d->positionError);
- if (!d->updatesOngoing)
- stopHandler();
- }
-}
-
-void QGeoPositionInfoSourceWinRT::updateSynchronized(QGeoPositionInfo currentInfo)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << currentInfo;
- Q_D(QGeoPositionInfoSourceWinRT);
- QMutexLocker locker(&d->mutex);
-
- d->periodicTimer.stop();
- d->lastPosition = currentInfo;
-
- if (d->updatesOngoing)
- d->periodicTimer.start();
-
- if (d->singleUpdateTimer.isActive()) {
- d->singleUpdateTimer.stop();
- if (!d->updatesOngoing)
- stopHandler();
- }
-
- emit positionUpdated(currentInfo);
-}
-
-QGeoPositionInfoSource::Error QGeoPositionInfoSourceWinRT::error() const
-{
- Q_D(const QGeoPositionInfoSourceWinRT);
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << d->positionError;
-
- // If the last encountered error was "Access denied", it is possible that the location service
- // has been enabled by now so that we are clear again.
- if ((d->positionError == QGeoPositionInfoSource::AccessError
- || d->positionError == QGeoPositionInfoSource::UnknownSourceError) && requestAccess())
- return QGeoPositionInfoSource::NoError;
-
- return d->positionError;
-}
-
-void QGeoPositionInfoSourceWinRT::setError(QGeoPositionInfoSource::Error positionError)
-{
- Q_D(QGeoPositionInfoSourceWinRT);
-
- if (positionError == d->positionError)
- return;
-
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << positionError;
- d->positionError = positionError;
- if (positionError != QGeoPositionInfoSource::NoError)
- emit QGeoPositionInfoSource::errorOccurred(positionError);
-}
-
-void QGeoPositionInfoSourceWinRT::reactOnError(QGeoPositionInfoSource::Error positionError)
-{
- setError(positionError);
- stopUpdates();
-}
-
-HRESULT QGeoPositionInfoSourceWinRT::onPositionChanged(IGeolocator *locator, IPositionChangedEventArgs *args)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_UNUSED(locator);
-
- HRESULT hr;
- ComPtr<IGeoposition> position;
- hr = args->get_Position(&position);
- RETURN_HR_IF_FAILED("Could not access position object.");
-
- QGeoPositionInfo currentInfo;
-
- ComPtr<IGeocoordinate> coord;
- hr = position->get_Coordinate(&coord);
- if (FAILED(hr))
- qErrnoWarning(hr, "Could not access coordinate");
-
- ComPtr<IGeocoordinateWithPoint> pointCoordinate;
- hr = coord.As(&pointCoordinate);
- if (FAILED(hr))
- qErrnoWarning(hr, "Could not cast coordinate.");
-
- ComPtr<IGeopoint> point;
- hr = pointCoordinate->get_Point(&point);
- if (FAILED(hr))
- qErrnoWarning(hr, "Could not obtain coordinate's point.");
-
- BasicGeoposition pos;
- hr = point->get_Position(&pos);
- if (FAILED(hr))
- qErrnoWarning(hr, "Could not obtain point's position.");
-
- DOUBLE lat = pos.Latitude;
- DOUBLE lon = pos.Longitude;
- DOUBLE alt = pos.Altitude;
-
- bool altitudeAvailable = false;
- ComPtr<IGeoshape> shape;
- hr = point.As(&shape);
- if (SUCCEEDED(hr) && shape) {
- AltitudeReferenceSystem altitudeSystem;
- hr = shape->get_AltitudeReferenceSystem(&altitudeSystem);
- if (SUCCEEDED(hr) && altitudeSystem == AltitudeReferenceSystem_Geoid)
- altitudeAvailable = true;
- }
- if (altitudeAvailable)
- currentInfo.setCoordinate(QGeoCoordinate(lat, lon, alt));
- else
- currentInfo.setCoordinate(QGeoCoordinate(lat, lon));
-
- DOUBLE accuracy;
- hr = coord->get_Accuracy(&accuracy);
- if (SUCCEEDED(hr))
- currentInfo.setAttribute(QGeoPositionInfo::HorizontalAccuracy, accuracy);
-
- IReference<double> *altAccuracy;
- hr = coord->get_AltitudeAccuracy(&altAccuracy);
- if (SUCCEEDED(hr) && altAccuracy) {
- double value;
- hr = altAccuracy->get_Value(&value);
- currentInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy, value);
- }
-
- IReference<double> *speed;
- hr = coord->get_Speed(&speed);
- if (SUCCEEDED(hr) && speed) {
- double value;
- hr = speed->get_Value(&value);
- currentInfo.setAttribute(QGeoPositionInfo::GroundSpeed, value);
- }
-
- IReference<double> *heading;
- hr = coord->get_Heading(&heading);
- if (SUCCEEDED(hr) && heading) {
- double value;
- hr = heading->get_Value(&value);
- double mod = 0;
- value = modf(value, &mod);
- value += static_cast<int>(mod) % 360;
- if (value >=0 && value <= 359) // get_Value might return nan/-nan
- currentInfo.setAttribute(QGeoPositionInfo::Direction, value);
- }
-
- DateTime dateTime;
- hr = coord->get_Timestamp(&dateTime);
-
- if (dateTime.UniversalTime > 0) {
- ULARGE_INTEGER uLarge;
- uLarge.QuadPart = dateTime.UniversalTime;
- FILETIME fileTime;
- fileTime.dwHighDateTime = uLarge.HighPart;
- fileTime.dwLowDateTime = uLarge.LowPart;
- SYSTEMTIME systemTime;
- if (FileTimeToSystemTime(&fileTime, &systemTime)) {
- currentInfo.setTimestamp(QDateTime(QDate(systemTime.wYear, systemTime.wMonth,
- systemTime.wDay),
- QTime(systemTime.wHour, systemTime.wMinute,
- systemTime.wSecond, systemTime.wMilliseconds),
- Qt::UTC));
- }
- }
-
- emit nativePositionUpdate(currentInfo);
-
- return S_OK;
-}
-
-static inline bool isDisabledStatus(PositionStatus status)
-{
- return status == PositionStatus_NoData || status == PositionStatus_Disabled
- || status == PositionStatus_NotAvailable;
-}
-
-HRESULT QGeoPositionInfoSourceWinRT::onStatusChanged(IGeolocator *, IStatusChangedEventArgs *args)
-{
- Q_D(QGeoPositionInfoSourceWinRT);
-
- const PositionStatus oldStatus = d->positionStatus;
- HRESULT hr = args->get_Status(&d->positionStatus);
- RETURN_HR_IF_FAILED("Could not obtain position status");
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << d->positionStatus;
- QGeoPositionInfoSource::Error error = QGeoPositionInfoSource::NoError;
- switch (d->positionStatus) {
- case PositionStatus::PositionStatus_NotAvailable:
- error = QGeoPositionInfoSource::UnknownSourceError;
- break;
- case PositionStatus::PositionStatus_Disabled:
- error = QGeoPositionInfoSource::AccessError;
- break;
- case PositionStatus::PositionStatus_NoData:
- error = QGeoPositionInfoSource::ClosedError;
- break;
- }
- if (error != QGeoPositionInfoSource::NoError) {
- QMetaObject::invokeMethod(this, "reactOnError", Qt::QueuedConnection,
- Q_ARG(QGeoPositionInfoSource::Error,
- QGeoPositionInfoSource::UnknownSourceError));
- }
-
- if (isDisabledStatus(oldStatus) != isDisabledStatus(d->positionStatus))
- emit supportedPositioningMethodsChanged();
-
- return S_OK;
-}
-
-bool QGeoPositionInfoSourceWinRT::requestAccess() const
-{
- Q_D(const QGeoPositionInfoSourceWinRT);
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- GeolocationAccessStatus accessStatus;
-
- ComPtr<IAsyncOperation<GeolocationAccessStatus>> op;
- HRESULT hr;
- hr = QEventDispatcherWinRT::runOnXamlThread([&op, d]() {
- HRESULT hr;
- if (!d->statics) {
- hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Devices_Geolocation_Geolocator).Get(),
- IID_PPV_ARGS(&d->statics));
- RETURN_HR_IF_FAILED("Could not access Geolocation Statics.");
- }
-
- hr = d->statics->RequestAccessAsync(&op);
- return hr;
- });
- if (FAILED(hr)) {
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << "Requesting access from Xaml thread failed";
- return false;
- }
-
- // We cannot wait inside the XamlThread as that would deadlock
-#ifdef Q_OS_WINRT
- QWinRTFunctions::await(op, &accessStatus);
-#else
- await(op, &accessStatus);
-#endif
- return accessStatus == GeolocationAccessStatus_Allowed;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h b/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h
deleted file mode 100644
index dbfde0e9..00000000
--- a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** 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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEWINRT_H
-#define QGEOPOSITIONINFOSOURCEWINRT_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeopositioninfosource.h"
-#include "qgeopositioninfo.h"
-
-#include <QtCore/qtimer.h>
-
-#include <EventToken.h>
-#include <wrl.h>
-
-namespace ABI {
- namespace Windows {
- namespace Devices {
- namespace Geolocation{
- struct IGeolocator;
- struct IPositionChangedEventArgs;
- struct IStatusChangedEventArgs;
- }
- }
- }
-}
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourceWinRTPrivate;
-
-class QGeoPositionInfoSourceWinRT : public QGeoPositionInfoSource
-{
- Q_OBJECT
-public:
- QGeoPositionInfoSourceWinRT(QObject *parent = nullptr);
- ~QGeoPositionInfoSourceWinRT() override;
- int init();
-
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
- PositioningMethods supportedPositioningMethods() const override;
-
- void setPreferredPositioningMethods(PositioningMethods methods) override;
-
- void setUpdateInterval(int msec) override;
- int minimumUpdateInterval() const override;
- Error error() const override;
-
- HRESULT onPositionChanged(ABI::Windows::Devices::Geolocation::IGeolocator *locator,
- ABI::Windows::Devices::Geolocation::IPositionChangedEventArgs *args);
- HRESULT onStatusChanged(ABI::Windows::Devices::Geolocation::IGeolocator *locator,
- ABI::Windows::Devices::Geolocation::IStatusChangedEventArgs *args);
-
- bool requestAccess() const;
-Q_SIGNALS:
- void nativePositionUpdate(const QGeoPositionInfo);
-public slots:
- void startUpdates() override;
- void stopUpdates() override;
-
- void requestUpdate(int timeout = 0) override;
-
-private slots:
- void stopHandler();
- void virtualPositionUpdate();
- void singleUpdateTimeOut();
- void updateSynchronized(const QGeoPositionInfo info);
- void reactOnError(QGeoPositionInfoSource::Error positionError);
-private:
- bool startHandler();
-
- Q_DISABLE_COPY(QGeoPositionInfoSourceWinRT)
- void setError(QGeoPositionInfoSource::Error positionError);
-
- QScopedPointer<QGeoPositionInfoSourceWinRTPrivate> d_ptr;
- Q_DECLARE_PRIVATE(QGeoPositionInfoSourceWinRT)
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCEWINRT_H
diff --git a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp
deleted file mode 100644
index 4e75c242..00000000
--- a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** 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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosourcefactory_winrt.h"
-#include "qgeopositioninfosource_winrt_p.h"
-
-#include <QtCore/qloggingcategory.h>
-
-Q_LOGGING_CATEGORY(lcPositioningWinRT, "qt.positioning.winrt")
-
-QT_BEGIN_NAMESPACE
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryWinRT::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_UNUSED(parameters)
- QGeoPositionInfoSourceWinRT *src = new QGeoPositionInfoSourceWinRT(parent);
- return src;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryWinRT::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryWinRT::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h
deleted file mode 100644
index 3e1ca3c5..00000000
--- a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** 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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_WINRT_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_WINRT_H
-
-#include <QtCore/qobject.h>
-#include <QtPositioning/qgeopositioninfosourcefactory.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourceFactoryWinRT : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCEFACTORY_WINRT_H
diff --git a/src/plugins/position/winrt/winrt.pro b/src/plugins/position/winrt/winrt.pro
deleted file mode 100644
index 446cb345..00000000
--- a/src/plugins/position/winrt/winrt.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qtposition_winrt
-
-QT = core core-private positioning
-
-SOURCES += qgeopositioninfosource_winrt.cpp \
- qgeopositioninfosourcefactory_winrt.cpp
-HEADERS += qgeopositioninfosource_winrt_p.h \
- qgeopositioninfosourcefactory_winrt.h
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryWinRT
-msvc:!winrt: LIBS += runtimeobject.lib
-load(qt_plugin)