Commit b9b07485 authored by chriadam's avatar chriadam

Merge branch 'jb33753' into 'master'

[systemsettings] Expose LocationMode. Contributes to JB#33753

See merge request mer-core/nemo-qml-plugin-systemsettings!95
parents e588cc1f 91b7e29e
......@@ -28,6 +28,7 @@ BuildRequires: pkgconfig(libsailfishkeyprovider) >= 0.0.14
BuildRequires: pkgconfig(connman-qt5) >= 1.2.7
BuildRequires: pkgconfig(ssu-sysinfo) >= 1.1.0
BuildRequires: pkgconfig(packagekitqt5)
BuildRequires: pkgconfig(glib-2.0)
%description
%{summary}.
......
This diff is collapsed.
......@@ -38,6 +38,8 @@
#include <QObject>
#include <QString>
#define LOCATION_SETTINGS_LAST_DATA_SOURCE_BIT 31
class LocationSettingsPrivate;
class SYSTEMSETTINGS_EXPORT LocationSettings : public QObject
{
......@@ -56,7 +58,12 @@ class SYSTEMSETTINGS_EXPORT LocationSettings : public QObject
Q_PROPERTY(OnlineAGpsState mlsOnlineState READ mlsOnlineState WRITE setMlsOnlineState NOTIFY mlsOnlineStateChanged)
Q_PROPERTY(bool mlsAvailable READ mlsAvailable 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(LocationMode)
public:
enum Mode {
......@@ -93,6 +100,43 @@ public:
void setMlsOnlineState(OnlineAGpsState state);
bool mlsAvailable() const;
enum LocationMode {
HighAccuracyMode,
BatterySavingMode,
DeviceOnlyMode,
CustomMode
};
LocationMode locationMode() const;
void setLocationMode(LocationMode locationMode);
// Data sources are grouped roughly by type,
// with gaps left for future expansion.
enum DataSource {
NoDataSources = 0UL,
OnlineDataSources = 1UL << 0,
DeviceSensorsData = 1UL << 5,
BluetoothData = 1UL << 10,
WlanData = 1UL << 15,
CellTowerData = 1UL << 20,
GpsData = 1UL << 25,
GlonassData = 1UL << 26,
BeidouData = 1UL << 27,
GalileoData = 1UL << 28,
QzssData = 1UL << 29,
SbasData = 1UL << 30,
LastDataSource = 1UL << LOCATION_SETTINGS_LAST_DATA_SOURCE_BIT
};
Q_DECLARE_FLAGS(DataSources, DataSource)
Q_FLAG(DataSources)
DataSources allowedDataSources() const;
void setAllowedDataSources(DataSources dataSources);
signals:
void hereStateChanged();
void locationEnabledChanged();
......@@ -100,6 +144,8 @@ signals:
void gpsFlightModeChanged();
void mlsEnabledChanged();
void mlsOnlineStateChanged();
void locationModeChanged();
void allowedDataSourcesChanged();
private:
LocationSettingsPrivate *d_ptr;
......@@ -107,4 +153,6 @@ private:
Q_DECLARE_PRIVATE(LocationSettings)
};
Q_DECLARE_OPERATORS_FOR_FLAGS(LocationSettings::DataSources)
#endif // LOCATIONSETTINGS_H
......@@ -41,6 +41,8 @@
#include <sailfishkeyprovider_processmutex.h>
#include <glib.h>
#include "locationsettings.h"
class NetworkManager;
......@@ -56,23 +58,52 @@ public:
LocationSettingsPrivate(LocationSettings::Mode mode, LocationSettings *settings);
~LocationSettingsPrivate();
LocationSettings::LocationMode calculateLocationMode() const;
void writeSettings();
bool mlsAvailable() const;
bool hereAvailable() const;
QFileSystemWatcher m_watcher;
bool m_locationEnabled;
bool m_gpsEnabled;
bool m_mlsEnabled;
LocationSettings::OnlineAGpsState m_mlsOnlineState;
LocationSettings::OnlineAGpsState m_hereState;
LocationSettings::LocationMode m_locationMode;
bool m_settingLocationMode;
bool m_settingMultipleSettings;
LocationSettings::DataSources m_allowedDataSources;
NetworkManager *m_connMan;
NetworkTechnology *m_gpsTech;
QDBusInterface *m_gpsTechInterface;
mutable QScopedPointer<Sailfish::KeyProvider::ProcessMutex> m_processMutex;
private slots:
void readSettings();
void findGpsTech();
void gpsTechPropertyChanged(const QString &propertyName, const QVariant &value);
void recalculateLocationMode();
};
// TODO: replace this with DBus calls to a central settings service...
class IniFile
{
public:
IniFile(const QString &fileName);
~IniFile();
bool isValid() const;
bool readBool(const QString &section, const QString &key, bool *value, bool defaultValue = false);
void writeBool(const QString &section, const QString &key, bool value);
void writeString(const QString &section, const QString &key, const QString &value);
private:
mutable QScopedPointer<Sailfish::KeyProvider::ProcessMutex> m_processMutex;
QString m_fileName;
GKeyFile *m_keyFile;
GError *m_error;
bool m_modified;
bool m_valid;
};
#endif // NEMO_SYSTEMSETTINGS_LOCATIONSETTINGS_P_H
......@@ -6,7 +6,7 @@ QT += qml dbus systeminfo
QT -= gui
CONFIG += c++11 hide_symbols link_pkgconfig
PKGCONFIG += profile mlite5 mce timed-qt5 libshadowutils blkid libcrypto nemomodels-qt5 libsailfishkeyprovider connman-qt5
PKGCONFIG += profile mlite5 mce timed-qt5 libshadowutils blkid libcrypto nemomodels-qt5 libsailfishkeyprovider connman-qt5 glib-2.0
PKGCONFIG += ssu-sysinfo nemodbus packagekitqt5
system(qdbusxml2cpp -p mceiface.h:mceiface.cpp mce.xml)
......
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