From 408406e652bf7450d91661dcdd38be767c7faacd Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 8 Feb 2022 17:45:57 +0100 Subject: [PATCH] Let call notification say if it's a group call --- libdino/src/service/calls.vala | 15 +++++++++++---- libdino/src/service/notification_events.vala | 10 +++++----- .../ui/conversation_content_view/call_widget.vala | 4 ++++ main/src/ui/conversation_titlebar/call_entry.vala | 3 --- main/src/ui/notifier_freedesktop.vala | 5 ++++- main/src/ui/notifier_gnotifications.vala | 7 +++++-- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/libdino/src/service/calls.vala b/libdino/src/service/calls.vala index 7900824e..a77dcb79 100644 --- a/libdino/src/service/calls.vala +++ b/libdino/src/service/calls.vala @@ -7,7 +7,7 @@ namespace Dino { public class Calls : StreamInteractionModule, Object { - public signal void call_incoming(Call call, CallState state, Conversation conversation, bool video); + public signal void call_incoming(Call call, CallState state, Conversation conversation, bool video, bool multiparty); public signal void call_outgoing(Call call, CallState state, Conversation conversation); public signal void call_terminated(Call call, string? reason_name, string? reason_text); @@ -76,6 +76,8 @@ namespace Dino { } public async bool can_conversation_do_calls(Conversation conversation) { + if (!can_we_do_calls(conversation.account)) return false; + if (conversation.type_ == Conversation.Type.CHAT) { return (yield get_call_resources(conversation.account, conversation.counterpart)).size > 0 || has_jmi_resources(conversation.counterpart); } else { @@ -104,7 +106,9 @@ namespace Dino { if (full_jids == null) return ret; foreach (Jid full_jid in full_jids) { - bool supports_rtc = yield stream.get_module(Xep.JingleRtp.Module.IDENTITY).is_available(stream, full_jid); + var module = stream.get_module(Xep.JingleRtp.Module.IDENTITY); + if (module == null) return ret; + bool supports_rtc = yield module.is_available(stream, full_jid); if (!supports_rtc) continue; ret.add(full_jid); } @@ -236,7 +240,7 @@ namespace Dino { call_state.we_should_send_audio = true; if (call.direction == Call.DIRECTION_INCOMING) { - call_incoming(call, call_state, conversation, video_requested); + call_incoming(call, call_state, conversation, video_requested, false); } else { call_outgoing(call, call_state, conversation); } @@ -414,6 +418,7 @@ namespace Dino { if (from_jid.equals_bare(account.bare_jid)) return; if (stream_interactor.get_module(MucManager.IDENTITY).is_own_muc_jid(from_jid, account)) return; + bool multiparty = false; CallState? call_state = null; foreach (StanzaNode join_method_node in join_methods) { @@ -428,6 +433,8 @@ namespace Dino { if (room_jid_str == null) return; Jid room_jid = new Jid(room_jid_str); call_state = create_recv_muji_call(account, from_jid, room_jid, message_stanza.type_); + + multiparty = true; break; } else if (join_method_node.name == "jingle" && join_method_node.ns_uri == Xep.CallInvites.NS_URI) { @@ -463,7 +470,7 @@ namespace Dino { conversation.last_active = call_state.call.time; if (conversation == null) return; - call_incoming(call_state.call, call_state, conversation, video_requested); + call_incoming(call_state.call, call_state, conversation, video_requested, multiparty); }); call_invites_module.call_accepted.connect((from_jid, to_jid, call_id, message_type) => { CallState? call_state = get_call_state_by_call_id(account, call_id, from_jid, to_jid); diff --git a/libdino/src/service/notification_events.vala b/libdino/src/service/notification_events.vala index 5b8db842..8771b5a9 100644 --- a/libdino/src/service/notification_events.vala +++ b/libdino/src/service/notification_events.vala @@ -30,8 +30,8 @@ public class NotificationEvents : StreamInteractionModule, Object { stream_interactor.get_module(MucManager.IDENTITY).invite_received.connect((account, room_jid, from_jid, password, reason) => on_invite_received.begin(account, room_jid, from_jid, password, reason)); stream_interactor.get_module(MucManager.IDENTITY).voice_request_received.connect((account, room_jid, from_jid, nick) => on_voice_request_received.begin(account, room_jid, from_jid, nick)); - stream_interactor.get_module(Calls.IDENTITY).call_incoming.connect((call, state, conversation, video) => on_call_incoming.begin(call, state, conversation, video)); - stream_interactor.connection_manager.connection_error.connect((account, error) => on_connection_error(account, error)); + stream_interactor.get_module(Calls.IDENTITY).call_incoming.connect((call, state, conversation, video, multiparty) => on_call_incoming.begin(call, state, conversation, video, multiparty)); + stream_interactor.connection_manager.connection_error.connect((account, error) => on_connection_error.begin(account, error)); stream_interactor.get_module(ChatInteraction.IDENTITY).focused_in.connect((conversation) => on_focused_in.begin(conversation)); notifier_promise = new Promise(); @@ -117,12 +117,12 @@ public class NotificationEvents : StreamInteractionModule, Object { yield notifier.notify_subscription_request(conversation); } - private async void on_call_incoming(Call call, CallState call_state, Conversation conversation, bool video) { + private async void on_call_incoming(Call call, CallState call_state, Conversation conversation, bool video, bool multiparty) { if (!stream_interactor.get_module(Calls.IDENTITY).can_we_do_calls(call.account)) return; string conversation_display_name = get_conversation_display_name(stream_interactor, conversation, null); NotificationProvider notifier = yield notifier.wait_async(); - yield notifier.notify_call(call, conversation, video, conversation_display_name); + yield notifier.notify_call(call, conversation, video, multiparty, conversation_display_name); call.notify["state"].connect(() => { if (call.state != Call.State.RINGING) { notifier.retract_call_notification.begin(call, conversation); @@ -160,7 +160,7 @@ public interface NotificationProvider : Object { public abstract async void notify_message(Message message, Conversation conversation, string conversation_display_name, string? participant_display_name); public abstract async void notify_file(FileTransfer file_transfer, Conversation conversation, bool is_image, string conversation_display_name, string? participant_display_name); - public abstract async void notify_call(Call call, Conversation conversation, bool video, string conversation_display_name); + public abstract async void notify_call(Call call, Conversation conversation, bool video, bool multiparty, string conversation_display_name); public abstract async void retract_call_notification(Call call, Conversation conversation); public abstract async void notify_subscription_request(Conversation conversation); public abstract async void notify_connection_error(Account account, ConnectionManager.ConnectionError error); diff --git a/main/src/ui/conversation_content_view/call_widget.vala b/main/src/ui/conversation_content_view/call_widget.vala index d9060872..e45792e2 100644 --- a/main/src/ui/conversation_content_view/call_widget.vala +++ b/main/src/ui/conversation_content_view/call_widget.vala @@ -124,7 +124,11 @@ namespace Dino.Ui { image.set_from_icon_name("dino-phone-ring-symbolic", IconSize.LARGE_TOOLBAR); if (call.direction == Call.DIRECTION_INCOMING) { bool video = call_manager.should_we_send_video(); + title_label.label = video ? _("Incoming video call") : _("Incoming call"); + if (call_manager.invited_to_group_call != null) { + title_label.label = video ? _("Incoming video group call") : _("Incoming group call"); + } if (stream_interactor.get_module(Calls.IDENTITY).can_we_do_calls(call.account)) { subtitle_label.label = "Ring ring…!"; diff --git a/main/src/ui/conversation_titlebar/call_entry.vala b/main/src/ui/conversation_titlebar/call_entry.vala index e5b7281c..1b8b2a05 100644 --- a/main/src/ui/conversation_titlebar/call_entry.vala +++ b/main/src/ui/conversation_titlebar/call_entry.vala @@ -84,9 +84,6 @@ namespace Dino.Ui { stream_interactor.connection_manager.connection_state_changed.connect((account, state) => { update_visibility.begin(); }); - Dino.Application.get_default().plugin_registry.video_call_plugin.devices_changed.connect((media, incoming) => { - update_visibility.begin(); - }); } private void open_call_window(CallState call_state) { diff --git a/main/src/ui/notifier_freedesktop.vala b/main/src/ui/notifier_freedesktop.vala index 17de0ce9..b6b31d34 100644 --- a/main/src/ui/notifier_freedesktop.vala +++ b/main/src/ui/notifier_freedesktop.vala @@ -107,10 +107,13 @@ public class Dino.Ui.FreeDesktopNotifier : NotificationProvider, Object { } } - public async void notify_call(Call call, Conversation conversation, bool video, string conversation_display_name) { + public async void notify_call(Call call, Conversation conversation, bool video, bool multiparty, string conversation_display_name) { debug("[%s] Call notification", call.account.bare_jid.to_string()); string summary = Markup.escape_text(conversation_display_name); string body = video ? _("Incoming video call") : _("Incoming call"); + if (multiparty) { + body = video ? _("Incoming video group call") : _("Incoming group call"); + } HashTable hash_table = new HashTable(null, null); hash_table["image-path"] = "call-start-symbolic"; diff --git a/main/src/ui/notifier_gnotifications.vala b/main/src/ui/notifier_gnotifications.vala index 665d47c4..d569a358 100644 --- a/main/src/ui/notifier_gnotifications.vala +++ b/main/src/ui/notifier_gnotifications.vala @@ -65,9 +65,12 @@ namespace Dino.Ui { } } - public async void notify_call(Call call, Conversation conversation, bool video, string conversation_display_name) { + public async void notify_call(Call call, Conversation conversation, bool video, bool multiparty, string conversation_display_name) { Notification notification = new Notification(conversation_display_name); - string body = _("Incoming call"); + string body = video ? _("Incoming video call") : _("Incoming call"); + if (multiparty) { + body = video ? _("Incoming video group call") : _("Incoming group call"); + } notification.set_body(body); notification.set_urgent(true);