aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala
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
parentd46d071e57e599e8cfb1780597cbecb36881c4d8 (diff)
downloaddino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz
dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'xmpp-vala')
-rw-r--r--xmpp-vala/CMakeLists.txt1
-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
-rw-r--r--xmpp-vala/src/module/bind.vala8
-rw-r--r--xmpp-vala/src/module/iq/module.vala2
-rw-r--r--xmpp-vala/src/module/iq/stanza.vala4
-rw-r--r--xmpp-vala/src/module/jid.vala107
-rw-r--r--xmpp-vala/src/module/message/module.vala20
-rw-r--r--xmpp-vala/src/module/message/stanza.vala10
-rw-r--r--xmpp-vala/src/module/presence/flag.vala48
-rw-r--r--xmpp-vala/src/module/presence/module.vala18
-rw-r--r--xmpp-vala/src/module/presence/stanza.vala6
-rw-r--r--xmpp-vala/src/module/roster/flag.vala6
-rw-r--r--xmpp-vala/src/module/roster/item.vala11
-rw-r--r--xmpp-vala/src/module/roster/module.vala8
-rw-r--r--xmpp-vala/src/module/roster/versioning_module.vala2
-rw-r--r--xmpp-vala/src/module/sasl.vala10
-rw-r--r--xmpp-vala/src/module/session.vala4
-rw-r--r--xmpp-vala/src/module/stanza.vala102
-rw-r--r--xmpp-vala/src/module/stanza_error.vala4
-rw-r--r--xmpp-vala/src/module/stream_error.vala2
-rw-r--r--xmpp-vala/src/module/tls.vala4
-rw-r--r--xmpp-vala/src/module/util.vala36
-rw-r--r--xmpp-vala/src/module/xep/0004_data_forms.vala2
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/flag.vala20
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala2
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/item.vala4
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala4
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/module.vala8
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/flag.vala119
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/module.vala101
-rw-r--r--xmpp-vala/src/module/xep/0048_bookmarks/conference.vala13
-rw-r--r--xmpp-vala/src/module/xep/0048_bookmarks/module.vala16
-rw-r--r--xmpp-vala/src/module/xep/0049_private_xml_storage.vala4
-rw-r--r--xmpp-vala/src/module/xep/0054_vcard/module.vala8
-rw-r--r--xmpp-vala/src/module/xep/0060_pubsub.vala16
-rw-r--r--xmpp-vala/src/module/xep/0066_out_of_band_data.vala6
-rw-r--r--xmpp-vala/src/module/xep/0084_user_avatars.vala8
-rw-r--r--xmpp-vala/src/module/xep/0085_chat_state_notifications.vala28
-rw-r--r--xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala2
-rw-r--r--xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala28
-rw-r--r--xmpp-vala/src/module/xep/0191_blocking_command.vala2
-rw-r--r--xmpp-vala/src/module/xep/0198_stream_management.vala2
-rw-r--r--xmpp-vala/src/module/xep/0199_ping.vala4
-rw-r--r--xmpp-vala/src/module/xep/0203_delayed_delivery.vala94
-rw-r--r--xmpp-vala/src/module/xep/0280_message_carbons.vala96
-rw-r--r--xmpp-vala/src/module/xep/0313_message_archive_management.vala22
-rw-r--r--xmpp-vala/src/module/xep/0333_chat_markers.vala30
-rw-r--r--xmpp-vala/src/module/xep/0368_srv_records_tls.vala6
-rw-r--r--xmpp-vala/tests/common.vala4
55 files changed, 572 insertions, 521 deletions
diff --git a/xmpp-vala/CMakeLists.txt b/xmpp-vala/CMakeLists.txt
index 6b08c765..3190fad0 100644
--- a/xmpp-vala/CMakeLists.txt
+++ b/xmpp-vala/CMakeLists.txt
@@ -21,6 +21,7 @@ SOURCES
"src/module/bind.vala"
"src/module/iq/module.vala"
"src/module/iq/stanza.vala"
+ "src/module/jid.vala"
"src/module/message/module.vala"
"src/module/message/stanza.vala"
"src/module/presence/flag.vala"
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;
}
diff --git a/xmpp-vala/src/module/bind.vala b/xmpp-vala/src/module/bind.vala
index 71aae149..a3b0762b 100644
--- a/xmpp-vala/src/module/bind.vala
+++ b/xmpp-vala/src/module/bind.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.Bind {
private const string NS_URI = "urn:ietf:params:xml:ns:xmpp-bind";
@@ -9,7 +7,7 @@ namespace Xmpp.Bind {
public string requested_resource { get; set; }
- public signal void bound_to_resource(XmppStream stream, string my_jid);
+ public signal void bound_to_resource(XmppStream stream, Jid my_jid);
public Module(string requested_resource) {
this.requested_resource = requested_resource;
@@ -20,7 +18,7 @@ namespace Xmpp.Bind {
if (flag == null || flag.finished) return;
if (iq.type_ == Iq.Stanza.TYPE_RESULT) {
- flag.my_jid = iq.stanza.get_subnode("jid", NS_URI, true).get_string_content();
+ flag.my_jid = Jid.parse(iq.stanza.get_subnode("jid", NS_URI, true).get_string_content());
flag.finished = true;
bound_to_resource(stream, flag.my_jid);
}
@@ -62,7 +60,7 @@ namespace Xmpp.Bind {
public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "bind");
- public string? my_jid;
+ public Jid? my_jid;
public bool finished = false;
public override string get_ns() { return NS_URI; }
diff --git a/xmpp-vala/src/module/iq/module.vala b/xmpp-vala/src/module/iq/module.vala
index 7a2425b4..45ba9d09 100644
--- a/xmpp-vala/src/module/iq/module.vala
+++ b/xmpp-vala/src/module/iq/module.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Iq {
private const string NS_URI = "jabber:client";
diff --git a/xmpp-vala/src/module/iq/stanza.vala b/xmpp-vala/src/module/iq/stanza.vala
index 8f114c9f..3c938883 100644
--- a/xmpp-vala/src/module/iq/stanza.vala
+++ b/xmpp-vala/src/module/iq/stanza.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Iq {
public class Stanza : Xmpp.Stanza {
@@ -44,7 +42,7 @@ public class Stanza : Xmpp.Stanza {
stanza.put_node(associated_child);
}
}
- public Stanza.from_stanza(StanzaNode stanza_node, string? my_jid) {
+ public Stanza.from_stanza(StanzaNode stanza_node, Jid? my_jid) {
base.incoming(stanza_node, my_jid);
}
}
diff --git a/xmpp-vala/src/module/jid.vala b/xmpp-vala/src/module/jid.vala
new file mode 100644
index 00000000..c20e0202
--- /dev/null
+++ b/xmpp-vala/src/module/jid.vala
@@ -0,0 +1,107 @@
+namespace Xmpp {
+
+public class Jid {
+ public string? localpart;
+ public string domainpart;
+ public string? resourcepart;
+
+ public Jid bare_jid {
+ owned get { return is_bare() ? this : new Jid.components(localpart, domainpart, null); }
+ }
+
+ public Jid domain_jid {
+ owned get { return is_domain() ? this : new Jid.components(null, domainpart, null); }
+ }
+
+ private string jid;
+
+ public Jid(string jid) {
+ Jid? parsed = Jid.parse(jid);
+ string? localpart = parsed != null ? (owned) parsed.localpart : null;
+ string domainpart = parsed != null ? (owned) parsed.domainpart : jid;
+ string? resourcepart = parsed != null ? (owned) parsed.resourcepart : null;
+ this.intern(jid, (owned) localpart, (owned) domainpart, (owned) resourcepart);
+ }
+
+ private Jid.intern(owned string jid, owned string? localpart, owned string domainpart, owned string? resourcepart) {
+ this.jid = (owned) jid;
+ this.localpart = (owned) localpart;
+ this.domainpart = (owned) domainpart;
+ this.resourcepart = (owned) resourcepart;
+ }
+
+ public Jid.components(owned string? localpart, owned string domainpart, owned string? resourcepart) {
+ string jid = domainpart;
+ if (localpart != null) {
+ jid = @"$localpart@$jid";
+ }
+ if (resourcepart != null) {
+ jid = @"$jid/$resourcepart";
+ }
+ this.jid = jid;
+ this.localpart = (owned) localpart;
+ this.domainpart = (owned) domainpart;
+ this.resourcepart = (owned) resourcepart;
+ }
+
+ public static Jid? parse(string jid) {
+ int slash_index = jid.index_of("/");
+ string resourcepart = slash_index == -1 ? null : jid.slice(slash_index + 1, jid.length);
+ string bare_jid = slash_index == -1 ? jid : jid.slice(0, slash_index);
+ int at_index = bare_jid.index_of("@");
+ string localpart = at_index == -1 ? null : bare_jid.slice(0, at_index);
+ string domainpart = at_index == -1 ? bare_jid : bare_jid.slice(at_index + 1, bare_jid.length);
+
+ if (domainpart == "") return null;
+ if (slash_index != -1 && resourcepart == "") return null;
+ if (at_index != -1 && localpart == "") return null;
+
+ return new Jid.intern(jid, (owned) localpart, (owned) domainpart, (owned) resourcepart);
+ }
+
+ public Jid with_resource(string? resourcepart) {
+ return new Jid.components(localpart, domainpart, resourcepart);
+ }
+
+ public bool is_domain() {
+ return localpart == null && resourcepart == null;
+ }
+
+ public bool is_bare() {
+ return localpart != null && resourcepart == null;
+ }
+
+ public bool is_full() {
+ return localpart != null && resourcepart != null;
+ }
+
+ public string to_string() {
+ return jid;
+ }
+
+ public bool equals_bare(Jid? jid) {
+ return jid != null && equals_bare_func(this, jid);
+ }
+
+ public bool equals(Jid? jid) {
+ return jid != null && equals_func(this, jid);
+ }
+
+ public static new bool equals_bare_func(Jid jid1, Jid jid2) {
+ return jid1.bare_jid.to_string() == jid2.bare_jid.to_string();
+ }
+
+ public static bool equals_func(Jid jid1, Jid jid2) {
+ return jid1.to_string() == jid2.to_string();
+ }
+
+ public static new uint hash_bare_func(Jid jid) {
+ return jid.bare_jid.to_string().hash();
+ }
+
+ public static new uint hash_func(Jid jid) {
+ return jid.to_string().hash();
+ }
+}
+
+}
diff --git a/xmpp-vala/src/module/message/module.vala b/xmpp-vala/src/module/message/module.vala
index afa3f005..cfb1d750 100644
--- a/xmpp-vala/src/module/message/module.vala
+++ b/xmpp-vala/src/module/message/module.vala
@@ -1,27 +1,27 @@
using Gee;
-using Xmpp.Core;
-namespace Xmpp.Message {
+
+namespace Xmpp {
private const string NS_URI = "jabber:client";
- public class Module : XmppStreamModule {
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "message_module");
+ public class MessageModule : XmppStreamModule {
+ public static ModuleIdentity<MessageModule> IDENTITY = new ModuleIdentity<MessageModule>(NS_URI, "message_module");
- public StanzaListenerHolder<Message.Stanza> received_pipeline = new StanzaListenerHolder<Message.Stanza>();
- public StanzaListenerHolder<Message.Stanza> send_pipeline = new StanzaListenerHolder<Message.Stanza>();
+ public StanzaListenerHolder<MessageStanza> received_pipeline = new StanzaListenerHolder<MessageStanza>();
+ public StanzaListenerHolder<MessageStanza> send_pipeline = new StanzaListenerHolder<MessageStanza>();
- public signal void pre_received_message(XmppStream stream, Message.Stanza message);
- public signal void received_message(XmppStream stream, Message.Stanza message);
+ public signal void pre_received_message(XmppStream stream, MessageStanza message);
+ public signal void received_message(XmppStream stream, MessageStanza message);
- public void send_message(XmppStream stream, Message.Stanza message) {
+ public void send_message(XmppStream stream, MessageStanza message) {
send_pipeline.run.begin(stream, message, (obj, res) => {
stream.write(message.stanza);
});
}
public async void received_message_stanza_async(XmppStream stream, StanzaNode node) {
- Message.Stanza message = new Message.Stanza.from_stanza(node, stream.get_flag(Bind.Flag.IDENTITY).my_jid);
+ MessageStanza message = new MessageStanza.from_stanza(node, stream.get_flag(Bind.Flag.IDENTITY).my_jid);
yield received_pipeline.run(stream, message);
received_message(stream, message);
}
diff --git a/xmpp-vala/src/module/message/stanza.vala b/xmpp-vala/src/module/message/stanza.vala
index 2b60c517..640f2796 100644
--- a/xmpp-vala/src/module/message/stanza.vala
+++ b/xmpp-vala/src/module/message/stanza.vala
@@ -1,10 +1,8 @@
using Gee;
-using Xmpp.Core;
+namespace Xmpp {
-namespace Xmpp.Message {
-
-public class Stanza : Xmpp.Stanza {
+public class MessageStanza : Xmpp.Stanza {
public const string NODE_BODY = "body";
public const string NODE_SUBJECT = "subject";
public const string NODE_THREAD = "thread";
@@ -40,12 +38,12 @@ public class Stanza : Xmpp.Stanza {
set { base.type_ = value; }
}
- public Stanza(string? id = null) {
+ public MessageStanza(string? id = null) {
base.outgoing(new StanzaNode.build("message"));
stanza.set_attribute(ATTRIBUTE_ID, id ?? random_uuid());
}
- public Stanza.from_stanza(StanzaNode stanza_node, string my_jid) {
+ public MessageStanza.from_stanza(StanzaNode stanza_node, Jid my_jid) {
base.incoming(stanza_node, my_jid);
}
diff --git a/xmpp-vala/src/module/presence/flag.vala b/xmpp-vala/src/module/presence/flag.vala
index 8fb44e13..bb3562a4 100644
--- a/xmpp-vala/src/module/presence/flag.vala
+++ b/xmpp-vala/src/module/presence/flag.vala
@@ -1,60 +1,60 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Presence {
public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "presence");
- private HashMap<string, ConcurrentList<string>> resources = new HashMap<string, ConcurrentList<string>>();
- private HashMap<string, Presence.Stanza> presences = new HashMap<string, Presence.Stanza>();
+ private HashMap<Jid, Gee.List<Jid>> resources = new HashMap<Jid, Gee.List<Jid>>(Jid.hash_bare_func, Jid.equals_bare_func);
+ private HashMap<Jid, Presence.Stanza> presences = new HashMap<Jid, Presence.Stanza>(Jid.hash_func, Jid.equals_func);
- public Set<string> get_available_jids() {
+ public Set<Jid> get_available_jids() {
return resources.keys;
}
- public Gee.List<string>? get_resources(string bare_jid) {
- return resources[bare_jid];
+ public Gee.List<Jid>? get_resources(Jid jid) {
+ return resources[jid];
}
- public Presence.Stanza? get_presence(string full_jid) {
+ public Presence.Stanza? get_presence(Jid full_jid) {
return presences[full_jid];
}
public void add_presence(Presence.Stanza presence) {
- string bare_jid = get_bare_jid(presence.from);
- if (!resources.has_key(bare_jid)) {
- resources[bare_jid] = new ConcurrentList<string>();
+ if (!resources.has_key(presence.from)) {
+ resources[presence.from] = new ArrayList<Jid>(Jid.equals_func);
}
- if (resources[bare_jid].contains(presence.from)) {
- resources[bare_jid].remove(presence.from);
+ if (resources[presence.from].contains(presence.from)) {
+ resources[presence.from].remove(presence.from);
}
- resources[bare_jid].add(presence.from);
+ resources[presence.from].add(presence.from);
presences[presence.from] = presence;
}
- public void remove_presence(string jid) {
- string bare_jid = get_bare_jid(jid);
- if (resources.has_key(bare_jid)) {
- if (is_bare_jid(jid)) {
- foreach (string full_jid in resources[jid]) {
+ public void remove_presence(Jid jid) {
+ if (resources.has_key(jid)) {
+ if (jid.is_bare()) {
+ foreach (Jid full_jid in resources[jid]) {
presences.unset(full_jid);
}
resources.unset(jid);
} else {
- resources[bare_jid].remove(jid);
- if (resources[bare_jid].size == 0) {
- resources.unset(bare_jid);
+ resources[jid].remove(jid);
+ if (resources[jid].size == 0) {
+ resources.unset(jid);
}
presences.unset(jid);
}
}
}
- public override string get_ns() { return NS_URI; }
+ public override string get_ns() {
+ return NS_URI;
+ }
- public override string get_id() { return IDENTITY.id; }
+ public override string get_id() {
+ return IDENTITY.id;
+ }
}
} \ No newline at end of file
diff --git a/xmpp-vala/src/module/presence/module.vala b/xmpp-vala/src/module/presence/module.vala
index 3488f532..cbc7d365 100644
--- a/xmpp-vala/src/module/presence/module.vala
+++ b/xmpp-vala/src/module/presence/module.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.Presence {
private const string NS_URI = "jabber:client";
@@ -10,39 +8,39 @@ namespace Xmpp.Presence {
public signal void pre_send_presence_stanza(XmppStream stream, Presence.Stanza presence);
public signal void initial_presence_sent(XmppStream stream, Presence.Stanza presence);
public signal void received_available(XmppStream stream, Presence.Stanza presence);
- public signal void received_available_show(XmppStream stream, string jid, string show);
+ public signal void received_available_show(XmppStream stream, Jid jid, string show);
public signal void received_unavailable(XmppStream stream, Presence.Stanza presence);
- public signal void received_subscription_request(XmppStream stream, string jid);
- public signal void received_unsubscription(XmppStream stream, string jid);
+ public signal void received_subscription_request(XmppStream stream, Jid jid);
+ public signal void received_unsubscription(XmppStream stream, Jid jid);
public bool available_resource = true;
- public void request_subscription(XmppStream stream, string bare_jid) {
+ public void request_subscription(XmppStream stream, Jid bare_jid) {
Presence.Stanza presence = new Presence.Stanza();
presence.to = bare_jid;
presence.type_ = Presence.Stanza.TYPE_SUBSCRIBE;
send_presence(stream, presence);
}
- public void approve_subscription(XmppStream stream, string bare_jid) {
+ public void approve_subscription(XmppStream stream, Jid bare_jid) {
Presence.Stanza presence = new Presence.Stanza();
presence.to = bare_jid;
presence.type_ = Presence.Stanza.TYPE_SUBSCRIBED;
send_presence(stream, presence);
}
- public void deny_subscription(XmppStream stream, string bare_jid) {
+ public void deny_subscription(XmppStream stream, Jid bare_jid) {
cancel_subscription(stream, bare_jid);
}
- public void cancel_subscription(XmppStream stream, string bare_jid) {
+ public void cancel_subscription(XmppStream stream, Jid bare_jid) {
Presence.Stanza presence = new Presence.Stanza();
presence.to = bare_jid;
presence.type_ = Presence.Stanza.TYPE_UNSUBSCRIBED;
send_presence(stream, presence);
}
- public void unsubscribe(XmppStream stream, string bare_jid) {
+ public void unsubscribe(XmppStream stream, Jid bare_jid) {
Presence.Stanza presence = new Presence.Stanza();
presence.to = bare_jid;
presence.type_ = Presence.Stanza.TYPE_UNSUBSCRIBE;
diff --git a/xmpp-vala/src/module/presence/stanza.vala b/xmpp-vala/src/module/presence/stanza.vala
index 0926555e..a7bcbb56 100644
--- a/xmpp-vala/src/module/presence/stanza.vala
+++ b/xmpp-vala/src/module/presence/stanza.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.Presence {
public class Stanza : Xmpp.Stanza {
@@ -85,9 +83,9 @@ public class Stanza : Xmpp.Stanza {
this.id = id ?? random_uuid();
}
- public Stanza.from_stanza(StanzaNode stanza_node, string my_jid) {
+ public Stanza.from_stanza(StanzaNode stanza_node, Jid my_jid) {
base.incoming(stanza_node, my_jid);
}
}
-} \ No newline at end of file
+}
diff --git a/xmpp-vala/src/module/roster/flag.vala b/xmpp-vala/src/module/roster/flag.vala
index 43d185d9..2e93911e 100644
--- a/xmpp-vala/src/module/roster/flag.vala
+++ b/xmpp-vala/src/module/roster/flag.vala
@@ -1,14 +1,12 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Roster {
public class Flag : XmppStreamFlag {
public const string ID = "roster";
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, ID);
- public HashMap<string, Item> roster_items = new HashMap<string, Item>();
+ public HashMap<Jid, Item> roster_items = new HashMap<Jid, Item>();
public string? iq_id;
@@ -16,7 +14,7 @@ public class Flag : XmppStreamFlag {
return roster_items.values;
}
- public Item? get_item(string jid) {
+ public Item? get_item(Jid jid) {
return roster_items[jid];
}
diff --git a/xmpp-vala/src/module/roster/item.vala b/xmpp-vala/src/module/roster/item.vala
index 1e39fce2..2fbf03ef 100644
--- a/xmpp-vala/src/module/roster/item.vala
+++ b/xmpp-vala/src/module/roster/item.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Roster {
public class Item {
@@ -18,9 +16,10 @@ public class Item {
public StanzaNode stanza_node;
- public string jid {
- get { return stanza_node.get_attribute(NODE_JID); }
- set { stanza_node.set_attribute(NODE_JID, value); }
+ private Jid jid_;
+ public Jid jid {
+ get { return jid_ ?? (jid_ = Jid.parse(stanza_node.get_attribute(NODE_JID))); }
+ set { stanza_node.set_attribute(NODE_JID, value.to_string()); }
}
public string? name {
@@ -42,4 +41,4 @@ public class Item {
}
}
-} \ No newline at end of file
+}
diff --git a/xmpp-vala/src/module/roster/module.vala b/xmpp-vala/src/module/roster/module.vala
index 85693686..5b15a43a 100644
--- a/xmpp-vala/src/module/roster/module.vala
+++ b/xmpp-vala/src/module/roster/module.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Roster {
private const string NS_URI = "jabber:iq:roster";
@@ -16,7 +14,7 @@ public class Module : XmppStreamModule, Iq.Handler {
public bool interested_resource = true;
- public void add_jid(XmppStream stream, string jid, string? handle = null) {
+ public void add_jid(XmppStream stream, Jid jid, string? handle = null) {
Item roster_item = new Item();
roster_item.jid = jid;
if (handle != null) {
@@ -25,7 +23,7 @@ public class Module : XmppStreamModule, Iq.Handler {
roster_set(stream, roster_item);
}
- public void remove_jid(XmppStream stream, string jid) {
+ public void remove_jid(XmppStream stream, Jid jid) {
Item roster_item = new Item();
roster_item.jid = jid;
roster_item.subscription = Item.SUBSCRIPTION_REMOVE;
@@ -37,7 +35,7 @@ public class Module : XmppStreamModule, Iq.Handler {
* Set a handle for a jid
* @param handle Handle to be set. If null, any handle will be removed.
*/
- public void set_jid_handle(XmppStream stream, string jid, string? handle) {
+ public void set_jid_handle(XmppStream stream, Jid jid, string? handle) {
Flag flag = stream.get_flag(Flag.IDENTITY);
Item item = flag.get_item(jid) ?? new Item() { jid=jid };
item.name = handle != null ? handle : "";
diff --git a/xmpp-vala/src/module/roster/versioning_module.vala b/xmpp-vala/src/module/roster/versioning_module.vala
index ce87ec2a..aa683883 100644
--- a/xmpp-vala/src/module/roster/versioning_module.vala
+++ b/xmpp-vala/src/module/roster/versioning_module.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Roster {
public class VersioningModule : XmppStreamModule {
diff --git a/xmpp-vala/src/module/sasl.vala b/xmpp-vala/src/module/sasl.vala
index d15c4549..4a427ce0 100644
--- a/xmpp-vala/src/module/sasl.vala
+++ b/xmpp-vala/src/module/sasl.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.PlainSasl {
private const string NS_URI = "urn:ietf:params:xml:ns:xmpp-sasl";
@@ -56,16 +54,16 @@ namespace Xmpp.PlainSasl {
}
}
if (!supportsPlain) {
- stderr.printf("Server at %s does not support %s auth, use full-features Sasl implementation!\n", stream.remote_name, MECHANISM);
+ stderr.printf("Server at %s does not support %s auth, use full-features Sasl implementation!\n", stream.remote_name.to_string(), MECHANISM);
return;
}
if (!name.contains("@")) {
- name = "%s@%s".printf(name, stream.remote_name);
+ name = "%s@%s".printf(name, stream.remote_name.to_string());
}
if (!use_full_name && name.contains("@")) {
var split = name.split("@");
- if (split[1] == stream.remote_name) {
+ if (split[1] == stream.remote_name.to_string()) {
name = split[0];
} else {
use_full_name = true;
@@ -74,7 +72,7 @@ namespace Xmpp.PlainSasl {
var name = this.name;
if (!use_full_name && name.contains("@")) {
var split = name.split("@");
- if (split[1] == stream.remote_name) {
+ if (split[1] == stream.remote_name.to_string()) {
name = split[0];
}
}
diff --git a/xmpp-vala/src/module/session.vala b/xmpp-vala/src/module/session.vala
index babf735c..c9e88a27 100644
--- a/xmpp-vala/src/module/session.vala
+++ b/xmpp-vala/src/module/session.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
/* Legacy. RFC 3921 3*/
namespace Xmpp.Session {
private const string NS_URI = "urn:ietf:params:xml:ns:xmpp-session";
@@ -24,7 +22,7 @@ public class Module : XmppStreamNegotiationModule {
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private void on_bound_resource(XmppStream stream, string my_jid) {
+ private void on_bound_resource(XmppStream stream, Jid my_jid) {
StanzaNode? session_node = stream.features.get_subnode("session", NS_URI);
if (session_node != null && session_node.get_subnode("optional", NS_URI) == null) {
stream.add_flag(new Flag());
diff --git a/xmpp-vala/src/module/stanza.vala b/xmpp-vala/src/module/stanza.vala
index 2bf3e29b..abdc33e9 100644
--- a/xmpp-vala/src/module/stanza.vala
+++ b/xmpp-vala/src/module/stanza.vala
@@ -1,70 +1,70 @@
-using Xmpp.Core;
-
namespace Xmpp {
- public class Stanza : Object {
+public class Stanza : Object {
- public const string ATTRIBUTE_FROM = "from";
- public const string ATTRIBUTE_ID = "id";
- public const string ATTRIBUTE_TO = "to";
- public const string ATTRIBUTE_TYPE = "type";
+ public const string ATTRIBUTE_FROM = "from";
+ public const string ATTRIBUTE_ID = "id";
+ public const string ATTRIBUTE_TO = "to";
+ public const string ATTRIBUTE_TYPE = "type";
- public const string TYPE_ERROR = "error";
+ public const string TYPE_ERROR = "error";
- private string? my_jid;
+ private Jid? my_jid;
+ private Jid? from_;
+ private Jid? to_;
- public virtual string? from {
- owned get {
- string? from_attribute = stanza.get_attribute(ATTRIBUTE_FROM);
- // "when a client receives a stanza that does not include a 'from' attribute, it MUST assume that the stanza
- // is from the user's account on the server." (RFC6120 8.1.2.1)
- if (from_attribute != null) return from_attribute;
- if (my_jid != null) {
- string my_bare_jid = get_bare_jid(my_jid); // has to be left-side value
- return my_bare_jid;
- }
- return null;
+ public virtual Jid? from {
+ owned get {
+ string? from_attribute = stanza.get_attribute(ATTRIBUTE_FROM);
+ // "when a client receives a stanza that does not include a 'from' attribute, it MUST assume that the stanza
+ // is from the user's account on the server." (RFC6120 8.1.2.1)
+ if (from_attribute != null) return from_ = Jid.parse(from_attribute);
+ if (my_jid != null) {
+ return my_jid.bare_jid;
}
- set { stanza.set_attribute(ATTRIBUTE_FROM, value); }
+ return null;
}
+ set { stanza.set_attribute(ATTRIBUTE_FROM, value.to_string()); }
+ }
- public virtual string? id {
- get { return stanza.get_attribute(ATTRIBUTE_ID); }
- set { stanza.set_attribute(ATTRIBUTE_ID, value); }
- }
+ public virtual string? id {
+ get { return stanza.get_attribute(ATTRIBUTE_ID); }
+ set { stanza.set_attribute(ATTRIBUTE_ID, value); }
+ }
- public virtual string? to {
- owned get {
- string? to_attribute = stanza.get_attribute(ATTRIBUTE_TO);
- // "if the stanza does not include a 'to' address then the client MUST treat it as if the 'to' address were
- // included with a value of the client's full JID." (RFC6120 8.1.1.1)
- return to_attribute == null ? my_jid : to_attribute;
- }
- set { stanza.set_attribute(ATTRIBUTE_TO, value); }
+ public virtual Jid? to {
+ owned get {
+ string? to_attribute = stanza.get_attribute(ATTRIBUTE_TO);
+ // "if the stanza does not include a 'to' address then the client MUST treat it as if the 'to' address were
+ // included with a value of the client's full JID." (RFC6120 8.1.1.1)
+ return to_attribute == null ? my_jid : to_ = Jid.parse(to_attribute);
}
+ set { stanza.set_attribute(ATTRIBUTE_TO, value.to_string()); }
+ }
- public virtual string? type_ {
- get { return stanza.get_attribute(ATTRIBUTE_TYPE); }
- set { stanza.set_attribute(ATTRIBUTE_TYPE, value); }
- }
+ public virtual string? type_ {
+ get { return stanza.get_attribute(ATTRIBUTE_TYPE); }
+ set { stanza.set_attribute(ATTRIBUTE_TYPE, value); }
+ }
- public StanzaNode stanza;
+ public StanzaNode stanza;
- public Stanza.incoming(StanzaNode stanza, string? my_jid) {
- this.stanza = stanza;
- this.my_jid = my_jid;
- }
+ public Stanza.incoming(StanzaNode stanza, Jid? my_jid) {
+ this.stanza = stanza;
+ this.my_jid = my_jid;
+ }
- public Stanza.outgoing(StanzaNode stanza) {
- this.stanza = stanza;
- }
+ public Stanza.outgoing(StanzaNode stanza) {
+ this.stanza = stanza;
+ }
- public bool is_error() {
- return type_ == TYPE_ERROR;
- }
+ public bool is_error() {
+ return type_ == TYPE_ERROR;
+ }
- public ErrorStanza? get_error() {
- return new ErrorStanza.from_stanza(this.stanza);
- }
+ public ErrorStanza? get_error() {
+ return new ErrorStanza.from_stanza(this.stanza);
}
+}
+
} \ No newline at end of file
diff --git a/xmpp-vala/src/module/stanza_error.vala b/xmpp-vala/src/module/stanza_error.vala
index 3543d3ed..51aa2629 100644
--- a/xmpp-vala/src/module/stanza_error.vala
+++ b/xmpp-vala/src/module/stanza_error.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp {
public class ErrorStanza {
@@ -66,4 +64,4 @@ namespace Xmpp {
error_node = stanza.get_subnode("error");
}
}
-} \ No newline at end of file
+}
diff --git a/xmpp-vala/src/module/stream_error.vala b/xmpp-vala/src/module/stream_error.vala
index fa54d06f..f1cfbf3a 100644
--- a/xmpp-vala/src/module/stream_error.vala
+++ b/xmpp-vala/src/module/stream_error.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.StreamError {
private const string NS_URI = "jabber:client";
private const string NS_ERROR = "urn:ietf:params:xml:ns:xmpp-streams";
diff --git a/xmpp-vala/src/module/tls.vala b/xmpp-vala/src/module/tls.vala
index 5defc72c..7118a321 100644
--- a/xmpp-vala/src/module/tls.vala
+++ b/xmpp-vala/src/module/tls.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.Tls {
private const string NS_URI = "urn:ietf:params:xml:ns:xmpp-tls";
@@ -52,7 +50,7 @@ namespace Xmpp.Tls {
stream.write(new StanzaNode.build("starttls", NS_URI).add_self_xmlns());
}
if (identity == null) {
- identity = new NetworkService("xmpp-client", "tcp", stream.remote_name);
+ identity = new NetworkService("xmpp-client", "tcp", stream.remote_name.to_string());
}
stream.add_flag(new Flag());
}
diff --git a/xmpp-vala/src/module/util.vala b/xmpp-vala/src/module/util.vala
index e42c4768..1043dee1 100644
--- a/xmpp-vala/src/module/util.vala
+++ b/xmpp-vala/src/module/util.vala
@@ -1,32 +1,22 @@
using Gee;
namespace Xmpp {
- public string get_bare_jid(string jid) {
- return jid.split("/")[0];
- }
-
- public bool is_bare_jid(string jid) {
- return !jid.contains("/");
- }
-
- public string? get_resource_part(string jid) {
- return jid.split("/")[1];
- }
- public string random_uuid() {
- uint32 b1 = Random.next_int();
- uint16 b2 = (uint16)Random.next_int();
- uint16 b3 = (uint16)(Random.next_int() | 0x4000u) & ~0xb000u;
- uint16 b4 = (uint16)(Random.next_int() | 0x8000u) & ~0x4000u;
- uint16 b5_1 = (uint16)Random.next_int();
- uint32 b5_2 = Random.next_int();
- return "%08x-%04x-%04x-%04x-%04x%08x".printf(b1, b2, b3, b4, b5_1, b5_2);
- }
+public string random_uuid() {
+ uint32 b1 = Random.next_int();
+ uint16 b2 = (uint16)Random.next_int();
+ uint16 b3 = (uint16)(Random.next_int() | 0x4000u) & ~0xb000u;
+ uint16 b4 = (uint16)(Random.next_int() | 0x8000u) & ~0x4000u;
+ uint16 b5_1 = (uint16)Random.next_int();
+ uint32 b5_2 = Random.next_int();
+ return "%08x-%04x-%04x-%04x-%04x%08x".printf(b1, b2, b3, b4, b5_1, b5_2);
+}
public abstract class StanzaListener<T> : Object {
public abstract string action_group { get; }
public abstract string[] after_actions { get; }
- public abstract async void run(Core.XmppStream stream, T stanza);
+
+ public abstract async void run(XmppStream stream, T stanza);
}
public class StanzaListenerHolder<T> : Object {
@@ -42,14 +32,14 @@ public class StanzaListenerHolder<T> : Object {
resort_list();
}
- public async void run(Core.XmppStream stream, T stanza) {
+ public async void run(XmppStream stream, T stanza) {
foreach (StanzaListener<T> l in listeners) {
yield l.run(stream, stanza);
}
}
private bool set_contains_action(Gee.List<StanzaListener<T>> s, string[] actions) {
- foreach(StanzaListener<T> l in s) {
+ foreach (StanzaListener<T> l in s) {
if (l.action_group in actions) {
return true;
}
diff --git a/xmpp-vala/src/module/xep/0004_data_forms.vala b/xmpp-vala/src/module/xep/0004_data_forms.vala
index 57ff834a..69c14b08 100644
--- a/xmpp-vala/src/module/xep/0004_data_forms.vala
+++ b/xmpp-vala/src/module/xep/0004_data_forms.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.DataForms {
public const string NS_URI = "jabber:x:data";
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala b/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
index 4f3e5eea..4661fede 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
@@ -1,22 +1,20 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.ServiceDiscovery {
public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "service_discovery");
- private HashMap<string, Gee.List<string>?> entity_features = new HashMap<string, Gee.List<string>?>();
- private HashMap<string, Gee.List<Identity>?> entity_identities = new HashMap<string, Gee.List<Identity>?>();
- private HashMap<string, Gee.List<Item>?> entity_items = new HashMap<string, Gee.List<Item>?>();
+ private HashMap<Jid, Gee.List<string>?> entity_features = new HashMap<Jid, Gee.List<string>?>(Jid.hash_func, Jid.equals_func);
+ private HashMap<Jid, Gee.List<Identity>?> entity_identities = new HashMap<Jid, Gee.List<Identity>?>(Jid.hash_func, Jid.equals_func);
+ private HashMap<Jid, Gee.List<Item>?> entity_items = new HashMap<Jid, Gee.List<Item>?>(Jid.hash_func, Jid.equals_func);
public Gee.List<string> features = new ArrayList<string>();
- public Gee.List<Identity>? get_entity_categories(string jid) {
+ public Gee.List<Identity>? get_entity_categories(Jid jid) {
return entity_identities.has_key(jid) ? entity_identities[jid] : null; // TODO isn’t this default for hashmap
}
- public bool? has_entity_identity(string jid, string category, string type) {
+ public bool? has_entity_identity(Jid jid, string category, string type) {
if (!entity_identities.has_key(jid)) return null;
if (entity_identities[jid] == null) return false;
foreach (Identity identity in entity_identities[jid]) {
@@ -25,21 +23,21 @@ public class Flag : XmppStreamFlag {
return false;
}
- public bool? has_entity_feature(string jid, string feature) {
+ public bool? has_entity_feature(Jid jid, string feature) {
if (!entity_features.has_key(jid)) return null;
if (entity_features[jid] == null) return false;
return entity_features[jid].contains(feature);
}
- public void set_entity_identities(string jid, Gee.List<Identity>? identities) {
+ public void set_entity_identities(Jid jid, Gee.List<Identity>? identities) {
entity_identities[jid] = identities;
}
- public void set_entity_features(string jid, Gee.List<string>? features) {
+ public void set_entity_features(Jid jid, Gee.List<string>? features) {
entity_features[jid] = features;
}
- public void set_entity_items(string jid, Gee.List<Item>? features) {
+ public void set_entity_items(Jid jid, Gee.List<Item>? features) {
entity_items[jid] = features;
}
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala b/xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala
index ca0fba5b..dc7f1e48 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.ServiceDiscovery {
public class InfoResult {
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/item.vala b/xmpp-vala/src/module/xep/0030_service_discovery/item.vala
index 9d8f1f3e..84445db0 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/item.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/item.vala
@@ -1,11 +1,11 @@
namespace Xmpp.Xep.ServiceDiscovery {
public class Item {
- public string jid;
+ public Jid jid;
public string? name;
public string? node;
- public Item(string jid, string? name = null, string? node = null) {
+ public Item(Jid jid, string? name = null, string? node = null) {
this.jid = jid;
this.name = name;
this.node = node;
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala b/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala
index 52de5efc..16a9f5ec 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.ServiceDiscovery {
public class ItemsResult {
@@ -11,7 +9,7 @@ public class ItemsResult {
owned get {
ArrayList<Item> ret = new ArrayList<Item>();
foreach (StanzaNode feature_node in iq.stanza.get_subnode("query", NS_URI_ITEMS).get_subnodes("item", NS_URI_ITEMS)) {
- ret.add(new Item(feature_node.get_attribute("jid", NS_URI_ITEMS),
+ ret.add(new Item(Jid.parse(feature_node.get_attribute("jid", NS_URI_ITEMS)),
feature_node.get_attribute("name", NS_URI_ITEMS),
feature_node.get_attribute("node", NS_URI_ITEMS)));
}
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
index 011a1f36..2b955738 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.ServiceDiscovery {
private const string NS_URI = "http://jabber.org/protocol/disco";
@@ -30,7 +28,7 @@ public class Module : XmppStreamModule, Iq.Handler {
}
public delegate void HasEntryCategoryRes(XmppStream stream, Gee.List<Identity>? identities);
- public void get_entity_categories(XmppStream stream, string jid, owned HasEntryCategoryRes listener) {
+ public void get_entity_categories(XmppStream stream, Jid jid, owned HasEntryCategoryRes listener) {
Gee.List<Identity>? res = stream.get_flag(Flag.IDENTITY).get_entity_categories(jid);
if (res != null) listener(stream, res);
request_info(stream, jid, (stream, query_result) => {
@@ -39,7 +37,7 @@ public class Module : XmppStreamModule, Iq.Handler {
}
public delegate void OnInfoResult(XmppStream stream, InfoResult? query_result);
- public void request_info(XmppStream stream, string jid, owned OnInfoResult listener) {
+ public void request_info(XmppStream stream, Jid jid, owned OnInfoResult listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_INFO).add_self_xmlns());
iq.to = jid;
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
@@ -51,7 +49,7 @@ public class Module : XmppStreamModule, Iq.Handler {
}
public delegate void OnItemsResult(XmppStream stream, ItemsResult query_result);
- public void request_items(XmppStream stream, string jid, owned OnItemsResult listener) {
+ public void request_items(XmppStream stream, Jid jid, owned OnItemsResult listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_ITEMS).add_self_xmlns());
iq.to = jid;
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
diff --git a/xmpp-vala/src/module/xep/0045_muc/flag.vala b/xmpp-vala/src/module/xep/0045_muc/flag.vala
index da469a41..87e0930f 100644
--- a/xmpp-vala/src/module/xep/0045_muc/flag.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/flag.vala
@@ -1,128 +1,123 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.Muc {
public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "muc");
- private HashMap<string, Gee.List<Feature>> room_features = new HashMap<string, Gee.List<Feature>>();
- private HashMap<string, string> room_names = new HashMap<string, string>();
+ private HashMap<Jid, Gee.List<Feature>> room_features = new HashMap<Jid, Gee.List<Feature>>(Jid.hash_bare_func, Jid.equals_bare_func);
+ private HashMap<Jid, string> room_names = new HashMap<Jid, string>(Jid.hash_bare_func, Jid.equals_bare_func);
- private HashMap<string, string> enter_ids = new HashMap<string, string>();
- private HashMap<string, string> own_nicks = new HashMap<string, string>();
- private HashMap<string, string> subjects = new HashMap<string, string>();
- private HashMap<string, string> subjects_by = new HashMap<string, string>();
+ private HashMap<Jid, string> enter_ids = new HashMap<Jid, string>(Jid.hash_bare_func, Jid.equals_bare_func);
+ private HashMap<Jid, string> own_nicks = new HashMap<Jid, string>(Jid.hash_bare_func, Jid.equals_bare_func);
+ private HashMap<Jid, string> subjects = new HashMap<Jid, string>(Jid.hash_bare_func, Jid.equals_bare_func);
+ private HashMap<Jid, Jid> subjects_by = new HashMap<Jid, Jid>(Jid.hash_bare_func, Jid.equals_bare_func);
- private HashMap<string, string> occupant_real_jids = new HashMap<string, string>();
- private HashMap<string, HashMap<string, Affiliation>> affiliations = new HashMap<string, HashMap<string, Affiliation>>();
- private HashMap<string, Role> occupant_role = new HashMap<string, Role>();
+ private HashMap<Jid, Jid> occupant_real_jids = new HashMap<Jid, Jid>(Jid.hash_func, Jid.equals_bare_func);
+ private HashMap<Jid, HashMap<Jid, Affiliation>> affiliations = new HashMap<Jid, HashMap<Jid, Affiliation>>(Jid.hash_bare_func, Jid.equals_bare_func);
+ private HashMap<Jid, Role> occupant_role = new HashMap<Jid, Role>(Jid.hash_func, Jid.equals_func);
- public string? get_room_name(string jid) { return room_names.has_key(jid) ? room_names[jid] : null; }
+ public string? get_room_name(Jid muc_jid) { return room_names.has_key(muc_jid.bare_jid) ? room_names[muc_jid.bare_jid] : null; }
- public bool has_room_feature(string jid, Feature feature) {
- return room_features.has_key(jid) && room_features[jid].contains(feature);
+ public bool has_room_feature(Jid muc_jid, Feature feature) {
+ return room_features.has_key(muc_jid.bare_jid) && room_features[muc_jid.bare_jid].contains(feature);
}
- public string? get_real_jid(string full_jid) { return occupant_real_jids[full_jid]; }
+ public Jid? get_real_jid(Jid full_jid) { return occupant_real_jids[full_jid]; }
- public Gee.List<string> get_offline_members(string muc_jid) {
- Gee.List<string> ret = new ArrayList<string>();
- HashMap<string, Affiliation>? muc_affiliations = affiliations[muc_jid];
+ public Gee.List<Jid> get_offline_members(Jid muc_jid) {
+ Gee.List<Jid> ret = new ArrayList<Jid>(Jid.equals_func);
+ HashMap<Jid, Affiliation>? muc_affiliations = affiliations[muc_jid.bare_jid];
if (muc_affiliations != null) {
- foreach (string jid in muc_affiliations.keys) {
- if (!jid.has_prefix(muc_jid)) ret.add(jid);
+ foreach (Jid jid in muc_affiliations.keys) {
+ if (!jid.equals_bare(muc_jid)) ret.add(jid);
}
}
return ret;
}
- public Affiliation get_affiliation(string muc_jid, string full_jid) {
- HashMap<string, Affiliation>? muc_affiliations = affiliations[muc_jid];
+ public Affiliation get_affiliation(Jid muc_jid, Jid full_jid) {
+ HashMap<Jid, Affiliation>? muc_affiliations = affiliations[muc_jid.bare_jid];
if (muc_affiliations != null) return muc_affiliations[full_jid];
return Affiliation.NONE;
}
- public Role? get_occupant_role(string full_jid) {
+ public Role? get_occupant_role(Jid full_jid) {
if (occupant_role.has_key(full_jid)) return occupant_role[full_jid];
return Role.NONE;
}
- public string? get_muc_nick(string bare_jid) { return own_nicks[bare_jid]; }
+ public string? get_muc_nick(Jid muc_jid) { return own_nicks[muc_jid.bare_jid]; }
- public string? get_enter_id(string bare_jid) { return enter_ids[bare_jid]; }
+ public string? get_enter_id(Jid muc_jid) { return enter_ids[muc_jid.bare_jid]; }
- public bool is_muc(string jid) { return own_nicks[jid] != null; }
+ public bool is_muc(Jid jid) { return own_nicks[jid] != null; }
- public bool is_occupant(string jid) {
- string bare_jid = get_bare_jid(jid);
- return own_nicks.has_key(bare_jid) || enter_ids.has_key(bare_jid);
+ public bool is_occupant(Jid jid) {
+ return own_nicks.has_key(jid.bare_jid) || enter_ids.has_key(jid.bare_jid);
}
public bool is_muc_enter_outstanding() { return enter_ids.size != 0; }
- public string? get_muc_subject(string bare_jid) { return subjects[bare_jid]; }
+ public string? get_muc_subject(Jid muc_jid) { return subjects[muc_jid.bare_jid]; }
- internal void set_room_name(string jid, string name) {
- room_names[jid] = name;
+ internal void set_room_name(Jid muc_jid, string name) {
+ room_names[muc_jid.bare_jid] = name;
}
- internal void set_room_features(string jid, Gee.List<Feature> features) {
- room_features[jid] = features;
+ internal void set_room_features(Jid muc_jid, Gee.List<Feature> features) {
+ room_features[muc_jid.bare_jid] = features;
}
- internal void set_real_jid(string full_jid, string real_jid) { occupant_real_jids[full_jid] = real_jid; }
+ internal void set_real_jid(Jid full_jid, Jid real_jid) { occupant_real_jids[full_jid] = real_jid; }
- internal void set_offline_member(string muc_jid, string real_jid, Affiliation affiliation) {
- set_affiliation(muc_jid, real_jid, affiliation);
+ internal void set_offline_member(Jid muc_jid, Jid real_jid, Affiliation affiliation) {
+ set_affiliation(muc_jid.bare_jid, real_jid, affiliation);
}
- internal void set_affiliation(string muc_jid, string full_jid, Affiliation affiliation) {
- if (!affiliations.has_key(muc_jid)) affiliations[muc_jid] = new HashMap<string, Affiliation>();
+ internal void set_affiliation(Jid muc_jid, Jid full_jid, Affiliation affiliation) {
+ if (!affiliations.has_key(muc_jid.bare_jid)) affiliations[muc_jid.bare_jid] = new HashMap<Jid, Affiliation>(Jid.hash_func, Jid.equals_func);
if (affiliation == Affiliation.NONE) {
- affiliations[muc_jid].unset(full_jid);
+ affiliations[muc_jid.bare_jid].unset(full_jid);
} else {
- affiliations[muc_jid][full_jid] = affiliation;
+ affiliations[muc_jid.bare_jid][full_jid] = affiliation;
}
}
- internal void set_occupant_role(string full_jid, Role role) {
+ internal void set_occupant_role(Jid full_jid, Role role) {
occupant_role[full_jid] = role;
}
- internal void set_muc_subject(string full_jid, string? subject) {
- string bare_jid = get_bare_jid(full_jid);
- subjects[bare_jid] = subject;
- subjects_by[bare_jid] = full_jid;
+ internal void set_muc_subject(Jid full_jid, string? subject) {
+ subjects[full_jid.bare_jid] = subject;
+ subjects_by[full_jid.bare_jid] = full_jid;
}
- internal void start_muc_enter(string bare_jid, string presence_id) {
- enter_ids[bare_jid] = presence_id;
+ internal void start_muc_enter(Jid jid, string presence_id) {
+ enter_ids[jid.bare_jid] = presence_id;
}
- internal void finish_muc_enter(string bare_jid, string? nick = null) {
- if (nick != null) own_nicks[bare_jid] = nick;
- enter_ids.unset(bare_jid);
+ internal void finish_muc_enter(Jid jid, string? nick = null) {
+ if (nick != null) own_nicks[jid.bare_jid] = nick;
+ enter_ids.unset(jid.bare_jid);
}
- internal void left_muc(XmppStream stream, string muc) {
- own_nicks.unset(muc);
- subjects.unset(muc);
- subjects_by.unset(muc);
- Gee.List<string>? occupants = stream.get_flag(Presence.Flag.IDENTITY).get_resources(muc);
+ internal void left_muc(XmppStream stream, Jid muc_jid) {
+ own_nicks.unset(muc_jid);
+ subjects.unset(muc_jid);
+ subjects_by.unset(muc_jid);
+ Gee.List<Jid>? occupants = stream.get_flag(Presence.Flag.IDENTITY).get_resources(muc_jid);
if (occupants != null) {
- foreach (string occupant in occupants) {
+ foreach (Jid occupant in occupants) {
remove_occupant_info(occupant);
}
}
}
- internal void remove_occupant_info(string full_jid) {
- occupant_real_jids.unset(full_jid);
- string bare_jid = get_bare_jid(full_jid);
- if (affiliations.has_key(full_jid)) affiliations[bare_jid].unset(full_jid);
- occupant_role.unset(full_jid);
+ internal void remove_occupant_info(Jid jid) {
+ occupant_real_jids.unset(jid);
+ if (affiliations.has_key(jid)) affiliations[jid].unset(jid);
+ occupant_role.unset(jid);
}
internal override string get_ns() { return NS_URI; }
diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala
index faaf1901..f0ae0ed6 100644
--- a/xmpp-vala/src/module/xep/0045_muc/module.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/module.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.Muc {
private const string NS_URI = "http://jabber.org/protocol/muc";
@@ -58,20 +56,20 @@ public enum Feature {
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0045_muc_module");
- public signal void received_occupant_affiliation(XmppStream stream, string jid, Affiliation? affiliation);
- public signal void received_occupant_jid(XmppStream stream, string jid, string? real_jid);
- public signal void received_occupant_role(XmppStream stream, string jid, Role? role);
- public signal void subject_set(XmppStream stream, string subject, string jid);
- public signal void room_configuration_changed(XmppStream stream, string jid, StatusCode code);
+ public signal void received_occupant_affiliation(XmppStream stream, Jid jid, Affiliation? affiliation);
+ public signal void received_occupant_jid(XmppStream stream, Jid jid, Jid? real_jid);
+ public signal void received_occupant_role(XmppStream stream, Jid jid, Role? role);
+ public signal void subject_set(XmppStream stream, string? subject, Jid jid);
+ public signal void room_configuration_changed(XmppStream stream, Jid jid, StatusCode code);
- public signal void room_entered(XmppStream stream, string jid, string nick);
- public signal void room_enter_error(XmppStream stream, string jid, MucEnterError? error); // TODO "?" shoudln't be necessary (vala bug), remove someday
- public signal void self_removed_from_room(XmppStream stream, string jid, StatusCode code);
- public signal void removed_from_room(XmppStream stream, string jid, StatusCode? code);
+ public signal void room_entered(XmppStream stream, Jid jid, string nick);
+ public signal void room_enter_error(XmppStream stream, Jid jid, MucEnterError? error); // TODO "?" shoudln't be necessary (vala bug), remove someday
+ public signal void self_removed_from_room(XmppStream stream, Jid jid, StatusCode code);
+ public signal void removed_from_room(XmppStream stream, Jid jid, StatusCode? code);
- public void enter(XmppStream stream, string bare_jid, string nick, string? password, DateTime? history_since) {
+ public void enter(XmppStream stream, Jid bare_jid, string nick, string? password, DateTime? history_since) {
Presence.Stanza presence = new Presence.Stanza();
- presence.to = bare_jid + "/" + nick;
+ presence.to = bare_jid.with_resource(nick);
StanzaNode x_node = new StanzaNode.build("x", NS_URI).add_self_xmlns();
if (password != null) {
x_node.put_node(new StanzaNode.build("password", NS_URI).put_node(new StanzaNode.text(password)));
@@ -89,47 +87,47 @@ public class Module : XmppStreamModule {
stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence);
}
- public void exit(XmppStream stream, string jid) {
+ public void exit(XmppStream stream, Jid jid) {
string nick = stream.get_flag(Flag.IDENTITY).get_muc_nick(jid);
Presence.Stanza presence = new Presence.Stanza();
- presence.to = jid + "/" + nick;
+ presence.to = jid.with_resource(nick);
presence.type_ = Presence.Stanza.TYPE_UNAVAILABLE;
stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence);
}
- public void change_subject(XmppStream stream, string jid, string subject) {
- Message.Stanza message = new Message.Stanza();
+ public void change_subject(XmppStream stream, Jid jid, string subject) {
+ MessageStanza message = new MessageStanza();
message.to = jid;
- message.type_ = Message.Stanza.TYPE_GROUPCHAT;
+ message.type_ = MessageStanza.TYPE_GROUPCHAT;
message.stanza.put_node((new StanzaNode.build("subject")).put_node(new StanzaNode.text(subject)));
- stream.get_module(Message.Module.IDENTITY).send_message(stream, message);
+ stream.get_module(MessageModule.IDENTITY).send_message(stream, message);
}
- public void change_nick(XmppStream stream, string jid, string new_nick) {
+ public void change_nick(XmppStream stream, Jid jid, string new_nick) {
Presence.Stanza presence = new Presence.Stanza();
- presence.to = jid + "/" + new_nick;
+ presence.to = jid.with_resource(new_nick);
stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence);
}
- public void invite(XmppStream stream, string to_muc, string jid) {
- Message.Stanza message = new Message.Stanza();
+ public void invite(XmppStream stream, Jid to_muc, Jid jid) {
+ MessageStanza message = new MessageStanza();
message.to = to_muc;
StanzaNode invite_node = new StanzaNode.build("x", NS_URI_USER).add_self_xmlns()
- .put_node(new StanzaNode.build("invite", NS_URI_USER).put_attribute("to", jid));
+ .put_node(new StanzaNode.build("invite", NS_URI_USER).put_attribute("to", jid.to_string()));
message.stanza.put_node(invite_node);
- stream.get_module(Message.Module.IDENTITY).send_message(stream, message);
+ stream.get_module(MessageModule.IDENTITY).send_message(stream, message);
}
- public void kick(XmppStream stream, string jid, string nick) {
+ public void kick(XmppStream stream, Jid jid, string nick) {
change_role(stream, jid, nick, "none");
}
/* XEP 0046: "A user cannot be kicked by a moderator with a lower affiliation." (XEP 0045 8.2) */
- public bool kick_possible(XmppStream stream, string occupant) {
- string muc_jid = get_bare_jid(occupant);
+ public bool kick_possible(XmppStream stream, Jid occupant) {
+ Jid muc_jid = occupant.bare_jid;
Flag flag = stream.get_flag(Flag.IDENTITY);
string own_nick = flag.get_muc_nick(muc_jid);
- Affiliation my_affiliation = flag.get_affiliation(muc_jid, muc_jid + "/" + own_nick);
+ Affiliation my_affiliation = flag.get_affiliation(muc_jid, muc_jid.with_resource(own_nick));
Affiliation other_affiliation = flag.get_affiliation(muc_jid, occupant);
switch (my_affiliation) {
case Affiliation.MEMBER:
@@ -142,22 +140,22 @@ public class Module : XmppStreamModule {
return true;
}
- public void change_role(XmppStream stream, string jid, string nick, string new_role) {
+ public void change_role(XmppStream stream, Jid jid, string nick, string new_role) {
StanzaNode query = new StanzaNode.build("query", NS_URI_ADMIN).add_self_xmlns();
query.put_node(new StanzaNode.build("item", NS_URI_ADMIN).put_attribute("nick", nick, NS_URI_ADMIN).put_attribute("role", new_role, NS_URI_ADMIN));
Iq.Stanza iq = new Iq.Stanza.set(query) { to=jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
}
- public void change_affiliation(XmppStream stream, string jid, string nick, string new_affiliation) {
+ public void change_affiliation(XmppStream stream, Jid jid, string nick, string new_affiliation) {
StanzaNode query = new StanzaNode.build("query", NS_URI_ADMIN).add_self_xmlns();
query.put_node(new StanzaNode.build("item", NS_URI_ADMIN).put_attribute("nick", nick, NS_URI_ADMIN).put_attribute("affiliation", new_affiliation, NS_URI_ADMIN));
Iq.Stanza iq = new Iq.Stanza.set(query) { to=jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
}
- public delegate void OnConfigFormResult(XmppStream stream, string jid, DataForms.DataForm data_form);
- public void get_config_form(XmppStream stream, string jid, owned OnConfigFormResult listener) {
+ public delegate void OnConfigFormResult(XmppStream stream, Jid jid, DataForms.DataForm data_form);
+ public void get_config_form(XmppStream stream, Jid jid, owned OnConfigFormResult listener) {
Iq.Stanza get_iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_OWNER).add_self_xmlns()) { to=jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, get_iq, (stream, form_iq) => {
StanzaNode? x_node = form_iq.stanza.get_deep_subnode(NS_URI_OWNER + ":query", DataForms.NS_URI + ":x");
@@ -176,7 +174,7 @@ public class Module : XmppStreamModule {
public override void attach(XmppStream stream) {
stream.add_flag(new Muc.Flag());
- stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
+ stream.get_module(MessageModule.IDENTITY).received_message.connect(on_received_message);
stream.get_module(Presence.Module.IDENTITY).received_presence.connect(check_for_enter_error);
stream.get_module(Presence.Module.IDENTITY).received_available.connect(on_received_available);
stream.get_module(Presence.Module.IDENTITY).received_unavailable.connect(on_received_unavailable);
@@ -192,7 +190,7 @@ public class Module : XmppStreamModule {
}
public override void detach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
+ stream.get_module(MessageModule.IDENTITY).received_message.disconnect(on_received_message);
stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(check_for_enter_error);
stream.get_module(Presence.Module.IDENTITY).received_available.disconnect(on_received_available);
stream.get_module(Presence.Module.IDENTITY).received_unavailable.disconnect(on_received_unavailable);
@@ -201,8 +199,8 @@ public class Module : XmppStreamModule {
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private void on_received_message(XmppStream stream, Message.Stanza message) {
- if (message.type_ == Message.Stanza.TYPE_GROUPCHAT) {
+ private void on_received_message(XmppStream stream, MessageStanza message) {
+ if (message.type_ == MessageStanza.TYPE_GROUPCHAT) {
StanzaNode? subject_node = message.stanza.get_subnode("subject");
if (subject_node != null) {
string subject = subject_node.get_string_content();
@@ -215,7 +213,7 @@ public class Module : XmppStreamModule {
private void check_for_enter_error(XmppStream stream, Presence.Stanza presence) {
Flag flag = stream.get_flag(Flag.IDENTITY);
if (presence.is_error() && flag.is_muc_enter_outstanding() && flag.is_occupant(presence.from)) {
- string bare_jid = get_bare_jid(presence.from);
+ Jid bare_jid = presence.from.bare_jid;
ErrorStanza? error_stanza = presence.get_error();
if (flag.get_enter_id(bare_jid) == presence.id) {
MucEnterError error = MucEnterError.NONE;
@@ -258,20 +256,21 @@ public class Module : XmppStreamModule {
if (x_node != null) {
ArrayList<int> status_codes = get_status_codes(x_node);
if (status_codes.contains(StatusCode.SELF_PRESENCE)) {
- string bare_jid = get_bare_jid(presence.from);
+ Jid bare_jid = presence.from.bare_jid;
if (flag.get_enter_id(bare_jid) != null) {
- room_entered(stream, bare_jid, get_resource_part(presence.from));
- flag.finish_muc_enter(bare_jid, get_resource_part(presence.from));
+ room_entered(stream, bare_jid, presence.from.resourcepart);
+ flag.finish_muc_enter(bare_jid, presence.from.resourcepart);
}
}
string? affiliation_str = x_node.get_deep_attribute("item", "affiliation");
if (affiliation_str != null) {
Affiliation affiliation = parse_affiliation(affiliation_str);
- flag.set_affiliation(get_bare_jid(presence.from), presence.from, affiliation);
+ flag.set_affiliation(presence.from.bare_jid, presence.from, affiliation);
received_occupant_affiliation(stream, presence.from, affiliation);
}
- string? jid = x_node.get_deep_attribute("item", "jid");
- if (jid != null) {
+ string? jid_ = x_node.get_deep_attribute("item", "jid");
+ if (jid_ != null) {
+ Jid? jid = Jid.parse(jid_);
flag.set_real_jid(presence.from, jid);
received_occupant_jid(stream, presence.from, jid);
}
@@ -301,10 +300,10 @@ public class Module : XmppStreamModule {
foreach (StatusCode code in USER_REMOVED_CODES) {
if (code in status_codes) {
if (StatusCode.SELF_PRESENCE in status_codes) {
- flag.left_muc(stream, get_bare_jid(presence.from));
+ flag.left_muc(stream, presence.from.bare_jid);
self_removed_from_room(stream, presence.from, code);
Presence.Flag presence_flag = stream.get_flag(Presence.Flag.IDENTITY);
- presence_flag.remove_presence(get_bare_jid(presence.from));
+ presence_flag.remove_presence(presence.from.bare_jid);
} else {
removed_from_room(stream, presence.from, code);
}
@@ -312,7 +311,7 @@ public class Module : XmppStreamModule {
}
}
- private void query_room_info(XmppStream stream, string jid) {
+ private void query_room_info(XmppStream stream, Jid jid) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, jid, (stream, query_result) => {
Gee.List<Feature> features = new ArrayList<Feature>();
@@ -351,8 +350,8 @@ public class Module : XmppStreamModule {
});
}
- public delegate void OnAffiliationResult(XmppStream stream, Gee.List<string> jids);
- private void query_affiliation(XmppStream stream, string jid, string affiliation, owned OnAffiliationResult? listener) {
+ public delegate void OnAffiliationResult(XmppStream stream, Gee.List<Jid> jids);
+ private void query_affiliation(XmppStream stream, Jid jid, string affiliation, owned OnAffiliationResult? listener) {
Iq.Stanza iq = new Iq.Stanza.get(
new StanzaNode.build("query", NS_URI_ADMIN)
.add_self_xmlns()
@@ -364,9 +363,9 @@ public class Module : XmppStreamModule {
StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI_ADMIN);
if (query_node == null) return;
Gee.List<StanzaNode> item_nodes = query_node.get_subnodes("item", NS_URI_ADMIN);
- Gee.List<string> ret_jids = new ArrayList<string>();
+ Gee.List<Jid> ret_jids = new ArrayList<Jid>(Jid.equals_func);
foreach (StanzaNode item in item_nodes) {
- string? jid_ = item.get_attribute("jid");
+ Jid? jid_ = Jid.parse(item.get_attribute("jid"));
string? affiliation_ = item.get_attribute("affiliation");
if (jid_ != null && affiliation_ != null) {
stream.get_flag(Muc.Flag.IDENTITY).set_offline_member(iq.from, jid_, parse_affiliation(affiliation_));
diff --git a/xmpp-vala/src/module/xep/0048_bookmarks/conference.vala b/xmpp-vala/src/module/xep/0048_bookmarks/conference.vala
index 6964f83d..e5037e42 100644
--- a/xmpp-vala/src/module/xep/0048_bookmarks/conference.vala
+++ b/xmpp-vala/src/module/xep/0048_bookmarks/conference.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.Xep.Bookmarks {
public class Conference : Object {
@@ -21,9 +19,10 @@ public class Conference : Object {
set { stanza_node.set_attribute(ATTRIBUTE_AUTOJOIN, value.to_string()); }
}
- public string jid {
- get { return stanza_node.get_attribute(ATTRIBUTE_JID); }
- set { stanza_node.set_attribute(ATTRIBUTE_JID, value); }
+ private Jid jid_;
+ public Jid jid {
+ get { return jid_ ?? (jid_ = Jid.parse(stanza_node.get_attribute(ATTRIBUTE_JID))); }
+ set { stanza_node.set_attribute(ATTRIBUTE_JID, value.to_string()); }
}
public string? name {
@@ -73,7 +72,7 @@ public class Conference : Object {
}
}
- public Conference(string jid) {
+ public Conference(Jid jid) {
this.stanza_node = new StanzaNode.build("conference", NS_URI);
this.jid = jid;
}
@@ -90,4 +89,4 @@ public class Conference : Object {
}
}
-} \ No newline at end of file
+}
diff --git a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala
index 6b354c57..2c16f5f0 100644
--- a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala
+++ b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.Bookmarks {
private const string NS_URI = "storage:bookmarks";
@@ -10,12 +8,16 @@ public class Module : XmppStreamModule {
public signal void received_conferences(XmppStream stream, Gee.List<Conference> conferences);
- public delegate void OnResult(XmppStream stream, Gee.List<Conference> conferences);
+ public delegate void OnResult(XmppStream stream, Gee.List<Conference>? conferences);
public void get_conferences(XmppStream stream, owned OnResult listener) {
StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns();
stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node, (stream, node) => {
- Gee.List<Conference> conferences = get_conferences_from_stanza(node);
- listener(stream, conferences);
+ if (node == null) {
+ listener(stream, null);
+ } else {
+ Gee.List<Conference> conferences = get_conferences_from_stanza(node);
+ listener(stream, conferences);
+ }
});
}
@@ -39,7 +41,7 @@ public class Module : XmppStreamModule {
public void replace_conference(XmppStream stream, Conference orig_conference, Conference modified_conference) {
get_conferences(stream, (stream, conferences) => {
foreach (Conference conference in conferences) {
- if (conference.autojoin == orig_conference.autojoin && conference.jid == orig_conference.jid &&
+ if (conference.autojoin == orig_conference.autojoin && conference.jid.equals(orig_conference.jid) &&
conference.name == orig_conference.name && conference.nick == orig_conference.nick) {
conference.autojoin = modified_conference.autojoin;
conference.jid = modified_conference.jid;
@@ -56,7 +58,7 @@ public class Module : XmppStreamModule {
get_conferences(stream, (stream, conferences) => {
Conference? rem = null;
foreach (Conference conference in conferences) {
- if (conference.name == conference_remove.name && conference.jid == conference_remove.jid && conference.autojoin == conference_remove.autojoin) {
+ if (conference.name == conference_remove.name && conference.jid.equals(conference_remove.jid) && conference.autojoin == conference_remove.autojoin) {
rem = conference;
break;
}
diff --git a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
index fd367dd8..5b3eb1b6 100644
--- a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
+++ b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.PrivateXmlStorage {
private const string NS_URI = "jabber:iq:private";
@@ -17,7 +15,7 @@ namespace Xmpp.Xep.PrivateXmlStorage {
});
}
- public delegate void OnResponse(XmppStream stream, StanzaNode node);
+ public delegate void OnResponse(XmppStream stream, StanzaNode? node);
public void retrieve(XmppStream stream, StanzaNode node, owned OnResponse listener) {
StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node);
Iq.Stanza iq = new Iq.Stanza.get(queryNode);
diff --git a/xmpp-vala/src/module/xep/0054_vcard/module.vala b/xmpp-vala/src/module/xep/0054_vcard/module.vala
index 2fc055cf..0627c076 100644
--- a/xmpp-vala/src/module/xep/0054_vcard/module.vala
+++ b/xmpp-vala/src/module/xep/0054_vcard/module.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.Xep.VCard {
private const string NS_URI = "vcard-temp";
private const string NS_URI_UPDATE = NS_URI + ":x:update";
@@ -7,7 +5,7 @@ private const string NS_URI_UPDATE = NS_URI + ":x:update";
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0153_vcard_based_avatars");
- public signal void received_avatar(XmppStream stream, string jid, string id);
+ public signal void received_avatar(XmppStream stream, Jid jid, string id);
private PixbufStorage storage;
@@ -37,14 +35,14 @@ public class Module : XmppStreamModule {
if (stream.get_flag(Muc.Flag.IDENTITY).is_occupant(presence.from)) {
received_avatar(stream, presence.from, sha1);
} else {
- received_avatar(stream, get_bare_jid(presence.from), sha1);
+ received_avatar(stream, presence.from.bare_jid, sha1);
}
} else {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("vCard", NS_URI).add_self_xmlns());
if (stream.get_flag(Muc.Flag.IDENTITY).is_occupant(presence.from)) {
iq.to = presence.from;
} else {
- iq.to = get_bare_jid(presence.from);
+ iq.to = presence.from.bare_jid;
}
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_received_vcard);
}
diff --git a/xmpp-vala/src/module/xep/0060_pubsub.vala b/xmpp-vala/src/module/xep/0060_pubsub.vala
index 45fcb137..e887f74f 100644
--- a/xmpp-vala/src/module/xep/0060_pubsub.vala
+++ b/xmpp-vala/src/module/xep/0060_pubsub.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.Pubsub {
private const string NS_URI = "http://jabber.org/protocol/pubsub";
private const string NS_URI_EVENT = NS_URI + "#event";
@@ -16,8 +14,8 @@ namespace Xmpp.Xep.Pubsub {
event_listeners[node] = new EventListenerDelegate((owned)listener);
}
- public delegate void OnResult(XmppStream stream, string jid, string? id, StanzaNode? node);
- public void request(XmppStream stream, string jid, string node, owned OnResult listener) { // TODO multiple nodes gehen auch
+ public delegate void OnResult(XmppStream stream, Jid jid, string? id, StanzaNode? node);
+ public void request(XmppStream stream, Jid jid, string node, owned OnResult listener) { // TODO multiple nodes gehen auch
Iq.Stanza request_iq = new Iq.Stanza.get(new StanzaNode.build("pubsub", NS_URI).add_self_xmlns().put_node(new StanzaNode.build("items", NS_URI).put_attribute("node", node)));
request_iq.to = jid;
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, request_iq, (stream, iq) => {
@@ -29,7 +27,7 @@ namespace Xmpp.Xep.Pubsub {
});
}
- public void publish(XmppStream stream, string? jid, string node_id, string node, string? item_id, StanzaNode content) {
+ public void publish(XmppStream stream, Jid? jid, string node_id, string node, string? item_id, StanzaNode content) {
StanzaNode pubsub_node = new StanzaNode.build("pubsub", NS_URI).add_self_xmlns();
StanzaNode publish_node = new StanzaNode.build("publish", NS_URI).put_attribute("node", node_id);
pubsub_node.put_node(publish_node);
@@ -42,17 +40,17 @@ namespace Xmpp.Xep.Pubsub {
}
public override void attach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
+ stream.get_module(MessageModule.IDENTITY).received_message.connect(on_received_message);
}
public override void detach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
+ stream.get_module(MessageModule.IDENTITY).received_message.disconnect(on_received_message);
}
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private void on_received_message(XmppStream stream, Message.Stanza message) {
+ private void on_received_message(XmppStream stream, MessageStanza message) {
StanzaNode event_node = message.stanza.get_subnode("event", NS_URI_EVENT); if (event_node == null) return;
StanzaNode items_node = event_node.get_subnode("items", NS_URI_EVENT); if (items_node == null) return;
StanzaNode item_node = items_node.get_subnode("item", NS_URI_EVENT); if (item_node == null) return;
@@ -65,7 +63,7 @@ namespace Xmpp.Xep.Pubsub {
}
public class EventListenerDelegate {
- public delegate void ResultFunc(XmppStream stream, string jid, string id, StanzaNode? node);
+ public delegate void ResultFunc(XmppStream stream, Jid jid, string id, StanzaNode? node);
public ResultFunc on_result { get; private owned set; }
public EventListenerDelegate(owned ResultFunc on_result) {
diff --git a/xmpp-vala/src/module/xep/0066_out_of_band_data.vala b/xmpp-vala/src/module/xep/0066_out_of_band_data.vala
index 804d406a..97a82104 100644
--- a/xmpp-vala/src/module/xep/0066_out_of_band_data.vala
+++ b/xmpp-vala/src/module/xep/0066_out_of_band_data.vala
@@ -1,14 +1,12 @@
-using Xmpp.Core;
-
namespace Xmpp.Xep.OutOfBandData {
public const string NS_URI = "jabber:x:oob";
-public static void add_url_to_message(Message.Stanza message, string url, string? desc = null) {
+public static void add_url_to_message(MessageStanza message, string url, string? desc = null) {
message.stanza.put_node(new StanzaNode.build("x", NS_URI).add_self_xmlns().put_node(new StanzaNode.build("url", NS_URI).put_node(new StanzaNode.text(url))));
}
-public static string? get_url_from_message(Message.Stanza message) {
+public static string? get_url_from_message(MessageStanza message) {
return message.stanza.get_deep_string_content(NS_URI + ":x", NS_URI + ":url");
}
diff --git a/xmpp-vala/src/module/xep/0084_user_avatars.vala b/xmpp-vala/src/module/xep/0084_user_avatars.vala
index 2b37f485..92ac54e2 100644
--- a/xmpp-vala/src/module/xep/0084_user_avatars.vala
+++ b/xmpp-vala/src/module/xep/0084_user_avatars.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.Xep.UserAvatars {
private const string NS_URI = "urn:xmpp:avatar";
private const string NS_URI_DATA = NS_URI + ":data";
@@ -8,7 +6,7 @@ namespace Xmpp.Xep.UserAvatars {
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0084_user_avatars");
- public signal void received_avatar(XmppStream stream, string jid, string id);
+ public signal void received_avatar(XmppStream stream, Jid jid, string id);
private PixbufStorage storage;
@@ -40,7 +38,7 @@ namespace Xmpp.Xep.UserAvatars {
public override void detach(XmppStream stream) { }
- public void on_pupsub_event(XmppStream stream, string jid, string id, StanzaNode? node) {
+ public void on_pupsub_event(XmppStream stream, Jid jid, string id, StanzaNode? node) {
StanzaNode? info_node = node.get_subnode("info", NS_URI_METADATA);
if (info_node == null || info_node.get_attribute("type") != "image/png") return;
if (storage.has_image(id)) {
@@ -53,7 +51,7 @@ namespace Xmpp.Xep.UserAvatars {
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private void on_pubsub_data_response(XmppStream stream, string jid, string? id, StanzaNode? node) {
+ private void on_pubsub_data_response(XmppStream stream, Jid jid, string? id, StanzaNode? node) {
if (node == null) return;
storage.store(id, Base64.decode(node.get_string_content()));
stream.get_module(Module.IDENTITY).received_avatar(stream, jid, id);
diff --git a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
index e92763fb..cc18c52f 100644
--- a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
+++ b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.ChatStateNotifications {
private const string NS_URI = "http://jabber.org/protocol/chatstates";
@@ -16,36 +14,36 @@ private const string[] STATES = {STATE_ACTIVE, STATE_INACTIVE, STATE_GONE, STATE
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0085_chat_state_notifications");
- public signal void chat_state_received(XmppStream stream, string jid, string state);
+ public signal void chat_state_received(XmppStream stream, Jid jid, string state);
private SendPipelineListener send_pipeline_listener = new SendPipelineListener();
/**
* "A message stanza that does not contain standard messaging content [...] SHOULD be a state other than <active/>" (0085, 5.6)
*/
- public void send_state(XmppStream stream, string jid, string state) {
- Message.Stanza message = new Message.Stanza();
+ public void send_state(XmppStream stream, Jid jid, string state) {
+ MessageStanza message = new MessageStanza();
message.to = jid;
- message.type_ = Message.Stanza.TYPE_CHAT;
+ message.type_ = MessageStanza.TYPE_CHAT;
message.stanza.put_node(new StanzaNode.build(state, NS_URI).add_self_xmlns());
- stream.get_module(Message.Module.IDENTITY).send_message(stream, message);
+ stream.get_module(MessageModule.IDENTITY).send_message(stream, message);
}
public override void attach(XmppStream stream) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
- stream.get_module(Message.Module.IDENTITY).send_pipeline.connect(send_pipeline_listener);
- stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
+ stream.get_module(MessageModule.IDENTITY).send_pipeline.connect(send_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_message.connect(on_received_message);
}
public override void detach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
- stream.get_module(Message.Module.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_message.disconnect(on_received_message);
+ stream.get_module(MessageModule.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
}
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private void on_received_message(XmppStream stream, Message.Stanza message) {
+ private void on_received_message(XmppStream stream, MessageStanza message) {
if (!message.is_error()) {
Gee.List<StanzaNode> nodes = message.stanza.get_all_subnodes();
foreach (StanzaNode node in nodes) {
@@ -58,16 +56,16 @@ public class Module : XmppStreamModule {
}
}
-public class SendPipelineListener : StanzaListener<Message.Stanza> {
+public class SendPipelineListener : StanzaListener<MessageStanza> {
private const string[] after_actions_const = {"MODIFY_BODY"};
public override string action_group { get { return "ADD_NODES"; } }
public override string[] after_actions { get { return after_actions_const; } }
- public override async void run(Core.XmppStream stream, Message.Stanza message) {
+ public override async void run(XmppStream stream, MessageStanza message) {
if (message.body == null) return;
- if (message.type_ != Message.Stanza.TYPE_CHAT) return;
+ if (message.type_ != MessageStanza.TYPE_CHAT) return;
message.stanza.put_node(new StanzaNode.build(STATE_ACTIVE, NS_URI).add_self_xmlns());
}
}
diff --git a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
index cba58883..19b0be3e 100644
--- a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
+++ b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.EntityCapabilities {
private const string NS_URI = "http://jabber.org/protocol/caps";
diff --git a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
index 826b8726..5e3cb320 100644
--- a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
+++ b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
@@ -1,41 +1,39 @@
-using Xmpp.Core;
-
namespace Xmpp.Xep.MessageDeliveryReceipts {
private const string NS_URI = "urn:xmpp:receipts";
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0184_message_delivery_receipts");
- public signal void receipt_received(XmppStream stream, string jid, string id);
+ public signal void receipt_received(XmppStream stream, Jid jid, string id);
private SendPipelineListener send_pipeline_listener = new SendPipelineListener();
- public void send_received(XmppStream stream, string from, string message_id) {
- Message.Stanza received_message = new Message.Stanza();
+ public void send_received(XmppStream stream, Jid from, string message_id) {
+ MessageStanza received_message = new MessageStanza();
received_message.to = from;
received_message.stanza.put_node(new StanzaNode.build("received", NS_URI).add_self_xmlns().put_attribute("id", message_id));
- stream.get_module(Message.Module.IDENTITY).send_message(stream, received_message);
+ stream.get_module(MessageModule.IDENTITY).send_message(stream, received_message);
}
- public static bool requests_receipt(Message.Stanza message) {
+ public static bool requests_receipt(MessageStanza message) {
return message.stanza.get_subnode("request", NS_URI) != null;
}
public override void attach(XmppStream stream) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
- stream.get_module(Message.Module.IDENTITY).received_message.connect(received_message);
- stream.get_module(Message.Module.IDENTITY).send_pipeline.connect(send_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_message.connect(received_message);
+ stream.get_module(MessageModule.IDENTITY).send_pipeline.connect(send_pipeline_listener);
}
public override void detach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_message.disconnect(received_message);
- stream.get_module(Message.Module.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_message.disconnect(received_message);
+ stream.get_module(MessageModule.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
}
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private void received_message(XmppStream stream, Message.Stanza message) {
+ private void received_message(XmppStream stream, MessageStanza message) {
StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI);
if (received_node != null) {
receipt_received(stream, message.from, received_node.get_attribute("id", NS_URI));
@@ -43,18 +41,18 @@ namespace Xmpp.Xep.MessageDeliveryReceipts {
}
}
-public class SendPipelineListener : StanzaListener<Message.Stanza> {
+public class SendPipelineListener : StanzaListener<MessageStanza> {
private const string[] after_actions_const = {};
public override string action_group { get { return "ADD_NODES"; } }
public override string[] after_actions { get { return after_actions_const; } }
- public override async void run(Core.XmppStream stream, Message.Stanza message) {
+ public override async void run(XmppStream stream, MessageStanza message) {
StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI);
if (received_node != null) return;
if (message.body == null) return;
- if (message.type_ == Message.Stanza.TYPE_GROUPCHAT) return;
+ if (message.type_ == MessageStanza.TYPE_GROUPCHAT) return;
message.stanza.put_node(new StanzaNode.build("request", NS_URI).add_self_xmlns());
}
}
diff --git a/xmpp-vala/src/module/xep/0191_blocking_command.vala b/xmpp-vala/src/module/xep/0191_blocking_command.vala
index 1520577f..4b78ed33 100644
--- a/xmpp-vala/src/module/xep/0191_blocking_command.vala
+++ b/xmpp-vala/src/module/xep/0191_blocking_command.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.BlockingCommand {
private const string NS_URI = "urn:xmpp:blocking";
diff --git a/xmpp-vala/src/module/xep/0198_stream_management.vala b/xmpp-vala/src/module/xep/0198_stream_management.vala
index 266e94c9..8ac41eb7 100644
--- a/xmpp-vala/src/module/xep/0198_stream_management.vala
+++ b/xmpp-vala/src/module/xep/0198_stream_management.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.Xep.StreamManagement {
public const string NS_URI = "urn:xmpp:sm:3";
diff --git a/xmpp-vala/src/module/xep/0199_ping.vala b/xmpp-vala/src/module/xep/0199_ping.vala
index ac467b35..661ad253 100644
--- a/xmpp-vala/src/module/xep/0199_ping.vala
+++ b/xmpp-vala/src/module/xep/0199_ping.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.Ping {
private const string NS_URI = "urn:xmpp:ping";
@@ -9,7 +7,7 @@ namespace Xmpp.Xep.Ping {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0199_ping");
public delegate void OnResult(XmppStream stream);
- public void send_ping(XmppStream stream, string jid, owned OnResult? listener) {
+ public void send_ping(XmppStream stream, Jid jid, owned OnResult? listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("ping", NS_URI).add_self_xmlns());
iq.to = jid;
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream) => {
diff --git a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala
index b36932b0..8581ed93 100644
--- a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala
+++ b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala
@@ -1,70 +1,82 @@
-using Xmpp.Core;
-
namespace Xmpp.Xep.DelayedDelivery {
- private const string NS_URI = "urn:xmpp:delay";
- public class Module : XmppStreamModule {
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0203_delayed_delivery");
+private const string NS_URI = "urn:xmpp:delay";
- private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener();
+public class Module : XmppStreamModule {
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0203_delayed_delivery");
- public static void set_message_delay(Message.Stanza message, DateTime datetime) {
- StanzaNode delay_node = (new StanzaNode.build("delay", NS_URI)).add_self_xmlns();
- delay_node.put_attribute("stamp", DateTimeProfiles.to_datetime(datetime));
- message.stanza.put_node(delay_node);
- }
+ private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener();
- public static DateTime? get_time_for_message(Message.Stanza message) {
- StanzaNode? delay_node = message.stanza.get_subnode("delay", NS_URI);
- if (delay_node != null) {
- return get_time_for_node(delay_node);
- }
- return null;
- }
+ public static void set_message_delay(MessageStanza message, DateTime datetime) {
+ StanzaNode delay_node = (new StanzaNode.build("delay", NS_URI)).add_self_xmlns();
+ delay_node.put_attribute("stamp", DateTimeProfiles.to_datetime(datetime));
+ message.stanza.put_node(delay_node);
+ }
- public static DateTime? get_time_for_node(StanzaNode node) {
- string? time = node.get_attribute("stamp");
- if (time != null) return DateTimeProfiles.parse_string(time);
- return null;
+ public static DateTime? get_time_for_message(MessageStanza message) {
+ StanzaNode? delay_node = message.stanza.get_subnode("delay", NS_URI);
+ if (delay_node != null) {
+ return get_time_for_node(delay_node);
}
+ return null;
+ }
- public override void attach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_listener);
- }
+ public static DateTime? get_time_for_node(StanzaNode node) {
+ string? time = node.get_attribute("stamp");
+ if (time != null) return DateTimeProfiles.parse_string(time);
+ return null;
+ }
- public override void detach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
- }
+ public override void attach(XmppStream stream) {
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.connect(received_pipeline_listener);
+ }
- public override string get_ns() { return NS_URI; }
- public override string get_id() { return IDENTITY.id; }
+ public override void detach(XmppStream stream) {
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
}
-public class ReceivedPipelineListener : StanzaListener<Message.Stanza> {
+ public override string get_ns() {
+ return NS_URI;
+ }
+
+ public override string get_id() {
+ return IDENTITY.id;
+ }
+}
+
+public class ReceivedPipelineListener : StanzaListener<MessageStanza> {
private const string[] after_actions_const = {};
public override string action_group { get { return "ADD_NODE"; } }
public override string[] after_actions { get { return after_actions_const; } }
- public override async void run(Core.XmppStream stream, Message.Stanza message) {
+ public override async void run(XmppStream stream, MessageStanza message) {
DateTime? datetime = Module.get_time_for_message(message);
if (datetime != null) message.add_flag(new MessageFlag(datetime));
}
}
- public class MessageFlag : Message.MessageFlag {
- public const string ID = "delayed_delivery";
+public class MessageFlag : Xmpp.MessageFlag {
+ public const string ID = "delayed_delivery";
- public DateTime datetime { get; private set; }
+ public DateTime datetime { get; private set; }
- public MessageFlag(DateTime datetime) {
- this.datetime = datetime;
- }
+ public MessageFlag(DateTime datetime) {
+ this.datetime = datetime;
+ }
- public static MessageFlag? get_flag(Message.Stanza message) { return (MessageFlag) message.get_flag(NS_URI, ID); }
+ public static MessageFlag? get_flag(MessageStanza message) {
+ return (MessageFlag) message.get_flag(NS_URI, ID);
+ }
+
+ public override string get_ns() {
+ return NS_URI;
+ }
- public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() {
+ return ID;
}
}
+
+}
diff --git a/xmpp-vala/src/module/xep/0280_message_carbons.vala b/xmpp-vala/src/module/xep/0280_message_carbons.vala
index 8dc4e00c..9e85a607 100644
--- a/xmpp-vala/src/module/xep/0280_message_carbons.vala
+++ b/xmpp-vala/src/module/xep/0280_message_carbons.vala
@@ -1,56 +1,60 @@
-using Xmpp.Core;
-
namespace Xmpp.Xep.MessageCarbons {
- private const string NS_URI = "urn:xmpp:carbons:2";
- public class Module : XmppStreamModule {
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0280_message_carbons_module");
+private const string NS_URI = "urn:xmpp:carbons:2";
- private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener();
+public class Module : XmppStreamModule {
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0280_message_carbons_module");
- public void enable(XmppStream stream) {
- Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("enable", NS_URI).add_self_xmlns());
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
- }
+ private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener();
- public void disable(XmppStream stream) {
- Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("disable", NS_URI).add_self_xmlns());
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
- }
+ public void enable(XmppStream stream) {
+ Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("enable", NS_URI).add_self_xmlns());
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
+ }
- public override void attach(XmppStream stream) {
- stream.stream_negotiated.connect(enable);
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_listener);
- stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
- }
+ public void disable(XmppStream stream) {
+ Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("disable", NS_URI).add_self_xmlns());
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
+ }
- public override void detach(XmppStream stream) {
- stream.stream_negotiated.disconnect(enable);
- stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
- }
+ public override void attach(XmppStream stream) {
+ stream.stream_negotiated.connect(enable);
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.connect(received_pipeline_listener);
+ stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
+ }
- public override string get_ns() { return NS_URI; }
- public override string get_id() { return IDENTITY.id; }
+ public override void detach(XmppStream stream) {
+ stream.stream_negotiated.disconnect(enable);
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
}
-public class ReceivedPipelineListener : StanzaListener<Message.Stanza> {
+ public override string get_ns() {
+ return NS_URI;
+ }
+
+ public override string get_id() {
+ return IDENTITY.id;
+ }
+}
+
+public class ReceivedPipelineListener : StanzaListener<MessageStanza> {
private const string[] after_actions_const = {"EXTRACT_MESSAGE_1"};
public override string action_group { get { return "EXTRACT_MESSAGE_2"; } }
public override string[] after_actions { get { return after_actions_const; } }
- public override async void run(Core.XmppStream stream, Message.Stanza message) {
+ public override async void run(XmppStream stream, MessageStanza message) {
StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI);
StanzaNode? sent_node = received_node == null ? message.stanza.get_subnode("sent", NS_URI) : null;
StanzaNode? carbons_node = received_node != null ? received_node : sent_node;
if (carbons_node != null) {
StanzaNode? forwarded_node = carbons_node.get_subnode("forwarded", "urn:xmpp:forward:0");
if (forwarded_node != null) {
- StanzaNode? message_node = forwarded_node.get_subnode("message", Message.NS_URI);
- string? from_attribute = message_node.get_attribute("from", Message.NS_URI);
+ StanzaNode? message_node = forwarded_node.get_subnode("message", Xmpp.NS_URI);
+ string? from_attribute = message_node.get_attribute("from", Xmpp.NS_URI);
// Any forwarded copies received by a Carbons-enabled client MUST be from that user's bare JID; any copies that do not meet this requirement MUST be ignored.
- if (from_attribute != null && from_attribute == get_bare_jid(stream.get_flag(Bind.Flag.IDENTITY).my_jid)) {
+ if (from_attribute != null && from_attribute == stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid.to_string()) {
if (received_node != null) {
message.add_flag(new MessageFlag(MessageFlag.TYPE_RECEIVED));
} else if (sent_node != null) {
@@ -66,22 +70,28 @@ public class ReceivedPipelineListener : StanzaListener<Message.Stanza> {
}
}
- public class MessageFlag : Message.MessageFlag {
- public const string ID = "message_carbons";
+public class MessageFlag : Xmpp.MessageFlag {
+ public const string ID = "message_carbons";
- public const string TYPE_RECEIVED = "received";
- public const string TYPE_SENT = "sent";
- private string type_;
+ public const string TYPE_RECEIVED = "received";
+ public const string TYPE_SENT = "sent";
+ private string type_;
- public MessageFlag(string type) {
- this.type_ = type;
- }
+ public MessageFlag(string type) {
+ this.type_ = type;
+ }
- public static MessageFlag? get_flag(Message.Stanza message) {
- return (MessageFlag) message.get_flag(NS_URI, ID);
- }
+ public static MessageFlag? get_flag(MessageStanza message) {
+ return (MessageFlag) message.get_flag(NS_URI, ID);
+ }
+
+ public override string get_ns() {
+ return NS_URI;
+ }
- public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() {
+ return ID;
}
}
+
+}
diff --git a/xmpp-vala/src/module/xep/0313_message_archive_management.vala b/xmpp-vala/src/module/xep/0313_message_archive_management.vala
index 0e3ac0c7..1c1b51e3 100644
--- a/xmpp-vala/src/module/xep/0313_message_archive_management.vala
+++ b/xmpp-vala/src/module/xep/0313_message_archive_management.vala
@@ -1,5 +1,3 @@
-using Xmpp.Core;
-
namespace Xmpp.Xep.MessageArchiveManagement {
public const string NS_URI = "urn:xmpp:mam:2";
@@ -44,12 +42,12 @@ public class Module : XmppStreamModule {
}
public override void attach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.connect(received_pipeline_listener);
stream.stream_negotiated.connect(query_availability);
}
public override void detach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
}
public override string get_ns() { return NS_URI; }
@@ -73,29 +71,31 @@ public class Module : XmppStreamModule {
}
private void query_availability(XmppStream stream) {
- stream.get_module(Xep.ServiceDiscovery.Module.IDENTITY).request_info(stream, get_bare_jid(stream.get_flag(Bind.Flag.IDENTITY).my_jid), (stream, info_result) => {
+ stream.get_module(Xep.ServiceDiscovery.Module.IDENTITY).request_info(stream, stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid, (stream, info_result) => {
+ if (info_result == null) return;
if (info_result.features.contains(NS_URI)) {
stream.add_flag(new Flag(NS_URI));
+ feature_available(stream);
} else if (info_result.features.contains(NS_URI_1)) {
stream.add_flag(new Flag(NS_URI_1));
+ feature_available(stream);
}
- if (stream.get_flag(Flag.IDENTITY) != null) feature_available(stream);
});
}
}
-public class ReceivedPipelineListener : StanzaListener<Message.Stanza> {
+public class ReceivedPipelineListener : StanzaListener<MessageStanza> {
private const string[] after_actions_const = {};
public override string action_group { get { return "EXTRACT_MESSAGE_1"; } }
public override string[] after_actions { get { return after_actions_const; } }
- public override async void run(Core.XmppStream stream, Message.Stanza message) {
+ public override async void run(XmppStream stream, MessageStanza message) {
// if (message.from != stream.remote_name) return;
if (stream.get_flag(Flag.IDENTITY) == null) return;
- StanzaNode? message_node = message.stanza.get_deep_subnode(NS_VER(stream) + ":result", "urn:xmpp:forward:0:forwarded", Message.NS_URI + ":message");
+ StanzaNode? message_node = message.stanza.get_deep_subnode(NS_VER(stream) + ":result", "urn:xmpp:forward:0:forwarded", Xmpp.NS_URI + ":message");
if (message_node != null) {
StanzaNode? forward_node = message.stanza.get_deep_subnode(NS_VER(stream) + ":result", "urn:xmpp:forward:0:forwarded", DelayedDelivery.NS_URI + ":delay");
DateTime? datetime = DelayedDelivery.Module.get_time_for_node(forward_node);
@@ -120,7 +120,7 @@ public class Flag : XmppStreamFlag {
public override string get_id() { return IDENTITY.id; }
}
-public class MessageFlag : Message.MessageFlag {
+public class MessageFlag : Xmpp.MessageFlag {
public const string ID = "message_archive_management";
public DateTime? server_time { get; private set; }
@@ -129,7 +129,7 @@ public class MessageFlag : Message.MessageFlag {
this.server_time = server_time;
}
- public static MessageFlag? get_flag(Message.Stanza message) { return (MessageFlag) message.get_flag(NS_URI, ID); }
+ public static MessageFlag? get_flag(MessageStanza message) { return (MessageFlag) message.get_flag(NS_URI, ID); }
public override string get_ns() { return NS_URI; }
public override string get_id() { return ID; }
diff --git a/xmpp-vala/src/module/xep/0333_chat_markers.vala b/xmpp-vala/src/module/xep/0333_chat_markers.vala
index 27cbd107..2cba957a 100644
--- a/xmpp-vala/src/module/xep/0333_chat_markers.vala
+++ b/xmpp-vala/src/module/xep/0333_chat_markers.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.ChatMarkers {
private const string NS_URI = "urn:xmpp:chat-markers:0";
@@ -14,39 +12,39 @@ private const string[] MARKERS = {MARKER_RECEIVED, MARKER_DISPLAYED, MARKER_ACKN
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0333_chat_markers");
- public signal void marker_received(XmppStream stream, string jid, string marker, string id);
+ public signal void marker_received(XmppStream stream, Jid jid, string marker, string id);
private SendPipelineListener send_pipeline_listener = new SendPipelineListener();
- public void send_marker(XmppStream stream, string jid, string message_id, string type_, string marker) {
- Message.Stanza received_message = new Message.Stanza();
+ public void send_marker(XmppStream stream, Jid jid, string message_id, string type_, string marker) {
+ MessageStanza received_message = new MessageStanza();
received_message.to = jid;
received_message.type_ = type_;
received_message.stanza.put_node(new StanzaNode.build(marker, NS_URI).add_self_xmlns().put_attribute("id", message_id));
- stream.get_module(Message.Module.IDENTITY).send_message(stream, received_message);
+ stream.get_module(MessageModule.IDENTITY).send_message(stream, received_message);
}
- public static bool requests_marking(Message.Stanza message) {
+ public static bool requests_marking(MessageStanza message) {
StanzaNode markable_node = message.stanza.get_subnode("markable", NS_URI);
return markable_node != null;
}
public override void attach(XmppStream stream) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
- stream.get_module(Message.Module.IDENTITY).send_pipeline.connect(send_pipeline_listener);
- stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
+ stream.get_module(MessageModule.IDENTITY).send_pipeline.connect(send_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_message.connect(on_received_message);
}
public override void detach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
- stream.get_module(Message.Module.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
+ stream.get_module(MessageModule.IDENTITY).received_message.disconnect(on_received_message);
+ stream.get_module(MessageModule.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
}
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private void on_received_message(XmppStream stream, Message.Stanza message) {
- if (message.type_ != Message.Stanza.TYPE_CHAT) return;
+ private void on_received_message(XmppStream stream, MessageStanza message) {
+ if (message.type_ != MessageStanza.TYPE_CHAT) return;
Gee.List<StanzaNode> nodes = message.stanza.get_all_subnodes();
foreach (StanzaNode node in nodes) {
if (node.ns_uri == NS_URI && node.name in MARKERS) {
@@ -56,18 +54,18 @@ public class Module : XmppStreamModule {
}
}
-public class SendPipelineListener : StanzaListener<Message.Stanza> {
+public class SendPipelineListener : StanzaListener<MessageStanza> {
private const string[] after_actions_const = {};
public override string action_group { get { return "ADD_NODES"; } }
public override string[] after_actions { get { return after_actions_const; } }
- public override async void run(Core.XmppStream stream, Message.Stanza message) {
+ public override async void run(XmppStream stream, MessageStanza message) {
StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI);
if (received_node != null) return;
if (message.body == null) return;
- if (message.type_ != Message.Stanza.TYPE_CHAT) return;
+ if (message.type_ != MessageStanza.TYPE_CHAT) return;
message.stanza.put_node(new StanzaNode.build("markable", NS_URI).add_self_xmlns());
}
}
diff --git a/xmpp-vala/src/module/xep/0368_srv_records_tls.vala b/xmpp-vala/src/module/xep/0368_srv_records_tls.vala
index 4d34e750..8ec299aa 100644
--- a/xmpp-vala/src/module/xep/0368_srv_records_tls.vala
+++ b/xmpp-vala/src/module/xep/0368_srv_records_tls.vala
@@ -1,7 +1,5 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Xep.SrvRecordsTls {
public class Module : XmppStreamNegotiationModule {
@@ -22,11 +20,11 @@ public class Module : XmppStreamNegotiationModule {
public class TlsConnectionProvider : 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("xmpps-client", "tcp", remote_name, null);
+ xmpp_target = yield resolver.lookup_service_async("xmpps-client", "tcp", remote_name.to_string(), null);
} catch (Error e) {
return null;
}
diff --git a/xmpp-vala/tests/common.vala b/xmpp-vala/tests/common.vala
index e1c155ac..01cc7d09 100644
--- a/xmpp-vala/tests/common.vala
+++ b/xmpp-vala/tests/common.vala
@@ -39,7 +39,7 @@ bool fail_if_eq_int(int left, int right, string? reason = null) {
return fail_if(left == right, @"$(reason + ": " ?? "")$left == $right");
}
-bool fail_if_not_eq_node(Core.StanzaNode left, Core.StanzaNode right, string? reason = null) {
+bool fail_if_not_eq_node(StanzaNode left, StanzaNode right, string? reason = null) {
if (fail_if_not_eq_str(left.name, right.name, @"$(reason + ": " ?? "")name mismatch")) return true;
if (fail_if_not_eq_str(left.val, right.val, @"$(reason + ": " ?? "")val mismatch")) return true;
if (left.name == "#text") return false;
@@ -55,7 +55,7 @@ bool fail_if_not_eq_node(Core.StanzaNode left, Core.StanzaNode right, string? re
return false;
}
-bool fail_if_not_eq_attr(Core.StanzaAttribute left, Core.StanzaAttribute right, string? reason = null) {
+bool fail_if_not_eq_attr(StanzaAttribute left, StanzaAttribute right, string? reason = null) {
if (fail_if_not_eq_str(left.name, right.name, @"$(reason + ": " ?? "")name mismatch")) return true;
if (fail_if_not_eq_str(left.val, right.val, @"$(reason + ": " ?? "")val mismatch")) return true;
if (fail_if_not_eq_str(left.ns_uri, right.ns_uri, @"$(reason + ": " ?? "")ns_uri mismatch")) return true;