diff options
author | fiaxh <git@mx.ax.lt> | 2017-06-13 18:14:59 +0200 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-06-13 20:12:40 +0200 |
commit | 7bbbb738fdb233f4ad91ffdd7d9247b28849d715 (patch) | |
tree | 649ac26e3feef6bae614442a7f3d6ee1057336e0 /xmpp-vala/src/module/xep/0030_service_discovery | |
parent | dabc2a8b1d2a7bf2019e5f913c736d80f11ceb53 (diff) | |
download | dino-7bbbb738fdb233f4ad91ffdd7d9247b28849d715.tar.gz dino-7bbbb738fdb233f4ad91ffdd7d9247b28849d715.zip |
Get rid of manual storage objects for delegates
Diffstat (limited to 'xmpp-vala/src/module/xep/0030_service_discovery')
-rw-r--r-- | xmpp-vala/src/module/xep/0030_service_discovery/module.vala | 29 |
1 files changed, 13 insertions, 16 deletions
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 2ec0f630..d8852735 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala @@ -29,32 +29,29 @@ public class Module : XmppStreamModule, Iq.Handler { identities.add(new Identity(category, type, name)); } - [CCode (has_target = false)] public delegate void HasEntryCategoryRes(XmppStream stream, ArrayList<Identity>? identities, Object? store); - public void get_entity_categories(XmppStream stream, string jid, HasEntryCategoryRes on_result, Object? store) { + public delegate void HasEntryCategoryRes(XmppStream stream, ArrayList<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); - if (res != null) on_result(stream, res, store); - request_info(stream, jid, (stream, query_result, store) => { - Tuple<HasEntryCategoryRes, Object> tuple = store as Tuple<HasEntryCategoryRes, Object>; - tuple.a(stream, query_result != null ? query_result.identities : null, tuple.b); - }, Tuple.create(on_result, store)); + if (res != null) listener(stream, res); + request_info(stream, jid, (stream, query_result) => { + listener(stream, query_result != null ? query_result.identities : null); + }); } - [CCode (has_target = false)] public delegate void OnInfoResult(XmppStream stream, InfoResult? query_result, Object? store); - public void request_info(XmppStream stream, string jid, OnInfoResult listener, Object? store) { + public delegate void OnInfoResult(XmppStream stream, InfoResult? query_result); + public void request_info(XmppStream stream, string 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, o) => { - Tuple<OnInfoResult, Object> tuple = o as Tuple<OnInfoResult, Object>; - OnInfoResult on_result = tuple.a; + stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => { InfoResult? result = InfoResult.create_from_iq(iq); stream.get_flag(Flag.IDENTITY).set_entity_features(iq.from, result != null ? result.features : null); stream.get_flag(Flag.IDENTITY).set_entity_identities(iq.from, result != null ? result.identities : null); - on_result(stream, result, tuple.b); - }, Tuple.create(listener, store)); + listener(stream, result); + }); } - [CCode (has_target = false)] public delegate void OnItemsResult(XmppStream stream, ItemsResult query_result); - public void request_items(XmppStream stream, string jid, OnItemsResult listener, Object? store) { + public delegate void OnItemsResult(XmppStream stream, ItemsResult query_result); + 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); |