aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/module/xep')
-rw-r--r--xmpp-vala/src/module/xep/0166_jingle/content.vala6
-rw-r--r--xmpp-vala/src/module/xep/0166_jingle/session.vala85
-rw-r--r--xmpp-vala/src/module/xep/0167_jingle_rtp/session_info_type.vala5
3 files changed, 42 insertions, 54 deletions
diff --git a/xmpp-vala/src/module/xep/0166_jingle/content.vala b/xmpp-vala/src/module/xep/0166_jingle/content.vala
index 41310aeb..be78c91a 100644
--- a/xmpp-vala/src/module/xep/0166_jingle/content.vala
+++ b/xmpp-vala/src/module/xep/0166_jingle/content.vala
@@ -229,6 +229,12 @@ public class Xmpp.Xep.Jingle.Content : Object {
public void send_transport_info(StanzaNode transport) {
session.send_transport_info(this, transport);
}
+
+ internal StanzaNode build_outer_content_node() {
+ return new StanzaNode.build("content", NS_URI)
+ .put_attribute("creator", content_creator.to_string())
+ .put_attribute("name", content_name);
+ }
}
public class Xmpp.Xep.Jingle.ContentEncryption : Object {
diff --git a/xmpp-vala/src/module/xep/0166_jingle/session.vala b/xmpp-vala/src/module/xep/0166_jingle/session.vala
index 4d04c8d5..0b377d0f 100644
--- a/xmpp-vala/src/module/xep/0166_jingle/session.vala
+++ b/xmpp-vala/src/module/xep/0166_jingle/session.vala
@@ -444,93 +444,72 @@ public class Xmpp.Xep.Jingle.Session : Object {
internal void send_session_info(StanzaNode child_node) {
if (state == State.ENDED) return;
- StanzaNode node = new StanzaNode.build("jingle", NS_URI).add_self_xmlns()
- .put_attribute("action", "session-info")
- .put_attribute("sid", sid)
- // TODO put `initiator`?
- .put_node(child_node);
- Iq.Stanza iq = new Iq.Stanza.set(node) { to=peer_full_jid };
+ StanzaNode jingle_node = build_outer_session_node("session-info").put_node(child_node);
+ Iq.Stanza iq = new Iq.Stanza.set(jingle_node) { to=peer_full_jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
}
internal void send_content_modify(Content content, Senders senders) {
if (state == State.ENDED) return;
- StanzaNode node = new StanzaNode.build("jingle", NS_URI).add_self_xmlns()
- .put_attribute("action", "content-modify")
- .put_attribute("sid", sid)
- .put_node(new StanzaNode.build("content", NS_URI)
- .put_attribute("creator", content.content_creator.to_string())
- .put_attribute("name", content.content_name)
+ StanzaNode jingle_node = build_outer_session_node("content-modify")
+ .put_node(content.build_outer_content_node()
.put_attribute("senders", senders.to_string()));
- Iq.Stanza iq = new Iq.Stanza.set(node) { to=peer_full_jid };
+
+ Iq.Stanza iq = new Iq.Stanza.set(jingle_node) { to=peer_full_jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
}
internal void send_transport_accept(Content content, TransportParameters transport_params) {
if (state == State.ENDED) return;
- StanzaNode jingle_response = new StanzaNode.build("jingle", NS_URI)
- .add_self_xmlns()
- .put_attribute("action", "transport-accept")
- .put_attribute("sid", sid)
- .put_node(new StanzaNode.build("content", NS_URI)
- .put_attribute("creator", "initiator")
- .put_attribute("name", content.content_name)
- .put_node(transport_params.to_transport_stanza_node("transport-accept"))
- );
- Iq.Stanza iq_response = new Iq.Stanza.set(jingle_response) { to=peer_full_jid };
+ StanzaNode jingle_node = build_outer_session_node("transport-accept")
+ .put_node(content.build_outer_content_node()
+ .put_node(transport_params.to_transport_stanza_node("transport-accept")));
+
+ Iq.Stanza iq_response = new Iq.Stanza.set(jingle_node) { to=peer_full_jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq_response);
}
internal void send_transport_replace(Content content, TransportParameters transport_params) {
if (state == State.ENDED) return;
- StanzaNode jingle = new StanzaNode.build("jingle", NS_URI)
- .add_self_xmlns()
- .put_attribute("action", "transport-replace")
- .put_attribute("sid", sid)
- .put_node(new StanzaNode.build("content", NS_URI)
- .put_attribute("creator", "initiator")
- .put_attribute("name", content.content_name)
- .put_node(transport_params.to_transport_stanza_node("transport-replace"))
- );
- Iq.Stanza iq = new Iq.Stanza.set(jingle) { to=peer_full_jid };
+ StanzaNode jingle_node = build_outer_session_node("transport-replace")
+ .put_node(content.build_outer_content_node()
+ .put_node(transport_params.to_transport_stanza_node("transport-replace")));
+
+ Iq.Stanza iq = new Iq.Stanza.set(jingle_node) { to=peer_full_jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
}
internal void send_transport_reject(Content content, StanzaNode transport_node) {
if (state == State.ENDED) return;
- StanzaNode jingle_response = new StanzaNode.build("jingle", NS_URI)
- .add_self_xmlns()
- .put_attribute("action", "transport-reject")
- .put_attribute("sid", sid)
- .put_node(new StanzaNode.build("content", NS_URI)
- .put_attribute("creator", "initiator")
- .put_attribute("name", content.content_name)
- .put_node(transport_node)
- );
- Iq.Stanza iq_response = new Iq.Stanza.set(jingle_response) { to=peer_full_jid };
+ StanzaNode jingle_node = build_outer_session_node("transport-reject")
+ .put_node(content.build_outer_content_node().put_node(transport_node));
+
+ Iq.Stanza iq_response = new Iq.Stanza.set(jingle_node) { to=peer_full_jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq_response);
}
internal void send_transport_info(Content content, StanzaNode transport) {
if (state == State.ENDED) return;
- StanzaNode jingle = new StanzaNode.build("jingle", NS_URI)
- .add_self_xmlns()
- .put_attribute("action", "transport-info")
- .put_attribute("sid", sid)
- .put_node(new StanzaNode.build("content", NS_URI)
- .put_attribute("creator", "initiator")
- .put_attribute("name", content.content_name)
- .put_node(transport)
- );
- Iq.Stanza iq = new Iq.Stanza.set(jingle) { to=peer_full_jid };
+ StanzaNode jingle_node = build_outer_session_node("transport-info")
+ .put_node(content.build_outer_content_node().put_node(transport));
+
+ Iq.Stanza iq = new Iq.Stanza.set(jingle_node) { to=peer_full_jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
}
+ private StanzaNode build_outer_session_node(string action) {
+ return new StanzaNode.build("jingle", NS_URI)
+ .add_self_xmlns()
+ .put_attribute("action", action)
+ .put_attribute("initiator", we_initiated ? local_full_jid.to_string() : peer_full_jid.to_string())
+ .put_attribute("sid", sid);
+ }
+
public bool senders_include_us(Senders senders) {
switch (senders) {
case Senders.BOTH:
diff --git a/xmpp-vala/src/module/xep/0167_jingle_rtp/session_info_type.vala b/xmpp-vala/src/module/xep/0167_jingle_rtp/session_info_type.vala
index 32cd9016..02ecd72c 100644
--- a/xmpp-vala/src/module/xep/0167_jingle_rtp/session_info_type.vala
+++ b/xmpp-vala/src/module/xep/0167_jingle_rtp/session_info_type.vala
@@ -53,7 +53,10 @@ namespace Xmpp.Xep.JingleRtp {
foreach (Jingle.Content content in session.contents) {
Parameters? parameters = content.content_params as Parameters;
if (parameters != null && parameters.media == media) {
- StanzaNode session_info_content = new StanzaNode.build(node_name, NS_URI).add_self_xmlns().put_attribute("name", content.content_name);
+ StanzaNode session_info_content = new StanzaNode.build(node_name, NS_URI)
+ .add_self_xmlns()
+ .put_attribute("name", content.content_name)
+ .put_attribute("creator", content.content_creator.to_string());
session.send_session_info(session_info_content);
}
}