aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-04-01 12:03:04 +0200
committerfiaxh <git@lightrise.org>2021-04-01 12:03:04 +0200
commit3454201e5a3da058ccbef0bbaf467599912a8c38 (patch)
tree6ff60c4d923e468135a86a9e8a5fae926c349b41 /xmpp-vala
parentb63a20f9189026a77ccc1769a4ab366d48f63233 (diff)
downloaddino-3454201e5a3da058ccbef0bbaf467599912a8c38.tar.gz
dino-3454201e5a3da058ccbef0bbaf467599912a8c38.zip
Use outgoing JMI if contact has supporting device
Diffstat (limited to 'xmpp-vala')
-rw-r--r--xmpp-vala/src/module/xep/0166_jingle/jingle_module.vala4
-rw-r--r--xmpp-vala/src/module/xep/0167_jingle_rtp/jingle_rtp_module.vala4
-rw-r--r--xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala14
3 files changed, 16 insertions, 6 deletions
diff --git a/xmpp-vala/src/module/xep/0166_jingle/jingle_module.vala b/xmpp-vala/src/module/xep/0166_jingle/jingle_module.vala
index 1e8a36d1..7314ca6c 100644
--- a/xmpp-vala/src/module/xep/0166_jingle/jingle_module.vala
+++ b/xmpp-vala/src/module/xep/0166_jingle/jingle_module.vala
@@ -102,7 +102,7 @@ namespace Xmpp.Xep.Jingle {
return (yield is_jingle_available(stream, full_jid)) && (yield select_transport(stream, type, components, full_jid, Set.empty())) != null;
}
- public async Session create_session(XmppStream stream, Gee.List<Content> contents, Jid receiver_full_jid, string sid = random_uuid()) throws Error {
+ public async Session create_session(XmppStream stream, Gee.List<Content> contents, Jid receiver_full_jid, string? sid = null) throws Error {
if (!yield is_jingle_available(stream, receiver_full_jid)) {
throw new Error.NO_SHARED_PROTOCOLS("No Jingle support");
}
@@ -111,7 +111,7 @@ namespace Xmpp.Xep.Jingle {
throw new Error.GENERAL("Couldn't determine own JID");
}
- Session session = new Session.initiate_sent(stream, sid, my_jid, receiver_full_jid);
+ Session session = new Session.initiate_sent(stream, sid ?? random_uuid(), my_jid, receiver_full_jid);
session.terminated.connect((session, stream, _1, _2, _3) => { stream.get_flag(Flag.IDENTITY).remove_session(session.sid); });
foreach (Content content in contents) {
diff --git a/xmpp-vala/src/module/xep/0167_jingle_rtp/jingle_rtp_module.vala b/xmpp-vala/src/module/xep/0167_jingle_rtp/jingle_rtp_module.vala
index 3a9ea09f..3adad114 100644
--- a/xmpp-vala/src/module/xep/0167_jingle_rtp/jingle_rtp_module.vala
+++ b/xmpp-vala/src/module/xep/0167_jingle_rtp/jingle_rtp_module.vala
@@ -26,7 +26,7 @@ public abstract class Module : XmppStreamModule {
public abstract Stream create_stream(Jingle.Content content);
public abstract void close_stream(Stream stream);
- public async Jingle.Session start_call(XmppStream stream, Jid receiver_full_jid, bool video) throws Jingle.Error {
+ public async Jingle.Session start_call(XmppStream stream, Jid receiver_full_jid, bool video, string? sid = null) throws Jingle.Error {
Jingle.Module jingle_module = stream.get_module(Jingle.Module.IDENTITY);
@@ -72,7 +72,7 @@ public abstract class Module : XmppStreamModule {
// Create session
try {
- Jingle.Session session = yield jingle_module.create_session(stream, contents, receiver_full_jid);
+ Jingle.Session session = yield jingle_module.create_session(stream, contents, receiver_full_jid, sid);
return session;
} catch (Jingle.Error e) {
throw new Jingle.Error.GENERAL(@"Couldn't create Jingle session: $(e.message)");
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 acb2ba2e..dbb6fd81 100644
--- a/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala
+++ b/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala
@@ -1,7 +1,7 @@
using Gee;
namespace Xmpp.Xep.JingleMessageInitiation {
- private const string NS_URI = "urn:xmpp:jingle-message:0";
+ public const string NS_URI = "urn:xmpp:jingle-message:0";
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0353_jingle_message_initiation");
@@ -11,6 +11,17 @@ namespace Xmpp.Xep.JingleMessageInitiation {
public signal void session_accepted(Jid from, string sid);
public signal void session_rejected(Jid from, Jid to, string sid);
+ public void send_session_propose_to_peer(XmppStream stream, Jid to, string sid, Gee.List<StanzaNode> descriptions) {
+ StanzaNode propose_node = new StanzaNode.build("propose", NS_URI).add_self_xmlns().put_attribute("id", sid, NS_URI);
+ foreach (StanzaNode desc_node in descriptions) {
+ propose_node.put_node(desc_node);
+ }
+
+ MessageStanza accepted_message = new MessageStanza() { to=to };
+ accepted_message.stanza.put_node(propose_node);
+ stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message);
+ }
+
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(
@@ -58,7 +69,6 @@ namespace Xmpp.Xep.JingleMessageInitiation {
switch (mi_node.name) {
case "accept":
case "proceed":
- if (!message.from.equals_bare(Bind.Flag.get_my_jid(stream))) return;
session_accepted(message.from, mi_node.get_attribute("id"));
break;
case "propose":