aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/core')
-rw-r--r--xmpp-vala/src/core/xmpp_stream.vala19
1 files changed, 17 insertions, 2 deletions
diff --git a/xmpp-vala/src/core/xmpp_stream.vala b/xmpp-vala/src/core/xmpp_stream.vala
index 2cba2b54..18256119 100644
--- a/xmpp-vala/src/core/xmpp_stream.vala
+++ b/xmpp-vala/src/core/xmpp_stream.vala
@@ -126,9 +126,10 @@ public class XmppStream {
foreach (XmppStreamModule module in modules) module.detach(this);
}
- public XmppStreamModule? get_module(string ns, string id) {
+ public T? get_module<T>(ModuleIdentity<T>? identity) {
+ if (identity == null) return null;
foreach (var module in modules) {
- if (module.get_ns() == ns && module.get_id() == id) {
+ if (module.get_ns() == identity.ns && module.get_id() == identity.id) {
return module;
}
}
@@ -231,6 +232,20 @@ public abstract class XmppStreamFlag {
public abstract string get_id();
}
+public class ModuleIdentity<T> : Object {
+ public string ns { get; private set; }
+ public string id { get; private set; }
+
+ public ModuleIdentity(string ns, string id) {
+ this.ns = ns;
+ this.id = id;
+ }
+
+ public T? cast(XmppStreamModule module) {
+ return (T?) module;
+ }
+}
+
public abstract class XmppStreamModule : Object {
public abstract void attach(XmppStream stream);
public abstract void detach(XmppStream stream);