From 7bbbb738fdb233f4ad91ffdd7d9247b28849d715 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 13 Jun 2017 18:14:59 +0200 Subject: Get rid of manual storage objects for delegates --- .../module/xep/0030_service_discovery/module.vala | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'xmpp-vala/src/module/xep/0030_service_discovery') 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? identities, Object? store); - public void get_entity_categories(XmppStream stream, string jid, HasEntryCategoryRes on_result, Object? store) { + public delegate void HasEntryCategoryRes(XmppStream stream, ArrayList? identities); + public void get_entity_categories(XmppStream stream, string jid, owned HasEntryCategoryRes listener) { ArrayList? 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 tuple = store as Tuple; - 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 tuple = o as Tuple; - 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); -- cgit v1.2.3-70-g09d2