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 @@ ...@@ -41,6 +41,15 @@
#define LOCATION_SETTINGS_LAST_DATA_SOURCE_BIT 31 #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. // The settings component here expects two types of usage for modifications.
// Either locationMode to high level location types, after which pendingAgreements tells // 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. // 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 ...@@ -55,18 +64,17 @@ class SYSTEMSETTINGS_EXPORT LocationSettings : public QObject
Q_PROPERTY(LocationMode locationMode READ locationMode WRITE setLocationMode NOTIFY locationModeChanged) Q_PROPERTY(LocationMode locationMode READ locationMode WRITE setLocationMode NOTIFY locationModeChanged)
Q_PROPERTY(QStringList pendingAgreements READ pendingAgreements NOTIFY pendingAgreementsChanged) Q_PROPERTY(QStringList pendingAgreements READ pendingAgreements NOTIFY pendingAgreementsChanged)
Q_PROPERTY(DataSources allowedDataSources READ allowedDataSources WRITE setAllowedDataSources NOTIFY allowedDataSourcesChanged) Q_PROPERTY(DataSources allowedDataSources READ allowedDataSources WRITE setAllowedDataSources NOTIFY allowedDataSourcesChanged)
Q_PROPERTY(bool gpsAvailable READ gpsAvailable CONSTANT) Q_PROPERTY(bool gpsAvailable READ gpsAvailable CONSTANT)
Q_PROPERTY(bool gpsEnabled READ gpsEnabled WRITE setGpsEnabled NOTIFY gpsEnabledChanged) Q_PROPERTY(bool gpsEnabled READ gpsEnabled WRITE setGpsEnabled NOTIFY gpsEnabledChanged)
Q_PROPERTY(bool gpsFlightMode READ gpsFlightMode WRITE setGpsFlightMode NOTIFY gpsFlightModeChanged) 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(bool hereAvailable READ hereAvailable CONSTANT)
Q_PROPERTY(OnlineAGpsState hereState READ hereState WRITE setHereState NOTIFY hereStateChanged) Q_PROPERTY(OnlineAGpsState hereState READ hereState WRITE setHereState NOTIFY hereStateChanged)
Q_PROPERTY(bool mlsAvailable READ mlsAvailable CONSTANT) Q_PROPERTY(bool mlsAvailable READ mlsAvailable CONSTANT)
Q_PROPERTY(bool mlsEnabled READ mlsEnabled WRITE setMlsEnabled NOTIFY mlsEnabledChanged) Q_PROPERTY(bool mlsEnabled READ mlsEnabled WRITE setMlsEnabled NOTIFY mlsEnabledChanged)
Q_PROPERTY(OnlineAGpsState mlsOnlineState READ mlsOnlineState WRITE setMlsOnlineState NOTIFY mlsOnlineStateChanged) Q_PROPERTY(OnlineAGpsState mlsOnlineState READ mlsOnlineState WRITE setMlsOnlineState NOTIFY mlsOnlineStateChanged)
Q_PROPERTY(bool yandexAvailable READ yandexAvailable CONSTANT) Q_PROPERTY(bool yandexAvailable READ yandexAvailable CONSTANT)
Q_PROPERTY(OnlineAGpsState yandexOnlineState READ yandexOnlineState WRITE setYandexOnlineState NOTIFY yandexOnlineStateChanged) Q_PROPERTY(OnlineAGpsState yandexOnlineState READ yandexOnlineState WRITE setYandexOnlineState NOTIFY yandexOnlineStateChanged)
...@@ -129,6 +137,11 @@ public: ...@@ -129,6 +137,11 @@ public:
void setGpsFlightMode(bool flightMode); void setGpsFlightMode(bool flightMode);
bool gpsAvailable() const; 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; OnlineAGpsState hereState() const;
void setHereState(OnlineAGpsState state); void setHereState(OnlineAGpsState state);
bool hereAvailable() const; bool hereAvailable() const;
...@@ -151,16 +164,16 @@ public: ...@@ -151,16 +164,16 @@ public:
void setAllowedDataSources(DataSources dataSources); void setAllowedDataSources(DataSources dataSources);
signals: signals:
void hereStateChanged();
void locationEnabledChanged(); void locationEnabledChanged();
void gpsEnabledChanged(); void gpsEnabledChanged();
void gpsFlightModeChanged(); void gpsFlightModeChanged();
void mlsEnabledChanged();
void mlsOnlineStateChanged();
void yandexOnlineStateChanged();
void locationModeChanged(); void locationModeChanged();
void pendingAgreementsChanged(); void pendingAgreementsChanged();
void allowedDataSourcesChanged(); void allowedDataSourcesChanged();
void hereStateChanged();
void mlsEnabledChanged();
void mlsOnlineStateChanged();
void yandexOnlineStateChanged();
private: private:
LocationSettingsPrivate *d_ptr; LocationSettingsPrivate *d_ptr;
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <QVariant> #include <QVariant>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QHash>
#include <sailfishkeyprovider_processmutex.h> #include <sailfishkeyprovider_processmutex.h>
...@@ -59,21 +60,17 @@ public: ...@@ -59,21 +60,17 @@ public:
LocationSettingsPrivate(LocationSettings::Mode mode, LocationSettings *settings); LocationSettingsPrivate(LocationSettings::Mode mode, LocationSettings *settings);
~LocationSettingsPrivate(); ~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; LocationSettings::LocationMode calculateLocationMode() const;
void writeSettings(); void writeSettings();
void removePendingAgreement(const QString &agreement);
int m_hereAvailable;
int m_mlsAvailable;
int m_yandexAvailable;
QFileSystemWatcher m_watcher; QFileSystemWatcher m_watcher;
bool m_locationEnabled; bool m_locationEnabled;
bool m_gpsEnabled; bool m_gpsEnabled;
bool m_mlsEnabled; QHash<QString, LocationProvider> m_providers;
LocationSettings::OnlineAGpsState m_mlsOnlineState;
LocationSettings::OnlineAGpsState m_yandexOnlineState;
LocationSettings::OnlineAGpsState m_hereState;
LocationSettings::LocationMode m_locationMode; LocationSettings::LocationMode m_locationMode;
bool m_settingMultipleSettings; bool m_settingMultipleSettings;
QStringList m_pendingAgreements; 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