aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0030_service_discovery
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/xep/0030_service_discovery
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/xep/0030_service_discovery')
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/flag.vala8
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/module.vala11
2 files changed, 7 insertions, 12 deletions
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<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "service_discovery");
private HashMap<string, ArrayList<string>> entity_features = new HashMap<string, ArrayList<string>>();
public ArrayList<string> features = new ArrayList<string>();
@@ -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<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0030_service_discovery_module");
public ArrayList<Identity> identities = new ArrayList<Identity>();
@@ -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<OnInfoResult, Object> tuple = o as Tuple<OnInfoResult, Object>;
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);
}