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/xep/0030_service_discovery/flag.vala | 8 ++------ xmpp-vala/src/module/xep/0030_service_discovery/module.vala | 11 +++++------ 2 files changed, 7 insertions(+), 12 deletions(-) (limited to 'xmpp-vala/src/module/xep/0030_service_discovery') diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala b/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala index 5be9f2eb..0f82f498 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala @@ -5,7 +5,7 @@ using Xmpp.Core; namespace Xmpp.Xep.ServiceDiscovery { public class Flag : XmppStreamFlag { - public const string ID = "service_discovery"; + public static FlagIdentity IDENTITY = new FlagIdentity(NS_URI, "service_discovery"); private HashMap> entity_features = new HashMap>(); public ArrayList features = new ArrayList(); @@ -21,13 +21,9 @@ public class Flag : XmppStreamFlag { public void add_own_feature(string feature) { features.add(feature); } - 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/xep/0030_service_discovery/module.vala b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala index 56df7771..4b51e230 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala @@ -8,8 +8,7 @@ namespace Xmpp.Xep.ServiceDiscovery { public const string NS_URI_ITEMS = NS_URI + "#items"; public class Module : XmppStreamModule, Iq.Handler { - public const string ID = "0030_service_discovery_module"; - public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0030_service_discovery_module"); public ArrayList identities = new ArrayList(); @@ -18,7 +17,7 @@ namespace Xmpp.Xep.ServiceDiscovery { } public void add_feature(XmppStream stream, string feature) { - Flag.get_flag(stream).add_own_feature(feature); + stream.get_flag(Flag.IDENTITY).add_own_feature(feature); } public void add_feature_notify(XmppStream stream, string feature) { @@ -66,21 +65,21 @@ namespace Xmpp.Xep.ServiceDiscovery { } public override string get_ns() { return NS_URI; } - public override string get_id() { return ID; } + public override string get_id() { return IDENTITY.id; } private static void on_request_info_response(XmppStream stream, Iq.Stanza iq, Object o) { Tuple tuple = o as Tuple; OnInfoResult on_result = tuple.a; InfoResult? result = InfoResult.create_from_iq(iq); if (result != null) { - Flag.get_flag(stream).set_entitiy_features(iq.from, result.features); + stream.get_flag(Flag.IDENTITY).set_entitiy_features(iq.from, result.features); on_result(stream, result, tuple.b); } } private void send_query_result(XmppStream stream, Iq.Stanza iq_request) { InfoResult query_result = new ServiceDiscovery.InfoResult(iq_request); - query_result.features = Flag.get_flag(stream).features; + query_result.features = stream.get_flag(Flag.IDENTITY).features; query_result.identities = identities; stream.get_module(Iq.Module.IDENTITY).send_iq(stream, query_result.iq); } -- cgit v1.2.3-70-g09d2