diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java
index fb9c2535c..9d800f73c 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java
@@ -50,6 +50,7 @@ import org.jivesoftware.smackx.rsm.packet.RSMSet;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
+import org.jxmpp.jid.BareJid;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.EntityFullJid;
import org.jxmpp.jid.Jid;
@@ -103,9 +104,12 @@ public final class MamManager extends Manager {
private final Jid archiveAddress;
+ private final ServiceDiscoveryManager serviceDiscoveryManager;
+
private MamManager(XMPPConnection connection, Jid archiveAddress) {
super(connection);
this.archiveAddress = archiveAddress;
+ serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
}
/**
@@ -586,6 +590,23 @@ public final class MamManager extends Manager {
}
}
+ /**
+ * Check if MAM is supported for the XMPP connection managed by this MamManager.
+ *
+ * @return true if MAM is supported for the XMPP connection, false
otherwhise.
+ *
+ * @throws NoResponseException
+ * @throws XMPPErrorException
+ * @throws NotConnectedException
+ * @throws InterruptedException
+ * @since 4.2.1
+ * @see XEP-0313 ยง 7. Determining support
+ */
+ public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
+ BareJid myBareJid = connection().getUser().asBareJid();
+ return serviceDiscoveryManager.supportsFeature(myBareJid, MamElements.NAMESPACE);
+ }
+
/**
* Returns true if Message Archive Management is supported by the server.
*
@@ -594,7 +615,10 @@ public final class MamManager extends Manager {
* @throws XMPPErrorException
* @throws NoResponseException
* @throws InterruptedException
+ * @depreacted use {@link #isSupported()} instead.
*/
+ @Deprecated
+ // TODO Remove in Smack 4.3
public boolean isSupportedByServer()
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(MamElements.NAMESPACE);
diff --git a/smack-integration-test/src/main/java/org/jivesoftware/smackx/mam/MamIntegrationTest.java b/smack-integration-test/src/main/java/org/jivesoftware/smackx/mam/MamIntegrationTest.java
index 665194be9..587885229 100644
--- a/smack-integration-test/src/main/java/org/jivesoftware/smackx/mam/MamIntegrationTest.java
+++ b/smack-integration-test/src/main/java/org/jivesoftware/smackx/mam/MamIntegrationTest.java
@@ -46,7 +46,7 @@ public class MamIntegrationTest extends AbstractSmackIntegrationTest {
mamManagerConTwo = MamManager.getInstanceFor(conTwo);
- if (!mamManagerConTwo.isSupportedByServer()) {
+ if (!mamManagerConTwo.isSupported()) {
throw new TestNotPossibleException("Message Archive Management (XEP-0313) is not supported by the server.");
}