正在查看: bbinstant v6.24.0 应用的 PubSubManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: bbinstant v6.24.0 应用的 PubSubManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.jivesoftware.smackx.pubsub;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.EmptyResultIQ;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
import org.jivesoftware.smackx.pubsub.packet.PubSub;
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
import org.jivesoftware.smackx.pubsub.util.NodeUtils;
import org.jxmpp.jid.a;
import org.jxmpp.jid.b;
import org.jxmpp.jid.i;
public final class PubSubManager extends Manager {
private final Map<String, Node> nodeMap;
private final a pubSubService;
private static final Logger LOGGER = Logger.getLogger(PubSubManager.class.getName());
private static final Map<XMPPConnection, Map<a, PubSubManager>> INSTANCES = new WeakHashMap();
PubSubManager(XMPPConnection xMPPConnection, a aVar) {
super(xMPPConnection);
this.nodeMap = new ConcurrentHashMap();
this.pubSubService = aVar;
}
public static org.jivesoftware.smackx.pubsub.PubSubManager getInstance(org.jivesoftware.smack.XMPPConnection r4) {
throw new UnsupportedOperationException("Method not decompiled: org.jivesoftware.smackx.pubsub.PubSubManager.getInstance(org.jivesoftware.smack.XMPPConnection):org.jivesoftware.smackx.pubsub.PubSubManager");
}
public static b getPubSubService(XMPPConnection xMPPConnection) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return ServiceDiscoveryManager.getInstanceFor(xMPPConnection).findService("http://jabber.org/protocol/pubsub", true, "pubsub", "service");
}
private PubSub sendPubsubPacket(IQ.Type type, ExtensionElement extensionElement, PubSubNamespace pubSubNamespace) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return sendPubsubPacket(this.pubSubService, type, Collections.singletonList(extensionElement), pubSubNamespace);
}
public boolean canCreateNodesAndPublishItems() throws SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException {
try {
LeafNode createNode = createNode();
if (createNode == null) {
return true;
}
deleteNode(createNode.getId());
return true;
} catch (XMPPException.XMPPErrorException e) {
if (e.getXMPPError().getCondition() == XMPPError.Condition.forbidden) {
return false;
}
throw e;
}
}
public LeafNode createNode() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
LeafNode leafNode = new LeafNode(this, ((NodeExtension) sendPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.CREATE), null).getExtension("create", PubSubNamespace.BASIC.getXmlns())).getNode());
this.nodeMap.put(leafNode.getId(), leafNode);
return leafNode;
}
public void deleteNode(String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
IQ.Type type = IQ.Type.set;
PubSubElementType pubSubElementType = PubSubElementType.DELETE;
sendPubsubPacket(type, new NodeExtension(pubSubElementType, str), pubSubElementType.getNamespace());
this.nodeMap.remove(str);
}
public DiscoverItems discoverNodes(String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
DiscoverItems discoverItems = new DiscoverItems();
if (str != null) {
discoverItems.setNode(str);
}
discoverItems.setTo(this.pubSubService);
return (DiscoverItems) connection().createStanzaCollectorAndSend(discoverItems).nextResultOrThrow();
}
public List<Affiliation> getAffiliations() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
IQ.Type type = IQ.Type.get;
PubSubElementType pubSubElementType = PubSubElementType.AFFILIATIONS;
return ((AffiliationsExtension) sendPubsubPacket(type, new NodeExtension(pubSubElementType), null).getExtension(pubSubElementType)).getAffiliations();
}
XMPPConnection getConnection() {
return connection();
}
public ConfigureForm getDefaultConfiguration() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
IQ.Type type = IQ.Type.get;
PubSubElementType pubSubElementType = PubSubElementType.DEFAULT;
return NodeUtils.getFormFromPacket(sendPubsubPacket(type, new NodeExtension(pubSubElementType), pubSubElementType.getNamespace()), pubSubElementType);
}
public <T extends Node> T getNode(String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
T t = (T) this.nodeMap.get(str);
if (t == null) {
DiscoverInfo discoverInfo = new DiscoverInfo();
discoverInfo.setTo(this.pubSubService);
discoverInfo.setNode(str);
DiscoverInfo discoverInfo2 = (DiscoverInfo) connection().createStanzaCollectorAndSend(discoverInfo).nextResultOrThrow();
if (discoverInfo2.hasIdentity("pubsub", "leaf")) {
t = new LeafNode(this, str);
} else {
if (!discoverInfo2.hasIdentity("pubsub", "collection")) {
throw new AssertionError("PubSub service '" + ((Object) this.pubSubService) + "' returned disco info result for node '" + str + "', but it did not contain an Identity of type 'leaf' or 'collection' (and category 'pubsub'), which is not allowed according to XEP-60 5.3.");
}
t = new CollectionNode(this, str);
}
this.nodeMap.put(str, t);
}
return t;
}
public a getServiceJid() {
return this.pubSubService;
}
public List<Subscription> getSubscriptions() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
IQ.Type type = IQ.Type.get;
PubSubElementType pubSubElementType = PubSubElementType.SUBSCRIPTIONS;
return ((SubscriptionsExtension) sendPubsubPacket(type, new NodeExtension(pubSubElementType), null).getExtension(pubSubElementType.getElementName(), pubSubElementType.getNamespace().getXmlns())).getSubscriptions();
}
public DiscoverInfo getSupportedFeatures() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return ServiceDiscoveryManager.getInstanceFor(connection()).discoverInfo(this.pubSubService);
}
PubSub sendPubsubPacket(i iVar, IQ.Type type, List<ExtensionElement> list, PubSubNamespace pubSubNamespace) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
PubSub pubSub = new PubSub(iVar, type, pubSubNamespace);
Iterator<ExtensionElement> it = list.iterator();
while (it.hasNext()) {
pubSub.addExtension(it.next());
}
return sendPubsubPacket(pubSub);
}
public LeafNode createNode(String str) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
return (LeafNode) createNode(str, null);
}
public org.jivesoftware.smackx.pubsub.Node createNode(java.lang.String r5, org.jivesoftware.smackx.xdata.Form r6) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException {
throw new UnsupportedOperationException("Method not decompiled: org.jivesoftware.smackx.pubsub.PubSubManager.createNode(java.lang.String, org.jivesoftware.smackx.xdata.Form):org.jivesoftware.smackx.pubsub.Node");
}
PubSub sendPubsubPacket(PubSub pubSub) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
IQ iq = (IQ) connection().createStanzaCollectorAndSend(pubSub).nextResultOrThrow();
if (iq instanceof EmptyResultIQ) {
return null;
}
return (PubSub) iq;
}
public static synchronized PubSubManager getInstance(XMPPConnection xMPPConnection, a aVar) {
PubSubManager pubSubManager;
synchronized (PubSubManager.class) {
try {
Map<XMPPConnection, Map<a, PubSubManager>> map = INSTANCES;
Map<a, PubSubManager> map2 = map.get(xMPPConnection);
if (map2 == null) {
map2 = new HashMap<>();
map.put(xMPPConnection, map2);
}
pubSubManager = map2.get(aVar);
if (pubSubManager == null) {
pubSubManager = new PubSubManager(xMPPConnection, aVar);
map2.put(aVar, pubSubManager);
}
} catch (Throwable th) {
throw th;
}
}
return pubSubManager;
}
}