aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/iq
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-06-13 18:14:59 +0200
committerfiaxh <git@mx.ax.lt>2017-06-13 20:12:40 +0200
commit7bbbb738fdb233f4ad91ffdd7d9247b28849d715 (patch)
tree649ac26e3feef6bae614442a7f3d6ee1057336e0 /xmpp-vala/src/module/iq
parentdabc2a8b1d2a7bf2019e5f913c736d80f11ceb53 (diff)
downloaddino-7bbbb738fdb233f4ad91ffdd7d9247b28849d715.tar.gz
dino-7bbbb738fdb233f4ad91ffdd7d9247b28849d715.zip
Get rid of manual storage objects for delegates
Diffstat (limited to 'xmpp-vala/src/module/iq')
-rw-r--r--xmpp-vala/src/module/iq/module.vala16
1 files changed, 7 insertions, 9 deletions
diff --git a/xmpp-vala/src/module/iq/module.vala b/xmpp-vala/src/module/iq/module.vala
index 6cd474ca..c3b7bffe 100644
--- a/xmpp-vala/src/module/iq/module.vala
+++ b/xmpp-vala/src/module/iq/module.vala
@@ -11,15 +11,15 @@ namespace Xmpp.Iq {
private HashMap<string, ResponseListener> responseListeners = new HashMap<string, ResponseListener>();
private HashMap<string, ArrayList<Handler>> namespaceRegistrants = new HashMap<string, ArrayList<Handler>>();
- [CCode (has_target = false)] public delegate void OnResult(XmppStream stream, Iq.Stanza iq, Object? store);
- public void send_iq(XmppStream stream, Iq.Stanza iq, OnResult? listener = null, Object? store = null) {
+ public delegate void OnResult(XmppStream stream, Iq.Stanza iq);
+ public void send_iq(XmppStream stream, Iq.Stanza iq, owned OnResult? listener = null) {
try {
stream.write(iq.stanza);
} catch (IOStreamError e) {
print(@"$(e.message)\n");
}
if (listener != null) {
- responseListeners[iq.id] = new ResponseListener(listener, store);
+ responseListeners[iq.id] = new ResponseListener((owned) listener);
}
}
@@ -56,7 +56,7 @@ namespace Xmpp.Iq {
if (responseListeners.has_key(iq.id)) {
ResponseListener? listener = responseListeners.get(iq.id);
if (listener != null) {
- listener.on_result(stream, iq, listener.reference);
+ listener.on_result(stream, iq);
}
responseListeners.unset(iq.id);
}
@@ -79,12 +79,10 @@ namespace Xmpp.Iq {
}
private class ResponseListener {
- public OnResult on_result { get; private set; }
- public Object? reference { get; private set; }
+ public OnResult on_result { get; private owned set; }
- public ResponseListener(OnResult on_result, Object? reference = null) {
- this.on_result = on_result;
- this.reference = reference;
+ public ResponseListener(owned OnResult on_result) {
+ this.on_result = (owned) on_result;
}
}
}