aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0115_entitiy_capabilities.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/xep/0115_entitiy_capabilities.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/xep/0115_entitiy_capabilities.vala')
-rw-r--r--xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala21
1 files changed, 7 insertions, 14 deletions
diff --git a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
index 6b8ae3bb..9387faaa 100644
--- a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
+++ b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
@@ -58,26 +58,19 @@ namespace Xmpp.Xep.EntityCapabilities {
string ver_attribute = c_node.get_attribute("ver", NS_URI);
ArrayList<string> capabilities = storage.get_features(ver_attribute);
if (capabilities.size == 0) {
- stream.get_module(ServiceDiscovery.Module.IDENTITY)
- .request_info(stream, presence.from, new ServiceDiscoveryInfoResponseListenerImpl(storage, ver_attribute));
+ stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, presence.from, on_received_info_response, Tuple.create(storage, ver_attribute));
} else {
ServiceDiscovery.Flag.get_flag(stream).set_entitiy_features(presence.from, capabilities);
}
}
}
- private class ServiceDiscoveryInfoResponseListenerImpl : ServiceDiscovery.InfoResponseListener, Object {
- private Storage storage;
- private string entity;
-
- public ServiceDiscoveryInfoResponseListenerImpl(Storage storage, string entity) {
- this.storage = storage;
- this.entity = entity;
- }
- public void on_result(XmppStream stream, ServiceDiscovery.InfoResult query_result) {
- if (compute_hash(query_result.identities, query_result.features) == entity) {
- storage.store_features(entity, query_result.features);
- }
+ private static void on_received_info_response(XmppStream stream, ServiceDiscovery.InfoResult query_result, Object? store) {
+ Tuple<Storage, string> tuple = store as Tuple<Storage, string>;
+ Storage storage = tuple.a;
+ string entity = tuple.b;
+ if (compute_hash(query_result.identities, query_result.features) == entity) {
+ storage.store_features(entity, query_result.features);
}
}