mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Fix isSupported discovery of "Push Notifications"
Fixes SMACK-780.
This commit is contained in:
parent
e1e12031ac
commit
0729392ab8
2 changed files with 55 additions and 0 deletions
|
@ -87,13 +87,32 @@ public final class PushNotificationsManager extends Manager {
|
||||||
* @throws XMPPErrorException
|
* @throws XMPPErrorException
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @deprecated Use {@link #isSupported()} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.3
|
||||||
public boolean isSupportedByServer()
|
public boolean isSupportedByServer()
|
||||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
return ServiceDiscoveryManager.getInstanceFor(connection())
|
return ServiceDiscoveryManager.getInstanceFor(connection())
|
||||||
.serverSupportsFeature(PushNotificationsElements.NAMESPACE);
|
.serverSupportsFeature(PushNotificationsElements.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if Push Notifications are supported by this account.
|
||||||
|
*
|
||||||
|
* @return true if Push Notifications are supported by this account.
|
||||||
|
* @throws NoResponseException
|
||||||
|
* @throws XMPPErrorException
|
||||||
|
* @throws NotConnectedException
|
||||||
|
* @throws InterruptedException
|
||||||
|
* @since 4.2.2
|
||||||
|
*/
|
||||||
|
public boolean isSupported()
|
||||||
|
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
|
return ServiceDiscoveryManager.getInstanceFor(connection()).accountSupportsFeatures(
|
||||||
|
PushNotificationsElements.NAMESPACE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable push notifications.
|
* Enable push notifications.
|
||||||
*
|
*
|
||||||
|
|
|
@ -52,6 +52,7 @@ import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||||
|
|
||||||
import org.jxmpp.jid.DomainBareJid;
|
import org.jxmpp.jid.DomainBareJid;
|
||||||
|
import org.jxmpp.jid.EntityBareJid;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
import org.jxmpp.util.cache.Cache;
|
import org.jxmpp.util.cache.Cache;
|
||||||
import org.jxmpp.util.cache.ExpirationCache;
|
import org.jxmpp.util.cache.ExpirationCache;
|
||||||
|
@ -680,6 +681,41 @@ public final class ServiceDiscoveryManager extends Manager {
|
||||||
return supportsFeatures(connection().getXMPPServiceDomain(), features);
|
return supportsFeatures(connection().getXMPPServiceDomain(), features);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given features are supported by the connection account. This means that the discovery information
|
||||||
|
* lookup will be performed on the bare JID of the connection managed by this ServiceDiscoveryManager.
|
||||||
|
*
|
||||||
|
* @param features the features to check
|
||||||
|
* @return <code>true</code> if all features are supported by the connection account, <code>false</code> otherwise
|
||||||
|
* @throws NoResponseException
|
||||||
|
* @throws XMPPErrorException
|
||||||
|
* @throws NotConnectedException
|
||||||
|
* @throws InterruptedException
|
||||||
|
* @since 4.2.2
|
||||||
|
*/
|
||||||
|
public boolean accountSupportsFeatures(CharSequence... features)
|
||||||
|
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
|
return accountSupportsFeatures(Arrays.asList(features));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given collection of features are supported by the connection account. This means that the discovery
|
||||||
|
* information lookup will be performed on the bare JID of the connection managed by this ServiceDiscoveryManager.
|
||||||
|
*
|
||||||
|
* @param features a collection of features
|
||||||
|
* @return <code>true</code> if all features are supported by the connection account, <code>false</code> otherwise
|
||||||
|
* @throws NoResponseException
|
||||||
|
* @throws XMPPErrorException
|
||||||
|
* @throws NotConnectedException
|
||||||
|
* @throws InterruptedException
|
||||||
|
* @since 4.2.2
|
||||||
|
*/
|
||||||
|
public boolean accountSupportsFeatures(Collection<? extends CharSequence> features)
|
||||||
|
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
|
EntityBareJid accountJid = connection().getUser().asEntityBareJid();
|
||||||
|
return supportsFeatures(accountJid, features);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the remote entity for it's features and returns true if the given feature is found.
|
* Queries the remote entity for it's features and returns true if the given feature is found.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue