From 0fae7a26c2a52c86c4091c49c63d554534a101ff Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 21 Feb 2015 17:20:47 +0100 Subject: [PATCH 01/30] Samck 4.1.0-rc3-SNAPSHOT --- version.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.gradle b/version.gradle index 4ad04179b..c6e700712 100644 --- a/version.gradle +++ b/version.gradle @@ -1,7 +1,7 @@ allprojects { ext { - shortVersion = '4.1.0-rc2' - isSnapshot = false + shortVersion = '4.1.0-rc3' + isSnapshot = true jxmppVersion = '0.4.2-beta1' smackMinAndroidSdk = 8 } From 8b0ccd742068dd887a8dfd6ca2cf4e188eeb074f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 22 Feb 2015 10:33:08 +0100 Subject: [PATCH 02/30] Minor javadoc fixes and improvements --- .../org/jivesoftware/smack/filter/PacketIDFilter.java | 4 ++-- .../org/jivesoftware/smack/tcp/BundleAndDefer.java | 8 ++++++++ .../org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 11 +++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java index 11796a0ab..e51d9c156 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java @@ -35,7 +35,7 @@ public class PacketIDFilter implements PacketFilter { * Creates a new packet ID filter using the specified packet's ID. * * @param packet the packet which the ID is taken from. - * @deprecated use {@link StanzaIdfilter(Stanza)} instead. + * @deprecated use {@link StanzaIdFilter#StanzaIdFilter(Stanza)} instead. */ @Deprecated public PacketIDFilter(Stanza packet) { @@ -46,7 +46,7 @@ public class PacketIDFilter implements PacketFilter { * Creates a new packet ID filter using the specified packet ID. * * @param packetID the packet ID to filter for. - * @deprecated use {@link StanzaIdFilter(String)} instead. + * @deprecated use {@link StanzaIdFilter#StanzaIdFilter(Stanza)} instead. */ @Deprecated public PacketIDFilter(String packetID) { diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/BundleAndDefer.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/BundleAndDefer.java index ad899f9e5..8fb585541 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/BundleAndDefer.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/BundleAndDefer.java @@ -27,6 +27,14 @@ public class BundleAndDefer { this.isStopped = isStopped; } + /** + * Stop the bundle and defer mechanism that was started when this instance of {@link BundleAndDefer} was emitted by + * Smack. + *

+ * It is possible that the defer period already expired when this is invoked. In this case this method is basically + * a no-op. + *

+ */ public void stopCurrentBundleAndDefer() { synchronized (isStopped) { if (isStopped.get()) { diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index f8852f1ad..774a5e24c 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -185,8 +185,19 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { private final SynchronizationPoint compressSyncPoint = new SynchronizationPoint( this); + /** + * The default bundle and defer callback, used for new connections. + * @see bundleAndDeferCallback + */ private static BundleAndDeferCallback defaultBundleAndDeferCallback; + /** + * The used bundle and defer callback. + *

+ * Although this field may be set concurrently, the 'volatile' keyword was deliberately not added, in order to avoid + * having a 'volatile' read within the writer threads loop. + *

+ */ private BundleAndDeferCallback bundleAndDeferCallback = defaultBundleAndDeferCallback; private static boolean useSmDefault = false; From 90969e252a9f4effa9591fc859908228a823d4ad Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 22 Feb 2015 10:44:22 +0100 Subject: [PATCH 03/30] Improve the bundle and defer mechanism Instead of always bundling when the queue is empty, only bundle once the queue has become empty and then only if it has been become empty again. The previous algorithm would also bundle and defer the last element found in the queue. This is not the case now. --- .../smack/tcp/BundleAndDeferCallback.java | 2 +- .../smack/tcp/XMPPTCPConnection.java | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/BundleAndDeferCallback.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/BundleAndDeferCallback.java index 5102b0019..050a16485 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/BundleAndDeferCallback.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/BundleAndDeferCallback.java @@ -20,7 +20,7 @@ package org.jivesoftware.smack.tcp; * This callback is used to get the current value of the period in which Smack does bundle and defer * outgoing stanzas. *

- * Smack will bundle and defer stanzas if the connection is authenticated, the send queue is empty + * Smack will bundle and defer stanzas if the connection is authenticated * and if a bundle and defer callback is set, either via * {@link XMPPTCPConnection#setDefaultBundleAndDeferCallback(BundleAndDeferCallback)} or * {@link XMPPTCPConnection#setBundleandDeferCallback(BundleAndDeferCallback)}, and diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 774a5e24c..a6dc0a516 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -1177,6 +1177,16 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { private volatile boolean instantShutdown; + /** + * True if some preconditions are given to start the bundle and defer mechanism. + *

+ * This will likely get set to true right after the start of the writer thread, because + * {@link #nextStreamElement()} will check if {@link queue} is empty, which is probably the case, and then set + * this field to true. + *

+ */ + private boolean shouldBundleAndDefer; + /** * Initializes the writer in order to be used. It is called at the first connection and also * is invoked if the connection is disconnected by an error. @@ -1262,6 +1272,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * @return the next element for writing or null. */ private Element nextStreamElement() { + // It is important the we check if the queue is empty before removing an element from it + if (queue.isEmpty()) { + shouldBundleAndDefer = true; + } Element packet = null; try { packet = queue.take(); @@ -1292,7 +1306,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // If the preconditions are given (e.g. bundleAndDefer callback is set, queue is // empty), then we could wait a bit for further stanzas attempting to decrease // our energy consumption - if (localBundleAndDeferCallback != null && isAuthenticated() && queue.isEmpty()) { + if (localBundleAndDeferCallback != null && isAuthenticated() && shouldBundleAndDefer) { + // Reset shouldBundleAndDefer to false, nextStreamElement() will set it to true once the + // queue is empty again. + shouldBundleAndDefer = false; final AtomicBoolean bundlingAndDeferringStopped = new AtomicBoolean(); final int bundleAndDeferMillis = localBundleAndDeferCallback.getBundleAndDeferMillis(new BundleAndDefer( bundlingAndDeferringStopped)); From 180a3bb4cacb62aa940a417983759e5117b0a65f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 23 Feb 2015 08:49:30 +0100 Subject: [PATCH 04/30] Fix SASL X-OAUTH2: Use Base64.encode() instead of decode() --- .../org/jivesoftware/smack/sasl/core/SASLXOauth2Mechanism.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/sasl/core/SASLXOauth2Mechanism.java b/smack-core/src/main/java/org/jivesoftware/smack/sasl/core/SASLXOauth2Mechanism.java index 1387fad90..a271f01a7 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/sasl/core/SASLXOauth2Mechanism.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/sasl/core/SASLXOauth2Mechanism.java @@ -73,7 +73,7 @@ public class SASLXOauth2Mechanism extends SASLMechanism { @Override protected byte[] getAuthenticationText() throws SmackException { // base64("\0" + user_name + "\0" + oauth_token) - return Base64.decode('\u0000' + authenticationId + '\u0000' + password); + return Base64.encode(toBytes('\u0000' + authenticationId + '\u0000' + password)); } @Override From b74b8c57577ffb1e07c6756e09314e80b361d7fb Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 23 Feb 2015 10:48:43 +0100 Subject: [PATCH 05/30] Make Stanza constructors 'protected' --- .../src/main/java/org/jivesoftware/smack/packet/Stanza.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java index 4e341b023..bc8d3c05d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java @@ -73,15 +73,15 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { */ protected String language; - public Stanza() { + protected Stanza() { this(StanzaIdUtil.newStanzaId()); } - public Stanza(String stanzaId) { + protected Stanza(String stanzaId) { setStanzaId(stanzaId); } - public Stanza(Stanza p) { + protected Stanza(Stanza p) { id = p.getStanzaId(); to = p.getTo(); from = p.getFrom(); From afba123ba3c4048ab4212f176ed3ee7dd13d5928 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 23 Feb 2015 10:49:33 +0100 Subject: [PATCH 06/30] Javadoc improvements in MultiMap and Stanza --- .../src/main/java/org/jivesoftware/smack/packet/Stanza.java | 5 +++-- .../src/main/java/org/jivesoftware/smack/util/MultiMap.java | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java index bc8d3c05d..790b921f5 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java @@ -230,12 +230,13 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { } /** - * Returns a copy of the packet extensions attached to the packet. + * Returns a list of all extension elements of this stanza. * - * @return the packet extensions. + * @return a list of all extension elements of this stanza. */ public List getExtensions() { synchronized (packetExtensions) { + // No need to create a new list, values() will already create a new one for us return packetExtensions.values(); } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java b/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java index de5af242c..88868a0f8 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java @@ -184,6 +184,11 @@ public class MultiMap { return map.keySet(); } + /** + * Returns a new list containing all values of this multi map. + * + * @return a new list with all values. + */ public List values() { List values = new ArrayList<>(size()); for (Set set : map.values()) { From bc3bbb5bb4ce37916a9bbc4f9ebe15791025c932 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 23 Feb 2015 13:58:51 +0100 Subject: [PATCH 07/30] Set "rootProject.name = 'Smack'" in settings.gradle --- settings.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/settings.gradle b/settings.gradle index d452c94c7..d83be147e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,8 @@ +// The name of the root project. +// If we would not set the name, then gradle would use the directory +// name of the root directory +rootProject.name = 'Smack' + include 'smack-core', 'smack-im', 'smack-tcp', From e9dd3e2fa6564dd1ecf0f5923bc4babad228ec7e Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 23 Feb 2015 22:15:57 +0100 Subject: [PATCH 08/30] Add copy constructor to Message and Presence and also implement Cloneable and add clone() methods. --- .../jivesoftware/smack/packet/Message.java | 32 ++++++++++++++++++- .../jivesoftware/smack/packet/Presence.java | 32 ++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java index 22b25a810..f08c3c653 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java @@ -50,7 +50,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Matt Tucker */ -public final class Message extends Stanza { +public final class Message extends Stanza implements Cloneable { public static final String ELEMENT = "message"; public static final String BODY = "body"; @@ -98,6 +98,23 @@ public final class Message extends Stanza { setBody(body); } + /** + * Copy constructor. + *

+ * This does not perform a deep clone, as extension elements are shared between the new and old + * instance. + *

+ * + * @param other + */ + public Message(Message other) { + super(other); + this.type = other.type; + this.thread = other.thread; + this.subjects.addAll(other.subjects); + this.bodies.addAll(other.bodies); + } + /** * Returns the type of the message. If no type has been set this method will return {@link * org.jivesoftware.smack.packet.Message.Type#normal}. @@ -445,6 +462,19 @@ public final class Message extends Stanza { return buf; } + /** + * Creates and returns a copy of this message stanza. + *

+ * This does not perform a deep clone, as extension elements are shared between the new and old + * instance. + *

+ * @return a clone of this message. + */ + @Override + public Message clone() { + return new Message(this); + } + /** * Represents a message subject, its language and the content of the subject. */ diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java index 86fe029a3..7f347dd51 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java @@ -55,7 +55,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Matt Tucker */ -public final class Presence extends Stanza { +public final class Presence extends Stanza implements Cloneable { public static final String ELEMENT = "presence"; @@ -88,6 +88,23 @@ public final class Presence extends Stanza { setMode(mode); } + /** + * Copy constructor. + *

+ * This does not perform a deep clone, as extension elements are shared between the new and old + * instance. + *

+ * + * @param other + */ + public Presence(Presence other) { + super(other); + this.type = other.type; + this.status = other.status; + this.priority = other.priority; + this.mode = other.mode; + } + /** * Returns true if the {@link Type presence type} is available (online) and * false if the user is unavailable (offline), or if this is a presence packet @@ -228,6 +245,19 @@ public final class Presence extends Stanza { return buf; } + /** + * Creates and returns a copy of this presence stanza. + *

+ * This does not perform a deep clone, as extension elements are shared between the new and old + * instance. + *

+ * @return a clone of this presence. + */ + @Override + public Presence clone() { + return new Presence(this); + } + /** * An enum to represent the presence type. Note that presence type is often confused * with presence mode. Generally, if a user is signed in to a server, they have a presence From 4424ec6c53e9e2ceba30ed2f6ca81065ab1667bf Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 23 Feb 2015 22:16:49 +0100 Subject: [PATCH 09/30] Make Roster API not leak internal state Fixes SMACK-645 --- .../org/jivesoftware/smack/roster/Roster.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java index ec87ec67c..fe22360da 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java @@ -724,7 +724,7 @@ public class Roster extends Manager { } if (presence == null) { if (unavailable != null) { - return unavailable; + return unavailable.clone(); } else { presence = new Presence(Presence.Type.unavailable); @@ -733,7 +733,7 @@ public class Roster extends Manager { } } else { - return presence; + return presence.clone(); } } } @@ -764,7 +764,7 @@ public class Roster extends Manager { return presence; } else { - return presence; + return presence.clone(); } } } @@ -786,7 +786,10 @@ public class Roster extends Manager { unavailable.setFrom(bareJid); res = new ArrayList<>(Arrays.asList(unavailable)); } else { - res = new ArrayList<>(userPresences.values()); + res = new ArrayList<>(userPresences.values().size()); + for (Presence presence : userPresences.values()) { + res.add(presence.clone()); + } } return res; } @@ -803,6 +806,7 @@ public class Roster extends Manager { List res = new ArrayList<>(allPresences.size()); for (Presence presence : allPresences) { if (presence.isAvailable()) { + // No need to clone presence here, getAllPresences already returns clones res.add(presence); } } @@ -835,7 +839,7 @@ public class Roster extends Manager { Presence unavailable = null; for (Presence presence : userPresences.values()) { if (presence.isAvailable()) { - answer.add(presence); + answer.add(presence.clone()); } else { unavailable = presence; @@ -845,7 +849,7 @@ public class Roster extends Manager { res = answer; } else if (unavailable != null) { - res = Arrays.asList(unavailable); + res = Arrays.asList(unavailable.clone()); } else { Presence presence = new Presence(Presence.Type.unavailable); @@ -853,7 +857,7 @@ public class Roster extends Manager { res = Arrays.asList(presence); } } - return Collections.unmodifiableList(res); + return res; } /** From 7e68bb74701692cf131e61606eab31bf9146df72 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 23 Feb 2015 22:17:31 +0100 Subject: [PATCH 10/30] Javadoc fixes in Roster --- .../main/java/org/jivesoftware/smack/roster/Roster.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java index fe22360da..06a63392f 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java @@ -655,8 +655,8 @@ public class Roster extends Manager { /** * Returns the presence info for a particular user. If the user is offline, or * if no presence data is available (such as when you are not subscribed to the - * user's presence updates), unavailable presence will be returned.

- *

+ * user's presence updates), unavailable presence will be returned. + *

* If the user has several presences (one for each resource), then the presence with * highest priority will be returned. If multiple presences have the same priority, * the one with the "most available" presence mode will be returned. In order, @@ -665,7 +665,8 @@ public class Roster extends Manager { * {@link org.jivesoftware.smack.packet.Presence.Mode#away away}, * {@link org.jivesoftware.smack.packet.Presence.Mode#xa extended away}, and * {@link org.jivesoftware.smack.packet.Presence.Mode#dnd do not disturb}.

- *

+ *

+ *

* Note that presence information is received asynchronously. So, just after logging * in to the server, presence values for users in the roster may be unavailable * even if they are actually online. In other words, the value returned by this @@ -673,6 +674,7 @@ public class Roster extends Manager { * other user's presence instant by instant. If you need to track presence over time, * such as when showing a visual representation of the roster, consider using a * {@link RosterListener}. + *

* * @param user an XMPP ID. The address could be in any valid format (e.g. * "domain/resource", "user@domain" or "user@domain/resource"). Any resource From 9006ccf291ec6efd307f808f2fc9e136c0231136 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 23 Feb 2015 21:25:03 +0100 Subject: [PATCH 11/30] Fix VCardManager.saveVCard(VCard) In case the users tries to save a VCard he previously retrieved via loadVCard() this would previously fail, as the 'to' address is set to the clients full JID. --- .../org/jivesoftware/smackx/vcardtemp/VCardManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/VCardManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/VCardManager.java index bc7bf47eb..3aea90308 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/VCardManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/VCardManager.java @@ -27,6 +27,7 @@ import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.packet.id.StanzaIdUtil; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.vcardtemp.packet.VCard; @@ -91,7 +92,12 @@ public class VCardManager extends Manager { * @throws NotConnectedException */ public void saveVCard(VCard vcard) throws NoResponseException, XMPPErrorException, NotConnectedException { + // XEP-54 § 3.2 "A user may publish or update his or her vCard by sending an IQ of type "set" with no 'to' address…" + vcard.setTo(null); vcard.setType(IQ.Type.set); + // Also make sure to generate a new stanza id (the given vcard could be a vcard result), in which case we don't + // want to use the same stanza id again (although it wouldn't break if we did) + vcard.setStanzaId(StanzaIdUtil.newStanzaId()); connection().createPacketCollectorAndSend(vcard).nextResultOrThrow(); } From 39382b8b389fe8a5e2ba50cb1a3d298556f20264 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 25 Feb 2015 16:09:41 +0100 Subject: [PATCH 12/30] Shorten Smack's executor service names instead of "Smack Executor - Foo 42 (2)" use "Smack-Foo 42 (2)" since sometimes the space for the name is limited (e.g. busybox's 'ps -t'). --- .../jivesoftware/smack/util/SmackExecutorThreadFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/SmackExecutorThreadFactory.java b/smack-core/src/main/java/org/jivesoftware/smack/util/SmackExecutorThreadFactory.java index 5823435ff..c3c59d7f8 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/SmackExecutorThreadFactory.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/SmackExecutorThreadFactory.java @@ -1,6 +1,6 @@ /** * - * Copyright 2014 Florian Schmaus + * Copyright 2014-2015 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public final class SmackExecutorThreadFactory implements ThreadFactory { @Override public Thread newThread(Runnable runnable) { Thread thread = new Thread(runnable); - thread.setName("Smack Executor - " + name + ' ' + count++ + " (" + connectionCounterValue + ")"); + thread.setName("Smack-" + name + ' ' + count++ + " (" + connectionCounterValue + ")"); thread.setDaemon(true); return thread; } From 404b90054b19967a6623c3afb3765792c853906c Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 25 Feb 2015 16:14:16 +0100 Subject: [PATCH 13/30] Use Executors.newSingleThreadScheduledExecutor and remove the calls to setMaximumPoolSize() and steKeepAliveTime() since they are ineffective on Android. --- .../java/org/jivesoftware/smack/AbstractXMPPConnection.java | 6 ++---- .../main/java/org/jivesoftware/smackx/ping/PingManager.java | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 5e8b4928a..c7d77c850 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -33,8 +33,8 @@ import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -244,7 +244,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { /** * This scheduled thread pool executor is used to remove pending callbacks. */ - private final ScheduledThreadPoolExecutor removeCallbacksService = new ScheduledThreadPoolExecutor(1, + private final ScheduledExecutorService removeCallbacksService = Executors.newSingleThreadScheduledExecutor( new SmackExecutorThreadFactory(connectionCounterValue, "Remove Callbacks")); private static int concurrencyLevel = Runtime.getRuntime().availableProcessors() + 1; @@ -333,8 +333,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { */ protected AbstractXMPPConnection(ConnectionConfiguration configuration) { config = configuration; - removeCallbacksService.setMaximumPoolSize(concurrencyLevel); - removeCallbacksService.setKeepAliveTime(THREAD_KEEP_ALIVE_SECONDS, TimeUnit.SECONDS); } protected ConnectionConfiguration getConfiguration() { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java index 35d9d8593..30e837b82 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java @@ -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; @@ -117,7 +117,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); From 4b7a396b9b224a792cd189c477587a88c5430dfe Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 26 Feb 2015 08:27:19 +0100 Subject: [PATCH 14/30] Improve logging wrt XMPPTCPConnection.shutdownDone --- .../java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index a6dc0a516..75be75283 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -1260,7 +1260,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { shutdownDone.checkIfSuccessOrWait(); } catch (NoResponseException e) { - LOGGER.log(Level.WARNING, "NoResponseException", e); + LOGGER.log(Level.WARNING, "shutdownDone was not marked as successful by the writer thread", e); } } @@ -1406,6 +1406,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { LOGGER.log(Level.FINE, "Ignoring Exception in writePackets()", e); } } finally { + LOGGER.fine("Reporting shutdownDone success in writer thread"); shutdownDone.reportSuccess(); } } From 49e1c837b2ba19708d51d0e71ebb9bc947113683 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 26 Feb 2015 08:45:28 +0100 Subject: [PATCH 15/30] Adjust AbstractListFilter.toString() to produce a similar styled output like the other toString() methods and add unit-test for the method. --- .../smack/filter/AbstractListFilter.java | 11 +++-- .../smack/filters/FilterToStringTest.java | 42 +++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 smack-core/src/test/java/org/jivesoftware/smack/filters/FilterToStringTest.java diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java index d32fb6eef..897ae24b6 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java @@ -19,6 +19,7 @@ package org.jivesoftware.smack.filter; import java.util.ArrayList; import java.util.Arrays; +import java.util.Iterator; import java.util.List; import org.jivesoftware.smack.util.Objects; @@ -68,9 +69,13 @@ public abstract class AbstractListFilter implements PacketFilter { public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName()); - sb.append(" ("); - for (PacketFilter filter : filters) { - sb.append(' ' + filter.toString() + ','); + sb.append(": ("); + for (Iterator it = filters.iterator(); it.hasNext();) { + PacketFilter filter = it.next(); + sb.append(filter.toString()); + if (it.hasNext()) { + sb.append(", "); + } } sb.append(")"); return sb.toString(); diff --git a/smack-core/src/test/java/org/jivesoftware/smack/filters/FilterToStringTest.java b/smack-core/src/test/java/org/jivesoftware/smack/filters/FilterToStringTest.java new file mode 100644 index 000000000..8d5ed2e8d --- /dev/null +++ b/smack-core/src/test/java/org/jivesoftware/smack/filters/FilterToStringTest.java @@ -0,0 +1,42 @@ +/** + * + * Copyright 2015 Florian Schmaus + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.smack.filters; + +import static org.junit.Assert.assertEquals; + +import org.jivesoftware.smack.filter.AndFilter; +import org.jivesoftware.smack.filter.MessageWithBodiesFilter; +import org.jivesoftware.smack.filter.StanzaIdFilter; +import org.jivesoftware.smack.filter.ThreadFilter; +import org.junit.Test; + +/** + * + */ +public class FilterToStringTest { + + @Test + public void abstractListFilterToStringTest() { + AndFilter andFilter = new AndFilter(); + andFilter.addFilter(new StanzaIdFilter("foo")); + andFilter.addFilter(new ThreadFilter("42")); + andFilter.addFilter(MessageWithBodiesFilter.INSTANCE); + + final String res =andFilter.toString(); + assertEquals("AndFilter: (StanzaIdFilter: id=foo, ThreadFilter: thread=42, MessageWithBodiesFilter)", res); + } +} From 2250ac20eddf10b8bd118e8551709ab82838a87f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 26 Feb 2015 08:55:53 +0100 Subject: [PATCH 16/30] Make VCard XML null value safe The user is able to set (most) values to null. We must take that into consideration when transforming the VCard to XML. --- .../smackx/vcardtemp/packet/VCard.java | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java index 303510031..fd18638e4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java @@ -565,23 +565,27 @@ public class VCard extends IQ { xml.rightAngleBracket(); if (hasNameField()) { xml.openElement("N"); - xml.element("FAMILY", lastName); - xml.element("GIVEN", firstName); - xml.element("MIDDLE", middleName); + xml.optElement("FAMILY", lastName); + xml.optElement("GIVEN", firstName); + xml.optElement("MIDDLE", middleName); xml.closeElement("N"); } if (hasOrganizationFields()) { xml.openElement("ORG"); - xml.element("ORGNAME", organization); - xml.element("ORGUNIT", organizationUnit); + xml.optElement("ORGNAME", organization); + xml.optElement("ORGUNIT", organizationUnit); xml.closeElement("ORG"); } for (Entry entry : otherSimpleFields.entrySet()) { - xml.element(entry.getKey(), entry.getValue()); + xml.optElement(entry.getKey(), entry.getValue()); } for (Entry entry : otherUnescapableFields.entrySet()) { + final String value = entry.getValue(); + if (value == null) { + continue; + } xml.openElement(entry.getKey()); - xml.append(entry.getValue()); + xml.append(value); xml.closeElement(entry.getKey()); } if (photoBinval != null) { @@ -607,24 +611,36 @@ public class VCard extends IQ { xml.closeElement("EMAIL"); } for (Entry phone : workPhones.entrySet()) { + final String number = phone.getValue(); + if (number == null) { + continue; + } xml.openElement("TEL"); xml.emptyElement("WORK"); xml.emptyElement(phone.getKey()); - xml.element("NUMBER", phone.getValue()); + xml.element("NUMBER", number); xml.closeElement("TEL"); } for (Entry phone : homePhones.entrySet()) { + final String number = phone.getValue(); + if (number == null) { + continue; + } xml.openElement("TEL"); xml.emptyElement("HOME"); xml.emptyElement(phone.getKey()); - xml.element("NUMBER", phone.getValue()); + xml.element("NUMBER", number); xml.closeElement("TEL"); } if (!workAddr.isEmpty()) { xml.openElement("ADR"); xml.emptyElement("WORK"); for (Entry entry : workAddr.entrySet()) { - xml.element(entry.getKey(), entry.getValue()); + final String value = entry.getValue(); + if (value == null) { + continue; + } + xml.element(entry.getKey(), value); } xml.closeElement("ADR"); } @@ -632,7 +648,11 @@ public class VCard extends IQ { xml.openElement("ADR"); xml.emptyElement("HOME"); for (Entry entry : homeAddr.entrySet()) { - xml.element(entry.getKey(), entry.getValue()); + final String value = entry.getValue(); + if (value == null) { + continue; + } + xml.element(entry.getKey(), value); } xml.closeElement("ADR"); } From d4a6d8e6533c0ad8c9e7f6566cde07016f0c1ec1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 26 Feb 2015 18:41:17 +0100 Subject: [PATCH 17/30] Rename PacketFilter (and implementing classes) and PacketExtension to StanzaFilter and ExtensionElement. --- documentation/debugging.md | 8 +- documentation/developer/stanzas.md | 4 +- documentation/extensions/hoxt.md | 2 +- documentation/extensions/invitation.md | 8 +- documentation/extensions/properties.md | 8 +- documentation/extensions/xhtml.md | 4 +- documentation/gettingstarted.md | 4 +- documentation/index.md | 2 +- documentation/processing.md | 14 +-- documentation/providers.md | 10 +-- .../java/org/jivesoftware/smack/IQTest.java | 4 +- .../jivesoftware/smack/PacketReaderTest.java | 4 +- .../smack/filter/PacketTypeFilterTest.java | 26 +++--- .../smack/AbstractXMPPConnection.java | 52 +++++------ .../jivesoftware/smack/PacketCollector.java | 41 +++++++-- .../jivesoftware/smack/PacketListener.java | 4 +- .../jivesoftware/smack/SmackException.java | 14 +-- .../jivesoftware/smack/XMPPConnection.java | 50 +++++------ .../smack/compress/packet/Compress.java | 4 +- .../smack/filter/AbstractListFilter.java | 18 ++-- .../jivesoftware/smack/filter/AndFilter.java | 8 +- ...ter.java => FlexibleStanzaTypeFilter.java} | 29 +++---- .../smack/filter/FromMatchesFilter.java | 2 +- .../smack/filter/IQReplyFilter.java | 8 +- .../smack/filter/IQTypeFilter.java | 12 +-- .../smack/filter/MessageTypeFilter.java | 16 ++-- .../smack/filter/MessageWithBodiesFilter.java | 4 +- .../filter/MessageWithSubjectFilter.java | 4 +- .../jivesoftware/smack/filter/NotFilter.java | 6 +- .../jivesoftware/smack/filter/OrFilter.java | 8 +- .../smack/filter/PacketExtensionFilter.java | 8 +- .../smack/filter/PacketFilter.java | 13 +-- .../smack/filter/PacketIDFilter.java | 2 +- .../smack/filter/PacketTypeFilter.java | 4 +- .../smack/filter/PresenceTypeFilter.java | 2 +- .../smack/filter/StanzaExtensionFilter.java | 76 ++++++++++++++++ .../smack/filter/StanzaFilter.java | 58 +++++++++++++ .../smack/filter/StanzaIdFilter.java | 2 +- .../smack/filter/StanzaTypeFilter.java | 62 +++++++++++++ .../smack/filter/ThreadFilter.java | 2 +- .../jivesoftware/smack/filter/ToFilter.java | 2 +- .../smack/packet/AbstractError.java | 10 +-- .../org/jivesoftware/smack/packet/Bind.java | 2 +- ...sion.java => DefaultExtensionElement.java} | 8 +- .../jivesoftware/smack/packet/Element.java | 2 +- .../smack/packet/ExtensionElement.java | 46 ++++++++++ .../smack/packet/FullStreamElement.java | 2 +- .../org/jivesoftware/smack/packet/IQ.java | 2 +- .../jivesoftware/smack/packet/Mechanisms.java | 2 +- .../smack/packet/NamedElement.java | 2 +- .../org/jivesoftware/smack/packet/Packet.java | 16 ++-- .../smack/packet/PacketExtension.java | 25 +++--- .../jivesoftware/smack/packet/Session.java | 2 +- .../org/jivesoftware/smack/packet/Stanza.java | 40 ++++----- .../smack/packet/StreamError.java | 2 +- .../jivesoftware/smack/packet/XMPPError.java | 4 +- .../provider/EmbeddedExtensionProvider.java | 12 +-- ...der.java => ExtensionElementProvider.java} | 6 +- .../smack/provider/ExtensionProviderInfo.java | 6 +- .../smack/provider/IntrospectionProvider.java | 4 +- .../smack/provider/ProviderFileLoader.java | 10 +-- .../smack/provider/ProviderManager.java | 22 ++--- .../provider/StreamFeatureProviderInfo.java | 4 +- .../smack/util/PacketParserUtils.java | 86 +++++++++++++------ .../jivesoftware/smack/util/PacketUtil.java | 10 +-- .../smack/util/XmlStringBuilder.java | 6 +- .../smack/PacketCollectorTest.java | 8 +- .../smack/packet/StreamErrorTest.java | 2 +- .../smack/parsing/ParsingExceptionTest.java | 8 +- .../carbons/packet/CarbonExtension.java | 6 +- .../provider/CarbonManagerProvider.java | 6 +- .../csi/packet/ClientStateIndication.java | 4 +- .../ClientStateIndicationFeatureProvider.java | 4 +- .../smackx/hoxt/packet/Base64BinaryChunk.java | 4 +- .../provider/Base64BinaryChunkProvider.java | 4 +- .../packet/AbstractJsonPacketExtension.java | 4 +- .../AbstractJsonExtensionProvider.java | 4 +- .../Base64BinaryChunkProviderTest.java | 6 +- .../smackx/GroupChatInvitationTest.java | 4 +- .../smackx/entitycaps/EntityCapsTest.java | 4 +- .../smackx/packet/MessageEventTest.java | 2 +- .../smackx/packet/XHTMLExtensionTest.java | 4 +- .../address/packet/MultipleAddresses.java | 4 +- .../provider/MultipleAddressesProvider.java | 4 +- .../smackx/amp/packet/AMPExtension.java | 4 +- .../amp/provider/AMPExtensionProvider.java | 4 +- .../attention/packet/AttentionExtension.java | 10 +-- .../smackx/bytestreams/ibb/DataListener.java | 10 +-- .../ibb/InBandBytestreamSession.java | 16 ++-- .../ibb/packet/DataPacketExtension.java | 4 +- .../ibb/provider/DataPacketProvider.java | 2 +- .../smackx/caps/EntityCapsManager.java | 20 ++--- .../smackx/caps/packet/CapsExtension.java | 4 +- .../caps/provider/CapsExtensionProvider.java | 4 +- .../smackx/chatstates/ChatStateManager.java | 12 +-- .../chatstates/packet/ChatStateExtension.java | 8 +- .../commands/packet/AdHocCommandData.java | 4 +- .../provider/AdHocCommandDataProvider.java | 14 +-- .../smackx/delay/DelayInformationManager.java | 4 +- .../delay/filter/DelayedStanzaFilter.java | 8 +- .../smackx/delay/packet/DelayInformation.java | 4 +- .../AbstractDelayInformationProvider.java | 4 +- .../AbstractNodeInformationProvider.java | 4 +- .../smackx/disco/NodeInformationProvider.java | 4 +- .../smackx/disco/ServiceDiscoveryManager.java | 8 +- .../disco/provider/DiscoverInfoProvider.java | 2 +- .../filetransfer/FaultTolerantNegotiator.java | 8 +- .../filetransfer/IBBTransferNegotiator.java | 31 +++---- .../Socks5TransferNegotiator.java | 23 ++--- .../smackx/filetransfer/StreamNegotiator.java | 4 +- .../smackx/forward/packet/Forwarded.java | 4 +- .../forward/provider/ForwardedProvider.java | 6 +- .../smackx/iqlast/LastActivityManager.java | 8 +- .../iqregister/packet/Registration.java | 4 +- .../provider/RegistrationProvider.java | 6 +- .../RegistrationStreamFeatureProvider.java | 4 +- .../packet/JivePropertiesExtension.java | 4 +- .../JivePropertiesExtensionProvider.java | 4 +- .../smackx/muc/MultiUserChat.java | 26 +++--- .../smackx/muc/MultiUserChatManager.java | 8 +- .../muc/packet/GroupChatInvitation.java | 12 +-- .../smackx/muc/packet/MUCInitialPresence.java | 4 +- .../smackx/muc/packet/MUCUser.java | 4 +- .../smackx/muc/provider/MUCOwnerProvider.java | 2 +- .../smackx/muc/provider/MUCUserProvider.java | 4 +- .../jivesoftware/smackx/nick/packet/Nick.java | 10 +-- .../smackx/offline/OfflineMessageManager.java | 14 +-- .../offline/packet/OfflineMessageInfo.java | 8 +- .../jivesoftware/smackx/pep/PEPManager.java | 6 +- .../smackx/pep/packet/PEPEvent.java | 4 +- .../smackx/pep/packet/PEPItem.java | 4 +- .../smackx/pep/provider/PEPProvider.java | 16 ++-- .../smackx/privacy/PrivacyListManager.java | 12 +-- .../privacy/filter/SetActiveListFilter.java | 4 +- .../privacy/filter/SetDefaultListFilter.java | 4 +- .../smackx/pubsub/Affiliation.java | 4 +- .../smackx/pubsub/ConfigurationEvent.java | 6 +- .../pubsub/EmbeddedPacketExtension.java | 12 +-- .../smackx/pubsub/EventElement.java | 6 +- .../smackx/pubsub/ItemsExtension.java | 16 ++-- .../jivesoftware/smackx/pubsub/LeafNode.java | 10 +-- .../org/jivesoftware/smackx/pubsub/Node.java | 30 +++---- .../smackx/pubsub/NodeExtension.java | 4 +- .../smackx/pubsub/PayloadItem.java | 12 +-- .../smackx/pubsub/PubSubManager.java | 8 +- .../smackx/pubsub/RetractItem.java | 4 +- .../smackx/pubsub/SimplePayload.java | 4 +- .../smackx/pubsub/packet/PubSub.java | 6 +- .../pubsub/provider/AffiliationProvider.java | 4 +- .../pubsub/provider/AffiliationsProvider.java | 4 +- .../pubsub/provider/ConfigEventProvider.java | 4 +- .../smackx/pubsub/provider/EventProvider.java | 4 +- .../pubsub/provider/FormNodeProvider.java | 4 +- .../smackx/pubsub/provider/ItemProvider.java | 12 +-- .../smackx/pubsub/provider/ItemsProvider.java | 4 +- .../pubsub/provider/PubSubProvider.java | 2 +- .../pubsub/provider/RetractEventProvider.java | 4 +- .../pubsub/provider/SimpleNodeProvider.java | 4 +- .../pubsub/provider/SubscriptionProvider.java | 4 +- .../provider/SubscriptionsProvider.java | 4 +- .../smackx/receipts/DeliveryReceipt.java | 6 +- .../receipts/DeliveryReceiptManager.java | 14 +-- .../receipts/DeliveryReceiptRequest.java | 8 +- .../jivesoftware/smackx/rsm/RSMManager.java | 16 ++-- .../smackx/rsm/packet/RSMSet.java | 4 +- .../smackx/rsm/provider/RSMSetProvider.java | 4 +- .../smackx/search/UserSearch.java | 4 +- .../smackx/shim/packet/Header.java | 4 +- .../smackx/shim/packet/HeadersExtension.java | 4 +- .../smackx/shim/provider/HeaderProvider.java | 4 +- .../smackx/shim/provider/HeadersProvider.java | 4 +- .../smackx/si/packet/StreamInitiation.java | 6 +- .../smackx/xdata/packet/DataForm.java | 4 +- .../xdata/provider/DataFormProvider.java | 4 +- .../smackx/xdatalayout/packet/DataLayout.java | 4 +- .../packet/ValidateElement.java | 4 +- .../smackx/xhtmlim/packet/XHTMLExtension.java | 4 +- .../provider/XHTMLExtensionProvider.java | 4 +- .../smackx/amp/AMPExtensionTest.java | 6 +- .../smackx/pubsub/ItemValidationTest.java | 18 ++-- .../provider/XHTMLExtensionProviderTest.java | 4 +- .../jivesoftware/util/ConnectionUtils.java | 4 +- .../jivesoftware/smack/chat/ChatManager.java | 16 ++-- .../org/jivesoftware/smack/roster/Roster.java | 6 +- .../smack/roster/packet/RosterVer.java | 4 +- .../RosterVerStreamFeatureProvider.java | 4 +- .../jingle/provider/JingleProviderTest.java | 4 +- .../smackx/jingleold/JingleManager.java | 4 +- .../smackx/jingleold/JingleSession.java | 6 +- .../jingleold/packet/JingleContent.java | 4 +- .../packet/JingleContentDescription.java | 4 +- .../jingleold/packet/JingleContentInfo.java | 4 +- .../jingleold/packet/JingleDescription.java | 4 +- .../smackx/jingleold/packet/JingleError.java | 14 +-- .../jingleold/packet/JingleTransport.java | 4 +- .../JingleContentDescriptionProvider.java | 4 +- .../provider/JingleContentInfoProvider.java | 14 +-- .../provider/JingleContentProvider.java | 4 +- .../provider/JingleDescriptionProvider.java | 4 +- .../jingleold/provider/JingleProvider.java | 4 +- .../provider/JingleTransportProvider.java | 4 +- .../smackx/workgroup/MetaData.java | 4 +- .../smackx/workgroup/agent/AgentRoster.java | 8 +- .../smackx/workgroup/agent/AgentSession.java | 26 +++--- .../workgroup/ext/forms/WorkgroupForm.java | 2 +- .../smackx/workgroup/packet/AgentStatus.java | 8 +- .../workgroup/packet/MetaDataProvider.java | 4 +- .../smackx/workgroup/packet/QueueDetails.java | 8 +- .../workgroup/packet/QueueOverview.java | 8 +- .../smackx/workgroup/packet/QueueUpdate.java | 8 +- .../workgroup/packet/RoomInvitation.java | 8 +- .../smackx/workgroup/packet/RoomTransfer.java | 8 +- .../smackx/workgroup/packet/SessionID.java | 8 +- .../workgroup/packet/TranscriptSearch.java | 2 +- .../smackx/workgroup/packet/UserID.java | 8 +- .../packet/WorkgroupInformation.java | 8 +- .../smackx/workgroup/user/Workgroup.java | 16 ++-- .../smackx/xevent/MessageEventManager.java | 6 +- .../smackx/xevent/packet/MessageEvent.java | 4 +- .../xevent/provider/MessageEventProvider.java | 4 +- .../smackx/xroster/RosterExchangeManager.java | 6 +- .../smackx/xroster/packet/RosterExchange.java | 4 +- .../provider/RosterExchangeProvider.java | 4 +- .../smack/sm/packet/StreamManagement.java | 4 +- .../smack/sm/predicates/AfterXStanzas.java | 4 +- .../smack/sm/predicates/ForEveryMessage.java | 4 +- .../smack/sm/predicates/ForEveryStanza.java | 4 +- .../ForMatchingPredicateOrAfterXStanzas.java | 8 +- .../sm/predicates/OnceForThisStanza.java | 6 +- .../smack/sm/predicates/Predicate.java | 4 +- .../sm/predicates/ShortcutPredicates.java | 14 +-- ...StreamManagementStreamFeatureProvider.java | 4 +- .../smack/tcp/XMPPTCPConnection.java | 10 +-- 233 files changed, 1175 insertions(+), 895 deletions(-) rename smack-core/src/main/java/org/jivesoftware/smack/filter/{FlexiblePacketTypeFilter.java => FlexibleStanzaTypeFilter.java} (56%) create mode 100644 smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaExtensionFilter.java create mode 100644 smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java create mode 100644 smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaTypeFilter.java rename smack-core/src/main/java/org/jivesoftware/smack/packet/{DefaultPacketExtension.java => DefaultExtensionElement.java} (92%) create mode 100644 smack-core/src/main/java/org/jivesoftware/smack/packet/ExtensionElement.java rename smack-core/src/main/java/org/jivesoftware/smack/provider/{PacketExtensionProvider.java => ExtensionElementProvider.java} (77%) diff --git a/documentation/debugging.md b/documentation/debugging.md index e5bf0df36..800b15afc 100644 --- a/documentation/debugging.md +++ b/documentation/debugging.md @@ -42,9 +42,9 @@ connection. The window will contain the following information: * XMPPConnection tabs -- each tab shows debugging information related to the connection. * Smack info tab -- shows information about Smack (e.g. Smack version, installed components, etc.). The connection tab will contain the following information: - * All Packets -- shows sent and received packets information parsed by Smack. - * Raw Sent Packets -- raw XML traffic generated by Smack and sent to the server. - * Raw Received Packets -- raw XML traffic sent by the server to the client. + * All Stanzas -- shows sent and received packets information parsed by Smack. + * Raw Sent Stanzas -- raw XML traffic generated by Smack and sent to the server. + * Raw Received Stanzas -- raw XML traffic sent by the server to the client. * Ad-hoc message -- allows to send ad-hoc packets of any type. * Information -- shows connection state and statistics. @@ -57,6 +57,6 @@ contain the following information: * Client Traffic (red text) -- raw XML traffic generated by Smack and sent to the server. * Server Traffic (blue text) -- raw XML traffic sent by the server to the client. - * Interpreted Packets (green text) -- shows XML packets from the server as parsed by Smack. Right click on any of the panes to bring up a menu with the choices to copy of the contents to the system clipboard or to clear the contents of the pane. + * Interpreted Stanzas (green text) -- shows XML packets from the server as parsed by Smack. Right click on any of the panes to bring up a menu with the choices to copy of the contents to the system clipboard or to clear the contents of the pane. Copyright (C) Jive Software 2002-2008 diff --git a/documentation/developer/stanzas.md b/documentation/developer/stanzas.md index e770e01e6..15883256f 100644 --- a/documentation/developer/stanzas.md +++ b/documentation/developer/stanzas.md @@ -1,7 +1,7 @@ PacketExtension =============== -The static `from(Packet)` Method +The static `from(Stanza)` Method -------------------------------- Every PacketExtension class must have a static `from()` method that retrieves that extension for a given Stanza (if any). @@ -9,7 +9,7 @@ Every PacketExtension class must have a static `from()` method that retrieves th Sample Code ```java -public static RSMSet from(Packet) { +public static RSMSet from(Stanza) { return packet.getExtension(ELEMENT, NAMESPACE); } ``` diff --git a/documentation/extensions/hoxt.md b/documentation/extensions/hoxt.md index b89f5a7d2..55bb17f3a 100644 --- a/documentation/extensions/hoxt.md +++ b/documentation/extensions/hoxt.md @@ -89,7 +89,7 @@ req.setTo("juliet@capulet.com/balcony"); // send it connection.sendIqWithResponseCallback(req, new PacketListener() { - public void processPacket(Packet packet) { + public void processPacket(Stanza packet) { HttpOverXmppResp resp = (HttpOverXmppResp) iq; // check HTTP response code if (resp.getStatusCode() == 200) { diff --git a/documentation/extensions/invitation.md b/documentation/extensions/invitation.md index 30f968ee7..222494503 100644 --- a/documentation/extensions/invitation.md +++ b/documentation/extensions/invitation.md @@ -1,7 +1,7 @@ Group Chat Invitations ====================== -The group chat invitation packet extension is used to invite other users to a +The group chat invitation extension is used to invite other users to a group chat room. * Inviting Other Users @@ -20,7 +20,7 @@ appropriately, as in the following code example: 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); ``` The XML generated for the invitation portion of the code above would be: @@ -32,11 +32,11 @@ The XML generated for the invitation portion of the code above would be: Listening for Invitations ------------------------- -To listen for group chat invitations, use a PacketExtensionFilter for the `x` +To listen for group chat invitations, use a StanzaExtensionFilter for the `x` element name and `jabber:x:conference` namespace, as in the following code example: ``` -PacketFilter filter = new PacketExtensionFilter("x", "jabber:x:conference"); +StanzaFilter filter = new StanzaExtensionFilter("x", "jabber:x:conference"); // Create a packet collector or packet listeners using the filter... ``` diff --git a/documentation/extensions/properties.md b/documentation/extensions/properties.md index 9a8e5d9a8..b4a54e281 100644 --- a/documentation/extensions/properties.md +++ b/documentation/extensions/properties.md @@ -1,4 +1,4 @@ -Packet Properties +Stanza Properties ================= Smack provides an easy mechanism for attaching arbitrary properties to @@ -20,7 +20,7 @@ jpe.setProperty("favoriteColor", new Color(0, 0, 255)); // Add an int as a property._ jpe.setProperty("favoriteNumber", 4); // Add the JivePropertiesExtension to the message packet_ -message.addPacketExtension(jpe); +message.addStanzaExtension(jpe); chat.sendMessage(message); ``` @@ -39,8 +39,8 @@ int favoriteNumber = ((Integer)jpe.getProperty("favoriteNumber")).intValue(); ``` For convenience `JivePropertiesManager` contains two helper methods namely -`addProperty(Packet packet, String name, Object value)` and -`getProperty(Packet packet, String name)`. +`addProperty(Stanza packet, String name, Object value)` and +`getProperty(Stanza packet, String name)`. Objects as Properties --------------------- diff --git a/documentation/extensions/xhtml.md b/documentation/extensions/xhtml.md index d24ef791b..d98fd5063 100644 --- a/documentation/extensions/xhtml.md +++ b/documentation/extensions/xhtml.md @@ -98,7 +98,7 @@ done. The last step is to send the message as you do with any other message. An XHTML message is like any regular message, therefore to send the message you can follow the usual steps you do in order to send a message. For example, to send a message as part of a chat just use the message **#send(Message)** of -_**Chat**_ or you can use the message **#send(Packet)** of +_**Chat**_ or you can use the message **#send(Stanza)** of _**XMPPConnection**_. **Example** @@ -143,7 +143,7 @@ XHTML bodies of any received message. ``` // Create a listener for the chat and display any XHTML content PacketListener packetListener = new PacketListener() { -public void processPacket(Packet packet) { +public void processPacket(Stanza packet) { Message message = (Message) packet; // Obtain the XHTML bodies of the message List bodies = XHTMLManager.getBodies(message); diff --git a/documentation/gettingstarted.md b/documentation/gettingstarted.md index e019064ed..d9ad4d84b 100644 --- a/documentation/gettingstarted.md +++ b/documentation/gettingstarted.md @@ -83,7 +83,7 @@ Retrieve the roster using the `Roster.getInstanceFor(XMPPConnection)` method. Th class allows you to find all the roster entries, the groups they belong to, and the current presence status of each entry. -Reading and Writing Packets +Reading and Writing Stanzas Each message to the XMPP server from a client is called a packet and is sent as XML. The `org.jivesoftware.smack.packet` package contains classes that @@ -102,7 +102,7 @@ con.sendPacket(presence); ``` Smack provides two ways to read incoming packets: `PacketListener`, and -`PacketCollector`. Both use `PacketFilter` instances to determine which +`PacketCollector`. Both use `StanzaFilter` instances to determine which packets should be processed. A packet listener is used for event style programming, while a packet collector has a result queue of packets that you can do polling and blocking operations on. So, a packet listener is useful diff --git a/documentation/index.md b/documentation/index.md index 385563d9f..c390866ea 100644 --- a/documentation/index.md +++ b/documentation/index.md @@ -7,7 +7,7 @@ * [Managing Connections](connections.html) * [Messaging Basics](messaging.html) * [Roster and Presence](roster.html) - * [Processing Incoming Packets](processing.html) + * [Processing Incoming Stanzas](processing.html) * [Provider Architecture](providers.html) * [Debugging with Smack](debugging.html) diff --git a/documentation/processing.md b/documentation/processing.md index 6d3b41c7e..5c7e387e5 100644 --- a/documentation/processing.md +++ b/documentation/processing.md @@ -1,4 +1,4 @@ -Processing Incoming Packets +Processing Incoming Stanzas =========================== [Back](index.html) @@ -9,7 +9,7 @@ constructs: * `org.jivesoftware.smack.PacketCollector` -- a class that lets you synchronously wait for new packets. * `org.jivesoftware.smack.PacketListener` -- an interface for asynchronously notifying you of incoming packets. A packet listener is used for event style programming, while a packet collector has a result queue of packets that you can do polling and blocking operations on. So, a packet listener is useful when you want to take some action whenever a packet happens to come in, while a packet collector is useful when you want to wait for a specific packet to arrive. Packet collectors and listeners can be created using an `XMPPConnection` instance. -The `org.jivesoftware.smack.filter.PacketFilter` interface determines which +The `org.jivesoftware.smack.filter.StanzaFilter` interface determines which specific packets will be delivered to a `PacketCollector` or `PacketListener`. Many pre-defined filters can be found in the `org.jivesoftware.smack.filter` package. @@ -20,7 +20,7 @@ and a packet listener: ``` // Create a packet filter to listen for new messages from a particular // user. We use an AndFilter to combine two other filters._ -PacketFilter filter = new AndFilter(new PacketTypeFilter(Message.class), +StanzaFilter filter = new AndFilter(new StanzaTypeFilter(Message.class), new FromContainsFilter("mary@jivesoftware.com")); // Assume we've created an XMPPConnection name "connection". @@ -38,19 +38,19 @@ PacketListener myListener = new PacketListener() { connection.addPacketListener(myListener, filter); ``` -Standard Packet Filters +Standard Stanza Filters ----------------------- A rich set of packet filters are included with Smack, or you can create your -own filters by coding to the `PacketFilter` interface. The default set of +own filters by coding to the `StanzaFilter` interface. The default set of filters includes: - * `PacketTypeFilter` -- filters for packets that are a particular Class type. + * `StanzaTypeFilter` -- filters for packets that are a particular Class type. * `StanzaIdFilter` -- filters for packets with a particular packet ID. * `ThreadFilter` -- filters for message packets with a particular thread ID. * `ToContainsFilter` -- filters for packets that are sent to a particular address. * `FromContainsFilter` -- filters for packets that are sent to a particular address. - * `PacketExtensionFilter` -- filters for packets that have a particular packet extension. + * `StanzaExtensionFilter` -- filters for packets that have a particular packet extension. * `AndFilter` -- implements the logical AND operation over two filters. * `OrFilter` -- implements the logical OR operation over two filters. * `NotFilter` -- implements the logical NOT operation on a filter. diff --git a/documentation/providers.md b/documentation/providers.md index a37c7be0c..e1356319a 100644 --- a/documentation/providers.md +++ b/documentation/providers.md @@ -1,4 +1,4 @@ -Provider Architecture: Packet Extensions and Custom IQ's +Provider Architecture: Stanza Extensions and Custom IQ's ======================================================== [Back](index.html) @@ -73,7 +73,7 @@ an XMPP time packet resembles the following: ### Introspection -_Time Packet_ +_Time Stanza_ @@ -190,7 +190,7 @@ public class MyIQProvider extends IQProvider { ### DiscoItemsProvider -_Disco Items Packet_ +_Disco Items Stanza_ @@ -264,11 +264,11 @@ _Disco Items IQProvider_ Extension Providers ------------------- -Packet extension providers are responsible for parsing packet extensions, +Stanza extension providers are responsible for parsing packet extensions, which are child elements in a custom namespace of IQ, message and presence packets. -_Pubsub Subscription Packet_ +_Pubsub Subscription Stanza_ diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/IQTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/IQTest.java index bd4aa6e8f..49184a875 100644 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/IQTest.java +++ b/smack-core/src/integration-test/java/org/jivesoftware/smack/IQTest.java @@ -20,7 +20,7 @@ package org.jivesoftware.smack; import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketIDFilter; -import org.jivesoftware.smack.filter.PacketTypeFilter; +import org.jivesoftware.smack.filter.StanzaTypeFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.test.SmackTestCase; import org.jivesoftware.smackx.packet.Version; @@ -51,7 +51,7 @@ public class IQTest extends SmackTestCase { }; PacketFilter filter = new AndFilter(new PacketIDFilter(iq.getStanzaId()), - new PacketTypeFilter(IQ.class)); + new StanzaTypeFilter(IQ.class)); PacketCollector collector = getConnection(0).createPacketCollector(filter); // Send the iq packet with an invalid namespace getConnection(0).sendPacket(iq); diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/PacketReaderTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/PacketReaderTest.java index c6f4f8775..aa5d345eb 100644 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/PacketReaderTest.java +++ b/smack-core/src/integration-test/java/org/jivesoftware/smack/PacketReaderTest.java @@ -19,7 +19,7 @@ package org.jivesoftware.smack; import org.jivesoftware.smack.filter.FromMatchesFilter; import org.jivesoftware.smack.filter.PacketIDFilter; -import org.jivesoftware.smack.filter.PacketTypeFilter; +import org.jivesoftware.smack.filter.StanzaTypeFilter; import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.packet.*; import org.jivesoftware.smack.test.SmackTestCase; @@ -143,7 +143,7 @@ public class PacketReaderTest extends SmackTestCase { message.setBody("HELLO"); getConnection(1).sendPacket(message); } - }, new PacketTypeFilter(Message.class)); + }, new StanzaTypeFilter(Message.class)); // User0 listen for replies from user1 PacketCollector collector = getConnection(0).createPacketCollector( diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/filter/PacketTypeFilterTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/filter/PacketTypeFilterTest.java index 18898b136..3a2261b03 100644 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/filter/PacketTypeFilterTest.java +++ b/smack-core/src/integration-test/java/org/jivesoftware/smack/filter/PacketTypeFilterTest.java @@ -21,9 +21,9 @@ import junit.framework.TestCase; import org.jivesoftware.smack.packet.*; /** - * Test cases for the PacketTypeFilter class. + * Test cases for the StanzaTypeFilter class. */ -public class PacketTypeFilterTest extends TestCase { +public class StanzaTypeFilterTest extends TestCase { private class InnerClassDummy { public class DummyPacket extends Packet { @@ -48,20 +48,20 @@ public class PacketTypeFilterTest extends TestCase { } /** - * Test case for the constructor of PacketTypeFilter objects. + * Test case for the constructor of StanzaTypeFilter objects. */ public void testConstructor() { - // We dont need to test this since PacketTypeFilter(Class packetType) only excepts Packets + // We dont need to test this since StanzaTypeFilter(Class packetType) only excepts Packets // Test a class that is not a subclass of Packet // try { - // new PacketTypeFilter(Dummy.class); + // new StanzaTypeFilter(Dummy.class); // fail("Parameter must be a subclass of Packet."); // } // catch (IllegalArgumentException e) {} // Test a class that is a subclass of Packet try { - new PacketTypeFilter(MockPacket.class); + new StanzaTypeFilter(MockPacket.class); } catch (IllegalArgumentException e) { fail(); @@ -69,7 +69,7 @@ public class PacketTypeFilterTest extends TestCase { // Test another class which is a subclass of Packet try { - new PacketTypeFilter(IQ.class); + new StanzaTypeFilter(IQ.class); } catch (IllegalArgumentException e) { fail(); @@ -77,7 +77,7 @@ public class PacketTypeFilterTest extends TestCase { // Test an internal class which is a subclass of Packet try { - new PacketTypeFilter(InnerClassDummy.DummyPacket.class); + new StanzaTypeFilter(InnerClassDummy.DummyPacket.class); } catch (IllegalArgumentException e) { fail(); @@ -85,7 +85,7 @@ public class PacketTypeFilterTest extends TestCase { // Test an internal static class which is a static subclass of Packet try { - new PacketTypeFilter(StaticInnerClassDummy.StaticDummyPacket.class); + new StanzaTypeFilter(StaticInnerClassDummy.StaticDummyPacket.class); } catch (IllegalArgumentException e) { fail(); @@ -93,19 +93,19 @@ public class PacketTypeFilterTest extends TestCase { } /** - * Test case to test the accept() method of PacketTypeFilter objects. + * Test case to test the accept() method of StanzaTypeFilter objects. */ public void testAccept() { Packet packet = new MockPacket(); - PacketTypeFilter filter = new PacketTypeFilter(MockPacket.class); + StanzaTypeFilter filter = new PacketTypeFilter(MockPacket.class); assertTrue(filter.accept(packet)); packet = (new InnerClassDummy()).getInnerInstance(); - filter = new PacketTypeFilter(InnerClassDummy.DummyPacket.class); + filter = new StanzaTypeFilter(InnerClassDummy.DummyPacket.class); assertTrue(filter.accept(packet)); packet = StaticInnerClassDummy.getInnerInstance(); - filter = new PacketTypeFilter(StaticInnerClassDummy.StaticDummyPacket.class); + filter = new StanzaTypeFilter(StaticInnerClassDummy.StaticDummyPacket.class); assertTrue(filter.accept(packet)); } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index c7d77c850..3343291bd 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -56,7 +56,7 @@ import org.jivesoftware.smack.compress.packet.Compress; import org.jivesoftware.smack.compression.XMPPInputOutputStream; import org.jivesoftware.smack.debugger.SmackDebugger; import org.jivesoftware.smack.filter.IQReplyFilter; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaIdFilter; import org.jivesoftware.smack.iqrequest.IQRequestHandler; import org.jivesoftware.smack.packet.Bind; @@ -64,7 +64,7 @@ import org.jivesoftware.smack.packet.ErrorIQ; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Mechanisms; 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.packet.Session; import org.jivesoftware.smack.packet.StartTls; @@ -72,7 +72,7 @@ import org.jivesoftware.smack.packet.PlainStreamElement; import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.parsing.ParsingExceptionCallback; import org.jivesoftware.smack.parsing.UnparsablePacket; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smack.util.DNSUtil; import org.jivesoftware.smack.util.Objects; @@ -154,7 +154,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { protected final Lock connectionLock = new ReentrantLock(); - protected final Map streamFeatures = new HashMap(); + protected final Map streamFeatures = new HashMap(); /** * The full JID of the authenticated user, as returned by the resource binding response of the server. @@ -716,14 +716,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { @Override public PacketCollector createPacketCollectorAndSend(IQ packet) throws NotConnectedException { - PacketFilter packetFilter = new IQReplyFilter(packet, this); + StanzaFilter packetFilter = new IQReplyFilter(packet, this); // Create the packet collector before sending the packet PacketCollector packetCollector = createPacketCollectorAndSend(packetFilter, packet); return packetCollector; } @Override - public PacketCollector createPacketCollectorAndSend(PacketFilter packetFilter, Stanza packet) + public PacketCollector createPacketCollectorAndSend(StanzaFilter packetFilter, Stanza packet) throws NotConnectedException { // Create the packet collector before sending the packet PacketCollector packetCollector = createPacketCollector(packetFilter); @@ -739,8 +739,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public PacketCollector createPacketCollector(PacketFilter packetFilter) { - PacketCollector.Configuration configuration = PacketCollector.newConfiguration().setPacketFilter(packetFilter); + public PacketCollector createPacketCollector(StanzaFilter packetFilter) { + PacketCollector.Configuration configuration = PacketCollector.newConfiguration().setStanzaFilter(packetFilter); return createPacketCollector(configuration); } @@ -759,7 +759,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { @Override @Deprecated - public void addPacketListener(PacketListener packetListener, PacketFilter packetFilter) { + public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter) { addAsyncPacketListener(packetListener, packetFilter); } @@ -770,7 +770,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public void addSyncPacketListener(PacketListener packetListener, PacketFilter packetFilter) { + public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) { if (packetListener == null) { throw new NullPointerException("Packet listener is null."); } @@ -788,7 +788,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public void addAsyncPacketListener(PacketListener packetListener, PacketFilter packetFilter) { + public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) { if (packetListener == null) { throw new NullPointerException("Packet listener is null."); } @@ -806,7 +806,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public void addPacketSendingListener(PacketListener packetListener, PacketFilter packetFilter) { + public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter) { if (packetListener == null) { throw new NullPointerException("Packet listener is null."); } @@ -862,7 +862,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { @Override public void addPacketInterceptor(PacketListener packetInterceptor, - PacketFilter packetFilter) { + StanzaFilter packetFilter) { if (packetInterceptor == null) { throw new NullPointerException("Packet interceptor is null."); } @@ -1244,7 +1244,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { protected static class ListenerWrapper { private final PacketListener packetListener; - private final PacketFilter packetFilter; + private final StanzaFilter packetFilter; /** * Create a class which associates a packet filter with a listener. @@ -1252,7 +1252,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @param packetListener the packet listener. * @param packetFilter the associated filter or null if it listen for all packets. */ - public ListenerWrapper(PacketListener packetListener, PacketFilter packetFilter) { + public ListenerWrapper(PacketListener packetListener, StanzaFilter packetFilter) { this.packetListener = packetListener; this.packetFilter = packetFilter; } @@ -1272,7 +1272,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { protected static class InterceptorWrapper { private final PacketListener packetInterceptor; - private final PacketFilter packetFilter; + private final StanzaFilter packetFilter; /** * Create a class which associates a packet filter with an interceptor. @@ -1280,7 +1280,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @param packetInterceptor the interceptor. * @param packetFilter the associated filter or null if it intercepts all packets. */ - public InterceptorWrapper(PacketListener packetInterceptor, PacketFilter packetFilter) { + public InterceptorWrapper(PacketListener packetInterceptor, StanzaFilter packetFilter) { this.packetInterceptor = packetInterceptor; this.packetFilter = packetFilter; } @@ -1339,7 +1339,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG && parser.getDepth() == initialDepth + 1) { - PacketExtension streamFeature = null; + ExtensionElement streamFeature = null; String name = parser.getName(); String namespace = parser.getNamespace(); switch (name) { @@ -1359,7 +1359,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { streamFeature = PacketParserUtils.parseCompressionFeature(parser); break; default: - PacketExtensionProvider provider = ProviderManager.getStreamFeatureProvider(name, namespace); + ExtensionElementProvider provider = ProviderManager.getStreamFeatureProvider(name, namespace); if (provider != null) { streamFeature = provider.parse(parser); } @@ -1401,7 +1401,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { @SuppressWarnings("unchecked") @Override - public F getFeature(String element, String namespace) { + public F getFeature(String element, String namespace) { return (F) streamFeatures.get(XmppStringUtils.generateKey(element, namespace)); } @@ -1410,19 +1410,19 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { return getFeature(element, namespace) != null; } - private void addStreamFeature(PacketExtension feature) { + private void addStreamFeature(ExtensionElement feature) { String key = XmppStringUtils.generateKey(feature.getElementName(), feature.getNamespace()); streamFeatures.put(key, feature); } @Override - public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter, + public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, PacketListener callback) throws NotConnectedException { sendStanzaWithResponseCallback(stanza, replyFilter, callback, null); } @Override - public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter, + public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, PacketListener callback, ExceptionCallback exceptionCallback) throws NotConnectedException { sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback, @@ -1430,7 +1430,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public void sendStanzaWithResponseCallback(Stanza stanza, final PacketFilter replyFilter, + public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter, final PacketListener callback, final ExceptionCallback exceptionCallback, long timeout) throws NotConnectedException { Objects.requireNonNull(stanza, "stanza must not be null"); @@ -1487,12 +1487,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { public void sendIqWithResponseCallback(IQ iqRequest, final PacketListener callback, final ExceptionCallback exceptionCallback, long timeout) throws NotConnectedException { - PacketFilter replyFilter = new IQReplyFilter(iqRequest, this); + StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this); sendStanzaWithResponseCallback(iqRequest, replyFilter, callback, exceptionCallback, timeout); } @Override - public void addOneTimeSyncCallback(final PacketListener callback, final PacketFilter packetFilter) { + public void addOneTimeSyncCallback(final PacketListener callback, final StanzaFilter packetFilter) { final PacketListener packetListener = new PacketListener() { @Override public void processPacket(Stanza packet) throws NotConnectedException { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java b/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java index 49ce54f64..83d81bd6d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java @@ -24,7 +24,7 @@ import java.util.logging.Logger; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.XMPPException.XMPPErrorException; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.Stanza; /** @@ -38,14 +38,14 @@ import org.jivesoftware.smack.packet.Stanza; * older packets are automatically dropped. The default number is retrieved by * {@link SmackConfiguration#getPacketCollectorSize()}. * - * @see XMPPConnection#createPacketCollector(PacketFilter) + * @see XMPPConnection#createPacketCollector(StanzaFilter) * @author Matt Tucker */ public class PacketCollector { private static final Logger LOGGER = Logger.getLogger(PacketCollector.class.getName()); - private final PacketFilter packetFilter; + private final StanzaFilter packetFilter; private final ArrayBlockingQueue resultQueue; /** @@ -89,11 +89,23 @@ public class PacketCollector { * filter is used to determine what packets are queued as results. * * @return the packet filter. + * @deprecated use {@link #getStanzaFilter()} instead. */ - public PacketFilter getPacketFilter() { - return packetFilter; + @Deprecated + public StanzaFilter getPacketFilter() { + return getStanzaFilter(); } + /** + * Returns the stanza filter associated with this stanza collector. The stanza + * filter is used to determine what stanzas are queued as results. + * + * @return the stanza filter. + */ + public StanzaFilter getStanzaFilter() { + return packetFilter; + } + /** * Polls to see if a packet is currently available and returns it, or * immediately returns null if no packets are currently in the @@ -266,7 +278,7 @@ public class PacketCollector { } public static class Configuration { - private PacketFilter packetFilter; + private StanzaFilter packetFilter; private int size = SmackConfiguration.getPacketCollectorSize(); private PacketCollector collectorToReset; @@ -279,9 +291,22 @@ public class PacketCollector { * * @param packetFilter * @return a reference to this configuration. + * @deprecated use {@link #setStanzaFilter(StanzaFilter)} instead. */ - public Configuration setPacketFilter(PacketFilter packetFilter) { - this.packetFilter = packetFilter; + @Deprecated + public Configuration setPacketFilter(StanzaFilter packetFilter) { + return setStanzaFilter(packetFilter); + } + + /** + * Set the stanza filter used by this collector. If null, then all stanzas will + * get collected by this collector. + * + * @param stanzaFilter + * @return a reference to this configuration. + */ + public Configuration setStanzaFilter(StanzaFilter stanzaFilter) { + this.packetFilter = stanzaFilter; return this; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java b/smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java index 56d6b93e2..fbe392883 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java @@ -30,10 +30,10 @@ import org.jivesoftware.smack.packet.Stanza; * Additionally you are able to intercept Packets that are going to be send and * make modifications to them. You can register a PacketListener as interceptor * by using {@link XMPPConnection#addPacketInterceptor(PacketListener, - * org.jivesoftware.smack.filter.PacketFilter)} + * org.jivesoftware.smack.filter.StanzaFilter)} *

* - * @see XMPPConnection#addAsyncPacketListener(PacketListener, org.jivesoftware.smack.filter.PacketFilter) + * @see XMPPConnection#addAsyncPacketListener(PacketListener, org.jivesoftware.smack.filter.StanzaFilter) * @author Matt Tucker */ public interface PacketListener { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java b/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java index 789f6a0ff..261a46807 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java @@ -19,7 +19,7 @@ package org.jivesoftware.smack; import java.util.ArrayList; import java.util.List; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.util.dns.HostAddress; /** @@ -65,9 +65,9 @@ public class SmackException extends Exception { */ private static final long serialVersionUID = -6523363748984543636L; - private final PacketFilter filter; + private final StanzaFilter filter; - private NoResponseException(String message, PacketFilter filter) { + private NoResponseException(String message, StanzaFilter filter) { super(message); this.filter = filter; } @@ -77,20 +77,20 @@ public class SmackException extends Exception { * * @return the used filter or null. */ - public PacketFilter getFilter() { + public StanzaFilter getFilter() { return filter; } public static NoResponseException newWith(XMPPConnection connection) { - return newWith(connection, (PacketFilter) null); + return newWith(connection, (StanzaFilter) null); } public static NoResponseException newWith(XMPPConnection connection, PacketCollector collector) { - return newWith(connection, collector.getPacketFilter()); + return newWith(connection, collector.getStanzaFilter()); } - public static NoResponseException newWith(XMPPConnection connection, PacketFilter filter) { + public static NoResponseException newWith(XMPPConnection connection, StanzaFilter filter) { final long replyTimeout = connection.getPacketReplyTimeout(); final StringBuilder sb = new StringBuilder(256); sb.append("No response received within reply timeout. Timeout was " diff --git a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java index fd93de2d1..183b9b1fc 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java @@ -20,11 +20,11 @@ package org.jivesoftware.smack; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.filter.IQReplyFilter; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.iqrequest.IQRequestHandler; 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.PlainStreamElement; /** @@ -211,7 +211,7 @@ public interface XMPPConnection { * @param packet the packet to send right after the collector got created * @return a new packet collector. */ - public PacketCollector createPacketCollectorAndSend(PacketFilter packetFilter, Stanza packet) + public PacketCollector createPacketCollectorAndSend(StanzaFilter packetFilter, Stanza packet) throws NotConnectedException; /** @@ -222,7 +222,7 @@ public interface XMPPConnection { *

* Note: If you send a Packet right after using this method, then * consider using - * {@link #createPacketCollectorAndSend(PacketFilter, Stanza)} instead. + * {@link #createPacketCollectorAndSend(StanzaFilter, Stanza)} instead. * Otherwise make sure cancel the PacketCollector in every case, e.g. even * if an exception is thrown, or otherwise you may leak the PacketCollector. *

@@ -230,13 +230,13 @@ public interface XMPPConnection { * @param packetFilter the packet filter to use. * @return a new packet collector. */ - public PacketCollector createPacketCollector(PacketFilter packetFilter); + public PacketCollector createPacketCollector(StanzaFilter packetFilter); /** * Create a new packet collector with the given packet collector configuration. *

* Please make sure to cancel the collector when it is no longer required. See also - * {@link #createPacketCollector(PacketFilter)}. + * {@link #createPacketCollector(StanzaFilter)}. *

* * @param configuration the packet collector configuration. @@ -257,17 +257,17 @@ public interface XMPPConnection { *

* This method has been deprecated. It is important to differentiate between using an asynchronous packet listener * (preferred where possible) and a synchronous packet lister. Refer - * {@link #addAsyncPacketListener(PacketListener, PacketFilter)} and - * {@link #addSyncPacketListener(PacketListener, PacketFilter)} for more information. + * {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} and + * {@link #addSyncPacketListener(PacketListener, StanzaFilter)} for more information. *

* * @param packetListener the packet listener to notify of new received packets. * @param packetFilter the packet filter to use. - * @deprecated use {@link #addAsyncPacketListener(PacketListener, PacketFilter)} or - * {@link #addSyncPacketListener(PacketListener, PacketFilter)}. + * @deprecated use {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} or + * {@link #addSyncPacketListener(PacketListener, StanzaFilter)}. */ @Deprecated - public void addPacketListener(PacketListener packetListener, PacketFilter packetFilter); + public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter); /** * Removes a packet listener for received packets from this connection. @@ -286,17 +286,17 @@ public interface XMPPConnection { *

* Important: This packet listeners will be called in the same single thread that processes all * incoming stanzas. Only use this kind of packet filter if it does not perform any XMPP activity that waits for a - * response. Consider using {@link #addAsyncPacketListener(PacketListener, PacketFilter)} when possible, i.e. when + * response. Consider using {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} when possible, i.e. when * the invocation order doesn't have to be the same as the order of the arriving packets. If the order of the * arriving packets, consider using a {@link PacketCollector} when possible. *

* * @param packetListener the packet listener to notify of new received packets. * @param packetFilter the packet filter to use. - * @see #addPacketInterceptor(PacketListener, PacketFilter) + * @see #addPacketInterceptor(PacketListener, StanzaFilter) * @since 4.1 */ - public void addSyncPacketListener(PacketListener packetListener, PacketFilter packetFilter); + public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter); /** * Removes a packet listener for received packets from this connection. @@ -312,17 +312,17 @@ public interface XMPPConnection { * when an incoming packet is received. A packet filter determines which packets will be delivered to the listener. * If the same packet listener is added again with a different filter, only the new filter will be used. *

- * Unlike {@link #addAsyncPacketListener(PacketListener, PacketFilter)} packet listeners added with this method will be + * Unlike {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} packet listeners added with this method will be * invoked asynchronously in their own thread. Use this method if the order of the packet listeners must not depend * on the order how the stanzas where received. *

* * @param packetListener the packet listener to notify of new received packets. * @param packetFilter the packet filter to use. - * @see #addPacketInterceptor(PacketListener, PacketFilter) + * @see #addPacketInterceptor(PacketListener, StanzaFilter) * @since 4.1 */ - public void addAsyncPacketListener(PacketListener packetListener, PacketFilter packetFilter); + public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter); /** * Removes an asynchronous packet listener for received packets from this connection. @@ -344,7 +344,7 @@ public interface XMPPConnection { * @param packetListener the packet listener to notify of sent packets. * @param packetFilter the packet filter to use. */ - public void addPacketSendingListener(PacketListener packetListener, PacketFilter packetFilter); + public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter); /** * Removes a packet listener for sending packets from this connection. @@ -360,12 +360,12 @@ public interface XMPPConnection { * will be delivered to the interceptor. * *

- * NOTE: For a similar functionality on incoming packets, see {@link #addAsyncPacketListener(PacketListener, PacketFilter)}. + * NOTE: For a similar functionality on incoming packets, see {@link #addAsyncPacketListener(PacketListener, StanzaFilter)}. * * @param packetInterceptor the packet interceptor to notify of packets about to be sent. * @param packetFilter the packet filter to use. */ - public void addPacketInterceptor(PacketListener packetInterceptor, PacketFilter packetFilter); + public void addPacketInterceptor(PacketListener packetInterceptor, StanzaFilter packetFilter); /** * Removes a packet interceptor. @@ -439,7 +439,7 @@ public interface XMPPConnection { * @param namespace * @return a packet extensions of the feature or null */ - public F getFeature(String element, String namespace); + public F getFeature(String element, String namespace); /** * Return true if the server supports the given stream feature. @@ -463,7 +463,7 @@ public interface XMPPConnection { * @param callback the callback invoked if there is a response (required) * @throws NotConnectedException */ - public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter, + public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, PacketListener callback) throws NotConnectedException; /** @@ -480,7 +480,7 @@ public interface XMPPConnection { * @param exceptionCallback the callback invoked if there is an exception (optional) * @throws NotConnectedException */ - public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter, PacketListener callback, + public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, PacketListener callback, ExceptionCallback exceptionCallback) throws NotConnectedException; /** @@ -498,7 +498,7 @@ public interface XMPPConnection { * @param timeout the timeout in milliseconds to wait for a response * @throws NotConnectedException */ - public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter, + public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, final PacketListener callback, final ExceptionCallback exceptionCallback, long timeout) throws NotConnectedException; @@ -554,7 +554,7 @@ public interface XMPPConnection { * @param callback the callback invoked once the packet filter matches a stanza. * @param packetFilter the filter to match stanzas or null to match all. */ - public void addOneTimeSyncCallback(PacketListener callback, PacketFilter packetFilter); + public void addOneTimeSyncCallback(PacketListener callback, StanzaFilter packetFilter); /** * Register an IQ request handler with this connection. diff --git a/smack-core/src/main/java/org/jivesoftware/smack/compress/packet/Compress.java b/smack-core/src/main/java/org/jivesoftware/smack/compress/packet/Compress.java index bb2ccd68c..c9a041a33 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/compress/packet/Compress.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/compress/packet/Compress.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.List; import org.jivesoftware.smack.packet.FullStreamElement; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.XmlStringBuilder; public class Compress extends FullStreamElement { @@ -53,7 +53,7 @@ public class Compress extends FullStreamElement { return xml; } - public static class Feature implements PacketExtension { + public static class Feature implements ExtensionElement { public static final String ELEMENT = "compression"; public final List methods; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java index 897ae24b6..f4f7ceae3 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java @@ -27,18 +27,18 @@ import org.jivesoftware.smack.util.Objects; /** * */ -public abstract class AbstractListFilter implements PacketFilter { +public abstract class AbstractListFilter implements StanzaFilter { /** * The list of filters. */ - protected final List filters; + protected final List filters; /** * Creates an empty filter. */ protected AbstractListFilter() { - filters = new ArrayList(); + filters = new ArrayList(); } /** @@ -46,12 +46,12 @@ public abstract class AbstractListFilter implements PacketFilter { * * @param filters the filters to add. */ - protected AbstractListFilter(PacketFilter... filters) { + protected AbstractListFilter(StanzaFilter... filters) { Objects.requireNonNull(filters, "Parameter must not be null."); - for(PacketFilter filter : filters) { + for(StanzaFilter filter : filters) { Objects.requireNonNull(filter, "Parameter must not be null."); } - this.filters = new ArrayList(Arrays.asList(filters)); + this.filters = new ArrayList(Arrays.asList(filters)); } /** @@ -60,7 +60,7 @@ public abstract class AbstractListFilter implements PacketFilter { * * @param filter a filter to add to the filter list. */ - public void addFilter(PacketFilter filter) { + public void addFilter(StanzaFilter filter) { Objects.requireNonNull(filter, "Parameter must not be null."); filters.add(filter); } @@ -70,8 +70,8 @@ public abstract class AbstractListFilter implements PacketFilter { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName()); sb.append(": ("); - for (Iterator it = filters.iterator(); it.hasNext();) { - PacketFilter filter = it.next(); + for (Iterator it = filters.iterator(); it.hasNext();) { + StanzaFilter filter = it.next(); sb.append(filter.toString()); if (it.hasNext()) { sb.append(", "); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java index 7006852fe..94fda8a5a 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java @@ -25,11 +25,11 @@ import org.jivesoftware.smack.packet.Stanza; * * @author Matt Tucker */ -public class AndFilter extends AbstractListFilter implements PacketFilter { +public class AndFilter extends AbstractListFilter implements StanzaFilter { /** * Creates an empty AND filter. Filters should be added using the - * {@link #addFilter(PacketFilter)} method. + * {@link #addFilter(StanzaFilter)} method. */ public AndFilter() { super(); @@ -40,12 +40,12 @@ public class AndFilter extends AbstractListFilter implements PacketFilter { * * @param filters the filters to add. */ - public AndFilter(PacketFilter... filters) { + public AndFilter(StanzaFilter... filters) { super(filters); } public boolean accept(Stanza packet) { - for (PacketFilter filter : filters) { + for (StanzaFilter filter : filters) { if (!filter.accept(packet)) { return false; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/FlexiblePacketTypeFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/FlexibleStanzaTypeFilter.java similarity index 56% rename from smack-core/src/main/java/org/jivesoftware/smack/filter/FlexiblePacketTypeFilter.java rename to smack-core/src/main/java/org/jivesoftware/smack/filter/FlexibleStanzaTypeFilter.java index 454d8caa3..c49cbc33d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/FlexiblePacketTypeFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/FlexibleStanzaTypeFilter.java @@ -1,6 +1,6 @@ /** * - * Copyright 2014 Florian Schmaus + * Copyright 2014-2015 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,39 +23,36 @@ import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.util.Objects; /** - * Filters for packets of a particular type and allows a custom method to further filter the packets. + * Filters for stanzas of a particular type and allows a custom method to further filter the packets. * * @author Florian Schmaus */ -public abstract class FlexiblePacketTypeFilter

implements PacketFilter { +public abstract class FlexibleStanzaTypeFilter implements StanzaFilter { - protected final Class

packetType; + protected final Class stanzaType; - public FlexiblePacketTypeFilter(Class

packetType) { - this.packetType = Objects.requireNonNull(packetType, "Type must not be null"); + public FlexibleStanzaTypeFilter(Class packetType) { + this.stanzaType = Objects.requireNonNull(packetType, "Type must not be null"); } @SuppressWarnings("unchecked") - public FlexiblePacketTypeFilter() { - packetType = (Class

) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; + public FlexibleStanzaTypeFilter() { + stanzaType = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; } @Override @SuppressWarnings("unchecked") - public boolean accept(Stanza packet) { - if (packetType.isInstance(packet)) { - return acceptSpecific((P) packet); + public final boolean accept(Stanza packet) { + if (stanzaType.isInstance(packet)) { + return acceptSpecific((S) packet); } return false; } - protected abstract boolean acceptSpecific(P packet); + protected abstract boolean acceptSpecific(S packet); @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(getClass().getSimpleName()); - sb.append(" (" + packetType.toString() + ')'); - return sb.toString(); + return getClass().getSimpleName() + ": " + stanzaType.toString(); } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.java index 3b48d0f13..8bf88b7e7 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.java @@ -30,7 +30,7 @@ import org.jxmpp.util.XmppStringUtils; * * @author Gaston Dombiak */ -public class FromMatchesFilter implements PacketFilter { +public class FromMatchesFilter implements StanzaFilter { private final String address; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/IQReplyFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/IQReplyFilter.java index 0c3064e65..ef639b073 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/IQReplyFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/IQReplyFilter.java @@ -48,10 +48,10 @@ import org.jxmpp.util.XmppStringUtils; * @author Lars Noschinski * */ -public class IQReplyFilter implements PacketFilter { +public class IQReplyFilter implements StanzaFilter { private static final Logger LOGGER = Logger.getLogger(IQReplyFilter.class.getName()); - private final PacketFilter iqAndIdFilter; + private final StanzaFilter iqAndIdFilter; private final OrFilter fromFilter; private final String to; private final String local; @@ -98,8 +98,8 @@ public class IQReplyFilter implements PacketFilter { server = conn.getServiceName().toLowerCase(Locale.US); packetId = iqPacket.getStanzaId(); - PacketFilter iqFilter = new OrFilter(IQTypeFilter.ERROR, IQTypeFilter.RESULT); - PacketFilter idFilter = new StanzaIdFilter(iqPacket); + StanzaFilter iqFilter = new OrFilter(IQTypeFilter.ERROR, IQTypeFilter.RESULT); + StanzaFilter idFilter = new StanzaIdFilter(iqPacket); iqAndIdFilter = new AndFilter(iqFilter, idFilter); fromFilter = new OrFilter(); fromFilter.addFilter(FromMatchesFilter.createFull(to)); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/IQTypeFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/IQTypeFilter.java index dc2c38b10..a7d3aa02f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/IQTypeFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/IQTypeFilter.java @@ -27,13 +27,13 @@ import org.jivesoftware.smack.util.Objects; * @author Alexander Wenckus * */ -public class IQTypeFilter extends FlexiblePacketTypeFilter { +public class IQTypeFilter extends FlexibleStanzaTypeFilter { - public static final PacketFilter GET = new IQTypeFilter(Type.get); - public static final PacketFilter SET = new IQTypeFilter(Type.set); - public static final PacketFilter RESULT = new IQTypeFilter(Type.result); - public static final PacketFilter ERROR = new IQTypeFilter(Type.error); - public static final PacketFilter GET_OR_SET = new OrFilter(GET, SET); + public static final StanzaFilter GET = new IQTypeFilter(Type.get); + public static final StanzaFilter SET = new IQTypeFilter(Type.set); + public static final StanzaFilter RESULT = new IQTypeFilter(Type.result); + public static final StanzaFilter ERROR = new IQTypeFilter(Type.error); + public static final StanzaFilter GET_OR_SET = new OrFilter(GET, SET); private final IQ.Type type; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageTypeFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageTypeFilter.java index 74df7bfed..4305a384e 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageTypeFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageTypeFilter.java @@ -27,15 +27,15 @@ import org.jivesoftware.smack.packet.Message.Type; * @see org.jivesoftware.smack.packet.Message.Type * @author Ward Harold */ -public class MessageTypeFilter extends FlexiblePacketTypeFilter { +public class MessageTypeFilter extends FlexibleStanzaTypeFilter { - public static final PacketFilter NORMAL = new MessageTypeFilter(Type.normal); - public static final PacketFilter CHAT = new MessageTypeFilter(Type.chat); - public static final PacketFilter GROUPCHAT = new MessageTypeFilter(Type.groupchat); - public static final PacketFilter HEADLINE = new MessageTypeFilter(Type.headline); - public static final PacketFilter ERROR = new MessageTypeFilter(Type.error); - public static final PacketFilter NORMAL_OR_CHAT = new OrFilter(NORMAL, CHAT); - public static final PacketFilter NORMAL_OR_CHAT_OR_HEADLINE = new OrFilter(NORMAL_OR_CHAT, + public static final StanzaFilter NORMAL = new MessageTypeFilter(Type.normal); + public static final StanzaFilter CHAT = new MessageTypeFilter(Type.chat); + public static final StanzaFilter GROUPCHAT = new MessageTypeFilter(Type.groupchat); + public static final StanzaFilter HEADLINE = new MessageTypeFilter(Type.headline); + public static final StanzaFilter ERROR = new MessageTypeFilter(Type.error); + public static final StanzaFilter NORMAL_OR_CHAT = new OrFilter(NORMAL, CHAT); + public static final StanzaFilter NORMAL_OR_CHAT_OR_HEADLINE = new OrFilter(NORMAL_OR_CHAT, HEADLINE); private final Message.Type type; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageWithBodiesFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageWithBodiesFilter.java index 201e5546d..47ab3ab52 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageWithBodiesFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageWithBodiesFilter.java @@ -22,9 +22,9 @@ import org.jivesoftware.smack.packet.Message; /** * Filters message stanzas which have at least one body */ -public class MessageWithBodiesFilter extends FlexiblePacketTypeFilter { +public class MessageWithBodiesFilter extends FlexibleStanzaTypeFilter { - public static final PacketFilter INSTANCE = new MessageWithBodiesFilter(); + public static final StanzaFilter INSTANCE = new MessageWithBodiesFilter(); private MessageWithBodiesFilter() { super(Message.class); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageWithSubjectFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageWithSubjectFilter.java index c484aa2e8..cd3106261 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageWithSubjectFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/MessageWithSubjectFilter.java @@ -22,9 +22,9 @@ import org.jivesoftware.smack.packet.Message; /** * Filters message stanzas which have at least one body */ -public class MessageWithSubjectFilter extends FlexiblePacketTypeFilter { +public class MessageWithSubjectFilter extends FlexibleStanzaTypeFilter { - public static final PacketFilter INSTANCE = new MessageWithSubjectFilter(); + public static final StanzaFilter INSTANCE = new MessageWithSubjectFilter(); private MessageWithSubjectFilter() { super(Message.class); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/NotFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/NotFilter.java index 76d63ce9c..27c363e6b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/NotFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/NotFilter.java @@ -26,16 +26,16 @@ import org.jivesoftware.smack.util.Objects; * * @author Matt Tucker */ -public class NotFilter implements PacketFilter { +public class NotFilter implements StanzaFilter { - private final PacketFilter filter; + private final StanzaFilter filter; /** * Creates a NOT filter using the specified filter. * * @param filter the filter. */ - public NotFilter(PacketFilter filter) { + public NotFilter(StanzaFilter filter) { this.filter = Objects.requireNonNull(filter, "Parameter must not be null."); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/OrFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/OrFilter.java index b1d96eeef..4d4b1cb5b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/OrFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/OrFilter.java @@ -25,11 +25,11 @@ import org.jivesoftware.smack.packet.Stanza; * * @author Matt Tucker */ -public class OrFilter extends AbstractListFilter implements PacketFilter { +public class OrFilter extends AbstractListFilter implements StanzaFilter { /** * Creates an empty OR filter. Filters should be added using the - * {@link #addFilter(PacketFilter)} method. + * {@link #addFilter(StanzaFilter)} method. */ public OrFilter() { super(); @@ -40,13 +40,13 @@ public class OrFilter extends AbstractListFilter implements PacketFilter { * * @param filters the filters to add. */ - public OrFilter(PacketFilter... filters) { + public OrFilter(StanzaFilter... filters) { super(filters); } @Override public boolean accept(Stanza packet) { - for (PacketFilter filter : filters) { + for (StanzaFilter filter : filters) { if (filter.accept(packet)) { return true; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketExtensionFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketExtensionFilter.java index c0deb6183..71d98c718 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketExtensionFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketExtensionFilter.java @@ -18,15 +18,17 @@ package org.jivesoftware.smack.filter; import org.jivesoftware.smack.packet.Stanza; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.StringUtils; /** * Filters for packets with a particular type of packet extension. * * @author Matt Tucker + * @deprecated use {@link StanzaExtensionFilter} instead. */ -public class PacketExtensionFilter implements PacketFilter { +@Deprecated +public class PacketExtensionFilter implements StanzaFilter { private final String elementName; private final String namespace; @@ -61,7 +63,7 @@ public class PacketExtensionFilter implements PacketFilter { * * @param packetExtension */ - public PacketExtensionFilter(PacketExtension packetExtension) { + public PacketExtensionFilter(ExtensionElement packetExtension) { this(packetExtension.getElementName(), packetExtension.getNamespace()); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketFilter.java index 5aecfa2a2..b910a065b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketFilter.java @@ -17,8 +17,6 @@ package org.jivesoftware.smack.filter; -import org.jivesoftware.smack.packet.Stanza; - /** * Defines a way to filter packets for particular attributes. Packet filters are used when * constructing packet listeners or collectors -- the filter defines what packets match the criteria @@ -45,14 +43,9 @@ import org.jivesoftware.smack.packet.Stanza; * @see org.jivesoftware.smack.PacketCollector * @see org.jivesoftware.smack.PacketListener * @author Matt Tucker + * @deprecated use {@link StanzaFilter} */ -public interface PacketFilter { +@Deprecated +public interface PacketFilter extends StanzaFilter { - /** - * Tests whether or not the specified packet should pass the filter. - * - * @param packet the packet to test. - * @return true if and only if packet passes the filter. - */ - public boolean accept(Stanza packet); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java index e51d9c156..136a5e842 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java @@ -27,7 +27,7 @@ import org.jivesoftware.smack.util.StringUtils; * @deprecated use {@link StanzaIdFilter} instead. */ @Deprecated -public class PacketIDFilter implements PacketFilter { +public class PacketIDFilter implements StanzaFilter { private final String packetID; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketTypeFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketTypeFilter.java index 5a32e784c..bac9eab06 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketTypeFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketTypeFilter.java @@ -31,8 +31,10 @@ import org.jivesoftware.smack.packet.Presence; * * * @author Matt Tucker + * @deprecated use {@link StanzaTypeFilter} instead. */ -public class PacketTypeFilter implements PacketFilter { +@Deprecated +public class PacketTypeFilter implements StanzaFilter { public static final PacketTypeFilter PRESENCE = new PacketTypeFilter(Presence.class); public static final PacketTypeFilter MESSAGE = new PacketTypeFilter(Message.class); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/PresenceTypeFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/PresenceTypeFilter.java index d67635609..9a5ac3888 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/PresenceTypeFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/PresenceTypeFilter.java @@ -24,7 +24,7 @@ import org.jivesoftware.smack.util.Objects; * A filter for Presence types. Returns true only if the stanza is an Presence packet and it matches the type provided in the * constructor. */ -public class PresenceTypeFilter extends FlexiblePacketTypeFilter { +public class PresenceTypeFilter extends FlexibleStanzaTypeFilter { public static final PresenceTypeFilter AVAILABLE = new PresenceTypeFilter(Type.available); public static final PresenceTypeFilter UNAVAILABLE = new PresenceTypeFilter(Type.unavailable); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaExtensionFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaExtensionFilter.java new file mode 100644 index 000000000..e8fb46d46 --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaExtensionFilter.java @@ -0,0 +1,76 @@ +/** + * + * Copyright 2003-2007 Jive Software. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jivesoftware.smack.filter; + +import org.jivesoftware.smack.packet.Stanza; +import org.jivesoftware.smack.packet.ExtensionElement; +import org.jivesoftware.smack.util.StringUtils; + +/** + * Filters for stanzas with a particular type of stanza extension. + * + * @author Matt Tucker + */ +public class StanzaExtensionFilter implements StanzaFilter { + + private final String elementName; + private final String namespace; + + /** + * Creates a new stanza extension filter. Stanzas will pass the filter if + * they have a stanza extension that matches the specified element name + * and namespace. + * + * @param elementName the XML element name of the stanza extension. + * @param namespace the XML namespace of the stanza extension. + */ + public StanzaExtensionFilter(String elementName, String namespace) { + StringUtils.requireNotNullOrEmpty(namespace, "namespace must not be null or empty"); + + this.elementName = elementName; + this.namespace = namespace; + } + + /** + * Creates a new stanza extension filter. Stanzas will pass the filter if they have a stanza + * extension that matches the specified namespace. + * + * @param namespace the XML namespace of the stanza extension. + */ + public StanzaExtensionFilter(String namespace) { + this(null, namespace); + } + + /** + * Creates a new stanza extension filter for the given stanza extension. + * + * @param packetExtension + */ + public StanzaExtensionFilter(ExtensionElement packetExtension) { + this(packetExtension.getElementName(), packetExtension.getNamespace()); + } + + public boolean accept(Stanza packet) { + return packet.hasExtension(elementName, namespace); + } + + @Override + public String toString() { + return getClass().getSimpleName() + ": element=" + elementName + " namespace=" + namespace; + } +} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java new file mode 100644 index 000000000..77c2a9950 --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java @@ -0,0 +1,58 @@ +/** + * + * Copyright 2003-2007 Jive Software. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jivesoftware.smack.filter; + +import org.jivesoftware.smack.packet.Stanza; + +/** + * Defines a way to filter stanzas for particular attributes. Stanza filters are used when + * constructing stanza listeners or collectors -- the filter defines what stanzas match the criteria + * of the collector or listener for further stanza processing. + *

+ * Several simple filters are pre-defined. These filters can be logically combined for more complex + * stanza filtering by using the {@link org.jivesoftware.smack.filter.AndFilter AndFilter} and + * {@link org.jivesoftware.smack.filter.OrFilter OrFilter} filters. It's also possible to define + * your own filters by implementing this interface. The code example below creates a trivial filter + * for stanzas with a specific ID (real code should use {@link StanzaIdFilter} instead). + * + *

+ * // Use an anonymous inner class to define a stanza filter that returns
+ * // all stanzas that have a stanza ID of "RS145".
+ * StanzaFilter myFilter = new StanzaFilter() {
+ *     public boolean accept(Stanza stanza) {
+ *         return "RS145".equals(stanza.getStanzaId());
+ *     }
+ * };
+ * // Create a new stanza collector using the filter we created.
+ * PacketCollector myCollector = connection.createPacketCollector(myFilter);
+ * 
+ * + * @see org.jivesoftware.smack.PacketCollector + * @see org.jivesoftware.smack.PacketListener + * @author Matt Tucker + */ +public interface StanzaFilter { + + /** + * Tests whether or not the specified stanza should pass the filter. + * + * @param stanza the packet to test. + * @return true if and only if stanza passes the filter. + */ + public boolean accept(Stanza stanza); +} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaIdFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaIdFilter.java index bf123726b..3cc9740a1 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaIdFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaIdFilter.java @@ -25,7 +25,7 @@ import org.jivesoftware.smack.util.StringUtils; * * @author Matt Tucker */ -public class StanzaIdFilter implements PacketFilter { +public class StanzaIdFilter implements StanzaFilter { private final String stanzaId; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaTypeFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaTypeFilter.java new file mode 100644 index 000000000..c3c706e39 --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaTypeFilter.java @@ -0,0 +1,62 @@ +/** + * + * Copyright 2003-2007 Jive Software. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jivesoftware.smack.filter; + +import org.jivesoftware.smack.packet.Message; +import org.jivesoftware.smack.packet.Stanza; +import org.jivesoftware.smack.packet.Presence; +import org.jivesoftware.smack.packet.IQ; + +/** + * Filters for Stanzas of a particular type. The type is given as a Class object, so + * example types would: + *
    + *
  • Message.class + *
  • IQ.class + *
  • Presence.class + *
+ * + * @author Matt Tucker + */ +public final class StanzaTypeFilter implements StanzaFilter { + + public static final StanzaTypeFilter PRESENCE = new StanzaTypeFilter(Presence.class); + public static final StanzaTypeFilter MESSAGE = new StanzaTypeFilter(Message.class); + public static final StanzaTypeFilter IQ = new StanzaTypeFilter(IQ.class); + + private final Class packetType; + + /** + * Creates a new packet type filter that will filter for packets that are the + * same type as packetType. + * + * @param packetType the Class type. + */ + public StanzaTypeFilter(Class packetType) { + this.packetType = packetType; + } + + public boolean accept(Stanza packet) { + return packetType.isInstance(packet); + } + + @Override + public String toString() { + return getClass().getSimpleName() + ": " + packetType.getName(); + } +} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/ThreadFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/ThreadFilter.java index da1c3d7dd..3cae484c8 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/ThreadFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/ThreadFilter.java @@ -25,7 +25,7 @@ import org.jivesoftware.smack.util.StringUtils; * * @author Matt Tucker */ -public class ThreadFilter extends FlexiblePacketTypeFilter implements PacketFilter { +public class ThreadFilter extends FlexibleStanzaTypeFilter implements StanzaFilter { private final String thread; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/ToFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/ToFilter.java index a691537b2..1563771f7 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/ToFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/ToFilter.java @@ -20,7 +20,7 @@ import java.util.Locale; import org.jivesoftware.smack.packet.Stanza; -public class ToFilter implements PacketFilter { +public class ToFilter implements StanzaFilter { private final String to; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java index cb0276d8c..f950cc81d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java @@ -28,18 +28,18 @@ public class AbstractError { private final String textNamespace; protected final Map descriptiveTexts; - private final List extensions; + private final List extensions; protected AbstractError(Map descriptiveTexts) { this(descriptiveTexts, null); } - protected AbstractError(Map descriptiveTexts, List extensions) { + protected AbstractError(Map descriptiveTexts, List extensions) { this(descriptiveTexts, null, extensions); } - protected AbstractError(Map descriptiveTexts, String textNamespace, List extensions) { + protected AbstractError(Map descriptiveTexts, String textNamespace, List extensions) { if (descriptiveTexts != null) { this.descriptiveTexts = descriptiveTexts; } else { @@ -91,7 +91,7 @@ public class AbstractError { * @param namespace the XML element namespace of the packet extension. * @return the extension, or null if it doesn't exist. */ - public PE getExtension(String elementName, String namespace) { + public PE getExtension(String elementName, String namespace) { return PacketUtil.extensionElementFrom(extensions, elementName, namespace); } @@ -104,7 +104,7 @@ public class AbstractError { xml.escape(text); xml.closeElement("text"); } - for (PacketExtension packetExtension : extensions) { + for (ExtensionElement packetExtension : extensions) { xml.append(packetExtension.toXML()); } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Bind.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Bind.java index df59cc5f6..1a863d684 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Bind.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Bind.java @@ -68,7 +68,7 @@ public class Bind extends IQ { return xml; } - public static class Feature implements PacketExtension { + public static class Feature implements ExtensionElement { public static final Feature INSTANCE = new Feature(); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/DefaultPacketExtension.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/DefaultExtensionElement.java similarity index 92% rename from smack-core/src/main/java/org/jivesoftware/smack/packet/DefaultPacketExtension.java rename to smack-core/src/main/java/org/jivesoftware/smack/packet/DefaultExtensionElement.java index 45f32c0b9..dc3b64788 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/DefaultPacketExtension.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/DefaultExtensionElement.java @@ -25,7 +25,7 @@ import java.util.Map; import org.jivesoftware.smack.util.XmlStringBuilder; /** - * Default implementation of the PacketExtension interface. Unless a PacketExtensionProvider + * Default implementation of the ExtensionElement interface. Unless a ExtensionElementProvider * is registered with {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager}, * instances of this class will be returned when getting packet extensions.

* @@ -42,11 +42,11 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * In this case, getValue("color") would return "blue", and getValue("food") would * return "pizza". This parsing mechanism mechanism is very simplistic and will not work * as desired in all cases (for example, if some of the elements have attributes. In those - * cases, a custom PacketExtensionProvider should be used. + * cases, a custom ExtensionElementProvider should be used. * * @author Matt Tucker */ -public class DefaultPacketExtension implements PacketExtension { +public class DefaultExtensionElement implements ExtensionElement { private String elementName; private String namespace; @@ -58,7 +58,7 @@ public class DefaultPacketExtension implements PacketExtension { * @param elementName the name of the element of the XML sub-document. * @param namespace the namespace of the element. */ - public DefaultPacketExtension(String elementName, String namespace) { + public DefaultExtensionElement(String elementName, String namespace) { this.elementName = elementName; this.namespace = namespace; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Element.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Element.java index 17b38280d..e78df0523 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Element.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Element.java @@ -18,7 +18,7 @@ package org.jivesoftware.smack.packet; /** - * Interface to represent a XML element. This is similar to {@link PacketExtension}, but does not + * Interface to represent a XML element. This is similar to {@link ExtensionElement}, but does not * carry a namespace and is usually included as child element of an packet extension. */ public interface Element { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/ExtensionElement.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/ExtensionElement.java new file mode 100644 index 000000000..0f79fbe66 --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/ExtensionElement.java @@ -0,0 +1,46 @@ +/** + * + * Copyright 2003-2007 Jive Software. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jivesoftware.smack.packet; + +/** + * Interface to represent extension elements. + *

+ * An extension element is an XML subdocument + * with a root element name and namespace. Extension elements are used to provide + * extended functionality beyond what is in the base XMPP specification. Examples of + * extensions elements include message events, message properties, and extra presence data. + * IQ stanzas have limited support for extension elements. + *

+ * This class is used primarily for extended content in XMPP Stanzas, to act as so called "extension elements". For more + * information see RFC 6120 § 8.4 Extended Content. + *

+ * + * @see DefaultExtensionElement + * @see org.jivesoftware.smack.provider.ExtensionElementProvider + * @author Matt Tucker + */ +public interface ExtensionElement extends NamedElement { + + /** + * Returns the root element XML namespace. + * + * @return the namespace. + */ + public String getNamespace(); + +} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/FullStreamElement.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/FullStreamElement.java index f9a831732..6eaf908f3 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/FullStreamElement.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/FullStreamElement.java @@ -23,6 +23,6 @@ package org.jivesoftware.smack.packet; * * @author Florian Schmaus */ -public abstract class FullStreamElement implements PlainStreamElement, PacketExtension { +public abstract class FullStreamElement implements PlainStreamElement, ExtensionElement { } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java index 386795fc2..5e21aeb62 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java @@ -302,7 +302,7 @@ public abstract class IQ extends Stanza { this(iq.getChildElementName(), iq.getChildElementNamespace()); } - public IQChildElementXmlStringBuilder(PacketExtension pe) { + public IQChildElementXmlStringBuilder(ExtensionElement pe) { this(pe.getElementName(), pe.getNamespace()); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Mechanisms.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Mechanisms.java index 17657f7a7..ae6a82a1a 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Mechanisms.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Mechanisms.java @@ -23,7 +23,7 @@ import java.util.List; import org.jivesoftware.smack.util.XmlStringBuilder; -public class Mechanisms implements PacketExtension { +public class Mechanisms implements ExtensionElement { public static final String ELEMENT = "mechanisms"; public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-sasl"; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/NamedElement.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/NamedElement.java index 6a1f52ba4..1f2571601 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/NamedElement.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/NamedElement.java @@ -18,7 +18,7 @@ package org.jivesoftware.smack.packet; /** - * Interface to represent a XML element. This is similar to {@link PacketExtension}, but does not + * Interface to represent a XML element. This is similar to {@link ExtensionElement}, but does not * carry a namespace and is usually included as child element of an packet extension. */ public interface NamedElement extends Element { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Packet.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Packet.java index 55f301ed4..c0d59328b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Packet.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Packet.java @@ -132,7 +132,7 @@ public interface Packet extends TopLevelStreamElement { * * @return the packet extensions. */ - public List getExtensions(); + public List getExtensions(); /** * Return a set of all extensions with the given element name and namespace. @@ -145,7 +145,7 @@ public interface Packet extends TopLevelStreamElement { * @return a set of all matching extensions. * @since 4.1 */ - public Set getExtensions(String elementName, String namespace); + public Set getExtensions(String elementName, String namespace); /** * Returns the first extension of this packet that has the given namespace. @@ -156,7 +156,7 @@ public interface Packet extends TopLevelStreamElement { * @param namespace the namespace of the extension that is desired. * @return the packet extension with the given namespace. */ - public PacketExtension getExtension(String namespace); + public ExtensionElement getExtension(String namespace); /** * Returns the first packet extension that matches the specified element name and @@ -173,20 +173,20 @@ public interface Packet extends TopLevelStreamElement { * @param namespace the XML element namespace of the packet extension. * @return the extension, or null if it doesn't exist. */ - public PE getExtension(String elementName, String namespace); + public PE getExtension(String elementName, String namespace); /** * Adds a packet extension to the packet. Does nothing if extension is null. * * @param extension a packet extension. */ - public void addExtension(PacketExtension extension); + public void addExtension(ExtensionElement extension); /** * Adds a collection of packet extensions to the packet. Does nothing if extensions is null. * * @param extensions a collection of packet extensions */ - public void addExtensions(Collection extensions); + public void addExtensions(Collection extensions); /** * Check if a packet extension with the given element and namespace exists. @@ -215,7 +215,7 @@ public interface Packet extends TopLevelStreamElement { * @param namespace * @return the removed packet extension or null. */ - public PacketExtension removeExtension(String elementName, String namespace); + public ExtensionElement removeExtension(String elementName, String namespace); /** * Removes a packet extension from the packet. @@ -223,7 +223,7 @@ public interface Packet extends TopLevelStreamElement { * @param extension the packet extension to remove. * @return the removed packet extension or null. */ - public PacketExtension removeExtension(PacketExtension extension); + public ExtensionElement removeExtension(ExtensionElement extension); @Override // NOTE When Smack is using Java 8, then this method should be moved in Element as "Default Method". diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/PacketExtension.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/PacketExtension.java index 738c6b8e3..04108ebb5 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/PacketExtension.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/PacketExtension.java @@ -18,27 +18,24 @@ package org.jivesoftware.smack.packet; /** - * Interface to represent packet extensions. A packet extension is an XML subdocument - * with a root element name and namespace. Packet extensions are used to provide + * Interface to represent extension elements. + *

+ * An extension element is an XML subdocument + * with a root element name and namespace. Extension elements are used to provide * extended functionality beyond what is in the base XMPP specification. Examples of - * packet extensions include message events, message properties, and extra presence data. - * IQ packets cannot contain packet extensions. + * extensions elements include message events, message properties, and extra presence data. + * IQ stanzas have limited support for extension elements. *

* This class is used primarily for extended content in XMPP Stanzas, to act as so called "extension elements". For more * information see RFC 6120 § 8.4 Extended Content. *

* - * @see DefaultPacketExtension - * @see org.jivesoftware.smack.provider.PacketExtensionProvider + * @see DefaultExtensionElement + * @see org.jivesoftware.smack.provider.ExtensionElementProvider * @author Matt Tucker + * @deprecated use {@link ExtensionElement} instead. */ -public interface PacketExtension extends NamedElement { - - /** - * Returns the root element XML namespace. - * - * @return the namespace. - */ - public String getNamespace(); +@Deprecated +public interface PacketExtension extends ExtensionElement { } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Session.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Session.java index 6f7ba502f..ea74d4fdb 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Session.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Session.java @@ -42,7 +42,7 @@ public class Session extends SimpleIQ { setType(IQ.Type.set); } - public static class Feature implements PacketExtension { + public static class Feature implements ExtensionElement { public static final String OPTIONAL_ELEMENT = "optional"; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java index 790b921f5..b3319d681 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java @@ -54,7 +54,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { protected static final String DEFAULT_LANGUAGE = java.util.Locale.getDefault().getLanguage().toLowerCase(Locale.US); - private final MultiMap packetExtensions = new MultiMap<>(); + private final MultiMap packetExtensions = new MultiMap<>(); private String id = null; private String to = null; @@ -88,7 +88,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { error = p.error; // Copy extensions - for (PacketExtension pe : p.getExtensions()) { + for (ExtensionElement pe : p.getExtensions()) { addExtension(pe); } } @@ -234,7 +234,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { * * @return a list of all extension elements of this stanza. */ - public List getExtensions() { + public List getExtensions() { synchronized (packetExtensions) { // No need to create a new list, values() will already create a new one for us return packetExtensions.values(); @@ -252,7 +252,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { * @return a set of all matching extensions. * @since 4.1 */ - public Set getExtensions(String elementName, String namespace) { + public Set getExtensions(String elementName, String namespace) { requireNotNullOrEmpty(elementName, "elementName must not be null or empty"); requireNotNullOrEmpty(namespace, "namespace must not be null or empty"); String key = XmppStringUtils.generateKey(elementName, namespace); @@ -268,32 +268,32 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { * @param namespace the namespace of the extension that is desired. * @return the packet extension with the given namespace. */ - public PacketExtension getExtension(String namespace) { + public ExtensionElement getExtension(String namespace) { return PacketUtil.extensionElementFrom(getExtensions(), null, namespace); } /** - * Returns the first packet extension that matches the specified element name and + * Returns the first extension that matches the specified element name and * namespace, or null if it doesn't exist. If the provided elementName is null, - * only the namespace is matched. Packet extensions are + * only the namespace is matched. Extensions are * are arbitrary XML sub-documents in standard XMPP packets. By default, a - * DefaultPacketExtension instance will be returned for each extension. However, - * PacketExtensionProvider instances can be registered with the + * {@link DefaultExtensionElement} instance will be returned for each extension. However, + * ExtensionElementProvider instances can be registered with the * {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager} * class to handle custom parsing. In that case, the type of the Object * will be determined by the provider. * - * @param elementName the XML element name of the packet extension. (May be null) - * @param namespace the XML element namespace of the packet extension. + * @param elementName the XML element name of the extension. (May be null) + * @param namespace the XML element namespace of the extension. * @return the extension, or null if it doesn't exist. */ @SuppressWarnings("unchecked") - public PE getExtension(String elementName, String namespace) { + public PE getExtension(String elementName, String namespace) { if (namespace == null) { return null; } String key = XmppStringUtils.generateKey(elementName, namespace); - PacketExtension packetExtension; + ExtensionElement packetExtension; synchronized (packetExtensions) { packetExtension = packetExtensions.getFirst(key); } @@ -308,7 +308,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { * * @param extension a packet extension. */ - public void addExtension(PacketExtension extension) { + public void addExtension(ExtensionElement extension) { if (extension == null) return; String key = XmppStringUtils.generateKey(extension.getElementName(), extension.getNamespace()); synchronized (packetExtensions) { @@ -321,9 +321,9 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { * * @param extensions a collection of packet extensions */ - public void addExtensions(Collection extensions) { + public void addExtensions(Collection extensions) { if (extensions == null) return; - for (PacketExtension packetExtension : extensions) { + for (ExtensionElement packetExtension : extensions) { addExtension(packetExtension); } } @@ -356,7 +356,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { */ public boolean hasExtension(String namespace) { synchronized (packetExtensions) { - for (PacketExtension packetExtension : packetExtensions.values()) { + for (ExtensionElement packetExtension : packetExtensions.values()) { if (packetExtension.getNamespace().equals(namespace)) { return true; } @@ -372,7 +372,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { * @param namespace * @return the removed packet extension or null. */ - public PacketExtension removeExtension(String elementName, String namespace) { + public ExtensionElement removeExtension(String elementName, String namespace) { String key = XmppStringUtils.generateKey(elementName, namespace); synchronized (packetExtensions) { return packetExtensions.remove(key); @@ -385,7 +385,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { * @param extension the packet extension to remove. * @return the removed packet extension or null. */ - public PacketExtension removeExtension(PacketExtension extension) { + public ExtensionElement removeExtension(ExtensionElement extension) { return removeExtension(extension.getElementName(), extension.getNamespace()); } @@ -405,7 +405,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet { protected final XmlStringBuilder getExtensionsXML() { XmlStringBuilder xml = new XmlStringBuilder(); // Add in all standard extension sub-packets. - for (PacketExtension extension : getExtensions()) { + for (ExtensionElement extension : getExtensions()) { xml.append(extension.toXML()); } return xml; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/StreamError.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/StreamError.java index b83150928..7029f923b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/StreamError.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/StreamError.java @@ -104,7 +104,7 @@ public class StreamError extends AbstractError implements PlainStreamElement { private final Condition condition; private final String conditionText; - public StreamError(Condition condition, String conditionText, Map descriptiveTexts, List extensions) { + public StreamError(Condition condition, String conditionText, Map descriptiveTexts, List extensions) { super(descriptiveTexts, extensions); // Some implementations may send the condition as non-empty element containing the empty string, that is // , in this case the parser may calls this constructor with the empty string diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/XMPPError.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/XMPPError.java index 251883127..e76bb393a 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/XMPPError.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/XMPPError.java @@ -99,7 +99,7 @@ public class XMPPError extends AbstractError { this(condition, null, null, null, null, null); } - public XMPPError(Condition condition, PacketExtension applicationSpecificCondition) { + public XMPPError(Condition condition, ExtensionElement applicationSpecificCondition) { this(condition, null, null, null, null, Arrays.asList(applicationSpecificCondition)); } @@ -115,7 +115,7 @@ public class XMPPError extends AbstractError { * @param extensions list of packet extensions */ public XMPPError(Condition condition, String conditionText, String errorGenerator, Type type, Map descriptiveTexts, - List extensions) { + List extensions) { super(descriptiveTexts, NAMESPACE, extensions); this.condition = condition; // Some implementations may send the condition as non-empty element containing the empty string, that is diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java index e843fd619..0ecb625b2 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -61,7 +61,7 @@ import org.xmlpull.v1.XmlPullParserException; * ItemsProvider extends {@link EmbeddedExtensionProvider} * ItemProvider extends {@link EmbeddedExtensionProvider} * and - * AtomProvider extends {@link PacketExtensionProvider} + * AtomProvider extends {@link ExtensionElementProvider} * * These classes are then registered in the meta-inf/smack.providers file * as follows. @@ -81,7 +81,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Robin Collier */ -public abstract class EmbeddedExtensionProvider extends PacketExtensionProvider { +public abstract class EmbeddedExtensionProvider extends ExtensionElementProvider { @Override public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, @@ -95,13 +95,13 @@ public abstract class EmbeddedExtensionProvider exte attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i)); } - List extensions = new ArrayList<>(); + List extensions = new ArrayList<>(); int event; do { event = parser.next(); if (event == XmlPullParser.START_TAG) - PacketParserUtils.addPacketExtension(extensions, parser); + PacketParserUtils.addExtensionElement(extensions, parser); } while (!(event == XmlPullParser.END_TAG && parser.getDepth() == initialDepth)); @@ -109,5 +109,5 @@ public abstract class EmbeddedExtensionProvider exte } protected abstract PE createReturnExtension(String currentElement, String currentNamespace, - Map attributeMap, List content); + Map attributeMap, List content); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/PacketExtensionProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionElementProvider.java similarity index 77% rename from smack-core/src/main/java/org/jivesoftware/smack/provider/PacketExtensionProvider.java rename to smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionElementProvider.java index ca14527b1..b36b3316f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/PacketExtensionProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionElementProvider.java @@ -18,15 +18,15 @@ package org.jivesoftware.smack.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; /** - * An abstract class for parsing custom packets extensions. Each PacketExtensionProvider must + * An abstract class for parsing custom extensions elements. Each ExtensionElementProvider must * be registered with the ProviderManager class for it to be used. Every implementation * of this abstract class must have a public, no-argument constructor. * * @author Matt Tucker */ -public abstract class PacketExtensionProvider extends Provider { +public abstract class ExtensionElementProvider extends Provider { } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionProviderInfo.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionProviderInfo.java index acc4d54b9..9605b7439 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionProviderInfo.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionProviderInfo.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smack.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; /** * Defines the information required to register a packet extension Provider with the {@link ProviderManager} when using the @@ -28,13 +28,13 @@ import org.jivesoftware.smack.packet.PacketExtension; public final class ExtensionProviderInfo extends AbstractProviderInfo { /** - * Defines an extension provider which implements the PacketExtensionProvider interface. + * Defines an extension provider which implements the ExtensionElementProvider interface. * * @param elementName Element that provider parses. * @param namespace Namespace that provider parses. * @param extProvider The provider implementation. */ - public ExtensionProviderInfo(String elementName, String namespace, PacketExtensionProvider extProvider) { + public ExtensionProviderInfo(String elementName, String namespace, ExtensionElementProvider extProvider) { super(elementName, namespace, extProvider); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/IntrospectionProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/IntrospectionProvider.java index 7d57233d0..88549db4f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/IntrospectionProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/IntrospectionProvider.java @@ -21,7 +21,7 @@ import java.lang.reflect.InvocationTargetException; 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.util.ParserUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -51,7 +51,7 @@ public class IntrospectionProvider{ } } - public static abstract class PacketExtensionIntrospectionProvider extends PacketExtensionProvider { + public static abstract class PacketExtensionIntrospectionProvider extends ExtensionElementProvider { private final Class elementClass; protected PacketExtensionIntrospectionProvider(Class elementClass) { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java index cde78857d..2090401cc 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java @@ -25,12 +25,12 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.xmlpull.v1.XmlPullParserFactory; import org.xmlpull.v1.XmlPullParser; /** - * Loads the {@link IQProvider} and {@link PacketExtensionProvider} information from a standard provider file in preparation + * Loads the {@link IQProvider} and {@link ExtensionElementProvider} information from a standard provider file in preparation * for loading into the {@link ProviderManager}. * * @author Robin Collier @@ -95,8 +95,8 @@ public class ProviderFileLoader implements ProviderLoader { // a PacketExtension, add the class object itself and // then we'll use reflection later to create instances // of the class. - if (PacketExtensionProvider.class.isAssignableFrom(provider)) { - extProviders.add(new ExtensionProviderInfo(elementName, namespace, (PacketExtensionProvider) provider.newInstance())); + if (ExtensionElementProvider.class.isAssignableFrom(provider)) { + extProviders.add(new ExtensionProviderInfo(elementName, namespace, (ExtensionElementProvider) provider.newInstance())); } else { exceptions.add(new IllegalArgumentException(className @@ -106,7 +106,7 @@ public class ProviderFileLoader implements ProviderLoader { case "streamFeatureProvider": sfProviders.add(new StreamFeatureProviderInfo(elementName, namespace, - (PacketExtensionProvider) provider.newInstance())); + (ExtensionElementProvider) provider.newInstance())); break; default: LOGGER.warning("Unknown provider type: " + typeName); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java index 5e22d2115..360d29f82 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java @@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.StringUtils; import org.jxmpp.util.XmppStringUtils; @@ -109,9 +109,9 @@ import org.jxmpp.util.XmppStringUtils; */ public final class ProviderManager { - private static final Map> extensionProviders = new ConcurrentHashMap>(); + private static final Map> extensionProviders = new ConcurrentHashMap>(); private static final Map> iqProviders = new ConcurrentHashMap>(); - private static final Map> streamFeatureProviders = new ConcurrentHashMap>(); + private static final Map> streamFeatureProviders = new ConcurrentHashMap>(); static { // Ensure that Smack is initialized by calling getVersion, so that user @@ -138,7 +138,7 @@ public final class ProviderManager { if (loader.getStreamFeatureProviderInfo() != null) { for (StreamFeatureProviderInfo info : loader.getStreamFeatureProviderInfo()) { addStreamFeatureProvider(info.getElementName(), info.getNamespace(), - (PacketExtensionProvider) info.getProvider()); + (ExtensionElementProvider) info.getProvider()); } } } @@ -238,7 +238,7 @@ public final class ProviderManager { * @param namespace namespace associated with extension provider. * @return the extenion provider. */ - public static PacketExtensionProvider getExtensionProvider(String elementName, String namespace) { + public static ExtensionElementProvider getExtensionProvider(String elementName, String namespace) { String key = getKey(elementName, namespace); return extensionProviders.get(key); } @@ -259,8 +259,8 @@ public final class ProviderManager { validate(elementName, namespace); // First remove existing providers String key = removeExtensionProvider(elementName, namespace); - if (provider instanceof PacketExtensionProvider) { - extensionProviders.put(key, (PacketExtensionProvider) provider); + if (provider instanceof ExtensionElementProvider) { + extensionProviders.put(key, (ExtensionElementProvider) provider); } else { throw new IllegalArgumentException("Provider must be a PacketExtensionProvider"); } @@ -288,18 +288,18 @@ public final class ProviderManager { * * @return all PacketExtensionProvider instances. */ - public static List> getExtensionProviders() { - List> providers = new ArrayList<>(extensionProviders.size()); + public static List> getExtensionProviders() { + List> providers = new ArrayList<>(extensionProviders.size()); providers.addAll(extensionProviders.values()); return providers; } - public static PacketExtensionProvider getStreamFeatureProvider(String elementName, String namespace) { + public static ExtensionElementProvider getStreamFeatureProvider(String elementName, String namespace) { String key = getKey(elementName, namespace); return streamFeatureProviders.get(key); } - public static void addStreamFeatureProvider(String elementName, String namespace, PacketExtensionProvider provider) { + public static void addStreamFeatureProvider(String elementName, String namespace, ExtensionElementProvider provider) { validate(elementName, namespace); String key = getKey(elementName, namespace); streamFeatureProviders.put(key, provider); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProviderInfo.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProviderInfo.java index 040b98752..1e48e51f9 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProviderInfo.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProviderInfo.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smack.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; /** * @@ -31,7 +31,7 @@ public final class StreamFeatureProviderInfo extends AbstractProviderInfo { * @param extProvider The provider implementation. */ public StreamFeatureProviderInfo(String elementName, String namespace, - PacketExtensionProvider extProvider) { + ExtensionElementProvider extProvider) { super(elementName, namespace, extProvider); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index 54f994609..cebc9934b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -30,13 +30,13 @@ import java.util.logging.Logger; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.compress.packet.Compress; -import org.jivesoftware.smack.packet.DefaultPacketExtension; +import org.jivesoftware.smack.packet.DefaultExtensionElement; import org.jivesoftware.smack.packet.EmptyResultIQ; import org.jivesoftware.smack.packet.ErrorIQ; import org.jivesoftware.smack.packet.IQ; 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.Presence; import org.jivesoftware.smack.packet.Session; import org.jivesoftware.smack.packet.StartTls; @@ -44,7 +44,7 @@ import org.jivesoftware.smack.packet.StreamError; import org.jivesoftware.smack.packet.UnparsedIQ; 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.provider.ProviderManager; import org.jivesoftware.smack.sasl.packet.SaslStreamElements.SASLFailure; import org.xmlpull.v1.XmlPullParser; @@ -284,7 +284,7 @@ public class PacketParserUtils { message.setError(parseError(parser)); break; default: - PacketParserUtils.addPacketExtension(message, parser, elementName, namespace); + PacketParserUtils.addExtensionElement(message, parser, elementName, namespace); break; } break; @@ -574,7 +574,7 @@ public class PacketParserUtils { // Be extra robust: Skip PacketExtensions that cause Exceptions, instead of // failing completely here. See SMACK-390 for more information. try { - PacketParserUtils.addPacketExtension(presence, parser, elementName, namespace); + PacketParserUtils.addExtensionElement(presence, parser, elementName, namespace); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to parse extension packet in Presence packet.", e); } @@ -797,7 +797,7 @@ public class PacketParserUtils { public static StreamError parseStreamError(XmlPullParser parser) throws IOException, XmlPullParserException, SmackException { final int initialDepth = parser.getDepth(); - List extensions = new ArrayList(); + List extensions = new ArrayList(); Map descriptiveTexts = null; StreamError.Condition condition = null; String conditionText = null; @@ -824,7 +824,7 @@ public class PacketParserUtils { } break; default: - PacketParserUtils.addPacketExtension(extensions, parser, name, namespace); + PacketParserUtils.addExtensionElement(extensions, parser, name, namespace); break; } break; @@ -853,7 +853,7 @@ public class PacketParserUtils { Map descriptiveTexts = null; XMPPError.Condition condition = null; String conditionText = null; - List extensions = new ArrayList(); + List extensions = new ArrayList(); // Parse the error header XMPPError.Type errorType = XMPPError.Type.fromString(parser.getAttributeValue("", "type")); @@ -880,7 +880,7 @@ public class PacketParserUtils { } break; default: - PacketParserUtils.addPacketExtension(extensions, parser, name, namespace); + PacketParserUtils.addExtensionElement(extensions, parser, name, namespace); } break; case XmlPullParser.END_TAG: @@ -893,26 +893,36 @@ public class PacketParserUtils { } /** - * Parses a packet extension sub-packet. + * @deprecated use {@link #parseExtensionElement(String, String, XmlPullParser)} instead. + */ + @Deprecated + public static ExtensionElement parsePacketExtension(String elementName, String namespace, + XmlPullParser parser) throws XmlPullParserException, + IOException, SmackException { + return parseExtensionElement(elementName, namespace, parser); + } + + /** + * Parses an extension element. * - * @param elementName the XML element name of the packet extension. + * @param elementName the XML element name of the extension element. * @param namespace the XML namespace of the packet extension. * @param parser the XML parser, positioned at the starting element of the extension. - * @return a PacketExtension. + * @return an extension element. */ - public static PacketExtension parsePacketExtension(String elementName, String namespace, + public static ExtensionElement parseExtensionElement(String elementName, String namespace, XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { ParserUtils.assertAtStartTag(parser); // See if a provider is registered to handle the extension. - PacketExtensionProvider provider = ProviderManager.getExtensionProvider(elementName, namespace); + ExtensionElementProvider provider = ProviderManager.getExtensionProvider(elementName, namespace); if (provider != null) { return provider.parse(parser); } final int initialDepth = parser.getDepth(); // No providers registered, so use a default extension. - DefaultPacketExtension extension = new DefaultPacketExtension(elementName, namespace); + DefaultExtensionElement extension = new DefaultExtensionElement(elementName, namespace); outerloop: while (true) { int eventType = parser.next(); switch (eventType) { @@ -1005,27 +1015,53 @@ public class PacketParserUtils { return null; } + @Deprecated public static void addPacketExtension(Stanza packet, XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { - ParserUtils.assertAtStartTag(parser); - addPacketExtension(packet, parser, parser.getName(), parser.getNamespace()); + addExtensionElement(packet, parser); } + @Deprecated public static void addPacketExtension(Stanza packet, XmlPullParser parser, String elementName, String namespace) throws XmlPullParserException, IOException, SmackException { - PacketExtension packetExtension = parsePacketExtension(elementName, namespace, parser); + addExtensionElement(packet, parser, elementName, namespace); + } + + @Deprecated + public static void addPacketExtension(Collection collection, XmlPullParser parser) + throws XmlPullParserException, IOException, SmackException { + addExtensionElement(collection, parser, parser.getName(), parser.getNamespace()); + } + + @Deprecated + public static void addPacketExtension(Collection collection, XmlPullParser parser, + String elementName, String namespace) throws XmlPullParserException, IOException, SmackException { + addExtensionElement(collection, parser, elementName, namespace); + } + + + public static void addExtensionElement(Stanza packet, XmlPullParser parser) + throws XmlPullParserException, IOException, SmackException { + ParserUtils.assertAtStartTag(parser); + addExtensionElement(packet, parser, parser.getName(), parser.getNamespace()); + } + + public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName, + String namespace) throws XmlPullParserException, IOException, SmackException { + ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); packet.addExtension(packetExtension); } - public static void addPacketExtension(Collection collection, XmlPullParser parser) - throws XmlPullParserException, IOException, SmackException { - addPacketExtension(collection, parser, parser.getName(), parser.getNamespace()); + public static void addExtensionElement(Collection collection, + XmlPullParser parser) throws XmlPullParserException, IOException, + SmackException { + addExtensionElement(collection, parser, parser.getName(), parser.getNamespace()); } - public static void addPacketExtension(Collection collection, XmlPullParser parser, - String elementName, String namespace) throws XmlPullParserException, IOException, SmackException { - PacketExtension packetExtension = parsePacketExtension(elementName, namespace, parser); + public static void addExtensionElement(Collection collection, + XmlPullParser parser, String elementName, String namespace) + throws XmlPullParserException, IOException, SmackException { + ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); collection.add(packetExtension); } - } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketUtil.java index 3b3b30a77..97673f74c 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketUtil.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketUtil.java @@ -18,7 +18,7 @@ package org.jivesoftware.smack.util; import java.util.Collection; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; public class PacketUtil { @@ -32,8 +32,8 @@ public class PacketUtil { * @deprecated use {@link #extensionElementFrom(Collection, String, String)} instead */ @Deprecated - public static PE packetExtensionfromCollection( - Collection collection, String element, + public static PE packetExtensionfromCollection( + Collection collection, String element, String namespace) { return extensionElementFrom(collection, element, namespace); } @@ -47,9 +47,9 @@ public class PacketUtil { * @return the extension element */ @SuppressWarnings("unchecked") - public static PE extensionElementFrom(Collection collection, + public static PE extensionElementFrom(Collection collection, String element, String namespace) { - for (PacketExtension packetExtension : collection) { + for (ExtensionElement packetExtension : collection) { if ((element == null || packetExtension.getElementName().equals( element)) && packetExtension.getNamespace().equals(namespace)) { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java b/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java index 0f7ebe138..43c86325b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java @@ -20,7 +20,7 @@ import java.util.Collection; import org.jivesoftware.smack.packet.Element; import org.jivesoftware.smack.packet.NamedElement; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; public class XmlStringBuilder implements Appendable, CharSequence { public static final String RIGHT_ANGLE_BRACKET = Character.toString('>'); @@ -31,7 +31,7 @@ public class XmlStringBuilder implements Appendable, CharSequence { sb = new LazyStringBuilder(); } - public XmlStringBuilder(PacketExtension pe) { + public XmlStringBuilder(ExtensionElement pe) { this(); prelude(pe); } @@ -244,7 +244,7 @@ public class XmlStringBuilder implements Appendable, CharSequence { return this; } - public XmlStringBuilder prelude(PacketExtension pe) { + public XmlStringBuilder prelude(ExtensionElement pe) { return prelude(pe.getElementName(), pe.getNamespace()); } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/PacketCollectorTest.java b/smack-core/src/test/java/org/jivesoftware/smack/PacketCollectorTest.java index e2e3b633b..41c0abbd5 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/PacketCollectorTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/PacketCollectorTest.java @@ -19,7 +19,7 @@ package org.jivesoftware.smack; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.Stanza; import org.junit.Test; @@ -175,7 +175,7 @@ public class PacketCollectorTest assertNull(collector.pollResult()); } - class OKEverything implements PacketFilter + class OKEverything implements StanzaFilter { @Override public boolean accept(Stanza packet) @@ -187,9 +187,9 @@ public class PacketCollectorTest class TestPacketCollector extends PacketCollector { - protected TestPacketCollector(XMPPConnection conection, PacketFilter packetFilter, int size) + protected TestPacketCollector(XMPPConnection conection, StanzaFilter packetFilter, int size) { - super(conection, PacketCollector.newConfiguration().setPacketFilter(packetFilter).setSize(size)); + super(conection, PacketCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size)); } } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/packet/StreamErrorTest.java b/smack-core/src/test/java/org/jivesoftware/smack/packet/StreamErrorTest.java index 905fb773e..a596614d2 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/packet/StreamErrorTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/packet/StreamErrorTest.java @@ -99,7 +99,7 @@ public class StreamErrorTest { assertNotNull(error); assertEquals(Condition.conflict, error.getCondition()); assertEquals("Replaced by new connection", error.getDescriptiveText()); - PacketExtension appSpecificElement = error.getExtension("appSpecificElement", "myns"); + ExtensionElement appSpecificElement = error.getExtension("appSpecificElement", "myns"); assertNotNull(appSpecificElement); } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java b/smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java index 9b568816b..a82f4ff58 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java @@ -20,8 +20,8 @@ import static org.junit.Assert.assertThat; import static org.jivesoftware.smack.test.util.CharsequenceEquals.equalsCharSequence; 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.test.util.TestUtils; import org.jivesoftware.smack.util.PacketParserUtils; @@ -72,12 +72,12 @@ public class ParsingExceptionTest { assertThat(MESSAGE_EXCEPTION_ELEMENT + EXTENSION2 + "
", equalsCharSequence(content)); } - static class ThrowException extends PacketExtensionProvider { + static class ThrowException extends ExtensionElementProvider { public static final String ELEMENT = "exception"; public static final String NAMESPACE = "http://smack.jivesoftware.org/exception"; @Override - public PacketExtension parse(XmlPullParser parser, int initialDepth) throws SmackException { + public ExtensionElement parse(XmlPullParser parser, int initialDepth) throws SmackException { throw new SmackException("Test Exception"); } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/packet/CarbonExtension.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/packet/CarbonExtension.java index f890d5631..64be4a00b 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/packet/CarbonExtension.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/packet/CarbonExtension.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.carbons.packet; import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smackx.forward.packet.Forwarded; @@ -32,7 +32,7 @@ import org.jivesoftware.smackx.forward.packet.Forwarded; * * @author Georg Lukas */ -public class CarbonExtension implements PacketExtension { +public class CarbonExtension implements ExtensionElement { public static final String NAMESPACE = Carbon.NAMESPACE; private final Direction dir; @@ -131,7 +131,7 @@ public class CarbonExtension implements PacketExtension { * Packet extension indicating that a message may not be carbon-copied. Adding this * extension to any message will disallow that message from being copied. */ - public static class Private implements PacketExtension { + public static class Private implements ExtensionElement { public static final Private INSTANCE = new Private(); public static final String ELEMENT = "private"; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java index 2d3c86c6b..65c90ef63 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.carbons.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.carbons.packet.CarbonExtension; import org.jivesoftware.smackx.carbons.packet.CarbonExtension.Direction; import org.jivesoftware.smackx.forward.packet.Forwarded; @@ -28,13 +28,13 @@ 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 * carbon copied messages from a packet. It will return a {@link CarbonExtension} packet extension. * * @author Georg Lukas * */ -public class CarbonManagerProvider extends PacketExtensionProvider { +public class CarbonManagerProvider extends ExtensionElementProvider { private static final ForwardedProvider FORWARDED_PROVIDER = new ForwardedProvider(); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/packet/ClientStateIndication.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/packet/ClientStateIndication.java index 790a90259..890a862c9 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/packet/ClientStateIndication.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/packet/ClientStateIndication.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.csi.packet; import org.jivesoftware.smack.packet.FullStreamElement; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; /** * @@ -73,7 +73,7 @@ public class ClientStateIndication { } } - public static class Feature implements PacketExtension { + public static class Feature implements ExtensionElement { public static final Feature INSTANCE = new Feature(); public static final String ELEMENT = "csi"; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/provider/ClientStateIndicationFeatureProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/provider/ClientStateIndicationFeatureProvider.java index c6c98eb46..95685e0af 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/provider/ClientStateIndicationFeatureProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/provider/ClientStateIndicationFeatureProvider.java @@ -19,12 +19,12 @@ package org.jivesoftware.smackx.csi.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.csi.packet.ClientStateIndication; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -public class ClientStateIndicationFeatureProvider extends PacketExtensionProvider { +public class ClientStateIndicationFeatureProvider extends ExtensionElementProvider { @Override public ClientStateIndication.Feature parse(XmlPullParser parser, int initialDepth) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/packet/Base64BinaryChunk.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/packet/Base64BinaryChunk.java index 7292b98d3..b4e747ac6 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/packet/Base64BinaryChunk.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/packet/Base64BinaryChunk.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.hoxt.packet; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smackx.hoxt.HOXTManager; /** @@ -26,7 +26,7 @@ import org.jivesoftware.smackx.hoxt.HOXTManager; * @author Andriy Tsykholyas * @see XEP-0332: HTTP over XMPP transport */ -public class Base64BinaryChunk implements PacketExtension { +public class Base64BinaryChunk implements ExtensionElement { public static final String ELEMENT_CHUNK = "chunk"; public static final String ATTRIBUTE_STREAM_ID = "streamId"; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProvider.java index 5f160aeb7..fd6578749 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProvider.java @@ -18,7 +18,7 @@ package org.jivesoftware.smackx.hoxt.provider; import java.io.IOException; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.hoxt.packet.Base64BinaryChunk; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -29,7 +29,7 @@ import org.xmlpull.v1.XmlPullParserException; * @author Andriy Tsykholyas * @see XEP-0332: HTTP over XMPP transport */ -public class Base64BinaryChunkProvider extends PacketExtensionProvider { +public class Base64BinaryChunkProvider extends ExtensionElementProvider { @Override public Base64BinaryChunk parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/json/packet/AbstractJsonPacketExtension.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/json/packet/AbstractJsonPacketExtension.java index 6cbccbfb0..616c6ea4d 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/json/packet/AbstractJsonPacketExtension.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/json/packet/AbstractJsonPacketExtension.java @@ -16,10 +16,10 @@ */ package org.jivesoftware.smackx.json.packet; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.XmlStringBuilder; -public abstract class AbstractJsonPacketExtension implements PacketExtension { +public abstract class AbstractJsonPacketExtension implements ExtensionElement { private final String json; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/json/provider/AbstractJsonExtensionProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/json/provider/AbstractJsonExtensionProvider.java index 4e2c37d14..821557017 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/json/provider/AbstractJsonExtensionProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/json/provider/AbstractJsonExtensionProvider.java @@ -19,13 +19,13 @@ package org.jivesoftware.smackx.json.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.smack.util.PacketParserUtils; import org.jivesoftware.smackx.json.packet.AbstractJsonPacketExtension; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -public abstract class AbstractJsonExtensionProvider extends PacketExtensionProvider { +public abstract class AbstractJsonExtensionProvider extends ExtensionElementProvider { @Override public AbstractJsonPacketExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProviderTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProviderTest.java index a96bcca5b..a4b00dd23 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProviderTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProviderTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.hoxt.packet.Base64BinaryChunk; import org.junit.Test; @@ -39,7 +39,7 @@ public class Base64BinaryChunkProviderTest { Base64BinaryChunkProvider provider = new Base64BinaryChunkProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string); - PacketExtension extension = provider.parse(parser); + ExtensionElement extension = provider.parse(parser); assertTrue(extension instanceof Base64BinaryChunk); Base64BinaryChunk chunk = (Base64BinaryChunk) extension; @@ -57,7 +57,7 @@ public class Base64BinaryChunkProviderTest { Base64BinaryChunkProvider provider = new Base64BinaryChunkProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string); - PacketExtension extension = provider.parse(parser); + ExtensionElement extension = provider.parse(parser); assertTrue(extension instanceof Base64BinaryChunk); Base64BinaryChunk chunk = (Base64BinaryChunk) extension; diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/GroupChatInvitationTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/GroupChatInvitationTest.java index 991650801..89f48278c 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/GroupChatInvitationTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/GroupChatInvitationTest.java @@ -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; /** * @@ -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); } diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/entitycaps/EntityCapsTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/entitycaps/EntityCapsTest.java index 94115dbce..4439062c5 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/entitycaps/EntityCapsTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/entitycaps/EntityCapsTest.java @@ -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); diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/packet/MessageEventTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/packet/MessageEventTest.java index 4006051e6..57f180ae9 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/packet/MessageEventTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/packet/MessageEventTest.java @@ -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; diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/packet/XHTMLExtensionTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/packet/XHTMLExtensionTest.java index a301bb131..4054e3cc5 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/packet/XHTMLExtensionTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/packet/XHTMLExtensionTest.java @@ -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) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/packet/MultipleAddresses.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/packet/MultipleAddresses.java index 18b1d4265..9fe631d5d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/packet/MultipleAddresses.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/packet/MultipleAddresses.java @@ -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 java.util.ArrayList; @@ -29,7 +29,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"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java index 77e3d6313..352ca10a1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java @@ -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.smackx.address.packet.MultipleAddresses; import org.jivesoftware.smackx.address.packet.MultipleAddresses.Type; import org.xmlpull.v1.XmlPullParser; @@ -30,7 +30,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Gaston Dombiak */ -public class MultipleAddressesProvider extends PacketExtensionProvider { +public class MultipleAddressesProvider extends ExtensionElementProvider { @Override public MultipleAddresses parse(XmlPullParser parser, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/packet/AMPExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/packet/AMPExtension.java index 44dddd566..55f803896 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/packet/AMPExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/packet/AMPExtension.java @@ -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"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/provider/AMPExtensionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/provider/AMPExtensionProvider.java index 0d1d3c379..b47d8ea04 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/provider/AMPExtensionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/provider/AMPExtensionProvider.java @@ -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 { +public class AMPExtensionProvider extends ExtensionElementProvider { private static final Logger LOGGER = Logger.getLogger(AMPExtensionProvider.class.getName()); /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/attention/packet/AttentionExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/attention/packet/AttentionExtension.java index d7b667635..a812fdd26 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/attention/packet/AttentionExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/attention/packet/AttentionExtension.java @@ -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 XEP-0224: Attention */ -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 { + public static class Provider extends ExtensionElementProvider { @Override public AttentionExtension parse(XmlPullParser parser, int initialDepth) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java index c4fb9e3b7..233c40075 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java @@ -19,8 +19,8 @@ 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.filter.StanzaFilter; +import org.jivesoftware.smack.filter.StanzaTypeFilter; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smackx.bytestreams.ibb.packet.Data; @@ -44,8 +44,8 @@ class DataListener implements PacketListener { private final InBandBytestreamManager manager; /* packet filter for all In-Band Bytestream data packets */ - private final PacketFilter dataFilter = new AndFilter( - new PacketTypeFilter(Data.class)); + private final StanzaFilter dataFilter = new AndFilter( + new StanzaTypeFilter(Data.class)); /** * Constructor. @@ -70,7 +70,7 @@ class DataListener implements PacketListener { * * @return the packet filter for In-Band Bytestream data packets */ - protected PacketFilter getFilter() { + protected StanzaFilter getFilter() { return this.dataFilter; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java index f5a0a1719..77f9ac148 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java @@ -28,8 +28,8 @@ import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.PacketListener; 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; @@ -279,7 +279,7 @@ public class InBandBytestreamSession implements BytestreamSession { * * @return the data packet filter */ - protected abstract PacketFilter getDataPacketFilter(); + protected abstract StanzaFilter getDataPacketFilter(); public synchronized int read() throws IOException { checkClosed(); @@ -489,12 +489,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()); } } @@ -536,12 +536,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()); } } @@ -551,7 +551,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 diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataPacketExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataPacketExtension.java index 71534f8c9..11e1a0a2a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataPacketExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataPacketExtension.java @@ -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. diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/DataPacketProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/DataPacketProvider.java index a3375ba08..b30c29418 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/DataPacketProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/DataPacketProvider.java @@ -46,7 +46,7 @@ public class DataPacketProvider { } } - public static class PacketExtensionProvider extends org.jivesoftware.smack.provider.PacketExtensionProvider { + public static class PacketExtensionProvider extends org.jivesoftware.smack.provider.ExtensionElementProvider { @Override public DataPacketExtension parse(XmlPullParser parser, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java index 9bf3370c5..a5879ae4a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java @@ -27,13 +27,13 @@ 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; @@ -90,11 +90,11 @@ public class EntityCapsManager extends Manager { private static Map 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 @@ -482,7 +482,7 @@ public class EntityCapsManager extends Manager { final List identities = new LinkedList(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities()); sdm.setNodeInformationProvider(entityNode + '#' + currentCapsVersion, new AbstractNodeInformationProvider() { List features = sdm.getFeatures(); - List packetExtensions = sdm.getExtendedInfoAsList(); + List packetExtensions = sdm.getExtendedInfoAsList(); @Override public List getNodeFeatures() { return features; @@ -492,7 +492,7 @@ public class EntityCapsManager extends Manager { return identities; } @Override - public List getNodePacketExtensions() { + public List getNodePacketExtensions() { return packetExtensions; } }); @@ -553,7 +553,7 @@ public class EntityCapsManager extends Manager { */ protected static boolean verifyPacketExtensions(DiscoverInfo info) { List foundFormTypes = new LinkedList(); - 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()) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/packet/CapsExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/packet/CapsExtension.java index 03369ccdb..4c1bb701e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/packet/CapsExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/packet/CapsExtension.java @@ -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"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java index 1835d5e10..0eba8f4e2 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java @@ -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 { +public class CapsExtensionProvider extends ExtensionElementProvider { public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/ChatStateManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/ChatStateManager.java index 0dd4278e7..bc0aab9b7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/ChatStateManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/ChatStateManager.java @@ -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 INSTANCES = new WeakHashMap(); - 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 @@ -170,7 +170,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; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/packet/ChatStateExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/packet/ChatStateExtension.java index 3e6e456eb..8aac8339c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/packet/ChatStateExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/packet/ChatStateExtension.java @@ -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 { + public static class Provider extends ExtensionElementProvider { @Override public ChatStateExtension parse(XmlPullParser parser, int initialDepth) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/packet/AdHocCommandData.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/packet/AdHocCommandData.java index fc58c8088..28d67fdd4 100755 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/packet/AdHocCommandData.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/packet/AdHocCommandData.java @@ -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; @@ -237,7 +237,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"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java index 541705258..f95c46aca 100755 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java @@ -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 { return adHocCommandData; } - public static class BadActionError extends PacketExtensionProvider { + public static class BadActionError extends ExtensionElementProvider { @Override public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badAction); } } - public static class MalformedActionError extends PacketExtensionProvider { + public static class MalformedActionError extends ExtensionElementProvider { @Override public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.malformedAction); } } - public static class BadLocaleError extends PacketExtensionProvider { + public static class BadLocaleError extends ExtensionElementProvider { @Override public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badLocale); } } - public static class BadPayloadError extends PacketExtensionProvider { + public static class BadPayloadError extends ExtensionElementProvider { @Override public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badPayload); } } - public static class BadSessionIDError extends PacketExtensionProvider { + public static class BadSessionIDError extends ExtensionElementProvider { @Override public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badSessionid); } } - public static class SessionExpiredError extends PacketExtensionProvider { + public static class SessionExpiredError extends ExtensionElementProvider { @Override public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.sessionExpired); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/DelayInformationManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/DelayInformationManager.java index 9a828c10d..fcd8fa08c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/DelayInformationManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/DelayInformationManager.java @@ -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; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/filter/DelayedStanzaFilter.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/filter/DelayedStanzaFilter.java index 5355c2ec6..433d157a2 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/filter/DelayedStanzaFilter.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/filter/DelayedStanzaFilter.java @@ -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() { } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/packet/DelayInformation.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/packet/DelayInformation.java index cdcb83da4..8786bef17 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/packet/DelayInformation.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/packet/DelayInformation.java @@ -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"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java index 991bb49aa..812a790d8 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java @@ -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 { +public abstract class AbstractDelayInformationProvider extends ExtensionElementProvider { @Override public final DelayInformation parse(XmlPullParser parser, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/AbstractNodeInformationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/AbstractNodeInformationProvider.java index 7cfb6d2fd..426b59fde 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/AbstractNodeInformationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/AbstractNodeInformationProvider.java @@ -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 getNodePacketExtensions() { + public List getNodePacketExtensions() { return null; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/NodeInformationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/NodeInformationProvider.java index 41c2d7855..42c68ddb4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/NodeInformationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/NodeInformationProvider.java @@ -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 getNodePacketExtensions(); + List getNodePacketExtensions(); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java index 267bd2e11..339e3755e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java @@ -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; @@ -445,10 +445,10 @@ public class ServiceDiscoveryManager extends Manager { * * @return the data form as List of PacketExtensions */ - public List getExtendedInfoAsList() { - List res = null; + public List getExtendedInfoAsList() { + List res = null; if (extendedInfo != null) { - res = new ArrayList(1); + res = new ArrayList(1); res.add(extendedInfo); } return res; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java index 8707485a7..40f9587d3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java @@ -61,7 +61,7 @@ public class DiscoverInfoProvider extends IQProvider { } // 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")) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java index 25ff808c4..cd957db1d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java @@ -36,7 +36,7 @@ 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.filter.StanzaFilter; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smackx.si.packet.StreamInitiation; @@ -51,8 +51,8 @@ public class FaultTolerantNegotiator extends StreamNegotiator { private final StreamNegotiator primaryNegotiator; private final StreamNegotiator secondaryNegotiator; private final XMPPConnection connection; - private PacketFilter primaryFilter; - private PacketFilter secondaryFilter; + private StanzaFilter primaryFilter; + private StanzaFilter secondaryFilter; public FaultTolerantNegotiator(XMPPConnection connection, StreamNegotiator primary, StreamNegotiator secondary) { @@ -61,7 +61,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator { this.connection = connection; } - public PacketFilter getInitiationPacketFilter(String from, String streamID) { + public StanzaFilter getInitiationPacketFilter(String from, String streamID) { if (primaryFilter == null || secondaryFilter == null) { primaryFilter = primaryNegotiator.getInitiationPacketFilter(from, streamID); secondaryFilter = secondaryNegotiator.getInitiationPacketFilter(from, streamID); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java index 578f5ffdd..c2895b2f5 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java @@ -24,11 +24,12 @@ 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.FlexibleStanzaTypeFilter; import org.jivesoftware.smack.filter.FromMatchesFilter; -import org.jivesoftware.smack.filter.PacketFilter; -import org.jivesoftware.smack.filter.PacketTypeFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Stanza; +import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager; import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest; import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession; @@ -81,7 +82,7 @@ public class IBBTransferNegotiator extends StreamNegotiator { return negotiateIncomingStream(streamInitiation); } - public PacketFilter getInitiationPacketFilter(String from, String streamID) { + public StanzaFilter getInitiationPacketFilter(String from, String streamID) { /* * this method is always called prior to #negotiateIncomingStream() so * the In-Band Bytestream initiation listener must ignore the next @@ -111,27 +112,19 @@ public class IBBTransferNegotiator extends StreamNegotiator { * This PacketFilter accepts an incoming In-Band Bytestream open request * with a specified session ID. */ - private static class IBBOpenSidFilter extends PacketTypeFilter { + private static class IBBOpenSidFilter extends FlexibleStanzaTypeFilter { - private String sessionID; + private final String sessionID; public IBBOpenSidFilter(String sessionID) { - super(Open.class); - if (sessionID == null) { - throw new IllegalArgumentException("StreamID cannot be null"); - } - this.sessionID = sessionID; + this.sessionID = Objects.requireNonNull(sessionID, "sessionID must not be null"); } - 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; + @Override + protected boolean acceptSpecific(Open bytestream) { + // packet must by of type SET and contains the given session ID + return this.sessionID.equals(bytestream.getSessionID()) + && IQ.Type.set.equals(bytestream.getType()); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java index efaa9b6e8..0cc7aa400 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java @@ -27,9 +27,9 @@ 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.FlexibleStanzaTypeFilter; import org.jivesoftware.smack.filter.FromMatchesFilter; -import org.jivesoftware.smack.filter.PacketFilter; -import org.jivesoftware.smack.filter.PacketTypeFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.util.Objects; @@ -85,7 +85,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator { } @Override - public PacketFilter getInitiationPacketFilter(final String from, String streamID) { + public StanzaFilter getInitiationPacketFilter(final String 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 @@ -126,27 +126,20 @@ 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 static class BytestreamSIDFilter extends FlexibleStanzaTypeFilter { 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; + protected boolean acceptSpecific(Bytestream bytestream) { + // packet must by of type SET and contains the given session ID + return this.sessionID.equals(bytestream.getSessionID()) + && IQ.Type.set.equals(bytestream.getType()); } - } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java index 66df77f02..0fff1304c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java @@ -23,7 +23,7 @@ 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.filter.StanzaFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smackx.si.packet.StreamInitiation; @@ -94,7 +94,7 @@ public abstract class StreamNegotiator { * @return The PacketFilter that will return the packet relatable to the stream * initiation. */ - public abstract PacketFilter getInitiationPacketFilter(String from, String streamID); + public abstract StanzaFilter getInitiationPacketFilter(String from, String streamID); abstract InputStream negotiateIncomingStream(Stanza streamInitiation) throws XMPPErrorException, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/packet/Forwarded.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/packet/Forwarded.java index 5117b95fa..47ef8a713 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/packet/Forwarded.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/packet/Forwarded.java @@ -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 XEP-0297: Stanza Forwarding */ -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"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java index 69febd966..0a2b3a237 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java @@ -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 { +public class ForwardedProvider extends ExtensionElementProvider { private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName()); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java index b067f4dc2..392046b8b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java @@ -28,7 +28,7 @@ import org.jivesoftware.smack.PacketListener; 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; @@ -92,7 +92,7 @@ import org.jivesoftware.smackx.iqlast.packet.LastActivity; public class LastActivityManager extends Manager { private static final Map instances = new WeakHashMap(); // 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; @@ -149,7 +149,7 @@ public class LastActivityManager extends Manager { break; } } - }, PacketTypeFilter.PRESENCE); + }, StanzaTypeFilter.PRESENCE); connection.addPacketSendingListener(new PacketListener() { @Override @@ -159,7 +159,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, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/packet/Registration.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/packet/Registration.java index fe78b61b8..7267db2b9 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/packet/Registration.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/packet/Registration.java @@ -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"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java index 2df60a139..9bdf5f7b6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java @@ -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 { throws XmlPullParserException, IOException, SmackException { String instruction = null; Map fields = new HashMap(); - List packetExtensions = new LinkedList(); + List packetExtensions = new LinkedList(); outerloop: while (true) { int eventType = parser.next(); @@ -62,7 +62,7 @@ public class RegistrationProvider extends IQProvider { } // Otherwise, it must be a packet extension. else { - PacketParserUtils.addPacketExtension(packetExtensions, parser); + PacketParserUtils.addExtensionElement(packetExtensions, parser); } } else if (eventType == XmlPullParser.END_TAG) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationStreamFeatureProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationStreamFeatureProvider.java index a1e54be3d..c4b19f8e3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationStreamFeatureProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationStreamFeatureProvider.java @@ -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 { +public class RegistrationStreamFeatureProvider extends ExtensionElementProvider { @Override public Registration.Feature parse(XmlPullParser parser, int initialDepth) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java index 362e2704d..2adf0d419 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java @@ -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. */ diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/provider/JivePropertiesExtensionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/provider/JivePropertiesExtensionProvider.java index 986c41994..ffc83653e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/provider/JivePropertiesExtensionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/provider/JivePropertiesExtensionProvider.java @@ -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 { +public class JivePropertiesExtensionProvider extends ExtensionElementProvider { private static final Logger LOGGER = Logger.getLogger(JivePropertiesExtensionProvider.class.getName()); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index 6679f3587..7f79ec6d0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -47,9 +47,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; @@ -108,12 +108,12 @@ 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; @@ -291,19 +291,19 @@ public class MultiUserChat { joinPresence.addExtension(mucInitialPresence); // Wait for a presence packet back from the server. - PacketFilter responseFilter = new AndFilter(FromMatchesFilter.createFull(room + "/" - + nickname), new PacketTypeFilter(Presence.class)); + StanzaFilter responseFilter = new AndFilter(FromMatchesFilter.createFull(room + "/" + + nickname), 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)); + StanzaTypeFilter.PRESENCE)); connection.addSyncPacketListener(subjectListener, new AndFilter(fromRoomFilter, MessageWithSubjectFilter.INSTANCE)); - connection.addSyncPacketListener(declinesListener, new AndFilter(new PacketExtensionFilter(MUCUser.ELEMENT, + connection.addSyncPacketListener(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; @@ -855,10 +855,10 @@ public class MultiUserChat { joinPresence.setTo(room + "/" + nickname); // Wait for a presence packet back from the server. - PacketFilter responseFilter = + StanzaFilter responseFilter = new AndFilter( FromMatchesFilter.createFull(room + "/" + nickname), - 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 @@ -1707,7 +1707,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; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java index be0a414f5..ea46e4ce5 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java @@ -37,10 +37,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; @@ -100,7 +100,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 invitationsListeners = new CopyOnWriteArraySet(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java index b4ed52f32..59d0e7ba6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java @@ -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; @@ -39,12 +39,12 @@ import org.xmlpull.v1.XmlPullParserException; * con.sendPacket(message); * * - * To listen for group chat invitations, use a PacketExtensionFilter for the + * To listen for group chat invitations, use a StanzaExtensionFilter for the * x element name and jabber:x:conference namespace, as in the * following code example: * *
- * 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...
  * 
* @@ -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 { + public static class Provider extends ExtensionElementProvider { @Override public GroupChatInvitation parse(XmlPullParser parser, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCInitialPresence.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCInitialPresence.java index 9fecb4335..99ac34959 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCInitialPresence.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCInitialPresence.java @@ -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"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCUser.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCUser.java index 21bc82ef9..88cbd0ce0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCUser.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCUser.java @@ -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"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java index cfac31cc0..9b476b1ad 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java @@ -49,7 +49,7 @@ public class MUCOwnerProvider extends IQProvider { } // Otherwise, it must be a packet extension. else { - PacketParserUtils.addPacketExtension(mucOwner, parser); + PacketParserUtils.addExtensionElement(mucOwner, parser); } } else if (eventType == XmlPullParser.END_TAG) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCUserProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCUserProvider.java index ba670e6f2..6564254cf 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCUserProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCUserProvider.java @@ -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 { +public class MUCUserProvider extends ExtensionElementProvider { /** * Parses a MUCUser packet (extension sub-packet). diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java index 7cd01d42a..b5bbb22f6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java @@ -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 XEP-0172: User Nickname */ -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 { + public static class Provider extends ExtensionElementProvider { @Override public Nick parse(XmlPullParser parser, int initialDepth) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java index 8fdf948d0..f47817b08 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java @@ -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; @@ -146,7 +146,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); @@ -186,7 +186,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 messages = null; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageInfo.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageInfo.java index 8500b8ab4..d8e88af70 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageInfo.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageInfo.java @@ -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 { + public static class Provider extends ExtensionElementProvider { /** * Parses a OfflineMessageInfo packet (extension sub-packet). diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java index 3e476b047..eb2083737 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java @@ -23,8 +23,8 @@ import java.util.List; import org.jivesoftware.smack.PacketListener; 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; @@ -64,7 +64,7 @@ public class PEPManager { private XMPPConnection connection; - private PacketFilter packetFilter = new PacketExtensionFilter("event", "http://jabber.org/protocol/pubsub#event"); + private StanzaFilter packetFilter = new StanzaExtensionFilter("event", "http://jabber.org/protocol/pubsub#event"); private PacketListener packetListener; /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPEvent.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPEvent.java index c455e0416..f2b4575ef 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPEvent.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPEvent.java @@ -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.

@@ -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; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPItem.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPItem.java index 0156bd957..138c9412a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPItem.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPItem.java @@ -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.

@@ -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(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java index e19f0b773..8786bb26f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java @@ -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 { +public class PEPProvider extends ExtensionElementProvider { - private static final Map> nodeParsers = new HashMap>(); + private static final Map> nodeParsers = new HashMap>(); - 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 { * @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 { // 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); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java index 3b539d918..391523e1a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java @@ -35,8 +35,8 @@ 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 INSTANCES = new WeakHashMap(); @@ -128,7 +128,7 @@ public class PrivacyListManager extends Manager { 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() { @@ -150,7 +150,7 @@ public class PrivacyListManager extends Manager { 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() { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetActiveListFilter.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetActiveListFilter.java index 2499cc88c..9699ce3cb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetActiveListFilter.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetActiveListFilter.java @@ -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 { +public class SetActiveListFilter extends FlexibleStanzaTypeFilter { public static final SetActiveListFilter INSTANCE = new SetActiveListFilter(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetDefaultListFilter.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetDefaultListFilter.java index cac736902..5988d1427 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetDefaultListFilter.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetDefaultListFilter.java @@ -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 { +public class SetDefaultListFilter extends FlexibleStanzaTypeFilter { public static final SetDefaultListFilter INSTANCE = new SetDefaultListFilter(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java index ce4159b7c..8686dab6d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java @@ -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; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigurationEvent.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigurationEvent.java index 0b26decd8..8e0b5444a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigurationEvent.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigurationEvent.java @@ -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 configuration element of a pubsub message event which @@ -49,11 +49,11 @@ public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketE return form; } - public List getExtensions() + public List getExtensions() { if (getConfiguration() == null) return Collections.emptyList(); else - return Arrays.asList(((PacketExtension)getConfiguration().getDataFormToSend())); + return Arrays.asList(((ExtensionElement)getConfiguration().getDataFormToSend())); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EmbeddedPacketExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EmbeddedPacketExtension.java index 546536c6e..969441137 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EmbeddedPacketExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EmbeddedPacketExtension.java @@ -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 getExtensions(); + List getExtensions(); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElement.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElement.java index b3e0b136b..8684085ae 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElement.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElement.java @@ -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 getExtensions() + public List getExtensions() { - return Arrays.asList(new PacketExtension[]{getEvent()}); + return Arrays.asList(new ExtensionElement[]{getEvent()}); } public NodeExtension getEvent() diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemsExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemsExtension.java index 64dca28dd..2f273e77f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemsExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemsExtension.java @@ -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 items; + protected List 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 items) + public ItemsExtension(ItemsElementType itemsType, String nodeId, List 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 items, boolean notify) + public ItemsExtension(String nodeId, List 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 getExtensions() + public List getExtensions() { - return (List)getItems(); + return (List)getItems(); } /** @@ -135,7 +135,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten * * return List of {@link Item}, {@link RetractItem}, or null */ - public List getItems() + public List 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()); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java index ee9aa2777..cf3b98ff5 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java @@ -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; @@ -71,7 +71,7 @@ public class LeafNode extends Node */ public List getItems() throws NoResponseException, XMPPErrorException, NotConnectedException { - return getItems((List) null, (List) null); + return getItems((List) null, (List) null); } /** @@ -169,8 +169,8 @@ public class LeafNode extends Node * @throws XMPPErrorException * @throws NotConnectedException */ - public List getItems(List additionalExtensions, - List returnedExtensions) throws NoResponseException, + public List getItems(List additionalExtensions, + List returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId())); request.addExtensions(additionalExtensions); @@ -184,7 +184,7 @@ public class LeafNode extends Node @SuppressWarnings("unchecked") private List getItems(PubSub request, - List returnedExtensions) throws NoResponseException, + List returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub result = con.createPacketCollectorAndSend(request).nextResultOrThrow(); ItemsExtension itemsElem = result.getExtension(PubSubElementType.ITEMS); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java index 8c4a57900..088f11c65 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java @@ -27,10 +27,10 @@ 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; @@ -164,7 +164,7 @@ abstract public class Node * @throws XMPPErrorException * @throws NotConnectedException */ - public List getSubscriptions(List additionalExtensions, Collection returnedExtensions) + public List getSubscriptions(List additionalExtensions, Collection returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException { return getSubscriptions(additionalExtensions, returnedExtensions, null); } @@ -206,18 +206,18 @@ abstract public class Node * Retrieve Subscriptions List * @since 4.1 */ - public List getSubscriptionsAsOwner(List additionalExtensions, - Collection returnedExtensions) throws NoResponseException, XMPPErrorException, + public List getSubscriptionsAsOwner(List additionalExtensions, + Collection returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException { return getSubscriptions(additionalExtensions, returnedExtensions, PubSubNamespace.OWNER); } - private List getSubscriptions(List additionalExtensions, - Collection returnedExtensions, PubSubNamespace pubSubNamespace) + private List getSubscriptions(List additionalExtensions, + Collection returnedExtensions, PubSubNamespace pubSubNamespace) throws NoResponseException, XMPPErrorException, NotConnectedException { 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); } } @@ -257,11 +257,11 @@ abstract public class Node * @throws XMPPErrorException * @throws NotConnectedException */ - public List getAffiliations(List additionalExtensions, Collection returnedExtensions) + public List getAffiliations(List additionalExtensions, Collection returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS, getId())); if (additionalExtensions != null) { - for (PacketExtension pe : additionalExtensions) { + for (ExtensionElement pe : additionalExtensions) { pubSub.addExtension(pe); } } @@ -476,12 +476,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); } @@ -554,7 +554,7 @@ abstract public class Node { EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); - List extList = event.getExtensions(); + List extList = event.getExtensions(); if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName())) { @@ -608,7 +608,7 @@ abstract public class Node * * @author Robin Collier */ - class EventContentFilter implements PacketFilter + class EventContentFilter implements StanzaFilter { private String firstElement; private String secondElement; @@ -649,7 +649,7 @@ abstract public class Node if (embedEvent instanceof EmbeddedPacketExtension) { - List secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions(); + List secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions(); if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement)) return true; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeExtension.java index a707f642a..a115eaa35 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeExtension.java @@ -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; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java index e8b7eebd1..e0f5865f1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java @@ -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 extends Item +public class PayloadItem extends Item { private E payload; /** * Create an Item 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 extends Item * Create an Item 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 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 extends Item * Get the payload associated with this Item. 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() { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java index 5c12865bf..fa509dc69 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java @@ -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; @@ -299,15 +299,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 { return sendPubsubPacket(con, to, type, Collections.singletonList(ext), ns); } - static PubSub sendPubsubPacket(XMPPConnection con, String to, Type type, List extList, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException + static PubSub sendPubsubPacket(XMPPConnection con, String to, Type type, List extList, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub pubSub = new PubSub(to, type, ns); - for (PacketExtension pe : extList) { + for (ExtensionElement pe : extList) { pubSub.addExtension(pe); } return sendPubsubPacket(con ,pubSub); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/RetractItem.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/RetractItem.java index 7f32965ff..4f20a5597 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/RetractItem.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/RetractItem.java @@ -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; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java index 689b5e9cb..40296b918 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java @@ -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; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java index ed979cc82..1684f188b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java @@ -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; /** @@ -56,7 +56,7 @@ public class PubSub extends IQ } @SuppressWarnings("unchecked") - public PE getExtension(PubSubElementType elem) + public PE getExtension(PubSubElementType elem) { return (PE) getExtension(elem.getElementName(), elem.getNamespace().getXmlns()); } @@ -86,7 +86,7 @@ public class PubSub extends IQ return xml; } - public static PubSub createPubsubPacket(String to, Type type, PacketExtension extension, PubSubNamespace ns) { + public static PubSub createPubsubPacket(String to, Type type, ExtensionElement extension, PubSubNamespace ns) { PubSub pubSub = new PubSub(to, type, ns); pubSub.addExtension(extension); return pubSub; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationProvider.java index df4659c75..03dfcfa1d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationProvider.java @@ -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 { @Override - protected Affiliation createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected Affiliation createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new Affiliation(attributeMap.get("node"), Affiliation.Type.valueOf(attributeMap.get("affiliation"))); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java index 35b4bde5c..195cbc8a7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java @@ -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 attributeMap, List content) + protected AffiliationsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new AffiliationsExtension((List)content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java index 8b2044732..e6cb6f7ca 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java @@ -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 { @Override - protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) + protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) { if (content.size() == 0) return new ConfigurationEvent(attMap.get("node")); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java index 621bab98a..2fbcb9373 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java @@ -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 { @Override - protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) + protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) { return new EventElement(EventElementType.valueOf(content.get(0).getElementName()), (NodeExtension)content.get(0)); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java index 8bb2d0613..86f16bd6e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java @@ -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 { @Override - protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), new Form((DataForm)content.iterator().next())); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java index 17a170cb1..490d104b2 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java @@ -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 item 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 smack.providers for its element name and namespace. If no + * {@link ExtensionElementProvider} is registered in smack.providers 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 +public class ItemProvider extends ExtensionElementProvider { @Override public Item parse(XmlPullParser parser, int initialDepth) @@ -57,7 +57,7 @@ public class ItemProvider extends PacketExtensionProvider String payloadElemName = parser.getName(); String payloadNS = parser.getNamespace(); - final PacketExtensionProvider extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS); + final ExtensionElementProvider extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS); if (extensionProvider == null) { CharSequence payloadText = PacketParserUtils.parseElement(parser, true); @@ -65,7 +65,7 @@ public class ItemProvider extends PacketExtensionProvider } else { - return new PayloadItem(id, node, extensionProvider.parse(parser)); + return new PayloadItem(id, node, extensionProvider.parse(parser)); } } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java index 4a13d86c3..6c52862d3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java @@ -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 { @Override - protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new ItemsExtension(ItemsExtension.ItemsElementType.items, attributeMap.get("node"), content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java index 43a357ddc..48730b8be 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java @@ -47,7 +47,7 @@ public class PubSubProvider extends IQProvider 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) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java index 583422c72..f329caf0d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java @@ -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 { @Override - protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new RetractItem(attributeMap.get("id")); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java index 0e586574c..31782fa11 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java @@ -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 { @Override - protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new NodeExtension(PubSubElementType.valueOfFromElemName(currentElement, currentNamespace), attributeMap.get("node")); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java index 8ae2d6981..b5c87ea4f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java @@ -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 +public class SubscriptionProvider extends ExtensionElementProvider { @Override public Subscription parse(XmlPullParser parser, int initialDepth) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java index e65878b0f..69e4fb183 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java @@ -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 attributeMap, List content) + protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new SubscriptionsExtension(attributeMap.get("node"), (List)content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java index 43de59616..6b239da84 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java @@ -20,7 +20,7 @@ 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.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"; @@ -101,7 +101,7 @@ public class DeliveryReceipt implements PacketExtension @Override protected DeliveryReceipt createReturnExtension(String currentElement, String currentNamespace, - Map attributeMap, List content) + Map attributeMap, List content) { return new DeliveryReceipt(attributeMap.get("id")); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java index 7393c4bd5..2e6e5cfa0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java @@ -31,9 +31,9 @@ import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPException; 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.PacketTypeFilter; +import org.jivesoftware.smack.filter.StanzaFilter; +import org.jivesoftware.smack.filter.StanzaExtensionFilter; +import org.jivesoftware.smack.filter.StanzaTypeFilter; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.roster.Roster; @@ -67,10 +67,10 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; */ public class DeliveryReceiptManager extends Manager { - private static final PacketFilter MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST = new AndFilter(PacketTypeFilter.MESSAGE, - new PacketExtensionFilter(new DeliveryReceiptRequest())); - private static final PacketFilter MESSAGES_WITH_DELIVERY_RECEIPT = new AndFilter(PacketTypeFilter.MESSAGE, - new PacketExtensionFilter(DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE)); + private static final StanzaFilter MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST = new AndFilter(StanzaTypeFilter.MESSAGE, + new StanzaExtensionFilter(new DeliveryReceiptRequest())); + private static final StanzaFilter MESSAGES_WITH_DELIVERY_RECEIPT = new AndFilter(StanzaTypeFilter.MESSAGE, + new StanzaExtensionFilter(DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE)); private static Map instances = new WeakHashMap(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java index 6c467f043..622f003fb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java @@ -20,9 +20,9 @@ import java.io.IOException; 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.id.StanzaIdUtil; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +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 Georg Lukas */ -public class DeliveryReceiptRequest implements PacketExtension +public class DeliveryReceiptRequest implements ExtensionElement { public static final String ELEMENT = "request"; @@ -93,7 +93,7 @@ public class DeliveryReceiptRequest implements PacketExtension /** * This Provider parses and returns DeliveryReceiptRequest packets. */ - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { @Override public DeliveryReceiptRequest parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/RSMManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/RSMManager.java index 8cb49adf1..dba8e662e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/RSMManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/RSMManager.java @@ -20,31 +20,31 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.PacketUtil; import org.jivesoftware.smackx.rsm.packet.RSMSet; import org.jivesoftware.smackx.rsm.packet.RSMSet.PageDirection; public class RSMManager { - Collection page(int max) { - List packetExtensions = new LinkedList(); + Collection page(int max) { + List packetExtensions = new LinkedList(); packetExtensions.add(new RSMSet(max)); return packetExtensions; } - Collection continuePage(int max, Collection returnedExtensions) { + Collection continuePage(int max, Collection returnedExtensions) { return continuePage(max, returnedExtensions, null); } - Collection continuePage(int max, - Collection returnedExtensions, - Collection additionalExtensions) { + Collection continuePage(int max, + Collection returnedExtensions, + Collection additionalExtensions) { if (returnedExtensions == null) { throw new IllegalArgumentException("returnedExtensions must no be null"); } if (additionalExtensions == null) { - additionalExtensions = new LinkedList(); + additionalExtensions = new LinkedList(); } RSMSet resultRsmSet = PacketUtil.extensionElementFrom(returnedExtensions, RSMSet.ELEMENT, RSMSet.NAMESPACE); if (resultRsmSet == null) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/packet/RSMSet.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/packet/RSMSet.java index dfb76f113..5f65b9b90 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/packet/RSMSet.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/packet/RSMSet.java @@ -17,10 +17,10 @@ package org.jivesoftware.smackx.rsm.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; -public class RSMSet implements PacketExtension { +public class RSMSet implements ExtensionElement { public static final String ELEMENT = "set"; public static final String NAMESPACE = "http://jabber.org/protocol/rsm"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/provider/RSMSetProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/provider/RSMSetProvider.java index c9668cf43..8cc90bb24 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/provider/RSMSetProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/provider/RSMSetProvider.java @@ -18,13 +18,13 @@ package org.jivesoftware.smackx.rsm.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.rsm.packet.RSMSet; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -public class RSMSetProvider extends PacketExtensionProvider { +public class RSMSetProvider extends ExtensionElementProvider { @Override public RSMSet parse(XmlPullParser parser, int initialDepth) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java index 5c58aa6dd..2df760b8e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java @@ -141,7 +141,7 @@ public class UserSearch extends SimpleIQ { else if (eventType == XmlPullParser.START_TAG && parser.getNamespace().equals("jabber:x:data")) { // Otherwise, it must be a packet extension. search = new UserSearch(); - PacketParserUtils.addPacketExtension(search, parser); + PacketParserUtils.addExtensionElement(search, parser); } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals("query")) { @@ -194,7 +194,7 @@ public class UserSearch extends SimpleIQ { } } else if (eventType == XmlPullParser.START_TAG && parser.getNamespace().equals("jabber:x:data")) { - PacketParserUtils.addPacketExtension(search, parser); + PacketParserUtils.addExtensionElement(search, parser); done = true; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/packet/Header.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/packet/Header.java index 41840ef26..3b7613713 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/packet/Header.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/packet/Header.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.shim.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; /** @@ -25,7 +25,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * @author Robin Collier */ -public class Header implements PacketExtension { +public class Header implements ExtensionElement { public static final String ELEMENT = "header"; private final String name; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/packet/HeadersExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/packet/HeadersExtension.java index ebaf1fa1a..14ae89c17 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/packet/HeadersExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/packet/HeadersExtension.java @@ -20,7 +20,7 @@ import java.util.Collections; 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.XmlStringBuilder; /** @@ -30,7 +30,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Robin Collier */ -public class HeadersExtension implements PacketExtension { +public class HeadersExtension implements ExtensionElement { public static final String ELEMENT = "headers"; public static final String NAMESPACE = "http://jabber.org/protocol/shim"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeaderProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeaderProvider.java index f43b8f846..800af7653 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeaderProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeaderProvider.java @@ -18,7 +18,7 @@ package org.jivesoftware.smackx.shim.provider; import java.io.IOException; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.shim.packet.Header; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -28,7 +28,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Robin Collier */ -public class HeaderProvider extends PacketExtensionProvider

{ +public class HeaderProvider extends ExtensionElementProvider
{ @Override public Header parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { String name = parser.getAttributeValue(null, "name"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeadersProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeadersProvider.java index a1ca25a78..ca47147eb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeadersProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeadersProvider.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.shim.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.shim.packet.Header; import org.jivesoftware.smackx.shim.packet.HeadersExtension; @@ -35,7 +35,7 @@ public class HeadersProvider extends EmbeddedExtensionProvider @SuppressWarnings("unchecked") @Override protected HeadersExtension createReturnExtension(String currentElement, String currentNamespace, - Map attributeMap, List content) { + Map attributeMap, List content) { return new HeadersExtension((List
) content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/si/packet/StreamInitiation.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/si/packet/StreamInitiation.java index bb405ee7b..b96368410 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/si/packet/StreamInitiation.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/si/packet/StreamInitiation.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.si.packet; import java.util.Date; import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.StringUtils; import org.jxmpp.util.XmppDateTime; import org.jivesoftware.smackx.xdata.packet.DataForm; @@ -195,7 +195,7 @@ public class StreamInitiation extends IQ { * * @author Alexander Wenckus */ - public static class File implements PacketExtension { + public static class File implements ExtensionElement { private final String name; @@ -370,7 +370,7 @@ public class StreamInitiation extends IQ { * @author Alexander Wenckus * */ - public class Feature implements PacketExtension { + public class Feature implements ExtensionElement { private final DataForm data; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/packet/DataForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/packet/DataForm.java index 3323fedda..c439cb759 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/packet/DataForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/packet/DataForm.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.xdata.packet; import org.jivesoftware.smack.packet.Element; 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.xdata.FormField; @@ -34,7 +34,7 @@ import java.util.Locale; * * @author Gaston Dombiak */ -public class DataForm implements PacketExtension { +public class DataForm implements ExtensionElement { public static final String NAMESPACE = "jabber:x:data"; public static final String ELEMENT = "x"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java index e94775d00..3c44e3b8e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java @@ -18,7 +18,7 @@ package org.jivesoftware.smackx.xdata.provider; import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.roster.packet.RosterPacket; import org.jivesoftware.smack.roster.provider.RosterPacketProvider; import org.jivesoftware.smackx.xdata.FormField; @@ -39,7 +39,7 @@ import java.util.List; * * @author Gaston Dombiak */ -public class DataFormProvider extends PacketExtensionProvider { +public class DataFormProvider extends ExtensionElementProvider { @Override public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatalayout/packet/DataLayout.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatalayout/packet/DataLayout.java index bf42b39c1..d26732bc4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatalayout/packet/DataLayout.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatalayout/packet/DataLayout.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; import org.jivesoftware.smack.packet.NamedElement; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.XmlStringBuilder; /** @@ -31,7 +31,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Anno van Vliet */ -public class DataLayout implements PacketExtension { +public class DataLayout implements ExtensionElement { public static final String ELEMENT = "page"; public static final String NAMESPACE = "http://jabber.org/protocol/xdata-layout"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.java index abe765ebb..2d0899e10 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.xdatavalidation.packet; import org.jivesoftware.smack.packet.NamedElement; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.NumberUtil; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.XmlStringBuilder; @@ -33,7 +33,7 @@ import org.jivesoftware.smackx.xdatavalidation.ValidationConsistencyException; * * @author Anno van Vliet */ -public abstract class ValidateElement implements PacketExtension { +public abstract class ValidateElement implements ExtensionElement { public static final String DATATYPE_XS_STRING = "xs:string"; public static final String ELEMENT = "validate"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/packet/XHTMLExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/packet/XHTMLExtension.java index 41158f82d..3132e5d28 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/packet/XHTMLExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/packet/XHTMLExtension.java @@ -18,7 +18,7 @@ package org.jivesoftware.smackx.xhtmlim.packet; import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.XmlStringBuilder; import java.util.ArrayList; @@ -35,7 +35,7 @@ import java.util.List; * * @author Gaston Dombiak */ -public class XHTMLExtension implements PacketExtension { +public class XHTMLExtension implements ExtensionElement { public static final String ELEMENT = "html"; public static final String NAMESPACE = "http://jabber.org/protocol/xhtml-im"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProvider.java index 105a1f5b3..50634b0e4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProvider.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.xhtmlim.provider; import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.xhtmlim.packet.XHTMLExtension; import org.xmlpull.v1.XmlPullParser; @@ -30,7 +30,7 @@ import java.io.IOException; * * @author Florian Schmaus */ -public class XHTMLExtensionProvider extends PacketExtensionProvider { +public class XHTMLExtensionProvider extends ExtensionElementProvider { @Override public XHTMLExtension parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException { diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java index f7b8ef454..9b343c5a4 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.amp; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smackx.amp.packet.AMPExtension; import org.jivesoftware.smackx.amp.provider.AMPExtensionProvider; import org.junit.Before; @@ -70,7 +70,7 @@ public class AMPExtensionTest { assertEquals(XmlPullParser.START_TAG, parser.next()); assertEquals(AMPExtension.ELEMENT, parser.getName()); - PacketExtension extension = ampProvider.parse(parser); + ExtensionElement extension = ampProvider.parse(parser); assertTrue(extension instanceof AMPExtension); AMPExtension amp = (AMPExtension) extension; @@ -89,7 +89,7 @@ public class AMPExtensionTest { assertEquals(XmlPullParser.START_TAG, parser.next()); assertEquals(AMPExtension.ELEMENT, parser.getName()); - PacketExtension extension = ampProvider.parse(parser); + ExtensionElement extension = ampProvider.parse(parser); assertTrue(extension instanceof AMPExtension); AMPExtension amp = (AMPExtension) extension; diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java index a12645a38..0c6ffc108 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue; import org.jivesoftware.smack.ThreadedDummyConnection; import org.jivesoftware.smack.packet.Stanza; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.InitExtensions; import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; @@ -104,7 +104,7 @@ public class ItemValidationTest extends InitExtensions { ""); Stanza message = PacketParserUtils.parseMessage(parser); - PacketExtension eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns()); + ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns()); assertTrue(eventExt instanceof EventElement); EventElement event = (EventElement) eventExt; @@ -113,7 +113,7 @@ public class ItemValidationTest extends InitExtensions { assertTrue(event.getExtensions().get(0) instanceof ItemsExtension); assertEquals(1, ((ItemsExtension)event.getExtensions().get(0)).items.size()); - PacketExtension itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0); + ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0); assertTrue(itemExt instanceof Item); assertEquals("testid1", ((Item)itemExt).getId()); } @@ -135,9 +135,9 @@ public class ItemValidationTest extends InitExtensions { ""); Stanza message = PacketParserUtils.parseMessage(parser); - PacketExtension eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns()); + ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns()); EventElement event = (EventElement) eventExt; - PacketExtension itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0); + ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0); assertTrue(itemExt instanceof PayloadItem); PayloadItem item = (PayloadItem)itemExt; @@ -182,9 +182,9 @@ public class ItemValidationTest extends InitExtensions { ""); Stanza message = PacketParserUtils.parseMessage(parser); - PacketExtension eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns()); + ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns()); EventElement event = (EventElement) eventExt; - PacketExtension itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0); + ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0); assertTrue(itemExt instanceof PayloadItem); PayloadItem item = (PayloadItem)itemExt; @@ -215,7 +215,7 @@ public class ItemValidationTest extends InitExtensions { ""); Stanza message = PacketParserUtils.parseMessage(parser); - PacketExtension eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns()); + ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns()); assertTrue(eventExt instanceof EventElement); EventElement event = (EventElement) eventExt; @@ -224,7 +224,7 @@ public class ItemValidationTest extends InitExtensions { assertTrue(event.getExtensions().get(0) instanceof ItemsExtension); assertEquals(1, ((ItemsExtension)event.getExtensions().get(0)).items.size()); - PacketExtension itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0); + ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0); assertTrue(itemExt instanceof PayloadItem); PayloadItem item = (PayloadItem)itemExt; diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProviderTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProviderTest.java index c81dc4ad7..3fd25cd36 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProviderTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProviderTest.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.xhtmlim.provider; import static org.jivesoftware.smack.test.util.CharsequenceEquals.equalsCharSequence; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.xhtmlim.packet.XHTMLExtension; import org.junit.Test; @@ -40,7 +40,7 @@ public class XHTMLExtensionProviderTest { parser.next(); XHTMLExtensionProvider provider = new XHTMLExtensionProvider(); - PacketExtension extension = provider.parse(parser, parser.getDepth()); + ExtensionElement extension = provider.parse(parser, parser.getDepth()); assertThat(extension, instanceOf(XHTMLExtension.class)); XHTMLExtension attachmentsInfo = (XHTMLExtension) extension; diff --git a/smack-extensions/src/test/java/org/jivesoftware/util/ConnectionUtils.java b/smack-extensions/src/test/java/org/jivesoftware/util/ConnectionUtils.java index bba1cfed2..edd85e959 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/util/ConnectionUtils.java +++ b/smack-extensions/src/test/java/org/jivesoftware/util/ConnectionUtils.java @@ -27,7 +27,7 @@ import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException.XMPPErrorException; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.XMPPError; @@ -75,7 +75,7 @@ public class ConnectionUtils { // mock packet collector final PacketCollector collector = mock(PacketCollector.class); - when(connection.createPacketCollector(isA(PacketFilter.class))).thenReturn( + when(connection.createPacketCollector(isA(StanzaFilter.class))).thenReturn( collector); Answer collectorAndSend = new Answer() { @Override diff --git a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java index 778ca8598..72e826587 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java @@ -32,11 +32,11 @@ import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.filter.AndFilter; -import org.jivesoftware.smack.filter.FlexiblePacketTypeFilter; +import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter; import org.jivesoftware.smack.filter.FromMatchesFilter; import org.jivesoftware.smack.filter.MessageTypeFilter; import org.jivesoftware.smack.filter.OrFilter; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.ThreadFilter; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message.Type; @@ -97,7 +97,7 @@ public class ChatManager extends Manager{ BARE_JID; } - private final PacketFilter packetFilter = new OrFilter(MessageTypeFilter.CHAT, new FlexiblePacketTypeFilter() { + private final StanzaFilter packetFilter = new OrFilter(MessageTypeFilter.CHAT, new FlexibleStanzaTypeFilter() { @Override protected boolean acceptSpecific(Message message) { @@ -134,8 +134,8 @@ public class ChatManager extends Manager{ private Set chatManagerListeners = new CopyOnWriteArraySet(); - private Map interceptors - = new WeakHashMap(); + private Map interceptors + = new WeakHashMap(); private ChatManager(XMPPConnection connection) { super(connection); @@ -352,8 +352,8 @@ public class ChatManager extends Manager{ } void sendMessage(Chat chat, Message message) throws NotConnectedException { - for(Map.Entry interceptor : interceptors.entrySet()) { - PacketFilter filter = interceptor.getValue(); + for(Map.Entry interceptor : interceptors.entrySet()) { + StanzaFilter filter = interceptor.getValue(); if(filter != null && filter.accept(message)) { interceptor.getKey().processMessage(message); } @@ -379,7 +379,7 @@ public class ChatManager extends Manager{ addOutgoingMessageInterceptor(messageInterceptor, null); } - public void addOutgoingMessageInterceptor(MessageListener messageInterceptor, PacketFilter filter) { + public void addOutgoingMessageInterceptor(MessageListener messageInterceptor, StanzaFilter filter) { if (messageInterceptor == null) { return; } diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java index 06a63392f..afbf43250 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java @@ -46,8 +46,8 @@ import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotLoggedInException; import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPException.XMPPErrorException; -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.packet.IQ; import org.jivesoftware.smack.packet.IQ.Type; @@ -112,7 +112,7 @@ public class Roster extends Manager { return roster; } - private static final PacketFilter PRESENCE_PACKET_FILTER = new PacketTypeFilter(Presence.class); + private static final StanzaFilter PRESENCE_PACKET_FILTER = StanzaTypeFilter.PRESENCE; private static boolean rosterLoadedAtLoginDefault = true; diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/packet/RosterVer.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/packet/RosterVer.java index 91a1cb7fd..7a0c55cb5 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/packet/RosterVer.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/packet/RosterVer.java @@ -16,10 +16,10 @@ */ package org.jivesoftware.smack.roster.packet; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.XmlStringBuilder; -public class RosterVer implements PacketExtension { +public class RosterVer implements ExtensionElement { public static final String ELEMENT = "ver"; public static final String NAMESPACE = "urn:xmpp:features:rosterver"; diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/provider/RosterVerStreamFeatureProvider.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/provider/RosterVerStreamFeatureProvider.java index f59a61706..fe741277f 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/provider/RosterVerStreamFeatureProvider.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/provider/RosterVerStreamFeatureProvider.java @@ -19,12 +19,12 @@ package org.jivesoftware.smack.roster.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.smack.roster.packet.RosterVer; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -public class RosterVerStreamFeatureProvider extends PacketExtensionProvider { +public class RosterVerStreamFeatureProvider extends ExtensionElementProvider { @Override public RosterVer parse(XmlPullParser parser, int initialDepth) diff --git a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/provider/JingleProviderTest.java b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/provider/JingleProviderTest.java index 6d86a640f..bfc187e18 100644 --- a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/provider/JingleProviderTest.java +++ b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/provider/JingleProviderTest.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.jingle.provider; import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.filter.PacketFilter; -import org.jivesoftware.smack.filter.PacketTypeFilter; +import org.jivesoftware.smack.filter.StanzaTypeFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.ProviderManager; @@ -69,7 +69,7 @@ public class JingleProviderTest extends SmackTestCase { iqSent.setType(IQ.Type.get); // Create a filter and a collector... - PacketFilter filter = new PacketTypeFilter(IQ.class); + PacketFilter filter = new StanzaTypeFilter(IQ.class); PacketCollector collector = getConnection(0).createPacketCollector(filter); System.out.println("Testing if a Jingle IQ can be sent and received..."); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java index fb9f12957..8242eac9f 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java @@ -27,7 +27,7 @@ import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Presence; @@ -441,7 +441,7 @@ public class JingleManager implements JingleSessionListener { * establish a new session. */ private void initJingleSessionRequestListeners() { - PacketFilter initRequestFilter = new PacketFilter() { + StanzaFilter initRequestFilter = new StanzaFilter() { // Return true if we accept this packet public boolean accept(Stanza pin) { if (pin instanceof IQ) { diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java index 99606c8b6..5dd80e2fa 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java @@ -30,7 +30,7 @@ import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.XMPPError; @@ -79,7 +79,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList PacketListener packetListener; - PacketFilter packetFilter; + StanzaFilter packetFilter; protected List jingleMediaManagers = null; @@ -676,7 +676,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList } }; - packetFilter = new PacketFilter() { + packetFilter = new StanzaFilter() { public boolean accept(Stanza packet) { if (packet instanceof IQ) { diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContent.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContent.java index e689a9d23..f57e75470 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContent.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContent.java @@ -21,14 +21,14 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; /** * Jingle content. * * @author Jeff Williams */ -public class JingleContent implements PacketExtension { +public class JingleContent implements ExtensionElement { public static final String NODENAME = "content"; public static final String CREATOR = "creator"; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContentDescription.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContentDescription.java index ccceef77e..1fca00466 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContentDescription.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContentDescription.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.jingleold.packet; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smackx.jingleold.media.PayloadType; import java.util.ArrayList; @@ -29,7 +29,7 @@ import java.util.List; * * @author Alvaro Saurin */ -public abstract class JingleContentDescription implements PacketExtension { +public abstract class JingleContentDescription implements ExtensionElement { // static diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContentInfo.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContentInfo.java index d38c9e3e4..3e32b794b 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContentInfo.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleContentInfo.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.jingleold.packet; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smackx.jingleold.media.ContentInfo; /** @@ -24,7 +24,7 @@ import org.jivesoftware.smackx.jingleold.media.ContentInfo; * * @author Alvaro Saurin */ -public class JingleContentInfo implements PacketExtension { +public class JingleContentInfo implements ExtensionElement { protected ContentInfo mediaInfoElement; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleDescription.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleDescription.java index b15004b3b..f8c106d98 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleDescription.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleDescription.java @@ -22,7 +22,7 @@ import java.util.Iterator; import java.util.List; import java.util.logging.Logger; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smackx.jingleold.media.PayloadType; /** @@ -30,7 +30,7 @@ import org.jivesoftware.smackx.jingleold.media.PayloadType; * * @author Alvaro Saurin */ -public abstract class JingleDescription implements PacketExtension { +public abstract class JingleDescription implements ExtensionElement { private static final Logger LOGGER = Logger.getLogger(JingleDescription.class.getName()); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java index 7562165fb..e868ebede 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java @@ -19,12 +19,12 @@ package org.jivesoftware.smackx.jingleold.packet; import java.util.Locale; -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.smackx.jingleold.media.ContentInfo; import org.xmlpull.v1.XmlPullParser; -public class JingleError implements PacketExtension { +public class JingleError implements ExtensionElement { public static String NAMESPACE = "urn:xmpp:tmp:jingle:errors"; @@ -122,9 +122,9 @@ public class JingleError implements PacketExtension { return NAMESPACE; } - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { - private PacketExtension audioInfo; + private ExtensionElement audioInfo; /** * Empty constructor. @@ -136,8 +136,8 @@ public class JingleError implements PacketExtension { * Parse a JingleDescription.Audio extension. */ @Override - public PacketExtension parse(XmlPullParser parser, int initialDepth) { - PacketExtension result = null; + public ExtensionElement parse(XmlPullParser parser, int initialDepth) { + ExtensionElement result = null; if (audioInfo != null) { result = audioInfo; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleTransport.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleTransport.java index a5303f24c..67d6e72a1 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleTransport.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleTransport.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.jingleold.packet; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smackx.jingleold.nat.ICECandidate; import org.jivesoftware.smackx.jingleold.nat.TransportCandidate; @@ -30,7 +30,7 @@ import java.util.List; * * @author Alvaro Saurin */ -public class JingleTransport implements PacketExtension { +public class JingleTransport implements ExtensionElement { // static diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentDescriptionProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentDescriptionProvider.java index 720c9e421..966c71dfd 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentDescriptionProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentDescriptionProvider.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jingleold.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.jingleold.media.PayloadType; import org.jivesoftware.smackx.jingleold.packet.JingleContentDescription; import org.jivesoftware.smackx.jingleold.packet.JingleContentDescription.JinglePayloadType; @@ -31,7 +31,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Alvaro Saurin */ -public abstract class JingleContentDescriptionProvider extends PacketExtensionProvider { +public abstract class JingleContentDescriptionProvider extends ExtensionElementProvider { /** * Parse a iq/jingle/description/payload-type element. diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentInfoProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentInfoProvider.java index 87f9555ca..5c492f442 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentInfoProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentInfoProvider.java @@ -16,8 +16,8 @@ */ package org.jivesoftware.smackx.jingleold.provider; -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.smackx.jingleold.media.ContentInfo; import org.jivesoftware.smackx.jingleold.packet.JingleContentInfo; import org.xmlpull.v1.XmlPullParser; @@ -32,9 +32,9 @@ public class JingleContentInfoProvider { /** * JingleDescription.Audio info provider */ - public static class Audio extends PacketExtensionProvider { + public static class Audio extends ExtensionElementProvider { - private final PacketExtension audioInfo; + private final ExtensionElement audioInfo; /** * Empty constructor. @@ -48,7 +48,7 @@ public class JingleContentInfoProvider { * * @param audioInfo the jmf info */ - public Audio(final PacketExtension audioInfo) { + public Audio(final ExtensionElement audioInfo) { super(); this.audioInfo = audioInfo; } @@ -57,8 +57,8 @@ public class JingleContentInfoProvider { * Parse a JingleDescription.Audio extension. */ @Override - public PacketExtension parse(XmlPullParser parser, int initialDepth) { - PacketExtension result = null; + public ExtensionElement parse(XmlPullParser parser, int initialDepth) { + ExtensionElement result = null; if (audioInfo != null) { result = audioInfo; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java index 1895512ae..382c743c6 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.jingleold.provider; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.jingleold.packet.JingleContent; import org.xmlpull.v1.XmlPullParser; @@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParser; * * @author Jeff Williams */ -public class JingleContentProvider extends PacketExtensionProvider { +public class JingleContentProvider extends ExtensionElementProvider { /** * Parse a JingleContent extension. diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleDescriptionProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleDescriptionProvider.java index a4b7644fa..c81b9339c 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleDescriptionProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleDescriptionProvider.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jingleold.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.jingleold.media.PayloadType; import org.jivesoftware.smackx.jingleold.packet.JingleDescription; import org.xmlpull.v1.XmlPullParser; @@ -30,7 +30,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Alvaro Saurin */ -public abstract class JingleDescriptionProvider extends PacketExtensionProvider { +public abstract class JingleDescriptionProvider extends ExtensionElementProvider { /** * Parse a iq/jingle/description/payload-type element. diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java index 1a9a41e19..41926e641 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java @@ -21,7 +21,7 @@ import java.io.IOException; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.jingleold.JingleActionEnum; import org.jivesoftware.smackx.jingleold.packet.Jingle; import org.jivesoftware.smackx.jingleold.packet.JingleContent; @@ -61,7 +61,7 @@ public class JingleProvider extends IQProvider { JingleDescriptionProvider jdpAudio = new JingleDescriptionProvider.Audio(); JingleTransportProvider jtpRawUdp = new JingleTransportProvider.RawUdp(); JingleTransportProvider jtpIce = new JingleTransportProvider.Ice(); - PacketExtensionProvider jmipAudio = new JingleContentInfoProvider.Audio(); + ExtensionElementProvider jmipAudio = new JingleContentInfoProvider.Audio(); int eventType; String elementName; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleTransportProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleTransportProvider.java index fa5aaa7b3..0c2fad5ac 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleTransportProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleTransportProvider.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jingleold.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.jingleold.nat.ICECandidate; import org.jivesoftware.smackx.jingleold.nat.TransportCandidate; import org.jivesoftware.smackx.jingleold.packet.JingleTransport; @@ -32,7 +32,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Alvaro Saurin */ -public abstract class JingleTransportProvider extends PacketExtensionProvider { +public abstract class JingleTransportProvider extends ExtensionElementProvider { /** * Obtain the corresponding TransportNegotiator instance. diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/MetaData.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/MetaData.java index 37d953220..528e16632 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/MetaData.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/MetaData.java @@ -22,12 +22,12 @@ import java.util.Map; import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; /** * MetaData packet extension. */ -public class MetaData implements PacketExtension { +public class MetaData implements ExtensionElement { /** * Element name of the packet extension. diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java index f5a475fca..8363717e2 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java @@ -22,8 +22,8 @@ import org.jivesoftware.smackx.workgroup.packet.AgentStatusRequest; import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; -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.Stanza; import org.jivesoftware.smack.packet.Presence; import org.jxmpp.util.XmppStringUtils; @@ -73,11 +73,11 @@ public class AgentRoster { listeners = new ArrayList(); presenceMap = new HashMap>(); // Listen for any roster packets. - PacketFilter rosterFilter = new PacketTypeFilter(AgentStatusRequest.class); + StanzaFilter rosterFilter = new StanzaTypeFilter(AgentStatusRequest.class); connection.addAsyncPacketListener(new AgentStatusListener(), rosterFilter); // Listen for any presence packets. connection.addAsyncPacketListener(new PresencePacketListener(), - new PacketTypeFilter(Presence.class)); + new StanzaTypeFilter(Presence.class)); // Send request for roster. AgentStatusRequest request = new AgentStatusRequest(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java index b23ccd277..96d04357d 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java @@ -40,8 +40,8 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.FromMatchesFilter; import org.jivesoftware.smack.filter.OrFilter; -import org.jivesoftware.smack.filter.PacketTypeFilter; -import org.jivesoftware.smack.packet.DefaultPacketExtension; +import org.jivesoftware.smack.filter.StanzaTypeFilter; +import org.jivesoftware.smack.packet.DefaultExtensionElement; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Stanza; @@ -142,10 +142,10 @@ public class AgentSession { // Create a filter to listen for packets we're interested in. OrFilter filter = new OrFilter( - new PacketTypeFilter(OfferRequestProvider.OfferRequestPacket.class), - new PacketTypeFilter(OfferRevokeProvider.OfferRevokePacket.class), - new PacketTypeFilter(Presence.class), - new PacketTypeFilter(Message.class)); + new StanzaTypeFilter(OfferRequestProvider.OfferRequestPacket.class), + new StanzaTypeFilter(OfferRevokeProvider.OfferRevokePacket.class), + new StanzaTypeFilter(Presence.class), + new StanzaTypeFilter(Message.class)); packetListener = new PacketListener() { public void processPacket(Stanza packet) { @@ -298,11 +298,11 @@ public class AgentSession { if (online) { presence = new Presence(Presence.Type.available); presence.setTo(workgroupJID); - presence.addExtension(new DefaultPacketExtension(AgentStatus.ELEMENT_NAME, + presence.addExtension(new DefaultExtensionElement(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE)); PacketCollector collector = this.connection.createPacketCollectorAndSend(new AndFilter( - new PacketTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)), presence); + new StanzaTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)), presence); presence = (Presence)collector.nextResultOrThrow(); @@ -316,7 +316,7 @@ public class AgentSession { presence = new Presence(Presence.Type.unavailable); presence.setTo(workgroupJID); - presence.addExtension(new DefaultPacketExtension(AgentStatus.ELEMENT_NAME, + presence.addExtension(new DefaultExtensionElement(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE)); connection.sendPacket(presence); } @@ -394,14 +394,14 @@ public class AgentSession { presence.setStatus(status); } // Send information about max chats and current chats as a packet extension. - DefaultPacketExtension agentStatus = new DefaultPacketExtension(AgentStatus.ELEMENT_NAME, + DefaultExtensionElement agentStatus = new DefaultExtensionElement(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE); agentStatus.setValue("max-chats", "" + maxChats); presence.addExtension(agentStatus); presence.addExtension(new MetaData(this.metaData)); PacketCollector collector = this.connection.createPacketCollectorAndSend(new AndFilter( - new PacketTypeFilter(Presence.class), + new StanzaTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)), presence); collector.nextResultOrThrow(); @@ -444,7 +444,7 @@ public class AgentSession { } presence.addExtension(new MetaData(this.metaData)); - PacketCollector collector = this.connection.createPacketCollectorAndSend(new AndFilter(new PacketTypeFilter(Presence.class), + PacketCollector collector = this.connection.createPacketCollectorAndSend(new AndFilter(new StanzaTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)), presence); collector.nextResultOrThrow(); @@ -741,7 +741,7 @@ public class AgentSession { } // Notify agent packets gives an overview of agent activity in a queue. - DefaultPacketExtension notifyAgents = (DefaultPacketExtension)presence.getExtension("notify-agents", "http://jabber.org/protocol/workgroup"); + DefaultExtensionElement notifyAgents = (DefaultExtensionElement)presence.getExtension("notify-agents", "http://jabber.org/protocol/workgroup"); if (notifyAgents != null) { int currentChats = Integer.parseInt(notifyAgents.getValue("current-chats")); int maxChats = Integer.parseInt(notifyAgents.getValue("max-chats")); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java index 31ca3dfc4..29c585151 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java @@ -60,7 +60,7 @@ public class WorkgroupForm extends SimpleIQ { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { // Parse the packet extension - PacketParserUtils.addPacketExtension(answer, parser); + PacketParserUtils.addExtensionElement(answer, parser); } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals(ELEMENT_NAME)) { diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java index 360e595d6..63cb33148 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java @@ -26,8 +26,8 @@ import java.util.Iterator; import java.util.List; import java.util.TimeZone; -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; @@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Matt Tucker */ -public class AgentStatus implements PacketExtension { +public class AgentStatus implements ExtensionElement { private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); @@ -223,7 +223,7 @@ public class AgentStatus implements PacketExtension { /** * Packet extension provider for AgentStatus packets. */ - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { @Override public AgentStatus parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java index 4a1ad2c65..c9b6f8fc2 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java @@ -23,7 +23,7 @@ import java.util.Map; import org.jivesoftware.smackx.workgroup.MetaData; import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +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 loki der quaeler */ -public class MetaDataProvider extends PacketExtensionProvider { +public class MetaDataProvider extends ExtensionElementProvider { /** * PacketExtensionProvider implementation diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java index eb6b9765e..e201daf83 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java @@ -19,8 +19,8 @@ package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smackx.workgroup.QueueUser; 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; @@ -37,7 +37,7 @@ import java.util.logging.Logger; * Queue details packet extension, which contains details about the users * currently in a queue. */ -public class QueueDetails implements PacketExtension { +public class QueueDetails implements ExtensionElement { private static final Logger LOGGER = Logger.getLogger(QueueDetails.class.getName()); /** @@ -143,7 +143,7 @@ public class QueueDetails implements PacketExtension { /** * Provider class for QueueDetails packet extensions. */ - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { @Override public QueueDetails parse(XmlPullParser parser, diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java index 8461c3303..2d9935a4a 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java @@ -19,8 +19,8 @@ package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smackx.workgroup.agent.WorkgroupQueue; 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; @@ -29,7 +29,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; -public class QueueOverview implements PacketExtension { +public class QueueOverview implements ExtensionElement { /** * Element name of the packet extension. @@ -117,7 +117,7 @@ public class QueueOverview implements PacketExtension { return buf.toString(); } - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { @Override public QueueOverview parse(XmlPullParser parser, diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java index db21ab904..debf402b4 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java @@ -19,8 +19,8 @@ package org.jivesoftware.smackx.workgroup.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; @@ -29,7 +29,7 @@ import org.xmlpull.v1.XmlPullParserException; * status notifications -- position updates, and estimated time * left in the queue updates. */ -public class QueueUpdate implements PacketExtension { +public class QueueUpdate implements ExtensionElement { /** * Element name of the packet extension. @@ -90,7 +90,7 @@ public class QueueUpdate implements PacketExtension { return NAMESPACE; } - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { @Override public QueueUpdate parse(XmlPullParser parser, int initialDepth) diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomInvitation.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomInvitation.java index 8f4c587d8..c03544ef0 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomInvitation.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomInvitation.java @@ -20,9 +20,9 @@ package org.jivesoftware.smackx.workgroup.packet; import java.io.IOException; import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.IQ.IQChildElementXmlStringBuilder; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.util.XmlStringBuilder; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -32,7 +32,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Gaston Dombiak */ -public class RoomInvitation implements PacketExtension { +public class RoomInvitation implements ExtensionElement { /** * Element name of the packet extension. @@ -158,7 +158,7 @@ public class RoomInvitation implements PacketExtension { } } - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { @Override public RoomInvitation parse(XmlPullParser parser, diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomTransfer.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomTransfer.java index 6144f7a25..8b4b4d9d8 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomTransfer.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomTransfer.java @@ -20,9 +20,9 @@ package org.jivesoftware.smackx.workgroup.packet; import java.io.IOException; import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.IQ.IQChildElementXmlStringBuilder; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.util.XmlStringBuilder; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -32,7 +32,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Gaston Dombiak */ -public class RoomTransfer implements PacketExtension { +public class RoomTransfer implements ExtensionElement { /** * Element name of the packet extension. @@ -158,7 +158,7 @@ public class RoomTransfer implements PacketExtension { } } - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { @Override public RoomTransfer parse(XmlPullParser parser, diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/SessionID.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/SessionID.java index 0930fd961..e869690cd 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/SessionID.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/SessionID.java @@ -19,12 +19,12 @@ package org.jivesoftware.smackx.workgroup.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; -public class SessionID implements PacketExtension { +public class SessionID implements ExtensionElement { /** * Element name of the packet extension. @@ -64,7 +64,7 @@ public class SessionID implements PacketExtension { return buf.toString(); } - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { @Override public SessionID parse(XmlPullParser parser, int initialDepth) diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java index d3485fdd8..79fd4c2d1 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java @@ -64,7 +64,7 @@ public class TranscriptSearch extends SimpleIQ { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { // Parse the packet extension - PacketParserUtils.addPacketExtension(answer, parser); + PacketParserUtils.addExtensionElement(answer, parser); } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals(ELEMENT_NAME)) { diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java index 145a0519d..3e2a6499f 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java @@ -19,12 +19,12 @@ package org.jivesoftware.smackx.workgroup.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; -public class UserID implements PacketExtension { +public class UserID implements ExtensionElement { /** * Element name of the packet extension. @@ -64,7 +64,7 @@ public class UserID implements PacketExtension { return buf.toString(); } - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { @Override public UserID parse(XmlPullParser parser, int initialDepth) diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java index 00a9208a8..9b19b2fb8 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java @@ -19,8 +19,8 @@ package org.jivesoftware.smackx.workgroup.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; @@ -28,7 +28,7 @@ import org.xmlpull.v1.XmlPullParserException; * A packet extension that contains information about the user and agent in a * workgroup chat. The packet extension is attached to group chat invitations. */ -public class WorkgroupInformation implements PacketExtension { +public class WorkgroupInformation implements ExtensionElement { /** * Element name of the packet extension. @@ -68,7 +68,7 @@ public class WorkgroupInformation implements PacketExtension { return buf.toString(); } - public static class Provider extends PacketExtensionProvider { + public static class Provider extends ExtensionElementProvider { /** * PacketExtensionProvider implementation diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java index 25156da22..05d5b1b71 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java @@ -31,12 +31,12 @@ 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.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; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.packet.DiscoverInfo; @@ -140,7 +140,7 @@ public class Workgroup { }); // Register a packet listener for all the messages sent to this client. - PacketFilter typeFilter = new PacketTypeFilter(Message.class); + StanzaFilter typeFilter = new StanzaTypeFilter(Message.class); connection.addAsyncPacketListener(new PacketListener() { public void processPacket(Stanza packet) { @@ -179,8 +179,8 @@ public class Workgroup { public boolean isAvailable() throws NoResponseException, XMPPErrorException, NotConnectedException { Presence directedPresence = new Presence(Presence.Type.available); directedPresence.setTo(workgroupJID); - PacketFilter typeFilter = new PacketTypeFilter(Presence.class); - PacketFilter fromFilter = FromMatchesFilter.create(workgroupJID); + StanzaFilter typeFilter = new StanzaTypeFilter(Presence.class); + StanzaFilter fromFilter = FromMatchesFilter.create(workgroupJID); PacketCollector collector = connection.createPacketCollectorAndSend(new AndFilter(fromFilter, typeFilter), directedPresence); @@ -496,8 +496,8 @@ public class Workgroup { if (packet instanceof Message) { Message msg = (Message)packet; // Check to see if the user left the queue. - PacketExtension pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup"); - PacketExtension queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup"); + ExtensionElement pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup"); + ExtensionElement queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup"); if (pe != null) { fireQueueDepartedEvent(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java index 732307bde..561ab508d 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java @@ -32,8 +32,8 @@ import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.MessageTypeFilter; 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.Stanza; import org.jivesoftware.smackx.xevent.packet.MessageEvent; @@ -52,7 +52,7 @@ public class MessageEventManager extends Manager { private static final Map INSTANCES = new WeakHashMap<>(); - private static final PacketFilter PACKET_FILTER = new AndFilter(new PacketExtensionFilter( + private static final StanzaFilter PACKET_FILTER = new AndFilter(new StanzaExtensionFilter( new MessageEvent()), new NotFilter(MessageTypeFilter.ERROR)); private List messageEventNotificationListeners = new CopyOnWriteArrayList(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/packet/MessageEvent.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/packet/MessageEvent.java index 6d18c6ea8..a58c65474 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/packet/MessageEvent.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/packet/MessageEvent.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.xevent.packet; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import java.util.ArrayList; import java.util.List; @@ -53,7 +53,7 @@ import java.util.List; * * @author Gaston Dombiak */ -public class MessageEvent implements PacketExtension { +public class MessageEvent implements ExtensionElement { public static final String NAMESPACE = "jabber:x:event"; public static final String ELEMENT = "x"; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/provider/MessageEventProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/provider/MessageEventProvider.java index 1b9e4e413..ba2304b96 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/provider/MessageEventProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/provider/MessageEventProvider.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.xevent.provider; import java.io.IOException; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.xevent.packet.MessageEvent; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -30,7 +30,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Gaston Dombiak */ -public class MessageEventProvider extends PacketExtensionProvider { +public class MessageEventProvider extends ExtensionElementProvider { /** * Parses a MessageEvent packet (extension sub-packet). diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java index 5569c27de..09ccadab1 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java @@ -27,8 +27,8 @@ import java.util.WeakHashMap; import org.jivesoftware.smack.PacketListener; 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.roster.Roster; @@ -52,7 +52,7 @@ public class RosterExchangeManager { private final static Map INSTANCES = new WeakHashMap<>(); - private final static PacketFilter PACKET_FILTER = new PacketExtensionFilter(ELEMENT, NAMESPACE); + private final static StanzaFilter PACKET_FILTER = new StanzaExtensionFilter(ELEMENT, NAMESPACE); private final Set rosterExchangeListeners = Collections.synchronizedSet(new HashSet()); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java index ea4ad201b..1baed7bda 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.xroster.packet; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.roster.Roster; import org.jivesoftware.smack.roster.RosterEntry; import org.jivesoftware.smack.roster.RosterGroup; @@ -48,7 +48,7 @@ import java.util.List; * * @author Gaston Dombiak */ -public class RosterExchange implements PacketExtension { +public class RosterExchange implements ExtensionElement { private List remoteRosterEntries = new ArrayList(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java index 45fd9274e..9eca95521 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java @@ -20,7 +20,7 @@ package org.jivesoftware.smackx.xroster.provider; import java.io.IOException; import java.util.ArrayList; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.xroster.RemoteRosterEntry; import org.jivesoftware.smackx.xroster.packet.RosterExchange; import org.xmlpull.v1.XmlPullParser; @@ -32,7 +32,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Gaston Dombiak */ -public class RosterExchangeProvider extends PacketExtensionProvider { +public class RosterExchangeProvider extends ExtensionElementProvider { /** * Parses a RosterExchange packet (extension sub-packet). diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/packet/StreamManagement.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/packet/StreamManagement.java index c92925d9b..46d85a140 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/packet/StreamManagement.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/packet/StreamManagement.java @@ -17,14 +17,14 @@ package org.jivesoftware.smack.sm.packet; import org.jivesoftware.smack.packet.FullStreamElement; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.util.XmlStringBuilder; public class StreamManagement { public static final String NAMESPACE = "urn:xmpp:sm:3"; - public static class StreamManagementFeature implements PacketExtension { + public static class StreamManagementFeature implements ExtensionElement { public static final String ELEMENT = "sm"; public static final StreamManagementFeature INSTANCE = new StreamManagementFeature(); diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/AfterXStanzas.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/AfterXStanzas.java index 72d7056ba..527d3123a 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/AfterXStanzas.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/AfterXStanzas.java @@ -16,10 +16,10 @@ */ package org.jivesoftware.smack.sm.predicates; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.Stanza; -public class AfterXStanzas implements PacketFilter { +public class AfterXStanzas implements StanzaFilter { final int count; int currentCount; diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForEveryMessage.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForEveryMessage.java index 86d37191e..7bd3d1443 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForEveryMessage.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForEveryMessage.java @@ -16,11 +16,11 @@ */ package org.jivesoftware.smack.sm.predicates; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Stanza; -public class ForEveryMessage implements PacketFilter { +public class ForEveryMessage implements StanzaFilter { public static final ForEveryMessage INSTANCE = new ForEveryMessage(); diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForEveryStanza.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForEveryStanza.java index 8e5555f2c..24f923752 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForEveryStanza.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForEveryStanza.java @@ -16,10 +16,10 @@ */ package org.jivesoftware.smack.sm.predicates; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.Stanza; -public class ForEveryStanza implements PacketFilter { +public class ForEveryStanza implements StanzaFilter { public static final ForEveryStanza INSTANCE = new ForEveryStanza(); diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForMatchingPredicateOrAfterXStanzas.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForMatchingPredicateOrAfterXStanzas.java index dcea27701..837b5c8a4 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForMatchingPredicateOrAfterXStanzas.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ForMatchingPredicateOrAfterXStanzas.java @@ -16,15 +16,15 @@ */ package org.jivesoftware.smack.sm.predicates; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.Stanza; -public class ForMatchingPredicateOrAfterXStanzas implements PacketFilter { +public class ForMatchingPredicateOrAfterXStanzas implements StanzaFilter { - private final PacketFilter predicate; + private final StanzaFilter predicate; private final AfterXStanzas afterXStanzas; - public ForMatchingPredicateOrAfterXStanzas(PacketFilter predicate, int count) { + public ForMatchingPredicateOrAfterXStanzas(StanzaFilter predicate, int count) { this.predicate = predicate; this.afterXStanzas = new AfterXStanzas(count); } diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/OnceForThisStanza.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/OnceForThisStanza.java index cb33c0ecf..15c00004c 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/OnceForThisStanza.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/OnceForThisStanza.java @@ -16,18 +16,18 @@ */ package org.jivesoftware.smack.sm.predicates; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.tcp.XMPPTCPConnection; import org.jivesoftware.smack.util.StringUtils; -public class OnceForThisStanza implements PacketFilter { +public class OnceForThisStanza implements StanzaFilter { private final String id; private final XMPPTCPConnection connection; public static void setup(XMPPTCPConnection connection, Stanza packet) { - PacketFilter packetFilter = new OnceForThisStanza(connection, packet); + StanzaFilter packetFilter = new OnceForThisStanza(connection, packet); connection.addRequestAckPredicate(packetFilter); } diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/Predicate.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/Predicate.java index 420924e6c..767886820 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/Predicate.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/Predicate.java @@ -16,11 +16,11 @@ */ package org.jivesoftware.smack.sm.predicates; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; public class Predicate { - public static PacketFilter forMessagesOrAfter5Stanzas() { + public static StanzaFilter forMessagesOrAfter5Stanzas() { return new ForMatchingPredicateOrAfterXStanzas(ForEveryMessage.INSTANCE, 5); } diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ShortcutPredicates.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ShortcutPredicates.java index c9fdb2c43..2e05bbc99 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ShortcutPredicates.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/predicates/ShortcutPredicates.java @@ -20,31 +20,31 @@ import java.util.Collection; import java.util.LinkedHashSet; import java.util.Set; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.packet.Stanza; -public class ShortcutPredicates implements PacketFilter { +public class ShortcutPredicates implements StanzaFilter { - private final Set predicates = new LinkedHashSet(); + private final Set predicates = new LinkedHashSet(); public ShortcutPredicates() { } - public ShortcutPredicates(Collection predicates) { + public ShortcutPredicates(Collection predicates) { this.predicates.addAll(predicates); } - public boolean addPredicate(PacketFilter predicate) { + public boolean addPredicate(StanzaFilter predicate) { return predicates.add(predicate); } - public boolean removePredicate(PacketFilter prediacte) { + public boolean removePredicate(StanzaFilter prediacte) { return predicates.remove(prediacte); } @Override public boolean accept(Stanza packet) { - for (PacketFilter predicate : predicates) { + for (StanzaFilter predicate : predicates) { if (predicate.accept(packet)) { return true; } diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/provider/StreamManagementStreamFeatureProvider.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/provider/StreamManagementStreamFeatureProvider.java index 46e5d2497..14f836b71 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/provider/StreamManagementStreamFeatureProvider.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/provider/StreamManagementStreamFeatureProvider.java @@ -16,11 +16,11 @@ */ package org.jivesoftware.smack.sm.provider; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.sm.packet.StreamManagement.StreamManagementFeature; import org.xmlpull.v1.XmlPullParser; -public class StreamManagementStreamFeatureProvider extends PacketExtensionProvider { +public class StreamManagementStreamFeatureProvider extends ExtensionElementProvider { @Override public StreamManagementFeature parse(XmlPullParser parser, diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 75be75283..9380d9b44 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -38,7 +38,7 @@ import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.compress.packet.Compressed; import org.jivesoftware.smack.compression.XMPPInputOutputStream; -import org.jivesoftware.smack.filter.PacketFilter; +import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.compress.packet.Compress; import org.jivesoftware.smack.packet.Element; import org.jivesoftware.smack.packet.IQ; @@ -279,7 +279,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * order in which they are invoked in order to determine if an ack request should be send or not. *

*/ - private final Set requestAckPredicates = new LinkedHashSet(); + private final Set requestAckPredicates = new LinkedHashSet(); private final XMPPTCPConnectionConfiguration config; @@ -534,7 +534,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { protected void sendPacketInternal(Stanza packet) throws NotConnectedException { packetWriter.sendStreamElement(packet); if (isSmEnabled()) { - for (PacketFilter requestAckPredicate : requestAckPredicates) { + for (StanzaFilter requestAckPredicate : requestAckPredicates) { if (requestAckPredicate.accept(packet)) { requestSmAcknowledgementInternal(); break; @@ -1487,7 +1487,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * @param predicate the predicate to add. * @return if the predicate was not already active. */ - public boolean addRequestAckPredicate(PacketFilter predicate) { + public boolean addRequestAckPredicate(StanzaFilter predicate) { synchronized (requestAckPredicates) { return requestAckPredicates.add(predicate); } @@ -1498,7 +1498,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * @param predicate the predicate to remove. * @return true if the predicate was removed. */ - public boolean removeRequestAckPredicate(PacketFilter predicate) { + public boolean removeRequestAckPredicate(StanzaFilter predicate) { synchronized (requestAckPredicates) { return requestAckPredicates.remove(predicate); } From 75ec271c6c813b3fd0a806374ffcf63d1db42e0b Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 1 Mar 2015 10:28:15 +0100 Subject: [PATCH 18/30] Rename PacketListener to StanzaListener and add the PacketListener as deprecated interface. --- .../smack/bosh/XMPPBOSHConnection.java | 2 +- .../smack/AbstractXMPPConnection.java | 92 +++++++++---------- .../jivesoftware/smack/PacketCollector.java | 2 +- .../jivesoftware/smack/PacketListener.java | 33 +------ .../jivesoftware/smack/StanzaListener.java | 53 +++++++++++ .../jivesoftware/smack/XMPPConnection.java | 58 ++++++------ .../smack/debugger/AbstractDebugger.java | 10 +- .../smack/debugger/SmackDebugger.java | 6 +- .../smack/filter/PacketFilter.java | 2 +- .../smack/filter/StanzaFilter.java | 2 +- .../test/util/WaitForPacketListener.java | 4 +- .../slf4j/SLF4JLoggingPacketListener.java | 4 +- .../debugger/slf4j/SLF4JSmackDebugger.java | 10 +- .../smackx/debugger/EnhancedDebugger.java | 16 ++-- .../smackx/debugger/LiteDebugger.java | 12 +-- .../smackx/carbons/CarbonManager.java | 4 +- .../smackx/bytestreams/ibb/DataListener.java | 4 +- .../ibb/InBandBytestreamManager.java | 4 +- .../ibb/InBandBytestreamSession.java | 18 ++-- .../smackx/caps/EntityCapsManager.java | 10 +- .../smackx/iqlast/LastActivityManager.java | 6 +- .../smackx/muc/MultiUserChat.java | 42 ++++----- .../smackx/muc/MultiUserChatManager.java | 6 +- .../jivesoftware/smackx/pep/PEPManager.java | 10 +- .../smackx/privacy/PrivacyListManager.java | 12 +-- .../org/jivesoftware/smackx/pubsub/Node.java | 40 ++++---- .../receipts/DeliveryReceiptManager.java | 8 +- .../InBandBytestreamSessionMessageTest.java | 8 +- .../ibb/InBandBytestreamSessionTest.java | 20 ++-- .../jivesoftware/smack/chat/ChatManager.java | 4 +- .../org/jivesoftware/smack/roster/Roster.java | 8 +- .../smack/chat/ChatConnectionTest.java | 2 +- .../smackx/jingleold/JingleManager.java | 4 +- .../smackx/jingleold/JingleSession.java | 10 +- .../smackx/workgroup/agent/AgentRoster.java | 10 +- .../smackx/workgroup/agent/AgentSession.java | 10 +- .../smackx/workgroup/user/Workgroup.java | 4 +- .../smackx/xevent/MessageEventManager.java | 4 +- .../smackx/xroster/RosterExchangeManager.java | 8 +- .../smack/tcp/XMPPTCPConnection.java | 22 ++--- 40 files changed, 305 insertions(+), 279 deletions(-) create mode 100644 smack-core/src/main/java/org/jivesoftware/smack/StanzaListener.java diff --git a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java index 1bc1e1492..2022c938e 100644 --- a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java +++ b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java @@ -158,7 +158,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection { initDebugger(); if (isFirstInitialization) { if (debugger.getReaderListener() != null) { - addAsyncPacketListener(debugger.getReaderListener(), null); + addAsyncStanzaListener(debugger.getReaderListener(), null); } if (debugger.getWriterListener() != null) { addPacketSendingListener(debugger.getWriterListener(), null); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 3343291bd..35a64043e 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -131,26 +131,26 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { /** * List of PacketListeners that will be notified synchronously when a new packet was received. */ - private final Map syncRecvListeners = new LinkedHashMap<>(); + private final Map syncRecvListeners = new LinkedHashMap<>(); /** * List of PacketListeners that will be notified asynchronously when a new packet was received. */ - private final Map asyncRecvListeners = new LinkedHashMap<>(); + private final Map asyncRecvListeners = new LinkedHashMap<>(); /** * List of PacketListeners that will be notified when a new packet was sent. */ - private final Map sendListeners = - new HashMap(); + private final Map sendListeners = + new HashMap(); /** * List of PacketListeners that will be notified when a new packet is about to be * sent to the server. These interceptors may modify the packet before it is being * actually sent to the server. */ - private final Map interceptors = - new HashMap(); + private final Map interceptors = + new HashMap(); protected final Lock connectionLock = new ReentrantLock(); @@ -759,18 +759,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { @Override @Deprecated - public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter) { - addAsyncPacketListener(packetListener, packetFilter); + public void addPacketListener(StanzaListener packetListener, StanzaFilter packetFilter) { + addAsyncStanzaListener(packetListener, packetFilter); } @Override @Deprecated - public boolean removePacketListener(PacketListener packetListener) { - return removeAsyncPacketListener(packetListener); + public boolean removePacketListener(StanzaListener packetListener) { + return removeAsyncStanzaListener(packetListener); } @Override - public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) { + public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter) { if (packetListener == null) { throw new NullPointerException("Packet listener is null."); } @@ -781,14 +781,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public boolean removeSyncPacketListener(PacketListener packetListener) { + public boolean removeSyncStanzaListener(StanzaListener packetListener) { synchronized (syncRecvListeners) { return syncRecvListeners.remove(packetListener) != null; } } @Override - public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) { + public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter) { if (packetListener == null) { throw new NullPointerException("Packet listener is null."); } @@ -799,14 +799,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public boolean removeAsyncPacketListener(PacketListener packetListener) { + public boolean removeAsyncStanzaListener(StanzaListener packetListener) { synchronized (asyncRecvListeners) { return asyncRecvListeners.remove(packetListener) != null; } } @Override - public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter) { + public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter) { if (packetListener == null) { throw new NullPointerException("Packet listener is null."); } @@ -817,7 +817,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public void removePacketSendingListener(PacketListener packetListener) { + public void removePacketSendingListener(StanzaListener packetListener) { synchronized (sendListeners) { sendListeners.remove(packetListener); } @@ -833,7 +833,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { */ @SuppressWarnings("javadoc") protected void firePacketSendingListeners(final Stanza packet) { - final List listenersToNotify = new LinkedList(); + final List listenersToNotify = new LinkedList(); synchronized (sendListeners) { for (ListenerWrapper listenerWrapper : sendListeners.values()) { if (listenerWrapper.filterMatches(packet)) { @@ -848,7 +848,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { asyncGo(new Runnable() { @Override public void run() { - for (PacketListener listener : listenersToNotify) { + for (StanzaListener listener : listenersToNotify) { try { listener.processPacket(packet); } @@ -861,7 +861,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public void addPacketInterceptor(PacketListener packetInterceptor, + public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter) { if (packetInterceptor == null) { throw new NullPointerException("Packet interceptor is null."); @@ -873,7 +873,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public void removePacketInterceptor(PacketListener packetInterceptor) { + public void removePacketInterceptor(StanzaListener packetInterceptor) { synchronized (interceptors) { interceptors.remove(packetInterceptor); } @@ -888,7 +888,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @param packet the packet that is going to be sent to the server */ private void firePacketInterceptors(Stanza packet) { - List interceptorsToInvoke = new LinkedList(); + List interceptorsToInvoke = new LinkedList(); synchronized (interceptors) { for (InterceptorWrapper interceptorWrapper : interceptors.values()) { if (interceptorWrapper.filterMatches(packet)) { @@ -896,7 +896,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } } } - for (PacketListener interceptor : interceptorsToInvoke) { + for (StanzaListener interceptor : interceptorsToInvoke) { try { interceptor.processPacket(packet); } catch (Exception e) { @@ -1107,7 +1107,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { // First handle the async recv listeners. Note that this code is very similar to what follows a few lines below, // the only difference is that asyncRecvListeners is used here and that the packet listeners are started in // their own thread. - final Collection listenersToNotify = new LinkedList(); + final Collection listenersToNotify = new LinkedList(); synchronized (asyncRecvListeners) { for (ListenerWrapper listenerWrapper : asyncRecvListeners.values()) { if (listenerWrapper.filterMatches(packet)) { @@ -1116,7 +1116,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } } - for (final PacketListener listener : listenersToNotify) { + for (final StanzaListener listener : listenersToNotify) { asyncGo(new Runnable() { @Override public void run() { @@ -1149,7 +1149,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { singleThreadedExecutorService.execute(new Runnable() { @Override public void run() { - for (PacketListener listener : listenersToNotify) { + for (StanzaListener listener : listenersToNotify) { try { listener.processPacket(packet); } catch(NotConnectedException e) { @@ -1243,7 +1243,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { */ protected static class ListenerWrapper { - private final PacketListener packetListener; + private final StanzaListener packetListener; private final StanzaFilter packetFilter; /** @@ -1252,7 +1252,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @param packetListener the packet listener. * @param packetFilter the associated filter or null if it listen for all packets. */ - public ListenerWrapper(PacketListener packetListener, StanzaFilter packetFilter) { + public ListenerWrapper(StanzaListener packetListener, StanzaFilter packetFilter) { this.packetListener = packetListener; this.packetFilter = packetFilter; } @@ -1261,7 +1261,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { return packetFilter == null || packetFilter.accept(packet); } - public PacketListener getListener() { + public StanzaListener getListener() { return packetListener; } } @@ -1271,7 +1271,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { */ protected static class InterceptorWrapper { - private final PacketListener packetInterceptor; + private final StanzaListener packetInterceptor; private final StanzaFilter packetFilter; /** @@ -1280,7 +1280,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @param packetInterceptor the interceptor. * @param packetFilter the associated filter or null if it intercepts all packets. */ - public InterceptorWrapper(PacketListener packetInterceptor, StanzaFilter packetFilter) { + public InterceptorWrapper(StanzaListener packetInterceptor, StanzaFilter packetFilter) { this.packetInterceptor = packetInterceptor; this.packetFilter = packetFilter; } @@ -1289,7 +1289,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { return packetFilter == null || packetFilter.accept(packet); } - public PacketListener getInterceptor() { + public StanzaListener getInterceptor() { return packetInterceptor; } } @@ -1417,13 +1417,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { @Override public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, - PacketListener callback) throws NotConnectedException { + StanzaListener callback) throws NotConnectedException { sendStanzaWithResponseCallback(stanza, replyFilter, callback, null); } @Override public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, - PacketListener callback, ExceptionCallback exceptionCallback) + StanzaListener callback, ExceptionCallback exceptionCallback) throws NotConnectedException { sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback, getPacketReplyTimeout()); @@ -1431,7 +1431,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { @Override public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter, - final PacketListener callback, final ExceptionCallback exceptionCallback, + final StanzaListener callback, final ExceptionCallback exceptionCallback, long timeout) throws NotConnectedException { Objects.requireNonNull(stanza, "stanza must not be null"); // While Smack allows to add PacketListeners with a PacketFilter value of 'null', we @@ -1439,7 +1439,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { Objects.requireNonNull(replyFilter, "replyFilter must not be null"); Objects.requireNonNull(callback, "callback must not be null"); - final PacketListener packetListener = new PacketListener() { + final StanzaListener packetListener = new StanzaListener() { @Override public void processPacket(Stanza packet) throws NotConnectedException { try { @@ -1452,14 +1452,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } } finally { - removeAsyncPacketListener(this); + removeAsyncStanzaListener(this); } } }; removeCallbacksService.schedule(new Runnable() { @Override public void run() { - boolean removed = removeAsyncPacketListener(packetListener); + boolean removed = removeAsyncStanzaListener(packetListener); // If the packetListener got removed, then it was never run and // we never received a response, inform the exception callback if (removed && exceptionCallback != null) { @@ -1467,24 +1467,24 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } } }, timeout, TimeUnit.MILLISECONDS); - addAsyncPacketListener(packetListener, replyFilter); + addAsyncStanzaListener(packetListener, replyFilter); sendPacket(stanza); } @Override - public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback) + public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException { sendIqWithResponseCallback(iqRequest, callback, null); } @Override - public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback, + public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback, ExceptionCallback exceptionCallback) throws NotConnectedException { sendIqWithResponseCallback(iqRequest, callback, exceptionCallback, getPacketReplyTimeout()); } @Override - public void sendIqWithResponseCallback(IQ iqRequest, final PacketListener callback, + public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback, final ExceptionCallback exceptionCallback, long timeout) throws NotConnectedException { StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this); @@ -1492,22 +1492,22 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public void addOneTimeSyncCallback(final PacketListener callback, final StanzaFilter packetFilter) { - final PacketListener packetListener = new PacketListener() { + public void addOneTimeSyncCallback(final StanzaListener callback, final StanzaFilter packetFilter) { + final StanzaListener packetListener = new StanzaListener() { @Override public void processPacket(Stanza packet) throws NotConnectedException { try { callback.processPacket(packet); } finally { - removeSyncPacketListener(this); + removeSyncStanzaListener(this); } } }; - addSyncPacketListener(packetListener, packetFilter); + addSyncStanzaListener(packetListener, packetFilter); removeCallbacksService.schedule(new Runnable() { @Override public void run() { - removeSyncPacketListener(packetListener); + removeSyncStanzaListener(packetListener); } }, getPacketReplyTimeout(), TimeUnit.MILLISECONDS); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java b/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java index 83d81bd6d..a324f8923 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java @@ -31,7 +31,7 @@ import org.jivesoftware.smack.packet.Stanza; * Provides a mechanism to collect packets into a result queue that pass a * specified filter. The collector lets you perform blocking and polling * operations on the result queue. So, a PacketCollector is more suitable to - * use than a {@link PacketListener} when you need to wait for a specific + * use than a {@link StanzaListener} when you need to wait for a specific * result.

* * Each packet collector will queue up a configured number of packets for processing before diff --git a/smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java b/smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java index fbe392883..856a53c54 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java @@ -17,37 +17,10 @@ package org.jivesoftware.smack; -import org.jivesoftware.smack.SmackException.NotConnectedException; -import org.jivesoftware.smack.packet.Stanza; - /** - * Provides a mechanism to listen for packets that pass a specified filter. - * This allows event-style programming -- every time a new packet is found, - * the {@link #processPacket(Stanza)} method will be called. This is the - * opposite approach to the functionality provided by a {@link PacketCollector} - * which lets you block while waiting for results. - *

- * Additionally you are able to intercept Packets that are going to be send and - * make modifications to them. You can register a PacketListener as interceptor - * by using {@link XMPPConnection#addPacketInterceptor(PacketListener, - * org.jivesoftware.smack.filter.StanzaFilter)} - *

- * - * @see XMPPConnection#addAsyncPacketListener(PacketListener, org.jivesoftware.smack.filter.StanzaFilter) - * @author Matt Tucker + * @deprecated use {@link StanzaListener} instead */ -public interface PacketListener { - - /** - * Process the next packet sent to this packet listener. - *

- * A single thread is responsible for invoking all listeners, so - * it's very important that implementations of this method not block - * for any extended period of time. - *

- * - * @param packet the packet to process. - */ - public void processPacket(Stanza packet) throws NotConnectedException; +@Deprecated +public interface PacketListener extends StanzaListener { } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/StanzaListener.java b/smack-core/src/main/java/org/jivesoftware/smack/StanzaListener.java new file mode 100644 index 000000000..01bcf89d9 --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/StanzaListener.java @@ -0,0 +1,53 @@ +/** + * + * Copyright 2003-2007 Jive Software. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jivesoftware.smack; + +import org.jivesoftware.smack.SmackException.NotConnectedException; +import org.jivesoftware.smack.packet.Stanza; + +/** + * Provides a mechanism to listen for packets that pass a specified filter. + * This allows event-style programming -- every time a new packet is found, + * the {@link #processPacket(Stanza)} method will be called. This is the + * opposite approach to the functionality provided by a {@link PacketCollector} + * which lets you block while waiting for results. + *

+ * Additionally you are able to intercept Packets that are going to be send and + * make modifications to them. You can register a PacketListener as interceptor + * by using {@link XMPPConnection#addPacketInterceptor(StanzaListener, + * org.jivesoftware.smack.filter.StanzaFilter)} + *

+ * + * @see XMPPConnection#addAsyncStanzaListener(StanzaListener, org.jivesoftware.smack.filter.StanzaFilter) + * @author Matt Tucker + */ +public interface StanzaListener { + + /** + * Process the next packet sent to this packet listener. + *

+ * A single thread is responsible for invoking all listeners, so + * it's very important that implementations of this method not block + * for any extended period of time. + *

+ * + * @param packet the packet to process. + */ + public void processPacket(Stanza packet) throws NotConnectedException; + +} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java index 183b9b1fc..b6c091dc3 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java @@ -204,7 +204,7 @@ public interface XMPPConnection { /** * Creates a new packet collector for this connection. A packet filter determines * which packets will be accumulated by the collector. A PacketCollector is - * more suitable to use than a {@link PacketListener} when you need to wait for + * more suitable to use than a {@link StanzaListener} when you need to wait for * a specific result. * * @param packetFilter the packet filter to use. @@ -217,7 +217,7 @@ public interface XMPPConnection { /** * Creates a new packet collector for this connection. A packet filter * determines which packets will be accumulated by the collector. A - * PacketCollector is more suitable to use than a {@link PacketListener} + * PacketCollector is more suitable to use than a {@link StanzaListener} * when you need to wait for a specific result. *

* Note: If you send a Packet right after using this method, then @@ -257,27 +257,27 @@ public interface XMPPConnection { *

* This method has been deprecated. It is important to differentiate between using an asynchronous packet listener * (preferred where possible) and a synchronous packet lister. Refer - * {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} and - * {@link #addSyncPacketListener(PacketListener, StanzaFilter)} for more information. + * {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} and + * {@link #addSyncStanzaListener(StanzaListener, StanzaFilter)} for more information. *

* * @param packetListener the packet listener to notify of new received packets. * @param packetFilter the packet filter to use. - * @deprecated use {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} or - * {@link #addSyncPacketListener(PacketListener, StanzaFilter)}. + * @deprecated use {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} or + * {@link #addSyncStanzaListener(StanzaListener, StanzaFilter)}. */ @Deprecated - public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter); + public void addPacketListener(StanzaListener packetListener, StanzaFilter packetFilter); /** * Removes a packet listener for received packets from this connection. * * @param packetListener the packet listener to remove. * @return true if the packet listener was removed - * @deprecated use {@link #removeAsyncPacketListener(PacketListener)} or {@link #removeSyncPacketListener(PacketListener)}. + * @deprecated use {@link #removeAsyncStanzaListener(StanzaListener)} or {@link #removeSyncStanzaListener(StanzaListener)}. */ @Deprecated - public boolean removePacketListener(PacketListener packetListener); + public boolean removePacketListener(StanzaListener packetListener); /** * Registers a synchronous packet listener with this connection. A packet listener will be invoked only when @@ -286,17 +286,17 @@ public interface XMPPConnection { *

* Important: This packet listeners will be called in the same single thread that processes all * incoming stanzas. Only use this kind of packet filter if it does not perform any XMPP activity that waits for a - * response. Consider using {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} when possible, i.e. when + * response. Consider using {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} when possible, i.e. when * the invocation order doesn't have to be the same as the order of the arriving packets. If the order of the * arriving packets, consider using a {@link PacketCollector} when possible. *

* * @param packetListener the packet listener to notify of new received packets. * @param packetFilter the packet filter to use. - * @see #addPacketInterceptor(PacketListener, StanzaFilter) + * @see #addPacketInterceptor(StanzaListener, StanzaFilter) * @since 4.1 */ - public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter); + public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter); /** * Removes a packet listener for received packets from this connection. @@ -305,24 +305,24 @@ public interface XMPPConnection { * @return true if the packet listener was removed * @since 4.1 */ - public boolean removeSyncPacketListener(PacketListener packetListener); + public boolean removeSyncStanzaListener(StanzaListener packetListener); /** * Registers an asynchronous packet listener with this connection. A packet listener will be invoked only * when an incoming packet is received. A packet filter determines which packets will be delivered to the listener. * If the same packet listener is added again with a different filter, only the new filter will be used. *

- * Unlike {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} packet listeners added with this method will be + * Unlike {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} packet listeners added with this method will be * invoked asynchronously in their own thread. Use this method if the order of the packet listeners must not depend * on the order how the stanzas where received. *

* * @param packetListener the packet listener to notify of new received packets. * @param packetFilter the packet filter to use. - * @see #addPacketInterceptor(PacketListener, StanzaFilter) + * @see #addPacketInterceptor(StanzaListener, StanzaFilter) * @since 4.1 */ - public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter); + public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter); /** * Removes an asynchronous packet listener for received packets from this connection. @@ -331,7 +331,7 @@ public interface XMPPConnection { * @return true if the packet listener was removed * @since 4.1 */ - public boolean removeAsyncPacketListener(PacketListener packetListener); + public boolean removeAsyncStanzaListener(StanzaListener packetListener); /** * Registers a packet listener with this connection. The listener will be @@ -344,14 +344,14 @@ public interface XMPPConnection { * @param packetListener the packet listener to notify of sent packets. * @param packetFilter the packet filter to use. */ - public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter); + public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter); /** * Removes a packet listener for sending packets from this connection. * * @param packetListener the packet listener to remove. */ - public void removePacketSendingListener(PacketListener packetListener); + public void removePacketSendingListener(StanzaListener packetListener); /** * Registers a packet interceptor with this connection. The interceptor will be @@ -360,19 +360,19 @@ public interface XMPPConnection { * will be delivered to the interceptor. * *

- * NOTE: For a similar functionality on incoming packets, see {@link #addAsyncPacketListener(PacketListener, StanzaFilter)}. + * NOTE: For a similar functionality on incoming packets, see {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}. * * @param packetInterceptor the packet interceptor to notify of packets about to be sent. * @param packetFilter the packet filter to use. */ - public void addPacketInterceptor(PacketListener packetInterceptor, StanzaFilter packetFilter); + public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter); /** * Removes a packet interceptor. * * @param packetInterceptor the packet interceptor to remove. */ - public void removePacketInterceptor(PacketListener packetInterceptor); + public void removePacketInterceptor(StanzaListener packetInterceptor); /** * Returns the current value of the reply timeout in milliseconds for request for this @@ -464,7 +464,7 @@ public interface XMPPConnection { * @throws NotConnectedException */ public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, - PacketListener callback) throws NotConnectedException; + StanzaListener callback) throws NotConnectedException; /** * Send a stanza and wait asynchronously for a response by using replyFilter. @@ -480,7 +480,7 @@ public interface XMPPConnection { * @param exceptionCallback the callback invoked if there is an exception (optional) * @throws NotConnectedException */ - public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, PacketListener callback, + public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback, ExceptionCallback exceptionCallback) throws NotConnectedException; /** @@ -499,7 +499,7 @@ public interface XMPPConnection { * @throws NotConnectedException */ public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, - final PacketListener callback, final ExceptionCallback exceptionCallback, + final StanzaListener callback, final ExceptionCallback exceptionCallback, long timeout) throws NotConnectedException; /** @@ -511,7 +511,7 @@ public interface XMPPConnection { * @param callback the callback invoked if there is result response (required) * @throws NotConnectedException */ - public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback) throws NotConnectedException; + public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException; /** * Send a IQ stanza and invoke callback if there is a result of @@ -526,7 +526,7 @@ public interface XMPPConnection { * @param exceptionCallback the callback invoked if there is an Exception optional * @throws NotConnectedException */ - public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback, + public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback, ExceptionCallback exceptionCallback) throws NotConnectedException; /** @@ -543,7 +543,7 @@ public interface XMPPConnection { * @param timeout the timeout in milliseconds to wait for a response * @throws NotConnectedException */ - public void sendIqWithResponseCallback(IQ iqRequest, final PacketListener callback, + public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback, final ExceptionCallback exceptionCallback, long timeout) throws NotConnectedException; @@ -554,7 +554,7 @@ public interface XMPPConnection { * @param callback the callback invoked once the packet filter matches a stanza. * @param packetFilter the filter to match stanzas or null to match all. */ - public void addOneTimeSyncCallback(PacketListener callback, StanzaFilter packetFilter); + public void addOneTimeSyncCallback(StanzaListener callback, StanzaFilter packetFilter); /** * Register an IQ request handler with this connection. diff --git a/smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java b/smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java index 199167f02..c6524fb8a 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java @@ -17,7 +17,7 @@ package org.jivesoftware.smack.debugger; import org.jivesoftware.smack.ConnectionListener; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.util.ObservableReader; @@ -35,7 +35,7 @@ public abstract class AbstractDebugger implements SmackDebugger { private final XMPPConnection connection; - private final PacketListener listener; + private final StanzaListener listener; private final ConnectionListener connListener; private final ReaderListener readerListener; private final WriterListener writerListener; @@ -67,7 +67,7 @@ public abstract class AbstractDebugger implements SmackDebugger { // Create a thread that will listen for all incoming packets and write them to // the GUI. This is what we call "interpreted" packet data, since it's the packet // data as Smack sees it and not as it's coming in as raw XML. - listener = new PacketListener() { + listener = new StanzaListener() { public void processPacket(Stanza packet) { if (printInterpreted) { log("RCV PKT (" + connection.getConnectionCounter() + "): " + packet.toXML()); @@ -166,11 +166,11 @@ public abstract class AbstractDebugger implements SmackDebugger { return writer; } - public PacketListener getReaderListener() { + public StanzaListener getReaderListener() { return listener; } - public PacketListener getWriterListener() { + public StanzaListener getWriterListener() { return null; } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/debugger/SmackDebugger.java b/smack-core/src/main/java/org/jivesoftware/smack/debugger/SmackDebugger.java index 6bef09459..0871ff1b1 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/debugger/SmackDebugger.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/debugger/SmackDebugger.java @@ -20,7 +20,7 @@ package org.jivesoftware.smack.debugger; import java.io.Reader; import java.io.Writer; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; /** * Interface that allows for implementing classes to debug XML traffic. That is a GUI window that @@ -84,7 +84,7 @@ public interface SmackDebugger { * @return the PacketListener that will listen for all incoming packets and write them to * the GUI */ - public abstract PacketListener getReaderListener(); + public abstract StanzaListener getReaderListener(); /** * Returns the thread that will listen for all outgoing packets and write them to the GUI. @@ -92,5 +92,5 @@ public interface SmackDebugger { * @return the PacketListener that will listen for all sent packets and write them to * the GUI */ - public abstract PacketListener getWriterListener(); + public abstract StanzaListener getWriterListener(); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketFilter.java index b910a065b..4dd91466d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/PacketFilter.java @@ -41,7 +41,7 @@ package org.jivesoftware.smack.filter; * * * @see org.jivesoftware.smack.PacketCollector - * @see org.jivesoftware.smack.PacketListener + * @see org.jivesoftware.smack.StanzaListener * @author Matt Tucker * @deprecated use {@link StanzaFilter} */ diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java index 77c2a9950..39a39e173 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java @@ -43,7 +43,7 @@ import org.jivesoftware.smack.packet.Stanza; * * * @see org.jivesoftware.smack.PacketCollector - * @see org.jivesoftware.smack.PacketListener + * @see org.jivesoftware.smack.StanzaListener * @author Matt Tucker */ public interface StanzaFilter { diff --git a/smack-core/src/test/java/org/jivesoftware/smack/test/util/WaitForPacketListener.java b/smack-core/src/test/java/org/jivesoftware/smack/test/util/WaitForPacketListener.java index 2e2c02425..1bedf27c7 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/test/util/WaitForPacketListener.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/test/util/WaitForPacketListener.java @@ -19,11 +19,11 @@ package org.jivesoftware.smack.test.util; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.packet.Stanza; -public class WaitForPacketListener implements PacketListener { +public class WaitForPacketListener implements StanzaListener { private CountDownLatch latch = new CountDownLatch(1); diff --git a/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JLoggingPacketListener.java b/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JLoggingPacketListener.java index 31cf1d28e..8b4d43fe2 100644 --- a/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JLoggingPacketListener.java +++ b/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JLoggingPacketListener.java @@ -17,12 +17,12 @@ package org.jivesoftware.smackx.debugger.slf4j; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.packet.Stanza; import org.slf4j.Logger; -class SLF4JLoggingPacketListener implements PacketListener { +class SLF4JLoggingPacketListener implements StanzaListener { private final Logger logger; private final String prefix; diff --git a/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JSmackDebugger.java b/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JSmackDebugger.java index c9dd213d8..8837f5f92 100644 --- a/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JSmackDebugger.java +++ b/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JSmackDebugger.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.debugger.slf4j; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.debugger.SmackDebugger; @@ -47,8 +47,8 @@ public class SLF4JSmackDebugger implements SmackDebugger { private final XMPPConnection connection; - private final PacketListener receivedListener = new SLF4JLoggingPacketListener(logger, RECEIVED_TAG); - private final PacketListener sentListener = new SLF4JLoggingPacketListener(logger, SENT_TAG); + private final StanzaListener receivedListener = new SLF4JLoggingPacketListener(logger, RECEIVED_TAG); + private final StanzaListener sentListener = new SLF4JLoggingPacketListener(logger, SENT_TAG); private final SLF4JRawXmlListener slf4JRawXmlListener = new SLF4JRawXmlListener(logger); private ObservableWriter writer; @@ -119,12 +119,12 @@ public class SLF4JSmackDebugger implements SmackDebugger { } @Override - public PacketListener getReaderListener() { + public StanzaListener getReaderListener() { return receivedListener; } @Override - public PacketListener getWriterListener() { + public StanzaListener getWriterListener() { return sentListener; } } diff --git a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java index 28deec887..389092ebf 100644 --- a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java +++ b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.debugger; import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.ConnectionListener; -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.debugger.SmackDebugger; @@ -148,8 +148,8 @@ public class EnhancedDebugger implements SmackDebugger { private XMPPConnection connection = null; - private PacketListener packetReaderListener = null; - private PacketListener packetWriterListener = null; + private StanzaListener packetReaderListener = null; + private StanzaListener packetWriterListener = null; private ConnectionListener connListener = null; private Writer writer; @@ -203,7 +203,7 @@ public class EnhancedDebugger implements SmackDebugger { // Create a thread that will listen for all incoming packets and write them to // the GUI. This is what we call "interpreted" packet data, since it's the packet // data as Smack sees it and not as it's coming in as raw XML. - packetReaderListener = new PacketListener() { + packetReaderListener = new StanzaListener() { SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa"); public void processPacket(final Stanza packet) { @@ -218,7 +218,7 @@ public class EnhancedDebugger implements SmackDebugger { // Create a thread that will listen for all outgoing packets and write them to // the GUI. - packetWriterListener = new PacketListener() { + packetWriterListener = new StanzaListener() { SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa"); public void processPacket(final Stanza packet) { @@ -757,11 +757,11 @@ public class EnhancedDebugger implements SmackDebugger { return writer; } - public PacketListener getReaderListener() { + public StanzaListener getReaderListener() { return packetReaderListener; } - public PacketListener getWriterListener() { + public StanzaListener getWriterListener() { return packetWriterListener; } @@ -956,7 +956,7 @@ public class EnhancedDebugger implements SmackDebugger { */ void cancel() { connection.removeConnectionListener(connListener); - connection.removeAsyncPacketListener(packetReaderListener); + connection.removeAsyncStanzaListener(packetReaderListener); connection.removePacketSendingListener(packetWriterListener); ((ObservableReader) reader).removeReaderListener(readerListener); ((ObservableWriter) writer).removeWriterListener(writerListener); diff --git a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/LiteDebugger.java b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/LiteDebugger.java index 259ca7900..9247c9978 100644 --- a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/LiteDebugger.java +++ b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/LiteDebugger.java @@ -40,7 +40,7 @@ import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.debugger.SmackDebugger; import org.jivesoftware.smack.packet.Stanza; @@ -63,7 +63,7 @@ public class LiteDebugger implements SmackDebugger { private JFrame frame = null; private XMPPConnection connection = null; - private PacketListener listener = null; + private StanzaListener listener = null; private Writer writer; private Reader reader; @@ -261,7 +261,7 @@ public class LiteDebugger implements SmackDebugger { // Create a thread that will listen for all incoming packets and write them to // the GUI. This is what we call "interpreted" packet data, since it's the packet // data as Smack sees it and not as it's coming in as raw XML. - listener = new PacketListener() { + listener = new StanzaListener() { public void processPacket(Stanza packet) { interpretedText1.append(packet.toXML().toString()); interpretedText2.append(packet.toXML().toString()); @@ -278,7 +278,7 @@ public class LiteDebugger implements SmackDebugger { * @param evt the event that indicates that the root window is closing */ public void rootWindowClosing(WindowEvent evt) { - connection.removeAsyncPacketListener(listener); + connection.removeAsyncStanzaListener(listener); ((ObservableReader)reader).removeReaderListener(readerListener); ((ObservableWriter)writer).removeWriterListener(writerListener); } @@ -345,11 +345,11 @@ public class LiteDebugger implements SmackDebugger { return writer; } - public PacketListener getReaderListener() { + public StanzaListener getReaderListener() { return listener; } - public PacketListener getWriterListener() { + public StanzaListener getWriterListener() { return null; } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java index eadd71137..743f5452a 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java @@ -25,7 +25,7 @@ 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; import org.jivesoftware.smack.XMPPException.XMPPErrorException; @@ -119,7 +119,7 @@ public class CarbonManager extends Manager { public void sendCarbonsEnabled(final boolean new_state) throws NotConnectedException { IQ setIQ = carbonsEnabledIQ(new_state); - connection().sendIqWithResponseCallback(setIQ, new PacketListener() { + connection().sendIqWithResponseCallback(setIQ, new StanzaListener() { public void processPacket(Stanza packet) { enabled_state = new_state; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java index 233c40075..432e02d1e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.bytestreams.ibb; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.StanzaFilter; @@ -38,7 +38,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Data; * * @author Henning Staib */ -class DataListener implements PacketListener { +class DataListener implements StanzaListener { /* manager containing the listeners and the XMPP connection */ private final InBandBytestreamManager manager; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java index e29fd0ce4..7fa27c46b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java @@ -214,7 +214,7 @@ public class InBandBytestreamManager implements BytestreamManager { // register bytestream data packet listener this.dataListener = new DataListener(this); - this.connection.addSyncPacketListener(this.dataListener, this.dataListener.getFilter()); + this.connection.addSyncStanzaListener(this.dataListener, this.dataListener.getFilter()); // register bytestream close packet listener this.closeListener = new CloseListener(this); @@ -542,7 +542,7 @@ public class InBandBytestreamManager implements BytestreamManager { // remove all listeners registered by this manager connection.unregisterIQRequestHandler(initiationListener); - this.connection.removeSyncPacketListener(this.dataListener); + this.connection.removeSyncStanzaListener(this.dataListener); connection.unregisterIQRequestHandler(closeListener); // shutdown threads diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java index 77f9ac148..e7a99d934 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java @@ -26,7 +26,7 @@ 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.StanzaFilter; import org.jivesoftware.smack.filter.StanzaTypeFilter; @@ -235,7 +235,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 dataQueue = new LinkedBlockingQueue(); @@ -264,7 +264,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()); } /** @@ -272,7 +272,7 @@ 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. @@ -431,7 +431,7 @@ public class InBandBytestreamSession implements BytestreamSession { * Invoked if the session is closed. */ private void cleanup() { - connection.removeSyncPacketListener(this.dataPacketListener); + connection.removeSyncStanzaListener(this.dataPacketListener); } } @@ -442,8 +442,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; @@ -505,8 +505,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 diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java index a5879ae4a..dcad233c4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java @@ -22,7 +22,7 @@ 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; @@ -311,7 +311,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 @@ -326,7 +326,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 @@ -336,7 +336,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; @@ -346,7 +346,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; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java index 392046b8b..08395c1a6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java @@ -24,7 +24,7 @@ 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; @@ -134,7 +134,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(); @@ -151,7 +151,7 @@ public class LastActivityManager extends Manager { } }, StanzaTypeFilter.PRESENCE); - connection.addPacketSendingListener(new PacketListener() { + connection.addPacketSendingListener(new StanzaListener() { @Override public void processPacket(Stanza packet) { Message message = (Message) packet; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index 7f79ec6d0..cbe2ee8a0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -31,7 +31,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; @@ -115,11 +115,11 @@ public class MultiUserChat { */ 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 String nickname = null; @@ -134,7 +134,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; @@ -145,7 +145,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; // Update the room subject @@ -158,7 +158,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; String from = presence.getFrom(); @@ -224,7 +224,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); @@ -237,7 +237,7 @@ public class MultiUserChat { } }; - presenceInterceptor = new PacketListener() { + presenceInterceptor = new StanzaListener() { @Override public void processPacket(Stanza packet) { Presence presence = (Presence) packet; @@ -295,12 +295,12 @@ public class MultiUserChat { + nickname), 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, + connection.addSyncStanzaListener(messageListener, fromRoomGroupchatFilter); + connection.addSyncStanzaListener(presenceListener, new AndFilter(fromRoomFilter, StanzaTypeFilter.PRESENCE)); - connection.addSyncPacketListener(subjectListener, new AndFilter(fromRoomFilter, + connection.addSyncStanzaListener(subjectListener, new AndFilter(fromRoomFilter, MessageWithSubjectFilter.INSTANCE)); - connection.addSyncPacketListener(declinesListener, new AndFilter(new StanzaExtensionFilter(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), StanzaTypeFilter.PRESENCE)); @@ -754,7 +754,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. * @@ -765,13 +765,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); } @@ -1724,9 +1724,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(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java index ea46e4ce5..0be189da4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java @@ -29,7 +29,7 @@ import java.util.concurrent.CopyOnWriteArraySet; 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; @@ -117,7 +117,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 @@ -133,7 +133,7 @@ public class MultiUserChatManager extends Manager { } } }; - connection.addAsyncPacketListener(invitationPacketListener, INVITATION_FILTER); + connection.addAsyncStanzaListener(invitationPacketListener, INVITATION_FILTER); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java index eb2083737..0d0e7035b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java @@ -20,7 +20,7 @@ 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.StanzaExtensionFilter; @@ -65,7 +65,7 @@ public class PEPManager { private XMPPConnection connection; private StanzaFilter packetFilter = new StanzaExtensionFilter("event", "http://jabber.org/protocol/pubsub#event"); - private PacketListener packetListener; + private StanzaListener packetListener; /** * Creates a new PEP exchange manager. @@ -134,7 +134,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"); @@ -142,12 +142,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 { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java index 391523e1a..c9ea3c19a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java @@ -29,7 +29,7 @@ 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; @@ -123,7 +123,7 @@ 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(); @@ -131,7 +131,7 @@ public class PrivacyListManager extends Manager { 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,7 +145,7 @@ 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(); @@ -153,7 +153,7 @@ public class PrivacyListManager extends Manager { 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; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java index 088f11c65..597f35d6a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java @@ -21,7 +21,7 @@ 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; @@ -50,9 +50,9 @@ abstract public class Node protected String id; protected String to; - protected ConcurrentHashMap, PacketListener> itemEventToListenerMap = new ConcurrentHashMap, PacketListener>(); - protected ConcurrentHashMap itemDeleteToListenerMap = new ConcurrentHashMap(); - protected ConcurrentHashMap configEventToListenerMap = new ConcurrentHashMap(); + protected ConcurrentHashMap, StanzaListener> itemEventToListenerMap = new ConcurrentHashMap, StanzaListener>(); + protected ConcurrentHashMap itemDeleteToListenerMap = new ConcurrentHashMap(); + protected ConcurrentHashMap configEventToListenerMap = new ConcurrentHashMap(); /** * Construct a node associated to the supplied connection with the specified @@ -397,9 +397,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")); } /** @@ -409,10 +409,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); } /** @@ -423,9 +423,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())); } /** @@ -435,10 +435,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); } /** @@ -449,12 +449,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)); } /** @@ -464,10 +464,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 @@ -515,7 +515,7 @@ abstract public class Node * * @author Robin Collier */ - public class ItemEventTranslator implements PacketListener + public class ItemEventTranslator implements StanzaListener { @SuppressWarnings("rawtypes") private ItemEventListener listener; @@ -541,7 +541,7 @@ abstract public class Node * * @author Robin Collier */ - public class ItemDeleteTranslator implements PacketListener + public class ItemDeleteTranslator implements StanzaListener { private ItemDeleteListener listener; @@ -584,7 +584,7 @@ abstract public class Node * * @author Robin Collier */ - public class NodeConfigTranslator implements PacketListener + public class NodeConfigTranslator implements StanzaListener { private NodeConfigListener listener; @@ -603,7 +603,7 @@ 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 diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java index 2e6e5cfa0..2a6840e3f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java @@ -26,7 +26,7 @@ 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; import org.jivesoftware.smack.filter.AndFilter; @@ -127,7 +127,7 @@ public class DeliveryReceiptManager extends Manager { sdm.addFeature(DeliveryReceipt.NAMESPACE); // Add the packet listener to handling incoming delivery receipts - connection.addAsyncPacketListener(new PacketListener() { + connection.addAsyncStanzaListener(new StanzaListener() { @Override public void processPacket(Stanza packet) throws NotConnectedException { DeliveryReceipt dr = DeliveryReceipt.from(packet); @@ -139,7 +139,7 @@ public class DeliveryReceiptManager extends Manager { }, MESSAGES_WITH_DELIVERY_RECEIPT); // Add the packet listener to handle incoming delivery receipt requests - connection.addAsyncPacketListener(new PacketListener() { + connection.addAsyncStanzaListener(new StanzaListener() { @Override public void processPacket(Stanza packet) throws NotConnectedException { final String from = packet.getFrom(); @@ -232,7 +232,7 @@ public class DeliveryReceiptManager extends Manager { receiptReceivedListeners.remove(listener); } - private static final PacketListener AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER = new PacketListener() { + private static final StanzaListener AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER = new StanzaListener() { @Override public void processPacket(Stanza packet) throws NotConnectedException { Message message = (Message) packet; diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionMessageTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionMessageTest.java index 094e60787..b2ea702ac 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionMessageTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionMessageTest.java @@ -25,7 +25,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Random; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException; @@ -260,7 +260,7 @@ public class InBandBytestreamSessionMessageTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // build invalid packet with out of order sequence String base64Data = Base64.encode("Data"); @@ -300,7 +300,7 @@ public class InBandBytestreamSessionMessageTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // verify data packet and notify listener for (int i = 0; i < controlData.length / blockSize; i++) { @@ -345,7 +345,7 @@ public class InBandBytestreamSessionMessageTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // verify data packet and notify listener for (int i = 0; i < controlData.length / blockSize; i++) { diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionTest.java index a946c5175..1f59b1418 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionTest.java @@ -27,7 +27,7 @@ import java.util.Random; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.XMPPError; @@ -307,7 +307,7 @@ public class InBandBytestreamSessionTest { // insert data to read InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); String base64Data = Base64.encode("Data"); DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data); Data data = new Data(dpe); @@ -341,7 +341,7 @@ public class InBandBytestreamSessionTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); String base64Data = Base64.encode("Data"); DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data); @@ -378,7 +378,7 @@ public class InBandBytestreamSessionTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // build data packets String base64Data = Base64.encode("Data"); @@ -416,7 +416,7 @@ public class InBandBytestreamSessionTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // build data packets DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, "AA=BB"); @@ -450,7 +450,7 @@ public class InBandBytestreamSessionTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // build invalid packet with out of order sequence String base64Data = Base64.encode("Data"); @@ -491,7 +491,7 @@ public class InBandBytestreamSessionTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // set data packet acknowledgment and notify listener for (int i = 0; i < controlData.length / blockSize; i++) { @@ -538,7 +538,7 @@ public class InBandBytestreamSessionTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // set data packet acknowledgment and notify listener for (int i = 0; i < controlData.length / blockSize; i++) { @@ -579,7 +579,7 @@ public class InBandBytestreamSessionTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // build data packet String base64Data = Base64.encode("Data"); @@ -622,7 +622,7 @@ public class InBandBytestreamSessionTest { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); final InputStream inputStream = session.getInputStream(); - PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); + StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); // build data packet String base64Data = Base64.encode("Data"); diff --git a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java index 72e826587..b34fafa64 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java @@ -28,7 +28,7 @@ import java.util.concurrent.CopyOnWriteArraySet; import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.MessageListener; import org.jivesoftware.smack.PacketCollector; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.filter.AndFilter; @@ -142,7 +142,7 @@ public class ChatManager extends Manager{ // Add a listener for all message packets so that we can deliver // messages to the best Chat instance available. - connection.addSyncPacketListener(new PacketListener() { + connection.addSyncStanzaListener(new StanzaListener() { public void processPacket(Stanza packet) { Message message = (Message) packet; Chat chat; diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java index afbf43250..6de3f540f 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java @@ -38,7 +38,7 @@ import org.jivesoftware.smack.AbstractConnectionClosedListener; import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ExceptionCallback; import org.jivesoftware.smack.Manager; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.SmackException.NoResponseException; @@ -195,7 +195,7 @@ public class Roster extends Manager { // Listen for any roster packets. connection.registerIQRequestHandler(new RosterPushListener()); // Listen for any presence packets. - connection.addSyncPacketListener(presencePacketListener, PRESENCE_PACKET_FILTER); + connection.addSyncStanzaListener(presencePacketListener, PRESENCE_PACKET_FILTER); // Listen for connection events connection.addConnectionListener(new AbstractConnectionClosedListener() { @@ -1159,7 +1159,7 @@ public class Roster extends Manager { /** * Listens for all presence packets and processes them. */ - private class PresencePacketListener implements PacketListener { + private class PresencePacketListener implements StanzaListener { /** * Retrieve the user presences (a map from resource to {@link Presence}) for a given key (usually a JID without @@ -1282,7 +1282,7 @@ public class Roster extends Manager { /** * Handles roster reults as described in RFC 6121 2.1.4 */ - private class RosterResultListener implements PacketListener { + private class RosterResultListener implements StanzaListener { @Override public void processPacket(Stanza packet) { diff --git a/smack-im/src/test/java/org/jivesoftware/smack/chat/ChatConnectionTest.java b/smack-im/src/test/java/org/jivesoftware/smack/chat/ChatConnectionTest.java index 10e139f17..4367050c4 100644 --- a/smack-im/src/test/java/org/jivesoftware/smack/chat/ChatConnectionTest.java +++ b/smack-im/src/test/java/org/jivesoftware/smack/chat/ChatConnectionTest.java @@ -51,7 +51,7 @@ public class ChatConnectionTest { listener = new TestChatManagerListener(); cm.addChatListener(listener); waitListener = new WaitForPacketListener(); - dc.addSyncPacketListener(waitListener, null); + dc.addSyncStanzaListener(waitListener, null); } @After diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java index 8242eac9f..ac8b65fbf 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.logging.Logger; import org.jivesoftware.smack.ConnectionCreationListener; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnectionRegistry; @@ -462,7 +462,7 @@ public class JingleManager implements JingleSessionListener { jingleSessionRequestListeners = new ArrayList(); // Start a packet listener for session initiation requests - connection.addAsyncPacketListener(new PacketListener() { + connection.addAsyncStanzaListener(new StanzaListener() { public void processPacket(Stanza packet) { triggerSessionRequested((Jingle) packet); } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java index 5dd80e2fa..51a330bbd 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java @@ -25,7 +25,7 @@ import java.util.logging.Logger; import org.jivesoftware.smack.AbstractConnectionClosedListener; import org.jivesoftware.smack.ConnectionListener; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; @@ -77,7 +77,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList ConnectionListener connectionListener; - PacketListener packetListener; + StanzaListener packetListener; StanzaFilter packetFilter; @@ -651,7 +651,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList */ protected void removeAsyncPacketListener() { if (packetListener != null) { - getConnection().removeAsyncPacketListener(packetListener); + getConnection().removeAsyncStanzaListener(packetListener); LOGGER.fine("JINGLE SESSION: REMOVE PACKET LISTENER"); } @@ -666,7 +666,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList LOGGER.fine("UpdatePacketListener"); - packetListener = new PacketListener() { + packetListener = new StanzaListener() { public void processPacket(Stanza packet) { try { receivePacketAndRespond((IQ) packet); @@ -723,7 +723,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList } }; - getConnection().addAsyncPacketListener(packetListener, packetFilter); + getConnection().addAsyncStanzaListener(packetListener, packetFilter); } // Listeners diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java index 8363717e2..3b04023c0 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.workgroup.agent; import org.jivesoftware.smackx.workgroup.packet.AgentStatus; import org.jivesoftware.smackx.workgroup.packet.AgentStatusRequest; -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.StanzaFilter; @@ -74,9 +74,9 @@ public class AgentRoster { presenceMap = new HashMap>(); // Listen for any roster packets. StanzaFilter rosterFilter = new StanzaTypeFilter(AgentStatusRequest.class); - connection.addAsyncPacketListener(new AgentStatusListener(), rosterFilter); + connection.addAsyncStanzaListener(new AgentStatusListener(), rosterFilter); // Listen for any presence packets. - connection.addAsyncPacketListener(new PresencePacketListener(), + connection.addAsyncStanzaListener(new PresencePacketListener(), new StanzaTypeFilter(Presence.class)); // Send request for roster. @@ -281,7 +281,7 @@ public class AgentRoster { /** * Listens for all presence packets and processes them. */ - private class PresencePacketListener implements PacketListener { + private class PresencePacketListener implements StanzaListener { public void processPacket(Stanza packet) { Presence presence = (Presence)packet; String from = presence.getFrom(); @@ -356,7 +356,7 @@ public class AgentRoster { /** * Listens for all roster packets and processes them. */ - private class AgentStatusListener implements PacketListener { + private class AgentStatusListener implements StanzaListener { public void processPacket(Stanza packet) { if (packet instanceof AgentStatusRequest) { diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java index 96d04357d..baf424c32 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java @@ -30,7 +30,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.PacketCollector; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; @@ -108,7 +108,7 @@ public class AgentSession { private TranscriptManager transcriptManager; private TranscriptSearchManager transcriptSearchManager; private Agent agent; - private PacketListener packetListener; + private StanzaListener packetListener; /** * Constructs a new agent session instance. Note, the {@link #setOnline(boolean)} @@ -147,7 +147,7 @@ public class AgentSession { new StanzaTypeFilter(Presence.class), new StanzaTypeFilter(Message.class)); - packetListener = new PacketListener() { + packetListener = new StanzaListener() { public void processPacket(Stanza packet) { try { handlePacket(packet); @@ -157,7 +157,7 @@ public class AgentSession { } } }; - connection.addAsyncPacketListener(packetListener, filter); + connection.addAsyncStanzaListener(packetListener, filter); // Create the agent associated to this session agent = new Agent(connection, workgroupJID); } @@ -167,7 +167,7 @@ public class AgentSession { * packet listeners that were added by this agent session will be removed. */ public void close() { - connection.removeAsyncPacketListener(packetListener); + connection.removeAsyncStanzaListener(packetListener); } /** diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java index 05d5b1b71..30ce5fd91 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.Map; import org.jivesoftware.smack.PacketCollector; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; @@ -142,7 +142,7 @@ public class Workgroup { // Register a packet listener for all the messages sent to this client. StanzaFilter typeFilter = new StanzaTypeFilter(Message.class); - connection.addAsyncPacketListener(new PacketListener() { + connection.addAsyncStanzaListener(new StanzaListener() { public void processPacket(Stanza packet) { handlePacket(packet); } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java index 561ab508d..dbfda2b5b 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java @@ -26,7 +26,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.Manager; -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.AndFilter; @@ -75,7 +75,7 @@ public class MessageEventManager extends Manager { private MessageEventManager(XMPPConnection connection) { super(connection); // Listens for all message event packets and fire the proper message event listeners. - connection.addAsyncPacketListener(new PacketListener() { + connection.addAsyncStanzaListener(new StanzaListener() { public void processPacket(Stanza packet) { Message message = (Message) packet; MessageEvent messageEvent = diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java index 09ccadab1..a8988238e 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java @@ -24,7 +24,7 @@ import java.util.Map; import java.util.Set; import java.util.WeakHashMap; -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.StanzaExtensionFilter; @@ -57,7 +57,7 @@ public class RosterExchangeManager { private final Set rosterExchangeListeners = Collections.synchronizedSet(new HashSet()); private final WeakReference weakRefConnection; - private final PacketListener packetListener; + private final StanzaListener packetListener; public synchronized static RosterExchangeManager getInstanceFor(XMPPConnection connection) { RosterExchangeManager rosterExchangeManager = INSTANCES.get(connection); @@ -76,7 +76,7 @@ public class RosterExchangeManager { public RosterExchangeManager(XMPPConnection connection) { weakRefConnection = new WeakReference(connection); // 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; RosterExchange rosterExchange = @@ -85,7 +85,7 @@ public class RosterExchangeManager { fireRosterExchangeListeners(message.getFrom(), rosterExchange.getRosterEntries()); } }; - connection.addAsyncPacketListener(packetListener, PACKET_FILTER); + connection.addAsyncStanzaListener(packetListener, PACKET_FILTER); } /** diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 9380d9b44..c6bdf45f4 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -20,7 +20,7 @@ import org.jivesoftware.smack.AbstractXMPPConnection; import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; import org.jivesoftware.smack.ConnectionCreationListener; -import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.AlreadyConnectedException; @@ -264,13 +264,13 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * themselves after they have been invoked. *

*/ - private final Collection stanzaAcknowledgedListeners = new ConcurrentLinkedQueue(); + private final Collection stanzaAcknowledgedListeners = new ConcurrentLinkedQueue(); /** * This listeners are invoked for a acknowledged stanza that has the given stanza ID. They will * only be invoked once and automatically removed after that. */ - private final Map stanzaIdAcknowledgedListeners = new ConcurrentHashMap(); + private final Map stanzaIdAcknowledgedListeners = new ConcurrentHashMap(); /** * Predicates that determine if an stream management ack should be requested from the server. @@ -613,7 +613,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // If debugging is enabled, we should start the thread that will listen for // all packets and then log them. if (config.isDebuggerEnabled()) { - addAsyncPacketListener(debugger.getReaderListener(), null); + addAsyncStanzaListener(debugger.getReaderListener(), null); if (debugger.getWriterListener() != null) { addPacketSendingListener(debugger.getWriterListener(), null); } @@ -1556,13 +1556,13 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * Add a Stanza acknowledged listener. *

* Those listeners will be invoked every time a Stanza has been acknowledged by the server. The will not get - * automatically removed. Consider using {@link #addStanzaIdAcknowledgedListener(String, PacketListener)} when + * automatically removed. Consider using {@link #addStanzaIdAcknowledgedListener(String, StanzaListener)} when * possible. *

* * @param listener the listener to add. */ - public void addStanzaAcknowledgedListener(PacketListener listener) { + public void addStanzaAcknowledgedListener(StanzaListener listener) { stanzaAcknowledgedListeners.add(listener); } @@ -1572,7 +1572,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * @param listener the listener. * @return true if the listener was removed. */ - public boolean removeStanzaAcknowledgedListener(PacketListener listener) { + public boolean removeStanzaAcknowledgedListener(StanzaListener listener) { return stanzaAcknowledgedListeners.remove(listener); } @@ -1595,7 +1595,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * @return the previous listener for this stanza ID or null. * @throws StreamManagementNotEnabledException if Stream Management is not enabled. */ - public PacketListener addStanzaIdAcknowledgedListener(final String id, PacketListener listener) throws StreamManagementNotEnabledException { + public StanzaListener addStanzaIdAcknowledgedListener(final String id, StanzaListener listener) throws StreamManagementNotEnabledException { // Prevent users from adding callbacks that will never get removed if (!smWasEnabledAtLeastOnce) { throw new StreamManagementException.StreamManagementNotEnabledException(); @@ -1617,7 +1617,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * @param id the stanza ID. * @return true if the listener was found and removed, false otherwise. */ - public PacketListener removeStanzaIdAcknowledgedListener(String id) { + public StanzaListener removeStanzaIdAcknowledgedListener(String id) { return stanzaIdAcknowledgedListeners.remove(id); } @@ -1739,7 +1739,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { @Override public void run() { for (Stanza ackedStanza : ackedStanzas) { - for (PacketListener listener : stanzaAcknowledgedListeners) { + for (StanzaListener listener : stanzaAcknowledgedListeners) { try { listener.processPacket(ackedStanza); } @@ -1751,7 +1751,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { if (StringUtils.isNullOrEmpty(id)) { continue; } - PacketListener listener = stanzaIdAcknowledgedListeners.remove(id); + StanzaListener listener = stanzaIdAcknowledgedListeners.remove(id); if (listener != null) { try { listener.processPacket(ackedStanza); From caa7b9acb8d9266b894348548ef6e9074b63ff18 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 28 Feb 2015 10:16:32 +0100 Subject: [PATCH 19/30] Improve message of StreamErrorException --- .../src/main/java/org/jivesoftware/smack/XMPPException.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/XMPPException.java b/smack-core/src/main/java/org/jivesoftware/smack/XMPPException.java index 774ca76ad..7f40ae771 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/XMPPException.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/XMPPException.java @@ -152,7 +152,9 @@ public abstract class XMPPException extends Exception { * @param streamError the root cause of the exception. */ public StreamErrorException(StreamError streamError) { - super(streamError.toString()); + super(streamError.getCondition().toString() + + " You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions\n" + + streamError.toString()); this.streamError = streamError; } From 21c0be5e2a532478fe3f418de17bb07d30a8e394 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 27 Feb 2015 23:38:13 +0100 Subject: [PATCH 20/30] Fixed AbstractXMPPConnection.cachedExecutorService the combination with concurrencyLevel and LinkedBlockingQueue never worked as intented. The idea was that the cachedExecutorService would spawn new threads until maximumPoolSize (=concurrencyLevel) is reached, and then start queing the Runnables. But this was not the case, since ThreadPoolExecutor does not take into consideration if the worker threads is busy, i.e. executing a Runnable, or idle, i.e. waiting for a Runnable. This means that if a busy Worker would execute a Runnable, which would block, because it's waiting for an event (e.g. an incoming IQ request), then the handling of those incoming IQ request would be queued by ThreadPoolExecutor, because no fewer threads then corePoolSize are running and the task can be queued (since the LinkedBlockingQueue is unbounded). --- .../smack/AbstractXMPPConnection.java | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 35a64043e..bf47eaf0d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -32,7 +32,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ThreadPoolExecutor; @@ -247,46 +246,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { private final ScheduledExecutorService removeCallbacksService = Executors.newSingleThreadScheduledExecutor( new SmackExecutorThreadFactory(connectionCounterValue, "Remove Callbacks")); - private static int concurrencyLevel = Runtime.getRuntime().availableProcessors() + 1; - /** - * Set the concurrency level used by newly created connections. - *

- * The concurrency level determines the maximum pool size of the executor service that is used to e.g. invoke - * callbacks and IQ request handlers. - *

- *

- * The default value is Runtime.getRuntime().availableProcessors() + 1. Note that the number of - * available processors may change at runtime. So you may need to adjust it to your enviornment, although in most - * cases this should not be necessary. - *

- * - * @param concurrencyLevel the concurrency level used by new connections. - */ - public static void setConcurrencyLevel(int concurrencyLevel) { - if (concurrencyLevel < 1) { - throw new IllegalArgumentException("concurrencyLevel must be greater than zero"); - } - AbstractXMPPConnection.concurrencyLevel = concurrencyLevel; - } - - /** - * The constant long '120'. - */ - private static final long THREAD_KEEP_ALIVE_SECONDS = 60L * 2; - - /** - * Creates an executor service just as {@link Executors#newCachedThreadPool()} would do, but with a keep alive time - * of 2 minutes instead of 60 seconds. And a custom thread factory to set meaningful names on the threads and set + * A cached thread pool executor service with custom thread factory to set meaningful names on the threads and set * them 'daemon'. */ - private final ExecutorService cachedExecutorService = new ThreadPoolExecutor( + private final ExecutorService cachedExecutorService = Executors.newCachedThreadPool( // @formatter:off - 0, // corePoolSize - concurrencyLevel, // maximumPoolSize - THREAD_KEEP_ALIVE_SECONDS, // keepAliveTime - TimeUnit.SECONDS, // keepAliveTime unit, note that MINUTES is Android API 9 - new LinkedBlockingQueue(), // workQueue new SmackExecutorThreadFactory( // threadFactory connectionCounterValue, "Cached Executor" From dde0cfd7f6f6b9e8c9fade51fa2d9a80ed242caa Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 27 Feb 2015 10:02:48 +0100 Subject: [PATCH 21/30] Fix incoming file transfers With bb8dcc9874641ec1f833ba6f33ccab8a86f91fa8 the concept if IQ request handlers was introduced in Smack. This doesn't allow packet/stanza collectors/listeners to filter for incoming IQ requests. Unfortunately the file transfer code relied on this being able, so it broke with the change. There were two places where the file transfer code was listening for incoming IQ requests: - InitationListener(s) - Negotiator(s) With this change, we let the InitiationListener signal the existence of an incoming initation request, send by an IQ of type 'set', using the newly created EventManager utility. The negotiator waits for those events to arrive and proceedes as it would have done when the packet collector was used. --- .../jivesoftware/smack/util/EventManger.java | 97 ++++++++++++++ .../bytestreams/ibb/InitiationListener.java | 3 + .../socks5/InitiationListener.java | 3 + .../filetransfer/FaultTolerantNegotiator.java | 118 ++++-------------- .../filetransfer/IBBTransferNegotiator.java | 31 +---- .../Socks5TransferNegotiator.java | 29 +---- .../smackx/filetransfer/StreamNegotiator.java | 57 ++++++--- 7 files changed, 171 insertions(+), 167 deletions(-) create mode 100644 smack-core/src/main/java/org/jivesoftware/smack/util/EventManger.java diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/EventManger.java b/smack-core/src/main/java/org/jivesoftware/smack/util/EventManger.java new file mode 100644 index 000000000..69ca3d6eb --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/EventManger.java @@ -0,0 +1,97 @@ +/** + * + * Copyright 2015 Florian Schmaus + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.smack.util; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * The event manager class is used to perform actions and wait for an event, which is usually caused by the action (or maybe never occurs). + *

+ * Events are distinguished by an unique event key. They can produce an event result, which can simply be null. + *

+ *

+ * The action is able to throw an exception. + *

+ * + * @param the event key. + * @param the event result. + * @param the exception which could be thrown by the action. + */ +public class EventManger { + + private final Map> events = new ConcurrentHashMap<>(); + + /** + * Perform an action and wait for an event. + *

+ * The event is signaled with {@link #signalEvent(Object, Object)}. + *

+ * + * @param eventKey the event key, must not be null. + * @param timeout the timeout to wait for the event in milliseconds. + * @param action the action to perform prior waiting for the event, must not be null. + * @return the event value, may be null. + * @throws InterruptedException if interrupted while waiting for the event. + * @throws E + */ + public R performActionAndWaitForEvent(K eventKey, long timeout, Callback action) throws InterruptedException, E { + final Reference reference = new Reference<>(); + events.put(eventKey, reference); + try { + synchronized (reference) { + action.action(); + reference.wait(timeout); + } + return reference.eventResult; + } + finally { + events.remove(eventKey); + } + } + + /** + * Signal an event and the event result. + *

+ * This method will return false if the event was not created with + * {@link #performActionAndWaitForEvent(Object, long, Callback)}. + *

+ * + * @param eventKey the event key, must not be null. + * @param eventResult the event result, may be null. + * @return true if the event was found and signaled, false otherwise. + */ + public boolean signalEvent(K eventKey, R eventResult) { + final Reference reference = events.get(eventKey); + if (reference == null) { + return false; + } + reference.eventResult = eventResult; + synchronized(reference) { + reference.notifyAll(); + } + return true; + } + + private static class Reference { + volatile V eventResult; + } + + public interface Callback { + public void action() throws E; + } +} diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InitiationListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InitiationListener.java index fc0dd2264..5aca64342 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InitiationListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InitiationListener.java @@ -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() + '\t' + ibbRequest.getSessionID(), ibbRequest); + // ignore request if in ignore list if (this.manager.getIgnoredBytestreamRequests().remove(ibbRequest.getSessionID())) return; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListener.java index 27c8a5c11..4b3608ae6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListener.java @@ -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 { Bytestream byteStreamRequest = (Bytestream) packet; + StreamNegotiator.signal(byteStreamRequest.getFrom() + '\t' + byteStreamRequest.getSessionID(), byteStreamRequest); + // ignore request if in ignore list if (this.manager.getIgnoredBytestreamRequests().remove(byteStreamRequest.getSessionID())) { return; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java index cd957db1d..d3c47ef47 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java @@ -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.StanzaFilter; +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; @@ -51,8 +40,6 @@ public class FaultTolerantNegotiator extends StreamNegotiator { private final StreamNegotiator primaryNegotiator; private final StreamNegotiator secondaryNegotiator; private final XMPPConnection connection; - private StanzaFilter primaryFilter; - private StanzaFilter secondaryFilter; public FaultTolerantNegotiator(XMPPConnection connection, StreamNegotiator primary, StreamNegotiator secondary) { @@ -61,12 +48,10 @@ public class FaultTolerantNegotiator extends StreamNegotiator { this.connection = connection; } - public StanzaFilter getInitiationPacketFilter(String 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(String from, String streamID) { + primaryNegotiator.newStreamInitiation(from, streamID); + secondaryNegotiator.newStreamInitiation(from, streamID); } InputStream negotiateIncomingStream(Stanza streamInitiation) { @@ -74,73 +59,28 @@ 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 { + // 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 { - PacketCollector collector = connection.createPacketCollectorAndSend( - getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()), - super.createInitiationAccept(initiation, getNamespaces())); - - ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(2); - CompletionService service - = new ExecutorCompletionService(threadPoolExecutor); - List> futures = new ArrayList>(); - InputStream stream = null; - SmackException exception = null; + StreamNegotiator streamNegotiator = determineNegotiator(initationSet); 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 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()); - } - } + return streamNegotiator.negotiateIncomingStream(initationSet); } - finally { - for (Future future : futures) { - future.cancel(true); - } - collector.cancel(); - threadPoolExecutor.shutdownNow(); + catch (InterruptedException e) { + // TODO remove this try/catch once merged into 4.2's master branch + throw new IllegalStateException(e); } - if (stream == null) { - if (exception != null) { - throw exception; - } - else { - throw new SmackException("File transfer negotiation failed."); - } - } - - return stream; } 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, String initiator, String target) @@ -167,18 +107,4 @@ public class FaultTolerantNegotiator extends StreamNegotiator { return namespaces; } - private class NegotiatorService implements Callable { - - 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); - } - } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java index c2895b2f5..d0c1b681d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java @@ -23,13 +23,7 @@ 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.FlexibleStanzaTypeFilter; -import org.jivesoftware.smack.filter.FromMatchesFilter; -import org.jivesoftware.smack.filter.StanzaFilter; -import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Stanza; -import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager; import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest; import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession; @@ -82,15 +76,14 @@ public class IBBTransferNegotiator extends StreamNegotiator { return negotiateIncomingStream(streamInitiation); } - public StanzaFilter getInitiationPacketFilter(String from, String streamID) { + @Override + public void newStreamInitiation(String 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,26 +101,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 FlexibleStanzaTypeFilter { - - private final String sessionID; - - public IBBOpenSidFilter(String sessionID) { - this.sessionID = Objects.requireNonNull(sessionID, "sessionID must not be null"); - } - - @Override - protected boolean acceptSpecific(Open bytestream) { - // packet must by of type SET and contains the given session ID - return this.sessionID.equals(bytestream.getSessionID()) - && IQ.Type.set.equals(bytestream.getType()); - } - } - /** * Derive from InBandBytestreamRequest to access protected constructor. */ diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java index 0cc7aa400..ef539b883 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java @@ -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.FlexibleStanzaTypeFilter; -import org.jivesoftware.smack.filter.FromMatchesFilter; -import org.jivesoftware.smack.filter.StanzaFilter; -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; @@ -85,15 +79,13 @@ public class Socks5TransferNegotiator extends StreamNegotiator { } @Override - public StanzaFilter getInitiationPacketFilter(final String from, String streamID) { + public void newStreamInitiation(String 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 @@ -123,25 +115,6 @@ public class Socks5TransferNegotiator extends StreamNegotiator { } } - /** - * This PacketFilter accepts an incoming SOCKS5 Bytestream request with a specified session ID. - */ - private static class BytestreamSIDFilter extends FlexibleStanzaTypeFilter { - - private final String sessionID; - - public BytestreamSIDFilter(String sessionID) { - this.sessionID = Objects.requireNonNull(sessionID, "SessionID cannot be null"); - } - - @Override - protected boolean acceptSpecific(Bytestream bytestream) { - // packet must by of type SET and contains the given session ID - return this.sessionID.equals(bytestream.getSessionID()) - && IQ.Type.set.equals(bytestream.getType()); - } - } - /** * Derive from Socks5BytestreamRequest to access protected constructor. */ diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java index 0fff1304c..5b42ca15a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java @@ -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.StanzaFilter; 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; @@ -43,6 +43,19 @@ import java.io.OutputStream; */ public abstract class StreamNegotiator { + /** + * A event manager for stream initiation requests send to us. + *

+ * Those are typical XEP-45 Open or XEP-65 Bytestream IQ requests. The even key is in the format + * "initiationFrom + '\t' + streamId" + *

+ */ + // 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 initationSetEvents = new EventManger<>(); + /** * Creates the initiation acceptance packet to forward to the stream * initiator. @@ -51,7 +64,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(); @@ -72,29 +85,42 @@ public abstract class StreamNegotiator { return response; } - Stanza initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException, NotConnectedException { - StreamInitiation response = createInitiationAccept(initiation, + protected final IQ initiateIncomingStream(final XMPPConnection connection, StreamInitiation initiation) + throws NoResponseException, XMPPErrorException, NotConnectedException { + 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() { + @Override + public void action() throws NotConnectedException { + connection.sendPacket(response); + } + }); + } + 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 PacketFilter that will return the packet relatable to the stream - * initiation. */ - public abstract StanzaFilter getInitiationPacketFilter(String from, String streamID); + protected abstract void newStreamInitiation(String from, String streamID); abstract InputStream negotiateIncomingStream(Stanza streamInitiation) throws XMPPErrorException, @@ -147,4 +173,7 @@ public abstract class StreamNegotiator { */ public abstract String[] getNamespaces(); + public static void signal(String eventKey, IQ eventValue) { + initationSetEvents.signalEvent(eventKey, eventValue); + } } From 96bb37f9245b89e6ea69b370a9dafd3d11e8f774 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 2 Mar 2015 15:12:19 +0100 Subject: [PATCH 22/30] Fix counting bug Stream Management implementation Previously Smack would put messages in the unacknowledgedStanzas queue after it received the 'enabled' element, when it should do so right after sending the 'enable' stream element. Imagine a session where '-->' denotes "received from server" and '<--' "sent to server" <-- enable --> iq roster push set --> presence some presence <-- iq roster push result --> enabled then Smack would not add the iq roster push result stanza to the unacknowledgedStanzas queue. This fixes the issue by initializing the unacknowledgedStanzas queue when the writer thread encounters a 'Enable' stream element. The additional 'instanceof' invocation in the writer thread should not be a big performance issue, since the existing "instanceof Stanza" check should be the common case and the "instanceof Enable" is an exclusive alternative to this case. --- .../jivesoftware/smack/tcp/XMPPTCPConnection.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index c6bdf45f4..fac6ecdc6 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -397,10 +397,15 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // There was a previous connection with SM enabled but that was either not resumable or // failed to resume. Make sure that we (re-)send the unacknowledged stanzas. unacknowledgedStanzas.drainTo(previouslyUnackedStanzas); + // Reset unacknowledged stanzas to 'null' to signal that we never send 'enable' in this + // XMPP session (There maybe was an enabled in a previous XMPP session of this + // connection instance though). This is used in writePackets to decide if stanzas should + // be added to the unacknowledged stanzas queue, because they have to be added right + // after the 'enable' stream element has been sent. + unacknowledgedStanzas = null; } if (isSmAvailable() && useSm) { // Remove what is maybe left from previously stream managed sessions - unacknowledgedStanzas = new ArrayBlockingQueue(QUEUE_SIZE); serverHandledStanzasCount = 0; // XEP-198 3. Enabling Stream Management. If the server response to 'Enable' is 'Failed' // then this is a non recoverable error and we therefore throw an exception. @@ -1330,11 +1335,17 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { if (element instanceof Stanza) { packet = (Stanza) element; } + else if (element instanceof Enable) { + // The client needs to add messages to the unacknowledged stanzas queue + // right after it sent 'enabled'. Stanza will be added once + // unacknowledgedStanzas is not null. + unacknowledgedStanzas = new ArrayBlockingQueue<>(QUEUE_SIZE); + } // Check if the stream element should be put to the unacknowledgedStanza // queue. Note that we can not do the put() in sendPacketInternal() and the // packet order is not stable at this point (sendPacketInternal() can be // called concurrently). - if (isSmEnabled() && packet != null) { + if (unacknowledgedStanzas != null && packet != null) { // If the unacknowledgedStanza queue is nearly full, request an new ack // from the server in order to drain it if (unacknowledgedStanzas.size() == 0.8 * XMPPTCPConnection.QUEUE_SIZE) { From 63fabf78ed082d3c3dde18847f100d960543b219 Mon Sep 17 00:00:00 2001 From: Anno van Vliet Date: Mon, 2 Mar 2015 14:46:42 +0100 Subject: [PATCH 23/30] Fixed Data IQ packet receiving Data packets where not received by the InBandByteStream due to a missing IQRequestHandler Conflicts: smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java --- .../smackx/bytestreams/ibb/DataListener.java | 26 ++++++++++++++++++- .../ibb/InBandBytestreamManager.java | 3 ++- .../ibb/InBandBytestreamSession.java | 8 ++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java index 432e02d1e..28fc0c1b2 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java @@ -21,8 +21,12 @@ import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaTypeFilter; +import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; +import org.jivesoftware.smack.iqrequest.IQRequestHandler; +import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Stanza; 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,7 +42,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Data; * * @author Henning Staib */ -class DataListener implements StanzaListener { +class DataListener extends AbstractIqRequestHandler implements StanzaListener, IQRequestHandler { /* manager containing the listeners and the XMPP connection */ private final InBandBytestreamManager manager; @@ -53,6 +57,7 @@ class DataListener implements StanzaListener { * @param manager the In-Band Bytestream manager */ public DataListener(InBandBytestreamManager manager) { + super(DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE, IQ.Type.set, Mode.async); this.manager = manager; } @@ -74,4 +79,23 @@ class DataListener implements StanzaListener { return this.dataFilter; } + @Override + public IQ handleIQRequest(IQ iqRequest) { + Data data = (Data) iqRequest; + InBandBytestreamSession ibbSession = this.manager.getSessions().get( + data.getDataPacketExtension().getSessionID()); + try { + if (ibbSession == null) { + this.manager.replyItemNotFoundPacket(data); + } + else { + ibbSession.processIQPacket(data); + } + } + catch (NotConnectedException e) { + return null; + } + return null; + } + } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java index 7fa27c46b..f3757ed14 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java @@ -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,6 +215,7 @@ public class InBandBytestreamManager implements BytestreamManager { // register bytestream data packet listener this.dataListener = new DataListener(this); this.connection.addSyncStanzaListener(this.dataListener, this.dataListener.getFilter()); + connection.registerIQRequestHandler(dataListener); // register bytestream close packet listener this.closeListener = new CloseListener(this); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java index e7a99d934..a82526ebd 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java @@ -814,4 +814,12 @@ public class InBandBytestreamSession implements BytestreamSession { } + /** + * @param data + * @throws NotConnectedException + */ + public void processIQPacket(Data data) throws NotConnectedException { + inputStream.dataPacketListener.processPacket(data); + } + } From 50cf7f42f3177a1a59f1417fb5f04e7d0f170bbc Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 2 Mar 2015 15:48:43 +0100 Subject: [PATCH 24/30] DataListener is no longer a StanzaListener it's just an IqRequestHandler. So remove the previous code related to it being a stanza listener. --- .../smackx/bytestreams/ibb/DataListener.java | 30 +------------------ .../ibb/InBandBytestreamManager.java | 3 +- .../bytestreams/ibb/DataListenerTest.java | 2 +- 3 files changed, 3 insertions(+), 32 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java index 28fc0c1b2..83406a6ad 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java @@ -16,15 +16,9 @@ */ package org.jivesoftware.smackx.bytestreams.ibb; -import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.SmackException.NotConnectedException; -import org.jivesoftware.smack.filter.AndFilter; -import org.jivesoftware.smack.filter.StanzaFilter; -import org.jivesoftware.smack.filter.StanzaTypeFilter; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; -import org.jivesoftware.smack.iqrequest.IQRequestHandler; import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smackx.bytestreams.ibb.packet.Data; import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension; @@ -42,15 +36,11 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension; * * @author Henning Staib */ -class DataListener extends AbstractIqRequestHandler implements StanzaListener, IQRequestHandler { +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 StanzaFilter dataFilter = new AndFilter( - new StanzaTypeFilter(Data.class)); - /** * Constructor. * @@ -61,24 +51,6 @@ class DataListener extends AbstractIqRequestHandler implements StanzaListener, I this.manager = manager; } - public void processPacket(Stanza packet) throws NotConnectedException { - Data data = (Data) packet; - InBandBytestreamSession ibbSession = this.manager.getSessions().get( - data.getDataPacketExtension().getSessionID()); - if (ibbSession == null) { - this.manager.replyItemNotFoundPacket(data); - } - } - - /** - * Returns the packet filter for In-Band Bytestream data packets. - * - * @return the packet filter for In-Band Bytestream data packets - */ - protected StanzaFilter getFilter() { - return this.dataFilter; - } - @Override public IQ handleIQRequest(IQ iqRequest) { Data data = (Data) iqRequest; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java index f3757ed14..bac9992de 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java @@ -214,7 +214,6 @@ public class InBandBytestreamManager implements BytestreamManager { // register bytestream data packet listener this.dataListener = new DataListener(this); - this.connection.addSyncStanzaListener(this.dataListener, this.dataListener.getFilter()); connection.registerIQRequestHandler(dataListener); // register bytestream close packet listener @@ -543,7 +542,7 @@ public class InBandBytestreamManager implements BytestreamManager { // remove all listeners registered by this manager connection.unregisterIQRequestHandler(initiationListener); - this.connection.removeSyncStanzaListener(this.dataListener); + connection.unregisterIQRequestHandler(dataListener); connection.unregisterIQRequestHandler(closeListener); // shutdown threads diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/DataListenerTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/DataListenerTest.java index 29da9edd2..93d8e5209 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/DataListenerTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/DataListenerTest.java @@ -63,7 +63,7 @@ public class DataListenerTest { data.setFrom(initiatorJID); data.setTo(targetJID); - dataListener.processPacket(data); + dataListener.handleIQRequest(data); // wait because packet is processed in an extra thread Thread.sleep(200); From 0279677883016aa8e4cf8e8a052dc9e3bc48ee37 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 3 Mar 2015 14:06:21 +0100 Subject: [PATCH 25/30] Add support for clirr to the build system --- build.gradle | 14 +++++++++++++- version.gradle | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0fd69f2e0..78cb47e0e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,7 @@ buildscript { } dependencies { classpath 'org.kordamp:markdown-gradle-plugin:0.1.1' + classpath 'org.kordamp.gradle:clirr-gradle-plugin:0.1.0' } } apply plugin: 'org.kordamp.gradle.markdown' @@ -95,7 +96,6 @@ allprojects { options.addStringOption('Xdoclint:none', '-quiet') } } - } gradle.taskGraph.whenReady { taskGraph -> @@ -181,6 +181,7 @@ subprojects { apply plugin: 'osgi' apply plugin: 'signing' apply plugin: 'checkstyle' + apply plugin: 'org.kordamp.gradle.clirr' checkstyle { configFile = new File(rootConfigDir, 'checkstyle.xml') @@ -280,6 +281,11 @@ subprojects { required { signingRequired } sign configurations.archives } + + clirr { + baseline = [group, name, clirrBaseline].join(':') + failOnErrors clirrFailOnErrors + } } subprojects*.jar { @@ -288,6 +294,12 @@ subprojects*.jar { } } +// Important to specify this task after the subprojects block +task clirrRootReport(type: org.kordamp.gradle.clirr.ClirrReportTask) { + dependsOn = subprojects.tasks.clirr + reports = files(subprojects.tasks.clirr.xmlReport) +} + def getGitCommit() { def dotGit = new File("$projectDir/.git") if (!dotGit.isDirectory()) return 'non-git build' diff --git a/version.gradle b/version.gradle index c6e700712..444bcf108 100644 --- a/version.gradle +++ b/version.gradle @@ -4,5 +4,10 @@ allprojects { isSnapshot = true jxmppVersion = '0.4.2-beta1' smackMinAndroidSdk = 8 + + // The baseline version to check the API's binary + // compatibility against with Clirr. + clirrBaseline = '4.1.0-rc2' + clirrFailOnErrors = false } } From 85a9b07230c6016fd331553fca2e4f95084ff0ab Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 3 Mar 2015 17:05:42 +0100 Subject: [PATCH 26/30] Fix MUC participantStatusListeners Thanks to Anno van Vliet for reporting the issue and proposing the fix. --- .../org/jivesoftware/smackx/muc/MultiUserChat.java | 2 +- .../org/jivesoftware/smackx/muc/packet/MUCUser.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index cbe2ee8a0..b85bc6d68 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -197,7 +197,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(), diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCUser.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCUser.java index 88cbd0ce0..4e68f4b84 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCUser.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCUser.java @@ -118,6 +118,19 @@ public class MUCUser implements ExtensionElement { return statusCodes; } + /** + * Returns true if this MUCUser instance has also {@link Status} information. + *

+ * If true is returned, then {@link #getStatus()} will return a non-empty set. + *

+ * + * @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 From 18d9be00995a42e68492d64d2d6b67ef1dfc7c3a Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 4 Mar 2015 13:08:35 +0100 Subject: [PATCH 27/30] Add CapsExtensionProviderTest --- .../smack/test/util/TestUtils.java | 23 ++++++++++ .../provider/CapsExtensionProviderTest.java | 44 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 smack-extensions/src/test/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProviderTest.java diff --git a/smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java b/smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java index 4da7b1f05..c1c03bf00 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java @@ -20,7 +20,10 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; +import org.jivesoftware.smack.SmackException; +import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.PacketParserUtils; +import org.jivesoftware.smack.util.ParserUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -40,6 +43,10 @@ final public class TestUtils { return getParser(stanza, "presence"); } + public static XmlPullParser getParser(String string) { + return getParser(string, null); + } + public static XmlPullParser getParser(String string, String startTag) { return getParser(new StringReader(string), startTag); } @@ -49,6 +56,9 @@ final public class TestUtils { try { parser = PacketParserUtils.newXmppParser(reader); if (startTag == null) { + while (parser.getEventType() != XmlPullParser.START_TAG) { + parser.next(); + } return parser; } boolean found = false; @@ -68,4 +78,17 @@ final public class TestUtils { return parser; } + public static EE parseExtensionElement(String elementString) + throws XmlPullParserException, IOException, SmackException { + return parseExtensionElement(getParser(elementString)); + } + + @SuppressWarnings("unchecked") + public static EE parseExtensionElement(XmlPullParser parser) + throws XmlPullParserException, IOException, SmackException { + ParserUtils.assertAtStartTag(parser); + final String elementName = parser.getName(); + final String namespace = parser.getNamespace(); + return (EE) PacketParserUtils.parseExtensionElement(elementName, namespace, parser); + } } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProviderTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProviderTest.java new file mode 100644 index 000000000..88e8afa98 --- /dev/null +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProviderTest.java @@ -0,0 +1,44 @@ +/** + * + * Copyright 2015 Florian Schmaus + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.smackx.caps.provider; + +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; +import org.jivesoftware.smack.test.util.TestUtils; +import org.jivesoftware.smackx.InitExtensions; +import org.jivesoftware.smackx.caps.packet.CapsExtension; +import org.junit.Test; +import org.xmlpull.v1.XmlPullParserException; + +public class CapsExtensionProviderTest extends InitExtensions { + + @Test + public void parseTest() throws XmlPullParserException, IOException, SmackException { + // @formatter:off + final String capsExtensionString = + ""; + // @formatter:on + CapsExtension capsExtension = TestUtils.parseExtensionElement(capsExtensionString); + assertNotNull(capsExtension); + } +} From b813e3aa9ebb9007d2770f7fdffb2c9393679fdd Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 4 Mar 2015 15:26:18 +0100 Subject: [PATCH 28/30] Return delivery receipts with the same type as the request Message delivery receipts now use the same message type as the corresponding message with the delivery receipt request. --- .../smackx/receipts/DeliveryReceiptManager.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java index 2a6840e3f..946696b1a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java @@ -156,8 +156,8 @@ public class DeliveryReceiptManager extends Manager { break; } - Message ack = new Message(from, Message.Type.normal); - ack.addExtension(new DeliveryReceipt(packet.getStanzaId())); + final Message messageWithReceiptRequest = (Message) packet; + Message ack = receiptMessageFor(messageWithReceiptRequest); connection.sendPacket(ack); } }, MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST); @@ -286,4 +286,17 @@ public class DeliveryReceiptManager extends Manager { public static String addDeliveryReceiptRequest(Message m) { return DeliveryReceiptRequest.addTo(m); } + + /** + * Create and return a new message including a delivery receipt extension for the given message. + * + * @param messageWithReceiptRequest the given message with a receipt request extension. + * @return a new message with a receipt. + * @since 4.1 + */ + public static Message receiptMessageFor(Message messageWithReceiptRequest) { + Message message = new Message(messageWithReceiptRequest.getFrom(), messageWithReceiptRequest.getType()); + message.addExtension(new DeliveryReceipt(messageWithReceiptRequest.getStanzaId())); + return message; + } } From 183af99ffbfae3d0eaf7631a5664d46426651555 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 4 Mar 2015 15:27:30 +0100 Subject: [PATCH 29/30] DeliveryReceipt helper methods take Message as argument Since it makes only sense for messages to have delivery receipts. --- .../smackx/receipts/DeliveryReceipt.java | 14 +++++++------- .../smackx/receipts/DeliveryReceiptManager.java | 2 +- .../smackx/receipts/DeliveryReceiptTest.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java index 6b239da84..87169dbe0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.receipts; import java.util.List; import java.util.Map; -import org.jivesoftware.smack.packet.Stanza; +import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.provider.EmbeddedExtensionProvider; import org.jivesoftware.smack.util.XmlStringBuilder; @@ -76,21 +76,21 @@ public class DeliveryReceipt implements ExtensionElement * * @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); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java index 946696b1a..3e0531ffc 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java @@ -130,7 +130,7 @@ public class DeliveryReceiptManager extends Manager { connection.addAsyncStanzaListener(new StanzaListener() { @Override public void processPacket(Stanza packet) throws NotConnectedException { - DeliveryReceipt dr = DeliveryReceipt.from(packet); + DeliveryReceipt dr = DeliveryReceipt.from((Message) packet); // notify listeners of incoming receipt for (ReceiptReceivedListener l : receiptReceivedListeners) { l.onReceiptReceived(packet.getFrom(), packet.getTo(), dr.getId(), packet); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/receipts/DeliveryReceiptTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/receipts/DeliveryReceiptTest.java index 7f30b9d5d..fe20e40c3 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/receipts/DeliveryReceiptTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/receipts/DeliveryReceiptTest.java @@ -115,7 +115,7 @@ public class DeliveryReceiptTest extends InitExtensions { c.processPacket(m); Stanza reply = c.getSentPacket(); - DeliveryReceipt r = DeliveryReceipt.from(reply); + DeliveryReceipt r = DeliveryReceipt.from((Message) reply); assertEquals("romeo@montague.com", reply.getTo()); assertEquals("test-receipt-request", r.getId()); } From ed4fa3390ff8e4d7ff19cd3a2b88f1fb95b05d98 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 4 Mar 2015 21:44:43 +0100 Subject: [PATCH 30/30] Add XMPPConnection.sendStanza(Stanza) and deprecate sendPacket(). --- documentation/gettingstarted.md | 2 +- .../smack/bosh/XMPPBOSHConnection.java | 4 +- .../java/org/jivesoftware/smack/IQTest.java | 4 +- .../org/jivesoftware/smack/MessageTest.java | 44 +++++++++---------- .../jivesoftware/smack/PacketReaderTest.java | 18 ++++---- .../org/jivesoftware/smack/PresenceTest.java | 18 ++++---- .../smack/AbstractXMPPConnection.java | 22 ++++++---- .../smack/SynchronizationPoint.java | 2 +- .../jivesoftware/smack/XMPPConnection.java | 10 +++++ .../jivesoftware/smack/DummyConnection.java | 10 ++--- .../smack/ThreadedDummyConnection.java | 6 +-- .../smackx/debugger/EnhancedDebugger.java | 2 +- .../jivesoftware/smackx/CompressionTest.java | 2 +- .../org/jivesoftware/smackx/FormTest.java | 2 +- .../smackx/GroupChatInvitationTest.java | 2 +- .../smackx/LastActivityManagerTest.java | 4 +- .../smackx/OfflineMessageManagerTest.java | 8 ++-- .../org/jivesoftware/smackx/VersionTest.java | 2 +- .../bytestreams/ibb/InBandBytestreamTest.java | 2 +- .../socks5/Socks5ByteStreamTest.java | 2 +- .../address/MultipleRecipientManager.java | 12 ++--- .../ibb/InBandBytestreamManager.java | 6 +-- .../ibb/InBandBytestreamRequest.java | 2 +- .../ibb/InBandBytestreamSession.java | 10 ++--- .../socks5/Socks5BytestreamManager.java | 2 +- .../socks5/Socks5BytestreamRequest.java | 4 +- .../smackx/caps/EntityCapsManager.java | 2 +- .../filetransfer/FileTransferManager.java | 2 +- .../filetransfer/FileTransferNegotiator.java | 4 +- .../smackx/filetransfer/StreamNegotiator.java | 2 +- .../smackx/muc/MultiUserChat.java | 12 ++--- .../smackx/muc/MultiUserChatManager.java | 2 +- .../muc/packet/GroupChatInvitation.java | 2 +- .../jivesoftware/smackx/pep/PEPManager.java | 2 +- .../jivesoftware/smackx/pubsub/LeafNode.java | 4 +- .../receipts/DeliveryReceiptManager.java | 4 +- .../bytestreams/ibb/CloseListenerTest.java | 2 +- .../bytestreams/ibb/DataListenerTest.java | 2 +- .../ibb/InBandBytestreamRequestTest.java | 4 +- .../ibb/InitiationListenerTest.java | 6 +-- .../socks5/InitiationListenerTest.java | 4 +- .../jivesoftware/util/ConnectionUtils.java | 4 +- .../java/org/jivesoftware/util/Protocol.java | 2 +- .../jivesoftware/smack/chat/ChatManager.java | 2 +- .../org/jivesoftware/smack/roster/Roster.java | 6 +-- .../smackx/jingle/JingleManagerTest.java | 2 +- .../smackx/jingle/JingleMediaTest.java | 2 +- .../jingle/provider/JingleProviderTest.java | 2 +- .../smackx/jingleold/JingleSession.java | 26 +++++------ .../jingleold/nat/TransportCandidate.java | 2 +- .../smackx/workgroup/agent/AgentRoster.java | 4 +- .../smackx/workgroup/agent/AgentSession.java | 8 ++-- .../smackx/workgroup/agent/Offer.java | 4 +- .../workgroup/agent/OfferConfirmation.java | 2 +- .../smackx/xevent/MessageEventManager.java | 8 ++-- .../smackx/xroster/RosterExchangeManager.java | 6 +-- .../smack/tcp/XMPPTCPConnection.java | 10 ++--- .../smack/tcp/PacketWriterTest.java | 4 +- 58 files changed, 183 insertions(+), 167 deletions(-) diff --git a/documentation/gettingstarted.md b/documentation/gettingstarted.md index d9ad4d84b..5913cc2f1 100644 --- a/documentation/gettingstarted.md +++ b/documentation/gettingstarted.md @@ -98,7 +98,7 @@ your presence to let people know you're unavailable and "out fishing": Presence presence = new Presence(Presence.Type.unavailable); presence.setStatus("Gone fishing"); // Send the packet (assume we have an XMPPConnection instance called "con"). -con.sendPacket(presence); +con.sendStanza(presence); ``` Smack provides two ways to read incoming packets: `PacketListener`, and diff --git a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java index 2022c938e..ded19e207 100644 --- a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java +++ b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java @@ -255,7 +255,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection { } @Override - protected void sendPacketInternal(Stanza packet) throws NotConnectedException { + protected void sendStanzaInternal(Stanza packet) throws NotConnectedException { sendElement(packet); } @@ -267,7 +267,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection { } } catch (BOSHException e) { - LOGGER.log(Level.SEVERE, "BOSHException in sendPacketInternal", e); + LOGGER.log(Level.SEVERE, "BOSHException in sendStanzaInternal", e); } } diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/IQTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/IQTest.java index 49184a875..29ae721c3 100644 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/IQTest.java +++ b/smack-core/src/integration-test/java/org/jivesoftware/smack/IQTest.java @@ -54,7 +54,7 @@ public class IQTest extends SmackTestCase { new StanzaTypeFilter(IQ.class)); PacketCollector collector = getConnection(0).createPacketCollector(filter); // Send the iq packet with an invalid namespace - getConnection(0).sendPacket(iq); + getConnection(0).sendStanza(iq); IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Stop queuing results @@ -85,7 +85,7 @@ public class IQTest extends SmackTestCase { PacketCollector collector = getConnection(0).createPacketCollector( new PacketIDFilter(versionRequest.getStanzaId())); - getConnection(0).sendPacket(versionRequest); + getConnection(0).sendStanza(versionRequest); // Wait up to 5 seconds for a result. IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/MessageTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/MessageTest.java index c9e77e17b..278e45198 100644 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/MessageTest.java +++ b/smack-core/src/integration-test/java/org/jivesoftware/smack/MessageTest.java @@ -42,11 +42,11 @@ public class MessageTest extends SmackTestCase { * message? */ public void testDirectPresence() { - getConnection(1).sendPacket(new Presence(Presence.Type.available)); + getConnection(1).sendStanza(new Presence(Presence.Type.available)); Presence presence = new Presence(Presence.Type.available); presence.setTo(getBareJID(1)); - getConnection(0).sendPacket(presence); + getConnection(0).sendStanza(presence); PacketCollector collector = getConnection(0) .createPacketCollector(new MessageTypeFilter(Message.Type.chat)); @@ -67,10 +67,10 @@ public class MessageTest extends SmackTestCase { * the client becomes available again the offline messages are received. */ public void testOfflineMessage() { - getConnection(0).sendPacket(new Presence(Presence.Type.available)); - getConnection(1).sendPacket(new Presence(Presence.Type.available)); + getConnection(0).sendStanza(new Presence(Presence.Type.available)); + getConnection(1).sendStanza(new Presence(Presence.Type.available)); // Make user2 unavailable - getConnection(1).sendPacket(new Presence(Presence.Type.unavailable)); + getConnection(1).sendStanza(new Presence(Presence.Type.unavailable)); try { Thread.sleep(500); @@ -86,7 +86,7 @@ public class MessageTest extends SmackTestCase { // User2 becomes available again - getConnection(1).sendPacket(new Presence(Presence.Type.available)); + getConnection(1).sendStanza(new Presence(Presence.Type.available)); // Check that offline messages are retrieved by user2 which is now available Message message = (Message) collector.nextResult(2500); @@ -112,7 +112,7 @@ public class MessageTest extends SmackTestCase { */ /*public void testOfflineMessageInvalidXML() { // Make user2 unavailable - getConnection(1).sendPacket(new Presence(Presence.Type.unavailable)); + getConnection(1).sendStanza(new Presence(Presence.Type.unavailable)); try { Thread.sleep(500); @@ -128,7 +128,7 @@ public class MessageTest extends SmackTestCase { // User2 becomes available again - getConnection(1).sendPacket(new Presence(Presence.Type.available)); + getConnection(1).sendStanza(new Presence(Presence.Type.available)); // Check that offline messages are retrieved by user2 which is now available Message message = (Message) collector.nextResult(2500); @@ -150,8 +150,8 @@ public class MessageTest extends SmackTestCase { * connections are not being closed. */ public void testHugeMessage() { - getConnection(0).sendPacket(new Presence(Presence.Type.available)); - getConnection(1).sendPacket(new Presence(Presence.Type.available)); + getConnection(0).sendStanza(new Presence(Presence.Type.available)); + getConnection(1).sendStanza(new Presence(Presence.Type.available)); // User2 becomes available again PacketCollector collector = getConnection(1).createPacketCollector( new MessageTypeFilter(Message.Type.chat)); @@ -165,7 +165,7 @@ public class MessageTest extends SmackTestCase { msg.setBody(sb.toString()); // Send the first message - getConnection(0).sendPacket(msg); + getConnection(0).sendStanza(msg); // Check that the connection that sent the message is still connected assertTrue("XMPPConnection was closed", getConnection(0).isConnected()); // Check that the message was received @@ -173,7 +173,7 @@ public class MessageTest extends SmackTestCase { assertNotNull("No Message was received", rcv); // Send the second message - getConnection(0).sendPacket(msg); + getConnection(0).sendStanza(msg); // Check that the connection that sent the message is still connected assertTrue("XMPPConnection was closed", getConnection(0).isConnected()); // Check that the second message was received @@ -200,11 +200,11 @@ public class MessageTest extends SmackTestCase { // Set this connection as highest priority Presence presence = new Presence(Presence.Type.available); presence.setPriority(10); - conn3.sendPacket(presence); + conn3.sendStanza(presence); // Set this connection as highest priority presence = new Presence(Presence.Type.available); presence.setPriority(5); - getConnection(0).sendPacket(presence); + getConnection(0).sendStanza(presence); // Let the server process the change in presences Thread.sleep(200); @@ -249,11 +249,11 @@ public class MessageTest extends SmackTestCase { // Set this connection as highest priority Presence presence = new Presence(Presence.Type.available); presence.setMode(Presence.Mode.away); - conn3.sendPacket(presence); + conn3.sendStanza(presence); // Set this connection as highest priority presence = new Presence(Presence.Type.available); presence.setMode(Presence.Mode.available); - getConnection(0).sendPacket(presence); + getConnection(0).sendStanza(presence); // Let the server process the change in presences Thread.sleep(200); @@ -299,12 +299,12 @@ public class MessageTest extends SmackTestCase { Presence presence = new Presence(Presence.Type.available); presence.setMode(Presence.Mode.available); presence.setPriority(10); - conn3.sendPacket(presence); + conn3.sendStanza(presence); // Set this connection as highest priority presence = new Presence(Presence.Type.available); presence.setMode(Presence.Mode.available); presence.setPriority(10); - getConnection(0).sendPacket(presence); + getConnection(0).sendStanza(presence); connectionConfiguration = new ConnectionConfiguration(getHost(), getPort(), getServiceName()); @@ -314,7 +314,7 @@ public class MessageTest extends SmackTestCase { presence = new Presence(Presence.Type.available); presence.setMode(Presence.Mode.available); presence.setPriority(4); - getConnection(0).sendPacket(presence); + getConnection(0).sendStanza(presence); // Let the server process the change in presences @@ -326,7 +326,7 @@ public class MessageTest extends SmackTestCase { PacketCollector coll4 = conn4.createPacketCollector(new MessageTypeFilter(Message.Type.chat)); // Send a message from this resource to indicate most recent activity - conn3.sendPacket(new Message("admin@" + getServiceName())); + conn3.sendStanza(new Message("admin@" + getServiceName())); // User1 sends a message to the bare JID of User0 Chat chat = getConnection(1).getChatManager().createChat(getBareJID(0), null); @@ -362,7 +362,7 @@ public class MessageTest extends SmackTestCase { Presence presence = new Presence(Presence.Type.available); presence.setMode(Presence.Mode.available); presence.setPriority(-1); - getConnection(0).sendPacket(presence); + getConnection(0).sendStanza(presence); // Let the server process the change in presences Thread.sleep(200); @@ -383,7 +383,7 @@ public class MessageTest extends SmackTestCase { presence = new Presence(Presence.Type.available); presence.setMode(Presence.Mode.available); presence.setPriority(1); - getConnection(0).sendPacket(presence); + getConnection(0).sendStanza(presence); // Let the server process the change in presences Thread.sleep(200); diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/PacketReaderTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/PacketReaderTest.java index aa5d345eb..7c24ea877 100644 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/PacketReaderTest.java +++ b/smack-core/src/integration-test/java/org/jivesoftware/smack/PacketReaderTest.java @@ -84,7 +84,7 @@ public class PacketReaderTest extends SmackTestCase { // Send the IQ and wait for the answer PacketCollector collector = getConnection(0).createPacketCollector( new PacketIDFilter(iqPacket.getStanzaId())); - getConnection(0).sendPacket(iqPacket); + getConnection(0).sendStanza(iqPacket); IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); if (response == null) { fail("No response from the other user."); @@ -114,7 +114,7 @@ public class PacketReaderTest extends SmackTestCase { Message msg = new Message(getConnection(0).getUser(), Message.Type.normal); - getConnection(1).sendPacket(msg); + getConnection(1).sendStanza(msg); // Remove the listener getConnection(0).removeAsyncPacketListener(listener); @@ -141,7 +141,7 @@ public class PacketReaderTest extends SmackTestCase { Message message = new Message(packet.getFrom()); message.setFrom(getFullJID(1)); message.setBody("HELLO"); - getConnection(1).sendPacket(message); + getConnection(1).sendStanza(message); } }, new StanzaTypeFilter(Message.class)); @@ -149,7 +149,7 @@ public class PacketReaderTest extends SmackTestCase { PacketCollector collector = getConnection(0).createPacketCollector( new FromMatchesFilter(getFullJID(1))); // User0 sends the regular message to user1 - getConnection(0).sendPacket(packet); + getConnection(0).sendStanza(packet); // Check that user0 got a reply from user1 assertNotNull("No message was received", collector.nextResult(1000)); @@ -159,7 +159,7 @@ public class PacketReaderTest extends SmackTestCase { packet.setTo(getFullJID(1)); packet.setBody("aloha"); packet.setError(new XMPPError(XMPPError.Condition.feature_not_implemented, null)); - getConnection(0).sendPacket(packet); + getConnection(0).sendStanza(packet); // Check that user0 got a reply from user1 assertNotNull("No message was received", collector.nextResult(1000)); } @@ -213,8 +213,8 @@ public class PacketReaderTest extends SmackTestCase { for (int i = 0; i < 5; i++) { - getConnection(1).sendPacket(msg0); - getConnection(0).sendPacket(msg1); + getConnection(1).sendStanza(msg0); + getConnection(0).sendStanza(msg1); } try { @@ -236,8 +236,8 @@ public class PacketReaderTest extends SmackTestCase { } for (int i = 0; i < 10; i++) { - getConnection(0).sendPacket(msg1); - getConnection(1).sendPacket(msg0); + getConnection(0).sendStanza(msg1); + getConnection(1).sendStanza(msg0); } try { diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/PresenceTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/PresenceTest.java index 9537b087e..f7c2a6792 100644 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/PresenceTest.java +++ b/smack-core/src/integration-test/java/org/jivesoftware/smack/PresenceTest.java @@ -46,9 +46,9 @@ public class PresenceTest extends SmackTestCase { conn.connect(); conn.login(getUsername(1), getUsername(1), "OtherPlace"); // Change the presence priorities of User_1 - getConnection(1).sendPacket(new Presence(Presence.Type.available, null, 1, + getConnection(1).sendStanza(new Presence(Presence.Type.available, null, 1, Presence.Mode.available)); - conn.sendPacket(new Presence(Presence.Type.available, null, 2, + conn.sendStanza(new Presence(Presence.Type.available, null, 2, Presence.Mode.available)); Thread.sleep(150); // Create the chats between the participants @@ -64,9 +64,9 @@ public class PresenceTest extends SmackTestCase { chat1.nextMessage(1000));*/ // Invert the presence priorities of User_1 - getConnection(1).sendPacket(new Presence(Presence.Type.available, null, 2, + getConnection(1).sendStanza(new Presence(Presence.Type.available, null, 2, Presence.Mode.available)); - conn.sendPacket(new Presence(Presence.Type.available, null, 1, + conn.sendStanza(new Presence(Presence.Type.available, null, 1, Presence.Mode.available)); Thread.sleep(150); @@ -86,14 +86,14 @@ public class PresenceTest extends SmackTestCase { /*assertNotNull("Resource with highest priority didn't receive the message", chat1.nextMessage(2000));*/ - getConnection(1).sendPacket(new Presence(Presence.Type.available, null, 2, + getConnection(1).sendStanza(new Presence(Presence.Type.available, null, 2, Presence.Mode.available)); // User_1 will log in again using another resource conn = createConnection(); conn.connect(); conn.login(getUsername(1), getPassword(1), "OtherPlace"); - conn.sendPacket(new Presence(Presence.Type.available, null, 1, + conn.sendStanza(new Presence(Presence.Type.available, null, 1, Presence.Mode.available)); chat2 = conn.getChatManager().createChat(getBareJID(0), chat0.getThreadID(), null); @@ -106,9 +106,9 @@ public class PresenceTest extends SmackTestCase { chat2.nextMessage(1000));*/ // Invert the presence priorities of User_1 - getConnection(1).sendPacket(new Presence(Presence.Type.available, null, 1, + getConnection(1).sendStanza(new Presence(Presence.Type.available, null, 1, Presence.Mode.available)); - conn.sendPacket(new Presence(Presence.Type.available, null, 2, + conn.sendStanza(new Presence(Presence.Type.available, null, 2, Presence.Mode.available)); Thread.sleep(150); @@ -139,7 +139,7 @@ public class PresenceTest extends SmackTestCase { */ public void testNotAvailablePresence() throws XMPPException { // Change the presence to unavailable of User_1 - getConnection(1).sendPacket(new Presence(Presence.Type.unavailable)); + getConnection(1).sendStanza(new Presence(Presence.Type.unavailable)); // User_1 will log in again using another resource (that is going to be available) XMPPTCPConnection conn = createConnection(); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index bf47eaf0d..79eef043c 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -325,7 +325,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { @Override public abstract boolean isSecureConnection(); - protected abstract void sendPacketInternal(Stanza packet) throws NotConnectedException; + protected abstract void sendStanzaInternal(Stanza packet) throws NotConnectedException; @Override public abstract void send(PlainStreamElement element) throws NotConnectedException; @@ -538,7 +538,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { // eventually load the roster. And we should load the roster before we // send the initial presence. if (config.isSendPresence() && !resumed) { - sendPacket(new Presence(Presence.Type.available)); + sendStanza(new Presence(Presence.Type.available)); } } @@ -596,8 +596,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } } + @Deprecated @Override public void sendPacket(Stanza packet) throws NotConnectedException { + sendStanza(packet); + } + + @Override + public void sendStanza(Stanza packet) throws NotConnectedException { Objects.requireNonNull(packet, "Packet must not be null"); throwNotConnectedExceptionIfAppropriate(); @@ -615,7 +621,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { // Invoke interceptors for the new packet that is about to be sent. Interceptors may modify // the content of the packet. firePacketInterceptors(packet); - sendPacketInternal(packet); + sendStanzaInternal(packet); } /** @@ -656,7 +662,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @throws NotConnectedException */ public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException { - sendPacket(unavailablePresence); + sendStanza(unavailablePresence); shutdown(); callConnectionClosedListener(); } @@ -694,7 +700,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { PacketCollector packetCollector = createPacketCollector(packetFilter); try { // Now we can send the packet as the collector has been created - sendPacket(packet); + sendStanza(packet); } catch (NotConnectedException | RuntimeException e) { packetCollector.cancel(); @@ -1023,7 +1029,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { ErrorIQ errorIQ = IQ.createErrorResponse(iq, new XMPPError( XMPPError.Condition.feature_not_implemented)); try { - sendPacket(errorIQ); + sendStanza(errorIQ); } catch (NotConnectedException e) { LOGGER.log(Level.WARNING, "NotConnectedException while sending error IQ to unkown IQ request", e); @@ -1052,7 +1058,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { return; } try { - sendPacket(response); + sendStanza(response); } catch (NotConnectedException e) { LOGGER.log(Level.WARNING, "NotConnectedException while sending response to IQ request", e); @@ -1433,7 +1439,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } }, timeout, TimeUnit.MILLISECONDS); addAsyncStanzaListener(packetListener, replyFilter); - sendPacket(stanza); + sendStanza(stanza); } @Override diff --git a/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java b/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java index 4cd2070e1..9a4614b59 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java @@ -62,7 +62,7 @@ public class SynchronizationPoint { try { if (request != null) { if (request instanceof Stanza) { - connection.sendPacket((Stanza) request); + connection.sendStanza((Stanza) request); } else if (request instanceof PlainStreamElement){ connection.send((PlainStreamElement) request); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java index b6c091dc3..3b7079f04 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java @@ -158,9 +158,19 @@ public interface XMPPConnection { * * @param packet the packet to send. * @throws NotConnectedException + * @deprecated use {@link #sendStanza(Stanza)} instead. */ + @Deprecated public void sendPacket(Stanza packet) throws NotConnectedException; + /** + * Sends the specified stanza to the server. + * + * @param stanza the stanza to send. + * @throws NotConnectedException if the connection is not connected. + */ + public void sendStanza(Stanza stanza) throws NotConnectedException; + /** * Send a PlainStreamElement. *

diff --git a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java index 0b0db518b..dde1da0cc 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java @@ -33,7 +33,7 @@ import org.jivesoftware.smack.packet.TopLevelStreamElement; * unit tests. * * Instances store any packets that are delivered to be send using the - * {@link #sendPacket(Stanza)} method in a blocking queue. The content of this queue + * {@link #sendStanza(Stanza)} method in a blocking queue. The content of this queue * can be inspected using {@link #getSentPacket()}. Typically these queues are * used to retrieve a message that was generated by the client. * @@ -132,7 +132,7 @@ public class DummyConnection extends AbstractXMPPConnection { } @Override - protected void sendPacketInternal(Stanza packet) { + protected void sendStanzaInternal(Stanza packet) { if (SmackConfiguration.DEBUG) { System.out.println("[SEND]: " + packet.toXML()); } @@ -140,7 +140,7 @@ public class DummyConnection extends AbstractXMPPConnection { } /** - * Returns the number of packets that's sent through {@link #sendPacket(Stanza)} and + * Returns the number of packets that's sent through {@link #sendStanza(Stanza)} and * that has not been returned by {@link #getSentPacket()}. * * @return the number of packets which are in the queue. @@ -150,7 +150,7 @@ public class DummyConnection extends AbstractXMPPConnection { } /** - * Returns the first packet that's sent through {@link #sendPacket(Stanza)} + * Returns the first packet that's sent through {@link #sendStanza(Stanza)} * and that has not been returned by earlier calls to this method. * * @return a sent packet. @@ -160,7 +160,7 @@ public class DummyConnection extends AbstractXMPPConnection { } /** - * Returns the first packet that's sent through {@link #sendPacket(Stanza)} + * Returns the first packet that's sent through {@link #sendStanza(Stanza)} * and that has not been returned by earlier calls to this method. This * method will block for up to the specified number of seconds if no packets * have been sent yet. diff --git a/smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java b/smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java index 5644c66cf..e5cec42d0 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java @@ -38,8 +38,8 @@ public class ThreadedDummyConnection extends DummyConnection { private volatile boolean timeout = false; @Override - public void sendPacket(Stanza packet) throws NotConnectedException { - super.sendPacket(packet); + public void sendStanza(Stanza packet) throws NotConnectedException { + super.sendStanza(packet); if (packet instanceof IQ && !timeout) { timeout = false; @@ -62,7 +62,7 @@ public class ThreadedDummyConnection extends DummyConnection { } /** - * Calling this method will cause the next sendPacket call with an IQ packet to timeout. + * Calling this method will cause the next sendStanza call with an IQ packet to timeout. * This is accomplished by simply stopping the auto creating of the reply packet * or processing one that was entered via {@link #processPacket(Stanza)}. */ diff --git a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java index 389092ebf..edd2fda17 100644 --- a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java +++ b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java @@ -578,7 +578,7 @@ public class EnhancedDebugger implements SmackDebugger { if (!"".equals(adhocMessages.getText())) { AdHocPacket packetToSend = new AdHocPacket(adhocMessages.getText()); try { - connection.sendPacket(packetToSend); + connection.sendStanza(packetToSend); } catch (NotConnectedException e1) { e1.printStackTrace(); diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/CompressionTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/CompressionTest.java index e58a2a810..c7d045bcd 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/CompressionTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/CompressionTest.java @@ -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()); diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/FormTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/FormTest.java index 5ffc06fa9..9a42dc272 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/FormTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/FormTest.java @@ -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); diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/GroupChatInvitationTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/GroupChatInvitationTest.java index 89f48278c..6b80247ec 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/GroupChatInvitationTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/GroupChatInvitationTest.java @@ -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); diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/LastActivityManagerTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/LastActivityManagerTest.java index 274165651..cfb28e128 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/LastActivityManagerTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/LastActivityManagerTest.java @@ -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 { diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/OfflineMessageManagerTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/OfflineMessageManagerTest.java index 04a01e3c1..e99b65cac 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/OfflineMessageManagerTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/OfflineMessageManagerTest.java @@ -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); diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/VersionTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/VersionTest.java index b608179bf..d093a678b 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/VersionTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/VersionTest.java @@ -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); diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamTest.java index 264c0515d..b54867d91 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamTest.java @@ -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()); diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ByteStreamTest.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ByteStreamTest.java index 3e862df7c..fbbed78fa 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ByteStreamTest.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ByteStreamTest.java @@ -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()); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java index 944ed181a..bc5822b66 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java @@ -102,7 +102,7 @@ public class MultipleRecipientManager { && StringUtils.isNullOrEmpty(replyTo) && StringUtils.isNullOrEmpty(replyRoom)) { String toJid = to.iterator().next(); packet.setTo(toJid); - connection.sendPacket(packet); + connection.sendStanza(packet); return; } String serviceAddress = getMultipleRecipienServiceAddress(connection); @@ -155,7 +155,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 @@ -203,19 +203,19 @@ public class MultipleRecipientManager { if (to != null) { for (String jid : to) { packet.setTo(jid); - connection.sendPacket(new PacketCopy(packet.toXML())); + connection.sendStanza(new PacketCopy(packet.toXML())); } } if (cc != null) { for (String jid : cc) { packet.setTo(jid); - connection.sendPacket(new PacketCopy(packet.toXML())); + connection.sendStanza(new PacketCopy(packet.toXML())); } } if (bcc != null) { for (String jid : bcc) { packet.setTo(jid); - connection.sendPacket(new PacketCopy(packet.toXML())); + connection.sendStanza(new PacketCopy(packet.toXML())); } } } @@ -258,7 +258,7 @@ public class MultipleRecipientManager { // Add extension to packet packet.addExtension(multipleAddresses); // Send the packet - connection.sendPacket(packet); + connection.sendStanza(packet); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java index bac9992de..ccc3a5f1d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java @@ -442,7 +442,7 @@ public class InBandBytestreamManager implements BytestreamManager { protected void replyRejectPacket(IQ request) throws NotConnectedException { XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable); IQ error = IQ.createErrorResponse(request, xmppError); - this.connection.sendPacket(error); + this.connection.sendStanza(error); } /** @@ -455,7 +455,7 @@ public class InBandBytestreamManager implements BytestreamManager { protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException { XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint); IQ error = IQ.createErrorResponse(request, xmppError); - this.connection.sendPacket(error); + this.connection.sendStanza(error); } /** @@ -468,7 +468,7 @@ public class InBandBytestreamManager implements BytestreamManager { protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException { XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found); IQ error = IQ.createErrorResponse(request, xmppError); - this.connection.sendPacket(error); + this.connection.sendStanza(error); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamRequest.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamRequest.java index 1e9483e53..53462128c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamRequest.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamRequest.java @@ -79,7 +79,7 @@ public class InBandBytestreamRequest implements BytestreamRequest { // acknowledge request IQ resultIQ = IQ.createResultIQ(this.byteStreamRequest); - connection.sendPacket(resultIQ); + connection.sendStanza(resultIQ); return ibbSession; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java index a82526ebd..1f197fa4c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java @@ -173,7 +173,7 @@ public class InBandBytestreamSession implements BytestreamSession { // acknowledge close request IQ confirmClose = IQ.createResultIQ(closeRequest); - this.connection.sendPacket(confirmClose); + this.connection.sendStanza(confirmClose); } @@ -457,7 +457,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; } @@ -467,7 +467,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; } @@ -476,7 +476,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(); @@ -808,7 +808,7 @@ public class InBandBytestreamSession implements BytestreamSession { Message message = new Message(remoteJID); message.addExtension(data); - connection.sendPacket(message); + connection.sendStanza(message); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java index eac999397..149a3fc12 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java @@ -704,7 +704,7 @@ public final class Socks5BytestreamManager implements BytestreamManager { protected void replyRejectPacket(IQ packet) throws NotConnectedException { XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable); IQ errorIQ = IQ.createErrorResponse(packet, xmppError); - this.connection.sendPacket(errorIQ); + this.connection.sendStanza(errorIQ); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamRequest.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamRequest.java index 28fb19c8b..c2d751cbb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamRequest.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamRequest.java @@ -257,7 +257,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())); @@ -282,7 +282,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); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java index dcad233c4..75ffbf6f4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java @@ -505,7 +505,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 (NotConnectedException e) { LOGGER.log(Level.WARNING, "Could could not update presence with caps info", e); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java index 47d80dc5a..45df2da7a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java @@ -173,6 +173,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); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java index 04dd26485..1be561969 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java @@ -192,7 +192,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(); } @@ -203,7 +203,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; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java index 5b42ca15a..57b07e515 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java @@ -98,7 +98,7 @@ public abstract class StreamNegotiator { streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getPacketReplyTimeout(), new Callback() { @Override public void action() throws NotConnectedException { - connection.sendPacket(response); + connection.sendStanza(response); } }); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index b85bc6d68..b3b48c0ad 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -518,7 +518,7 @@ public class MultiUserChat { // field is in the form "roomName@service/nickname" Presence leavePresence = new Presence(Presence.Type.unavailable); leavePresence.setTo(room + "/" + nickname); - connection.sendPacket(leavePresence); + connection.sendStanza(leavePresence); // Reset occupant information. occupantsMap.clear(); nickname = null; @@ -689,7 +689,7 @@ public class MultiUserChat { // Add the MUCUser packet that includes the invitation to the message message.addExtension(mucUser); - connection.sendPacket(message); + connection.sendStanza(message); } /** @@ -892,7 +892,7 @@ public class MultiUserChat { joinPresence.setTo(room + "/" + nickname); // Send join packet. - connection.sendPacket(joinPresence); + connection.sendStanza(joinPresence); } /** @@ -939,7 +939,7 @@ public class MultiUserChat { form.addField(requestVoiceField); Message message = new Message(room); message.addExtension(form); - connection.sendPacket(message); + connection.sendStanza(message); } /** @@ -1575,7 +1575,7 @@ public class MultiUserChat { public void sendMessage(String text) throws XMPPException, NotConnectedException { Message message = createMessage(); message.setBody(text); - connection.sendPacket(message); + connection.sendStanza(message); } /** @@ -1612,7 +1612,7 @@ public class MultiUserChat { public void sendMessage(Message message) throws XMPPException, NotConnectedException { message.setTo(room); message.setType(Message.Type.groupchat); - connection.sendPacket(message); + connection.sendStanza(message); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java index 0be189da4..e6512f7b0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java @@ -284,7 +284,7 @@ public class MultiUserChatManager extends Manager { // Add the MUCUser packet that includes the rejection message.addExtension(mucUser); - connection().sendPacket(message); + connection().sendStanza(message); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java index 59d0e7ba6..cfd14f3b3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java @@ -36,7 +36,7 @@ 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); * * * To listen for group chat invitations, use a StanzaExtensionFilter for the diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java index 0d0e7035b..544764cc7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java @@ -115,7 +115,7 @@ public class PEPManager { //pubSub.setFrom(connection.getUser()); // Send the message that contains the roster - connection.sendPacket(pubSub); + connection.sendStanza(pubSub); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java index cf3b98ff5..c89dae1df 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java @@ -211,7 +211,7 @@ public class LeafNode extends Node { PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId())); - con.sendPacket(packet); + con.sendStanza(packet); } /** @@ -256,7 +256,7 @@ public class LeafNode extends Node { PubSub packet = createPubsubPacket(Type.set, new PublishItem(getId(), items)); - con.sendPacket(packet); + con.sendStanza(packet); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java index 3e0531ffc..909941a35 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java @@ -56,7 +56,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; * }); * Message message = … * DeliveryReceiptRequest.addTo(message); - * connection.sendPacket(message); + * connection.sendStanza(message); * * * DeliveryReceiptManager can be configured to automatically add delivery receipt requests to every @@ -158,7 +158,7 @@ public class DeliveryReceiptManager extends Manager { final Message messageWithReceiptRequest = (Message) packet; Message ack = receiptMessageFor(messageWithReceiptRequest); - connection.sendPacket(ack); + connection.sendStanza(ack); } }, MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST); } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/CloseListenerTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/CloseListenerTest.java index 0430124bf..3f3fb1847 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/CloseListenerTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/CloseListenerTest.java @@ -68,7 +68,7 @@ public class CloseListenerTest { // capture reply to the In-Band Bytestream close request ArgumentCaptor argument = ArgumentCaptor.forClass(IQ.class); - verify(connection).sendPacket(argument.capture()); + verify(connection).sendStanza(argument.capture()); // assert that reply is the correct error packet assertEquals(initiatorJID, argument.getValue().getTo()); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/DataListenerTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/DataListenerTest.java index 93d8e5209..43382d73c 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/DataListenerTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/DataListenerTest.java @@ -70,7 +70,7 @@ public class DataListenerTest { // capture reply to the In-Band Bytestream close request ArgumentCaptor argument = ArgumentCaptor.forClass(IQ.class); - verify(connection).sendPacket(argument.capture()); + verify(connection).sendStanza(argument.capture()); // assert that reply is the correct error packet assertEquals(initiatorJID, argument.getValue().getTo()); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamRequestTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamRequestTest.java index 057549a2c..cbf7bb39f 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamRequestTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamRequestTest.java @@ -78,7 +78,7 @@ public class InBandBytestreamRequestTest { // capture reply to the In-Band Bytestream open request ArgumentCaptor argument = ArgumentCaptor.forClass(IQ.class); - verify(connection).sendPacket(argument.capture()); + verify(connection).sendStanza(argument.capture()); // assert that reply is the correct error packet assertEquals(initiatorJID, argument.getValue().getTo()); @@ -103,7 +103,7 @@ public class InBandBytestreamRequestTest { // capture reply to the In-Band Bytestream open request ArgumentCaptor argument = ArgumentCaptor.forClass(IQ.class); - verify(connection).sendPacket(argument.capture()); + verify(connection).sendStanza(argument.capture()); // assert that reply is the correct acknowledgment packet assertEquals(initiatorJID, argument.getValue().getTo()); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InitiationListenerTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InitiationListenerTest.java index 5f57d089b..e1c7bea4a 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InitiationListenerTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/InitiationListenerTest.java @@ -86,7 +86,7 @@ public class InitiationListenerTest { // capture reply to the In-Band Bytestream open request ArgumentCaptor argument = ArgumentCaptor.forClass(IQ.class); - verify(connection).sendPacket(argument.capture()); + verify(connection).sendStanza(argument.capture()); // assert that reply is the correct error packet assertEquals(initiatorJID, argument.getValue().getTo()); @@ -114,7 +114,7 @@ public class InitiationListenerTest { // capture reply to the In-Band Bytestream open request ArgumentCaptor argument = ArgumentCaptor.forClass(IQ.class); - verify(connection).sendPacket(argument.capture()); + verify(connection).sendStanza(argument.capture()); // assert that reply is the correct error packet assertEquals(initiatorJID, argument.getValue().getTo()); @@ -204,7 +204,7 @@ public class InitiationListenerTest { // capture reply to the In-Band Bytestream open request ArgumentCaptor argument = ArgumentCaptor.forClass(IQ.class); - verify(connection).sendPacket(argument.capture()); + verify(connection).sendStanza(argument.capture()); // assert that reply is the correct error packet assertEquals(initiatorJID, argument.getValue().getTo()); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListenerTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListenerTest.java index 9475fe287..de0cc4ae2 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListenerTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListenerTest.java @@ -93,7 +93,7 @@ public class InitiationListenerTest { // capture reply to the SOCKS5 Bytestream initiation ArgumentCaptor argument = ArgumentCaptor.forClass(IQ.class); - verify(connection).sendPacket(argument.capture()); + verify(connection).sendStanza(argument.capture()); // assert that reply is the correct error packet assertEquals(initiatorJID, argument.getValue().getTo()); @@ -183,7 +183,7 @@ public class InitiationListenerTest { // capture reply to the SOCKS5 Bytestream initiation ArgumentCaptor argument = ArgumentCaptor.forClass(IQ.class); - verify(connection).sendPacket(argument.capture()); + verify(connection).sendStanza(argument.capture()); // assert that reply is the correct error packet assertEquals(initiatorJID, argument.getValue().getTo()); diff --git a/smack-extensions/src/test/java/org/jivesoftware/util/ConnectionUtils.java b/smack-extensions/src/test/java/org/jivesoftware/util/ConnectionUtils.java index edd85e959..9dd870445 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/util/ConnectionUtils.java +++ b/smack-extensions/src/test/java/org/jivesoftware/util/ConnectionUtils.java @@ -53,7 +53,7 @@ public class ConnectionUtils { *

      * 
      *   PacketCollector collector = connection.createPacketCollector(new PacketFilter());
-     *   connection.sendPacket(packet);
+     *   connection.sendStanza(packet);
      *   Packet reply = collector.nextResult();
      * 
      * 
@@ -95,7 +95,7 @@ public class ConnectionUtils { return null; } }; - doAnswer(addIncoming).when(connection).sendPacket(isA(Stanza.class)); + doAnswer(addIncoming).when(connection).sendStanza(isA(Stanza.class)); // mock receive methods Answer answer = new Answer() { diff --git a/smack-extensions/src/test/java/org/jivesoftware/util/Protocol.java b/smack-extensions/src/test/java/org/jivesoftware/util/Protocol.java index 75acff249..c96fd215e 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/util/Protocol.java +++ b/smack-extensions/src/test/java/org/jivesoftware/util/Protocol.java @@ -52,7 +52,7 @@ import org.jivesoftware.smack.packet.Stanza; * public void methodToTest() { * Packet packet = new Packet(); // create an XMPP packet * PacketCollector collector = connection.createPacketCollector(new StanzaIdFilter()); - * connection.sendPacket(packet); + * connection.sendStanza(packet); * Packet reply = collector.nextResult(); * } * diff --git a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java index b34fafa64..102b73276 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java @@ -362,7 +362,7 @@ public class ChatManager extends Manager{ if (message.getFrom() == null) { message.setFrom(connection().getUser()); } - connection().sendPacket(message); + connection().sendStanza(message); } PacketCollector createPacketCollector(Chat chat) { diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java index 6de3f540f..496fcae4e 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java @@ -483,7 +483,7 @@ public class Roster extends Manager { // Create a presence subscription packet and send. Presence presencePacket = new Presence(Presence.Type.subscribe); presencePacket.setTo(user); - connection.sendPacket(presencePacket); + connection.sendStanza(presencePacket); } /** @@ -1242,7 +1242,7 @@ public class Roster extends Manager { } if (response != null) { response.setTo(presence.getFrom()); - connection.sendPacket(response); + connection.sendStanza(response); } break; case unsubscribe: @@ -1252,7 +1252,7 @@ public class Roster extends Manager { // has unsubscribed to our presence. response = new Presence(Presence.Type.unsubscribed); response.setTo(presence.getFrom()); - connection.sendPacket(response); + connection.sendStanza(response); } // Otherwise, in manual mode so ignore. break; diff --git a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleManagerTest.java b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleManagerTest.java index c2632b833..bf795a2d5 100644 --- a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleManagerTest.java +++ b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleManagerTest.java @@ -175,7 +175,7 @@ public class JingleManagerTest extends SmackTestCase { iqSent.setType(IQ.Type.set); System.out.println("Sending packet and waiting... "); - getConnection(1).sendPacket(iqSent); + getConnection(1).sendStanza(iqSent); try { Thread.sleep(10000); } catch (InterruptedException e) { diff --git a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleMediaTest.java b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleMediaTest.java index 4b12a785b..147fda5fb 100644 --- a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleMediaTest.java +++ b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleMediaTest.java @@ -368,7 +368,7 @@ public class JingleMediaTest extends SmackTestCase { Thread.sleep(20000); //js0.sendFormattedError(JingleError.UNSUPPORTED_TRANSPORTS); - js0.sendPacket(js0.createJingleError(null, JingleError.UNSUPPORTED_TRANSPORTS)); + js0.sendStanza(js0.createJingleError(null, JingleError.UNSUPPORTED_TRANSPORTS)); Thread.sleep(20000); diff --git a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/provider/JingleProviderTest.java b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/provider/JingleProviderTest.java index bfc187e18..72cef16c7 100644 --- a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/provider/JingleProviderTest.java +++ b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/provider/JingleProviderTest.java @@ -75,7 +75,7 @@ public class JingleProviderTest extends SmackTestCase { System.out.println("Testing if a Jingle IQ can be sent and received..."); // Send the iq packet with an invalid namespace - getConnection(0).sendPacket(iqSent); + getConnection(0).sendStanza(iqSent); // Receive the packet IQ iqReceived = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java index 51a330bbd..5b1893b12 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java @@ -325,12 +325,12 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList // // If the response is anything other than a RESULT then send it now. // if ((response != null) && (!response.getType().equals(IQ.Type.result))) { - // getConnection().sendPacket(response); + // getConnection().sendStanza(response); // } // Loop through all of the responses and send them. for (IQ response : responses) { - sendPacket(response); + sendStanza(response); } } @@ -397,7 +397,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList // Send section // ---------------------------------------------------------------------------------------------------------- - public void sendPacket(IQ iq) throws NotConnectedException { + public void sendStanza(IQ iq) throws NotConnectedException { if (iq instanceof Jingle) { @@ -405,7 +405,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList } else { - getConnection().sendPacket(iq); + getConnection().sendStanza(iq); } } @@ -467,7 +467,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList // The the packet. if ((getConnection() != null) && (getConnection().isConnected())) - getConnection().sendPacket(jout); + getConnection().sendStanza(jout); } return jout; } @@ -483,7 +483,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList // updatePacketListener(); // // // Send the actual packet. - // sendPacket(inJingle); + // sendStanza(inJingle); // // // Change to the PENDING state. // setSessionState(JingleSessionStateEnum.PENDING); @@ -507,7 +507,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList IQ ack = IQ.createResultIQ(iq); // No! Don't send it. Let it flow to the normal way IQ results get processed and sent. - // getConnection().sendPacket(ack); + // getConnection().sendStanza(ack); result = ack; } } @@ -518,7 +518,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList * Send a content info message. */ // public synchronized void sendContentInfo(ContentInfo ci) { - // sendPacket(new Jingle(new JingleContentInfo(ci))); + // sendStanza(new Jingle(new JingleContentInfo(ci))); // } /* * (non-Javadoc) @@ -806,7 +806,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList } // Send the "accept" and wait for the ACK addExpectedId(jout.getStanzaId()); - sendPacket(jout); + sendStanza(jout); //triggerSessionEstablished(); @@ -838,7 +838,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList } // Send the "accept" and wait for the ACK addExpectedId(jout.getStanzaId()); - sendPacket(jout); + sendStanza(jout); } } } @@ -974,7 +974,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList LOGGER.fine("Terminate " + reason); Jingle jout = new Jingle(JingleActionEnum.SESSION_TERMINATE); jout.setType(IQ.Type.set); - sendPacket(jout); + sendStanza(jout); triggerSessionClosed(reason); } @@ -1035,7 +1035,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList // errorPacket.addExtension(jingleError); // NO! Let the normal state machinery do all of the sending. - // getConnection().sendPacket(perror); + // getConnection().sendStanza(perror); LOGGER.severe("Error sent: " + errorPacket.toXML()); } return errorPacket; @@ -1094,7 +1094,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList // Save the session-initiate packet ID, so that we can respond to it. sessionInitPacketID = jingle.getStanzaId(); - sendPacket(jingle); + sendStanza(jingle); // Now setup to track the media negotiators, so that we know when (if) to send a session-accept. setupListeners(); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportCandidate.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportCandidate.java index 43244ac7e..e451702b4 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportCandidate.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportCandidate.java @@ -613,7 +613,7 @@ public abstract class TransportCandidate { String id = null; byte[] send = null; byte[] receive = null; - DatagramPacket sendPacket = null; + DatagramPacket sendStanza = null; List listeners = new ArrayList(); List resultListeners = new ArrayList(); boolean enabled = true; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java index 3b04023c0..f04510b4e 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java @@ -82,7 +82,7 @@ public class AgentRoster { // Send request for roster. AgentStatusRequest request = new AgentStatusRequest(); request.setTo(workgroupJID); - connection.sendPacket(request); + connection.sendStanza(request); } /** @@ -94,7 +94,7 @@ public class AgentRoster { public void reload() throws NotConnectedException { AgentStatusRequest request = new AgentStatusRequest(); request.setTo(workgroupJID); - connection.sendPacket(request); + connection.sendStanza(request); } /** diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java index baf424c32..0492740ce 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java @@ -318,7 +318,7 @@ public class AgentSession { presence.setTo(workgroupJID); presence.addExtension(new DefaultExtensionElement(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE)); - connection.sendPacket(presence); + connection.sendStanza(presence); } } @@ -465,7 +465,7 @@ public class AgentSession { DepartQueuePacket departPacket = new DepartQueuePacket(this.workgroupJID); // PENDING - this.connection.sendPacket(departPacket); + this.connection.sendStanza(departPacket); } /** @@ -693,7 +693,7 @@ public class AgentSession { if (packet instanceof OfferRequestProvider.OfferRequestPacket) { // Acknowledge the IQ set. IQ reply = IQ.createResultIQ((IQ) packet); - connection.sendPacket(reply); + connection.sendStanza(reply); fireOfferRequestEvent((OfferRequestProvider.OfferRequestPacket)packet); } @@ -782,7 +782,7 @@ public class AgentSession { else if (packet instanceof OfferRevokeProvider.OfferRevokePacket) { // Acknowledge the IQ set. IQ reply = IQ.createResultIQ((OfferRevokeProvider.OfferRevokePacket) packet); - connection.sendPacket(reply); + connection.sendStanza(reply); fireOfferRevokeEvent((OfferRevokeProvider.OfferRevokePacket)packet); } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java index 374de974e..3092324d5 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java @@ -84,7 +84,7 @@ public class Offer { */ public void accept() throws NotConnectedException { Stanza acceptPacket = new AcceptPacket(this.session.getWorkgroupJID()); - connection.sendPacket(acceptPacket); + connection.sendStanza(acceptPacket); // TODO: listen for a reply. accepted = true; } @@ -95,7 +95,7 @@ public class Offer { */ public void reject() throws NotConnectedException { RejectPacket rejectPacket = new RejectPacket(this.session.getWorkgroupJID()); - connection.sendPacket(rejectPacket); + connection.sendStanza(rejectPacket); // TODO: listen for a reply. rejected = true; } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/OfferConfirmation.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/OfferConfirmation.java index 7cb0d7198..4f65ec6fc 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/OfferConfirmation.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/OfferConfirmation.java @@ -55,7 +55,7 @@ public class OfferConfirmation extends SimpleIQ { public void notifyService(XMPPConnection con, String workgroup, String createdRoomName) throws NotConnectedException { NotifyServicePacket packet = new NotifyServicePacket(workgroup, createdRoomName); - con.sendPacket(packet); + con.sendStanza(packet); } public static class Provider extends IQProvider { diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java index dbfda2b5b..3b525534e 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java @@ -218,7 +218,7 @@ public class MessageEventManager extends Manager { messageEvent.setStanzaId(packetID); msg.addExtension(messageEvent); // Send the packet - connection().sendPacket(msg); + connection().sendStanza(msg); } /** @@ -237,7 +237,7 @@ public class MessageEventManager extends Manager { messageEvent.setStanzaId(packetID); msg.addExtension(messageEvent); // Send the packet - connection().sendPacket(msg); + connection().sendStanza(msg); } /** @@ -256,7 +256,7 @@ public class MessageEventManager extends Manager { messageEvent.setStanzaId(packetID); msg.addExtension(messageEvent); // Send the packet - connection().sendPacket(msg); + connection().sendStanza(msg); } /** @@ -275,6 +275,6 @@ public class MessageEventManager extends Manager { messageEvent.setStanzaId(packetID); msg.addExtension(messageEvent); // Send the packet - connection().sendPacket(msg); + connection().sendStanza(msg); } } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java index a8988238e..547c3f3fd 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/RosterExchangeManager.java @@ -125,7 +125,7 @@ public class RosterExchangeManager { XMPPConnection connection = weakRefConnection.get(); // Send the message that contains the roster - connection.sendPacket(msg); + connection.sendStanza(msg); } /** @@ -145,7 +145,7 @@ public class RosterExchangeManager { XMPPConnection connection = weakRefConnection.get(); // Send the message that contains the roster - connection.sendPacket(msg); + connection.sendStanza(msg); } /** @@ -168,7 +168,7 @@ public class RosterExchangeManager { XMPPConnection connection = weakRefConnection.get(); // Send the message that contains the roster - connection.sendPacket(msg); + connection.sendStanza(msg); } /** diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index fac6ecdc6..b95b16132 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -421,7 +421,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { } // (Re-)send the stanzas *after* we tried to enable SM for (Stanza stanza : previouslyUnackedStanzas) { - sendPacketInternal(stanza); + sendStanzaInternal(stanza); } afterSuccessfulLogin(false); @@ -508,7 +508,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { setWasAuthenticated(); // If we are able to resume the stream, then don't set // connected/authenticated/usingTLS to false since we like behave like we are still - // connected (e.g. sendPacket should not throw a NotConnectedException). + // connected (e.g. sendStanza should not throw a NotConnectedException). if (isSmResumptionPossible() && instant) { disconnectedButResumeable = true; } else { @@ -536,7 +536,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { } @Override - protected void sendPacketInternal(Stanza packet) throws NotConnectedException { + protected void sendStanzaInternal(Stanza packet) throws NotConnectedException { packetWriter.sendStreamElement(packet); if (isSmEnabled()) { for (StanzaFilter requestAckPredicate : requestAckPredicates) { @@ -1342,8 +1342,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { unacknowledgedStanzas = new ArrayBlockingQueue<>(QUEUE_SIZE); } // Check if the stream element should be put to the unacknowledgedStanza - // queue. Note that we can not do the put() in sendPacketInternal() and the - // packet order is not stable at this point (sendPacketInternal() can be + // queue. Note that we can not do the put() in sendStanzaInternal() and the + // packet order is not stable at this point (sendStanzaInternal() can be // called concurrently). if (unacknowledgedStanzas != null && packet != null) { // If the unacknowledgedStanza queue is nearly full, request an new ack diff --git a/smack-tcp/src/test/java/org/jivesoftware/smack/tcp/PacketWriterTest.java b/smack-tcp/src/test/java/org/jivesoftware/smack/tcp/PacketWriterTest.java index 338c713e2..5b501b634 100644 --- a/smack-tcp/src/test/java/org/jivesoftware/smack/tcp/PacketWriterTest.java +++ b/smack-tcp/src/test/java/org/jivesoftware/smack/tcp/PacketWriterTest.java @@ -35,7 +35,7 @@ public class PacketWriterTest { /** * Make sure that packet writer does block once the queue reaches * {@link PacketWriter#QUEUE_SIZE} and that - * {@link PacketWriter#sendPacket(org.jivesoftware.smack.tcp.packet.Packet)} does unblock after the + * {@link PacketWriter#sendStanza(org.jivesoftware.smack.tcp.packet.Packet)} does unblock after the * interrupt. * * @throws InterruptedException @@ -84,7 +84,7 @@ public class PacketWriterTest { // will block before we call shutdown. Otherwise we may get false positives (which is still // better then false negatives). barrier.await(); - // Not really cool, but may increases the chances for 't' to block in sendPacket. + // Not really cool, but may increases the chances for 't' to block in sendStanza. Thread.sleep(250); // Set to true for testing purposes, so that shutdown() won't wait packet writer