Commit 2f399d79 authored by pvuorela's avatar pvuorela

Generalize the location provider support

Old Here/Mls/Yandex now provided only as convenience for qml side,
and in even fewer places.

C++ side can call new functions for getting and settings arbitrary
provider state.
parent 34db4734
This diff is collapsed.
......@@ -41,6 +41,15 @@
#define LOCATION_SETTINGS_LAST_DATA_SOURCE_BIT 31
struct LocationProvider {
bool hasAgreement = false;
bool agreementAccepted = false;
bool onlineCapable = true;
bool onlineEnabled = false;
bool offlineCapable = false;
bool offlineEnabled = false;
};
// The settings component here expects two types of usage for modifications.
// Either locationMode to high level location types, after which pendingAgreements tells
// which location services need to be explicitly turned on to ensure the usage agreement is acknowledged.
......@@ -55,18 +64,17 @@ class SYSTEMSETTINGS_EXPORT LocationSettings : public QObject
Q_PROPERTY(LocationMode locationMode READ locationMode WRITE setLocationMode NOTIFY locationModeChanged)
Q_PROPERTY(QStringList pendingAgreements READ pendingAgreements NOTIFY pendingAgreementsChanged)
Q_PROPERTY(DataSources allowedDataSources READ allowedDataSources WRITE setAllowedDataSources NOTIFY allowedDataSourcesChanged)
Q_PROPERTY(bool gpsAvailable READ gpsAvailable CONSTANT)
Q_PROPERTY(bool gpsEnabled READ gpsEnabled WRITE setGpsEnabled NOTIFY gpsEnabledChanged)
Q_PROPERTY(bool gpsFlightMode READ gpsFlightMode WRITE setGpsFlightMode NOTIFY gpsFlightModeChanged)
Q_PROPERTY(QStringList locationProviders READ locationProviders CONSTANT)
// Some specific locators provided as convenience for qml
Q_PROPERTY(bool hereAvailable READ hereAvailable CONSTANT)
Q_PROPERTY(OnlineAGpsState hereState READ hereState WRITE setHereState NOTIFY hereStateChanged)
Q_PROPERTY(bool mlsAvailable READ mlsAvailable CONSTANT)
Q_PROPERTY(bool mlsEnabled READ mlsEnabled WRITE setMlsEnabled NOTIFY mlsEnabledChanged)
Q_PROPERTY(OnlineAGpsState mlsOnlineState READ mlsOnlineState WRITE setMlsOnlineState NOTIFY mlsOnlineStateChanged)
Q_PROPERTY(bool yandexAvailable READ yandexAvailable CONSTANT)
Q_PROPERTY(OnlineAGpsState yandexOnlineState READ yandexOnlineState WRITE setYandexOnlineState NOTIFY yandexOnlineStateChanged)
......@@ -129,6 +137,11 @@ public:
void setGpsFlightMode(bool flightMode);
bool gpsAvailable() const;
QStringList locationProviders() const;
LocationProvider providerInfo(const QString &name) const;
bool updateLocationProvider(const QString &name, const LocationProvider &providerState);
// qml helpers for specific location providers
OnlineAGpsState hereState() const;
void setHereState(OnlineAGpsState state);
bool hereAvailable() const;
......@@ -151,16 +164,16 @@ public:
void setAllowedDataSources(DataSources dataSources);
signals:
void hereStateChanged();
void locationEnabledChanged();
void gpsEnabledChanged();
void gpsFlightModeChanged();
void mlsEnabledChanged();
void mlsOnlineStateChanged();
void yandexOnlineStateChanged();
void locationModeChanged();
void pendingAgreementsChanged();
void allowedDataSourcesChanged();
void hereStateChanged();
void mlsEnabledChanged();
void mlsOnlineStateChanged();
void yandexOnlineStateChanged();
private:
LocationSettingsPrivate *d_ptr;
......
......@@ -39,6 +39,7 @@
#include <QVariant>
#include <QString>
#include <QStringList>
#include <QHash>
#include <sailfishkeyprovider_processmutex.h>
......@@ -59,21 +60,17 @@ public:
LocationSettingsPrivate(LocationSettings::Mode mode, LocationSettings *settings);
~LocationSettingsPrivate();
void loadProviders();
bool updateProvider(const QString &name, const LocationProvider &state);
LocationSettings::OnlineAGpsState onlineState(const QString &name, bool *valid = nullptr) const;
void updateOnlineAgpsState(const QString &name, LocationSettings::OnlineAGpsState state);
LocationSettings::LocationMode calculateLocationMode() const;
void writeSettings();
void removePendingAgreement(const QString &agreement);
int m_hereAvailable;
int m_mlsAvailable;
int m_yandexAvailable;
QFileSystemWatcher m_watcher;
bool m_locationEnabled;
bool m_gpsEnabled;
bool m_mlsEnabled;
LocationSettings::OnlineAGpsState m_mlsOnlineState;
LocationSettings::OnlineAGpsState m_yandexOnlineState;
LocationSettings::OnlineAGpsState m_hereState;
QHash<QString, LocationProvider> m_providers;
LocationSettings::LocationMode m_locationMode;
bool m_settingMultipleSettings;
QStringList m_pendingAgreements;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment