Skip to content

Commit

Permalink
notification: Pass the desktop-id to the notification impl
Browse files Browse the repository at this point in the history
Notification implementers expects that the app-id is always matching the
application desktop-id, but while this is true for flatpaks is not true
for snaps, so include an extra desktop-id value the notification so that
can be used by the portals to properly implement actions and notify the
shell.
  • Loading branch information
3v1n0 committed Nov 2, 2022
1 parent 7d56375 commit bf0c70d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
14 changes: 13 additions & 1 deletion data/org.freedesktop.impl.portal.Notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@
the notification is replaced by the new one.
The format of the @notification is the same as for
org.freedesktop.portal.Notification.AddNotification().
org.freedesktop.portal.Notification.AddNotification() plus
these private meta-data keys (all optional):
<variablelist>
<varlistentry>
<term>desktop-id s</term>
<listitem>
<para>
The desktop ID of the application sending the notification.
This may me omitted in case the provided @app_id is matching it.
</para>
</listitem>
</varlistentry>
</variablelist>
-->
<method name="AddNotification">
<arg type="s" name="app_id" direction="in"/>
Expand Down
11 changes: 9 additions & 2 deletions src/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,19 @@ check_notification (GVariant *notification,
}

static GVariant *
maybe_remove_icon (GVariant *notification)
sanitize_notification (XdpAppInfo *app_info,
GVariant *notification)
{
const char *desktop_id;
GVariantBuilder n;
int i;

g_variant_builder_init (&n, G_VARIANT_TYPE_VARDICT);

desktop_id = xdp_app_info_get_desktop_id (app_info);
if (desktop_id && g_strcmp0 (xdp_app_info_get_id (app_info), desktop_id) != 0)
g_variant_builder_add (&n, "{sv}", "desktop-id", desktop_id);

for (i = 0; i < g_variant_n_children (notification); i++)
{
const char *key;
Expand Down Expand Up @@ -386,7 +393,7 @@ handle_add_in_thread_func (GTask *task,
id = (const char *)g_object_get_data (G_OBJECT (request), "id");
notification = (GVariant *)g_object_get_data (G_OBJECT (request), "notification");

notification2 = maybe_remove_icon (notification);
notification2 = sanitize_notification (request->app_info, notification);
xdp_dbus_impl_notification_call_add_notification (impl,
xdp_app_info_get_id (request->app_info),
id,
Expand Down

0 comments on commit bf0c70d

Please sign in to comment.