1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-18 08:51:08 +01:00

Use Jid (and subclasses) from jxmpp-jid

Fixes SMACK-634
This commit is contained in:
Florian Schmaus 2015-02-14 17:15:02 +01:00
parent 0ee2d9ed1e
commit 5bb4727c57
180 changed files with 1510 additions and 1032 deletions

View file

@ -43,12 +43,13 @@ import org.jivesoftware.smackx.pubsub.util.NodeUtils;
import org.jivesoftware.smackx.shim.packet.Header;
import org.jivesoftware.smackx.shim.packet.HeadersExtension;
import org.jivesoftware.smackx.xdata.Form;
import org.jxmpp.jid.Jid;
abstract public class Node
{
protected XMPPConnection con;
protected String id;
protected String to;
protected Jid to;
protected ConcurrentHashMap<ItemEventListener<Item>, PacketListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, PacketListener>();
protected ConcurrentHashMap<ItemDeleteListener, PacketListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, PacketListener>();
@ -73,7 +74,7 @@ abstract public class Node
*
* For example, OpenFire requires the server to be prefixed by <b>pubsub</b>
*/
void setTo(String toAddress)
void setTo(Jid toAddress)
{
to = toAddress;
}

View file

@ -38,6 +38,10 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
import org.jivesoftware.smackx.pubsub.util.NodeUtils;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jxmpp.jid.DomainBareJid;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;
/**
* This is the starting point for access to the pubsub service. It
@ -51,7 +55,7 @@ import org.jivesoftware.smackx.xdata.FormField;
final public class PubSubManager
{
private XMPPConnection con;
private String to;
private DomainBareJid to;
private Map<String, Node> nodeMap = new ConcurrentHashMap<String, Node>();
/**
@ -59,11 +63,12 @@ final public class PubSubManager
* name to <i>pubsub</i>
*
* @param connection The XMPP connection
* @throws XmppStringprepException
*/
public PubSubManager(XMPPConnection connection)
public PubSubManager(XMPPConnection connection) throws XmppStringprepException
{
con = connection;
to = "pubsub." + connection.getServiceName();
to = JidCreate.domainBareFrom("pubsub." + connection.getServiceName());
}
/**
@ -73,7 +78,7 @@ final public class PubSubManager
* @param connection The XMPP connection
* @param toAddress The pubsub specific to address (required for some servers)
*/
public PubSubManager(XMPPConnection connection, String toAddress)
public PubSubManager(XMPPConnection connection, DomainBareJid toAddress)
{
con = connection;
to = toAddress;
@ -314,7 +319,7 @@ final public class PubSubManager
return sendPubsubPacket(con, to, type, Collections.singletonList(ext), ns);
}
static PubSub sendPubsubPacket(XMPPConnection con, String to, Type type, List<PacketExtension> extList, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
static PubSub sendPubsubPacket(XMPPConnection con, Jid to, Type type, List<PacketExtension> extList, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
PubSub pubSub = new PubSub(to, type, ns);
for (PacketExtension pe : extList) {

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.pubsub.packet;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.pubsub.PubSubElementType;
import org.jxmpp.jid.Jid;
/**
* The standard PubSub extension of an {@link IQ} packet. This is the topmost
@ -40,7 +41,7 @@ public class PubSub extends IQ
super(ELEMENT, ns.getXmlns());
}
public PubSub(String to, Type type, PubSubNamespace ns) {
public PubSub(Jid to, Type type, PubSubNamespace ns) {
super(ELEMENT, (ns == null ? PubSubNamespace.BASIC : ns).getXmlns());
setTo(to);
setType(type);
@ -86,7 +87,7 @@ public class PubSub extends IQ
return xml;
}
public static PubSub createPubsubPacket(String to, Type type, PacketExtension extension, PubSubNamespace ns) {
public static PubSub createPubsubPacket(Jid to, Type type, PacketExtension extension, PubSubNamespace ns) {
PubSub pubSub = new PubSub(to, type, ns);
pubSub.addExtension(extension);
return pubSub;