use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class GeolocationIntegrationTest method registerListenerAndWait.
/**
* Registers a listener for GeoLocation data. This implicitly publishes a CAPS update to include a notification
* filter for the geolocation node. This method blocks until the server has indicated that this update has been
* received.
*
* @param geoManager The GeoLocationManager instance for the connection that is expected to receive data.
* @param discoManager The ServiceDiscoveryManager instance for the connection that is expected to publish data.
* @param listener A listener instance for GeoLocation data that is to be registered.
*
* @throws Exception if the test fails
*/
public void registerListenerAndWait(GeoLocationManager geoManager, ServiceDiscoveryManager discoManager, PepEventListener<GeoLocation> listener) throws Exception {
final SimpleResultSyncPoint notificationFilterReceived = new SimpleResultSyncPoint();
final EntityCapabilitiesChangedListener notificationFilterReceivedListener = info -> {
if (info.containsFeature(GeoLocationManager.GEOLOCATION_NODE + "+notify")) {
notificationFilterReceived.signal();
}
};
discoManager.addEntityCapabilitiesChangedListener(notificationFilterReceivedListener);
try {
geoManager.addGeoLocationListener(listener);
notificationFilterReceived.waitForResult(timeout);
} finally {
discoManager.removeEntityCapabilitiesChangedListener(notificationFilterReceivedListener);
}
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class Workgroup method isEmailAvailable.
/**
* The workgroup service may be configured to send email. This queries the Workgroup Service
* to see if the email service has been configured and is available.
*
* @return true if the email service is available, otherwise return false.
* @throws SmackException if Smack detected an exceptional situation.
* @throws InterruptedException if the calling thread was interrupted.
*/
public boolean isEmailAvailable() throws SmackException, InterruptedException {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
try {
DomainBareJid workgroupService = workgroupJID.asDomainBareJid();
DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService);
return infoResult.containsFeature("jive:email:provider");
} catch (XMPPException e) {
return false;
}
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class HttpFileUploadManager method discoverUploadService.
/**
* Discover upload service.
*
* Called automatically when connection is authenticated.
*
* Note that this is a synchronous call -- Smack must wait for the server response.
*
* @return true if upload service was discovered
*
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
* @throws SmackException.NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
* @throws SmackException.NoResponseException if there was no response from the remote entity.
*/
public boolean discoverUploadService() throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection());
List<DiscoverInfo> servicesDiscoverInfo = sdm.findServicesDiscoverInfo(NAMESPACE, true, true);
if (servicesDiscoverInfo.isEmpty()) {
servicesDiscoverInfo = sdm.findServicesDiscoverInfo(NAMESPACE_0_2, true, true);
if (servicesDiscoverInfo.isEmpty()) {
return false;
}
}
DiscoverInfo discoverInfo = servicesDiscoverInfo.get(0);
defaultUploadService = uploadServiceFrom(discoverInfo);
return true;
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class Socks5ByteStreamManagerTest method shouldDisableService.
/**
* The SOCKS5 Bytestream feature should be removed form the service discovery manager if Socks5
* bytestream feature is disabled.
*
* @throws InterruptedException if the calling thread was interrupted.
* @throws SmackException if Smack detected an exceptional situation.
* @throws XMPPErrorException if there was an XMPP error returned.
*/
@Test
public void shouldDisableService() throws XMPPErrorException, SmackException, InterruptedException {
final Protocol protocol = new Protocol();
final XMPPConnection connection = ConnectionUtils.createMockedConnection(protocol, initiatorJID);
Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
assertTrue(discoveryManager.includesFeature(Bytestream.NAMESPACE));
byteStreamManager.disableService();
assertFalse(discoveryManager.includesFeature(Bytestream.NAMESPACE));
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class PepManager method isSupported.
public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
XMPPConnection connection = connection();
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
BareJid localBareJid = connection.getUser().asBareJid();
return serviceDiscoveryManager.supportsFeatures(localBareJid, REQUIRED_FEATURES);
}
Aggregations