use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project xabber-android by redsolution.
the class AttentionManager method onSettingsChanged.
public void onSettingsChanged() {
synchronized (enabledLock) {
for (AccountJid account : AccountManager.getInstance().getEnabledAccounts()) {
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null) {
continue;
}
ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(accountItem.getConnection());
if (manager == null) {
continue;
}
boolean contains = false;
for (String feature : manager.getFeatures()) {
if (AttentionExtension.NAMESPACE.equals(feature)) {
contains = true;
}
}
if (SettingsManager.chatsAttention() == contains) {
continue;
}
if (SettingsManager.chatsAttention()) {
manager.addFeature(AttentionExtension.NAMESPACE);
} else {
manager.removeFeature(AttentionExtension.NAMESPACE);
}
}
AccountManager.getInstance().resendPresence();
}
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class MessageFasteningManager method announceSupport.
/**
* Announce support for Message Fastening via Service Discovery.
*/
public void announceSupport() {
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection());
discoveryManager.addFeature(NAMESPACE);
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class MessageFasteningManager method stopAnnouncingSupport.
/**
* Stop announcing support for Message Fastening.
*/
public void stopAnnouncingSupport() {
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection());
discoveryManager.removeFeature(NAMESPACE);
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class Socks5BytestreamManager method disableService.
/**
* Disables the SOCKS5 Bytestream manager by removing the SOCKS5 Bytestream feature from the
* service discovery, disabling the listener for SOCKS5 Bytestream initiation requests and
* resetting its internal state, which includes removing this instance from the managers map.
* <p>
* To re-enable the SOCKS5 Bytestream feature invoke {@link #getBytestreamManager(XMPPConnection)}.
* Using the file transfer API will automatically re-enable the SOCKS5 Bytestream feature.
*/
public synchronized void disableService() {
XMPPConnection connection = connection();
// remove initiation packet listener
connection.unregisterIQRequestHandler(initiationListener);
// shutdown threads
this.initiationListener.shutdown();
// clear listeners
this.allRequestListeners.clear();
this.userListeners.clear();
// reset internal state
this.lastWorkingProxy = null;
this.proxyBlacklist.clear();
this.ignoredBytestreamRequests.clear();
// remove manager from static managers map
managers.remove(connection);
// shutdown local SOCKS5 proxy if there are no more managers for other connections
if (managers.size() == 0) {
Socks5Proxy.getSocks5Proxy().stop();
}
// remove feature from service discovery
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
// check if service discovery is not already disposed by connection shutdown
if (serviceDiscoveryManager != null) {
serviceDiscoveryManager.removeFeature(Bytestream.NAMESPACE);
}
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Smack by igniterealtime.
the class FileTransferNegotiator method isServiceEnabled.
/**
* Checks to see if all file transfer related services are enabled on the
* connection.
*
* @param connection The connection to check
* @return True if all related services are enabled, false if they are not.
*/
public static boolean isServiceEnabled(final XMPPConnection connection) {
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 (!manager.includesFeature(namespace)) {
return false;
}
}
return true;
}
Aggregations