From 07917f1d841f449157aa3aaa2507b0547dd274e7 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 16 Nov 2020 15:55:33 +0100 Subject: Refactor XmppStream, TLS and connection method logic fixes #534 --- .../src/module/xep/0030_service_discovery/module.vala | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'xmpp-vala/src/module/xep/0030_service_discovery/module.vala') 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 42547f62..537e460b 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala @@ -23,7 +23,10 @@ public class Module : XmppStreamModule, Iq.Handler { } public void remove_feature(XmppStream stream, string feature) { - stream.get_flag(Flag.IDENTITY).remove_own_feature(feature); + Flag? flag = stream.get_flag(Flag.IDENTITY); + if (flag != null) { + flag.remove_own_feature(feature); + } } public void add_feature_notify(XmppStream stream, string feature) { @@ -34,14 +37,6 @@ public class Module : XmppStreamModule, Iq.Handler { remove_feature(stream, feature + "+notify"); } - public void add_identity(XmppStream stream, Identity identity) { - stream.get_flag(Flag.IDENTITY).add_own_identity(identity); - } - - public void remove_identity(XmppStream stream, Identity identity) { - stream.get_flag(Flag.IDENTITY).remove_own_identity(identity); - } - public async bool has_entity_feature(XmppStream stream, Jid jid, string feature) { return yield this.cache.has_entity_feature(jid, feature); } @@ -93,7 +88,7 @@ public class Module : XmppStreamModule, Iq.Handler { public override void attach(XmppStream stream) { stream.add_flag(new Flag()); - add_identity(stream, own_identity); + stream.get_flag(Flag.IDENTITY).add_own_identity(own_identity); stream.get_module(Iq.Module.IDENTITY).register_for_namespace(NS_URI_INFO, this); add_feature(stream, NS_URI_INFO); @@ -102,7 +97,8 @@ public class Module : XmppStreamModule, Iq.Handler { public override void detach(XmppStream stream) { active_info_requests.clear(); - remove_identity(stream, own_identity); + Flag? flag = stream.get_flag(Flag.IDENTITY); + if (flag != null) flag.remove_own_identity(own_identity); stream.get_module(Iq.Module.IDENTITY).unregister_from_namespace(NS_URI_INFO, this); remove_feature(stream, NS_URI_INFO); -- cgit v1.2.3-54-g00ecf