aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/core
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2018-01-12 21:03:09 +0100
committerfiaxh <git@mx.ax.lt>2018-01-28 00:38:47 +0100
commit782ae4c049e2b6fab13d7453cbb0e74610e7d200 (patch)
tree1b4cd0a1689cee0c2e2cac2ae9a5fb8ebbe63621 /xmpp-vala/src/core
parentd46d071e57e599e8cfb1780597cbecb36881c4d8 (diff)
downloaddino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz
dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'xmpp-vala/src/core')
-rw-r--r--xmpp-vala/src/core/namespace_state.vala2
-rw-r--r--xmpp-vala/src/core/stanza_attribute.vala2
-rw-r--r--xmpp-vala/src/core/stanza_node.vala2
-rw-r--r--xmpp-vala/src/core/stanza_reader.vala2
-rw-r--r--xmpp-vala/src/core/stanza_writer.vala3
-rw-r--r--xmpp-vala/src/core/xmpp_log.vala2
-rw-r--r--xmpp-vala/src/core/xmpp_stream.vala18
7 files changed, 16 insertions, 15 deletions
diff --git a/xmpp-vala/src/core/namespace_state.vala b/xmpp-vala/src/core/namespace_state.vala
index b55812b4..fe83ad09 100644
--- a/xmpp-vala/src/core/namespace_state.vala
+++ b/xmpp-vala/src/core/namespace_state.vala
@@ -1,6 +1,6 @@
using Gee;
-namespace Xmpp.Core {
+namespace Xmpp {
public class NamespaceState {
private HashMap<string, string> uri_to_name = new HashMap<string, string> ();
diff --git a/xmpp-vala/src/core/stanza_attribute.vala b/xmpp-vala/src/core/stanza_attribute.vala
index 86fb426e..c2edeba0 100644
--- a/xmpp-vala/src/core/stanza_attribute.vala
+++ b/xmpp-vala/src/core/stanza_attribute.vala
@@ -1,4 +1,4 @@
-namespace Xmpp.Core {
+namespace Xmpp {
public class StanzaAttribute : StanzaEntry {
diff --git a/xmpp-vala/src/core/stanza_node.vala b/xmpp-vala/src/core/stanza_node.vala
index 695a72cd..0544cc1f 100644
--- a/xmpp-vala/src/core/stanza_node.vala
+++ b/xmpp-vala/src/core/stanza_node.vala
@@ -1,6 +1,6 @@
using Gee;
-namespace Xmpp.Core {
+namespace Xmpp {
public abstract class StanzaEntry {
protected const string ANSI_COLOR_END = "\x1b[0m";
diff --git a/xmpp-vala/src/core/stanza_reader.vala b/xmpp-vala/src/core/stanza_reader.vala
index 6a7520ba..b8cb1f4c 100644
--- a/xmpp-vala/src/core/stanza_reader.vala
+++ b/xmpp-vala/src/core/stanza_reader.vala
@@ -1,6 +1,6 @@
using Gee;
-namespace Xmpp.Core {
+namespace Xmpp {
public const string XMLNS_URI = "http://www.w3.org/2000/xmlns/";
public const string XML_URI = "http://www.w3.org/XML/1998/namespace";
diff --git a/xmpp-vala/src/core/stanza_writer.vala b/xmpp-vala/src/core/stanza_writer.vala
index 62c870de..aa94dec9 100644
--- a/xmpp-vala/src/core/stanza_writer.vala
+++ b/xmpp-vala/src/core/stanza_writer.vala
@@ -1,4 +1,5 @@
-namespace Xmpp.Core {
+namespace Xmpp {
+
public class StanzaWriter {
private OutputStream output;
diff --git a/xmpp-vala/src/core/xmpp_log.vala b/xmpp-vala/src/core/xmpp_log.vala
index 77fedd03..b42cd30a 100644
--- a/xmpp-vala/src/core/xmpp_log.vala
+++ b/xmpp-vala/src/core/xmpp_log.vala
@@ -1,6 +1,6 @@
using Gee;
-namespace Xmpp.Core {
+namespace Xmpp {
public class XmppLog {
protected const string ANSI_COLOR_END = "\x1b[0m";
diff --git a/xmpp-vala/src/core/xmpp_stream.vala b/xmpp-vala/src/core/xmpp_stream.vala
index 6c364e80..09e973bd 100644
--- a/xmpp-vala/src/core/xmpp_stream.vala
+++ b/xmpp-vala/src/core/xmpp_stream.vala
@@ -1,6 +1,6 @@
using Gee;
-namespace Xmpp.Core {
+namespace Xmpp {
public errordomain IOStreamError {
READ,
@@ -13,7 +13,7 @@ public errordomain IOStreamError {
public class XmppStream {
public const string NS_URI = "http://etherx.jabber.org/streams";
- public string remote_name;
+ public Jid remote_name;
public XmppLog log = new XmppLog();
public StanzaNode? features { get; private set; default = new StanzaNode.build("features", NS_URI); }
@@ -43,13 +43,13 @@ public class XmppStream {
}
public async void connect(string? remote_name = null) throws IOStreamError {
- if (remote_name != null) this.remote_name = (!)remote_name;
+ if (remote_name != null) this.remote_name = Jid.parse(remote_name);
attach_negotation_modules();
try {
int min_priority = -1;
ConnectionProvider? best_provider = null;
foreach (ConnectionProvider connection_provider in connection_providers) {
- int? priority = yield connection_provider.get_priority(remote_name);
+ int? priority = yield connection_provider.get_priority(this.remote_name);
if (priority != null && (priority < min_priority || min_priority == -1)) {
min_priority = priority;
best_provider = connection_provider;
@@ -60,7 +60,7 @@ public class XmppStream {
stream = yield best_provider.connect(this);
}
if (stream == null) {
- stream = yield (new SocketClient()).connect_async(new NetworkService("xmpp-client", "tcp", this.remote_name));
+ stream = yield (new SocketClient()).connect_async(new NetworkService("xmpp-client", "tcp", this.remote_name.to_string()));
}
if (stream == null) {
throw new IOStreamError.CONNECT("client.connect() returned null");
@@ -187,7 +187,7 @@ public class XmppStream {
private async void setup() throws IOStreamError {
StanzaNode outs = new StanzaNode.build("stream", "http://etherx.jabber.org/streams")
- .put_attribute("to", remote_name)
+ .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);
@@ -349,7 +349,7 @@ public abstract class XmppStreamNegotiationModule : XmppStreamModule {
}
public abstract class ConnectionProvider {
- public async abstract int? get_priority(string remote_name);
+ public async abstract int? get_priority(Jid remote_name);
public async abstract IOStream? connect(XmppStream stream);
public abstract string get_id();
}
@@ -357,11 +357,11 @@ public abstract class ConnectionProvider {
public class StartTlsConnectionProvider : ConnectionProvider {
private SrvTarget? srv_target;
- public async override int? get_priority(string remote_name) {
+ public async override int? get_priority(Jid remote_name) {
GLib.List<SrvTarget>? xmpp_target = null;
try {
GLibFixes.Resolver resolver = GLibFixes.Resolver.get_default();
- xmpp_target = yield resolver.lookup_service_async("xmpp-client", "tcp", remote_name, null);
+ xmpp_target = yield resolver.lookup_service_async("xmpp-client", "tcp", remote_name.to_string(), null);
} catch (Error e) {
return null;
}