From 98c69f68950b191238895d729ae71391f545d350 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 10 Jan 2015 18:47:47 +0100 Subject: [PATCH] Add ServiceDiscoveryManager.serverSupportsFeature() --- .../smackx/carbons/CarbonManager.java | 3 +-- .../smackx/disco/ServiceDiscoveryManager.java | 15 +++++++++++++++ .../smackx/offline/OfflineMessageManager.java | 2 +- .../smackx/privacy/PrivacyListManager.java | 3 +-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java index 19860e14f..b5d54387d 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java @@ -104,8 +104,7 @@ public class CarbonManager extends Manager { * @throws NoResponseException */ public boolean isSupportedByServer() throws NoResponseException, XMPPErrorException, NotConnectedException { - return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature( - connection().getServiceName(), CarbonExtension.NAMESPACE); + return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(CarbonExtension.NAMESPACE); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java index 079ee61d0..b8b8b6255 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java @@ -637,6 +637,21 @@ public class ServiceDiscoveryManager extends Manager { connection().createPacketCollectorAndSend(discoverItems).nextResultOrThrow(); } + /** + * Returns true if the server supports the given feature. + * + * @param feature + * @return true if the server supports the given feature. + * @throws NoResponseException + * @throws XMPPErrorException + * @throws NotConnectedException + * @since 4.1 + */ + public boolean serverSupportsFeature(String feature) throws NoResponseException, XMPPErrorException, + NotConnectedException { + return supportsFeature(connection().getServiceName(), feature); + } + /** * Queries the remote entity for it's features and returns true if the given feature is found. * diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java index 1ac34e590..7cd707364 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java @@ -78,7 +78,7 @@ public class OfflineMessageManager { * @throws NotConnectedException */ public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException, NotConnectedException { - return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(connection.getServiceName(), namespace); + return ServiceDiscoveryManager.getInstanceFor(connection).serverSupportsFeature(namespace); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java index 532eea2e7..c154ec0e6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java @@ -547,7 +547,6 @@ public class PrivacyListManager extends Manager { * @throws NotConnectedException */ public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException{ - return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature( - connection().getServiceName(), NAMESPACE); + return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(NAMESPACE); } }