From 26b16665e5893d1afcad64a2e027e504d87b4bd0 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 19 Dec 2016 18:09:03 +0100 Subject: [PATCH] Add setting to enable IoT Managers automatically or not. Since they interfer a lot with existing code (presence management etc.) --- .../java/org/jivesoftware/smackx/iot/IoTManager.java | 10 ++++++++++ .../jivesoftware/smackx/iot/data/IoTDataManager.java | 1 + .../smackx/iot/discovery/IoTDiscoveryManager.java | 2 ++ .../iot/provisioning/IoTProvisioningManager.java | 2 ++ 4 files changed, 15 insertions(+) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/IoTManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/IoTManager.java index eb8b78ac4..97ed28fce 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/IoTManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/IoTManager.java @@ -34,6 +34,16 @@ public abstract class IoTManager extends Manager { private boolean allowNonFriends; + private static boolean autoEnable; + + public static void setAutoEnableIoTManagers(boolean autoEnable) { + IoTManager.autoEnable = autoEnable; + } + + public static boolean isAutoEnableActive() { + return autoEnable; + } + protected IoTManager(XMPPConnection connection) { super(connection); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java index 2602927d5..1c1d77caf 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java @@ -62,6 +62,7 @@ public final class IoTDataManager extends IoTManager { static { XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() { public void connectionCreated(XMPPConnection connection) { + if (!isAutoEnableActive()) return; getInstanceFor(connection); } }); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java index f1ce9c362..678ab5bcd 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java @@ -39,6 +39,7 @@ import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.packet.DiscoverInfo; +import org.jivesoftware.smackx.iot.IoTManager; import org.jivesoftware.smackx.iot.Thing; import org.jivesoftware.smackx.iot.control.IoTControlManager; import org.jivesoftware.smackx.iot.data.IoTDataManager; @@ -74,6 +75,7 @@ public final class IoTDiscoveryManager extends Manager { static { XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() { public void connectionCreated(XMPPConnection connection) { + if (!IoTManager.isAutoEnableActive()) return; getInstanceFor(connection); } }); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java index 33196beb2..5069c7ee6 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java @@ -49,6 +49,7 @@ import org.jivesoftware.smack.roster.RosterEntry; import org.jivesoftware.smack.roster.SubscribeListener; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.packet.DiscoverInfo; +import org.jivesoftware.smackx.iot.IoTManager; import org.jivesoftware.smackx.iot.discovery.IoTDiscoveryManager; import org.jivesoftware.smackx.iot.provisioning.element.ClearCache; import org.jivesoftware.smackx.iot.provisioning.element.ClearCacheResponse; @@ -83,6 +84,7 @@ public final class IoTProvisioningManager extends Manager { static { XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() { public void connectionCreated(XMPPConnection connection) { + if (!IoTManager.isAutoEnableActive()) return; getInstanceFor(connection); } });