From 9214e31b98d69d2c8ad56f8634345aeb98b234cc Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Thu, 5 Oct 2023 14:24:03 +0200 Subject: [PATCH] WIP call notifications --- libdino/src/service/notification_events.vala | 3 +- plugins/notification-sound/src/plugin.vala | 30 ++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/libdino/src/service/notification_events.vala b/libdino/src/service/notification_events.vala index 8771b5a9..c9f2647c 100644 --- a/libdino/src/service/notification_events.vala +++ b/libdino/src/service/notification_events.vala @@ -96,7 +96,8 @@ public class NotificationEvents : StreamInteractionModule, Object { } break; case CallItem.TYPE: - // handled in `on_call_incoming` + // Also handled in `on_call_incoming` + notify_content_item(item, conversation); break; } } diff --git a/plugins/notification-sound/src/plugin.vala b/plugins/notification-sound/src/plugin.vala index 081fd1c3..e014d106 100644 --- a/plugins/notification-sound/src/plugin.vala +++ b/plugins/notification-sound/src/plugin.vala @@ -8,9 +8,35 @@ public class Plugin : RootInterface, Object { public void registered(Dino.Application app) { this.app = app; Canberra.Context.create(out sound_context); + string sound_id = "", + description = "Unknown notification"; - app.stream_interactor.get_module(NotificationEvents.IDENTITY).notify_content_item.connect((item, conversation) => { - sound_context.play(0, Canberra.PROP_EVENT_ID, "message-new-instant", Canberra.PROP_EVENT_DESCRIPTION, "New Dino message"); + var? module = app.stream_interactor.get_module(NotificationEvents.IDENTITY); + + if (module == null) + return; + + module.notify_content_item.connect((item, conversation) => { + switch (item.type_) { + case MessageItem.TYPE: + description = "New Dino message"; + sound_id = "message-new-instant"; + break; + case CallItem.TYPE: + description = "Incoming call"; + sound_id = "phone-incoming-call"; + break; + case FileItem.TYPE: + description = "Incoming file"; + sound_id = "message-new-instant"; + break; + } + + sound_context.play(0, + Canberra.PROP_EVENT_ID, + sound_id, + Canberra.PROP_EVENT_DESCRIPTION, + description); }); }