aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0030_service_discovery
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2018-01-12 21:03:09 +0100
committerfiaxh <git@mx.ax.lt>2018-01-28 00:38:47 +0100
commit782ae4c049e2b6fab13d7453cbb0e74610e7d200 (patch)
tree1b4cd0a1689cee0c2e2cac2ae9a5fb8ebbe63621 /xmpp-vala/src/module/xep/0030_service_discovery
parentd46d071e57e599e8cfb1780597cbecb36881c4d8 (diff)
downloaddino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz
dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'xmpp-vala/src/module/xep/0030_service_discovery')
-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
5 files changed, 15 insertions, 23 deletions
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) => {