[Devicenotifications Engine] Keep at most one notification per UDI
ClosedPublic

Authored by bruns on Oct 2 2018, 3:19 AM.

Details

Summary

Each notification was created as new datasource, and was newer removed
as long as the engine exists. This is especially bad for long living
applets like the device notifier. As there can only be one notification
per device (the last error state, or none), use the UDI as source name
and update the contents.

Also cancel (remove source) an old notifications in case of a successful
setup, otherwise old error messages are shown in the device notifier.

Test Plan

in Dolphin, select "Release" (context menu) for a mounted CD
-> Notification in device notifier appears "Device can be safely removed"
remount without ejecting
-> Notification message is removed, device shows "mounted" emblem.

Without the change, the message stayed and the device kept the notification
emblem "(!)".

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bruns created this revision.Oct 2 2018, 3:19 AM
Restricted Application added a project: Plasma. · View Herald TranscriptOct 2 2018, 3:19 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
bruns requested review of this revision.Oct 2 2018, 3:19 AM
broulik added a subscriber: broulik.Oct 2 2018, 7:20 AM

I think this makes sense

dataengines/devicenotifications/devicenotificationsengine.cpp
39

This potentially breaks applets relying on the structure of that name? Not sure how big of an issue this is as far as "API promise" we give for dataengines but perhaps at least keep the notification part first

dataengines/devicenotifications/devicenotificationsengine.h
26

Unused?

dataengines/devicenotifications/ksolidnotify.cpp
152

Move this into the relevant case below, please

bruns marked an inline comment as done.Oct 2 2018, 1:37 PM
bruns added inline comments.
dataengines/devicenotifications/devicenotificationsengine.cpp
39

The only user I could find is the device notifier, which relies on the contents of the container only for matching, and does not require any specific format for the source name.
Preferably we had some API documentation for the dataengines ...

dataengines/devicenotifications/devicenotificationsengine.h
26

yes, leftover from a different approach.

42

whitespace.

dataengines/devicenotifications/ksolidnotify.cpp
152

I considered this and did not because of the early return.
All the other cases just do a break and have a common return statement (more correctly, an emit notify(...)), this one differs.

broulik accepted this revision.Oct 2 2018, 2:00 PM
This revision is now accepted and ready to land.Oct 2 2018, 2:00 PM
This revision was automatically updated to reflect the committed changes.
bruns marked an inline comment as done.