use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class FileTransferNegotiator method setServiceEnabled.
/**
* Enable the Jabber services related to file transfer on the particular
* connection.
*
* @param connection The connection on which to enable or disable the services.
* @param isEnabled True to enable, false to disable.
*/
private static void setServiceEnabled(final XMPPConnection connection, final boolean isEnabled) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(connection);
List<String> namespaces = new ArrayList<>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(DataPacketExtension.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Bytestream.NAMESPACE);
}
for (String namespace : namespaces) {
if (isEnabled) {
manager.addFeature(namespace);
} else {
manager.removeFeature(namespace);
}
}
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class EntityTimeManager method disable.
public synchronized void disable() {
if (!enabled)
return;
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection());
sdm.removeFeature(Time.NAMESPACE);
enabled = false;
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class MoodIntegrationTest method publishAndWait.
/**
* Publish data using PEP, and block until the server has echoed the publication back to the publishing user.
*
* @param moodManager The MoodManager instance for the connection that is expected to publish data.
* @param discoManager The ServiceDiscoveryManager instance for the connection that is expected to publish data.
* @param data The data to be published.
*
* @throws Exception if the test fails
*/
public void publishAndWait(MoodManager moodManager, ServiceDiscoveryManager discoManager, Mood data) throws Exception {
final SimpleResultSyncPoint publicationEchoReceived = new SimpleResultSyncPoint();
final PepEventListener<MoodElement> publicationEchoListener = (jid, moodElement, id, message) -> {
if (moodElement.getMood().equals(data)) {
publicationEchoReceived.signal();
}
};
try {
registerListenerAndWait(moodManager, discoManager, publicationEchoListener);
moodManager.addMoodListener(publicationEchoListener);
moodManager.setMood(data);
} finally {
moodManager.removeMoodListener(publicationEchoListener);
}
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class EntityCapsTest method tearDown.
@AfterClass
public void tearDown() throws NotConnectedException, InterruptedException {
RosterUtil.ensureNotSubscribedToEachOther(conOne, conTwo);
ServiceDiscoveryManager[] sdms = new ServiceDiscoveryManager[] { sdmOne, sdmTwo };
for (ServiceDiscoveryManager sdm : sdms) {
for (String dummyFeature : dummyFeatures) {
sdm.removeFeature(dummyFeature);
}
}
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class UserTuneIntegrationTest method publishAndWait.
/**
* Publish data using PEP, and block until the server has echoed the publication back to the publishing user.
*
* @param userTuneManager The UserTuneManager instance for the connection that is expected to publish data.
* @param discoManager The ServiceDiscoveryManager instance for the connection that is expected to publish data.
* @param data The data to be published.
*
* @throws Exception if the test fails
*/
public void publishAndWait(UserTuneManager userTuneManager, ServiceDiscoveryManager discoManager, UserTuneElement data) throws Exception {
final SimpleResultSyncPoint publicationEchoReceived = new SimpleResultSyncPoint();
final PepEventListener<UserTuneElement> publicationEchoListener = (jid, userTune, id, message) -> {
if (userTune.equals(data)) {
publicationEchoReceived.signal();
}
};
try {
registerListenerAndWait(userTuneManager, discoManager, publicationEchoListener);
userTuneManager.addUserTuneListener(publicationEchoListener);
userTuneManager.publishUserTune(data);
} finally {
userTuneManager.removeUserTuneListener(publicationEchoListener);
}
}
Aggregations