From db57a973534f099af2b150f1a1307d1948553d9f Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 19 Mar 2017 12:55:36 +0100 Subject: Add typed identity to manager modules and stream flags --- xmpp-vala/src/module/presence/flag.vala | 8 ++------ xmpp-vala/src/module/presence/module.vala | 11 +++++------ 2 files changed, 7 insertions(+), 12 deletions(-) (limited to 'xmpp-vala/src/module/presence') 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 IDENTITY = new FlagIdentity(NS_URI, "presence"); private HashMap> resources = new HashMap>(); private HashMap presences = new HashMap(); @@ -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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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; } } } -- cgit v1.2.3-70-g09d2