aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2022-02-08 22:04:36 +0100
committerfiaxh <git@lightrise.org>2022-02-08 22:13:59 +0100
commit8b473c890b74f5aed835db097b6eb3d03bef6a08 (patch)
tree2a0f40d8dd721761e3525ed9e022ca257b803ead
parent43ea088f646a8b3a5c41699f48cf5f0b4e7d4107 (diff)
downloaddino-8b473c890b74f5aed835db097b6eb3d03bef6a08.tar.gz
dino-8b473c890b74f5aed835db097b6eb3d03bef6a08.zip
Call Invite Message: Send 'finished' messages, include reasons
-rw-r--r--libdino/src/service/call_peer_state.vala4
-rw-r--r--libdino/src/service/call_state.vala5
-rw-r--r--libdino/src/service/calls.vala33
-rw-r--r--xmpp-vala/src/module/xep/0353_call_invite_message.vala17
4 files changed, 42 insertions, 17 deletions
diff --git a/libdino/src/service/call_peer_state.vala b/libdino/src/service/call_peer_state.vala
index de5c69cb..5fa77926 100644
--- a/libdino/src/service/call_peer_state.vala
+++ b/libdino/src/service/call_peer_state.vala
@@ -97,6 +97,10 @@ public class Dino.PeerState : Object {
}
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);
if (stream == null) return;
diff --git a/libdino/src/service/call_state.vala b/libdino/src/service/call_state.vala
index ecb69773..73b26650 100644
--- a/libdino/src/service/call_state.vala
+++ b/libdino/src/service/call_state.vala
@@ -130,6 +130,11 @@ public class Dino.CallState : Object {
foreach (PeerState peer in peers_cpy) {
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;
} else if (call.state == Call.State.RINGING) {
foreach (PeerState peer in peers_cpy) {
diff --git a/libdino/src/service/calls.vala b/libdino/src/service/calls.vala
index a77dcb79..94ddc0df 100644
--- a/libdino/src/service/calls.vala
+++ b/libdino/src/service/calls.vala
@@ -83,9 +83,7 @@ namespace Dino {
} else {
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);
- bool supports_ussid = yield entity_info.has_feature(conversation.account, conversation.counterpart.bare_jid, Xep.UniqueStableStanzaIDs.NS_URI);
- 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);
+ return is_private && 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;
}
@@ -369,15 +366,20 @@ namespace Dino {
if (peer_state == null) return;
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
if (from.equals(account.full_jid)) return;
call.ourpart = from;
call.state = Call.State.OTHER_DEVICE;
remove_call_from_datastructures(call);
- } else if (from.equals_bare(peer_state.jid) && to.equals(account.full_jid)) { // Message from our peer
- // We proposed the call
+ return;
+ }
+
+ // 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
call_states[call].rename_peer(jmi_request_peer[call].jid, from);
jmi_request_peer[call].call_resource.begin(from);
@@ -477,7 +479,8 @@ namespace Dino {
if (call_state == null) return;
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
if (from_jid.equals(account.full_jid)) return;
@@ -485,10 +488,14 @@ namespace Dino {
call.ourpart = from_jid;
call.state = Call.State.OTHER_DEVICE;
remove_call_from_datastructures(call);
- } else if (to_jid.equals(account.full_jid)) { // Message from our peer
- // We proposed the call
+ return;
+ }
+
+ // 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
- 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);
}
});
@@ -509,9 +516,9 @@ namespace Dino {
call_state.call.state = Call.State.MISSED;
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;
- 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) => {
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;
}
}