Commit a9bd6b4a authored by Roman Gilg's avatar Roman Gilg

[libcolorcorrect] Send auto location updates only when desirable

Instead of always sending auto location updates through our daemon query
the current running and mode states of KWin and only send it when running
is true and mode is zero, i.e. automatic location and time updates.

This is primarily meant as an improvement for deployments in sensitive
operation areas, where connections to external sources (even like in our
case anonymously via mozilla location service or if available gps) might
be unwanted.

Another future improvement might be to only launch the daemon on demand,
i.e. let KWin ask for this via dbus through KDED's functionality when
automatic mode is activated (either at startup or per config change).

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9352
parent d3434a2d
......@@ -122,6 +122,8 @@ bool CompositorAdaptor::resetData(QHash<QString, QVariant> data)
SETTER(m_activeEnabled, data["ActiveEnabled"].toBool(), activeEnabledChanged())
SETTER(m_active, data["Active"].toBool(), activeChanged())
SETTER(m_running, data["Running"].toBool(), runningChanged())
SETTER(m_mode, (Mode)data["Mode"].toInt(), modeChanged())
SETTER(m_nightTemperatureEnabled, data["NightTemperatureEnabled"].toBool(), nightTemperatureEnabledChanged())
......
......@@ -46,6 +46,8 @@ class COLORCORRECT_EXPORT CompositorAdaptor : public QObject
Q_PROPERTY(bool activeStaged READ activeStaged WRITE setActiveStaged NOTIFY activeStagedChanged)
Q_PROPERTY(bool activeDefault READ activeDefault CONSTANT)
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
Q_PROPERTY(bool modeEnabled READ modeEnabled NOTIFY modeEnabledChanged)
Q_PROPERTY(int mode READ mode NOTIFY modeChanged)
Q_PROPERTY(int modeStaged READ modeStaged WRITE setModeStaged NOTIFY modeStagedChanged)
......@@ -146,6 +148,10 @@ public:
return true;
}
bool running() {
return m_running;
}
bool modeEnabled() const {
return m_modeEnabled;
}
......@@ -387,6 +393,9 @@ Q_SIGNALS:
void activeEnabledChanged();
void activeChanged();
void activeStagedChanged();
void runningChanged();
void modeEnabledChanged();
void modeChanged();
void modeStagedChanged();
......@@ -434,6 +443,8 @@ private:
bool m_active = false;
bool m_activeStaged = false;
bool m_running = false;
bool m_modeEnabled = true;
Mode m_mode = Mode::ModeAutomatic;
Mode m_modeStaged = Mode::ModeAutomatic;
......
......@@ -30,8 +30,23 @@ LocationUpdater::LocationUpdater(QObject *parent, const QList<QVariant> &)
: KDEDModule(parent)
{
m_adaptor = new ColorCorrect::CompositorAdaptor(this);
m_locator = new ColorCorrect::Geolocator(this);
connect(m_locator, &ColorCorrect::Geolocator::locationChanged, this, &LocationUpdater::sendLocation);
connect(m_adaptor, &ColorCorrect::CompositorAdaptor::dataUpdated, this,
&LocationUpdater::resetLocator);
resetLocator();
}
void LocationUpdater::resetLocator()
{
if (m_adaptor->running() && m_adaptor->mode() == 0) {
if (!m_locator) {
m_locator = new ColorCorrect::Geolocator(this);
connect(m_locator, &ColorCorrect::Geolocator::locationChanged, this,
&LocationUpdater::sendLocation);
}
} else {
delete m_locator;
m_locator = nullptr;
}
}
void LocationUpdater::sendLocation(double latitude, double longitude)
......
......@@ -35,8 +35,10 @@ public Q_SLOTS:
void sendLocation(double latitude, double longitude);
private:
ColorCorrect::CompositorAdaptor *m_adaptor;
ColorCorrect::Geolocator *m_locator;
void resetLocator();
ColorCorrect::CompositorAdaptor *m_adaptor = nullptr;
ColorCorrect::Geolocator *m_locator = nullptr;
};
#endif
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