From 8b473c890b74f5aed835db097b6eb3d03bef6a08 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 8 Feb 2022 22:04:36 +0100 Subject: Call Invite Message: Send 'finished' messages, include reasons --- xmpp-vala/src/module/xep/0353_call_invite_message.vala | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'xmpp-vala/src/module/xep') diff --git a/xmpp-vala/src/module/xep/0353_call_invite_message.vala b/xmpp-vala/src/module/xep/0353_call_invite_message.vala index e0e95058..bc74ba2c 100644 --- a/xmpp-vala/src/module/xep/0353_call_invite_message.vala +++ b/xmpp-vala/src/module/xep/0353_call_invite_message.vala @@ -10,6 +10,7 @@ namespace Xmpp.Xep.CallInvites { public signal void call_retracted(Jid from, Jid to, string call_id, string message_type); public signal void call_accepted(Jid from, Jid to, string call_id, string message_type); public signal void call_rejected(Jid from, Jid to, string call_id, string message_type); + public signal void call_left(Jid from, Jid to, string call_id, string message_type); public string send_jingle_propose(XmppStream stream, Jid invitee, string sid, bool video) { StanzaNode jingle_node = new StanzaNode.build("jingle", CallInvites.NS_URI) @@ -37,19 +38,24 @@ namespace Xmpp.Xep.CallInvites { } public void send_retract(XmppStream stream, Jid to, string call_id, string message_type) { - send_message(stream, "retract", to, call_id, message_type); + send_message(stream, to, call_id, "retract", "cancel", message_type); } public void send_accept(XmppStream stream, Jid to, string call_id, string message_type) { - send_message(stream, "accept", to, call_id, message_type); + send_message(stream, to, call_id, "accept", null, message_type); } public void send_reject(XmppStream stream, Jid to, string call_id, string message_type) { - send_message(stream, "reject", to, call_id, message_type); + send_message(stream, to, call_id, "reject", "busy", message_type); } - private void send_message(XmppStream stream, string action, Jid to, string call_id, string message_type) { + public void send_finish(XmppStream stream, Jid to, string call_id, string message_type) { + send_message(stream, to, call_id, "finish", "success", message_type); + } + + private void send_message(XmppStream stream, Jid to, string call_id, string action, string? reason, string message_type) { StanzaNode inner_node = new StanzaNode.build(action, NS_URI).add_self_xmlns().put_attribute("id", call_id); + if (reason != null) inner_node.put_node(new StanzaNode.build("reason", NS_URI).put_node(new StanzaNode.build(reason, NS_URI))); MessageStanza message = new MessageStanza() { to=to, type_=message_type }; message.stanza.put_node(inner_node); MessageProcessingHints.set_message_hint(message, MessageProcessingHints.HINT_STORE); @@ -90,6 +96,9 @@ namespace Xmpp.Xep.CallInvites { case "reject": call_rejected(message.from, message.to, call_id, message.type_); break; + case "finish": + call_left(message.from, message.to, call_id, message.type_); + break; } } -- cgit v1.2.3-70-g09d2