aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/core/module_flag.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-11-16 15:55:33 +0100
committerfiaxh <git@lightrise.org>2020-11-20 15:21:18 +0100
commit07917f1d841f449157aa3aaa2507b0547dd274e7 (patch)
tree315ef3bc243491565d3d5097968dca38d67a7eab /xmpp-vala/src/core/module_flag.vala
parent881b9eec9dcd8fd8c81b0b9d7bfd2ae714d7722e (diff)
downloaddino-07917f1d841f449157aa3aaa2507b0547dd274e7.tar.gz
dino-07917f1d841f449157aa3aaa2507b0547dd274e7.zip
Refactor XmppStream, TLS and connection method logic
fixes #534
Diffstat (limited to 'xmpp-vala/src/core/module_flag.vala')
-rw-r--r--xmpp-vala/src/core/module_flag.vala61
1 files changed, 61 insertions, 0 deletions
diff --git a/xmpp-vala/src/core/module_flag.vala b/xmpp-vala/src/core/module_flag.vala
new file mode 100644
index 00000000..95547852
--- /dev/null
+++ b/xmpp-vala/src/core/module_flag.vala
@@ -0,0 +1,61 @@
+namespace Xmpp {
+
+ public class FlagIdentity<T> : Object {
+ public string ns { get; private set; }
+ public string id { get; private set; }
+
+ public FlagIdentity(string ns, string id) {
+ this.ns = ns;
+ this.id = id;
+ }
+
+ public T? cast(XmppStreamFlag flag) {
+ return flag.get_type().is_a(typeof(T)) ? (T?) flag : null;
+ }
+
+ public bool matches(XmppStreamFlag module) {
+ return module.get_ns() == ns && module.get_id() == id;
+ }
+ }
+
+ public abstract class XmppStreamFlag : Object {
+ public abstract string get_ns();
+
+ 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 module.get_type().is_a(typeof(T)) ? (T?) module : null;
+ }
+
+ public bool matches(XmppStreamModule module) {
+ return module.get_ns() == ns && module.get_id() == id;
+ }
+ }
+
+ public abstract class XmppStreamModule : Object {
+ public abstract void attach(XmppStream stream);
+
+ public abstract void detach(XmppStream stream);
+
+ public abstract string get_ns();
+
+ public abstract string get_id();
+ }
+
+ public abstract class XmppStreamNegotiationModule : XmppStreamModule {
+ public abstract bool mandatory_outstanding(XmppStream stream);
+
+ public abstract bool negotiation_active(XmppStream stream);
+ }
+
+} \ No newline at end of file