aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/presence
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-19 12:55:36 +0100
committerfiaxh <git@mx.ax.lt>2017-03-20 22:28:27 +0100
commitdb57a973534f099af2b150f1a1307d1948553d9f (patch)
tree238ae1d4e53412a33e3febd07318dfd38b0eb2f8 /xmpp-vala/src/module/presence
parent233f2b35d033cd20d1ac648bf2d723bcb7a918fc (diff)
downloaddino-db57a973534f099af2b150f1a1307d1948553d9f.tar.gz
dino-db57a973534f099af2b150f1a1307d1948553d9f.zip
Add typed identity to manager modules and stream flags
Diffstat (limited to 'xmpp-vala/src/module/presence')
-rw-r--r--xmpp-vala/src/module/presence/flag.vala8
-rw-r--r--xmpp-vala/src/module/presence/module.vala11
2 files changed, 7 insertions, 12 deletions
diff --git a/xmpp-vala/src/module/presence/flag.vala b/xmpp-vala/src/module/presence/flag.vala
index a92c9405..8fb44e13 100644
--- a/xmpp-vala/src/module/presence/flag.vala
+++ b/xmpp-vala/src/module/presence/flag.vala
@@ -5,7 +5,7 @@ using Xmpp.Core;
namespace Xmpp.Presence {
public class Flag : XmppStreamFlag {
- public const string ID = "presence";
+ public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "presence");
private HashMap<string, ConcurrentList<string>> resources = new HashMap<string, ConcurrentList<string>>();
private HashMap<string, Presence.Stanza> presences = new HashMap<string, Presence.Stanza>();
@@ -52,13 +52,9 @@ public class Flag : XmppStreamFlag {
}
}
- public static Flag? get_flag(XmppStream stream) { return (Flag?) stream.get_flag(NS_URI, ID); }
-
- public static bool has_flag(XmppStream stream) { return get_flag(stream) != null; }
-
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
} \ No newline at end of file
diff --git a/xmpp-vala/src/module/presence/module.vala b/xmpp-vala/src/module/presence/module.vala
index 7e5dca17..3c078453 100644
--- a/xmpp-vala/src/module/presence/module.vala
+++ b/xmpp-vala/src/module/presence/module.vala
@@ -4,8 +4,7 @@ namespace Xmpp.Presence {
private const string NS_URI = "jabber:client";
public class Module : XmppStreamModule {
- public const string ID = "presence_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "presence_module");
public signal void received_presence(XmppStream stream, Presence.Stanza presence);
public signal void pre_send_presence_stanza(XmppStream stream, Presence.Stanza presence);
@@ -67,16 +66,16 @@ namespace Xmpp.Presence {
}
private void on_received_presence_stanza(XmppStream stream, StanzaNode node) {
- Presence.Stanza presence = new Presence.Stanza.from_stanza(node, Bind.Flag.get_flag(stream).my_jid);
+ Presence.Stanza presence = new Presence.Stanza.from_stanza(node, stream.get_flag(Bind.Flag.IDENTITY).my_jid);
received_presence(stream, presence);
switch (presence.type_) {
case Presence.Stanza.TYPE_AVAILABLE:
- Flag.get_flag(stream).add_presence(presence);
+ stream.get_flag(Flag.IDENTITY).add_presence(presence);
received_available(stream, presence);
received_available_show(stream, presence.from, presence.show);
break;
case Presence.Stanza.TYPE_UNAVAILABLE:
- Flag.get_flag(stream).remove_presence(presence.from);
+ stream.get_flag(Flag.IDENTITY).remove_presence(presence.from);
received_unavailable(stream, presence.from);
break;
case Presence.Stanza.TYPE_SUBSCRIBE:
@@ -101,7 +100,7 @@ namespace Xmpp.Presence {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
}