aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala')
-rw-r--r--xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala52
1 files changed, 34 insertions, 18 deletions
diff --git a/xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala b/xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala
index e26d63b7..09eaf711 100644
--- a/xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala
+++ b/xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala
@@ -21,41 +21,41 @@ public class Module : Jingle.Transport, XmppStreamModule {
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- public async bool is_transport_available(XmppStream stream, Jid full_jid) {
- return yield stream.get_module(ServiceDiscovery.Module.IDENTITY).has_entity_feature(stream, full_jid, NS_URI);
+ public async bool is_transport_available(XmppStream stream, uint8 components, Jid full_jid) {
+ return components == 1 && yield stream.get_module(ServiceDiscovery.Module.IDENTITY).has_entity_feature(stream, full_jid, NS_URI);
}
- public string transport_ns_uri() {
- return NS_URI;
- }
- public Jingle.TransportType transport_type() {
- return Jingle.TransportType.STREAMING;
- }
- public int transport_priority() {
- return 0;
- }
- public Jingle.TransportParameters create_transport_parameters(XmppStream stream, Jid local_full_jid, Jid peer_full_jid) {
+ public string ns_uri { get { return NS_URI; } }
+ public Jingle.TransportType type_ { get { return Jingle.TransportType.STREAMING; } }
+ public int priority { get { return 0; } }
+ public Jingle.TransportParameters create_transport_parameters(XmppStream stream, uint8 components, Jid local_full_jid, Jid peer_full_jid) {
+ assert(components == 1);
return new Parameters.create(peer_full_jid, random_uuid());
}
- public Jingle.TransportParameters parse_transport_parameters(XmppStream stream, Jid local_full_jid, Jid peer_full_jid, StanzaNode transport) throws Jingle.IqError {
+ public Jingle.TransportParameters parse_transport_parameters(XmppStream stream, uint8 components, Jid local_full_jid, Jid peer_full_jid, StanzaNode transport) throws Jingle.IqError {
return Parameters.parse(peer_full_jid, transport);
}
}
class Parameters : Jingle.TransportParameters, Object {
+ public string ns_uri { get { return NS_URI; } }
+ public uint8 components { get { return 1; } }
public Jingle.Role role { get; private set; }
public Jid peer_full_jid { get; private set; }
public string sid { get; private set; }
public int block_size { get; private set; }
+
private Parameters(Jingle.Role role, Jid peer_full_jid, string sid, int block_size) {
this.role = role;
this.peer_full_jid = peer_full_jid;
this.sid = sid;
this.block_size = block_size;
}
+
public Parameters.create(Jid peer_full_jid, string sid) {
this(Jingle.Role.INITIATOR, peer_full_jid, sid, DEFAULT_BLOCKSIZE);
}
+
public static Parameters parse(Jid peer_full_jid, StanzaNode transport) throws Jingle.IqError {
string? sid = transport.get_attribute("sid");
int block_size = transport.get_attribute_int("block-size");
@@ -64,27 +64,43 @@ class Parameters : Jingle.TransportParameters, Object {
}
return new Parameters(Jingle.Role.RESPONDER, peer_full_jid, sid, block_size);
}
+
public string transport_ns_uri() {
return NS_URI;
}
- public StanzaNode to_transport_stanza_node() {
+
+ public void set_content(Jingle.Content content) {
+
+ }
+
+ public StanzaNode to_transport_stanza_node(string action_type) {
return new StanzaNode.build("transport", NS_URI)
.add_self_xmlns()
.put_attribute("block-size", block_size.to_string())
.put_attribute("sid", sid);
}
- public void on_transport_accept(StanzaNode transport) throws Jingle.IqError {
+
+ public void handle_transport_accept(StanzaNode transport) throws Jingle.IqError {
Parameters other = Parameters.parse(peer_full_jid, transport);
if (other.sid != sid || other.block_size > block_size) {
throw new Jingle.IqError.NOT_ACCEPTABLE("invalid IBB sid or block_size");
}
block_size = other.block_size;
}
- public void on_transport_info(StanzaNode transport) throws Jingle.IqError {
+
+ public void handle_transport_info(StanzaNode transport) throws Jingle.IqError {
throw new Jingle.IqError.UNSUPPORTED_INFO("transport-info not supported for IBBs");
}
- public void create_transport_connection(XmppStream stream, Jingle.Session session) {
- session.set_transport_connection(stream, InBandBytestreams.Connection.create(stream, peer_full_jid, sid, block_size, role == Jingle.Role.INITIATOR));
+
+ public void create_transport_connection(XmppStream stream, Jingle.Content content) {
+ IOStream iostream = InBandBytestreams.Connection.create(stream, peer_full_jid, sid, block_size, role == Jingle.Role.INITIATOR);
+ Jingle.StreamingConnection connection = new Jingle.StreamingConnection();
+ if (content.security_params != null) {
+ iostream = content.security_params.wrap_stream(iostream);
+ }
+ connection.set_stream.begin(iostream);
+ debug("set transport conn ibb");
+ content.set_transport_connection(connection, 1);
}
}