aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/roster/module.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-11 23:04:58 +0100
committerfiaxh <git@mx.ax.lt>2017-03-11 23:09:57 +0100
commitf40a34bdc1995e656b09cc1252a8dcce685e373f (patch)
treed56684122d0a2f0e13ee9d94e6e8675bae1b4c52 /xmpp-vala/src/module/roster/module.vala
parent0ea4ac7e20674e3e6a8d1b3d4b53702dace72907 (diff)
downloaddino-f40a34bdc1995e656b09cc1252a8dcce685e373f.tar.gz
dino-f40a34bdc1995e656b09cc1252a8dcce685e373f.zip
Use delegates + object storage instead of listener objects
Diffstat (limited to 'xmpp-vala/src/module/roster/module.vala')
-rw-r--r--xmpp-vala/src/module/roster/module.vala22
1 files changed, 10 insertions, 12 deletions
diff --git a/xmpp-vala/src/module/roster/module.vala b/xmpp-vala/src/module/roster/module.vala
index c9400b3a..f29b73f7 100644
--- a/xmpp-vala/src/module/roster/module.vala
+++ b/xmpp-vala/src/module/roster/module.vala
@@ -95,20 +95,18 @@ namespace Xmpp.Roster {
Flag.get_flag(stream).iq_id = random_uuid();
StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns();
Iq.Stanza iq = new Iq.Stanza.get(query_node, Flag.get_flag(stream).iq_id);
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, new IqResponseListenerImpl());
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_roster_get_received);
}
- private class IqResponseListenerImpl : Iq.ResponseListener, Object {
- public void on_result(XmppStream stream, Iq.Stanza iq) {
- Flag flag = Flag.get_flag(stream);
- if (iq.id == flag.iq_id) {
- StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI);
- foreach (StanzaNode item_node in query_node.sub_nodes) {
- Item item = new Item.from_stanza_node(item_node);
- flag.roster_items[item.jid] = item;
- }
- stream.get_module(Module.IDENTITY).received_roster(stream, flag.roster_items.values);
+ private static void on_roster_get_received(XmppStream stream, Iq.Stanza iq) {
+ Flag flag = Flag.get_flag(stream);
+ if (iq.id == flag.iq_id) {
+ StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI);
+ foreach (StanzaNode item_node in query_node.sub_nodes) {
+ Item item = new Item.from_stanza_node(item_node);
+ flag.roster_items[item.jid] = item;
}
+ stream.get_module(Module.IDENTITY).received_roster(stream, flag.roster_items.values);
}
}
@@ -116,7 +114,7 @@ namespace Xmpp.Roster {
StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns()
.put_node(roster_item.stanza_node);
Iq.Stanza iq = new Iq.Stanza.set(query_node);
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, null);
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
}
}
}