aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0030_service_discovery
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/module/xep/0030_service_discovery')
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/flag.vala19
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala6
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala8
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/module.vala11
4 files changed, 29 insertions, 15 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 7c49fc30..cd847974 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
@@ -7,11 +7,12 @@ namespace Xmpp.Xep.ServiceDiscovery {
public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "service_discovery");
- private HashMap<string, ArrayList<string>?> entity_features = new HashMap<string, ArrayList<string>?>();
- private HashMap<string, ArrayList<Identity>?> entity_identities = new HashMap<string, ArrayList<Identity>?>();
- public ArrayList<string> features = new ArrayList<string>();
+ 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>?>();
+ public Gee.List<string> features = new ArrayList<string>();
- public ArrayList<Identity>? get_entity_categories(string jid) {
+ public Gee.List<Identity>? get_entity_categories(string jid) {
return entity_identities.has_key(jid) ? entity_identities[jid] : null; // TODO isnt this default for hashmap
}
@@ -30,14 +31,18 @@ public class Flag : XmppStreamFlag {
return entity_features[jid].contains(feature);
}
- public void set_entity_identities(string jid, ArrayList<Identity>? identities) {
+ public void set_entity_identities(string jid, Gee.List<Identity>? identities) {
entity_identities[jid] = identities;
}
- public void set_entity_features(string jid, ArrayList<string>? features) {
+ public void set_entity_features(string jid, Gee.List<string>? features) {
entity_features[jid] = features;
}
+ public void set_entity_items(string jid, Gee.List<Item>? features) {
+ entity_items[jid] = features;
+ }
+
public void add_own_feature(string feature) { features.add(feature); }
public override string get_ns() { return NS_URI; }
@@ -45,4 +50,4 @@ public class Flag : XmppStreamFlag {
public override string get_id() { return IDENTITY.id; }
}
-} \ No newline at end of file
+}
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 ae6b9caf..4ae917dc 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
@@ -7,7 +7,7 @@ namespace Xmpp.Xep.ServiceDiscovery {
public class InfoResult {
public Iq.Stanza iq { get; private set; }
- public ArrayList<string> features {
+ public Gee.List<string> features {
owned get {
ArrayList<string> ret = new ArrayList<string>();
foreach (StanzaNode feature_node in iq.stanza.get_subnode("query", NS_URI_INFO).get_subnodes("feature", NS_URI_INFO)) {
@@ -22,7 +22,7 @@ public class InfoResult {
}
}
- public ArrayList<Identity> identities {
+ public Gee.List<Identity> identities {
owned get {
ArrayList<Identity> ret = new ArrayList<Identity>();
foreach (StanzaNode feature_node in iq.stanza.get_subnode("query", NS_URI_INFO).get_subnodes("identity", NS_URI_INFO)) {
@@ -75,4 +75,4 @@ public class InfoResult {
}
}
-} \ No newline at end of file
+}
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 2c29c320..2979f108 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
@@ -19,9 +19,13 @@ public class ItemsResult {
}
}
- public ItemsResult.from_iq(Iq.Stanza iq) {
+ private ItemsResult.from_iq(Iq.Stanza iq) {
this.iq = iq;
}
+
+ public static ItemsResult? create_from_iq(Iq.Stanza iq) {
+ return new ItemsResult.from_iq(iq);
+ }
}
-} \ No newline at end of file
+}
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 d8852735..e09a3b8d 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
@@ -29,9 +29,9 @@ public class Module : XmppStreamModule, Iq.Handler {
identities.add(new Identity(category, type, name));
}
- public delegate void HasEntryCategoryRes(XmppStream stream, ArrayList<Identity>? identities);
+ public delegate void HasEntryCategoryRes(XmppStream stream, Gee.List<Identity>? identities);
public void get_entity_categories(XmppStream stream, string jid, owned HasEntryCategoryRes listener) {
- ArrayList<Identity>? res = stream.get_flag(Flag.IDENTITY).get_entity_categories(jid);
+ 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) => {
listener(stream, query_result != null ? query_result.identities : null);
@@ -54,7 +54,12 @@ public class Module : XmppStreamModule, Iq.Handler {
public void request_items(XmppStream stream, string 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);
+ print(iq.stanza.to_string() + "\n");
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
+ ItemsResult? result = ItemsResult.create_from_iq(iq);
+ stream.get_flag(Flag.IDENTITY).set_entity_items(iq.from, result != null ? result.items : null);
+ listener(stream, result);
+ });
}
public void on_iq_get(XmppStream stream, Iq.Stanza iq) {