From ea174ab632ced082eb0f1c51cea1bc9dc5c7c89e Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 2 Aug 2017 17:29:55 +0200 Subject: Http file upload --- .../src/module/xep/0030_service_discovery/flag.vala | 19 ++++++++++++------- .../xep/0030_service_discovery/info_result.vala | 6 +++--- .../xep/0030_service_discovery/items_result.vala | 8 ++++++-- .../src/module/xep/0030_service_discovery/module.vala | 11 ++++++++--- .../src/module/xep/0115_entitiy_capabilities.vala | 8 ++++---- 5 files changed, 33 insertions(+), 19 deletions(-) (limited to 'xmpp-vala/src/module/xep') 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 IDENTITY = new FlagIdentity(NS_URI, "service_discovery"); - private HashMap?> entity_features = new HashMap?>(); - private HashMap?> entity_identities = new HashMap?>(); - public ArrayList features = new ArrayList(); + private HashMap?> entity_features = new HashMap?>(); + private HashMap?> entity_identities = new HashMap?>(); + private HashMap?> entity_items = new HashMap?>(); + public Gee.List features = new ArrayList(); - public ArrayList? get_entity_categories(string jid) { + public Gee.List? 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? identities) { + public void set_entity_identities(string jid, Gee.List? identities) { entity_identities[jid] = identities; } - public void set_entity_features(string jid, ArrayList? features) { + public void set_entity_features(string jid, Gee.List? features) { entity_features[jid] = features; } + public void set_entity_items(string jid, Gee.List? 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 features { + public Gee.List features { owned get { ArrayList ret = new ArrayList(); 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 identities { + public Gee.List identities { owned get { ArrayList ret = new ArrayList(); 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? identities); + public delegate void HasEntryCategoryRes(XmppStream stream, Gee.List? identities); public void get_entity_categories(XmppStream stream, string jid, owned HasEntryCategoryRes listener) { - ArrayList? res = stream.get_flag(Flag.IDENTITY).get_entity_categories(jid); + Gee.List? 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 capabilities = storage.get_features(ver_attribute); + Gee.List 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 identities, ArrayList features) { + private static string compute_hash(Gee.List identities, Gee.List 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 capabilities); - public abstract ArrayList get_features(string entitiy); + public abstract void store_features(string entitiy, Gee.List capabilities); + public abstract Gee.List get_features(string entitiy); } } -- cgit v1.2.3-70-g09d2