New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement v2 notification spec #1298
base: main
Are you sure you want to change the base?
Conversation
What is the case for letting an app play a sound freely? In the discussion there was talk of linking sound playback to specific cases, e.g. alarm, new message, new email. Also, it seems to me that the question of custom sounds versus system sounds still needs to be resolved for these example cases, unless there is a valid case to allow an app to play sound freely. |
It's not that apps are allowed to play sound freely, they are allowed to set it. The server may decided whether to play the sound. In GNOME Shell we have a policy system that controls whether a notification can have a sound or not.
I think this doesn't need to be exclusive and I don't see how it would conflict with class specific sounds.
Apps already can play any sound if they have the correct sandbox permission. So we prefer that apps use the notification sound so that the system policy can be respected e.g. do-not-disturb. Although, we may want to restrict the type and length of the sound a notification can have. |
What is driving me nuts in the freedesktop notification spec is that there's no way to know that system sounds are supported and which music formats are supported for custom sounds. This made the sound spec part just unusable when I attempted to play sound with it:
This resulted in application always playing the notification sound on its own. I really hope these problems will be solved in the new API. |
eae298c
to
6cb0d0b
Compare
1c893d7
to
9c11013
Compare
Adding a notification may fail, instead of waiting for the timeout we can check the result we get in the callback.
For debugging it's important that the backend doesn't just crash without telling the reason. It would be even nicer if the test would fail immediately instead of hitting the timeout, but that' currently not possible since the client doesn't know whether the backend failed.
We can reuse most of the test setup for all tests. This will make it easier to test more properties.
This filters unsupported properties from a notification request without failing it. This allows backwards compatibility after adding new properties. This should had been the case from the beginning so that we don't have to break API when extending the notification interface. See [1]. [1] https://dbus.freedesktop.org/doc/dbus-api-design.html#extensibility
This allows setting a custom path for the icon validator, especially useful when testing without installing.
The sandbox for the icon-validator needs a privileged container. And it needs librsvg to be able to validate SVGs.
If debug messages are turned on the output of validate-icon isn't a valid key file since it contains log output as well.
9c11013
to
60db472
Compare
I think one thing to check is if there are static permissions that can help apps guess what mode the device is in (sound, vibration, silent, DND). For example, alarms will certainly be allowed by users, because they are logically important to them. In fact, apps that will use alarm notifications will be able to play sound (because in any mode you cannot completely mute the sound, unless it can be done selectively without dynamic permission), but especially to present a notification (even more so if this is also not constrained by specific experience and actions). |
5705ffc
to
049806c
Compare
@pwithnall thanks for the review :) |
049806c
to
fc2483f
Compare
GString *composed = user_data; | ||
gchar *str = (gchar *) text; | ||
|
||
while (*str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like this entire function (its hard to tell what it is trying to achieve) but i don't have a good suggestion either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to remove new lines and replace them with a space, without introducing multiple spaces.
@@ -171,6 +171,21 @@ | |||
* ``target`` (``v``) | |||
Target parameter to send along when activating the action. | |||
* ``desktop-file-id`` (``s``) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really doubt this is a good idea. The portal should be able to determine the app id and fetch the desktop file based on that. What are you trying to accomplish here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tries to solve the following:
- The current API can't really be used outside of flatpak, because there isn't a reliable why to get the app id.
- A single flatpak may export multiple desktop files and there isn't any way how the portal can know which desktop-file-id should be used for D-Bus activation, app name and icon.
Still have to look at the sound validator but I'm through with everything else. |
fc2483f
to
fed1cdd
Compare
Thanks for the review. I think i addressed everything. |
This is the list of options that can be used as `purpose` for `buttons`. | ||
--> | ||
<property name="SupportedOptions" type="a{sv}" access="read"/> | ||
|
||
<!-- | ||
ActionInvoked: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is modeled after org.freedesktop.Application.ActivateAction
. Shouldn't this also split out the platform_data into its own argument instead of sending it in the @parameter
array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice, but doesn't that break backwards compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, true, but you could always add a ActionInvoked2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i prefer to not have a second signal. I think it's not too bad to have as a second value in @parameter
. Honestly i would like this signal not to exist at all :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a second signal would be better. Adding a new value into parameter
may count as an API break anyway, because user code may be strictly validating the parameter
they receive, and not expect an additional entry in the av
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would that count as an API break? It's defined as a av
already. And it doesn't say anywhere that there is only one value set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, does this parameter
not match the parameter
of a GAction
? Or does it just look similar but have different semantics? Reading the rest of the spec it looks like parameter
is actually just a dumping ground for vaguely-typed response data? Typically an a{sv}
with well-defined-but-extensible keys would be used for this in a D-Bus API, but changing to that would definitely be an API break (or require a new signal).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, does this parameter not match the parameter of a GAction?
No, it doesn't match. The GAction parameter
or actually target
is placed in the parameter array. It just looks similar.
The current specs don't even say that it will be the first value in the parameter argument:
array which will contain the target parameter for the action, if one was specified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having two similar but slightly different interfaces will be really confusing. Having a ActionInvoked2
which matches the arguments from org.freedesktop.Application.ActivateAction
would be an improvement (and we could add a a{sv}
just for good measure).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having two similar but slightly different interfaces will be really confusing.
You mean org.freedesktop.Application.ActivateAction
and the ActionInvoked
signal?
The two different interfaces are pretty much never used in the same application. I think it may be a little confusing (but already having the two is confusing enough), and requiring applications, or client libs, to implement a third interface may be even more confusing, since they need to support version one 1 the interface.
I agree it's sub optimal but i strongly think that adding a ActionInvoked2
creates unnecessary extra work for applications (or client libraries).
This property allows applications to specify a sound to be played whenever the notification is displayed. The format used is inspired by the serialized from of GIcons.
The `markup-body` property allows applications to set markup on the body. The used markup is a subset of html limted to <b>, <i> and <a>.
The `desktop-file-id` allows applications to specify the desktop file that should be used to look up information about the app. This is especially useful for unsandboxed apps where the portal can't look up the desktop file id based on the app id.
This property allows apps to specify how the notification is displayed.
We need to hand out the activation token for XDG Activation in some way. I think it's pretty nice that we can just add the same platform data as used for DBus Activation to the ActionInvoked signal.
The category allows the notification server to handle specific notification different. E.g. calls notifications.
The purpose for a button allows the notification server to style the button specially and know the purpose of the button.
Let applications query supported options for category and button purpose.
fed1cdd
to
3ad1832
Compare
After lot of consideration I started implementing parts of the proposed and discussed notification API
For now this includes:
desktop-file-id
propertymarkup-body
propertydisplay-hint
propertynew actions, similar to buttons (the name may be a little confusing, open for suggestions)Part of buttons nowcontent-typecategory
propertycontent-typecategory
,action purposeand button purpose APIThis needs changes in libportal flatpak/libportal#147 for tests.
I also started writing the changes needed in xdg-desktop-portal-gtk: https://github.com/jsparber/xdg-desktop-portal-gtk/tree/implement_notification_v2 and other portal backends need to do the same thing.
Parts that didn't made it from #1304 into this MR may be added it a later revision of the portal.
Fixes: #485