mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
Add MamManager.isSupported()
Fixes SMACK-777.
This commit is contained in:
parent
7404bf8fe7
commit
b9ed22c732
2 changed files with 25 additions and 1 deletions
|
@ -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, <code>false</code>otherwhise.
|
||||
*
|
||||
* @throws NoResponseException
|
||||
* @throws XMPPErrorException
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @since 4.2.1
|
||||
* @see <a href="https://xmpp.org/extensions/xep-0313.html#support">XEP-0313 § 7. Determining support</a>
|
||||
*/
|
||||
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);
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue