aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/core
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-10 21:45:56 +0100
committerMarvin W <git@larma.de>2017-03-10 21:49:29 +0100
commitd8e102a160f316369c99d3dc2df7d7d54f5bc955 (patch)
treed712347416a77ebbb5f9fdbb82e542af4555f4d9 /xmpp-vala/src/core
parent9cdc3619bd172a731333b8152ee561eed76e77f8 (diff)
downloaddino-d8e102a160f316369c99d3dc2df7d7d54f5bc955.tar.gz
dino-d8e102a160f316369c99d3dc2df7d7d54f5bc955.zip
Use typed identity in module manager
Diffstat (limited to 'xmpp-vala/src/core')
-rw-r--r--xmpp-vala/src/core/xmpp_stream.vala8
1 files changed, 5 insertions, 3 deletions
diff --git a/xmpp-vala/src/core/xmpp_stream.vala b/xmpp-vala/src/core/xmpp_stream.vala
index 18256119..38b4abb4 100644
--- a/xmpp-vala/src/core/xmpp_stream.vala
+++ b/xmpp-vala/src/core/xmpp_stream.vala
@@ -129,9 +129,7 @@ public class XmppStream {
public T? get_module<T>(ModuleIdentity<T>? identity) {
if (identity == null) return null;
foreach (var module in modules) {
- if (module.get_ns() == identity.ns && module.get_id() == identity.id) {
- return module;
- }
+ if (identity.matches(module)) return identity.cast(module);
}
return null;
}
@@ -244,6 +242,10 @@ public class ModuleIdentity<T> : Object {
public T? cast(XmppStreamModule module) {
return (T?) module;
}
+
+ public bool matches(XmppStreamModule module) {
+ return module.get_ns() == ns && module.get_id() == id;
+ }
}
public abstract class XmppStreamModule : Object {