Improve JMI handling (type=chat, filter message sender)
This commit is contained in:
parent
421f43dd8b
commit
4c6664a365
|
@ -185,8 +185,8 @@ namespace Dino {
|
||||||
if (stream == null) return;
|
if (stream == null) return;
|
||||||
|
|
||||||
string sid = sid_by_call[call.account][call];
|
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_peer(stream, call.counterpart, sid);
|
||||||
|
stream.get_module(Xep.JingleMessageInitiation.Module.IDENTITY).send_session_reject_to_self(stream, sid);
|
||||||
remove_call_from_datastructures(call);
|
remove_call_from_datastructures(call);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -632,6 +632,11 @@ namespace Dino {
|
||||||
mi_module.session_rejected.connect((from, to, sid) => {
|
mi_module.session_rejected.connect((from, to, sid) => {
|
||||||
if (!call_by_sid[account].has_key(sid)) return;
|
if (!call_by_sid[account].has_key(sid)) return;
|
||||||
Call call = call_by_sid[account][sid];
|
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;
|
call.state = Call.State.DECLINED;
|
||||||
remove_call_from_datastructures(call);
|
remove_call_from_datastructures(call);
|
||||||
call_terminated(call, null, null);
|
call_terminated(call, null, null);
|
||||||
|
@ -639,6 +644,11 @@ namespace Dino {
|
||||||
mi_module.session_retracted.connect((from, to, sid) => {
|
mi_module.session_retracted.connect((from, to, sid) => {
|
||||||
if (!call_by_sid[account].has_key(sid)) return;
|
if (!call_by_sid[account].has_key(sid)) return;
|
||||||
Call call = call_by_sid[account][sid];
|
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;
|
call.state = Call.State.MISSED;
|
||||||
remove_call_from_datastructures(call);
|
remove_call_from_datastructures(call);
|
||||||
call_terminated(call, null, null);
|
call_terminated(call, null, null);
|
||||||
|
|
|
@ -17,47 +17,35 @@ namespace Xmpp.Xep.JingleMessageInitiation {
|
||||||
propose_node.put_node(desc_node);
|
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);
|
accepted_message.stanza.put_node(propose_node);
|
||||||
stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message);
|
stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send_session_retract_to_peer(XmppStream stream, Jid to, string sid) {
|
public void send_session_retract_to_peer(XmppStream stream, Jid to, string sid) {
|
||||||
MessageStanza retract_message = new MessageStanza() { to=to };
|
send_jmi_message(stream, "retract", to, sid);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send_session_accept_to_self(XmppStream stream, string 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 };
|
send_jmi_message(stream, "accept", Bind.Flag.get_my_jid(stream).bare_jid, sid);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send_session_reject_to_self(XmppStream stream, string 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 };
|
send_jmi_message(stream, "reject", Bind.Flag.get_my_jid(stream).bare_jid, sid);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send_session_proceed_to_peer(XmppStream stream, Jid to, string sid) {
|
public void send_session_proceed_to_peer(XmppStream stream, Jid to, string sid) {
|
||||||
MessageStanza accepted_message = new MessageStanza() { to=to };
|
send_jmi_message(stream, "proceed", to, sid);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send_session_reject_to_peer(XmppStream stream, Jid to, string 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(
|
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));
|
.put_attribute("id", sid, NS_URI));
|
||||||
stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message);
|
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"));
|
session_retracted(message.from, message.to, mi_node.get_attribute("id"));
|
||||||
break;
|
break;
|
||||||
case "reject":
|
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"));
|
session_rejected(message.from, message.to, mi_node.get_attribute("id"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue