diff options
author | fiaxh <git@lightrise.org> | 2020-04-24 14:19:42 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2020-04-24 14:19:42 +0200 |
commit | f8f305efe551838c780dce4224c06bed695d8a62 (patch) | |
tree | 1e5b9f6988d0bb911a53d3234eba464873e6984b /xmpp-vala/src/module/xep/0049_private_xml_storage.vala | |
parent | 1db94905ae7af1c1aed475a090dfb09e59fb2520 (diff) | |
download | dino-f8f305efe551838c780dce4224c06bed695d8a62.tar.gz dino-f8f305efe551838c780dce4224c06bed695d8a62.zip |
xmpp-vala: Use more async
Diffstat (limited to 'xmpp-vala/src/module/xep/0049_private_xml_storage.vala')
-rw-r--r-- | xmpp-vala/src/module/xep/0049_private_xml_storage.vala | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala index 5b3eb1b6..81ccde9b 100644 --- a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala +++ b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala @@ -6,22 +6,17 @@ namespace Xmpp.Xep.PrivateXmlStorage { public class Module : XmppStreamModule { public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0049_private_xml_storage"); - public delegate void OnSuccess(XmppStream stream); - public void store(XmppStream stream, StanzaNode node, owned OnSuccess listener) { + public async void store(XmppStream stream, StanzaNode node) { StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node); Iq.Stanza iq = new Iq.Stanza.set(queryNode); - stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => { - listener(stream); - }); + yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); } - public delegate void OnResponse(XmppStream stream, StanzaNode? node); - public void retrieve(XmppStream stream, StanzaNode node, owned OnResponse listener) { + public async StanzaNode? retrieve(XmppStream stream, StanzaNode node) { StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node); Iq.Stanza iq = new Iq.Stanza.get(queryNode); - stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => { - listener(stream, iq.stanza.get_subnode("query", NS_URI)); - }); + Iq.Stanza iq_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + return iq_result.stanza.get_subnode("query", NS_URI); } public override void attach(XmppStream stream) { } |