RFC: Introduce KClockSkewNotifier class
AbandonedPublic

Authored by zzag on Oct 14 2019, 10:51 AM.

Details

Reviewers
None
Group Reviewers
Frameworks
Summary

The new class provides a way for monitoring system clock changes. This
class can be useful for applications that build their logic around time,
for example dynamic wallpapers, so reacting to system clock changes is
quite crucial for them.

The new class can also be useful for Night Color in KWin and time data
engine as they two don't have support for FreeBSD. KClockSkewNotifier
also doesn't have support for FreeBSD at this moment, however when it
gains that, we'll have to patch only one place rather than two.

All good stuff happens in so called "notifier engines." A notifier
engine is responsible for detecting system clock changes and all
platform-specific code must reside there. KClockSkewNotifier is just a
thin wrapper around the corresponding engine, which is loaded and
unloaded as needed.

In long term, we need to add a couple more notifier engines. One for
Windows(?), one for FreeBSD(?), and one that doesn't use any platform
specific APIs but QTimer.

"KClockSkewNotifier" is not the best name. I'm open to suggestions.

Test Plan

No autotests because setting time requires root privileges.

Diff Detail

Repository
R244 KCoreAddons
Branch
kclockskewnotifier
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 21090
Build 21108: arc lint + arc unit
zzag created this revision.Oct 14 2019, 10:51 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptOct 14 2019, 10:51 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
zzag requested review of this revision.Oct 14 2019, 10:51 AM

We have similar code in plasma-workspace/dataengines/time

that has a faux BSD implementation by using a combination of the legacy, but working:

QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.connect(QString(), QString(), QStringLiteral("org.kde.KTimeZoned"), QStringLiteral("timeZoneChanged"), this, SLOT(tzConfigChanged()));

and equally legacy, but working

dbus.connect(QStringLiteral("org.kde.Solid.PowerManagement"),
             QStringLiteral("/org/kde/Solid/PowerManagement/Actions/SuspendSession"),
             QStringLiteral("org.kde.Solid.PowerManagement.Actions.SuspendSession"),
             QStringLiteral("resumingFromSuspend"),
             this,
             SLOT(clockSkewed()))

Obviously this doesn't cover all the cases (like some ntp service kicking in) but it's better than nothing.


AFAIK all the usecases above could use the existing dataengine, but I'm not against replacing dataengines with library code.

apol added a subscriber: apol.Oct 14 2019, 12:31 PM

It feels weird to create a class directly into KF5 when it hasn't even started to be used.
It could make sense to develop it within some of the apps and when we are sure the API is stable and it wants to be used on other components/products, we can promote it to the right framework.

zzag abandoned this revision.Oct 14 2019, 12:35 PM

Okay

zzag reclaimed this revision.Jan 6 2020, 8:25 PM

D25962 adds one usage of (K)ClockSkewNotifier in KWin.

zzag updated this revision to Diff 72993.Jan 7 2020, 3:54 PM

Rename signal.

zzag added a comment.Jan 7 2020, 4:31 PM

The KWin patch has landed. Can we proceed now?

zzag updated this revision to Diff 73158.Jan 9 2020, 10:29 PM

Build with older versions of glibc. See D26553

zzag updated this revision to Diff 73471.Jan 13 2020, 11:16 PM

Fix a typo.

zzag abandoned this revision.Apr 29 2022, 8:52 AM