From d8e102a160f316369c99d3dc2df7d7d54f5bc955 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 10 Mar 2017 21:45:56 +0100 Subject: Use typed identity in module manager --- xmpp-vala/src/core/xmpp_stream.vala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'xmpp-vala/src/core') 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(ModuleIdentity? 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 : 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 { -- cgit v1.2.3-70-g09d2