diff options
author | fiaxh <git@lightrise.org> | 2021-04-29 15:03:37 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2021-04-29 16:14:17 +0200 |
commit | 4c6664a365bb64904078c07c588f129456583457 (patch) | |
tree | 4b386cbfdb0ea3bd65bc5448c0a38a2aa1008519 | |
parent | 421f43dd8bd993eb88581e1b5011cc061ceb4fc8 (diff) | |
download | dino-4c6664a365bb64904078c07c588f129456583457.tar.gz dino-4c6664a365bb64904078c07c588f129456583457.zip |
Improve JMI handling (type=chat, filter message sender)
-rw-r--r-- | libdino/src/service/calls.vala | 12 | ||||
-rw-r--r-- | xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala | 35 |
2 files changed, 22 insertions, 25 deletions
diff --git a/libdino/src/service/calls.vala b/libdino/src/service/calls.vala index 3615e24f..26a0492a 100644 --- a/libdino/src/service/calls.vala +++ b/libdino/src/service/calls.vala @@ -185,8 +185,8 @@ namespace Dino { if (stream == null) return; string sid = sid_by_call[call.account][call]; - stream.get_module(Xep.JingleMessageInitiation.Module.IDENTITY).send_session_reject_to_self(stream, sid); stream.get_module(Xep.JingleMessageInitiation.Module.IDENTITY).send_session_reject_to_peer(stream, call.counterpart, sid); + stream.get_module(Xep.JingleMessageInitiation.Module.IDENTITY).send_session_reject_to_self(stream, sid); remove_call_from_datastructures(call); } } @@ -632,6 +632,11 @@ namespace Dino { mi_module.session_rejected.connect((from, to, sid) => { if (!call_by_sid[account].has_key(sid)) return; Call call = call_by_sid[account][sid]; + + bool outgoing_reject = call.direction == Call.DIRECTION_OUTGOING && from.equals_bare(call.counterpart); + bool incoming_reject = call.direction == Call.DIRECTION_INCOMING && from.equals_bare(account.bare_jid); + if (!(outgoing_reject || incoming_reject)) return; + call.state = Call.State.DECLINED; remove_call_from_datastructures(call); call_terminated(call, null, null); @@ -639,6 +644,11 @@ namespace Dino { mi_module.session_retracted.connect((from, to, sid) => { if (!call_by_sid[account].has_key(sid)) return; Call call = call_by_sid[account][sid]; + + bool outgoing_retract = call.direction == Call.DIRECTION_OUTGOING && from.equals_bare(call.counterpart); + bool incoming_retract = call.direction == Call.DIRECTION_INCOMING && from.equals_bare(account.bare_jid); + if (!(outgoing_retract || incoming_retract)) return; + call.state = Call.State.MISSED; remove_call_from_datastructures(call); call_terminated(call, null, null); diff --git a/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala b/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala index e26be515..71e16a95 100644 --- a/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala +++ b/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala @@ -17,47 +17,35 @@ namespace Xmpp.Xep.JingleMessageInitiation { propose_node.put_node(desc_node); } - MessageStanza accepted_message = new MessageStanza() { to=to }; + MessageStanza accepted_message = new MessageStanza() { to=to, type_=MessageStanza.TYPE_CHAT }; accepted_message.stanza.put_node(propose_node); stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); } public void send_session_retract_to_peer(XmppStream stream, Jid to, string sid) { - MessageStanza retract_message = new MessageStanza() { to=to }; - retract_message.stanza.put_node( - new StanzaNode.build("retract", NS_URI).add_self_xmlns() - .put_attribute("id", sid, NS_URI)); - stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, retract_message); + send_jmi_message(stream, "retract", to, sid); } public void send_session_accept_to_self(XmppStream stream, string sid) { - MessageStanza accepted_message = new MessageStanza() { to=Bind.Flag.get_my_jid(stream).bare_jid }; - accepted_message.stanza.put_node( - new StanzaNode.build("accept", NS_URI).add_self_xmlns() - .put_attribute("id", sid, NS_URI)); - stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); + send_jmi_message(stream, "accept", Bind.Flag.get_my_jid(stream).bare_jid, sid); } public void send_session_reject_to_self(XmppStream stream, string sid) { - MessageStanza accepted_message = new MessageStanza() { to=Bind.Flag.get_my_jid(stream).bare_jid }; - accepted_message.stanza.put_node( - new StanzaNode.build("reject", NS_URI).add_self_xmlns() - .put_attribute("id", sid, NS_URI)); - stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); + send_jmi_message(stream, "reject", Bind.Flag.get_my_jid(stream).bare_jid, sid); } public void send_session_proceed_to_peer(XmppStream stream, Jid to, string sid) { - MessageStanza accepted_message = new MessageStanza() { to=to }; - accepted_message.stanza.put_node( - new StanzaNode.build("proceed", NS_URI).add_self_xmlns() - .put_attribute("id", sid, NS_URI)); - stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); + send_jmi_message(stream, "proceed", to, sid); } public void send_session_reject_to_peer(XmppStream stream, Jid to, string sid) { - MessageStanza accepted_message = new MessageStanza() { to=to }; + send_jmi_message(stream, "reject", to, sid); + } + + private void send_jmi_message(XmppStream stream, string name, Jid to, string sid) { + MessageStanza accepted_message = new MessageStanza() { to=to, type_=MessageStanza.TYPE_CHAT }; accepted_message.stanza.put_node( - new StanzaNode.build("reject", NS_URI).add_self_xmlns() + new StanzaNode.build(name, NS_URI).add_self_xmlns() .put_attribute("id", sid, NS_URI)); stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); } @@ -95,7 +83,6 @@ namespace Xmpp.Xep.JingleMessageInitiation { session_retracted(message.from, message.to, mi_node.get_attribute("id")); break; case "reject": - if (!message.from.equals_bare(Bind.Flag.get_my_jid(stream))) return; session_rejected(message.from, message.to, mi_node.get_attribute("id")); break; } |