korgac: honour notification inhibition by delaying reminders
ClosedPublic

Authored by dfaure on Nov 19 2019, 12:00 PM.

Details

Summary

Or in layman terms, don't pop up reminders during a presentation.

Plasma has a "do not disturb" setting (which is even automatically
enabled when mirroring the screen onto a projector), and that setting is
available via a property in a freedesktop notifications interface.

The code is in alarmdialog rather than alarmclient because the "suspend"
code is in alarmdialog and calls wakeUp() directly.

Test Plan
  • Create event in korganizer with reminder in 2 minutes
  • Enable "do not disturb" mode in Plasma (Notifications systray icon)
  • Wait for > 2 minutes, no reminder
  • Disable "do not disturb" mode
  • The reminder shows immediately
  • Click Suspend for 1 minute
  • Enable "do not disturb" again
  • Wait for > 1 minute, no reminder
  • Disable "do not disturb" mode
  • The reminder shows immediately

Diff Detail

Repository
R210 KOrganizer
Branch
release/19.12
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 18947
Build 18965: arc lint + arc unit
dfaure created this revision.Nov 19 2019, 12:00 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptNov 19 2019, 12:00 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
dfaure requested review of this revision.Nov 19 2019, 12:00 PM

lgtm

korgac/alarmdialog.cpp
794

This blocks.

What happens when the "inhibited" property doesn't exist? Will it return a default-constructed (false)?

dfaure added inline comments.
korgac/alarmdialog.cpp
794

Something's really weird. If I kill plasmashell, then this blocks for 25 seconds (and then returns false indeed).

That timeout is reproducible on the command-line, qdbus org.freedesktop.Notifications blocks for 25s when plasma isn't running. I found why:

/usr/share/dbus/services/org.kde.plasma.Notifications.service says

[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=/usr/bin/plasma_waitforname org.freedesktop.Notifications

This looks like an awful hack to me. It only makes sense if plasma is currently starting, but otherwise, it will just block for 25s for no purpose.
DBus activation is meant to actually start the process which will register under that name, not just wait and hope...

I could work around it by making this code non-blocking, but it would still delay all notifications by 25 seconds, and probably output warnings about dbus timeouts. I would say this org.kde.plasma.Notifications.service file is an unrelated issue affecting all users of org.freedesktop.Notifications.

Thank you David.
I'm very much in favor of this once you have the blocking figured-out.

Something's really weird. If I kill plasmashell, then this blocks for 25 seconds (and then returns false indeed).

Ooooh, yeah, we have some "plasma-waitforname" script that is autostarted by dbus when notification service is called. This is so apps sending notifications before plasma is up on login don't end up showing ontop of the splash screen and whatever. But also causes this annoying behavior. You could check QDBusConnectionInterface::isServiceRegistered before calling into it.

@davidedmundson any way to restrict dbus autolaunch to certain methods?

Good idea, I'll use isServiceRegistered to avoid DBus activation which is definitely not wanted here.
This is actually the answer (AFAIK) to your question for davidedmundson - unguarded calls *will* activate (i.e. autostart) services, isServiceRegistered is the way to avoid it.

With that in, I don't think the blocking call is an issue. If Plasma blocks for a long time we have bigger problems than a slightly delayed reminder.

If Plasma blocks for a long time we have bigger problems than a slightly delayed reminder.

The service isn't neccessarily owned by Plasmashell. There's alternative services, such as Dunst. That inhibited property is non-standard but when not present I think it will just return false which is desired here.

Right. That won't block for long either.

dfaure updated this revision to Diff 69994.Nov 19 2019, 2:01 PM

Check that the fdo service is up, to avoid triggering DBus activation

Two +1 = one +2, like in Qt? ;-)

broulik accepted this revision.Nov 20 2019, 4:32 PM
This revision is now accepted and ready to land.Nov 20 2019, 4:32 PM
dfaure closed this revision.Nov 20 2019, 9:37 PM