diff options
Diffstat (limited to 'xmpp-vala/src/module/xep')
5 files changed, 33 insertions, 19 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) { diff --git a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala index 6f19fb12..689c3605 100644 --- a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala +++ b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala @@ -55,7 +55,7 @@ namespace Xmpp.Xep.EntityCapabilities { StanzaNode? c_node = presence.stanza.get_subnode("c", NS_URI); if (c_node != null) { string ver_attribute = c_node.get_attribute("ver", NS_URI); - ArrayList<string> capabilities = storage.get_features(ver_attribute); + Gee.List<string> capabilities = storage.get_features(ver_attribute); if (capabilities.size == 0) { stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, presence.from, (stream, query_result) => { store_entity_result(stream, ver_attribute, query_result); @@ -74,7 +74,7 @@ namespace Xmpp.Xep.EntityCapabilities { } } - private static string compute_hash(ArrayList<ServiceDiscovery.Identity> identities, ArrayList<string> features) { + private static string compute_hash(Gee.List<ServiceDiscovery.Identity> identities, Gee.List<string> features) { identities.sort(compare_identities); features.sort(); @@ -109,7 +109,7 @@ namespace Xmpp.Xep.EntityCapabilities { } public interface Storage : Object { - public abstract void store_features(string entitiy, ArrayList<string> capabilities); - public abstract ArrayList<string> get_features(string entitiy); + public abstract void store_features(string entitiy, Gee.List<string> capabilities); + public abstract Gee.List<string> get_features(string entitiy); } } |