Rename 'Packet' class to 'Stanza'

Smack still uses the term 'Packet' in some places. This is just the
first step towards using correct XMPP terms in Smack.
This commit is contained in:
Florian Schmaus 2015-02-05 11:17:27 +01:00
parent 9fc26f1d83
commit 4698805a34
142 changed files with 595 additions and 572 deletions

View File

@ -36,7 +36,7 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PlainStreamElement;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
@ -256,15 +256,15 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
}
@Override
protected void sendPacketInternal(Packet packet) throws NotConnectedException {
protected void sendPacketInternal(Stanza packet) throws NotConnectedException {
sendElement(packet);
}
private void sendElement(Element element) {
try {
send(ComposableBody.builder().setPayloadXML(element.toXML().toString()).build());
if (element instanceof Packet) {
firePacketSendingListeners((Packet) element);
if (element instanceof Stanza) {
firePacketSendingListeners((Stanza) element);
}
}
catch (BOSHException e) {

View File

@ -50,7 +50,7 @@ public class IQTest extends SmackTestCase {
}
};
PacketFilter filter = new AndFilter(new PacketIDFilter(iq.getPacketID()),
PacketFilter filter = new AndFilter(new PacketIDFilter(iq.getStanzaId()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = getConnection(0).createPacketCollector(filter);
// Send the iq packet with an invalid namespace
@ -83,7 +83,7 @@ public class IQTest extends SmackTestCase {
// Create a packet collector to listen for a response.
PacketCollector collector = getConnection(0).createPacketCollector(
new PacketIDFilter(versionRequest.getPacketID()));
new PacketIDFilter(versionRequest.getStanzaId()));
getConnection(0).sendPacket(versionRequest);

View File

@ -83,7 +83,7 @@ public class PacketReaderTest extends SmackTestCase {
// Send the IQ and wait for the answer
PacketCollector collector = getConnection(0).createPacketCollector(
new PacketIDFilter(iqPacket.getPacketID()));
new PacketIDFilter(iqPacket.getStanzaId()));
getConnection(0).sendPacket(iqPacket);
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
if (response == null) {

View File

@ -56,7 +56,7 @@ public class PacketIDFilterTest extends TestCase {
public MockIDPacket(String id) {
this.id = id;
}
public String getPacketID() {
public String getStanzaId() {
return id;
}
}

View File

@ -63,7 +63,7 @@ import org.jivesoftware.smack.packet.Bind;
import org.jivesoftware.smack.packet.ErrorIQ;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Mechanisms;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Session;
@ -120,7 +120,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* and perform blocking and polling operations on the result queue.
* <p>
* We use a ConcurrentLinkedQueue here, because its Iterator is weakly
* consistent and we want {@link #invokePacketCollectors(Packet)} for-each
* consistent and we want {@link #invokePacketCollectors(Stanza)} for-each
* loop to be lock free. As drawback, removing a PacketCollector is O(n).
* The alternative would be a synchronized HashSet, but this would mean a
* synchronized block around every usage of <code>collectors</code>.
@ -362,7 +362,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override
public abstract boolean isSecureConnection();
protected abstract void sendPacketInternal(Packet packet) throws NotConnectedException;
protected abstract void sendPacketInternal(Stanza packet) throws NotConnectedException;
@Override
public abstract void send(PlainStreamElement element) throws NotConnectedException;
@ -634,7 +634,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
@Override
public void sendPacket(Packet packet) throws NotConnectedException {
public void sendPacket(Stanza packet) throws NotConnectedException {
Objects.requireNonNull(packet, "Packet must not be null");
throwNotConnectedExceptionIfAppropriate();
@ -725,7 +725,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
@Override
public PacketCollector createPacketCollectorAndSend(PacketFilter packetFilter, Packet packet)
public PacketCollector createPacketCollectorAndSend(PacketFilter packetFilter, Stanza packet)
throws NotConnectedException {
// Create the packet collector before sending the packet
PacketCollector packetCollector = createPacketCollector(packetFilter);
@ -828,13 +828,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
/**
* Process all packet listeners for sending packets.
* <p>
* Compared to {@link #firePacketInterceptors(Packet)}, the listeners will be invoked in a new thread.
* Compared to {@link #firePacketInterceptors(Stanza)}, the listeners will be invoked in a new thread.
* </p>
*
* @param packet the packet to process.
*/
@SuppressWarnings("javadoc")
protected void firePacketSendingListeners(final Packet packet) {
protected void firePacketSendingListeners(final Stanza packet) {
final List<PacketListener> listenersToNotify = new LinkedList<PacketListener>();
synchronized (sendListeners) {
for (ListenerWrapper listenerWrapper : sendListeners.values()) {
@ -889,7 +889,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
*
* @param packet the packet that is going to be sent to the server
*/
private void firePacketInterceptors(Packet packet) {
private void firePacketInterceptors(Stanza packet) {
List<PacketListener> interceptorsToInvoke = new LinkedList<PacketListener>();
synchronized (interceptors) {
for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
@ -973,7 +973,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
protected void parseAndProcessStanza(XmlPullParser parser) throws Exception {
ParserUtils.assertAtStartTag(parser);
int parserDepth = parser.getDepth();
Packet stanza = null;
Stanza stanza = null;
try {
stanza = PacketParserUtils.parseStanza(parser);
}
@ -999,7 +999,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
*
* @param packet the packet to process.
*/
protected void processPacket(Packet packet) {
protected void processPacket(Stanza packet) {
assert(packet != null);
lastStanzaReceived = System.currentTimeMillis();
// Deliver the incoming packet to listeners.
@ -1011,9 +1011,9 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
*/
private class ListenerNotification implements Runnable {
private final Packet packet;
private final Stanza packet;
public ListenerNotification(Packet packet) {
public ListenerNotification(Stanza packet) {
this.packet = packet;
}
@ -1023,12 +1023,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
/**
* Invoke {@link PacketCollector#processPacket(Packet)} for every
* Invoke {@link PacketCollector#processPacket(Stanza)} for every
* PacketCollector with the given packet. Also notify the receive listeners with a matching packet filter about the packet.
*
* @param packet the packet to notify the PacketCollectors and receive listeners about.
*/
protected void invokePacketCollectorsAndNotifyRecvListeners(final Packet packet) {
protected void invokePacketCollectorsAndNotifyRecvListeners(final Stanza packet) {
if (packet instanceof IQ) {
final IQ iq = (IQ) packet;
final IQ.Type type = iq.getType();
@ -1259,7 +1259,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
this.packetFilter = packetFilter;
}
public boolean filterMatches(Packet packet) {
public boolean filterMatches(Stanza packet) {
return packetFilter == null || packetFilter.accept(packet);
}
@ -1287,7 +1287,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
this.packetFilter = packetFilter;
}
public boolean filterMatches(Packet packet) {
public boolean filterMatches(Stanza packet) {
return packetFilter == null || packetFilter.accept(packet);
}
@ -1418,13 +1418,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
@Override
public void sendStanzaWithResponseCallback(Packet stanza, PacketFilter replyFilter,
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter,
PacketListener callback) throws NotConnectedException {
sendStanzaWithResponseCallback(stanza, replyFilter, callback, null);
}
@Override
public void sendStanzaWithResponseCallback(Packet stanza, PacketFilter replyFilter,
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter,
PacketListener callback, ExceptionCallback exceptionCallback)
throws NotConnectedException {
sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback,
@ -1432,7 +1432,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
@Override
public void sendStanzaWithResponseCallback(Packet stanza, PacketFilter replyFilter,
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter,
final PacketListener callback, final ExceptionCallback exceptionCallback,
long timeout) throws NotConnectedException {
Objects.requireNonNull(stanza, "stanza must not be null");
@ -1443,7 +1443,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
final PacketListener packetListener = new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
try {
XMPPErrorException.ifHasErrorThenThrow(packet);
callback.processPacket(packet);
@ -1497,7 +1497,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
public void addOneTimeSyncCallback(final PacketListener callback, final PacketFilter packetFilter) {
final PacketListener packetListener = new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
try {
callback.processPacket(packet);
} finally {

View File

@ -25,7 +25,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.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
/**
* Provides a mechanism to collect packets into a result queue that pass a
@ -46,7 +46,7 @@ public class PacketCollector {
private static final Logger LOGGER = Logger.getLogger(PacketCollector.class.getName());
private final PacketFilter packetFilter;
private final ArrayBlockingQueue<Packet> resultQueue;
private final ArrayBlockingQueue<Stanza> resultQueue;
/**
* The packet collector which timeout for the next result will get reset once this collector collects a stanza.
@ -103,7 +103,7 @@ public class PacketCollector {
* results.
*/
@SuppressWarnings("unchecked")
public <P extends Packet> P pollResult() {
public <P extends Stanza> P pollResult() {
return (P) resultQueue.poll();
}
@ -118,7 +118,7 @@ public class PacketCollector {
* @return the next available packet.
* @throws XMPPErrorException in case an error response.
*/
public <P extends Packet> P pollResultOrThrow() throws XMPPErrorException {
public <P extends Stanza> P pollResultOrThrow() throws XMPPErrorException {
P result = pollResult();
if (result != null) {
XMPPErrorException.ifHasErrorThenThrow(result);
@ -133,7 +133,7 @@ public class PacketCollector {
* @return the next available packet.
*/
@SuppressWarnings("unchecked")
public <P extends Packet> P nextResultBlockForever() {
public <P extends Stanza> P nextResultBlockForever() {
throwIfCancelled();
P res = null;
while (res == null) {
@ -153,7 +153,7 @@ public class PacketCollector {
*
* @return the next available packet.
*/
public <P extends Packet> P nextResult() {
public <P extends Stanza> P nextResult() {
return nextResult(connection.getPacketReplyTimeout());
}
@ -168,7 +168,7 @@ public class PacketCollector {
* @return the next available packet.
*/
@SuppressWarnings("unchecked")
public <P extends Packet> P nextResult(long timeout) {
public <P extends Stanza> P nextResult(long timeout) {
throwIfCancelled();
P res = null;
long remainingWait = timeout;
@ -197,7 +197,7 @@ public class PacketCollector {
* @throws XMPPErrorException in case an error response.
* @throws NoResponseException if there was no response from the server.
*/
public <P extends Packet> P nextResultOrThrow() throws NoResponseException, XMPPErrorException {
public <P extends Stanza> P nextResultOrThrow() throws NoResponseException, XMPPErrorException {
return nextResultOrThrow(connection.getPacketReplyTimeout());
}
@ -210,7 +210,7 @@ public class PacketCollector {
* @throws NoResponseException if there was no response from the server.
* @throws XMPPErrorException in case an error response.
*/
public <P extends Packet> P nextResultOrThrow(long timeout) throws NoResponseException, XMPPErrorException {
public <P extends Stanza> P nextResultOrThrow(long timeout) throws NoResponseException, XMPPErrorException {
P result = nextResult(timeout);
cancel();
if (result == null) {
@ -238,7 +238,7 @@ public class PacketCollector {
*
* @param packet the packet to process.
*/
protected void processPacket(Packet packet) {
protected void processPacket(Stanza packet) {
if (packetFilter == null || packetFilter.accept(packet)) {
while (!resultQueue.offer(packet)) {
// Since we know the queue is full, this poll should never actually block.

View File

@ -18,12 +18,12 @@
package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Packet;
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(Packet)} method will be called. This is the
* 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.
* <p>
@ -48,6 +48,6 @@ public interface PacketListener {
*
* @param packet the packet to process.
*/
public void processPacket(Packet packet) throws NotConnectedException;
public void processPacket(Stanza packet) throws NotConnectedException;
}

View File

@ -25,7 +25,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.TopLevelStreamElement;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PlainStreamElement;
public class SynchronizationPoint<E extends Exception> {
@ -61,8 +61,8 @@ public class SynchronizationPoint<E extends Exception> {
connectionLock.lock();
try {
if (request != null) {
if (request instanceof Packet) {
connection.sendPacket((Packet) request);
if (request instanceof Stanza) {
connection.sendPacket((Stanza) request);
}
else if (request instanceof PlainStreamElement){
connection.send((PlainStreamElement) request);

View File

@ -23,7 +23,7 @@ import org.jivesoftware.smack.filter.IQReplyFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.PlainStreamElement;
@ -151,7 +151,7 @@ public interface XMPPConnection {
* @param packet the packet to send.
* @throws NotConnectedException
*/
public void sendPacket(Packet packet) throws NotConnectedException;
public void sendPacket(Stanza packet) throws NotConnectedException;
/**
* Send a PlainStreamElement.
@ -203,7 +203,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, Packet packet)
public PacketCollector createPacketCollectorAndSend(PacketFilter packetFilter, Stanza packet)
throws NotConnectedException;
/**
@ -214,7 +214,7 @@ public interface XMPPConnection {
* <p>
* <b>Note:</b> If you send a Packet right after using this method, then
* consider using
* {@link #createPacketCollectorAndSend(PacketFilter, Packet)} instead.
* {@link #createPacketCollectorAndSend(PacketFilter, 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.
* </p>
@ -455,7 +455,7 @@ public interface XMPPConnection {
* @param callback the callback invoked if there is a response (required)
* @throws NotConnectedException
*/
public void sendStanzaWithResponseCallback(Packet stanza, PacketFilter replyFilter,
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter,
PacketListener callback) throws NotConnectedException;
/**
@ -472,7 +472,7 @@ public interface XMPPConnection {
* @param exceptionCallback the callback invoked if there is an exception (optional)
* @throws NotConnectedException
*/
public void sendStanzaWithResponseCallback(Packet stanza, PacketFilter replyFilter, PacketListener callback,
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter, PacketListener callback,
ExceptionCallback exceptionCallback) throws NotConnectedException;
/**
@ -490,7 +490,7 @@ public interface XMPPConnection {
* @param timeout the timeout in milliseconds to wait for a response
* @throws NotConnectedException
*/
public void sendStanzaWithResponseCallback(Packet stanza, PacketFilter replyFilter,
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter,
final PacketListener callback, final ExceptionCallback exceptionCallback,
long timeout) throws NotConnectedException;

View File

@ -17,7 +17,7 @@
package org.jivesoftware.smack;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StreamError;
import org.jivesoftware.smack.packet.XMPPError;
@ -134,7 +134,7 @@ public abstract class XMPPException extends Exception {
return getMessage();
}
public static void ifHasErrorThenThrow(Packet packet) throws XMPPErrorException {
public static void ifHasErrorThenThrow(Stanza packet) throws XMPPErrorException {
XMPPError xmppError = packet.getError();
if (xmppError != null) {
throw new XMPPErrorException(xmppError);

View File

@ -19,7 +19,7 @@ package org.jivesoftware.smack.debugger;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.ObservableReader;
import org.jivesoftware.smack.util.ObservableWriter;
import org.jivesoftware.smack.util.ReaderListener;
@ -68,7 +68,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
// 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() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
if (printInterpreted) {
log("RCV PKT (" + connection.getConnectionCounter() + "): " + packet.toXML());
}

View File

@ -21,7 +21,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.Objects;
/**
@ -69,7 +69,7 @@ public class AndFilter implements PacketFilter {
filters.add(filter);
}
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
for (PacketFilter filter : filters) {
if (!filter.accept(packet)) {
return false;

View File

@ -19,14 +19,14 @@ package org.jivesoftware.smack.filter;
import java.lang.reflect.ParameterizedType;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
/**
* Filters for packets of a particular type and allows a custom method to further filter the packets.
*
* @author Florian Schmaus
*/
public abstract class FlexiblePacketTypeFilter<P extends Packet> implements PacketFilter {
public abstract class FlexiblePacketTypeFilter<P extends Stanza> implements PacketFilter {
protected final Class<P> packetType;
@ -41,7 +41,7 @@ public abstract class FlexiblePacketTypeFilter<P extends Packet> implements Pack
@Override
@SuppressWarnings("unchecked")
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
if (packetType.isInstance(packet)) {
return acceptSpecific((P) packet);
}

View File

@ -19,7 +19,7 @@ package org.jivesoftware.smack.filter;
import java.util.Locale;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jxmpp.util.XmppStringUtils;
/**
@ -89,7 +89,7 @@ public class FromMatchesFilter implements PacketFilter {
return new FromMatchesFilter(address, false);
}
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
String from = packet.getFrom();
if (from == null) {
return address == null;

View File

@ -22,7 +22,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jxmpp.util.XmppStringUtils;
/**
@ -96,7 +96,7 @@ public class IQReplyFilter implements PacketFilter {
local = localJid.toLowerCase(Locale.US);
server = conn.getServiceName().toLowerCase(Locale.US);
packetId = iqPacket.getPacketID();
packetId = iqPacket.getStanzaId();
PacketFilter iqFilter = new OrFilter(IQTypeFilter.ERROR, IQTypeFilter.RESULT);
PacketFilter idFilter = new PacketIDFilter(iqPacket);
@ -113,7 +113,7 @@ public class IQReplyFilter implements PacketFilter {
}
@Override
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
// First filter out everything that is not an IQ stanza and does not have the correct ID set.
if (!iqAndIdFilter.accept(packet))
return false;

View File

@ -18,7 +18,7 @@ package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
/**
*
@ -31,7 +31,7 @@ public class IQResultReplyFilter extends IQReplyFilter {
}
@Override
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
if (!super.accept(packet)) {
return false;
}

View File

@ -17,7 +17,7 @@
package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
/**
* Implements the logical NOT operation on a packet filter. In other words, packets
@ -41,7 +41,7 @@ public class NotFilter implements PacketFilter {
this.filter = filter;
}
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
return !filter.accept(packet);
}
}

View File

@ -21,7 +21,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.Objects;
/**
@ -69,7 +69,7 @@ public class OrFilter implements PacketFilter {
filters.add(filter);
}
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
for (PacketFilter filter : filters) {
if (filter.accept(packet)) {
return true;

View File

@ -17,7 +17,7 @@
package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.StringUtils;
@ -65,7 +65,7 @@ public class PacketExtensionFilter implements PacketFilter {
this(packetExtension.getElementName(), packetExtension.getNamespace());
}
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
return packet.hasExtension(elementName, namespace);
}
}

View File

@ -17,7 +17,7 @@
package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
/**
* Defines a way to filter packets for particular attributes. Packet filters are used when
@ -35,7 +35,7 @@ import org.jivesoftware.smack.packet.Packet;
* // all packets that have a packet ID of &quot;RS145&quot;.
* PacketFilter myFilter = new PacketFilter() {
* public boolean accept(Packet packet) {
* return &quot;RS145&quot;.equals(packet.getPacketID());
* return &quot;RS145&quot;.equals(packet.getStanzaId());
* }
* };
* // Create a new packet collector using the filter we created.
@ -54,5 +54,5 @@ public interface PacketFilter {
* @param packet the packet to test.
* @return true if and only if <tt>packet</tt> passes the filter.
*/
public boolean accept(Packet packet);
public boolean accept(Stanza packet);
}

View File

@ -17,7 +17,7 @@
package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.StringUtils;
/**
@ -34,8 +34,8 @@ public class PacketIDFilter implements PacketFilter {
*
* @param packet the packet which the ID is taken from.
*/
public PacketIDFilter(Packet packet) {
this(packet.getPacketID());
public PacketIDFilter(Stanza packet) {
this(packet.getStanzaId());
}
/**
@ -48,8 +48,8 @@ public class PacketIDFilter implements PacketFilter {
this.packetID = packetID;
}
public boolean accept(Packet packet) {
return packetID.equals(packet.getPacketID());
public boolean accept(Stanza packet) {
return packetID.equals(packet.getStanzaId());
}
public String toString() {

View File

@ -18,7 +18,7 @@
package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.Presence;
/**
@ -37,7 +37,7 @@ public class PacketTypeFilter implements PacketFilter {
public static final PacketTypeFilter PRESENCE = new PacketTypeFilter(Presence.class);
public static final PacketTypeFilter MESSAGE = new PacketTypeFilter(Message.class);
private final Class<? extends Packet> packetType;
private final Class<? extends Stanza> packetType;
/**
* Creates a new packet type filter that will filter for packets that are the
@ -45,11 +45,11 @@ public class PacketTypeFilter implements PacketFilter {
*
* @param packetType the Class type.
*/
public PacketTypeFilter(Class<? extends Packet> packetType) {
public PacketTypeFilter(Class<? extends Stanza> packetType) {
this.packetType = packetType;
}
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
return packetType.isInstance(packet);
}

View File

@ -17,7 +17,7 @@
package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.util.StringUtils;
@ -40,7 +40,7 @@ public class ThreadFilter implements PacketFilter {
this.thread = thread;
}
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
return packet instanceof Message && thread.equals(((Message) packet).getThread());
}
}

View File

@ -18,7 +18,7 @@ package org.jivesoftware.smack.filter;
import java.util.Locale;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
public class ToFilter implements PacketFilter {
@ -29,7 +29,7 @@ public class ToFilter implements PacketFilter {
}
@Override
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
String packetTo = packet.getTo();
if (packetTo == null) {
return false;

View File

@ -29,7 +29,7 @@ public class EmptyResultIQ extends IQ {
throw new IllegalArgumentException(
"IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML());
}
setPacketID(request.getPacketID());
setStanzaId(request.getStanzaId());
setFrom(request.getTo());
setTo(request.getFrom());
}

View File

@ -19,7 +19,7 @@ package org.jivesoftware.smack.packet;
/**
* Base class for Stream elements. Everything that is not a stanza (RFC 6120 8.), ie. message,
* presence and iq, should sublcass this class instead of {@link Packet}.
* presence and iq, should sublcass this class instead of {@link Stanza}.
*
* @author Florian Schmaus
*/

View File

@ -39,7 +39,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
*
* @author Matt Tucker
*/
public abstract class IQ extends Packet {
public abstract class IQ extends Stanza {
// Don't name this field 'ELEMENT'. When it comes to IQ, ELEMENT is the child element!
public static final String IQ_ELEMENT = "iq";
@ -247,7 +247,7 @@ public abstract class IQ extends Packet {
"IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML());
}
final ErrorIQ result = new ErrorIQ(error);
result.setPacketID(request.getPacketID());
result.setStanzaId(request.getStanzaId());
result.setFrom(request.getTo());
result.setTo(request.getFrom());
return result;

View File

@ -50,7 +50,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
*
* @author Matt Tucker
*/
public final class Message extends Packet {
public final class Message extends Stanza {
public static final String ELEMENT = "message";
public static final String BODY = "body";
@ -126,7 +126,7 @@ public final class Message extends Packet {
* <p>
* The default subject of a message is the subject that corresponds to the message's language.
* (see {@link #getLanguage()}) or if no language is set to the applications default
* language (see {@link Packet#getDefaultLanguage()}).
* language (see {@link Stanza#getDefaultLanguage()}).
*
* @return the subject of the message.
*/
@ -244,7 +244,7 @@ public final class Message extends Packet {
* <p>
* The default body of a message is the body that corresponds to the message's language.
* (see {@link #getLanguage()}) or if no language is set to the applications default
* language (see {@link Packet#getDefaultLanguage()}).
* language (see {@link Stanza#getDefaultLanguage()}).
*
* @return the body of the message.
*/

View File

@ -20,7 +20,7 @@ package org.jivesoftware.smack.packet;
/**
* Plain stream elements, ie. everything that is <b>not a stanza</b> as defined
* RFC 6120 8. Stanzas are {@link Message}, {@link Presence} and {@link IQ}.
* Everything else should sublcass this class instead of {@link Packet}.
* Everything else should sublcass this class instead of {@link Stanza}.
* <p>
* It is important to cleanly distinguish between stanzas and non-stanzas. For
* example plain stream elements don't count into the stanza count of XEP-198

View File

@ -55,7 +55,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
*
* @author Matt Tucker
*/
public final class Presence extends Packet {
public final class Presence extends Stanza {
public static final String ELEMENT = "presence";

View File

@ -28,18 +28,21 @@ import java.util.List;
import java.util.Locale;
/**
* Base class for XMPP Stanzas, which are called packets in Smack.
* Base class for XMPP Stanzas, which are called Packet in older versions of Smack (i.e. &lt; 4.1).
* <p>
* Every packet has a unique ID (which is automatically
* generated, but can be overridden). Optionally, the "to" and "from" fields can be set.
* Every stanza has a unique ID (which is automatically generated, but can be overridden). Stanza
* IDs are required for IQ stanzas and recommended for presence and message stanzas. Optionally, the
* "to" and "from" fields can be set.
* </p>
* <p>
* XMPP Stanzas are {@link Message}, {@link IQ} and {@link Presence}. Which therefore subclass this class.
* XMPP Stanzas are {@link Message}, {@link IQ} and {@link Presence}. Which therefore subclass this
* class. <b>If you think you need to subclass this class, then you are doing something wrong.</b>
* </p>
*
* @author Matt Tucker
* @see <a href="http://xmpp.org/rfcs/rfc6120.html#stanzas">RFC 6120 § 8. XML Stanzas</a>
*/
public abstract class Packet implements TopLevelStreamElement {
public abstract class Stanza implements TopLevelStreamElement {
public static final String TEXT = "text";
public static final String ITEM = "item";
@ -49,7 +52,7 @@ public abstract class Packet implements TopLevelStreamElement {
private final MultiMap<String, PacketExtension> packetExtensions = new MultiMap<>();
private String packetID = null;
private String id = null;
private String to = null;
private String from = null;
private XMPPError error = null;
@ -66,16 +69,16 @@ public abstract class Packet implements TopLevelStreamElement {
*/
protected String language;
public Packet() {
public Stanza() {
this(StanzaIdUtil.newStanzaId());
}
public Packet(String packetID) {
setPacketID(packetID);
public Stanza(String stanzaId) {
setStanzaId(stanzaId);
}
public Packet(Packet p) {
packetID = p.getPacketID();
public Stanza(Stanza p) {
id = p.getStanzaId();
to = p.getTo();
from = p.getFrom();
error = p.error;
@ -87,22 +90,42 @@ public abstract class Packet implements TopLevelStreamElement {
}
/**
* Returns the unique ID of the packet. The returned value could be <code>null</code>.
* Returns the unique ID of the stanza. The returned value could be <code>null</code>.
*
* @return the packet's unique ID or <code>null</code> if the packet's id is not available.
* @return the packet's unique ID or <code>null</code> if the id is not available.
*/
public String getStanzaId() {
return id;
}
/**
*
* @return the stanza id.
* @deprecated use {@link #getStanzaId()} instead.
*/
@Deprecated
public String getPacketID() {
return packetID;
return getStanzaId();
}
/**
* Sets the unique ID of the packet. To indicate that a packet has no id
* pass <code>null</code> as the packet's id value.
*
* @param packetID the unique ID for the packet.
* @param id the unique ID for the packet.
*/
public void setStanzaId(String id) {
this.id = id;
}
/**
*
* @param packetID
* @deprecated use {@link #setStanzaId(String)} instead.
*/
@Deprecated
public void setPacketID(String packetID) {
this.packetID = packetID;
setStanzaId(packetID);
}
/**
@ -367,7 +390,7 @@ public abstract class Packet implements TopLevelStreamElement {
protected void addCommonAttributes(XmlStringBuilder xml) {
xml.optAttribute("to", getTo());
xml.optAttribute("from", getFrom());
xml.optAttribute("id", getPacketID());
xml.optAttribute("id", getStanzaId());
xml.xmllangAttribute(getLanguage());
}

View File

@ -18,7 +18,7 @@
package org.jivesoftware.smack.packet;
/**
* A XMPP top level stream element. This is either a stanza ({@link Packet}) or
* A XMPP top level stream element. This is either a stanza ({@link Stanza}) or
* just a plain stream element ({@link PlainStreamElement}).
*/
public interface TopLevelStreamElement extends Element {

View File

@ -35,7 +35,7 @@ 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.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Session;
@ -128,7 +128,7 @@ public class PacketParserUtils {
return parser;
}
public static Packet parseStanza(String stanza) throws XmlPullParserException, IOException, SmackException {
public static Stanza parseStanza(String stanza) throws XmlPullParserException, IOException, SmackException {
return parseStanza(getParserFor(stanza));
}
@ -143,7 +143,7 @@ public class PacketParserUtils {
* @throws SmackException
* @throws IOException
*/
public static Packet parseStanza(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
public static Stanza parseStanza(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
ParserUtils.assertAtStartTag(parser);
final String name = parser.getName();
switch (name) {
@ -221,7 +221,7 @@ public class PacketParserUtils {
final int initialDepth = parser.getDepth();
Message message = new Message();
message.setPacketID(parser.getAttributeValue("", "id"));
message.setStanzaId(parser.getAttributeValue("", "id"));
message.setTo(parser.getAttributeValue("", "to"));
message.setFrom(parser.getAttributeValue("", "from"));
String typeString = parser.getAttributeValue("", "type");
@ -237,7 +237,7 @@ public class PacketParserUtils {
defaultLanguage = language;
}
else {
defaultLanguage = Packet.getDefaultLanguage();
defaultLanguage = Stanza.getDefaultLanguage();
}
// Parse sub-elements. We include extra logic to make sure the values
@ -529,7 +529,7 @@ public class PacketParserUtils {
Presence presence = new Presence(type);
presence.setTo(parser.getAttributeValue("", "to"));
presence.setFrom(parser.getAttributeValue("", "from"));
presence.setPacketID(parser.getAttributeValue("", "id"));
presence.setStanzaId(parser.getAttributeValue("", "id"));
String language = getLanguageAttribute(parser);
if (language != null && !"".equals(language.trim())) {
@ -562,7 +562,7 @@ public class PacketParserUtils {
LOGGER.warning("Empty or null mode text in presence show element form "
+ presence.getFrom()
+ " with id '"
+ presence.getPacketID()
+ presence.getStanzaId()
+ "' which is invalid according to RFC6121 4.7.2.1");
}
break;
@ -661,7 +661,7 @@ public class PacketParserUtils {
}
// Set basic values on the iq packet.
iqPacket.setPacketID(id);
iqPacket.setStanzaId(id);
iqPacket.setTo(to);
iqPacket.setFrom(from);
iqPacket.setType(type);
@ -868,7 +868,7 @@ public class PacketParserUtils {
switch (namespace) {
case XMPPError.NAMESPACE:
switch (name) {
case Packet.TEXT:
case Stanza.TEXT:
descriptiveTexts = parseDescriptiveTexts(parser, descriptiveTexts);
break;
default:
@ -1005,13 +1005,13 @@ public class PacketParserUtils {
return null;
}
public static void addPacketExtension(Packet packet, XmlPullParser parser) throws XmlPullParserException,
public static void addPacketExtension(Stanza packet, XmlPullParser parser) throws XmlPullParserException,
IOException, SmackException {
ParserUtils.assertAtStartTag(parser);
addPacketExtension(packet, parser, parser.getName(), parser.getNamespace());
}
public static void addPacketExtension(Packet packet, XmlPullParser parser, String elementName, String namespace)
public static void addPacketExtension(Stanza packet, XmlPullParser parser, String elementName, String namespace)
throws XmlPullParserException, IOException, SmackException {
PacketExtension packetExtension = parsePacketExtension(elementName, namespace, parser);
packet.addExtension(packetExtension);

View File

@ -24,7 +24,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PlainStreamElement;
import org.jivesoftware.smack.packet.TopLevelStreamElement;
@ -33,12 +33,12 @@ import org.jivesoftware.smack.packet.TopLevelStreamElement;
* unit tests.
*
* Instances store any packets that are delivered to be send using the
* {@link #sendPacket(Packet)} method in a blocking queue. The content of this queue
* {@link #sendPacket(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.
*
* Packets that should be processed by the client to simulate a received stanza
* can be delivered using the {@linkplain #processPacket(Packet)} method.
* can be delivered using the {@linkplain #processPacket(Stanza)} method.
* It invokes the registered packet interceptors and listeners.
*
* @see XMPPConnection
@ -132,7 +132,7 @@ public class DummyConnection extends AbstractXMPPConnection {
}
@Override
protected void sendPacketInternal(Packet packet) {
protected void sendPacketInternal(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(Packet)} and
* Returns the number of packets that's sent through {@link #sendPacket(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(Packet)}
* Returns the first packet that's sent through {@link #sendPacket(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(Packet)}
* Returns the first packet that's sent through {@link #sendPacket(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.
@ -184,7 +184,7 @@ public class DummyConnection extends AbstractXMPPConnection {
*
* @param packet the packet to process.
*/
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
if (SmackConfiguration.DEBUG) {
System.out.println("[RECV]: " + packet.toXML());
}

View File

@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.junit.Test;
public class PacketCollectorTest
@ -33,29 +33,29 @@ public class PacketCollectorTest
for (int i=0; i<6; i++)
{
Packet testPacket = new TestPacket(i);
Stanza testPacket = new TestPacket(i);
collector.processPacket(testPacket);
}
// Assert that '0' has rolled off
assertEquals("1", collector.nextResultBlockForever().getPacketID());
assertEquals("2", collector.nextResultBlockForever().getPacketID());
assertEquals("3", collector.nextResultBlockForever().getPacketID());
assertEquals("4", collector.nextResultBlockForever().getPacketID());
assertEquals("5", collector.pollResult().getPacketID());
assertEquals("1", collector.nextResultBlockForever().getStanzaId());
assertEquals("2", collector.nextResultBlockForever().getStanzaId());
assertEquals("3", collector.nextResultBlockForever().getStanzaId());
assertEquals("4", collector.nextResultBlockForever().getStanzaId());
assertEquals("5", collector.pollResult().getStanzaId());
assertNull(collector.pollResult());
for (int i=10; i<15; i++)
{
Packet testPacket = new TestPacket(i);
Stanza testPacket = new TestPacket(i);
collector.processPacket(testPacket);
}
assertEquals("10", collector.nextResultBlockForever().getPacketID());
assertEquals("11", collector.nextResultBlockForever().getPacketID());
assertEquals("12", collector.nextResultBlockForever().getPacketID());
assertEquals("13", collector.nextResultBlockForever().getPacketID());
assertEquals("14", collector.pollResult().getPacketID());
assertEquals("10", collector.nextResultBlockForever().getStanzaId());
assertEquals("11", collector.nextResultBlockForever().getStanzaId());
assertEquals("12", collector.nextResultBlockForever().getStanzaId());
assertEquals("13", collector.nextResultBlockForever().getStanzaId());
assertEquals("14", collector.pollResult().getStanzaId());
assertNull(collector.pollResult());
assertNull(collector.nextResult(1000));
@ -88,7 +88,7 @@ public class PacketCollectorTest
{
}
@SuppressWarnings("unused")
Packet packet = collector.nextResultBlockForever();
Stanza packet = collector.nextResultBlockForever();
// System.out.println(Thread.currentThread().getName() + " packet: " + packet);
}
}
@ -108,7 +108,7 @@ public class PacketCollectorTest
@Override
public void run()
{
Packet p = null;
Stanza p = null;
do
{
@ -132,7 +132,7 @@ public class PacketCollectorTest
@Override
public void run()
{
Packet p = null;
Stanza p = null;
do
{
@ -178,7 +178,7 @@ public class PacketCollectorTest
class OKEverything implements PacketFilter
{
@Override
public boolean accept(Packet packet)
public boolean accept(Stanza packet)
{
return true;
}
@ -193,17 +193,17 @@ public class PacketCollectorTest
}
}
class TestPacket extends Packet
class TestPacket extends Stanza
{
public TestPacket(int i)
{
setPacketID(String.valueOf(i));
setStanzaId(String.valueOf(i));
}
@Override
public String toXML()
{
return "<packetId>" + getPacketID() + "</packetId>";
return "<packetId>" + getStanzaId() + "</packetId>";
}
}
}

View File

@ -29,11 +29,11 @@ public class StanzaIdTest {
@Test
public void testIqId() {
IQ iq1 = new TestIQ();
String iq1Id = iq1.getPacketID();
String iq1Id = iq1.getStanzaId();
assertTrue(StringUtils.isNotEmpty(iq1Id));
IQ iq2 = new TestIQ();
String iq2Id = iq2.getPacketID();
String iq2Id = iq2.getStanzaId();
assertTrue(StringUtils.isNotEmpty(iq2Id));
assertFalse(iq1Id.equals(iq2Id));

View File

@ -24,7 +24,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.IQ.Type;
/**
@ -34,11 +34,11 @@ import org.jivesoftware.smack.packet.IQ.Type;
*/
public class ThreadedDummyConnection extends DummyConnection {
private BlockingQueue<IQ> replyQ = new ArrayBlockingQueue<IQ>(1);
private BlockingQueue<Packet> messageQ = new LinkedBlockingQueue<Packet>(5);
private BlockingQueue<Stanza> messageQ = new LinkedBlockingQueue<Stanza>(5);
private volatile boolean timeout = false;
@Override
public void sendPacket(Packet packet) throws NotConnectedException {
public void sendPacket(Stanza packet) throws NotConnectedException {
super.sendPacket(packet);
if (packet instanceof IQ && !timeout) {
@ -52,7 +52,7 @@ public class ThreadedDummyConnection extends DummyConnection {
replyPacket = IQ.createResultIQ((IQ) packet);
replyQ.add(replyPacket);
}
replyPacket.setPacketID(packet.getPacketID());
replyPacket.setStanzaId(packet.getStanzaId());
replyPacket.setFrom(packet.getTo());
replyPacket.setTo(packet.getFrom());
replyPacket.setType(Type.result);
@ -64,7 +64,7 @@ public class ThreadedDummyConnection extends DummyConnection {
/**
* Calling this method will cause the next sendPacket 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(Packet)}.
* or processing one that was entered via {@link #processPacket(Stanza)}.
*/
public void setTimeout() {
timeout = true;
@ -86,9 +86,9 @@ public class ThreadedDummyConnection extends DummyConnection {
}
class ProcessQueue extends Thread {
private BlockingQueue<? extends Packet> processQ;
private BlockingQueue<? extends Stanza> processQ;
ProcessQueue(BlockingQueue<? extends Packet> queue) {
ProcessQueue(BlockingQueue<? extends Stanza> queue) {
processQ = queue;
}

View File

@ -20,7 +20,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.junit.Test;
/**
@ -44,7 +44,7 @@ public class FromMatchesFilterTest {
public void autoCompareMatchingFullJid()
{
FromMatchesFilter filter = FromMatchesFilter.create(FULL_JID1_R1);
Packet packet = new Packet() {
Stanza packet = new Stanza() {
@Override
public String toXML() { return null; }
};
@ -72,7 +72,7 @@ public class FromMatchesFilterTest {
public void autoCompareMatchingBaseJid()
{
FromMatchesFilter filter = FromMatchesFilter.create(BASE_JID1);
Packet packet = new Packet() {
Stanza packet = new Stanza() {
@Override
public String toXML() { return null; }
};
@ -100,7 +100,7 @@ public class FromMatchesFilterTest {
public void autoCompareMatchingServiceJid()
{
FromMatchesFilter filter = FromMatchesFilter.create(SERVICE_JID1);
Packet packet = new Packet() {
Stanza packet = new Stanza() {
@Override
public String toXML() { return null; }
};
@ -125,7 +125,7 @@ public class FromMatchesFilterTest {
public void bareCompareMatchingFullJid()
{
FromMatchesFilter filter = FromMatchesFilter.createBare(FULL_JID1_R1);
Packet packet = new Packet() {
Stanza packet = new Stanza() {
@Override
public String toXML() { return null; }
};
@ -153,7 +153,7 @@ public class FromMatchesFilterTest {
public void bareCompareMatchingBaseJid()
{
FromMatchesFilter filter = FromMatchesFilter.createBare(BASE_JID1);
Packet packet = new Packet() {
Stanza packet = new Stanza() {
@Override
public String toXML() { return null; }
};
@ -181,7 +181,7 @@ public class FromMatchesFilterTest {
public void bareCompareMatchingServiceJid()
{
FromMatchesFilter filter = FromMatchesFilter.createBare(SERVICE_JID1);
Packet packet = new Packet() {
Stanza packet = new Stanza() {
@Override
public String toXML() { return null; }
};
@ -206,7 +206,7 @@ public class FromMatchesFilterTest {
public void fullCompareMatchingFullJid()
{
FromMatchesFilter filter = FromMatchesFilter.createFull(FULL_JID1_R1);
Packet packet = new Packet() {
Stanza packet = new Stanza() {
@Override
public String toXML() { return null; }
};
@ -234,7 +234,7 @@ public class FromMatchesFilterTest {
public void fullCompareMatchingBaseJid()
{
FromMatchesFilter filter = FromMatchesFilter.createFull(BASE_JID1);
Packet packet = new Packet() {
Stanza packet = new Stanza() {
@Override
public String toXML() { return null; }
};
@ -262,7 +262,7 @@ public class FromMatchesFilterTest {
public void fullCompareMatchingServiceJid()
{
FromMatchesFilter filter = FromMatchesFilter.createFull(SERVICE_JID1);
Packet packet = new Packet() {
Stanza packet = new Stanza() {
@Override
public String toXML() { return null; }
};

View File

@ -46,8 +46,8 @@ public class IQResponseTest {
final IQ result = IQ.createResultIQ(request);
assertEquals(IQ.Type.result, result.getType());
assertNotNull(result.getPacketID());
assertEquals(request.getPacketID(), result.getPacketID());
assertNotNull(result.getStanzaId());
assertEquals(request.getStanzaId(), result.getStanzaId());
assertEquals(request.getFrom(), result.getTo());
assertEquals(request.getTo(), result.getFrom());
assertEquals("", result.getChildElementXML().toString());
@ -68,8 +68,8 @@ public class IQResponseTest {
final IQ result = IQ.createErrorResponse(request, error);
assertEquals(IQ.Type.error, result.getType());
assertNotNull(result.getPacketID());
assertEquals(request.getPacketID(), result.getPacketID());
assertNotNull(result.getStanzaId());
assertEquals(request.getStanzaId(), result.getStanzaId());
assertEquals(request.getFrom(), result.getTo());
assertEquals(error, result.getError());
// TODO this test was never valid

View File

@ -51,7 +51,7 @@ public class MessageTest {
String control = controlBuilder.toString();
Message messageTypeInConstructor = new Message(null, Message.Type.chat);
messageTypeInConstructor.setPacketID(null);
messageTypeInConstructor.setStanzaId(null);
assertEquals(type, messageTypeInConstructor.getType());
assertXMLEqual(control, messageTypeInConstructor.toXML().toString());
@ -210,7 +210,7 @@ public class MessageTest {
private static Message getNewMessage() {
Message message = new Message();
message.setPacketID(null);
message.setStanzaId(null);
return message;
}
}

View File

@ -47,7 +47,7 @@ public class PresenceTest {
String control = controlBuilder.toString();
Presence presenceTypeInConstructor = new Presence(type);
presenceTypeInConstructor.setPacketID(null);
presenceTypeInConstructor.setStanzaId(null);
assertEquals(type, presenceTypeInConstructor.getType());
assertXMLEqual(control, presenceTypeInConstructor.toXML().toString());
@ -146,7 +146,7 @@ public class PresenceTest {
Presence presenceModeInConstructor = new Presence(Presence.Type.available, status, priority,
mode1);
presenceModeInConstructor.setPacketID(null);
presenceModeInConstructor.setStanzaId(null);
assertEquals(mode1, presenceModeInConstructor.getMode());
assertXMLEqual(control, presenceModeInConstructor.toXML().toString());
@ -194,7 +194,7 @@ public class PresenceTest {
private static Presence getNewPresence() {
Presence presence = new Presence(Presence.Type.available);
presence.setPacketID(null);
presence.setStanzaId(null);
return presence;
}
}

View File

@ -21,14 +21,14 @@ import java.util.concurrent.TimeUnit;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
public class WaitForPacketListener implements PacketListener {
private CountDownLatch latch = new CountDownLatch(1);
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
reportInvoked();
}

View File

@ -33,7 +33,7 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.sasl.SASLError;
import org.jivesoftware.smack.sasl.packet.SaslStreamElements;
@ -59,7 +59,7 @@ public class PacketParserUtilsTest {
@Test
public void singleMessageBodyTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage();
String defaultLanguage = Stanza.getDefaultLanguage();
String otherLanguage = determineNonDefaultLanguage();
String control;
@ -208,7 +208,7 @@ public class PacketParserUtilsTest {
@Test
public void singleMessageSubjectTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage();
String defaultLanguage = Stanza.getDefaultLanguage();
String otherLanguage = determineNonDefaultLanguage();
String control;
@ -357,7 +357,7 @@ public class PacketParserUtilsTest {
@Test
public void multipleMessageBodiesTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage();
String defaultLanguage = Stanza.getDefaultLanguage();
String otherLanguage = determineNonDefaultLanguage();
String control;
@ -510,7 +510,7 @@ public class PacketParserUtilsTest {
@Test
public void multipleMessageSubjectsTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage();
String defaultLanguage = Stanza.getDefaultLanguage();
String otherLanguage = determineNonDefaultLanguage();
String control;
@ -748,7 +748,7 @@ public class PacketParserUtilsTest {
.t("This is a test of the emergency broadcast system, 3.")
.asString(outputProperties);
Packet message = PacketParserUtils.parseStanza(control);
Stanza message = PacketParserUtils.parseStanza(control);
XmlUnitUtils.assertSimilar(control, message.toXML());
}

View File

@ -18,7 +18,7 @@
package org.jivesoftware.smackx.debugger.slf4j;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.slf4j.Logger;
@ -31,7 +31,7 @@ class SLF4JLoggingPacketListener implements PacketListener {
this.prefix = Validate.notNull(prefix);
}
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
if (SLF4JSmackDebugger.printInterpreted.get() && logger.isDebugEnabled()) {
logger.debug("{}: PKT [{}] '{}'", prefix, packet.getClass().getName(), packet.toXML());
}

View File

@ -25,7 +25,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.debugger.SmackDebugger;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.ObservableReader;
import org.jivesoftware.smack.util.ObservableWriter;
@ -206,7 +206,7 @@ public class EnhancedDebugger implements SmackDebugger {
packetReaderListener = new PacketListener() {
SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa");
public void processPacket(final Packet packet) {
public void processPacket(final Stanza packet) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
addReadPacketToTable(dateFormatter, packet);
@ -221,7 +221,7 @@ public class EnhancedDebugger implements SmackDebugger {
packetWriterListener = new PacketListener() {
SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa");
public void processPacket(final Packet packet) {
public void processPacket(final Stanza packet) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
addSentPacketToTable(dateFormatter, packet);
@ -791,7 +791,7 @@ public class EnhancedDebugger implements SmackDebugger {
* @param dateFormatter the SimpleDateFormat to use to format Dates
* @param packet the read packet to add to the table
*/
private void addReadPacketToTable(final SimpleDateFormat dateFormatter, final Packet packet) {
private void addReadPacketToTable(final SimpleDateFormat dateFormatter, final Stanza packet) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
String messageType;
@ -836,7 +836,7 @@ public class EnhancedDebugger implements SmackDebugger {
packetReceivedIcon,
packetTypeIcon,
messageType,
packet.getPacketID(),
packet.getStanzaId(),
type,
"",
from});
@ -852,7 +852,7 @@ public class EnhancedDebugger implements SmackDebugger {
* @param dateFormatter the SimpleDateFormat to use to format Dates
* @param packet the sent packet to add to the table
*/
private void addSentPacketToTable(final SimpleDateFormat dateFormatter, final Packet packet) {
private void addSentPacketToTable(final SimpleDateFormat dateFormatter, final Stanza packet) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
String messageType;
@ -897,7 +897,7 @@ public class EnhancedDebugger implements SmackDebugger {
packetSentIcon,
packetTypeIcon,
messageType,
packet.getPacketID(),
packet.getStanzaId(),
type,
to,
""});
@ -970,7 +970,7 @@ public class EnhancedDebugger implements SmackDebugger {
* The whole text to send must be passed to the constructor. This implies that the client of
* this class is responsible for sending a valid text to the constructor.
*/
private class AdHocPacket extends Packet {
private class AdHocPacket extends Stanza {
private String text;

View File

@ -43,7 +43,7 @@ import javax.swing.JTextArea;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.debugger.SmackDebugger;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.ObservableReader;
import org.jivesoftware.smack.util.ObservableWriter;
import org.jivesoftware.smack.util.ReaderListener;
@ -262,7 +262,7 @@ public class LiteDebugger implements SmackDebugger {
// 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() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
interpretedText1.append(packet.toXML().toString());
interpretedText2.append(packet.toXML().toString());
interpretedText1.append(NEWLINE);

View File

@ -31,7 +31,7 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.carbons.packet.CarbonExtension;
import org.jivesoftware.smackx.carbons.packet.Carbon;
import org.jivesoftware.smackx.carbons.packet.CarbonExtension.Private;
@ -120,7 +120,7 @@ public class CarbonManager extends Manager {
IQ setIQ = carbonsEnabledIQ(new_state);
connection().sendIqWithResponseCallback(setIQ, new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
enabled_state = new_state;
}
});

View File

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.gcm.packet;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.json.packet.AbstractJsonPacketExtension;
/**
@ -53,7 +53,7 @@ public class GcmPacketExtension extends AbstractJsonPacketExtension {
* @param packet
* @return the GCM packet extension or null.
*/
public static GcmPacketExtension from(Packet packet) {
public static GcmPacketExtension from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
}
}

View File

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.json.packet;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
/**
* XMPP JSON Containers as defined in XEP-0335
@ -48,7 +48,7 @@ public class JsonPacketExtension extends AbstractJsonPacketExtension {
* @param packet
* @return the JSON packet extension or null.
*/
public static JsonPacketExtension from(Packet packet) {
public static JsonPacketExtension from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
}
}

View File

@ -59,7 +59,7 @@ public class CompressionTest extends SmackTestCase {
version.setTo(getServiceName());
// Create a packet collector to listen for a response.
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(version.getPacketID()));
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(version.getStanzaId()));
connection.sendPacket(version);

View File

@ -212,9 +212,9 @@ public class MessageEventManagerTest extends SmackTestCase {
// Send the message that contains the notifications request
try {
chat1.sendMessage(msg);
messageEventManager2.sendDisplayedNotification(getBareJID(0), msg.getPacketID());
messageEventManager2.sendComposingNotification(getBareJID(0), msg.getPacketID());
messageEventManager2.sendCancelledNotification(getBareJID(0), msg.getPacketID());
messageEventManager2.sendDisplayedNotification(getBareJID(0), msg.getStanzaId());
messageEventManager2.sendComposingNotification(getBareJID(0), msg.getStanzaId());
messageEventManager2.sendCancelledNotification(getBareJID(0), msg.getStanzaId());
// Wait up to 2 seconds
long initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 &&

View File

@ -45,7 +45,7 @@ public class VersionTest extends SmackTestCase {
version.setTo(getServiceName());
// Create a packet collector to listen for a response.
PacketCollector collector = getConnection(0).createPacketCollector(new PacketIDFilter(version.getPacketID()));
PacketCollector collector = getConnection(0).createPacketCollector(new PacketIDFilter(version.getStanzaId()));
getConnection(0).sendPacket(version);

View File

@ -62,7 +62,7 @@ public class InBandBytestreamTest extends SmackTestCase {
open.setTo(targetConnection.getUser());
PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
open.getPacketID()));
open.getStanzaId()));
initiatorConnection.sendPacket(open);
Packet result = collector.nextResult();

View File

@ -83,7 +83,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
bytestreamInitiation.addStreamHost("proxy.localhost", "127.0.0.1", 7777);
PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
bytestreamInitiation.getPacketID()));
bytestreamInitiation.getStanzaId()));
initiatorConnection.sendPacket(bytestreamInitiation);
Packet result = collector.nextResult();

View File

@ -24,7 +24,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -65,7 +65,7 @@ public class MultipleRecipientManager {
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public static void send(XMPPConnection connection, Packet packet, Collection<String> to, Collection<String> cc, Collection<String> bcc) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException
public static void send(XMPPConnection connection, Stanza packet, Collection<String> to, Collection<String> cc, Collection<String> bcc) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException
{
send(connection, packet, to, cc, bcc, null, null, false);
}
@ -94,7 +94,7 @@ public class MultipleRecipientManager {
* server does not support them.
* @throws NotConnectedException
*/
public static void send(XMPPConnection connection, Packet packet, Collection<String> to, Collection<String> cc, Collection<String> bcc,
public static void send(XMPPConnection connection, Stanza packet, Collection<String> to, Collection<String> cc, Collection<String> bcc,
String replyTo, String replyRoom, boolean noReply) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException {
// Check if *only* 'to' is set and contains just *one* entry, in this case extended stanzas addressing is not
// required at all and we can send it just as normal stanza without needing to add the extension element
@ -192,13 +192,13 @@ public class MultipleRecipientManager {
* @return the MultipleRecipientInfo contained in the specified packet or <tt>null</tt>
* if none was found.
*/
public static MultipleRecipientInfo getMultipleRecipientInfo(Packet packet) {
public static MultipleRecipientInfo getMultipleRecipientInfo(Stanza packet) {
MultipleAddresses extension = (MultipleAddresses) packet
.getExtension(MultipleAddresses.ELEMENT, MultipleAddresses.NAMESPACE);
return extension == null ? null : new MultipleRecipientInfo(extension);
}
private static void sendToIndividualRecipients(XMPPConnection connection, Packet packet,
private static void sendToIndividualRecipients(XMPPConnection connection, Stanza packet,
Collection<String> to, Collection<String> cc, Collection<String> bcc) throws NotConnectedException {
if (to != null) {
for (String jid : to) {
@ -220,7 +220,7 @@ public class MultipleRecipientManager {
}
}
private static void sendThroughService(XMPPConnection connection, Packet packet, Collection<String> to,
private static void sendThroughService(XMPPConnection connection, Stanza packet, Collection<String> to,
Collection<String> cc, Collection<String> bcc, String replyTo, String replyRoom, boolean noReply,
String serviceAddress) throws NotConnectedException {
// Create multiple recipient extension
@ -289,7 +289,7 @@ public class MultipleRecipientManager {
* (i.e. cannot change the TO address of a queues packet to be sent) then this class was
* created to keep the XML stanza to send.
*/
private static class PacketCopy extends Packet {
private static class PacketCopy extends Stanza {
private CharSequence text;

View File

@ -21,7 +21,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
/**
@ -56,7 +56,7 @@ class DataListener implements PacketListener {
this.manager = manager;
}
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
Data data = (Data) packet;
InBandBytestreamSession ibbSession = this.manager.getSessions().get(
data.getDataPacketExtension().getSessionID());

View File

@ -32,7 +32,7 @@ import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
@ -447,7 +447,7 @@ public class InBandBytestreamSession implements BytestreamSession {
private long lastSequence = -1;
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
// get data packet extension
DataPacketExtension data = ((Data) packet).getDataPacketExtension();
@ -508,7 +508,7 @@ public class InBandBytestreamSession implements BytestreamSession {
protected PacketListener getDataPacketListener() {
return new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
// get data packet extension
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
DataPacketExtension.ELEMENT,
@ -553,7 +553,7 @@ public class InBandBytestreamSession implements BytestreamSession {
*/
private class IBBDataPacketFilter implements PacketFilter {
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
// sender equals remote peer
if (!packet.getFrom().equalsIgnoreCase(remoteJID)) {
return false;

View File

@ -24,7 +24,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
@ -77,7 +77,7 @@ class InitiationListener extends AbstractIqRequestHandler {
return null;
}
private void processRequest(Packet packet) throws NotConnectedException {
private void processRequest(Stanza packet) throws NotConnectedException {
Open ibbRequest = (Open) packet;
// validate that block size is within allowed range

View File

@ -24,7 +24,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
@ -74,7 +74,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
return null;
}
private void processRequest(Packet packet) throws NotConnectedException {
private void processRequest(Stanza packet) throws NotConnectedException {
Bytestream byteStreamRequest = (Bytestream) packet;
// ignore request if in ignore list

View File

@ -39,7 +39,7 @@ import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
import org.jivesoftware.smackx.bytestreams.BytestreamManager;
@ -480,7 +480,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
Bytestream initiation = createBytestreamInitiation(sessionID, targetJID, streamHosts);
// send initiation packet
Packet response = connection.createPacketCollectorAndSend(initiation).nextResultOrThrow(
Stanza response = connection.createPacketCollectorAndSend(initiation).nextResultOrThrow(
getTargetResponseTimeout());
// extract used stream host from response

View File

@ -296,7 +296,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
Bytestream response = new Bytestream(this.bytestreamRequest.getSessionID());
response.setTo(this.bytestreamRequest.getFrom());
response.setType(IQ.Type.result);
response.setPacketID(this.bytestreamRequest.getPacketID());
response.setStanzaId(this.bytestreamRequest.getStanzaId());
response.setUsedHost(selectedHost.getJID());
return response;
}

View File

@ -26,7 +26,7 @@ import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.filter.NotFilter;
@ -315,7 +315,7 @@ public class EntityCapsManager extends Manager {
// Listen for remote presence stanzas with the caps extension
// If we receive such a stanza, record the JID and nodeVer
@Override
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
if (!entityCapsEnabled())
return;
@ -328,7 +328,7 @@ public class EntityCapsManager extends Manager {
connection.addAsyncPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
// always remove the JID from the map, even if entityCaps are
// disabled
String from = packet.getFrom();
@ -338,7 +338,7 @@ public class EntityCapsManager extends Manager {
connection.addPacketSendingListener(new PacketListener() {
@Override
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
presenceSend = true;
}
}, PRESENCES);
@ -347,7 +347,7 @@ public class EntityCapsManager extends Manager {
// XEP-0115 specifies that a client SHOULD include entity capabilities
// with every presence notification it sends.
PacketListener packetInterceptor = new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
if (!entityCapsEnabled)
return;
CapsVersionAndHash capsVersionAndHash = getCapsVersion();

View File

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.caps.packet;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -72,7 +72,7 @@ public class CapsExtension implements PacketExtension {
return xml;
}
public static CapsExtension from(Packet stanza) {
public static CapsExtension from(Stanza stanza) {
return stanza.getExtension(ELEMENT, NAMESPACE);
}
}

View File

@ -323,7 +323,7 @@ public class AdHocCommandManager extends Manager {
// Creates the response with the corresponding data
AdHocCommandData response = new AdHocCommandData();
response.setTo(requestData.getFrom());
response.setPacketID(requestData.getPacketID());
response.setStanzaId(requestData.getStanzaId());
response.setNode(requestData.getNode());
response.setId(requestData.getTo());

View File

@ -18,7 +18,7 @@ package org.jivesoftware.smackx.delay;
import java.util.Date;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.delay.packet.DelayInformation;
@ -38,24 +38,24 @@ public class DelayInformationManager {
/**
* Get Delayed Delivery information as defined in XEP-203
* <p>
* Prefer {@link #getDelayInformation(Packet)} over this method for backwards compatibility.
* Prefer {@link #getDelayInformation(Stanza)} over this method for backwards compatibility.
* </p>
* @param packet
* @return the Delayed Delivery information or <code>null</code>
*/
public static DelayInformation getXep203DelayInformation(Packet packet) {
public static DelayInformation getXep203DelayInformation(Stanza packet) {
return DelayInformation.from(packet);
}
/**
* Get Delayed Delivery information as defined in XEP-91
* <p>
* Prefer {@link #getDelayInformation(Packet)} over this method for backwards compatibility.
* Prefer {@link #getDelayInformation(Stanza)} over this method for backwards compatibility.
* </p>
* @param packet
* @return the Delayed Delivery information or <code>null</code>
*/
public static DelayInformation getLegacyDelayInformation(Packet packet) {
public static DelayInformation getLegacyDelayInformation(Stanza packet) {
return packet.getExtension(LEGACY_DELAYED_DELIVERY_ELEMENT, LEGACY_DELAYED_DELIVERY_NAMESPACE);
}
@ -66,7 +66,7 @@ public class DelayInformationManager {
* @param packet
* @return the Delayed Delivery information or <code>null</code>
*/
public static DelayInformation getDelayInformation(Packet packet) {
public static DelayInformation getDelayInformation(Stanza packet) {
DelayInformation delayInformation = getXep203DelayInformation(packet);
if (delayInformation != null) {
return delayInformation;
@ -80,7 +80,7 @@ public class DelayInformationManager {
* @param packet
* @return the Delayed Delivery timestamp or <code>null</code>
*/
public static Date getDelayTimestamp(Packet packet) {
public static Date getDelayTimestamp(Stanza packet) {
DelayInformation delayInformation = getDelayInformation(packet);
if (delayInformation == null) {
return null;
@ -94,7 +94,7 @@ public class DelayInformationManager {
* @param packet
* @return true if the stanza got delayed.
*/
public static boolean isDelayedStanza(Packet packet) {
public static boolean isDelayedStanza(Stanza packet) {
PacketExtension packetExtension = getDelayInformation(packet);
return packetExtension != null;
}

View File

@ -18,7 +18,7 @@ package org.jivesoftware.smackx.delay.filter;
import org.jivesoftware.smack.filter.NotFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.delay.DelayInformationManager;
/**
@ -37,7 +37,7 @@ public class DelayedStanzaFilter implements PacketFilter {
}
@Override
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
return DelayInformationManager.isDelayedStanza(packet);
}

View File

@ -18,7 +18,7 @@ package org.jivesoftware.smackx.delay.packet;
import java.util.Date;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.util.XmppDateTime;
@ -111,10 +111,10 @@ public class DelayInformation implements PacketExtension {
*
* @param packet
* @return the DelayInformation or null
* @deprecated use {@link #from(Packet)} instead
* @deprecated use {@link #from(Stanza)} instead
*/
@Deprecated
public static DelayInformation getFrom(Packet packet) {
public static DelayInformation getFrom(Stanza packet) {
return from(packet);
}
@ -123,7 +123,7 @@ public class DelayInformation implements PacketExtension {
* @param packet
* @return the DelayInformation or null
*/
public static DelayInformation from(Packet packet) {
public static DelayInformation from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
}
}

View File

@ -26,7 +26,7 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.caps.EntityCapsManager;
@ -123,7 +123,7 @@ public class ServiceDiscoveryManager extends Manager {
DiscoverItems response = new DiscoverItems();
response.setType(IQ.Type.result);
response.setTo(discoverItems.getFrom());
response.setPacketID(discoverItems.getPacketID());
response.setStanzaId(discoverItems.getStanzaId());
response.setNode(discoverItems.getNode());
// Add the defined items related to the requested node. Look for
@ -154,7 +154,7 @@ public class ServiceDiscoveryManager extends Manager {
DiscoverInfo response = new DiscoverInfo();
response.setType(IQ.Type.result);
response.setTo(discoverInfo.getFrom());
response.setPacketID(discoverInfo.getPacketID());
response.setStanzaId(discoverInfo.getStanzaId());
response.setNode(discoverInfo.getNode());
// Add the client's identity and features only if "node" is null
// and if the request was not send to a node. If Entity Caps are
@ -528,7 +528,7 @@ public class ServiceDiscoveryManager extends Manager {
disco.setTo(entityID);
disco.setNode(node);
Packet result = connection().createPacketCollectorAndSend(disco).nextResultOrThrow();
Stanza result = connection().createPacketCollectorAndSend(disco).nextResultOrThrow();
return (DiscoverInfo) result;
}
@ -565,7 +565,7 @@ public class ServiceDiscoveryManager extends Manager {
disco.setTo(entityID);
disco.setNode(node);
Packet result = connection().createPacketCollectorAndSend(disco).nextResultOrThrow();
Stanza result = connection().createPacketCollectorAndSend(disco).nextResultOrThrow();
return (DiscoverItems) result;
}

View File

@ -37,7 +37,7 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.si.packet.StreamInitiation;
@ -69,12 +69,12 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
return new OrFilter(primaryFilter, secondaryFilter);
}
InputStream negotiateIncomingStream(Packet streamInitiation) {
InputStream negotiateIncomingStream(Stanza streamInitiation) {
throw new UnsupportedOperationException("Negotiation only handled by create incoming " +
"stream method.");
}
final Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) {
final Stanza initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) {
throw new UnsupportedOperationException("Initiation handled by createIncomingStream " +
"method");
}
@ -139,7 +139,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
return stream;
}
private StreamNegotiator determineNegotiator(Packet streamInitiation) {
private StreamNegotiator determineNegotiator(Stanza streamInitiation) {
return primaryFilter.accept(streamInitiation) ? primaryNegotiator : secondaryNegotiator;
}
@ -176,7 +176,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
}
public InputStream call() throws XMPPErrorException, InterruptedException, SmackException {
Packet streamInitiation = collector.nextResult();
Stanza streamInitiation = collector.nextResult();
if (streamInitiation == null) {
throw new NoResponseException(connection);
}

View File

@ -32,7 +32,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
@ -317,7 +317,7 @@ public class FileTransferNegotiator extends Manager {
si.setTo(userID);
si.setType(IQ.Type.set);
Packet siResponse = connection().createPacketCollectorAndSend(si).nextResultOrThrow(
Stanza siResponse = connection().createPacketCollectorAndSend(si).nextResultOrThrow(
responseTimeout);
if (siResponse instanceof IQ) {

View File

@ -28,7 +28,7 @@ import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession;
@ -77,7 +77,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
*/
this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());
Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
Stanza streamInitiation = initiateIncomingStream(this.connection, initiation);
return negotiateIncomingStream(streamInitiation);
}
@ -96,7 +96,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
return new String[] { DataPacketExtension.NAMESPACE };
}
InputStream negotiateIncomingStream(Packet streamInitiation) throws NotConnectedException {
InputStream negotiateIncomingStream(Stanza streamInitiation) throws NotConnectedException {
// build In-Band Bytestream request
InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
(Open) streamInitiation);
@ -123,7 +123,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
this.sessionID = sessionID;
}
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
if (super.accept(packet)) {
Open bytestream = (Open) packet;

View File

@ -31,7 +31,7 @@ import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession;
@ -79,7 +79,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
*/
this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());
Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
Stanza streamInitiation = initiateIncomingStream(this.connection, initiation);
return negotiateIncomingStream(streamInitiation);
}
@ -101,7 +101,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
}
@Override
InputStream negotiateIncomingStream(Packet streamInitiation) throws InterruptedException,
InputStream negotiateIncomingStream(Stanza streamInitiation) throws InterruptedException,
SmackException, XMPPErrorException {
// build SOCKS5 Bytestream request
Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
@ -138,7 +138,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
}
@Override
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
if (super.accept(packet)) {
Bytestream bytestream = (Bytestream) packet;

View File

@ -25,7 +25,7 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.si.packet.StreamInitiation;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
@ -58,7 +58,7 @@ public abstract class StreamNegotiator {
response.setTo(streamInitiationOffer.getFrom());
response.setFrom(streamInitiationOffer.getTo());
response.setType(IQ.Type.result);
response.setPacketID(streamInitiationOffer.getPacketID());
response.setStanzaId(streamInitiationOffer.getStanzaId());
DataForm form = new DataForm(DataForm.Type.submit);
FormField field = new FormField(
@ -72,7 +72,7 @@ public abstract class StreamNegotiator {
return response;
}
Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException, NotConnectedException {
Stanza initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException, NotConnectedException {
StreamInitiation response = createInitiationAccept(initiation,
getNamespaces());
@ -80,7 +80,7 @@ public abstract class StreamNegotiator {
PacketCollector collector = connection
.createPacketCollectorAndSend(getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()), response);
Packet streamMethodInitiation = collector.nextResultOrThrow();
Stanza streamMethodInitiation = collector.nextResultOrThrow();
return streamMethodInitiation;
}
@ -97,7 +97,7 @@ public abstract class StreamNegotiator {
public abstract PacketFilter getInitiationPacketFilter(String from, String streamID);
abstract InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPErrorException,
abstract InputStream negotiateIncomingStream(Stanza streamInitiation) throws XMPPErrorException,
InterruptedException, NoResponseException, SmackException;
/**

View File

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.forward.packet;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.delay.packet.DelayInformation;
@ -32,7 +32,7 @@ public class Forwarded implements PacketExtension {
public static final String ELEMENT = "forwarded";
private final DelayInformation delay;
private final Packet forwardedPacket;
private final Stanza forwardedPacket;
/**
* Creates a new Forwarded packet extension.
@ -40,7 +40,7 @@ public class Forwarded implements PacketExtension {
* @param delay an optional {@link DelayInformation} timestamp of the packet.
* @param fwdPacket the packet that is forwarded (required).
*/
public Forwarded(DelayInformation delay, Packet fwdPacket) {
public Forwarded(DelayInformation delay, Stanza fwdPacket) {
this.delay = delay;
this.forwardedPacket = fwdPacket;
}
@ -50,7 +50,7 @@ public class Forwarded implements PacketExtension {
*
* @param fwdPacket the packet that is forwarded (required).
*/
public Forwarded(Packet fwdPacket) {
public Forwarded(Stanza fwdPacket) {
this(null, fwdPacket);
}
@ -77,9 +77,9 @@ public class Forwarded implements PacketExtension {
/**
* get the packet forwarded by this stanza.
*
* @return the {@link Packet} instance (typically a message) that was forwarded.
* @return the {@link Stanza} instance (typically a message) that was forwarded.
*/
public Packet getForwardedPacket() {
public Stanza getForwardedPacket() {
return forwardedPacket;
}
@ -97,7 +97,7 @@ public class Forwarded implements PacketExtension {
* @param packet
* @return the Forwarded extension or null
*/
public static Forwarded from(Packet packet) {
public static Forwarded from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
}
}

View File

@ -21,7 +21,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.delay.packet.DelayInformation;
@ -43,7 +43,7 @@ public class ForwardedProvider extends PacketExtensionProvider<Forwarded> {
@Override
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
DelayInformation di = null;
Packet packet = null;
Stanza packet = null;
outerloop: while (true) {
int eventType = parser.next();

View File

@ -34,7 +34,7 @@ import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.packet.XMPPError.Condition;
@ -135,7 +135,7 @@ public class LastActivityManager extends Manager {
// Listen to all the sent messages to reset the idle time on each one
connection.addPacketSendingListener(new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
Presence presence = (Presence) packet;
Presence.Mode mode = presence.getMode();
if (mode == null) return;
@ -153,7 +153,7 @@ public class LastActivityManager extends Manager {
connection.addPacketSendingListener(new PacketListener() {
@Override
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
Message message = (Message) packet;
// if it's not an error message, reset the idle time
if (message.getType() == Message.Type.error) return;
@ -172,7 +172,7 @@ public class LastActivityManager extends Manager {
message.setType(IQ.Type.result);
message.setTo(iqRequest.getFrom());
message.setFrom(iqRequest.getTo());
message.setPacketID(iqRequest.getPacketID());
message.setStanzaId(iqRequest.getStanzaId());
message.setLastActivity(getIdleTime());
return message;

View File

@ -290,7 +290,7 @@ public class AccountManager extends Manager {
}
private PacketCollector createPacketCollectorAndSend(IQ req) throws NotConnectedException {
PacketCollector collector = connection().createPacketCollectorAndSend(new PacketIDFilter(req.getPacketID()), req);
PacketCollector collector = connection().createPacketCollectorAndSend(new PacketIDFilter(req.getStanzaId()), req);
return collector;
}
}

View File

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.iqversion.packet;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.StringUtils;
/**
@ -35,7 +35,7 @@ import org.jivesoftware.smack.util.StringUtils;
*
* // Create a packet collector to listen for a response.
* PacketCollector collector = con.createPacketCollector(
* new PacketIDFilter(versionRequest.getPacketID()));
* new PacketIDFilter(versionRequest.getStanzaId()));
*
* con.sendPacket(versionRequest);
*
@ -147,9 +147,9 @@ public class Version extends IQ {
return xml;
}
public static Version createResultFor(Packet request, Version version) {
public static Version createResultFor(Stanza request, Version version) {
Version result = new Version(version);
result.setPacketID(request.getPacketID());
result.setStanzaId(request.getStanzaId());
result.setTo(request.getFrom());
return result;
}

View File

@ -20,7 +20,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.jiveproperties.packet.JivePropertiesExtension;
public class JivePropertiesManager {
@ -53,7 +53,7 @@ public class JivePropertiesManager {
* @param name the name of the property to add.
* @param value the value of the property to add.
*/
public static void addProperty(Packet packet, String name, Object value) {
public static void addProperty(Stanza packet, String name, Object value) {
JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.NAMESPACE);
if (jpe == null) {
jpe = new JivePropertiesExtension();
@ -70,7 +70,7 @@ public class JivePropertiesManager {
* @param name
* @return the property or <tt>null</tt> if none found.
*/
public static Object getProperty(Packet packet, String name) {
public static Object getProperty(Stanza packet, String name) {
Object res = null;
JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.NAMESPACE);
if (jpe != null) {
@ -86,7 +86,7 @@ public class JivePropertiesManager {
* @param packet
* @return a collection of the names of all properties.
*/
public static Collection<String> getPropertiesNames(Packet packet) {
public static Collection<String> getPropertiesNames(Stanza packet) {
JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.NAMESPACE);
if (jpe == null) {
return Collections.emptyList();
@ -101,7 +101,7 @@ public class JivePropertiesManager {
* @param packet
* @return a map of all properties of the given packet.
*/
public static Map<String, Object> getProperties(Packet packet) {
public static Map<String, Object> getProperties(Stanza packet) {
JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.NAMESPACE);
if (jpe == null) {
return Collections.emptyMap();

View File

@ -53,7 +53,7 @@ import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.filter.ToFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -136,7 +136,7 @@ public class MultiUserChat {
messageListener = new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
Message message = (Message) packet;
for (MessageListener listener : messageListeners) {
listener.processMessage(message);
@ -146,7 +146,7 @@ public class MultiUserChat {
// Create a listener for subject updates.
subjectListener = new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
Message msg = (Message) packet;
// Update the room subject
subject = msg.getSubject();
@ -159,7 +159,7 @@ public class MultiUserChat {
// Create a listener for all presence updates.
presenceListener = new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
Presence presence = (Presence) packet;
String from = presence.getFrom();
String myRoomJID = MultiUserChat.this.room + "/" + nickname;
@ -225,7 +225,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() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
// Get the MUC User extension
MUCUser mucUser = MUCUser.from(packet);
// Check if the MUCUser informs that the invitee has declined the invitation
@ -239,7 +239,7 @@ public class MultiUserChat {
presenceInterceptor = new PacketListener() {
@Override
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
Presence presence = (Presence) packet;
for (PresenceListener interceptor : presenceInterceptors) {
interceptor.processPresence(presence);
@ -1709,7 +1709,7 @@ public class MultiUserChat {
// Wait for an error or confirmation message back from the server.
PacketFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new PacketFilter() {
@Override
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
Message msg = (Message) packet;
return subject.equals(msg.getSubject());
}

View File

@ -42,7 +42,7 @@ import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.NotFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.disco.AbstractNodeInformationProvider;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
@ -118,7 +118,7 @@ public class MultiUserChatManager extends Manager {
// Listens for all messages that include a MUCUser extension and fire the invitation
// listeners if the message includes an invitation.
PacketListener invitationPacketListener = new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
final Message message = (Message) packet;
// Get the MUCUser extension
final MUCUser mucUser = MUCUser.from(message);

View File

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.muc.packet;
import java.io.IOException;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -112,10 +112,10 @@ public class GroupChatInvitation implements PacketExtension {
*
* @param packet
* @return the GroupChatInvitation or null
* @deprecated use {@link #from(Packet)} instead
* @deprecated use {@link #from(Stanza)} instead
*/
@Deprecated
public static GroupChatInvitation getFrom(Packet packet) {
public static GroupChatInvitation getFrom(Stanza packet) {
return from(packet);
}
@ -124,7 +124,7 @@ public class GroupChatInvitation implements PacketExtension {
* @param packet
* @return the GroupChatInvitation or null
*/
public static GroupChatInvitation from(Packet packet) {
public static GroupChatInvitation from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
}

View File

@ -18,7 +18,7 @@
package org.jivesoftware.smackx.muc.packet;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.util.XmppDateTime;
@ -108,10 +108,10 @@ public class MUCInitialPresence implements PacketExtension {
*
* @param packet
* @return the MUCInitialPresence PacketExtension or {@code null}
* @deprecated use {@link #from(Packet)} instead
* @deprecated use {@link #from(Stanza)} instead
*/
@Deprecated
public static MUCInitialPresence getFrom(Packet packet) {
public static MUCInitialPresence getFrom(Stanza packet) {
return from(packet);
}
@ -121,7 +121,7 @@ public class MUCInitialPresence implements PacketExtension {
* @param packet
* @return the MUCInitialPresence PacketExtension or {@code null}
*/
public static MUCInitialPresence from(Packet packet) {
public static MUCInitialPresence from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
}

View File

@ -18,7 +18,7 @@
package org.jivesoftware.smackx.muc.packet;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import java.util.HashMap;
import java.util.HashSet;
@ -204,10 +204,10 @@ public class MUCUser implements PacketExtension {
*
* @param packet
* @return the MUCUser PacketExtension or {@code null}
* @deprecated use {@link #from(Packet)} instead
* @deprecated use {@link #from(Stanza)} instead
*/
@Deprecated
public static MUCUser getFrom(Packet packet) {
public static MUCUser getFrom(Stanza packet) {
return from(packet);
}
@ -217,7 +217,7 @@ public class MUCUser implements PacketExtension {
* @param packet
* @return the MUCUser PacketExtension or {@code null}
*/
public static MUCUser from(Packet packet) {
public static MUCUser from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
}

View File

@ -27,7 +27,7 @@ import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
@ -147,7 +147,7 @@ public class OfflineMessageManager {
}
// Filter offline messages that were requested by this request
PacketFilter messageFilter = new AndFilter(PACKET_FILTER, new PacketFilter() {
public boolean accept(Packet packet) {
public boolean accept(Stanza packet) {
OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
namespace);
return nodes.contains(info.getNode());

View File

@ -26,7 +26,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.pep.packet.PEPEvent;
import org.jivesoftware.smackx.pep.packet.PEPItem;
@ -135,7 +135,7 @@ public class PEPManager {
private void init() {
// Listens for all roster exchange packets and fire the roster exchange listeners.
packetListener = new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
Message message = (Message) packet;
PEPEvent event = (PEPEvent) message.getExtension("event", "http://jabber.org/protocol/pubsub#event");
// Fire event for roster exchange listeners

View File

@ -40,7 +40,7 @@ import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.privacy.filter.SetActiveListFilter;
import org.jivesoftware.smackx.privacy.filter.SetDefaultListFilter;
@ -125,7 +125,7 @@ public class PrivacyListManager extends Manager {
// cached(Active|Default)ListName handling
connection.addPacketSendingListener(new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
XMPPConnection connection = connection();
Privacy privacy = (Privacy) packet;
PacketFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection);
@ -133,7 +133,7 @@ public class PrivacyListManager extends Manager {
final boolean declinceActiveList = privacy.isDeclineActiveList();
connection.addOneTimeSyncCallback(new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
if (declinceActiveList) {
cachedActiveListName = null;
}
@ -147,7 +147,7 @@ public class PrivacyListManager extends Manager {
}, SetActiveListFilter.INSTANCE);
connection.addPacketSendingListener(new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
XMPPConnection connection = connection();
Privacy privacy = (Privacy) packet;
PacketFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection);
@ -155,7 +155,7 @@ public class PrivacyListManager extends Manager {
final boolean declinceDefaultList = privacy.isDeclineDefaultList();
connection.addOneTimeSyncCallback(new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
if (declinceDefaultList) {
cachedDefaultListName = null;
}
@ -169,7 +169,7 @@ public class PrivacyListManager extends Manager {
}, SetDefaultListFilter.INSTANCE);
connection.addSyncPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
Privacy privacy = (Privacy) packet;
// If a privacy IQ result stanza has an active or default list name set, then we use that
// as cached list name.
@ -243,7 +243,7 @@ public class PrivacyListManager extends Manager {
* @throws NoResponseException
* @throws NotConnectedException
*/
private Packet setRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException, NotConnectedException {
private Stanza setRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request is a get iq type
requestPrivacy.setType(Privacy.Type.set);

View File

@ -18,14 +18,14 @@ package org.jivesoftware.smackx.pubsub;
import java.util.List;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.PacketParserUtils;
/**
* This interface defines {@link PacketExtension} implementations that contain other
* extensions. This effectively extends the idea of an extension within one of the
* top level {@link Packet} types to consider any embedded element to be an extension
* 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
* utilities such as {@link PacketParserUtils#parsePacketExtension(String, String, org.xmlpull.v1.XmlPullParser)} to be used
* to parse any element of the XML being parsed.

View File

@ -29,7 +29,7 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.delay.DelayInformationManager;
@ -100,7 +100,7 @@ abstract public class Node
{
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(
PubSubElementType.CONFIGURE_OWNER, getId()), PubSubNamespace.OWNER);
Packet reply = sendPubsubPacket(pubSub);
Stanza reply = sendPubsubPacket(pubSub);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
}
@ -492,7 +492,7 @@ abstract public class Node
}
private static List<String> getSubscriptionIds(Packet packet)
private static List<String> getSubscriptionIds(Stanza packet)
{
HeadersExtension headers = (HeadersExtension)packet.getExtension("headers", "http://jabber.org/protocol/shim");
List<String> values = null;
@ -526,7 +526,7 @@ abstract public class Node
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void processPacket(Packet packet)
public void processPacket(Stanza packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
@ -550,7 +550,7 @@ abstract public class Node
listener = eventListener;
}
public void processPacket(Packet packet)
public void processPacket(Stanza packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
@ -593,7 +593,7 @@ abstract public class Node
listener = eventListener;
}
public void processPacket(Packet packet)
public void processPacket(Stanza packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
ConfigurationEvent config = (ConfigurationEvent)event.getEvent();
@ -624,7 +624,7 @@ abstract public class Node
secondElement = secondLevelElement;
}
public boolean accept(Packet packet)
public boolean accept(Stanza packet)
{
if (!(packet instanceof Message))
return false;

View File

@ -28,7 +28,7 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.EmptyResultIQ;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
@ -233,7 +233,7 @@ final public class PubSubManager
*/
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException
{
Packet reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
return subElem.getSubscriptions();
}

View File

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.pubsub.util;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.pubsub.ConfigureForm;
import org.jivesoftware.smackx.pubsub.FormNode;
import org.jivesoftware.smackx.pubsub.PubSubElementType;
@ -36,7 +36,7 @@ public class NodeUtils
* @param elem
* @return The configuration form
*/
public static ConfigureForm getFormFromPacket(Packet packet, PubSubElementType elem)
public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem)
{
FormNode config = packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
Form formReply = config.getForm();

View File

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.receipts;
import java.util.List;
import java.util.Map;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -76,10 +76,10 @@ public class DeliveryReceipt implements PacketExtension
*
* @param p the packet
* @return the {@link DeliveryReceipt} extension or {@code null}
* @deprecated use {@link #from(Packet)} instead
* @deprecated use {@link #from(Stanza)} instead
*/
@Deprecated
public static DeliveryReceipt getFrom(Packet p) {
public static DeliveryReceipt getFrom(Stanza p) {
return from(p);
}
@ -89,7 +89,7 @@ public class DeliveryReceipt implements PacketExtension
* @param packet the packet
* @return the {@link DeliveryReceipt} extension or {@code null}
*/
public static DeliveryReceipt from(Packet packet) {
public static DeliveryReceipt from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
}

View File

@ -35,7 +35,7 @@ import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.roster.Roster;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -129,7 +129,7 @@ public class DeliveryReceiptManager extends Manager {
// Add the packet listener to handling incoming delivery receipts
connection.addAsyncPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
DeliveryReceipt dr = DeliveryReceipt.from(packet);
// notify listeners of incoming receipt
for (ReceiptReceivedListener l : receiptReceivedListeners) {
@ -141,7 +141,7 @@ public class DeliveryReceiptManager extends Manager {
// Add the packet listener to handle incoming delivery receipt requests
connection.addAsyncPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
final String from = packet.getFrom();
final XMPPConnection connection = connection();
switch (autoReceiptMode) {
@ -157,7 +157,7 @@ public class DeliveryReceiptManager extends Manager {
}
Message ack = new Message(from, Message.Type.normal);
ack.addExtension(new DeliveryReceipt(packet.getPacketID()));
ack.addExtension(new DeliveryReceipt(packet.getStanzaId()));
connection.sendPacket(ack);
}
}, MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST);
@ -234,7 +234,7 @@ public class DeliveryReceiptManager extends Manager {
private static final PacketListener AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER = new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
Message message = (Message) packet;
DeliveryReceiptRequest.addTo(message);
}

View File

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.receipts;
import java.io.IOException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.id.StanzaIdUtil;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
@ -56,10 +56,10 @@ public class DeliveryReceiptRequest implements PacketExtension
*
* @param p the packet
* @return the {@link DeliveryReceiptRequest} extension or {@code null}
* @deprecated use {@link #from(Packet)} instead
* @deprecated use {@link #from(Stanza)} instead
*/
@Deprecated
public static DeliveryReceiptRequest getFrom(Packet p) {
public static DeliveryReceiptRequest getFrom(Stanza p) {
return from(p);
}
@ -69,7 +69,7 @@ public class DeliveryReceiptRequest implements PacketExtension
* @param packet the packet
* @return the {@link DeliveryReceiptRequest} extension or {@code null}
*/
public static DeliveryReceiptRequest from(Packet packet) {
public static DeliveryReceiptRequest from(Stanza packet) {
return packet.getExtension(ELEMENT, DeliveryReceipt.NAMESPACE);
}
@ -83,11 +83,11 @@ public class DeliveryReceiptRequest implements PacketExtension
* @return the Message ID which will be used as receipt ID
*/
public static String addTo(Message message) {
if (message.getPacketID() == null) {
message.setPacketID(StanzaIdUtil.newStanzaId());
if (message.getStanzaId() == null) {
message.setStanzaId(StanzaIdUtil.newStanzaId());
}
message.addExtension(new DeliveryReceiptRequest());
return message.getPacketID();
return message.getStanzaId();
}
/**

View File

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.receipts;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
/**
* Interface for received receipt notifications.
@ -28,7 +28,7 @@ public interface ReceiptReceivedListener {
* Callback invoked when a new receipt got received.
* <p>
* {@code receiptId} correspondents to the message ID, which can be obtained with
* {@link org.jivesoftware.smack.packet.Packet#getPacketID()}.
* {@link org.jivesoftware.smack.packet.Stanza#getStanzaId()}.
* </p>
*
* @param fromJid the jid that send this receipt
@ -36,5 +36,5 @@ public interface ReceiptReceivedListener {
* @param receiptId the message ID of the packet which has been received and this receipt is for
* @param receipt the receipt
*/
void onReceiptReceived(String fromJid, String toJid, String receiptId, Packet receipt);
void onReceiptReceived(String fromJid, String toJid, String receiptId, Stanza receipt);
}

View File

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.rsm.packet;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -147,7 +147,7 @@ public class RSMSet implements PacketExtension {
return xml;
}
public static RSMSet from(Packet packet) {
public static RSMSet from(Stanza packet) {
return (RSMSet) packet.getExtension(ELEMENT, NAMESPACE);
}

View File

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.search;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Item;
@ -43,7 +43,7 @@ public class ReportedData {
*
* @param packet the packet used for reporting data.
*/
public static ReportedData getReportedDataFrom(Packet packet) {
public static ReportedData getReportedDataFrom(Stanza packet) {
// Check if the packet includes the DataForm extension
DataForm dataForm = DataForm.from(packet);
if (dataForm != null) {

View File

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.shim.packet;
import java.util.Collections;
import java.util.List;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -71,7 +71,7 @@ public class HeadersExtension implements PacketExtension {
* @param packet
* @return the headers extension or null.
*/
public static HeadersExtension from(Packet packet) {
public static HeadersExtension from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
}
}

View File

@ -21,7 +21,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.xdata.packet.DataForm;
/**
@ -53,7 +53,7 @@ public class Form {
* @return the data form parsed from the packet or <tt>null</tt> if there was not
* a form in the packet.
*/
public static Form getFormFrom(Packet packet) {
public static Form getFormFrom(Stanza packet) {
// Check if the packet includes the DataForm extension
DataForm dataForm = DataForm.from(packet);
if (dataForm != null) {

View File

@ -18,7 +18,7 @@
package org.jivesoftware.smackx.xdata.packet;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.xdata.FormField;
@ -305,7 +305,7 @@ public class DataForm implements PacketExtension {
* @param packet
* @return the DataForm or null
*/
public static DataForm from(Packet packet) {
public static DataForm from(Stanza packet) {
return (DataForm) packet.getExtension(ELEMENT, NAMESPACE);
}

Some files were not shown because too many files have changed in this diff Show More