正在查看: bbinstant v6.24.0 应用的 AMPManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: bbinstant v6.24.0 应用的 AMPManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.amp.packet.AMPExtension;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
public class AMPManager {
static {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
@Override
public void connectionCreated(XMPPConnection xMPPConnection) {
AMPManager.setServiceEnabled(xMPPConnection, true);
}
});
}
public static boolean isActionSupported(XMPPConnection xMPPConnection, AMPExtension.Action action) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return isFeatureSupportedByServer(xMPPConnection, "http://jabber.org/protocol/amp?action=" + action.toString());
}
public static boolean isConditionSupported(XMPPConnection xMPPConnection, String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return isFeatureSupportedByServer(xMPPConnection, "http://jabber.org/protocol/amp?condition=" + str);
}
private static boolean isFeatureSupportedByServer(XMPPConnection xMPPConnection, String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return ServiceDiscoveryManager.getInstanceFor(xMPPConnection).serverSupportsFeature(str);
}
public static boolean isServiceEnabled(XMPPConnection xMPPConnection) {
xMPPConnection.getXMPPServiceDomain();
return ServiceDiscoveryManager.getInstanceFor(xMPPConnection).includesFeature(AMPExtension.NAMESPACE);
}
public static synchronized void setServiceEnabled(XMPPConnection xMPPConnection, boolean z) {
synchronized (AMPManager.class) {
try {
if (isServiceEnabled(xMPPConnection) == z) {
return;
}
if (z) {
ServiceDiscoveryManager.getInstanceFor(xMPPConnection).addFeature(AMPExtension.NAMESPACE);
} else {
ServiceDiscoveryManager.getInstanceFor(xMPPConnection).removeFeature(AMPExtension.NAMESPACE);
}
} catch (Throwable th) {
throw th;
}
}
}
}