mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 01:29:38 +02:00
Merge branch '4.1'
Conflicts: smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java smack-core/src/main/java/org/jivesoftware/smack/debugger/SmackDebugger.java smack-core/src/main/java/org/jivesoftware/smack/packet/Packet.java smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/VCardManager.java smack-extensions/src/test/java/org/jivesoftware/smackx/receipts/DeliveryReceiptTest.java smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java version.gradle
This commit is contained in:
commit
701aa7d9c4
298 changed files with 2402 additions and 1562 deletions
|
@ -61,7 +61,7 @@ public class CompressionTest extends SmackTestCase {
|
|||
// Create a packet collector to listen for a response.
|
||||
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(version.getStanzaId()));
|
||||
|
||||
connection.sendPacket(version);
|
||||
connection.sendStanza(version);
|
||||
|
||||
// Wait up to 5 seconds for a result.
|
||||
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
|
|
|
@ -123,7 +123,7 @@ public class FormTest extends SmackTestCase {
|
|||
// Add the completed form to the message
|
||||
msg2.addExtension(completedForm.getDataFormToSend());
|
||||
// Send the message with the completed form
|
||||
getConnection(1).sendPacket(msg2);
|
||||
getConnection(1).sendStanza(msg2);
|
||||
|
||||
// Get the message with the completed form
|
||||
Message msg3 = (Message) collector.nextResult(2000);
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.jivesoftware.smack.*;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.SmackTestCase;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -46,7 +46,7 @@ public class GroupChatInvitationTest extends SmackTestCase {
|
|||
Message message = new Message(getBareJID(1));
|
||||
message.setBody("Group chat invitation!");
|
||||
message.addExtension(invitation);
|
||||
getConnection(0).sendPacket(message);
|
||||
getConnection(0).sendStanza(message);
|
||||
|
||||
Thread.sleep(250);
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class GroupChatInvitationTest extends SmackTestCase {
|
|||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// Register listener for groupchat invitations.
|
||||
PacketFilter filter = new PacketExtensionFilter("x", "jabber:x:conference");
|
||||
PacketFilter filter = new StanzaExtensionFilter("x", "jabber:x:conference");
|
||||
collector = getConnection(1).createPacketCollector(filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public class LastActivityManagerTest extends SmackTestCase {
|
|||
|
||||
// Send a message as the last activity action from connection 1 to
|
||||
// connection 0
|
||||
conn1.sendPacket(new Message(getBareJID(0)));
|
||||
conn1.sendStanza(new Message(getBareJID(0)));
|
||||
|
||||
// Wait 1 seconds to have some idle time
|
||||
try {
|
||||
|
@ -70,7 +70,7 @@ public class LastActivityManagerTest extends SmackTestCase {
|
|||
|
||||
// Send a message as the last activity action from connection 2 to
|
||||
// connection 0
|
||||
conn2.sendPacket(new Message(getBareJID(0)));
|
||||
conn2.sendStanza(new Message(getBareJID(0)));
|
||||
|
||||
// Wait 1 seconds to have some idle time
|
||||
try {
|
||||
|
|
|
@ -55,7 +55,7 @@ public class OfflineMessageManagerTest extends SmackTestCase {
|
|||
*/
|
||||
public void testReadAndDelete() {
|
||||
// Make user2 unavailable
|
||||
getConnection(1).sendPacket(new Presence(Presence.Type.unavailable));
|
||||
getConnection(1).sendStanza(new Presence(Presence.Type.unavailable));
|
||||
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
|
@ -100,7 +100,7 @@ public class OfflineMessageManagerTest extends SmackTestCase {
|
|||
// User2 becomes available again
|
||||
PacketCollector collector = getConnection(1).createPacketCollector(
|
||||
new MessageTypeFilter(Message.Type.chat));
|
||||
getConnection(1).sendPacket(new Presence(Presence.Type.available));
|
||||
getConnection(1).sendStanza(new Presence(Presence.Type.available));
|
||||
|
||||
// Check that no offline messages was sent to the user
|
||||
Message message = (Message) collector.nextResult(2500);
|
||||
|
@ -124,7 +124,7 @@ public class OfflineMessageManagerTest extends SmackTestCase {
|
|||
*/
|
||||
public void testFetchAndPurge() {
|
||||
// Make user2 unavailable
|
||||
getConnection(1).sendPacket(new Presence(Presence.Type.unavailable));
|
||||
getConnection(1).sendStanza(new Presence(Presence.Type.unavailable));
|
||||
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
|
@ -158,7 +158,7 @@ public class OfflineMessageManagerTest extends SmackTestCase {
|
|||
// User2 becomes available again
|
||||
PacketCollector collector = getConnection(1).createPacketCollector(
|
||||
new MessageTypeFilter(Message.Type.chat));
|
||||
getConnection(1).sendPacket(new Presence(Presence.Type.available));
|
||||
getConnection(1).sendStanza(new Presence(Presence.Type.available));
|
||||
|
||||
// Check that no offline messages was sent to the user
|
||||
Message message = (Message) collector.nextResult(2500);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class VersionTest extends SmackTestCase {
|
|||
// Create a packet collector to listen for a response.
|
||||
PacketCollector collector = getConnection(0).createPacketCollector(new PacketIDFilter(version.getStanzaId()));
|
||||
|
||||
getConnection(0).sendPacket(version);
|
||||
getConnection(0).sendStanza(version);
|
||||
|
||||
// Wait up to 5 seconds for a result.
|
||||
IQ result = (IQ)collector.nextResult(5000);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class InBandBytestreamTest extends SmackTestCase {
|
|||
|
||||
PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
|
||||
open.getStanzaId()));
|
||||
initiatorConnection.sendPacket(open);
|
||||
initiatorConnection.sendStanza(open);
|
||||
Packet result = collector.nextResult();
|
||||
|
||||
assertNotNull(result.getError());
|
||||
|
|
|
@ -84,7 +84,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
|||
|
||||
PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
|
||||
bytestreamInitiation.getStanzaId()));
|
||||
initiatorConnection.sendPacket(bytestreamInitiation);
|
||||
initiatorConnection.sendStanza(bytestreamInitiation);
|
||||
Packet result = collector.nextResult();
|
||||
|
||||
assertNotNull(result.getError());
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.jivesoftware.smack.SmackConfiguration;
|
|||
import org.jivesoftware.smack.TCPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.filter.IQTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
@ -90,7 +90,7 @@ public class EntityCapsTest extends SmackTestCase {
|
|||
discoInfoSend = true;
|
||||
}
|
||||
|
||||
}, new AndFilter(new PacketTypeFilter(DiscoverInfo.class), new IQTypeFilter(IQ.Type.get)));
|
||||
}, new AndFilter(new StanzaTypeFilter(DiscoverInfo.class), new IQTypeFilter(IQ.Type.get)));
|
||||
|
||||
// add a bogus feature so that con1 ver won't match con0's
|
||||
sdm1.addFeature(DISCOVER_TEST_FEATURE);
|
||||
|
|
|
@ -83,7 +83,7 @@ public class MessageEventTest extends SmackTestCase {
|
|||
|
||||
// Create a Listener that listens for Messages with the extension "jabber:x:roster"
|
||||
// This listener will listen on the conn2 and answer an ACK if everything is ok
|
||||
PacketFilter packetFilter = new PacketExtensionFilter("x", "jabber:x:event");
|
||||
PacketFilter packetFilter = new StanzaExtensionFilter("x", "jabber:x:event");
|
||||
PacketListener packetListener = new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
Message message = (Message) packet;
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Iterator;
|
|||
import org.jivesoftware.smack.Chat;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.ThreadFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -143,7 +143,7 @@ public class XHTMLExtensionTest extends SmackTestCase {
|
|||
//"http://jabber.org/protocol/xhtml-im"
|
||||
// This listener will listen on the conn2 and answer an ACK if everything is ok
|
||||
PacketFilter packetFilter =
|
||||
new PacketExtensionFilter("html", "http://jabber.org/protocol/xhtml-im");
|
||||
new StanzaExtensionFilter("html", "http://jabber.org/protocol/xhtml-im");
|
||||
PacketListener packetListener = new PacketListener() {
|
||||
@Override
|
||||
public void processPacket(Packet packet) {
|
||||
|
|
|
@ -107,7 +107,7 @@ public class MultipleRecipientManager {
|
|||
&& StringUtils.isNullOrEmpty(replyTo) && StringUtils.isNullOrEmpty(replyRoom)) {
|
||||
Jid toJid = to.iterator().next();
|
||||
packet.setTo(toJid);
|
||||
connection.sendPacket(packet);
|
||||
connection.sendStanza(packet);
|
||||
return;
|
||||
}
|
||||
DomainBareJid serviceAddress = getMultipleRecipienServiceAddress(connection);
|
||||
|
@ -161,7 +161,7 @@ public class MultipleRecipientManager {
|
|||
if (replyAddress != null && replyAddress.getJid() != null) {
|
||||
// Send reply to the reply_to address
|
||||
reply.setTo(replyAddress.getJid());
|
||||
connection.sendPacket(reply);
|
||||
connection.sendStanza(reply);
|
||||
}
|
||||
else {
|
||||
// Send reply to multiple recipients
|
||||
|
@ -209,19 +209,19 @@ public class MultipleRecipientManager {
|
|||
if (to != null) {
|
||||
for (Jid jid : to) {
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (cc != null) {
|
||||
for (Jid jid : cc) {
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (bcc != null) {
|
||||
for (Jid jid : bcc) {
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public class MultipleRecipientManager {
|
|||
// Add extension to packet
|
||||
packet.addExtension(multipleAddresses);
|
||||
// Send the packet
|
||||
connection.sendPacket(packet);
|
||||
connection.sendStanza(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.jivesoftware.smackx.address.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MultipleAddresses implements PacketExtension {
|
||||
public class MultipleAddresses implements ExtensionElement {
|
||||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/address";
|
||||
public static final String ELEMENT = "addresses";
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.address.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
|
||||
import org.jivesoftware.smackx.address.packet.MultipleAddresses.Type;
|
||||
|
@ -32,7 +32,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MultipleAddressesProvider extends PacketExtensionProvider<MultipleAddresses> {
|
||||
public class MultipleAddressesProvider extends ExtensionElementProvider<MultipleAddresses> {
|
||||
|
||||
@Override
|
||||
public MultipleAddresses parse(XmlPullParser parser,
|
||||
|
|
|
@ -20,12 +20,12 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.amp.AMPDeliverCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPExpireAtCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPMatchResourceCondition;
|
||||
|
||||
public class AMPExtension implements PacketExtension {
|
||||
public class AMPExtension implements ExtensionElement {
|
||||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/amp";
|
||||
public static final String ELEMENT = "amp";
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.amp.provider;
|
|||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.amp.AMPDeliverCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPExpireAtCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPMatchResourceCondition;
|
||||
|
@ -28,7 +28,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
||||
public class AMPExtensionProvider extends PacketExtensionProvider<AMPExtension> {
|
||||
public class AMPExtensionProvider extends ExtensionElementProvider<AMPExtension> {
|
||||
private static final Logger LOGGER = Logger.getLogger(AMPExtensionProvider.class.getName());
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.attention.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* @see <a
|
||||
* href="http://xmpp.org/extensions/xep-0224.html">XEP-0224: Attention</a>
|
||||
*/
|
||||
public class AttentionExtension implements PacketExtension {
|
||||
public class AttentionExtension implements ExtensionElement {
|
||||
|
||||
/**
|
||||
* The XML element name of an 'attention' extension.
|
||||
|
@ -73,14 +73,14 @@ public class AttentionExtension implements PacketExtension {
|
|||
}
|
||||
|
||||
/**
|
||||
* A {@link PacketExtensionProvider} for the {@link AttentionExtension}. As
|
||||
* A {@link ExtensionElementProvider} for the {@link AttentionExtension}. As
|
||||
* Attention elements have no state/information other than the element name
|
||||
* and namespace, this implementation simply returns new instances of
|
||||
* {@link AttentionExtension}.
|
||||
*
|
||||
* @author Guus der Kinderen, guus.der.kinderen@gmail.com
|
||||
s */
|
||||
public static class Provider extends PacketExtensionProvider<AttentionExtension> {
|
||||
public static class Provider extends ExtensionElementProvider<AttentionExtension> {
|
||||
|
||||
@Override
|
||||
public AttentionExtension parse(XmlPullParser parser, int initialDepth) {
|
||||
|
|
|
@ -16,13 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||
|
||||
/**
|
||||
* DataListener handles all In-Band Bytestream IQ stanzas containing a data
|
||||
|
@ -38,40 +36,38 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
class DataListener implements PacketListener {
|
||||
class DataListener extends AbstractIqRequestHandler {
|
||||
|
||||
/* manager containing the listeners and the XMPP connection */
|
||||
private final InBandBytestreamManager manager;
|
||||
|
||||
/* packet filter for all In-Band Bytestream data packets */
|
||||
private final PacketFilter dataFilter = new AndFilter(
|
||||
new PacketTypeFilter(Data.class));
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param manager the In-Band Bytestream manager
|
||||
*/
|
||||
public DataListener(InBandBytestreamManager manager) {
|
||||
super(DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE, IQ.Type.set, Mode.async);
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
public void processPacket(Stanza packet) throws NotConnectedException, InterruptedException {
|
||||
Data data = (Data) packet;
|
||||
@Override
|
||||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
Data data = (Data) iqRequest;
|
||||
InBandBytestreamSession ibbSession = this.manager.getSessions().get(
|
||||
data.getDataPacketExtension().getSessionID());
|
||||
if (ibbSession == null) {
|
||||
this.manager.replyItemNotFoundPacket(data);
|
||||
try {
|
||||
if (ibbSession == null) {
|
||||
this.manager.replyItemNotFoundPacket(data);
|
||||
}
|
||||
else {
|
||||
ibbSession.processIQPacket(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the packet filter for In-Band Bytestream data packets.
|
||||
*
|
||||
* @return the packet filter for In-Band Bytestream data packets
|
||||
*/
|
||||
protected PacketFilter getFilter() {
|
||||
return this.dataFilter;
|
||||
catch (NotConnectedException|InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,11 +25,11 @@ import java.util.Random;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jivesoftware.smack.AbstractConnectionClosedListener;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
|
@ -215,7 +215,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
|
||||
// register bytestream data packet listener
|
||||
this.dataListener = new DataListener(this);
|
||||
this.connection.addSyncPacketListener(this.dataListener, this.dataListener.getFilter());
|
||||
connection.registerIQRequestHandler(dataListener);
|
||||
|
||||
// register bytestream close packet listener
|
||||
this.closeListener = new CloseListener(this);
|
||||
|
@ -446,7 +446,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
protected void replyRejectPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
|
||||
IQ error = IQ.createErrorResponse(request, xmppError);
|
||||
this.connection.sendPacket(error);
|
||||
this.connection.sendStanza(error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -460,7 +460,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint);
|
||||
IQ error = IQ.createErrorResponse(request, xmppError);
|
||||
this.connection.sendPacket(error);
|
||||
this.connection.sendStanza(error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -474,7 +474,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found);
|
||||
IQ error = IQ.createErrorResponse(request, xmppError);
|
||||
this.connection.sendPacket(error);
|
||||
this.connection.sendStanza(error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -548,7 +548,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
|
||||
// remove all listeners registered by this manager
|
||||
connection.unregisterIQRequestHandler(initiationListener);
|
||||
this.connection.removeSyncPacketListener(this.dataListener);
|
||||
connection.unregisterIQRequestHandler(dataListener);
|
||||
connection.unregisterIQRequestHandler(closeListener);
|
||||
|
||||
// shutdown threads
|
||||
|
|
|
@ -81,7 +81,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
|||
|
||||
// acknowledge request
|
||||
IQ resultIQ = IQ.createResultIQ(this.byteStreamRequest);
|
||||
connection.sendPacket(resultIQ);
|
||||
connection.sendStanza(resultIQ);
|
||||
|
||||
return ibbSession;
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -175,7 +175,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
|
||||
// acknowledge close request
|
||||
IQ confirmClose = IQ.createResultIQ(closeRequest);
|
||||
this.connection.sendPacket(confirmClose);
|
||||
this.connection.sendStanza(confirmClose);
|
||||
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
private abstract class IBBInputStream extends InputStream {
|
||||
|
||||
/* the data packet listener to fill the data queue */
|
||||
private final PacketListener dataPacketListener;
|
||||
private final StanzaListener dataPacketListener;
|
||||
|
||||
/* queue containing received In-Band Bytestream data packets */
|
||||
protected final BlockingQueue<DataPacketExtension> dataQueue = new LinkedBlockingQueue<DataPacketExtension>();
|
||||
|
@ -266,7 +266,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
public IBBInputStream() {
|
||||
// add data packet listener to connection
|
||||
this.dataPacketListener = getDataPacketListener();
|
||||
connection.addSyncPacketListener(this.dataPacketListener, getDataPacketFilter());
|
||||
connection.addSyncStanzaListener(this.dataPacketListener, getDataPacketFilter());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -274,14 +274,14 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*
|
||||
* @return the data packet listener
|
||||
*/
|
||||
protected abstract PacketListener getDataPacketListener();
|
||||
protected abstract StanzaListener getDataPacketListener();
|
||||
|
||||
/**
|
||||
* Returns the packet filter that accepts In-Band Bytestream data packets.
|
||||
*
|
||||
* @return the data packet filter
|
||||
*/
|
||||
protected abstract PacketFilter getDataPacketFilter();
|
||||
protected abstract StanzaFilter getDataPacketFilter();
|
||||
|
||||
public synchronized int read() throws IOException {
|
||||
checkClosed();
|
||||
|
@ -433,7 +433,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* Invoked if the session is closed.
|
||||
*/
|
||||
private void cleanup() {
|
||||
connection.removeSyncPacketListener(this.dataPacketListener);
|
||||
connection.removeSyncStanzaListener(this.dataPacketListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -444,8 +444,8 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*/
|
||||
private class IQIBBInputStream extends IBBInputStream {
|
||||
|
||||
protected PacketListener getDataPacketListener() {
|
||||
return new PacketListener() {
|
||||
protected StanzaListener getDataPacketListener() {
|
||||
return new StanzaListener() {
|
||||
|
||||
private long lastSequence = -1;
|
||||
|
||||
|
@ -459,7 +459,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
if (data.getSeq() <= this.lastSequence) {
|
||||
IQ unexpectedRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
|
||||
XMPPError.Condition.unexpected_request));
|
||||
connection.sendPacket(unexpectedRequest);
|
||||
connection.sendStanza(unexpectedRequest);
|
||||
return;
|
||||
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
// data is invalid; respond with bad-request error
|
||||
IQ badRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
|
||||
XMPPError.Condition.bad_request));
|
||||
connection.sendPacket(badRequest);
|
||||
connection.sendStanza(badRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
|
||||
// confirm IQ
|
||||
IQ confirmData = IQ.createResultIQ((IQ) packet);
|
||||
connection.sendPacket(confirmData);
|
||||
connection.sendStanza(confirmData);
|
||||
|
||||
// set last seen sequence
|
||||
this.lastSequence = data.getSeq();
|
||||
|
@ -491,12 +491,12 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
};
|
||||
}
|
||||
|
||||
protected PacketFilter getDataPacketFilter() {
|
||||
protected StanzaFilter getDataPacketFilter() {
|
||||
/*
|
||||
* filter all IQ stanzas having type 'SET' (represented by Data class), containing a
|
||||
* data packet extension, matching session ID and recipient
|
||||
*/
|
||||
return new AndFilter(new PacketTypeFilter(Data.class), new IBBDataPacketFilter());
|
||||
return new AndFilter(new StanzaTypeFilter(Data.class), new IBBDataPacketFilter());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -507,8 +507,8 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*/
|
||||
private class MessageIBBInputStream extends IBBInputStream {
|
||||
|
||||
protected PacketListener getDataPacketListener() {
|
||||
return new PacketListener() {
|
||||
protected StanzaListener getDataPacketListener() {
|
||||
return new StanzaListener() {
|
||||
|
||||
public void processPacket(Stanza packet) {
|
||||
// get data packet extension
|
||||
|
@ -538,12 +538,12 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected PacketFilter getDataPacketFilter() {
|
||||
protected StanzaFilter getDataPacketFilter() {
|
||||
/*
|
||||
* filter all message stanzas containing a data packet extension, matching session ID
|
||||
* and recipient
|
||||
*/
|
||||
return new AndFilter(new PacketTypeFilter(Message.class), new IBBDataPacketFilter());
|
||||
return new AndFilter(new StanzaTypeFilter(Message.class), new IBBDataPacketFilter());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* containing an In-Band Bytestream data packet extension whose session ID matches this sessions
|
||||
* ID.
|
||||
*/
|
||||
private class IBBDataPacketFilter implements PacketFilter {
|
||||
private class IBBDataPacketFilter implements StanzaFilter {
|
||||
|
||||
public boolean accept(Stanza packet) {
|
||||
// sender equals remote peer
|
||||
|
@ -811,10 +811,19 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
Message message = new Message(remoteJID);
|
||||
message.addExtension(data);
|
||||
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void processIQPacket(Data data) throws NotConnectedException, InterruptedException {
|
||||
inputStream.dataPacketListener.processPacket(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.jivesoftware.smackx.filetransfer.StreamNegotiator;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -86,6 +87,8 @@ class InitiationListener extends AbstractIqRequestHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
StreamNegotiator.signal(ibbRequest.getFrom().toString() + '\t' + ibbRequest.getSessionID(), ibbRequest);
|
||||
|
||||
// ignore request if in ignore list
|
||||
if (this.manager.getIgnoredBytestreamRequests().remove(ibbRequest.getSessionID()))
|
||||
return;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ.IQChildElementXmlStringBuilder;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.util.stringencoder.Base64;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class DataPacketExtension implements PacketExtension {
|
||||
public class DataPacketExtension implements ExtensionElement {
|
||||
|
||||
/**
|
||||
* The element name of the data packet extension.
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DataPacketProvider {
|
|||
}
|
||||
}
|
||||
|
||||
public static class PacketExtensionProvider extends org.jivesoftware.smack.provider.PacketExtensionProvider<DataPacketExtension> {
|
||||
public static class PacketExtensionProvider extends org.jivesoftware.smack.provider.ExtensionElementProvider<DataPacketExtension> {
|
||||
|
||||
@Override
|
||||
public DataPacketExtension parse(XmlPullParser parser,
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||
import org.jivesoftware.smackx.filetransfer.StreamNegotiator;
|
||||
|
||||
/**
|
||||
* InitiationListener handles all incoming SOCKS5 Bytestream initiation requests. If there are no
|
||||
|
@ -77,6 +78,8 @@ final class InitiationListener extends AbstractIqRequestHandler {
|
|||
private void processRequest(Stanza packet) throws NotConnectedException, InterruptedException {
|
||||
Bytestream byteStreamRequest = (Bytestream) packet;
|
||||
|
||||
StreamNegotiator.signal(byteStreamRequest.getFrom().toString() + '\t' + byteStreamRequest.getSessionID(), byteStreamRequest);
|
||||
|
||||
// ignore request if in ignore list
|
||||
if (this.manager.getIgnoredBytestreamRequests().remove(byteStreamRequest.getSessionID())) {
|
||||
return;
|
||||
|
|
|
@ -710,7 +710,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
protected void replyRejectPacket(IQ packet) throws NotConnectedException, InterruptedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
|
||||
IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
|
||||
this.connection.sendPacket(errorIQ);
|
||||
this.connection.sendStanza(errorIQ);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -258,7 +258,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
|
||||
// send used-host confirmation
|
||||
Bytestream response = createUsedHostResponse(selectedHost);
|
||||
this.manager.getConnection().sendPacket(response);
|
||||
this.manager.getConnection().sendStanza(response);
|
||||
|
||||
return new Socks5BytestreamSession(socket, selectedHost.getJID().equals(
|
||||
this.bytestreamRequest.getFrom()));
|
||||
|
@ -285,7 +285,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
String errorMessage = "Could not establish socket with any provided host";
|
||||
XMPPError error = XMPPError.from(XMPPError.Condition.item_not_found, errorMessage);
|
||||
IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);
|
||||
this.manager.getConnection().sendPacket(errorIQ);
|
||||
this.manager.getConnection().sendStanza(errorIQ);
|
||||
throw new XMPPErrorException(errorMessage, error);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,18 +22,18 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache;
|
||||
|
@ -92,11 +92,11 @@ public class EntityCapsManager extends Manager {
|
|||
|
||||
private static Map<XMPPConnection, EntityCapsManager> instances = new WeakHashMap<>();
|
||||
|
||||
private static final PacketFilter PRESENCES_WITH_CAPS = new AndFilter(new PacketTypeFilter(Presence.class), new PacketExtensionFilter(
|
||||
private static final StanzaFilter PRESENCES_WITH_CAPS = new AndFilter(new StanzaTypeFilter(Presence.class), new StanzaExtensionFilter(
|
||||
ELEMENT, NAMESPACE));
|
||||
private static final PacketFilter PRESENCES_WITHOUT_CAPS = new AndFilter(new PacketTypeFilter(Presence.class), new NotFilter(new PacketExtensionFilter(
|
||||
private static final StanzaFilter PRESENCES_WITHOUT_CAPS = new AndFilter(new StanzaTypeFilter(Presence.class), new NotFilter(new StanzaExtensionFilter(
|
||||
ELEMENT, NAMESPACE)));
|
||||
private static final PacketFilter PRESENCES = PacketTypeFilter.PRESENCE;
|
||||
private static final StanzaFilter PRESENCES = StanzaTypeFilter.PRESENCE;
|
||||
|
||||
/**
|
||||
* Map of "node + '#' + hash" to DiscoverInfo data
|
||||
|
@ -313,7 +313,7 @@ public class EntityCapsManager extends Manager {
|
|||
if (autoEnableEntityCaps)
|
||||
enableEntityCaps();
|
||||
|
||||
connection.addAsyncPacketListener(new PacketListener() {
|
||||
connection.addAsyncStanzaListener(new StanzaListener() {
|
||||
// Listen for remote presence stanzas with the caps extension
|
||||
// If we receive such a stanza, record the JID and nodeVer
|
||||
@Override
|
||||
|
@ -328,7 +328,7 @@ public class EntityCapsManager extends Manager {
|
|||
|
||||
}, PRESENCES_WITH_CAPS);
|
||||
|
||||
connection.addAsyncPacketListener(new PacketListener() {
|
||||
connection.addAsyncStanzaListener(new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) {
|
||||
// always remove the JID from the map, even if entityCaps are
|
||||
|
@ -338,7 +338,7 @@ public class EntityCapsManager extends Manager {
|
|||
}
|
||||
}, PRESENCES_WITHOUT_CAPS);
|
||||
|
||||
connection.addPacketSendingListener(new PacketListener() {
|
||||
connection.addPacketSendingListener(new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) {
|
||||
presenceSend = true;
|
||||
|
@ -348,7 +348,7 @@ public class EntityCapsManager extends Manager {
|
|||
// Intercept presence packages and add caps data when intended.
|
||||
// XEP-0115 specifies that a client SHOULD include entity capabilities
|
||||
// with every presence notification it sends.
|
||||
PacketListener packetInterceptor = new PacketListener() {
|
||||
StanzaListener packetInterceptor = new StanzaListener() {
|
||||
public void processPacket(Stanza packet) {
|
||||
if (!entityCapsEnabled)
|
||||
return;
|
||||
|
@ -486,7 +486,7 @@ public class EntityCapsManager extends Manager {
|
|||
final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
|
||||
sdm.setNodeInformationProvider(entityNode + '#' + currentCapsVersion, new AbstractNodeInformationProvider() {
|
||||
List<String> features = sdm.getFeatures();
|
||||
List<PacketExtension> packetExtensions = sdm.getExtendedInfoAsList();
|
||||
List<ExtensionElement> packetExtensions = sdm.getExtendedInfoAsList();
|
||||
@Override
|
||||
public List<String> getNodeFeatures() {
|
||||
return features;
|
||||
|
@ -496,7 +496,7 @@ public class EntityCapsManager extends Manager {
|
|||
return identities;
|
||||
}
|
||||
@Override
|
||||
public List<PacketExtension> getNodePacketExtensions() {
|
||||
public List<ExtensionElement> getNodePacketExtensions() {
|
||||
return packetExtensions;
|
||||
}
|
||||
});
|
||||
|
@ -509,7 +509,7 @@ public class EntityCapsManager extends Manager {
|
|||
if (connection != null && connection.isAuthenticated() && presenceSend) {
|
||||
Presence presence = new Presence(Presence.Type.available);
|
||||
try {
|
||||
connection.sendPacket(presence);
|
||||
connection.sendStanza(presence);
|
||||
}
|
||||
catch (InterruptedException | NotConnectedException e) {
|
||||
LOGGER.log(Level.WARNING, "Could could not update presence with caps info", e);
|
||||
|
@ -557,7 +557,7 @@ public class EntityCapsManager extends Manager {
|
|||
*/
|
||||
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
|
||||
List<FormField> foundFormTypes = new LinkedList<FormField>();
|
||||
for (PacketExtension pe : info.getExtensions()) {
|
||||
for (ExtensionElement pe : info.getExtensions()) {
|
||||
if (pe.getNamespace().equals(DataForm.NAMESPACE)) {
|
||||
DataForm df = (DataForm) pe;
|
||||
for (FormField f : df.getFields()) {
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
package org.jivesoftware.smackx.caps.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
/**
|
||||
* A XEP-0115 Entity Capabilities extension.
|
||||
*/
|
||||
public class CapsExtension implements PacketExtension {
|
||||
public class CapsExtension implements ExtensionElement {
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/caps";
|
||||
public static final String ELEMENT = "c";
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@ package org.jivesoftware.smackx.caps.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.caps.EntityCapsManager;
|
||||
import org.jivesoftware.smackx.caps.packet.CapsExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class CapsExtensionProvider extends PacketExtensionProvider<CapsExtension> {
|
||||
public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtension> {
|
||||
|
||||
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
|
|
|
@ -29,10 +29,10 @@ import org.jivesoftware.smack.chat.ChatManager;
|
|||
import org.jivesoftware.smack.chat.ChatManagerListener;
|
||||
import org.jivesoftware.smack.chat.ChatMessageListener;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class ChatStateManager extends Manager {
|
|||
private static final Map<XMPPConnection, ChatStateManager> INSTANCES =
|
||||
new WeakHashMap<XMPPConnection, ChatStateManager>();
|
||||
|
||||
private static final PacketFilter filter = new NotFilter(new PacketExtensionFilter(NAMESPACE));
|
||||
private static final StanzaFilter filter = new NotFilter(new StanzaExtensionFilter(NAMESPACE));
|
||||
|
||||
/**
|
||||
* Returns the ChatStateManager related to the XMPPConnection and it will create one if it does
|
||||
|
@ -96,7 +96,7 @@ public class ChatStateManager extends Manager {
|
|||
|
||||
/**
|
||||
* Sets the current state of the provided chat. This method will send an empty bodied Message
|
||||
* packet with the state attached as a {@link org.jivesoftware.smack.packet.PacketExtension}, if
|
||||
* packet with the state attached as a {@link org.jivesoftware.smack.packet.ExtensionElement}, if
|
||||
* and only if the new chat state is different than the last state.
|
||||
*
|
||||
* @param newState the new state of the chat
|
||||
|
@ -171,7 +171,7 @@ public class ChatStateManager extends Manager {
|
|||
}
|
||||
|
||||
public void processMessage(Chat chat, Message message) {
|
||||
PacketExtension extension = message.getExtension(NAMESPACE);
|
||||
ExtensionElement extension = message.getExtension(NAMESPACE);
|
||||
if (extension == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package org.jivesoftware.smackx.chatstates.packet;
|
||||
|
||||
import org.jivesoftware.smackx.chatstates.ChatState;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* @author Alexander Wenckus
|
||||
* @see org.jivesoftware.smackx.chatstates.ChatState
|
||||
*/
|
||||
public class ChatStateExtension implements PacketExtension {
|
||||
public class ChatStateExtension implements ExtensionElement {
|
||||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/chatstates";
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class ChatStateExtension implements PacketExtension {
|
|||
return xml;
|
||||
}
|
||||
|
||||
public static class Provider extends PacketExtensionProvider<ChatStateExtension> {
|
||||
public static class Provider extends ExtensionElementProvider<ChatStateExtension> {
|
||||
|
||||
@Override
|
||||
public ChatStateExtension parse(XmlPullParser parser, int initialDepth) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.jivesoftware.smackx.commands.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand.Action;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand.SpecificErrorCondition;
|
||||
|
@ -238,7 +238,7 @@ public class AdHocCommandData extends IQ {
|
|||
return sessionID;
|
||||
}
|
||||
|
||||
public static class SpecificError implements PacketExtension {
|
||||
public static class SpecificError implements ExtensionElement {
|
||||
|
||||
public static final String namespace = "http://jabber.org/protocol/commands";
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.IOException;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand.Action;
|
||||
|
@ -119,42 +119,42 @@ public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
|
|||
return adHocCommandData;
|
||||
}
|
||||
|
||||
public static class BadActionError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class BadActionError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badAction);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MalformedActionError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class MalformedActionError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.malformedAction);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BadLocaleError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class BadLocaleError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badLocale);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BadPayloadError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class BadPayloadError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badPayload);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BadSessionIDError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class BadSessionIDError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badSessionid);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SessionExpiredError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class SessionExpiredError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.sessionExpired);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.delay;
|
|||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +95,7 @@ public class DelayInformationManager {
|
|||
* @return true if the stanza got delayed.
|
||||
*/
|
||||
public static boolean isDelayedStanza(Stanza packet) {
|
||||
PacketExtension packetExtension = getDelayInformation(packet);
|
||||
ExtensionElement packetExtension = getDelayInformation(packet);
|
||||
return packetExtension != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,21 +17,21 @@
|
|||
package org.jivesoftware.smackx.delay.filter;
|
||||
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.delay.DelayInformationManager;
|
||||
|
||||
/**
|
||||
* Filters stanza with delay information, ie. stanzas that got delayed for some reason
|
||||
*/
|
||||
public class DelayedStanzaFilter implements PacketFilter {
|
||||
public class DelayedStanzaFilter implements StanzaFilter {
|
||||
|
||||
public static final PacketFilter INSTANCE = new DelayedStanzaFilter();
|
||||
public static final StanzaFilter INSTANCE = new DelayedStanzaFilter();
|
||||
|
||||
/**
|
||||
* Filters stanzas that got not delayed, ie. have no delayed information
|
||||
*/
|
||||
public static final PacketFilter NOT_DELAYED_STANZA = new NotFilter(INSTANCE);
|
||||
public static final StanzaFilter NOT_DELAYED_STANZA = new NotFilter(INSTANCE);
|
||||
|
||||
private DelayedStanzaFilter() {
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.delay.packet;
|
|||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import org.jxmpp.util.XmppDateTime;
|
|||
* @author Gaston Dombiak
|
||||
* @author Florian Schmaus
|
||||
*/
|
||||
public class DelayInformation implements PacketExtension {
|
||||
public class DelayInformation implements ExtensionElement {
|
||||
public static final String ELEMENT = "delay";
|
||||
public static final String NAMESPACE = "urn:xmpp:delay";
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ import java.text.ParseException;
|
|||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public abstract class AbstractDelayInformationProvider extends PacketExtensionProvider<DelayInformation> {
|
||||
public abstract class AbstractDelayInformationProvider extends ExtensionElementProvider<DelayInformation> {
|
||||
|
||||
@Override
|
||||
public final DelayInformation parse(XmlPullParser parser,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.disco;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
|
||||
|
@ -40,7 +40,7 @@ public abstract class AbstractNodeInformationProvider implements NodeInformation
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<PacketExtension> getNodePacketExtensions() {
|
||||
public List<ExtensionElement> getNodePacketExtensions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.disco;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
|
||||
|
@ -68,5 +68,5 @@ public interface NodeInformationProvider {
|
|||
*
|
||||
* @return a list of the packet extensions defined in the node.
|
||||
*/
|
||||
List<PacketExtension> getNodePacketExtensions();
|
||||
List<ExtensionElement> getNodePacketExtensions();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
|||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.caps.EntityCapsManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
|
@ -447,10 +447,10 @@ public class ServiceDiscoveryManager extends Manager {
|
|||
*
|
||||
* @return the data form as List of PacketExtensions
|
||||
*/
|
||||
public List<PacketExtension> getExtendedInfoAsList() {
|
||||
List<PacketExtension> res = null;
|
||||
public List<ExtensionElement> getExtendedInfoAsList() {
|
||||
List<ExtensionElement> res = null;
|
||||
if (extendedInfo != null) {
|
||||
res = new ArrayList<PacketExtension>(1);
|
||||
res = new ArrayList<ExtensionElement>(1);
|
||||
res.add(extendedInfo);
|
||||
}
|
||||
return res;
|
||||
|
|
|
@ -61,7 +61,7 @@ public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> {
|
|||
}
|
||||
// Otherwise, it must be a packet extension.
|
||||
else {
|
||||
PacketParserUtils.addPacketExtension(discoverInfo, parser);
|
||||
PacketParserUtils.addExtensionElement(discoverInfo, parser);
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("identity")) {
|
||||
|
|
|
@ -18,26 +18,15 @@ package org.jivesoftware.smackx.filetransfer;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletionService;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorCompletionService;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.OrFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
|
@ -52,8 +41,6 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
private final StreamNegotiator primaryNegotiator;
|
||||
private final StreamNegotiator secondaryNegotiator;
|
||||
private final XMPPConnection connection;
|
||||
private PacketFilter primaryFilter;
|
||||
private PacketFilter secondaryFilter;
|
||||
|
||||
public FaultTolerantNegotiator(XMPPConnection connection, StreamNegotiator primary,
|
||||
StreamNegotiator secondary) {
|
||||
|
@ -62,12 +49,10 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
this.connection = connection;
|
||||
}
|
||||
|
||||
public PacketFilter getInitiationPacketFilter(Jid from, String streamID) {
|
||||
if (primaryFilter == null || secondaryFilter == null) {
|
||||
primaryFilter = primaryNegotiator.getInitiationPacketFilter(from, streamID);
|
||||
secondaryFilter = secondaryNegotiator.getInitiationPacketFilter(from, streamID);
|
||||
}
|
||||
return new OrFilter(primaryFilter, secondaryFilter);
|
||||
@Override
|
||||
public void newStreamInitiation(Jid from, String streamID) {
|
||||
primaryNegotiator.newStreamInitiation(from, streamID);
|
||||
secondaryNegotiator.newStreamInitiation(from, streamID);
|
||||
}
|
||||
|
||||
InputStream negotiateIncomingStream(Stanza streamInitiation) {
|
||||
|
@ -75,73 +60,23 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
"stream method.");
|
||||
}
|
||||
|
||||
final Stanza initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) {
|
||||
throw new UnsupportedOperationException("Initiation handled by createIncomingStream " +
|
||||
"method");
|
||||
}
|
||||
public InputStream createIncomingStream(final StreamInitiation initiation) throws SmackException, XMPPErrorException, InterruptedException {
|
||||
// This could be either an xep47 ibb 'open' iq or an xep65 streamhost iq
|
||||
IQ initationSet = initiateIncomingStream(connection, initiation);
|
||||
|
||||
public InputStream createIncomingStream(StreamInitiation initiation) throws SmackException, InterruptedException {
|
||||
PacketCollector collector = connection.createPacketCollectorAndSend(
|
||||
getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()),
|
||||
super.createInitiationAccept(initiation, getNamespaces()));
|
||||
StreamNegotiator streamNegotiator = determineNegotiator(initationSet);
|
||||
|
||||
ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(2);
|
||||
CompletionService<InputStream> service
|
||||
= new ExecutorCompletionService<InputStream>(threadPoolExecutor);
|
||||
List<Future<InputStream>> futures = new ArrayList<Future<InputStream>>();
|
||||
InputStream stream = null;
|
||||
SmackException exception = null;
|
||||
try {
|
||||
futures.add(service.submit(new NegotiatorService(collector)));
|
||||
futures.add(service.submit(new NegotiatorService(collector)));
|
||||
|
||||
int i = 0;
|
||||
while (stream == null && i < futures.size()) {
|
||||
Future<InputStream> future;
|
||||
try {
|
||||
i++;
|
||||
future = service.poll(connection.getPacketReplyTimeout(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (future == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
stream = future.get();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
/* Do Nothing */
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
exception = new SmackException(e.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
for (Future<InputStream> future : futures) {
|
||||
future.cancel(true);
|
||||
}
|
||||
collector.cancel();
|
||||
threadPoolExecutor.shutdownNow();
|
||||
}
|
||||
if (stream == null) {
|
||||
if (exception != null) {
|
||||
throw exception;
|
||||
}
|
||||
else {
|
||||
throw new SmackException("File transfer negotiation failed.");
|
||||
}
|
||||
}
|
||||
|
||||
return stream;
|
||||
return streamNegotiator.negotiateIncomingStream(initationSet);
|
||||
}
|
||||
|
||||
private StreamNegotiator determineNegotiator(Stanza streamInitiation) {
|
||||
return primaryFilter.accept(streamInitiation) ? primaryNegotiator : secondaryNegotiator;
|
||||
if (streamInitiation instanceof Bytestream) {
|
||||
return primaryNegotiator;
|
||||
} else if (streamInitiation instanceof Open){
|
||||
return secondaryNegotiator;
|
||||
} else {
|
||||
throw new IllegalStateException("Unknown stream initation type");
|
||||
}
|
||||
}
|
||||
|
||||
public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target)
|
||||
|
@ -168,18 +103,4 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
return namespaces;
|
||||
}
|
||||
|
||||
private class NegotiatorService implements Callable<InputStream> {
|
||||
|
||||
private PacketCollector collector;
|
||||
|
||||
NegotiatorService(PacketCollector collector) {
|
||||
this.collector = collector;
|
||||
}
|
||||
|
||||
public InputStream call() throws XMPPErrorException, InterruptedException, NoResponseException, SmackException {
|
||||
Stanza streamInitiation = collector.nextResultOrThrow();
|
||||
StreamNegotiator negotiator = determineNegotiator(streamInitiation);
|
||||
return negotiator.negotiateIncomingStream(streamInitiation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,6 +171,6 @@ public class FileTransferManager extends Manager {
|
|||
// Socks5BytestreamManager.replyRejectPacket(IQ).
|
||||
IQ rejection = IQ.createErrorResponse(initiation, new XMPPError(
|
||||
XMPPError.Condition.forbidden));
|
||||
connection().sendPacket(rejection);
|
||||
connection().sendStanza(rejection);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ public class FileTransferNegotiator extends Manager {
|
|||
String errorMessage = "No stream methods contained in stanza.";
|
||||
XMPPError error = XMPPError.from(XMPPError.Condition.bad_request, errorMessage);
|
||||
IQ iqPacket = IQ.createErrorResponse(si, error);
|
||||
connection().sendPacket(iqPacket);
|
||||
connection().sendStanza(iqPacket);
|
||||
throw new FileTransferException.NoStreamMethodsOfferedException();
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ public class FileTransferNegotiator extends Manager {
|
|||
}
|
||||
catch (NoAcceptableTransferMechanisms e) {
|
||||
IQ iqPacket = IQ.createErrorResponse(si, XMPPError.from(XMPPError.Condition.bad_request, "No acceptable transfer mechanism"));
|
||||
connection().sendPacket(iqPacket);
|
||||
connection().sendStanza(iqPacket);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,6 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
|
|||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
|
||||
|
@ -82,15 +77,14 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
|||
return negotiateIncomingStream(streamInitiation);
|
||||
}
|
||||
|
||||
public PacketFilter getInitiationPacketFilter(Jid from, String streamID) {
|
||||
@Override
|
||||
public void newStreamInitiation(Jid from, String streamID) {
|
||||
/*
|
||||
* this method is always called prior to #negotiateIncomingStream() so
|
||||
* the In-Band Bytestream initiation listener must ignore the next
|
||||
* In-Band Bytestream request with the given session ID
|
||||
*/
|
||||
this.manager.ignoreBytestreamRequestOnce(streamID);
|
||||
|
||||
return new AndFilter(FromMatchesFilter.create(from), new IBBOpenSidFilter(streamID));
|
||||
}
|
||||
|
||||
public String[] getNamespaces() {
|
||||
|
@ -108,34 +102,6 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
|||
return session.getInputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* This PacketFilter accepts an incoming In-Band Bytestream open request
|
||||
* with a specified session ID.
|
||||
*/
|
||||
private static class IBBOpenSidFilter extends PacketTypeFilter {
|
||||
|
||||
private String sessionID;
|
||||
|
||||
public IBBOpenSidFilter(String sessionID) {
|
||||
super(Open.class);
|
||||
if (sessionID == null) {
|
||||
throw new IllegalArgumentException("StreamID cannot be null");
|
||||
}
|
||||
this.sessionID = sessionID;
|
||||
}
|
||||
|
||||
public boolean accept(Stanza packet) {
|
||||
if (super.accept(packet)) {
|
||||
Open bytestream = (Open) packet;
|
||||
|
||||
// packet must by of type SET and contains the given session ID
|
||||
return this.sessionID.equals(bytestream.getSessionID())
|
||||
&& IQ.Type.set.equals(bytestream.getType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive from InBandBytestreamRequest to access protected constructor.
|
||||
*/
|
||||
|
|
|
@ -26,13 +26,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession;
|
||||
|
@ -86,15 +80,13 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PacketFilter getInitiationPacketFilter(final Jid from, String streamID) {
|
||||
public void newStreamInitiation(final Jid from, String streamID) {
|
||||
/*
|
||||
* this method is always called prior to #negotiateIncomingStream() so the SOCKS5
|
||||
* InitiationListener must ignore the next SOCKS5 Bytestream request with the given session
|
||||
* ID
|
||||
*/
|
||||
this.manager.ignoreBytestreamRequestOnce(streamID);
|
||||
|
||||
return new AndFilter(FromMatchesFilter.create(from), new BytestreamSIDFilter(streamID));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,32 +116,6 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This PacketFilter accepts an incoming SOCKS5 Bytestream request with a specified session ID.
|
||||
*/
|
||||
private static class BytestreamSIDFilter extends PacketTypeFilter {
|
||||
|
||||
private final String sessionID;
|
||||
|
||||
public BytestreamSIDFilter(String sessionID) {
|
||||
super(Bytestream.class);
|
||||
this.sessionID = Objects.requireNonNull(sessionID, "SessionID cannot be null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
if (super.accept(packet)) {
|
||||
Bytestream bytestream = (Bytestream) packet;
|
||||
|
||||
// packet must by of type SET and contains the given session ID
|
||||
return this.sessionID.equals(bytestream.getSessionID())
|
||||
&& IQ.Type.set.equals(bytestream.getType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive from Socks5BytestreamRequest to access protected constructor.
|
||||
*/
|
||||
|
|
|
@ -16,16 +16,16 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.filetransfer;
|
||||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.EventManger;
|
||||
import org.jivesoftware.smack.util.EventManger.Callback;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
@ -44,6 +44,19 @@ import java.io.OutputStream;
|
|||
*/
|
||||
public abstract class StreamNegotiator {
|
||||
|
||||
/**
|
||||
* A event manager for stream initiation requests send to us.
|
||||
* <p>
|
||||
* Those are typical XEP-45 Open or XEP-65 Bytestream IQ requests. The even key is in the format
|
||||
* "initiationFrom + '\t' + streamId"
|
||||
* </p>
|
||||
*/
|
||||
// TODO This field currently being static is considered a quick hack. Ideally this should take
|
||||
// the local connection into account, for example by changing the key to
|
||||
// "localJid + '\t' + initiationFrom + '\t' + streamId" or making the field non-static (but then
|
||||
// you need to provide access to the InitiationListeners, which could get tricky)
|
||||
protected static final EventManger<String, IQ, SmackException.NotConnectedException> initationSetEvents = new EventManger<>();
|
||||
|
||||
/**
|
||||
* Creates the initiation acceptance packet to forward to the stream
|
||||
* initiator.
|
||||
|
@ -52,7 +65,7 @@ public abstract class StreamNegotiator {
|
|||
* @param namespaces The namespace that relates to the accepted means of transfer.
|
||||
* @return The response to be forwarded to the initiator.
|
||||
*/
|
||||
public StreamInitiation createInitiationAccept(
|
||||
protected static StreamInitiation createInitiationAccept(
|
||||
StreamInitiation streamInitiationOffer, String[] namespaces)
|
||||
{
|
||||
StreamInitiation response = new StreamInitiation();
|
||||
|
@ -73,29 +86,47 @@ public abstract class StreamNegotiator {
|
|||
return response;
|
||||
}
|
||||
|
||||
Stanza initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
StreamInitiation response = createInitiationAccept(initiation,
|
||||
protected final IQ initiateIncomingStream(final XMPPConnection connection, StreamInitiation initiation)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
final StreamInitiation response = createInitiationAccept(initiation,
|
||||
getNamespaces());
|
||||
|
||||
// establish collector to await response
|
||||
PacketCollector collector = connection
|
||||
.createPacketCollectorAndSend(getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()), response);
|
||||
newStreamInitiation(initiation.getFrom(), initiation.getSessionID());
|
||||
|
||||
Stanza streamMethodInitiation = collector.nextResultOrThrow();
|
||||
final String eventKey = initiation.getFrom().toString() + '\t' + initiation.getSessionID();
|
||||
IQ streamMethodInitiation;
|
||||
try {
|
||||
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getPacketReplyTimeout(), new Callback<NotConnectedException>() {
|
||||
@Override
|
||||
public void action() throws NotConnectedException {
|
||||
try {
|
||||
connection.sendStanza(response);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
// TODO remove this try/catch once merged into 4.2's master branch
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
if (streamMethodInitiation == null) {
|
||||
throw NoResponseException.newWith(connection);
|
||||
}
|
||||
XMPPErrorException.ifHasErrorThenThrow(streamMethodInitiation);
|
||||
return streamMethodInitiation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the packet filter that will return the initiation packet for the appropriate stream
|
||||
* initiation.
|
||||
* Signal that a new stream initiation arrived. The negotiator may needs to prepare for it.
|
||||
*
|
||||
* @param from The initiator of the file transfer.
|
||||
* @param streamID The stream ID related to the transfer.
|
||||
* @return The <b><i>PacketFilter</b></i> that will return the packet relatable to the stream
|
||||
* initiation.
|
||||
*/
|
||||
public abstract PacketFilter getInitiationPacketFilter(Jid from, String streamID);
|
||||
protected abstract void newStreamInitiation(Jid from, String streamID);
|
||||
|
||||
|
||||
abstract InputStream negotiateIncomingStream(Stanza streamInitiation) throws XMPPErrorException,
|
||||
|
@ -149,4 +180,7 @@ public abstract class StreamNegotiator {
|
|||
*/
|
||||
public abstract String[] getNamespaces();
|
||||
|
||||
public static void signal(String eventKey, IQ eventValue) {
|
||||
initationSetEvents.signalEvent(eventKey, eventValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.forward.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
|||
* @author Georg Lukas
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0297.html">XEP-0297: Stanza Forwarding</a>
|
||||
*/
|
||||
public class Forwarded implements PacketExtension {
|
||||
public class Forwarded implements ExtensionElement {
|
||||
public static final String NAMESPACE = "urn:xmpp:forward:0";
|
||||
public static final String ELEMENT = "forwarded";
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.logging.Logger;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
import org.jivesoftware.smackx.delay.provider.DelayInformationProvider;
|
||||
|
@ -31,12 +31,12 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* This class implements the {@link PacketExtensionProvider} to parse
|
||||
* This class implements the {@link ExtensionElementProvider} to parse
|
||||
* forwarded messages from a packet. It will return a {@link Forwarded} packet extension.
|
||||
*
|
||||
* @author Georg Lukas
|
||||
*/
|
||||
public class ForwardedProvider extends PacketExtensionProvider<Forwarded> {
|
||||
public class ForwardedProvider extends ExtensionElementProvider<Forwarded> {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName());
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
|
|||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -93,7 +93,7 @@ import org.jxmpp.jid.Jid;
|
|||
public class LastActivityManager extends Manager {
|
||||
private static final Map<XMPPConnection, LastActivityManager> instances = new WeakHashMap<XMPPConnection, LastActivityManager>();
|
||||
// private static final PacketFilter IQ_GET_LAST_FILTER = new AndFilter(IQTypeFilter.GET,
|
||||
// new PacketTypeFilter(LastActivity.class));
|
||||
// new StanzaTypeFilter(LastActivity.class));
|
||||
|
||||
private static boolean enabledPerDefault = true;
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class LastActivityManager extends Manager {
|
|||
super(connection);
|
||||
|
||||
// Listen to all the sent messages to reset the idle time on each one
|
||||
connection.addPacketSendingListener(new PacketListener() {
|
||||
connection.addPacketSendingListener(new StanzaListener() {
|
||||
public void processPacket(Stanza packet) {
|
||||
Presence presence = (Presence) packet;
|
||||
Presence.Mode mode = presence.getMode();
|
||||
|
@ -150,9 +150,9 @@ public class LastActivityManager extends Manager {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}, PacketTypeFilter.PRESENCE);
|
||||
}, StanzaTypeFilter.PRESENCE);
|
||||
|
||||
connection.addPacketSendingListener(new PacketListener() {
|
||||
connection.addPacketSendingListener(new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) {
|
||||
Message message = (Message) packet;
|
||||
|
@ -160,7 +160,7 @@ public class LastActivityManager extends Manager {
|
|||
if (message.getType() == Message.Type.error) return;
|
||||
resetIdleTime();
|
||||
}
|
||||
}, PacketTypeFilter.MESSAGE);
|
||||
}, StanzaTypeFilter.MESSAGE);
|
||||
|
||||
// Register a listener for a last activity query
|
||||
connection.registerIQRequestHandler(new AbstractIqRequestHandler(LastActivity.ELEMENT, LastActivity.NAMESPACE,
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jivesoftware.smackx.iqregister.packet;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* Represents registration packets. An empty GET query will cause the server to return information
|
||||
|
@ -100,7 +100,7 @@ public class Registration extends IQ {
|
|||
return xml;
|
||||
}
|
||||
|
||||
public static class Feature implements PacketExtension {
|
||||
public static class Feature implements ExtensionElement {
|
||||
|
||||
public static final String ELEMENT = "register";
|
||||
public static final String NAMESPACE = "http://jabber.org/features/iq-register";
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.iqregister.packet.Registration;
|
||||
|
@ -38,7 +38,7 @@ public class RegistrationProvider extends IQProvider<Registration> {
|
|||
throws XmlPullParserException, IOException, SmackException {
|
||||
String instruction = null;
|
||||
Map<String, String> fields = new HashMap<String, String>();
|
||||
List<PacketExtension> packetExtensions = new LinkedList<PacketExtension>();
|
||||
List<ExtensionElement> packetExtensions = new LinkedList<ExtensionElement>();
|
||||
outerloop:
|
||||
while (true) {
|
||||
int eventType = parser.next();
|
||||
|
@ -62,7 +62,7 @@ public class RegistrationProvider extends IQProvider<Registration> {
|
|||
}
|
||||
// Otherwise, it must be a packet extension.
|
||||
else {
|
||||
PacketParserUtils.addPacketExtension(packetExtensions, parser);
|
||||
PacketParserUtils.addExtensionElement(packetExtensions, parser);
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.iqregister.provider;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.iqregister.packet.Registration;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class RegistrationStreamFeatureProvider extends PacketExtensionProvider<Registration.Feature> {
|
||||
public class RegistrationStreamFeatureProvider extends ExtensionElementProvider<Registration.Feature> {
|
||||
|
||||
@Override
|
||||
public Registration.Feature parse(XmlPullParser parser, int initialDepth) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
|
||||
|
@ -38,7 +38,7 @@ import org.jivesoftware.smack.util.stringencoder.Base64;
|
|||
* Serializable interface).
|
||||
*
|
||||
*/
|
||||
public class JivePropertiesExtension implements PacketExtension {
|
||||
public class JivePropertiesExtension implements ExtensionElement {
|
||||
/**
|
||||
* Namespace used to store packet properties.
|
||||
*/
|
||||
|
|
|
@ -24,14 +24,14 @@ import java.util.Map;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager;
|
||||
import org.jivesoftware.smackx.jiveproperties.packet.JivePropertiesExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class JivePropertiesExtensionProvider extends PacketExtensionProvider<JivePropertiesExtension> {
|
||||
public class JivePropertiesExtensionProvider extends ExtensionElementProvider<JivePropertiesExtension> {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(JivePropertiesExtensionProvider.class.getName());
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.jivesoftware.smack.MessageListener;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.PresenceListener;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
|
@ -45,9 +45,9 @@ import org.jivesoftware.smack.filter.FromMatchesFilter;
|
|||
import org.jivesoftware.smack.filter.MessageTypeFilter;
|
||||
import org.jivesoftware.smack.filter.MessageWithSubjectFilter;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.filter.ToFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -112,18 +112,18 @@ public class MultiUserChat {
|
|||
* the groupchat participants, i.e. it filters only the bare JID of the from
|
||||
* attribute against the JID of the MUC.
|
||||
*/
|
||||
private final PacketFilter fromRoomFilter;
|
||||
private final StanzaFilter fromRoomFilter;
|
||||
|
||||
/**
|
||||
* Same as {@link #fromRoomFilter} together with {@link MessageTypeFilter#GROUPCHAT}.
|
||||
*/
|
||||
private final PacketFilter fromRoomGroupchatFilter;
|
||||
private final StanzaFilter fromRoomGroupchatFilter;
|
||||
|
||||
private final PacketListener presenceInterceptor;
|
||||
private final PacketListener messageListener;
|
||||
private final PacketListener presenceListener;
|
||||
private final PacketListener subjectListener;
|
||||
private final PacketListener declinesListener;
|
||||
private final StanzaListener presenceInterceptor;
|
||||
private final StanzaListener messageListener;
|
||||
private final StanzaListener presenceListener;
|
||||
private final StanzaListener subjectListener;
|
||||
private final StanzaListener declinesListener;
|
||||
|
||||
private String subject;
|
||||
private Resourcepart nickname;
|
||||
|
@ -138,7 +138,7 @@ public class MultiUserChat {
|
|||
fromRoomFilter = FromMatchesFilter.create(room);
|
||||
fromRoomGroupchatFilter = new AndFilter(fromRoomFilter, MessageTypeFilter.GROUPCHAT);
|
||||
|
||||
messageListener = new PacketListener() {
|
||||
messageListener = new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
Message message = (Message) packet;
|
||||
|
@ -149,7 +149,7 @@ public class MultiUserChat {
|
|||
};
|
||||
|
||||
// Create a listener for subject updates.
|
||||
subjectListener = new PacketListener() {
|
||||
subjectListener = new StanzaListener() {
|
||||
public void processPacket(Stanza packet) {
|
||||
Message msg = (Message) packet;
|
||||
FullJid from = msg.getFrom().asFullJidIfPossible();
|
||||
|
@ -167,7 +167,7 @@ public class MultiUserChat {
|
|||
};
|
||||
|
||||
// Create a listener for all presence updates.
|
||||
presenceListener = new PacketListener() {
|
||||
presenceListener = new StanzaListener() {
|
||||
public void processPacket(Stanza packet) {
|
||||
Presence presence = (Presence) packet;
|
||||
final FullJid from = presence.getFrom().asFullJidIfPossible();
|
||||
|
@ -210,7 +210,7 @@ public class MultiUserChat {
|
|||
case unavailable:
|
||||
occupantsMap.remove(from);
|
||||
MUCUser mucUser = MUCUser.from(packet);
|
||||
if (mucUser != null && mucUser.getStatus() != null) {
|
||||
if (mucUser != null && mucUser.hasStatus()) {
|
||||
// Fire events according to the received presence code
|
||||
checkPresenceCode(
|
||||
mucUser.getStatus(),
|
||||
|
@ -237,7 +237,7 @@ public class MultiUserChat {
|
|||
|
||||
// Listens for all messages that include a MUCUser extension and fire the invitation
|
||||
// rejection listeners if the message includes an invitation rejection.
|
||||
declinesListener = new PacketListener() {
|
||||
declinesListener = new StanzaListener() {
|
||||
public void processPacket(Stanza packet) {
|
||||
// Get the MUC User extension
|
||||
MUCUser mucUser = MUCUser.from(packet);
|
||||
|
@ -250,7 +250,7 @@ public class MultiUserChat {
|
|||
}
|
||||
};
|
||||
|
||||
presenceInterceptor = new PacketListener() {
|
||||
presenceInterceptor = new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) {
|
||||
Presence presence = (Presence) packet;
|
||||
|
@ -306,18 +306,18 @@ public class MultiUserChat {
|
|||
joinPresence.addExtension(mucInitialPresence);
|
||||
|
||||
// Wait for a presence packet back from the server.
|
||||
PacketFilter responseFilter = new AndFilter(FromMatchesFilter.createFull(jid), new PacketTypeFilter(Presence.class));
|
||||
StanzaFilter responseFilter = new AndFilter(FromMatchesFilter.createFull(jid), new StanzaTypeFilter(Presence.class));
|
||||
|
||||
// Setup the messageListeners and presenceListeners *before* the join presence is send.
|
||||
connection.addSyncPacketListener(messageListener, fromRoomGroupchatFilter);
|
||||
connection.addSyncPacketListener(presenceListener, new AndFilter(fromRoomFilter,
|
||||
PacketTypeFilter.PRESENCE));
|
||||
connection.addSyncPacketListener(subjectListener, new AndFilter(fromRoomFilter,
|
||||
connection.addSyncStanzaListener(messageListener, fromRoomGroupchatFilter);
|
||||
connection.addSyncStanzaListener(presenceListener, new AndFilter(fromRoomFilter,
|
||||
StanzaTypeFilter.PRESENCE));
|
||||
connection.addSyncStanzaListener(subjectListener, new AndFilter(fromRoomFilter,
|
||||
MessageWithSubjectFilter.INSTANCE));
|
||||
connection.addSyncPacketListener(declinesListener, new AndFilter(new PacketExtensionFilter(MUCUser.ELEMENT,
|
||||
connection.addSyncStanzaListener(declinesListener, new AndFilter(new StanzaExtensionFilter(MUCUser.ELEMENT,
|
||||
MUCUser.NAMESPACE), new NotFilter(MessageTypeFilter.ERROR)));
|
||||
connection.addPacketInterceptor(presenceInterceptor, new AndFilter(new ToFilter(room),
|
||||
PacketTypeFilter.PRESENCE));
|
||||
StanzaTypeFilter.PRESENCE));
|
||||
messageCollector = connection.createPacketCollector(fromRoomGroupchatFilter);
|
||||
|
||||
Presence presence;
|
||||
|
@ -539,7 +539,7 @@ public class MultiUserChat {
|
|||
// field is in the form "roomName@service/nickname"
|
||||
Presence leavePresence = new Presence(Presence.Type.unavailable);
|
||||
leavePresence.setTo(JidCreate.fullFrom(room, nickname));
|
||||
connection.sendPacket(leavePresence);
|
||||
connection.sendStanza(leavePresence);
|
||||
// Reset occupant information.
|
||||
occupantsMap.clear();
|
||||
nickname = null;
|
||||
|
@ -717,7 +717,7 @@ public class MultiUserChat {
|
|||
// Add the MUCUser packet that includes the invitation to the message
|
||||
message.addExtension(mucUser);
|
||||
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -782,7 +782,7 @@ public class MultiUserChat {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds a new {@link PacketListener} that will be invoked every time a new presence
|
||||
* Adds a new {@link StanzaListener} that will be invoked every time a new presence
|
||||
* is going to be sent by this MultiUserChat to the server. Packet interceptors may
|
||||
* add new extensions to the presence that is going to be sent to the MUC service.
|
||||
*
|
||||
|
@ -793,13 +793,13 @@ public class MultiUserChat {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes a {@link PacketListener} that was being invoked every time a new presence
|
||||
* Removes a {@link StanzaListener} that was being invoked every time a new presence
|
||||
* was being sent by this MultiUserChat to the server. Packet interceptors may
|
||||
* add new extensions to the presence that is going to be sent to the MUC service.
|
||||
*
|
||||
* @param presenceInterceptor the packet interceptor to remove.
|
||||
*/
|
||||
public void removePresenceInterceptor(PacketListener presenceInterceptor) {
|
||||
public void removePresenceInterceptor(StanzaListener presenceInterceptor) {
|
||||
presenceInterceptors.remove(presenceInterceptor);
|
||||
}
|
||||
|
||||
|
@ -886,10 +886,10 @@ public class MultiUserChat {
|
|||
joinPresence.setTo(jid);
|
||||
|
||||
// Wait for a presence packet back from the server.
|
||||
PacketFilter responseFilter =
|
||||
StanzaFilter responseFilter =
|
||||
new AndFilter(
|
||||
FromMatchesFilter.createFull(jid),
|
||||
new PacketTypeFilter(Presence.class));
|
||||
new StanzaTypeFilter(Presence.class));
|
||||
PacketCollector response = connection.createPacketCollectorAndSend(responseFilter, joinPresence);
|
||||
// Wait up to a certain number of seconds for a reply. If there is a negative reply, an
|
||||
// exception will be thrown
|
||||
|
@ -924,7 +924,7 @@ public class MultiUserChat {
|
|||
joinPresence.setTo(JidCreate.fullFrom(room, nickname));
|
||||
|
||||
// Send join packet.
|
||||
connection.sendPacket(joinPresence);
|
||||
connection.sendStanza(joinPresence);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -973,7 +973,7 @@ public class MultiUserChat {
|
|||
form.addField(requestVoiceField);
|
||||
Message message = new Message(room);
|
||||
message.addExtension(form);
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1642,7 +1642,7 @@ public class MultiUserChat {
|
|||
public void sendMessage(String text) throws XMPPException, NotConnectedException, InterruptedException {
|
||||
Message message = createMessage();
|
||||
message.setBody(text);
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1680,7 +1680,7 @@ public class MultiUserChat {
|
|||
public void sendMessage(Message message) throws XMPPException, NotConnectedException, InterruptedException {
|
||||
message.setTo(room);
|
||||
message.setType(Message.Type.groupchat);
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1778,7 +1778,7 @@ public class MultiUserChat {
|
|||
Message message = createMessage();
|
||||
message.setSubject(subject);
|
||||
// Wait for an error or confirmation message back from the server.
|
||||
PacketFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new PacketFilter() {
|
||||
StanzaFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() {
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
Message msg = (Message) packet;
|
||||
|
@ -1795,9 +1795,9 @@ public class MultiUserChat {
|
|||
* connection.
|
||||
*/
|
||||
private void removeConnectionCallbacks() {
|
||||
connection.removeSyncPacketListener(messageListener);
|
||||
connection.removeSyncPacketListener(presenceListener);
|
||||
connection.removeSyncPacketListener(declinesListener);
|
||||
connection.removeSyncStanzaListener(messageListener);
|
||||
connection.removeSyncStanzaListener(presenceListener);
|
||||
connection.removeSyncStanzaListener(declinesListener);
|
||||
connection.removePacketInterceptor(presenceInterceptor);
|
||||
if (messageCollector != null) {
|
||||
messageCollector.cancel();
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
|
@ -38,10 +38,10 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.MessageTypeFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.disco.AbstractNodeInformationProvider;
|
||||
|
@ -107,7 +107,7 @@ public class MultiUserChatManager extends Manager {
|
|||
return multiUserChatManager;
|
||||
}
|
||||
|
||||
private static final PacketFilter INVITATION_FILTER = new AndFilter(PacketTypeFilter.MESSAGE, new PacketExtensionFilter(new MUCUser()),
|
||||
private static final StanzaFilter INVITATION_FILTER = new AndFilter(StanzaTypeFilter.MESSAGE, new StanzaExtensionFilter(new MUCUser()),
|
||||
new NotFilter(MessageTypeFilter.ERROR));
|
||||
|
||||
private final Set<InvitationListener> invitationsListeners = new CopyOnWriteArraySet<InvitationListener>();
|
||||
|
@ -124,7 +124,7 @@ public class MultiUserChatManager extends Manager {
|
|||
super(connection);
|
||||
// Listens for all messages that include a MUCUser extension and fire the invitation
|
||||
// listeners if the message includes an invitation.
|
||||
PacketListener invitationPacketListener = new PacketListener() {
|
||||
StanzaListener invitationPacketListener = new StanzaListener() {
|
||||
public void processPacket(Stanza packet) {
|
||||
final Message message = (Message) packet;
|
||||
// Get the MUCUser extension
|
||||
|
@ -145,7 +145,7 @@ public class MultiUserChatManager extends Manager {
|
|||
}
|
||||
}
|
||||
};
|
||||
connection.addAsyncPacketListener(invitationPacketListener, INVITATION_FILTER);
|
||||
connection.addAsyncStanzaListener(invitationPacketListener, INVITATION_FILTER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -307,7 +307,7 @@ public class MultiUserChatManager extends Manager {
|
|||
// Add the MUCUser packet that includes the rejection
|
||||
message.addExtension(mucUser);
|
||||
|
||||
connection().sendPacket(message);
|
||||
connection().sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,8 +20,8 @@ package org.jivesoftware.smackx.muc.packet;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -36,15 +36,15 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
* Message message = new Message("user@chat.example.com");
|
||||
* message.setBody("Join me for a group chat!");
|
||||
* message.addExtension(new GroupChatInvitation("room@chat.example.com"););
|
||||
* con.sendPacket(message);
|
||||
* con.sendStanza(message);
|
||||
* </pre>
|
||||
*
|
||||
* To listen for group chat invitations, use a PacketExtensionFilter for the
|
||||
* To listen for group chat invitations, use a StanzaExtensionFilter for the
|
||||
* <tt>x</tt> element name and <tt>jabber:x:conference</tt> namespace, as in the
|
||||
* following code example:
|
||||
*
|
||||
* <pre>
|
||||
* PacketFilter filter = new PacketExtensionFilter("x", "jabber:x:conference");
|
||||
* PacketFilter filter = new StanzaExtensionFilter("x", "jabber:x:conference");
|
||||
* // Create a packet collector or packet listeners using the filter...
|
||||
* </pre>
|
||||
*
|
||||
|
@ -55,7 +55,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class GroupChatInvitation implements PacketExtension {
|
||||
public class GroupChatInvitation implements ExtensionElement {
|
||||
|
||||
/**
|
||||
* Element name of the packet extension.
|
||||
|
@ -128,7 +128,7 @@ public class GroupChatInvitation implements PacketExtension {
|
|||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
public static class Provider extends PacketExtensionProvider<GroupChatInvitation> {
|
||||
public static class Provider extends ExtensionElementProvider<GroupChatInvitation> {
|
||||
|
||||
@Override
|
||||
public GroupChatInvitation parse(XmlPullParser parser,
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.muc.packet;
|
|||
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
|
||||
|
@ -37,7 +37,7 @@ import java.util.Date;
|
|||
* @author Gaston Dombiak
|
||||
* @see MUCInitialPresence#setHistory(MUCInitialPresence.History)
|
||||
*/
|
||||
public class MUCInitialPresence implements PacketExtension {
|
||||
public class MUCInitialPresence implements ExtensionElement {
|
||||
|
||||
public static final String ELEMENT = "x";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/muc";
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCUser implements PacketExtension {
|
||||
public class MUCUser implements ExtensionElement {
|
||||
|
||||
public static final String ELEMENT = "x";
|
||||
public static final String NAMESPACE = MUCInitialPresence.NAMESPACE + "#user";
|
||||
|
@ -118,6 +118,19 @@ public class MUCUser implements PacketExtension {
|
|||
return statusCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this MUCUser instance has also {@link Status} information.
|
||||
* <p>
|
||||
* If <code>true</code> is returned, then {@link #getStatus()} will return a non-empty set.
|
||||
* </p>
|
||||
*
|
||||
* @return true if this MUCUser has status information.
|
||||
* @since 4.1
|
||||
*/
|
||||
public boolean hasStatus() {
|
||||
return !statusCodes.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the notification that the room has been destroyed. After a room has been destroyed,
|
||||
* the room occupants will receive a Presence packet of type 'unavailable' with the reason for
|
||||
|
|
|
@ -49,7 +49,7 @@ public class MUCOwnerProvider extends IQProvider<MUCOwner> {
|
|||
}
|
||||
// Otherwise, it must be a packet extension.
|
||||
else {
|
||||
PacketParserUtils.addPacketExtension(mucOwner, parser);
|
||||
PacketParserUtils.addExtensionElement(mucOwner, parser);
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jivesoftware.smackx.muc.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -31,7 +31,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCUserProvider extends PacketExtensionProvider<MUCUser> {
|
||||
public class MUCUserProvider extends ExtensionElementProvider<MUCUser> {
|
||||
|
||||
/**
|
||||
* Parses a MUCUser packet (extension sub-packet).
|
||||
|
|
|
@ -18,18 +18,18 @@ package org.jivesoftware.smackx.nick.packet;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* A minimalistic implementation of a {@link PacketExtension} for nicknames.
|
||||
* A minimalistic implementation of a {@link ExtensionElement} for nicknames.
|
||||
*
|
||||
* @author Guus der Kinderen, guus.der.kinderen@gmail.com
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0172.html">XEP-0172: User Nickname</a>
|
||||
*/
|
||||
public class Nick implements PacketExtension {
|
||||
public class Nick implements ExtensionElement {
|
||||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/nick";
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class Nick implements PacketExtension {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider extends PacketExtensionProvider<Nick> {
|
||||
public static class Provider extends ExtensionElementProvider<Nick> {
|
||||
|
||||
@Override
|
||||
public Nick parse(XmlPullParser parser, int initialDepth)
|
||||
|
|
|
@ -23,9 +23,9 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
@ -60,8 +60,8 @@ public class OfflineMessageManager {
|
|||
|
||||
private final XMPPConnection connection;
|
||||
|
||||
private static final PacketFilter PACKET_FILTER = new AndFilter(new PacketExtensionFilter(
|
||||
new OfflineMessageInfo()), PacketTypeFilter.MESSAGE);
|
||||
private static final StanzaFilter PACKET_FILTER = new AndFilter(new StanzaExtensionFilter(
|
||||
new OfflineMessageInfo()), StanzaTypeFilter.MESSAGE);
|
||||
|
||||
public OfflineMessageManager(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
|
@ -150,7 +150,7 @@ public class OfflineMessageManager {
|
|||
request.addItem(item);
|
||||
}
|
||||
// Filter offline messages that were requested by this request
|
||||
PacketFilter messageFilter = new AndFilter(PACKET_FILTER, new PacketFilter() {
|
||||
StanzaFilter messageFilter = new AndFilter(PACKET_FILTER, new StanzaFilter() {
|
||||
public boolean accept(Stanza packet) {
|
||||
OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
|
||||
namespace);
|
||||
|
@ -191,7 +191,7 @@ public class OfflineMessageManager {
|
|||
request.setFetch(true);
|
||||
|
||||
PacketCollector resultCollector = connection.createPacketCollectorAndSend(request);
|
||||
PacketCollector.Configuration messageCollectorConfiguration = PacketCollector.newConfiguration().setPacketFilter(PACKET_FILTER).setCollectorToReset(resultCollector);
|
||||
PacketCollector.Configuration messageCollectorConfiguration = PacketCollector.newConfiguration().setStanzaFilter(PACKET_FILTER).setCollectorToReset(resultCollector);
|
||||
PacketCollector messageCollector = connection.createPacketCollector(messageCollectorConfiguration);
|
||||
|
||||
List<Message> messages = null;
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.jivesoftware.smackx.offline.packet;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -32,7 +32,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class OfflineMessageInfo implements PacketExtension {
|
||||
public class OfflineMessageInfo implements ExtensionElement {
|
||||
|
||||
private String node = null;
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class OfflineMessageInfo implements PacketExtension {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider extends PacketExtensionProvider<OfflineMessageInfo> {
|
||||
public static class Provider extends ExtensionElementProvider<OfflineMessageInfo> {
|
||||
|
||||
/**
|
||||
* Parses a OfflineMessageInfo packet (extension sub-packet).
|
||||
|
|
|
@ -20,11 +20,11 @@ package org.jivesoftware.smackx.pep;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
|
@ -65,8 +65,8 @@ public class PEPManager {
|
|||
|
||||
private XMPPConnection connection;
|
||||
|
||||
private PacketFilter packetFilter = new PacketExtensionFilter("event", "http://jabber.org/protocol/pubsub#event");
|
||||
private PacketListener packetListener;
|
||||
private StanzaFilter packetFilter = new StanzaExtensionFilter("event", "http://jabber.org/protocol/pubsub#event");
|
||||
private StanzaListener packetListener;
|
||||
|
||||
/**
|
||||
* Creates a new PEP exchange manager.
|
||||
|
@ -117,7 +117,7 @@ public class PEPManager {
|
|||
//pubSub.setFrom(connection.getUser());
|
||||
|
||||
// Send the message that contains the roster
|
||||
connection.sendPacket(pubSub);
|
||||
connection.sendStanza(pubSub);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,7 +136,7 @@ public class PEPManager {
|
|||
|
||||
private void init() {
|
||||
// Listens for all roster exchange packets and fire the roster exchange listeners.
|
||||
packetListener = new PacketListener() {
|
||||
packetListener = new StanzaListener() {
|
||||
public void processPacket(Stanza packet) {
|
||||
Message message = (Message) packet;
|
||||
PEPEvent event = (PEPEvent) message.getExtension("event", "http://jabber.org/protocol/pubsub#event");
|
||||
|
@ -144,12 +144,12 @@ public class PEPManager {
|
|||
firePEPListeners(message.getFrom(), event);
|
||||
}
|
||||
};
|
||||
connection.addSyncPacketListener(packetListener, packetFilter);
|
||||
connection.addSyncStanzaListener(packetListener, packetFilter);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if (connection != null)
|
||||
connection.removeSyncPacketListener(packetListener);
|
||||
connection.removeSyncStanzaListener(packetListener);
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.pep.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* Represents XMPP Personal Event Protocol packets.<p>
|
||||
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.packet.PacketExtension;
|
|||
*
|
||||
* @author Jeff Williams
|
||||
*/
|
||||
public class PEPEvent implements PacketExtension {
|
||||
public class PEPEvent implements ExtensionElement {
|
||||
|
||||
PEPItem item;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.pep.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* Represents XMPP Personal Event Protocol packets.<p>
|
||||
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.packet.PacketExtension;
|
|||
*
|
||||
* @author Jeff Williams
|
||||
*/
|
||||
public abstract class PEPItem implements PacketExtension {
|
||||
public abstract class PEPItem implements ExtensionElement {
|
||||
|
||||
String id;
|
||||
abstract String getNode();
|
||||
|
|
|
@ -22,8 +22,8 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -41,11 +41,11 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*
|
||||
* @author Jeff Williams
|
||||
*/
|
||||
public class PEPProvider extends PacketExtensionProvider<PacketExtension> {
|
||||
public class PEPProvider extends ExtensionElementProvider<ExtensionElement> {
|
||||
|
||||
private static final Map<String, PacketExtensionProvider<?>> nodeParsers = new HashMap<String, PacketExtensionProvider<?>>();
|
||||
private static final Map<String, ExtensionElementProvider<?>> nodeParsers = new HashMap<String, ExtensionElementProvider<?>>();
|
||||
|
||||
public static void registerPEPParserExtension(String node, PacketExtensionProvider<?> pepItemParser) {
|
||||
public static void registerPEPParserExtension(String node, ExtensionElementProvider<?> pepItemParser) {
|
||||
nodeParsers.put(node, pepItemParser);
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,9 @@ public class PEPProvider extends PacketExtensionProvider<PacketExtension> {
|
|||
* @throws SmackException
|
||||
*/
|
||||
@Override
|
||||
public PacketExtension parse(XmlPullParser parser, int initialDepth)
|
||||
public ExtensionElement parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
PacketExtension pepItem = null;
|
||||
ExtensionElement pepItem = null;
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
|
@ -72,7 +72,7 @@ public class PEPProvider extends PacketExtensionProvider<PacketExtension> {
|
|||
// Figure out the node for this event.
|
||||
String node = parser.getAttributeValue("", "node");
|
||||
// Get the parser for this kind of node, and if found then parse the node.
|
||||
PacketExtensionProvider<?> nodeParser = nodeParsers.get(node);
|
||||
ExtensionElementProvider<?> nodeParser = nodeParsers.get(node);
|
||||
if (nodeParser != null) {
|
||||
pepItem = nodeParser.parse(parser);
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -118,7 +118,7 @@ public class PingManager extends Manager {
|
|||
|
||||
private PingManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
executorService = new ScheduledThreadPoolExecutor(1,
|
||||
executorService = Executors.newSingleThreadScheduledExecutor(
|
||||
new SmackExecutorThreadFactory(connection.getConnectionCounter(), "Ping"));
|
||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
sdm.addFeature(Ping.NAMESPACE);
|
||||
|
|
|
@ -29,14 +29,14 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.IQResultReplyFilter;
|
||||
import org.jivesoftware.smack.filter.IQTypeFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -65,9 +65,9 @@ import org.jivesoftware.smackx.privacy.packet.PrivacyItem;
|
|||
public class PrivacyListManager extends Manager {
|
||||
public static final String NAMESPACE = Privacy.NAMESPACE;
|
||||
|
||||
public static final PacketFilter PRIVACY_FILTER = new PacketTypeFilter(Privacy.class);
|
||||
public static final StanzaFilter PRIVACY_FILTER = new StanzaTypeFilter(Privacy.class);
|
||||
|
||||
private static final PacketFilter PRIVACY_RESULT = new AndFilter(IQTypeFilter.RESULT, PRIVACY_FILTER);
|
||||
private static final StanzaFilter PRIVACY_RESULT = new AndFilter(IQTypeFilter.RESULT, PRIVACY_FILTER);
|
||||
|
||||
// Keep the list of instances of this class.
|
||||
private static final Map<XMPPConnection, PrivacyListManager> INSTANCES = new WeakHashMap<XMPPConnection, PrivacyListManager>();
|
||||
|
@ -123,15 +123,15 @@ public class PrivacyListManager extends Manager {
|
|||
});
|
||||
|
||||
// cached(Active|Default)ListName handling
|
||||
connection.addPacketSendingListener(new PacketListener() {
|
||||
connection.addPacketSendingListener(new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
XMPPConnection connection = connection();
|
||||
Privacy privacy = (Privacy) packet;
|
||||
PacketFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection);
|
||||
StanzaFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection);
|
||||
final String activeListName = privacy.getActiveName();
|
||||
final boolean declinceActiveList = privacy.isDeclineActiveList();
|
||||
connection.addOneTimeSyncCallback(new PacketListener() {
|
||||
connection.addOneTimeSyncCallback(new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
if (declinceActiveList) {
|
||||
|
@ -145,15 +145,15 @@ public class PrivacyListManager extends Manager {
|
|||
}, iqResultReplyFilter);
|
||||
}
|
||||
}, SetActiveListFilter.INSTANCE);
|
||||
connection.addPacketSendingListener(new PacketListener() {
|
||||
connection.addPacketSendingListener(new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
XMPPConnection connection = connection();
|
||||
Privacy privacy = (Privacy) packet;
|
||||
PacketFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection);
|
||||
StanzaFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection);
|
||||
final String defaultListName = privacy.getDefaultName();
|
||||
final boolean declinceDefaultList = privacy.isDeclineDefaultList();
|
||||
connection.addOneTimeSyncCallback(new PacketListener() {
|
||||
connection.addOneTimeSyncCallback(new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
if (declinceDefaultList) {
|
||||
|
@ -167,7 +167,7 @@ public class PrivacyListManager extends Manager {
|
|||
}, iqResultReplyFilter);
|
||||
}
|
||||
}, SetDefaultListFilter.INSTANCE);
|
||||
connection.addSyncPacketListener(new PacketListener() {
|
||||
connection.addSyncStanzaListener(new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
Privacy privacy = (Privacy) packet;
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.privacy.filter;
|
||||
|
||||
import org.jivesoftware.smack.filter.FlexiblePacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smackx.privacy.packet.Privacy;
|
||||
|
||||
public class SetActiveListFilter extends FlexiblePacketTypeFilter<Privacy> {
|
||||
public class SetActiveListFilter extends FlexibleStanzaTypeFilter<Privacy> {
|
||||
|
||||
public static final SetActiveListFilter INSTANCE = new SetActiveListFilter();
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.privacy.filter;
|
||||
|
||||
import org.jivesoftware.smack.filter.FlexiblePacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smackx.privacy.packet.Privacy;
|
||||
|
||||
public class SetDefaultListFilter extends FlexiblePacketTypeFilter<Privacy> {
|
||||
public class SetDefaultListFilter extends FlexibleStanzaTypeFilter<Privacy> {
|
||||
|
||||
public static final SetDefaultListFilter INSTANCE = new SetDefaultListFilter();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* Represents a affiliation between a user and a node, where the {@link #type} defines
|
||||
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.packet.PacketExtension;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class Affiliation implements PacketExtension
|
||||
public class Affiliation implements ExtensionElement
|
||||
{
|
||||
protected String node;
|
||||
protected Type type;
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* Represents the <b>configuration</b> element of a pubsub message event which
|
||||
|
@ -49,11 +49,11 @@ public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketE
|
|||
return form;
|
||||
}
|
||||
|
||||
public List<PacketExtension> getExtensions()
|
||||
public List<ExtensionElement> getExtensions()
|
||||
{
|
||||
if (getConfiguration() == null)
|
||||
return Collections.emptyList();
|
||||
else
|
||||
return Arrays.asList(((PacketExtension)getConfiguration().getDataFormToSend()));
|
||||
return Arrays.asList(((ExtensionElement)getConfiguration().getDataFormToSend()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ package org.jivesoftware.smackx.pubsub;
|
|||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
/**
|
||||
* This interface defines {@link PacketExtension} implementations that contain other
|
||||
* This interface defines {@link ExtensionElement} implementations that contain other
|
||||
* extensions. This effectively extends the idea of an extension within one of the
|
||||
* top level {@link Stanza} types to consider any embedded element to be an extension
|
||||
* of its parent. This more easily enables the usage of some of Smacks parsing
|
||||
|
@ -37,12 +37,12 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public interface EmbeddedPacketExtension extends PacketExtension
|
||||
public interface EmbeddedPacketExtension extends ExtensionElement
|
||||
{
|
||||
/**
|
||||
* Get the list of embedded {@link PacketExtension} objects.
|
||||
* Get the list of embedded {@link ExtensionElement} objects.
|
||||
*
|
||||
* @return List of embedded {@link PacketExtension}
|
||||
* @return List of embedded {@link ExtensionElement}
|
||||
*/
|
||||
List<PacketExtension> getExtensions();
|
||||
List<ExtensionElement> getExtensions();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
|
||||
/**
|
||||
|
@ -46,9 +46,9 @@ public class EventElement implements EmbeddedPacketExtension
|
|||
return type;
|
||||
}
|
||||
|
||||
public List<PacketExtension> getExtensions()
|
||||
public List<ExtensionElement> getExtensions()
|
||||
{
|
||||
return Arrays.asList(new PacketExtension[]{getEvent()});
|
||||
return Arrays.asList(new ExtensionElement[]{getEvent()});
|
||||
}
|
||||
|
||||
public NodeExtension getEvent()
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.pubsub;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* This class is used to for multiple purposes.
|
||||
|
@ -36,7 +36,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
|
|||
{
|
||||
protected ItemsElementType type;
|
||||
protected Boolean notify;
|
||||
protected List<? extends PacketExtension> items;
|
||||
protected List<? extends ExtensionElement> items;
|
||||
|
||||
public enum ItemsElementType
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
|
|||
* @param nodeId The node to which the items are being sent or deleted
|
||||
* @param items The list of {@link Item} or {@link RetractItem}
|
||||
*/
|
||||
public ItemsExtension(ItemsElementType itemsType, String nodeId, List<? extends PacketExtension> items)
|
||||
public ItemsExtension(ItemsElementType itemsType, String nodeId, List<? extends ExtensionElement> items)
|
||||
{
|
||||
super(itemsType.getNodeElement(), nodeId);
|
||||
type = itemsType;
|
||||
|
@ -106,7 +106,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
|
|||
* @param nodeId The node to which the items are being sent or deleted
|
||||
* @param items The list of {@link Item} or {@link RetractItem}
|
||||
*/
|
||||
public ItemsExtension(String nodeId, List<? extends PacketExtension> items, boolean notify)
|
||||
public ItemsExtension(String nodeId, List<? extends ExtensionElement> items, boolean notify)
|
||||
{
|
||||
super(ItemsElementType.retract.getNodeElement(), nodeId);
|
||||
type = ItemsElementType.retract;
|
||||
|
@ -125,9 +125,9 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<PacketExtension> getExtensions()
|
||||
public List<ExtensionElement> getExtensions()
|
||||
{
|
||||
return (List<PacketExtension>)getItems();
|
||||
return (List<ExtensionElement>)getItems();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,7 +135,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
|
|||
*
|
||||
* return List of {@link Item}, {@link RetractItem}, or null
|
||||
*/
|
||||
public List<? extends PacketExtension> getItems()
|
||||
public List<? extends ExtensionElement> getItems()
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
|
|||
else
|
||||
{
|
||||
builder.append("'>");
|
||||
for (PacketExtension item : items)
|
||||
for (ExtensionElement item : items)
|
||||
{
|
||||
builder.append(item.toXML());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class LeafNode extends Node
|
|||
*/
|
||||
public <T extends Item> List<T> getItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
||||
{
|
||||
return getItems((List<PacketExtension>) null, (List<PacketExtension>) null);
|
||||
return getItems((List<ExtensionElement>) null, (List<ExtensionElement>) null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,8 +176,8 @@ public class LeafNode extends Node
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public <T extends Item> List<T> getItems(List<PacketExtension> additionalExtensions,
|
||||
List<PacketExtension> returnedExtensions) throws NoResponseException,
|
||||
public <T extends Item> List<T> getItems(List<ExtensionElement> additionalExtensions,
|
||||
List<ExtensionElement> returnedExtensions) throws NoResponseException,
|
||||
XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId()));
|
||||
request.addExtensions(additionalExtensions);
|
||||
|
@ -191,7 +191,7 @@ public class LeafNode extends Node
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends Item> List<T> getItems(PubSub request,
|
||||
List<PacketExtension> returnedExtensions) throws NoResponseException,
|
||||
List<ExtensionElement> returnedExtensions) throws NoResponseException,
|
||||
XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub result = con.createPacketCollectorAndSend(request).nextResultOrThrow();
|
||||
ItemsExtension itemsElem = result.getExtension(PubSubElementType.ITEMS);
|
||||
|
@ -219,7 +219,7 @@ public class LeafNode extends Node
|
|||
{
|
||||
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
|
||||
|
||||
con.sendPacket(packet);
|
||||
con.sendStanza(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,7 +266,7 @@ public class LeafNode extends Node
|
|||
{
|
||||
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
|
||||
|
||||
con.sendPacket(packet);
|
||||
con.sendStanza(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,16 +21,16 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.OrFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smackx.delay.DelayInformationManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
|
@ -51,9 +51,9 @@ abstract public class Node
|
|||
protected String id;
|
||||
protected Jid to;
|
||||
|
||||
protected ConcurrentHashMap<ItemEventListener<Item>, PacketListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, PacketListener>();
|
||||
protected ConcurrentHashMap<ItemDeleteListener, PacketListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, PacketListener>();
|
||||
protected ConcurrentHashMap<NodeConfigListener, PacketListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, PacketListener>();
|
||||
protected ConcurrentHashMap<ItemEventListener<Item>, StanzaListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, StanzaListener>();
|
||||
protected ConcurrentHashMap<ItemDeleteListener, StanzaListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, StanzaListener>();
|
||||
protected ConcurrentHashMap<NodeConfigListener, StanzaListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, StanzaListener>();
|
||||
|
||||
/**
|
||||
* Construct a node associated to the supplied connection with the specified
|
||||
|
@ -170,7 +170,7 @@ abstract public class Node
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public List<Subscription> getSubscriptions(List<PacketExtension> additionalExtensions, Collection<PacketExtension> returnedExtensions)
|
||||
public List<Subscription> getSubscriptions(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
return getSubscriptions(additionalExtensions, returnedExtensions, null);
|
||||
}
|
||||
|
@ -214,18 +214,18 @@ abstract public class Node
|
|||
* Retrieve Subscriptions List</a>
|
||||
* @since 4.1
|
||||
*/
|
||||
public List<Subscription> getSubscriptionsAsOwner(List<PacketExtension> additionalExtensions,
|
||||
Collection<PacketExtension> returnedExtensions) throws NoResponseException, XMPPErrorException,
|
||||
public List<Subscription> getSubscriptionsAsOwner(List<ExtensionElement> additionalExtensions,
|
||||
Collection<ExtensionElement> returnedExtensions) throws NoResponseException, XMPPErrorException,
|
||||
NotConnectedException, InterruptedException {
|
||||
return getSubscriptions(additionalExtensions, returnedExtensions, PubSubNamespace.OWNER);
|
||||
}
|
||||
|
||||
private List<Subscription> getSubscriptions(List<PacketExtension> additionalExtensions,
|
||||
Collection<PacketExtension> returnedExtensions, PubSubNamespace pubSubNamespace)
|
||||
private List<Subscription> getSubscriptions(List<ExtensionElement> additionalExtensions,
|
||||
Collection<ExtensionElement> returnedExtensions, PubSubNamespace pubSubNamespace)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()), pubSubNamespace);
|
||||
if (additionalExtensions != null) {
|
||||
for (PacketExtension pe : additionalExtensions) {
|
||||
for (ExtensionElement pe : additionalExtensions) {
|
||||
pubSub.addExtension(pe);
|
||||
}
|
||||
}
|
||||
|
@ -267,11 +267,12 @@ abstract public class Node
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public List<Affiliation> getAffiliations(List<PacketExtension> additionalExtensions, Collection<PacketExtension> returnedExtensions)
|
||||
public List<Affiliation> getAffiliations(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
|
||||
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS, getId()));
|
||||
if (additionalExtensions != null) {
|
||||
for (PacketExtension pe : additionalExtensions) {
|
||||
for (ExtensionElement pe : additionalExtensions) {
|
||||
pubSub.addExtension(pe);
|
||||
}
|
||||
}
|
||||
|
@ -413,9 +414,9 @@ abstract public class Node
|
|||
@SuppressWarnings("unchecked")
|
||||
public void addItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener)
|
||||
{
|
||||
PacketListener conListener = new ItemEventTranslator(listener);
|
||||
StanzaListener conListener = new ItemEventTranslator(listener);
|
||||
itemEventToListenerMap.put(listener, conListener);
|
||||
con.addSyncPacketListener(conListener, new EventContentFilter(EventElementType.items.toString(), "item"));
|
||||
con.addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.items.toString(), "item"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -425,10 +426,10 @@ abstract public class Node
|
|||
*/
|
||||
public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener)
|
||||
{
|
||||
PacketListener conListener = itemEventToListenerMap.remove(listener);
|
||||
StanzaListener conListener = itemEventToListenerMap.remove(listener);
|
||||
|
||||
if (conListener != null)
|
||||
con.removeSyncPacketListener(conListener);
|
||||
con.removeSyncStanzaListener(conListener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -439,9 +440,9 @@ abstract public class Node
|
|||
*/
|
||||
public void addConfigurationListener(NodeConfigListener listener)
|
||||
{
|
||||
PacketListener conListener = new NodeConfigTranslator(listener);
|
||||
StanzaListener conListener = new NodeConfigTranslator(listener);
|
||||
configEventToListenerMap.put(listener, conListener);
|
||||
con.addSyncPacketListener(conListener, new EventContentFilter(EventElementType.configuration.toString()));
|
||||
con.addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.configuration.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -451,10 +452,10 @@ abstract public class Node
|
|||
*/
|
||||
public void removeConfigurationListener(NodeConfigListener listener)
|
||||
{
|
||||
PacketListener conListener = configEventToListenerMap .remove(listener);
|
||||
StanzaListener conListener = configEventToListenerMap .remove(listener);
|
||||
|
||||
if (conListener != null)
|
||||
con.removeSyncPacketListener(conListener);
|
||||
con.removeSyncStanzaListener(conListener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -465,12 +466,12 @@ abstract public class Node
|
|||
*/
|
||||
public void addItemDeleteListener(ItemDeleteListener listener)
|
||||
{
|
||||
PacketListener delListener = new ItemDeleteTranslator(listener);
|
||||
StanzaListener delListener = new ItemDeleteTranslator(listener);
|
||||
itemDeleteToListenerMap.put(listener, delListener);
|
||||
EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract");
|
||||
EventContentFilter purge = new EventContentFilter(EventElementType.purge.toString());
|
||||
|
||||
con.addSyncPacketListener(delListener, new OrFilter(deleteItem, purge));
|
||||
con.addSyncStanzaListener(delListener, new OrFilter(deleteItem, purge));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -480,10 +481,10 @@ abstract public class Node
|
|||
*/
|
||||
public void removeItemDeleteListener(ItemDeleteListener listener)
|
||||
{
|
||||
PacketListener conListener = itemDeleteToListenerMap .remove(listener);
|
||||
StanzaListener conListener = itemDeleteToListenerMap .remove(listener);
|
||||
|
||||
if (conListener != null)
|
||||
con.removeSyncPacketListener(conListener);
|
||||
con.removeSyncStanzaListener(conListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -492,12 +493,12 @@ abstract public class Node
|
|||
return super.toString() + " " + getClass().getName() + " id: " + id;
|
||||
}
|
||||
|
||||
protected PubSub createPubsubPacket(Type type, PacketExtension ext)
|
||||
protected PubSub createPubsubPacket(Type type, ExtensionElement ext)
|
||||
{
|
||||
return createPubsubPacket(type, ext, null);
|
||||
}
|
||||
|
||||
protected PubSub createPubsubPacket(Type type, PacketExtension ext, PubSubNamespace ns)
|
||||
protected PubSub createPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns)
|
||||
{
|
||||
return PubSub.createPubsubPacket(to, type, ext, ns);
|
||||
}
|
||||
|
@ -531,7 +532,7 @@ abstract public class Node
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class ItemEventTranslator implements PacketListener
|
||||
public class ItemEventTranslator implements StanzaListener
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
private ItemEventListener listener;
|
||||
|
@ -557,7 +558,7 @@ abstract public class Node
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class ItemDeleteTranslator implements PacketListener
|
||||
public class ItemDeleteTranslator implements StanzaListener
|
||||
{
|
||||
private ItemDeleteListener listener;
|
||||
|
||||
|
@ -570,7 +571,7 @@ abstract public class Node
|
|||
{
|
||||
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
|
||||
|
||||
List<PacketExtension> extList = event.getExtensions();
|
||||
List<ExtensionElement> extList = event.getExtensions();
|
||||
|
||||
if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName()))
|
||||
{
|
||||
|
@ -600,7 +601,7 @@ abstract public class Node
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class NodeConfigTranslator implements PacketListener
|
||||
public class NodeConfigTranslator implements StanzaListener
|
||||
{
|
||||
private NodeConfigListener listener;
|
||||
|
||||
|
@ -619,12 +620,12 @@ abstract public class Node
|
|||
}
|
||||
|
||||
/**
|
||||
* Filter for {@link PacketListener} to filter out events not specific to the
|
||||
* Filter for {@link StanzaListener} to filter out events not specific to the
|
||||
* event type expected for this node.
|
||||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
class EventContentFilter implements PacketFilter
|
||||
class EventContentFilter implements StanzaFilter
|
||||
{
|
||||
private String firstElement;
|
||||
private String secondElement;
|
||||
|
@ -665,7 +666,7 @@ abstract public class Node
|
|||
|
||||
if (embedEvent instanceof EmbeddedPacketExtension)
|
||||
{
|
||||
List<PacketExtension> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
|
||||
List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
|
||||
|
||||
if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement))
|
||||
return true;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* A class which represents a common element within the pubsub defined
|
||||
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.packet.PacketExtension;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class NodeExtension implements PacketExtension
|
||||
public class NodeExtension implements ExtensionElement
|
||||
{
|
||||
private final PubSubElementType element;
|
||||
private final String node;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
|
||||
|
||||
/**
|
||||
|
@ -43,14 +43,14 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class PayloadItem<E extends PacketExtension> extends Item
|
||||
public class PayloadItem<E extends ExtensionElement> extends Item
|
||||
{
|
||||
private E payload;
|
||||
|
||||
/**
|
||||
* Create an <tt>Item</tt> with no id and a payload The id will be set by the server.
|
||||
*
|
||||
* @param payloadExt A {@link PacketExtension} which represents the payload data.
|
||||
* @param payloadExt A {@link ExtensionElement} which represents the payload data.
|
||||
*/
|
||||
public PayloadItem(E payloadExt)
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ public class PayloadItem<E extends PacketExtension> extends Item
|
|||
* Create an <tt>Item</tt> with an id and payload.
|
||||
*
|
||||
* @param itemId The id of this item. It can be null if we want the server to set the id.
|
||||
* @param payloadExt A {@link PacketExtension} which represents the payload data.
|
||||
* @param payloadExt A {@link ExtensionElement} which represents the payload data.
|
||||
*/
|
||||
public PayloadItem(String itemId, E payloadExt)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ public class PayloadItem<E extends PacketExtension> extends Item
|
|||
*
|
||||
* @param itemId The id of this item.
|
||||
* @param nodeId The id of the node the item was published to.
|
||||
* @param payloadExt A {@link PacketExtension} which represents the payload data.
|
||||
* @param payloadExt A {@link ExtensionElement} which represents the payload data.
|
||||
*/
|
||||
public PayloadItem(String itemId, String nodeId, E payloadExt)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ public class PayloadItem<E extends PacketExtension> extends Item
|
|||
* Get the payload associated with this <tt>Item</tt>. Customising the payload
|
||||
* parsing from the server can be accomplished as described in {@link ItemProvider}.
|
||||
*
|
||||
* @return The payload as a {@link PacketExtension}.
|
||||
* @return The payload as a {@link ExtensionElement}.
|
||||
*/
|
||||
public E getPayload()
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.packet.EmptyResultIQ;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
|
@ -314,15 +314,15 @@ final public class PubSubManager
|
|||
return mgr.discoverInfo(to);
|
||||
}
|
||||
|
||||
private PubSub sendPubsubPacket(Type type, PacketExtension ext, PubSubNamespace ns)
|
||||
private PubSub sendPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
return sendPubsubPacket(con, to, type, Collections.singletonList(ext), ns);
|
||||
}
|
||||
|
||||
static PubSub sendPubsubPacket(XMPPConnection con, Jid to, Type type, List<PacketExtension> extList, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
||||
static PubSub sendPubsubPacket(XMPPConnection con, Jid to, Type type, List<ExtensionElement> extList, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
||||
{
|
||||
PubSub pubSub = new PubSub(to, type, ns);
|
||||
for (PacketExtension pe : extList) {
|
||||
for (ExtensionElement pe : extList) {
|
||||
pubSub.addExtension(pe);
|
||||
}
|
||||
return sendPubsubPacket(con ,pubSub);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class RetractItem implements PacketExtension
|
||||
public class RetractItem implements ExtensionElement
|
||||
{
|
||||
private String id;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* The default payload representation for {@link PayloadItem#getPayload()}. It simply
|
||||
|
@ -24,7 +24,7 @@ import org.jivesoftware.smack.packet.PacketExtension;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class SimplePayload implements PacketExtension
|
||||
public class SimplePayload implements ExtensionElement
|
||||
{
|
||||
private final String elemName;
|
||||
private final String ns;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.pubsub.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.pubsub.PubSubElementType;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class PubSub extends IQ
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <PE extends PacketExtension> PE getExtension(PubSubElementType elem)
|
||||
public <PE extends ExtensionElement> PE getExtension(PubSubElementType elem)
|
||||
{
|
||||
return (PE) getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class PubSub extends IQ
|
|||
return xml;
|
||||
}
|
||||
|
||||
public static PubSub createPubsubPacket(Jid to, Type type, PacketExtension extension, PubSubNamespace ns) {
|
||||
public static PubSub createPubsubPacket(Jid to, Type type, ExtensionElement extension, PubSubNamespace ns) {
|
||||
PubSub pubSub = new PubSub(to, type, ns);
|
||||
pubSub.addExtension(extension);
|
||||
return pubSub;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.Affiliation;
|
||||
|
||||
|
@ -32,7 +32,7 @@ import org.jivesoftware.smackx.pubsub.Affiliation;
|
|||
public class AffiliationProvider extends EmbeddedExtensionProvider<Affiliation>
|
||||
{
|
||||
@Override
|
||||
protected Affiliation createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected Affiliation createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
return new Affiliation(attributeMap.get("node"), Affiliation.Type.valueOf(attributeMap.get("affiliation")));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.Affiliation;
|
||||
import org.jivesoftware.smackx.pubsub.AffiliationsExtension;
|
||||
|
@ -33,7 +33,7 @@ import org.jivesoftware.smackx.pubsub.AffiliationsExtension;
|
|||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected AffiliationsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected AffiliationsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
return new AffiliationsExtension((List<Affiliation>)content);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.ConfigurationEvent;
|
||||
import org.jivesoftware.smackx.pubsub.ConfigureForm;
|
||||
|
@ -34,7 +34,7 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
|||
public class ConfigEventProvider extends EmbeddedExtensionProvider<ConfigurationEvent>
|
||||
{
|
||||
@Override
|
||||
protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content)
|
||||
protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
if (content.size() == 0)
|
||||
return new ConfigurationEvent(attMap.get("node"));
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.EventElement;
|
||||
import org.jivesoftware.smackx.pubsub.EventElementType;
|
||||
|
@ -34,7 +34,7 @@ import org.jivesoftware.smackx.pubsub.NodeExtension;
|
|||
public class EventProvider extends EmbeddedExtensionProvider<EventElement>
|
||||
{
|
||||
@Override
|
||||
protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content)
|
||||
protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
return new EventElement(EventElementType.valueOf(content.get(0).getElementName()), (NodeExtension)content.get(0));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.FormNode;
|
||||
import org.jivesoftware.smackx.pubsub.FormNodeType;
|
||||
|
@ -35,7 +35,7 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
|||
public class FormNodeProvider extends EmbeddedExtensionProvider<FormNode>
|
||||
{
|
||||
@Override
|
||||
protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), new Form((DataForm)content.iterator().next()));
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.pubsub.Item;
|
||||
|
@ -33,12 +33,12 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
/**
|
||||
* Parses an <b>item</b> element as is defined in both the {@link PubSubNamespace#BASIC} and
|
||||
* {@link PubSubNamespace#EVENT} namespaces. To parse the item contents, it will use whatever
|
||||
* {@link PacketExtensionProvider} is registered in <b>smack.providers</b> for its element name and namespace. If no
|
||||
* {@link ExtensionElementProvider} is registered in <b>smack.providers</b> for its element name and namespace. If no
|
||||
* provider is registered, it will return a {@link SimplePayload}.
|
||||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class ItemProvider extends PacketExtensionProvider<Item>
|
||||
public class ItemProvider extends ExtensionElementProvider<Item>
|
||||
{
|
||||
@Override
|
||||
public Item parse(XmlPullParser parser, int initialDepth)
|
||||
|
@ -57,7 +57,7 @@ public class ItemProvider extends PacketExtensionProvider<Item>
|
|||
String payloadElemName = parser.getName();
|
||||
String payloadNS = parser.getNamespace();
|
||||
|
||||
final PacketExtensionProvider<PacketExtension> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS);
|
||||
final ExtensionElementProvider<ExtensionElement> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS);
|
||||
if (extensionProvider == null)
|
||||
{
|
||||
CharSequence payloadText = PacketParserUtils.parseElement(parser, true);
|
||||
|
@ -65,7 +65,7 @@ public class ItemProvider extends PacketExtensionProvider<Item>
|
|||
}
|
||||
else
|
||||
{
|
||||
return new PayloadItem<PacketExtension>(id, node, extensionProvider.parse(parser));
|
||||
return new PayloadItem<ExtensionElement>(id, node, extensionProvider.parse(parser));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.ItemsExtension;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class ItemsProvider extends EmbeddedExtensionProvider<ItemsExtension>
|
|||
{
|
||||
|
||||
@Override
|
||||
protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
return new ItemsExtension(ItemsExtension.ItemsElementType.items, attributeMap.get("node"), content);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class PubSubProvider extends IQProvider<PubSub>
|
|||
int eventType = parser.next();
|
||||
switch (eventType) {
|
||||
case XmlPullParser.START_TAG:
|
||||
PacketParserUtils.addPacketExtension(pubsub, parser);
|
||||
PacketParserUtils.addExtensionElement(pubsub, parser);
|
||||
break;
|
||||
case XmlPullParser.END_TAG:
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.RetractItem;
|
||||
|
||||
|
@ -33,7 +33,7 @@ import org.jivesoftware.smackx.pubsub.RetractItem;
|
|||
public class RetractEventProvider extends EmbeddedExtensionProvider<RetractItem>
|
||||
{
|
||||
@Override
|
||||
protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
return new RetractItem(attributeMap.get("id"));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.NodeExtension;
|
||||
import org.jivesoftware.smackx.pubsub.PubSubElementType;
|
||||
|
@ -33,7 +33,7 @@ import org.jivesoftware.smackx.pubsub.PubSubElementType;
|
|||
public class SimpleNodeProvider extends EmbeddedExtensionProvider<NodeExtension>
|
||||
{
|
||||
@Override
|
||||
protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
return new NodeExtension(PubSubElementType.valueOfFromElemName(currentElement, currentNamespace), attributeMap.get("node"));
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.pubsub.Subscription;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -29,7 +29,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class SubscriptionProvider extends PacketExtensionProvider<Subscription>
|
||||
public class SubscriptionProvider extends ExtensionElementProvider<Subscription>
|
||||
{
|
||||
@Override
|
||||
public Subscription parse(XmlPullParser parser, int initialDepth)
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.Subscription;
|
||||
import org.jivesoftware.smackx.pubsub.SubscriptionsExtension;
|
||||
|
@ -34,7 +34,7 @@ public class SubscriptionsProvider extends EmbeddedExtensionProvider<Subscriptio
|
|||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>)content);
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.jivesoftware.smackx.receipts;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
*
|
||||
* @author Georg Lukas
|
||||
*/
|
||||
public class DeliveryReceipt implements PacketExtension
|
||||
public class DeliveryReceipt implements ExtensionElement
|
||||
{
|
||||
public static final String NAMESPACE = "urn:xmpp:receipts";
|
||||
public static final String ELEMENT = "received";
|
||||
|
@ -76,21 +76,21 @@ public class DeliveryReceipt implements PacketExtension
|
|||
*
|
||||
* @param p the packet
|
||||
* @return the {@link DeliveryReceipt} extension or {@code null}
|
||||
* @deprecated use {@link #from(Stanza)} instead
|
||||
* @deprecated use {@link #from(Message)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static DeliveryReceipt getFrom(Stanza p) {
|
||||
public static DeliveryReceipt getFrom(Message p) {
|
||||
return from(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link DeliveryReceipt} extension of the packet, if any.
|
||||
* Get the {@link DeliveryReceipt} extension of the message, if any.
|
||||
*
|
||||
* @param packet the packet
|
||||
* @param message the message.
|
||||
* @return the {@link DeliveryReceipt} extension or {@code null}
|
||||
*/
|
||||
public static DeliveryReceipt from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
public static DeliveryReceipt from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,7 +101,7 @@ public class DeliveryReceipt implements PacketExtension
|
|||
|
||||
@Override
|
||||
protected DeliveryReceipt createReturnExtension(String currentElement, String currentNamespace,
|
||||
Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
Map<String, String> attributeMap, List<? extends ExtensionElement> content)
|
||||
{
|
||||
return new DeliveryReceipt(attributeMap.get("id"));
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue