Call Invite Message: Send 'finished' messages, include reasons

This commit is contained in:
fiaxh 2022-02-08 22:04:36 +01:00
parent 43ea088f64
commit 8b473c890b
4 changed files with 42 additions and 17 deletions

View file

@ -97,6 +97,10 @@ public class Dino.PeerState : Object {
} }
public async void call_resource(Jid full_jid) { public async void call_resource(Jid full_jid) {
if (!call_state.accepted) {
warning("Tried to call resource in an unaccepted call?!");
return;
}
XmppStream? stream = stream_interactor.get_stream(call.account); XmppStream? stream = stream_interactor.get_stream(call.account);
if (stream == null) return; if (stream == null) return;

View file

@ -130,6 +130,11 @@ public class Dino.CallState : Object {
foreach (PeerState peer in peers_cpy) { foreach (PeerState peer in peers_cpy) {
peer.end(Xep.Jingle.ReasonElement.SUCCESS, reason_text); peer.end(Xep.Jingle.ReasonElement.SUCCESS, reason_text);
} }
if (use_cim) {
XmppStream stream = stream_interactor.get_stream(call.account);
if (stream == null) return;
stream.get_module(Xep.CallInvites.Module.IDENTITY).send_finish(stream, cim_counterpart, cim_call_id, cim_message_type);
}
call.state = Call.State.ENDED; call.state = Call.State.ENDED;
} else if (call.state == Call.State.RINGING) { } else if (call.state == Call.State.RINGING) {
foreach (PeerState peer in peers_cpy) { foreach (PeerState peer in peers_cpy) {

View file

@ -83,9 +83,7 @@ namespace Dino {
} else { } else {
bool is_private = stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart); bool is_private = stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart);
EntityInfo entity_info = stream_interactor.get_module(EntityInfo.IDENTITY); EntityInfo entity_info = stream_interactor.get_module(EntityInfo.IDENTITY);
bool supports_ussid = yield entity_info.has_feature(conversation.account, conversation.counterpart.bare_jid, Xep.UniqueStableStanzaIDs.NS_URI); return is_private && can_initiate_groupcall(conversation.account);
bool supports_mam = yield entity_info.has_feature(conversation.account, conversation.counterpart.bare_jid, Xep.MessageArchiveManagement.NS_URI_2);
return is_private && (supports_ussid || supports_mam) && can_initiate_groupcall(conversation.account);
} }
} }
@ -261,7 +259,6 @@ namespace Dino {
} }
} }
} }
if (call_state.invited_to_group_call != null && call_state.invited_to_group_call.equals(relevant_jid)) return call_state;
} }
return null; return null;
} }
@ -369,15 +366,20 @@ namespace Dino {
if (peer_state == null) return; if (peer_state == null) return;
Call call = peer_state.call; Call call = peer_state.call;
if (from.equals_bare(account.bare_jid)) { // Carboned message from our account // Carboned message from our account
if (from.equals_bare(account.bare_jid)) {
// Ignore carbon from ourselves // Ignore carbon from ourselves
if (from.equals(account.full_jid)) return; if (from.equals(account.full_jid)) return;
call.ourpart = from; call.ourpart = from;
call.state = Call.State.OTHER_DEVICE; call.state = Call.State.OTHER_DEVICE;
remove_call_from_datastructures(call); remove_call_from_datastructures(call);
} else if (from.equals_bare(peer_state.jid) && to.equals(account.full_jid)) { // Message from our peer return;
// We proposed the call }
// We proposed the call. This is a message from our peer.
if (call.direction == Call.DIRECTION_OUTGOING &&
from.equals_bare(peer_state.jid) && to.equals(account.full_jid)) {
// We know the full jid of our peer now // We know the full jid of our peer now
call_states[call].rename_peer(jmi_request_peer[call].jid, from); call_states[call].rename_peer(jmi_request_peer[call].jid, from);
jmi_request_peer[call].call_resource.begin(from); jmi_request_peer[call].call_resource.begin(from);
@ -477,7 +479,8 @@ namespace Dino {
if (call_state == null) return; if (call_state == null) return;
Call call = call_state.call; Call call = call_state.call;
if (from_jid.equals_bare(account.bare_jid)) { // Carboned message from our account // Carboned message from our account
if (from_jid.equals_bare(account.bare_jid)) {
// Ignore carbon from ourselves // Ignore carbon from ourselves
if (from_jid.equals(account.full_jid)) return; if (from_jid.equals(account.full_jid)) return;
@ -485,10 +488,14 @@ namespace Dino {
call.ourpart = from_jid; call.ourpart = from_jid;
call.state = Call.State.OTHER_DEVICE; call.state = Call.State.OTHER_DEVICE;
remove_call_from_datastructures(call); remove_call_from_datastructures(call);
} else if (to_jid.equals(account.full_jid)) { // Message from our peer return;
// We proposed the call }
// We proposed the call. This is a message from our peer.
if (call.direction == Call.DIRECTION_OUTGOING &&
to_jid.equals(account.full_jid)) {
// We know the full jid of our peer now // We know the full jid of our peer now
call_states[call].rename_peer(jmi_request_peer[call].jid, from_jid); call_state.rename_peer(jmi_request_peer[call].jid, from_jid);
jmi_request_peer[call].call_resource.begin(from_jid); jmi_request_peer[call].call_resource.begin(from_jid);
} }
}); });
@ -509,9 +516,9 @@ namespace Dino {
call_state.call.state = Call.State.MISSED; call_state.call.state = Call.State.MISSED;
remove_call_from_datastructures(call_state.call); remove_call_from_datastructures(call_state.call);
}); });
call_invites_module.call_rejected.connect((from_jid, to_jid, muc_jid, message_type) => { call_invites_module.call_rejected.connect((from_jid, to_jid, call_id, message_type) => {
if (from_jid.equals_bare(account.bare_jid)) return; if (from_jid.equals_bare(account.bare_jid)) return;
debug(@"[%s] %s rejected our MUJI invite to %s", account.bare_jid.to_string(), from_jid.to_string(), muc_jid.to_string()); debug(@"[%s] %s rejected our MUJI invite", account.bare_jid.to_string(), from_jid.to_string());
}); });
stream_interactor.module_manager.get_module(account, Xep.Coin.Module.IDENTITY).coin_info_received.connect((jid, info) => { stream_interactor.module_manager.get_module(account, Xep.Coin.Module.IDENTITY).coin_info_received.connect((jid, info) => {

View file

@ -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_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_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_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) { public string send_jingle_propose(XmppStream stream, Jid invitee, string sid, bool video) {
StanzaNode jingle_node = new StanzaNode.build("jingle", CallInvites.NS_URI) 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) { 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) { 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) { 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); 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 }; MessageStanza message = new MessageStanza() { to=to, type_=message_type };
message.stanza.put_node(inner_node); message.stanza.put_node(inner_node);
MessageProcessingHints.set_message_hint(message, MessageProcessingHints.HINT_STORE); MessageProcessingHints.set_message_hint(message, MessageProcessingHints.HINT_STORE);
@ -90,6 +96,9 @@ namespace Xmpp.Xep.CallInvites {
case "reject": case "reject":
call_rejected(message.from, message.to, call_id, message.type_); call_rejected(message.from, message.to, call_id, message.type_);
break; break;
case "finish":
call_left(message.from, message.to, call_id, message.type_);
break;
} }
} }