aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/core')
-rw-r--r--xmpp-vala/src/core/direct_tls_xmpp_stream.vala4
-rw-r--r--xmpp-vala/src/core/io_xmpp_stream.vala17
-rw-r--r--xmpp-vala/src/core/starttls_xmpp_stream.vala4
-rw-r--r--xmpp-vala/src/core/stream_connect.vala4
-rw-r--r--xmpp-vala/src/core/tls_xmpp_stream.vala12
-rw-r--r--xmpp-vala/src/core/xmpp_stream.vala5
6 files changed, 32 insertions, 14 deletions
diff --git a/xmpp-vala/src/core/direct_tls_xmpp_stream.vala b/xmpp-vala/src/core/direct_tls_xmpp_stream.vala
index f2e06e2c..2f159ab6 100644
--- a/xmpp-vala/src/core/direct_tls_xmpp_stream.vala
+++ b/xmpp-vala/src/core/direct_tls_xmpp_stream.vala
@@ -6,8 +6,8 @@ public class Xmpp.DirectTlsXmppStream : TlsXmppStream {
uint16 port;
TlsXmppStream.OnInvalidCertWrapper on_invalid_cert;
- public DirectTlsXmppStream(Jid remote_name, string host, uint16 port, TlsXmppStream.OnInvalidCertWrapper on_invalid_cert) {
- base(remote_name);
+ public DirectTlsXmppStream(Jid remote_name, string host, uint16 port, Jid? own_jid, TlsXmppStream.OnInvalidCertWrapper on_invalid_cert) {
+ base(remote_name, own_jid);
this.host = host;
this.port = port;
this.on_invalid_cert = on_invalid_cert;
diff --git a/xmpp-vala/src/core/io_xmpp_stream.vala b/xmpp-vala/src/core/io_xmpp_stream.vala
index 1d9d061b..e13d1448 100644
--- a/xmpp-vala/src/core/io_xmpp_stream.vala
+++ b/xmpp-vala/src/core/io_xmpp_stream.vala
@@ -74,12 +74,7 @@ public abstract class Xmpp.IoXmppStream : XmppStream {
}
public override async void setup() throws IOError {
- StanzaNode outs = new StanzaNode.build("stream", "http://etherx.jabber.org/streams")
- .put_attribute("to", remote_name.to_string())
- .put_attribute("version", "1.0")
- .put_attribute("xmlns", "jabber:client")
- .put_attribute("stream", "http://etherx.jabber.org/streams", XMLNS_URI);
- outs.has_nodes = true;
+ StanzaNode outs = generate_root_node();
log.node("OUT ROOT", outs, this);
yield write_async(outs, Priority.HIGH, cancellable);
received_root_node(this, yield read_root());
@@ -87,6 +82,16 @@ public abstract class Xmpp.IoXmppStream : XmppStream {
setup_needed = false;
}
+ public virtual StanzaNode generate_root_node() {
+ StanzaNode root_node = new StanzaNode.build("stream", "http://etherx.jabber.org/streams")
+ .put_attribute("to", remote_name.to_string())
+ .put_attribute("version", "1.0")
+ .put_attribute("xmlns", "jabber:client")
+ .put_attribute("stream", "http://etherx.jabber.org/streams", XMLNS_URI);
+ root_node.has_nodes = true;
+ return root_node;
+ }
+
private async StanzaNode read_root() throws IOError {
StanzaReader? reader = this.reader;
if (reader == null) throw new IOError.NOT_CONNECTED("trying to read, but no stream open");
diff --git a/xmpp-vala/src/core/starttls_xmpp_stream.vala b/xmpp-vala/src/core/starttls_xmpp_stream.vala
index 01c75207..ca810650 100644
--- a/xmpp-vala/src/core/starttls_xmpp_stream.vala
+++ b/xmpp-vala/src/core/starttls_xmpp_stream.vala
@@ -6,8 +6,8 @@ public class Xmpp.StartTlsXmppStream : TlsXmppStream {
uint16 port;
TlsXmppStream.OnInvalidCertWrapper on_invalid_cert;
- public StartTlsXmppStream(Jid remote, string host, uint16 port, TlsXmppStream.OnInvalidCertWrapper on_invalid_cert) {
- base(remote);
+ public StartTlsXmppStream(Jid remote, string host, uint16 port, Jid? own_jid, TlsXmppStream.OnInvalidCertWrapper on_invalid_cert) {
+ base(remote, own_jid);
this.host = host;
this.port = port;
this.on_invalid_cert = on_invalid_cert;
diff --git a/xmpp-vala/src/core/stream_connect.vala b/xmpp-vala/src/core/stream_connect.vala
index af27ff0d..7e3843fa 100644
--- a/xmpp-vala/src/core/stream_connect.vala
+++ b/xmpp-vala/src/core/stream_connect.vala
@@ -60,9 +60,9 @@ namespace Xmpp {
foreach (SrvTargetInfo target in targets) {
try {
if (target.service == "xmpp-client") {
- stream = new StartTlsXmppStream(remote, target.host, target.port, on_invalid_cert_wrapper);
+ stream = new StartTlsXmppStream(remote, target.host, target.port, bare_jid, on_invalid_cert_wrapper);
} else {
- stream = new DirectTlsXmppStream(remote, target.host, target.port, on_invalid_cert_wrapper);
+ stream = new DirectTlsXmppStream(remote, target.host, target.port, bare_jid, on_invalid_cert_wrapper);
}
stream.log = new XmppLog(bare_jid.to_string(), log_options);
diff --git a/xmpp-vala/src/core/tls_xmpp_stream.vala b/xmpp-vala/src/core/tls_xmpp_stream.vala
index 6a5e935b..81ab1c54 100644
--- a/xmpp-vala/src/core/tls_xmpp_stream.vala
+++ b/xmpp-vala/src/core/tls_xmpp_stream.vala
@@ -1,6 +1,7 @@
public abstract class Xmpp.TlsXmppStream : IoXmppStream {
public TlsCertificateFlags? errors;
+ private Jid? own_jid;
public delegate bool OnInvalidCert(GLib.TlsCertificate peer_cert, GLib.TlsCertificateFlags errors);
public class OnInvalidCertWrapper {
@@ -10,8 +11,9 @@ public abstract class Xmpp.TlsXmppStream : IoXmppStream {
}
}
- protected TlsXmppStream(Jid remote_name) {
+ protected TlsXmppStream(Jid remote_name, Jid? own_jid) {
base(remote_name);
+ this.own_jid = own_jid;
}
protected bool on_invalid_certificate(TlsCertificate peer_cert, TlsCertificateFlags errors) {
@@ -28,4 +30,12 @@ public abstract class Xmpp.TlsXmppStream : IoXmppStream {
warning(@"[%p, %s] Tls Certificate Errors: %s", this, this.remote_name.to_string(), error_str);
return false;
}
+
+ public override StanzaNode generate_root_node() {
+ StanzaNode root_node = base.generate_root_node();
+ if (own_jid != null) {
+ root_node.put_attribute("from", own_jid.bare_jid.to_string());
+ }
+ return root_node;
+ }
} \ No newline at end of file
diff --git a/xmpp-vala/src/core/xmpp_stream.vala b/xmpp-vala/src/core/xmpp_stream.vala
index 54433b67..7b05a26e 100644
--- a/xmpp-vala/src/core/xmpp_stream.vala
+++ b/xmpp-vala/src/core/xmpp_stream.vala
@@ -22,6 +22,7 @@ public abstract class Xmpp.XmppStream : Object {
public XmppLog log = new XmppLog();
public bool negotiation_complete { get; set; default=false; }
+ public bool expect_further_negotiation_stanzas = false;
protected bool non_negotiation_modules_attached = false;
protected bool setup_needed = false;
protected bool disconnected = false;
@@ -99,6 +100,8 @@ public abstract class Xmpp.XmppStream : Object {
public async void loop() throws IOError {
while (true) {
+ expect_further_negotiation_stanzas = false;
+
if (setup_needed) {
yield setup();
}
@@ -112,7 +115,7 @@ public abstract class Xmpp.XmppStream : Object {
yield handle_stanza(node);
- if (!non_negotiation_modules_attached && negotiation_modules_done()) {
+ if (!expect_further_negotiation_stanzas && !non_negotiation_modules_attached && negotiation_modules_done()) {
attach_non_negotation_modules();
non_negotiation_modules_attached = true;
if (!negotiation_complete) {