Commit 34db4734 authored by pvuorela's avatar pvuorela

[nemo-qml-plugin-systemsettings] Refactor location settings. Contributes to JB#47257

Adjusted for better maintainability.
- Api addition: pendingAgreements tells which location services
are missing acceptance on currently set location mode
- Some code moved around for grouping both deprecated parts and
location services together
- Yandex locator enabled setting removed, was copy-paste detail from
mls which has both offline and online variants.
- agps_providers on settings file didn't appear used by anything. Removed.
- Removed writing deprecated keys, only need to read them (if even that).
- Simplified lots of things
parent d469f881
This diff is collapsed.
...@@ -37,34 +37,38 @@ ...@@ -37,34 +37,38 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QStringList>
#define LOCATION_SETTINGS_LAST_DATA_SOURCE_BIT 31 #define LOCATION_SETTINGS_LAST_DATA_SOURCE_BIT 31
// 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.
// Or setting location mode to custom, and modifying specific details.
class LocationSettingsPrivate; class LocationSettingsPrivate;
class SYSTEMSETTINGS_EXPORT LocationSettings : public QObject class SYSTEMSETTINGS_EXPORT LocationSettings : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool locationEnabled READ locationEnabled WRITE setLocationEnabled NOTIFY locationEnabledChanged) Q_PROPERTY(bool locationEnabled READ locationEnabled WRITE setLocationEnabled NOTIFY locationEnabledChanged)
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 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(bool gpsAvailable READ gpsAvailable CONSTANT)
Q_PROPERTY(OnlineAGpsState hereState READ hereState WRITE setHereState NOTIFY hereStateChanged)
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(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 mlsAvailable READ mlsAvailable CONSTANT)
Q_PROPERTY(bool yandexLocatorEnabled READ yandexLocatorEnabled WRITE setYandexLocatorEnabled NOTIFY yandexLocatorEnabledChanged) Q_PROPERTY(bool yandexAvailable READ yandexAvailable CONSTANT)
Q_PROPERTY(OnlineAGpsState yandexLocatorOnlineState READ yandexLocatorOnlineState WRITE setYandexLocatorOnlineState NOTIFY yandexLocatorOnlineStateChanged) Q_PROPERTY(OnlineAGpsState yandexOnlineState READ yandexOnlineState WRITE setYandexOnlineState NOTIFY yandexOnlineStateChanged)
Q_PROPERTY(bool yandexLocatorAvailable READ yandexLocatorAvailable CONSTANT)
Q_PROPERTY(LocationMode locationMode READ locationMode WRITE setLocationMode NOTIFY locationModeChanged)
Q_PROPERTY(DataSources allowedDataSources READ allowedDataSources WRITE setAllowedDataSources NOTIFY allowedDataSourcesChanged)
Q_ENUMS(OnlineAGpsState) Q_ENUMS(OnlineAGpsState)
Q_ENUMS(LocationMode) Q_ENUMS(LocationMode)
...@@ -75,41 +79,12 @@ public: ...@@ -75,41 +79,12 @@ public:
SynchronousMode SynchronousMode
}; };
explicit LocationSettings(QObject *parent = 0);
explicit LocationSettings(Mode mode, QObject *parent = 0);
virtual ~LocationSettings();
bool locationEnabled() const;
void setLocationEnabled(bool enabled);
bool gpsEnabled() const;
void setGpsEnabled(bool enabled);
bool gpsFlightMode() const;
void setGpsFlightMode(bool flightMode);
bool gpsAvailable() const;
enum OnlineAGpsState { enum OnlineAGpsState {
OnlineAGpsAgreementNotAccepted, OnlineAGpsAgreementNotAccepted,
OnlineAGpsDisabled, OnlineAGpsDisabled,
OnlineAGpsEnabled OnlineAGpsEnabled
}; };
OnlineAGpsState hereState() const;
void setHereState(OnlineAGpsState state);
bool hereAvailable() const;
bool mlsEnabled() const;
void setMlsEnabled(bool enabled);
OnlineAGpsState mlsOnlineState() const;
void setMlsOnlineState(OnlineAGpsState state);
bool mlsAvailable() const;
bool yandexLocatorEnabled() const;
void setYandexLocatorEnabled(bool enabled);
OnlineAGpsState yandexLocatorOnlineState() const;
void setYandexLocatorOnlineState(OnlineAGpsState state);
bool yandexLocatorAvailable() const;
enum LocationMode { enum LocationMode {
HighAccuracyMode, HighAccuracyMode,
BatterySavingMode, BatterySavingMode,
...@@ -117,9 +92,6 @@ public: ...@@ -117,9 +92,6 @@ public:
CustomMode CustomMode
}; };
LocationMode locationMode() const;
void setLocationMode(LocationMode locationMode);
// Data sources are grouped roughly by type, // Data sources are grouped roughly by type,
// with gaps left for future expansion. // with gaps left for future expansion.
enum DataSource { enum DataSource {
...@@ -144,6 +116,37 @@ public: ...@@ -144,6 +116,37 @@ public:
Q_DECLARE_FLAGS(DataSources, DataSource) Q_DECLARE_FLAGS(DataSources, DataSource)
Q_FLAG(DataSources) Q_FLAG(DataSources)
explicit LocationSettings(QObject *parent = 0);
explicit LocationSettings(Mode mode, QObject *parent = 0);
virtual ~LocationSettings();
bool locationEnabled() const;
void setLocationEnabled(bool enabled);
bool gpsEnabled() const;
void setGpsEnabled(bool enabled);
bool gpsFlightMode() const;
void setGpsFlightMode(bool flightMode);
bool gpsAvailable() const;
OnlineAGpsState hereState() const;
void setHereState(OnlineAGpsState state);
bool hereAvailable() const;
bool mlsEnabled() const;
void setMlsEnabled(bool enabled);
OnlineAGpsState mlsOnlineState() const;
void setMlsOnlineState(OnlineAGpsState state);
bool mlsAvailable() const;
OnlineAGpsState yandexOnlineState() const;
void setYandexOnlineState(OnlineAGpsState state);
bool yandexAvailable() const;
LocationMode locationMode() const;
void setLocationMode(LocationMode locationMode);
QStringList pendingAgreements() const;
DataSources allowedDataSources() const; DataSources allowedDataSources() const;
void setAllowedDataSources(DataSources dataSources); void setAllowedDataSources(DataSources dataSources);
...@@ -154,9 +157,9 @@ signals: ...@@ -154,9 +157,9 @@ signals:
void gpsFlightModeChanged(); void gpsFlightModeChanged();
void mlsEnabledChanged(); void mlsEnabledChanged();
void mlsOnlineStateChanged(); void mlsOnlineStateChanged();
void yandexLocatorEnabledChanged(); void yandexOnlineStateChanged();
void yandexLocatorOnlineStateChanged();
void locationModeChanged(); void locationModeChanged();
void pendingAgreementsChanged();
void allowedDataSourcesChanged(); void allowedDataSourcesChanged();
private: private:
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <QDBusInterface> #include <QDBusInterface>
#include <QVariant> #include <QVariant>
#include <QString> #include <QString>
#include <QStringList>
#include <sailfishkeyprovider_processmutex.h> #include <sailfishkeyprovider_processmutex.h>
...@@ -60,22 +61,22 @@ public: ...@@ -60,22 +61,22 @@ public:
LocationSettings::LocationMode calculateLocationMode() const; LocationSettings::LocationMode calculateLocationMode() const;
void writeSettings(); void writeSettings();
void removePendingAgreement(const QString &agreement);
bool mlsAvailable() const; int m_hereAvailable;
bool yandexLocatorAvailable() const; int m_mlsAvailable;
bool hereAvailable() const; int m_yandexAvailable;
QFileSystemWatcher m_watcher; QFileSystemWatcher m_watcher;
bool m_locationEnabled; bool m_locationEnabled;
bool m_gpsEnabled; bool m_gpsEnabled;
bool m_mlsEnabled; bool m_mlsEnabled;
bool m_yandexLocatorEnabled;
LocationSettings::OnlineAGpsState m_mlsOnlineState; LocationSettings::OnlineAGpsState m_mlsOnlineState;
LocationSettings::OnlineAGpsState m_yandexLocatorOnlineState; LocationSettings::OnlineAGpsState m_yandexOnlineState;
LocationSettings::OnlineAGpsState m_hereState; LocationSettings::OnlineAGpsState m_hereState;
LocationSettings::LocationMode m_locationMode; LocationSettings::LocationMode m_locationMode;
bool m_settingLocationMode;
bool m_settingMultipleSettings; bool m_settingMultipleSettings;
QStringList m_pendingAgreements;
LocationSettings::DataSources m_allowedDataSources; LocationSettings::DataSources m_allowedDataSources;
NetworkManager *m_connMan; NetworkManager *m_connMan;
NetworkTechnology *m_gpsTech; NetworkTechnology *m_gpsTech;
...@@ -85,7 +86,6 @@ private slots: ...@@ -85,7 +86,6 @@ private slots:
void readSettings(); void readSettings();
void findGpsTech(); void findGpsTech();
void gpsTechPropertyChanged(const QString &propertyName, const QVariant &value); void gpsTechPropertyChanged(const QString &propertyName, const QVariant &value);
void recalculateLocationMode();
}; };
// TODO: replace this with DBus calls to a central settings service... // TODO: replace this with DBus calls to a central settings service...
......
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