1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 03:52:06 +01:00

Rename PacketListener to StanzaListener

and add the PacketListener as deprecated interface.
This commit is contained in:
Florian Schmaus 2015-03-01 10:28:15 +01:00
parent d4a6d8e653
commit 75ec271c6c
40 changed files with 305 additions and 279 deletions

View file

@ -158,7 +158,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
initDebugger(); initDebugger();
if (isFirstInitialization) { if (isFirstInitialization) {
if (debugger.getReaderListener() != null) { if (debugger.getReaderListener() != null) {
addAsyncPacketListener(debugger.getReaderListener(), null); addAsyncStanzaListener(debugger.getReaderListener(), null);
} }
if (debugger.getWriterListener() != null) { if (debugger.getWriterListener() != null) {
addPacketSendingListener(debugger.getWriterListener(), null); addPacketSendingListener(debugger.getWriterListener(), null);

View file

@ -131,26 +131,26 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
/** /**
* List of PacketListeners that will be notified synchronously when a new packet was received. * List of PacketListeners that will be notified synchronously when a new packet was received.
*/ */
private final Map<PacketListener, ListenerWrapper> syncRecvListeners = new LinkedHashMap<>(); private final Map<StanzaListener, ListenerWrapper> syncRecvListeners = new LinkedHashMap<>();
/** /**
* List of PacketListeners that will be notified asynchronously when a new packet was received. * List of PacketListeners that will be notified asynchronously when a new packet was received.
*/ */
private final Map<PacketListener, ListenerWrapper> asyncRecvListeners = new LinkedHashMap<>(); private final Map<StanzaListener, ListenerWrapper> asyncRecvListeners = new LinkedHashMap<>();
/** /**
* List of PacketListeners that will be notified when a new packet was sent. * List of PacketListeners that will be notified when a new packet was sent.
*/ */
private final Map<PacketListener, ListenerWrapper> sendListeners = private final Map<StanzaListener, ListenerWrapper> sendListeners =
new HashMap<PacketListener, ListenerWrapper>(); new HashMap<StanzaListener, ListenerWrapper>();
/** /**
* List of PacketListeners that will be notified when a new packet is about to be * List of PacketListeners that will be notified when a new packet is about to be
* sent to the server. These interceptors may modify the packet before it is being * sent to the server. These interceptors may modify the packet before it is being
* actually sent to the server. * actually sent to the server.
*/ */
private final Map<PacketListener, InterceptorWrapper> interceptors = private final Map<StanzaListener, InterceptorWrapper> interceptors =
new HashMap<PacketListener, InterceptorWrapper>(); new HashMap<StanzaListener, InterceptorWrapper>();
protected final Lock connectionLock = new ReentrantLock(); protected final Lock connectionLock = new ReentrantLock();
@ -759,18 +759,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override @Override
@Deprecated @Deprecated
public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter) { public void addPacketListener(StanzaListener packetListener, StanzaFilter packetFilter) {
addAsyncPacketListener(packetListener, packetFilter); addAsyncStanzaListener(packetListener, packetFilter);
} }
@Override @Override
@Deprecated @Deprecated
public boolean removePacketListener(PacketListener packetListener) { public boolean removePacketListener(StanzaListener packetListener) {
return removeAsyncPacketListener(packetListener); return removeAsyncStanzaListener(packetListener);
} }
@Override @Override
public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) { public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter) {
if (packetListener == null) { if (packetListener == null) {
throw new NullPointerException("Packet listener is null."); throw new NullPointerException("Packet listener is null.");
} }
@ -781,14 +781,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
@Override @Override
public boolean removeSyncPacketListener(PacketListener packetListener) { public boolean removeSyncStanzaListener(StanzaListener packetListener) {
synchronized (syncRecvListeners) { synchronized (syncRecvListeners) {
return syncRecvListeners.remove(packetListener) != null; return syncRecvListeners.remove(packetListener) != null;
} }
} }
@Override @Override
public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) { public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter) {
if (packetListener == null) { if (packetListener == null) {
throw new NullPointerException("Packet listener is null."); throw new NullPointerException("Packet listener is null.");
} }
@ -799,14 +799,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
@Override @Override
public boolean removeAsyncPacketListener(PacketListener packetListener) { public boolean removeAsyncStanzaListener(StanzaListener packetListener) {
synchronized (asyncRecvListeners) { synchronized (asyncRecvListeners) {
return asyncRecvListeners.remove(packetListener) != null; return asyncRecvListeners.remove(packetListener) != null;
} }
} }
@Override @Override
public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter) { public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter) {
if (packetListener == null) { if (packetListener == null) {
throw new NullPointerException("Packet listener is null."); throw new NullPointerException("Packet listener is null.");
} }
@ -817,7 +817,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
@Override @Override
public void removePacketSendingListener(PacketListener packetListener) { public void removePacketSendingListener(StanzaListener packetListener) {
synchronized (sendListeners) { synchronized (sendListeners) {
sendListeners.remove(packetListener); sendListeners.remove(packetListener);
} }
@ -833,7 +833,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
*/ */
@SuppressWarnings("javadoc") @SuppressWarnings("javadoc")
protected void firePacketSendingListeners(final Stanza packet) { protected void firePacketSendingListeners(final Stanza packet) {
final List<PacketListener> listenersToNotify = new LinkedList<PacketListener>(); final List<StanzaListener> listenersToNotify = new LinkedList<StanzaListener>();
synchronized (sendListeners) { synchronized (sendListeners) {
for (ListenerWrapper listenerWrapper : sendListeners.values()) { for (ListenerWrapper listenerWrapper : sendListeners.values()) {
if (listenerWrapper.filterMatches(packet)) { if (listenerWrapper.filterMatches(packet)) {
@ -848,7 +848,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
asyncGo(new Runnable() { asyncGo(new Runnable() {
@Override @Override
public void run() { public void run() {
for (PacketListener listener : listenersToNotify) { for (StanzaListener listener : listenersToNotify) {
try { try {
listener.processPacket(packet); listener.processPacket(packet);
} }
@ -861,7 +861,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
@Override @Override
public void addPacketInterceptor(PacketListener packetInterceptor, public void addPacketInterceptor(StanzaListener packetInterceptor,
StanzaFilter packetFilter) { StanzaFilter packetFilter) {
if (packetInterceptor == null) { if (packetInterceptor == null) {
throw new NullPointerException("Packet interceptor is null."); throw new NullPointerException("Packet interceptor is null.");
@ -873,7 +873,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
@Override @Override
public void removePacketInterceptor(PacketListener packetInterceptor) { public void removePacketInterceptor(StanzaListener packetInterceptor) {
synchronized (interceptors) { synchronized (interceptors) {
interceptors.remove(packetInterceptor); interceptors.remove(packetInterceptor);
} }
@ -888,7 +888,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @param packet the packet that is going to be sent to the server * @param packet the packet that is going to be sent to the server
*/ */
private void firePacketInterceptors(Stanza packet) { private void firePacketInterceptors(Stanza packet) {
List<PacketListener> interceptorsToInvoke = new LinkedList<PacketListener>(); List<StanzaListener> interceptorsToInvoke = new LinkedList<StanzaListener>();
synchronized (interceptors) { synchronized (interceptors) {
for (InterceptorWrapper interceptorWrapper : interceptors.values()) { for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
if (interceptorWrapper.filterMatches(packet)) { if (interceptorWrapper.filterMatches(packet)) {
@ -896,7 +896,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
} }
} }
for (PacketListener interceptor : interceptorsToInvoke) { for (StanzaListener interceptor : interceptorsToInvoke) {
try { try {
interceptor.processPacket(packet); interceptor.processPacket(packet);
} catch (Exception e) { } catch (Exception e) {
@ -1107,7 +1107,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// First handle the async recv listeners. Note that this code is very similar to what follows a few lines below, // First handle the async recv listeners. Note that this code is very similar to what follows a few lines below,
// the only difference is that asyncRecvListeners is used here and that the packet listeners are started in // the only difference is that asyncRecvListeners is used here and that the packet listeners are started in
// their own thread. // their own thread.
final Collection<PacketListener> listenersToNotify = new LinkedList<PacketListener>(); final Collection<StanzaListener> listenersToNotify = new LinkedList<StanzaListener>();
synchronized (asyncRecvListeners) { synchronized (asyncRecvListeners) {
for (ListenerWrapper listenerWrapper : asyncRecvListeners.values()) { for (ListenerWrapper listenerWrapper : asyncRecvListeners.values()) {
if (listenerWrapper.filterMatches(packet)) { if (listenerWrapper.filterMatches(packet)) {
@ -1116,7 +1116,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
} }
for (final PacketListener listener : listenersToNotify) { for (final StanzaListener listener : listenersToNotify) {
asyncGo(new Runnable() { asyncGo(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -1149,7 +1149,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
singleThreadedExecutorService.execute(new Runnable() { singleThreadedExecutorService.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
for (PacketListener listener : listenersToNotify) { for (StanzaListener listener : listenersToNotify) {
try { try {
listener.processPacket(packet); listener.processPacket(packet);
} catch(NotConnectedException e) { } catch(NotConnectedException e) {
@ -1243,7 +1243,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
*/ */
protected static class ListenerWrapper { protected static class ListenerWrapper {
private final PacketListener packetListener; private final StanzaListener packetListener;
private final StanzaFilter packetFilter; private final StanzaFilter packetFilter;
/** /**
@ -1252,7 +1252,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @param packetListener the packet listener. * @param packetListener the packet listener.
* @param packetFilter the associated filter or null if it listen for all packets. * @param packetFilter the associated filter or null if it listen for all packets.
*/ */
public ListenerWrapper(PacketListener packetListener, StanzaFilter packetFilter) { public ListenerWrapper(StanzaListener packetListener, StanzaFilter packetFilter) {
this.packetListener = packetListener; this.packetListener = packetListener;
this.packetFilter = packetFilter; this.packetFilter = packetFilter;
} }
@ -1261,7 +1261,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
return packetFilter == null || packetFilter.accept(packet); return packetFilter == null || packetFilter.accept(packet);
} }
public PacketListener getListener() { public StanzaListener getListener() {
return packetListener; return packetListener;
} }
} }
@ -1271,7 +1271,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
*/ */
protected static class InterceptorWrapper { protected static class InterceptorWrapper {
private final PacketListener packetInterceptor; private final StanzaListener packetInterceptor;
private final StanzaFilter packetFilter; private final StanzaFilter packetFilter;
/** /**
@ -1280,7 +1280,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @param packetInterceptor the interceptor. * @param packetInterceptor the interceptor.
* @param packetFilter the associated filter or null if it intercepts all packets. * @param packetFilter the associated filter or null if it intercepts all packets.
*/ */
public InterceptorWrapper(PacketListener packetInterceptor, StanzaFilter packetFilter) { public InterceptorWrapper(StanzaListener packetInterceptor, StanzaFilter packetFilter) {
this.packetInterceptor = packetInterceptor; this.packetInterceptor = packetInterceptor;
this.packetFilter = packetFilter; this.packetFilter = packetFilter;
} }
@ -1289,7 +1289,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
return packetFilter == null || packetFilter.accept(packet); return packetFilter == null || packetFilter.accept(packet);
} }
public PacketListener getInterceptor() { public StanzaListener getInterceptor() {
return packetInterceptor; return packetInterceptor;
} }
} }
@ -1417,13 +1417,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override @Override
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
PacketListener callback) throws NotConnectedException { StanzaListener callback) throws NotConnectedException {
sendStanzaWithResponseCallback(stanza, replyFilter, callback, null); sendStanzaWithResponseCallback(stanza, replyFilter, callback, null);
} }
@Override @Override
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
PacketListener callback, ExceptionCallback exceptionCallback) StanzaListener callback, ExceptionCallback exceptionCallback)
throws NotConnectedException { throws NotConnectedException {
sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback, sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback,
getPacketReplyTimeout()); getPacketReplyTimeout());
@ -1431,7 +1431,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override @Override
public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter, public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter,
final PacketListener callback, final ExceptionCallback exceptionCallback, final StanzaListener callback, final ExceptionCallback exceptionCallback,
long timeout) throws NotConnectedException { long timeout) throws NotConnectedException {
Objects.requireNonNull(stanza, "stanza must not be null"); Objects.requireNonNull(stanza, "stanza must not be null");
// While Smack allows to add PacketListeners with a PacketFilter value of 'null', we // While Smack allows to add PacketListeners with a PacketFilter value of 'null', we
@ -1439,7 +1439,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
Objects.requireNonNull(replyFilter, "replyFilter must not be null"); Objects.requireNonNull(replyFilter, "replyFilter must not be null");
Objects.requireNonNull(callback, "callback must not be null"); Objects.requireNonNull(callback, "callback must not be null");
final PacketListener packetListener = new PacketListener() { final StanzaListener packetListener = new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
try { try {
@ -1452,14 +1452,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
} }
finally { finally {
removeAsyncPacketListener(this); removeAsyncStanzaListener(this);
} }
} }
}; };
removeCallbacksService.schedule(new Runnable() { removeCallbacksService.schedule(new Runnable() {
@Override @Override
public void run() { public void run() {
boolean removed = removeAsyncPacketListener(packetListener); boolean removed = removeAsyncStanzaListener(packetListener);
// If the packetListener got removed, then it was never run and // If the packetListener got removed, then it was never run and
// we never received a response, inform the exception callback // we never received a response, inform the exception callback
if (removed && exceptionCallback != null) { if (removed && exceptionCallback != null) {
@ -1467,24 +1467,24 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
} }
}, timeout, TimeUnit.MILLISECONDS); }, timeout, TimeUnit.MILLISECONDS);
addAsyncPacketListener(packetListener, replyFilter); addAsyncStanzaListener(packetListener, replyFilter);
sendPacket(stanza); sendPacket(stanza);
} }
@Override @Override
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback) public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback)
throws NotConnectedException { throws NotConnectedException {
sendIqWithResponseCallback(iqRequest, callback, null); sendIqWithResponseCallback(iqRequest, callback, null);
} }
@Override @Override
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback, public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
ExceptionCallback exceptionCallback) throws NotConnectedException { ExceptionCallback exceptionCallback) throws NotConnectedException {
sendIqWithResponseCallback(iqRequest, callback, exceptionCallback, getPacketReplyTimeout()); sendIqWithResponseCallback(iqRequest, callback, exceptionCallback, getPacketReplyTimeout());
} }
@Override @Override
public void sendIqWithResponseCallback(IQ iqRequest, final PacketListener callback, public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
final ExceptionCallback exceptionCallback, long timeout) final ExceptionCallback exceptionCallback, long timeout)
throws NotConnectedException { throws NotConnectedException {
StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this); StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this);
@ -1492,22 +1492,22 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
@Override @Override
public void addOneTimeSyncCallback(final PacketListener callback, final StanzaFilter packetFilter) { public void addOneTimeSyncCallback(final StanzaListener callback, final StanzaFilter packetFilter) {
final PacketListener packetListener = new PacketListener() { final StanzaListener packetListener = new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
try { try {
callback.processPacket(packet); callback.processPacket(packet);
} finally { } finally {
removeSyncPacketListener(this); removeSyncStanzaListener(this);
} }
} }
}; };
addSyncPacketListener(packetListener, packetFilter); addSyncStanzaListener(packetListener, packetFilter);
removeCallbacksService.schedule(new Runnable() { removeCallbacksService.schedule(new Runnable() {
@Override @Override
public void run() { public void run() {
removeSyncPacketListener(packetListener); removeSyncStanzaListener(packetListener);
} }
}, getPacketReplyTimeout(), TimeUnit.MILLISECONDS); }, getPacketReplyTimeout(), TimeUnit.MILLISECONDS);
} }

View file

@ -31,7 +31,7 @@ import org.jivesoftware.smack.packet.Stanza;
* Provides a mechanism to collect packets into a result queue that pass a * Provides a mechanism to collect packets into a result queue that pass a
* specified filter. The collector lets you perform blocking and polling * specified filter. The collector lets you perform blocking and polling
* operations on the result queue. So, a PacketCollector is more suitable to * operations on the result queue. So, a PacketCollector is more suitable to
* use than a {@link PacketListener} when you need to wait for a specific * use than a {@link StanzaListener} when you need to wait for a specific
* result.<p> * result.<p>
* *
* Each packet collector will queue up a configured number of packets for processing before * Each packet collector will queue up a configured number of packets for processing before

View file

@ -17,37 +17,10 @@
package org.jivesoftware.smack; package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Stanza;
/** /**
* Provides a mechanism to listen for packets that pass a specified filter. * @deprecated use {@link StanzaListener} instead
* This allows event-style programming -- every time a new packet is found,
* the {@link #processPacket(Stanza)} method will be called. This is the
* opposite approach to the functionality provided by a {@link PacketCollector}
* which lets you block while waiting for results.
* <p>
* Additionally you are able to intercept Packets that are going to be send and
* make modifications to them. You can register a PacketListener as interceptor
* by using {@link XMPPConnection#addPacketInterceptor(PacketListener,
* org.jivesoftware.smack.filter.StanzaFilter)}
* </p>
*
* @see XMPPConnection#addAsyncPacketListener(PacketListener, org.jivesoftware.smack.filter.StanzaFilter)
* @author Matt Tucker
*/ */
public interface PacketListener { @Deprecated
public interface PacketListener extends StanzaListener {
/**
* Process the next packet sent to this packet listener.
* <p>
* A single thread is responsible for invoking all listeners, so
* it's very important that implementations of this method not block
* for any extended period of time.
* </p>
*
* @param packet the packet to process.
*/
public void processPacket(Stanza packet) throws NotConnectedException;
} }

View file

@ -0,0 +1,53 @@
/**
*
* Copyright 2003-2007 Jive Software.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Stanza;
/**
* Provides a mechanism to listen for packets that pass a specified filter.
* This allows event-style programming -- every time a new packet is found,
* the {@link #processPacket(Stanza)} method will be called. This is the
* opposite approach to the functionality provided by a {@link PacketCollector}
* which lets you block while waiting for results.
* <p>
* Additionally you are able to intercept Packets that are going to be send and
* make modifications to them. You can register a PacketListener as interceptor
* by using {@link XMPPConnection#addPacketInterceptor(StanzaListener,
* org.jivesoftware.smack.filter.StanzaFilter)}
* </p>
*
* @see XMPPConnection#addAsyncStanzaListener(StanzaListener, org.jivesoftware.smack.filter.StanzaFilter)
* @author Matt Tucker
*/
public interface StanzaListener {
/**
* Process the next packet sent to this packet listener.
* <p>
* A single thread is responsible for invoking all listeners, so
* it's very important that implementations of this method not block
* for any extended period of time.
* </p>
*
* @param packet the packet to process.
*/
public void processPacket(Stanza packet) throws NotConnectedException;
}

View file

@ -204,7 +204,7 @@ public interface XMPPConnection {
/** /**
* Creates a new packet collector for this connection. A packet filter determines * Creates a new packet collector for this connection. A packet filter determines
* which packets will be accumulated by the collector. A PacketCollector is * which packets will be accumulated by the collector. A PacketCollector is
* more suitable to use than a {@link PacketListener} when you need to wait for * more suitable to use than a {@link StanzaListener} when you need to wait for
* a specific result. * a specific result.
* *
* @param packetFilter the packet filter to use. * @param packetFilter the packet filter to use.
@ -217,7 +217,7 @@ public interface XMPPConnection {
/** /**
* Creates a new packet collector for this connection. A packet filter * Creates a new packet collector for this connection. A packet filter
* determines which packets will be accumulated by the collector. A * determines which packets will be accumulated by the collector. A
* PacketCollector is more suitable to use than a {@link PacketListener} * PacketCollector is more suitable to use than a {@link StanzaListener}
* when you need to wait for a specific result. * when you need to wait for a specific result.
* <p> * <p>
* <b>Note:</b> If you send a Packet right after using this method, then * <b>Note:</b> If you send a Packet right after using this method, then
@ -257,27 +257,27 @@ public interface XMPPConnection {
* <p> * <p>
* This method has been deprecated. It is important to differentiate between using an asynchronous packet listener * This method has been deprecated. It is important to differentiate between using an asynchronous packet listener
* (preferred where possible) and a synchronous packet lister. Refer * (preferred where possible) and a synchronous packet lister. Refer
* {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} and * {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} and
* {@link #addSyncPacketListener(PacketListener, StanzaFilter)} for more information. * {@link #addSyncStanzaListener(StanzaListener, StanzaFilter)} for more information.
* </p> * </p>
* *
* @param packetListener the packet listener to notify of new received packets. * @param packetListener the packet listener to notify of new received packets.
* @param packetFilter the packet filter to use. * @param packetFilter the packet filter to use.
* @deprecated use {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} or * @deprecated use {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} or
* {@link #addSyncPacketListener(PacketListener, StanzaFilter)}. * {@link #addSyncStanzaListener(StanzaListener, StanzaFilter)}.
*/ */
@Deprecated @Deprecated
public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter); public void addPacketListener(StanzaListener packetListener, StanzaFilter packetFilter);
/** /**
* Removes a packet listener for received packets from this connection. * Removes a packet listener for received packets from this connection.
* *
* @param packetListener the packet listener to remove. * @param packetListener the packet listener to remove.
* @return true if the packet listener was removed * @return true if the packet listener was removed
* @deprecated use {@link #removeAsyncPacketListener(PacketListener)} or {@link #removeSyncPacketListener(PacketListener)}. * @deprecated use {@link #removeAsyncStanzaListener(StanzaListener)} or {@link #removeSyncStanzaListener(StanzaListener)}.
*/ */
@Deprecated @Deprecated
public boolean removePacketListener(PacketListener packetListener); public boolean removePacketListener(StanzaListener packetListener);
/** /**
* Registers a <b>synchronous</b> packet listener with this connection. A packet listener will be invoked only when * Registers a <b>synchronous</b> packet listener with this connection. A packet listener will be invoked only when
@ -286,17 +286,17 @@ public interface XMPPConnection {
* <p> * <p>
* <b>Important:</b> This packet listeners will be called in the same <i>single</i> thread that processes all * <b>Important:</b> This packet listeners will be called in the same <i>single</i> thread that processes all
* incoming stanzas. Only use this kind of packet filter if it does not perform any XMPP activity that waits for a * incoming stanzas. Only use this kind of packet filter if it does not perform any XMPP activity that waits for a
* response. Consider using {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} when possible, i.e. when * response. Consider using {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} when possible, i.e. when
* the invocation order doesn't have to be the same as the order of the arriving packets. If the order of the * the invocation order doesn't have to be the same as the order of the arriving packets. If the order of the
* arriving packets, consider using a {@link PacketCollector} when possible. * arriving packets, consider using a {@link PacketCollector} when possible.
* </p> * </p>
* *
* @param packetListener the packet listener to notify of new received packets. * @param packetListener the packet listener to notify of new received packets.
* @param packetFilter the packet filter to use. * @param packetFilter the packet filter to use.
* @see #addPacketInterceptor(PacketListener, StanzaFilter) * @see #addPacketInterceptor(StanzaListener, StanzaFilter)
* @since 4.1 * @since 4.1
*/ */
public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter); public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
/** /**
* Removes a packet listener for received packets from this connection. * Removes a packet listener for received packets from this connection.
@ -305,24 +305,24 @@ public interface XMPPConnection {
* @return true if the packet listener was removed * @return true if the packet listener was removed
* @since 4.1 * @since 4.1
*/ */
public boolean removeSyncPacketListener(PacketListener packetListener); public boolean removeSyncStanzaListener(StanzaListener packetListener);
/** /**
* Registers an <b>asynchronous</b> packet listener with this connection. A packet listener will be invoked only * Registers an <b>asynchronous</b> packet listener with this connection. A packet listener will be invoked only
* when an incoming packet is received. A packet filter determines which packets will be delivered to the listener. * when an incoming packet is received. A packet filter determines which packets will be delivered to the listener.
* If the same packet listener is added again with a different filter, only the new filter will be used. * If the same packet listener is added again with a different filter, only the new filter will be used.
* <p> * <p>
* Unlike {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} packet listeners added with this method will be * Unlike {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} packet listeners added with this method will be
* invoked asynchronously in their own thread. Use this method if the order of the packet listeners must not depend * invoked asynchronously in their own thread. Use this method if the order of the packet listeners must not depend
* on the order how the stanzas where received. * on the order how the stanzas where received.
* </p> * </p>
* *
* @param packetListener the packet listener to notify of new received packets. * @param packetListener the packet listener to notify of new received packets.
* @param packetFilter the packet filter to use. * @param packetFilter the packet filter to use.
* @see #addPacketInterceptor(PacketListener, StanzaFilter) * @see #addPacketInterceptor(StanzaListener, StanzaFilter)
* @since 4.1 * @since 4.1
*/ */
public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter); public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
/** /**
* Removes an <b>asynchronous</b> packet listener for received packets from this connection. * Removes an <b>asynchronous</b> packet listener for received packets from this connection.
@ -331,7 +331,7 @@ public interface XMPPConnection {
* @return true if the packet listener was removed * @return true if the packet listener was removed
* @since 4.1 * @since 4.1
*/ */
public boolean removeAsyncPacketListener(PacketListener packetListener); public boolean removeAsyncStanzaListener(StanzaListener packetListener);
/** /**
* Registers a packet listener with this connection. The listener will be * Registers a packet listener with this connection. The listener will be
@ -344,14 +344,14 @@ public interface XMPPConnection {
* @param packetListener the packet listener to notify of sent packets. * @param packetListener the packet listener to notify of sent packets.
* @param packetFilter the packet filter to use. * @param packetFilter the packet filter to use.
*/ */
public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter); public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter);
/** /**
* Removes a packet listener for sending packets from this connection. * Removes a packet listener for sending packets from this connection.
* *
* @param packetListener the packet listener to remove. * @param packetListener the packet listener to remove.
*/ */
public void removePacketSendingListener(PacketListener packetListener); public void removePacketSendingListener(StanzaListener packetListener);
/** /**
* Registers a packet interceptor with this connection. The interceptor will be * Registers a packet interceptor with this connection. The interceptor will be
@ -360,19 +360,19 @@ public interface XMPPConnection {
* will be delivered to the interceptor. * will be delivered to the interceptor.
* *
* <p> * <p>
* NOTE: For a similar functionality on incoming packets, see {@link #addAsyncPacketListener(PacketListener, StanzaFilter)}. * NOTE: For a similar functionality on incoming packets, see {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}.
* *
* @param packetInterceptor the packet interceptor to notify of packets about to be sent. * @param packetInterceptor the packet interceptor to notify of packets about to be sent.
* @param packetFilter the packet filter to use. * @param packetFilter the packet filter to use.
*/ */
public void addPacketInterceptor(PacketListener packetInterceptor, StanzaFilter packetFilter); public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter);
/** /**
* Removes a packet interceptor. * Removes a packet interceptor.
* *
* @param packetInterceptor the packet interceptor to remove. * @param packetInterceptor the packet interceptor to remove.
*/ */
public void removePacketInterceptor(PacketListener packetInterceptor); public void removePacketInterceptor(StanzaListener packetInterceptor);
/** /**
* Returns the current value of the reply timeout in milliseconds for request for this * Returns the current value of the reply timeout in milliseconds for request for this
@ -464,7 +464,7 @@ public interface XMPPConnection {
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
PacketListener callback) throws NotConnectedException; StanzaListener callback) throws NotConnectedException;
/** /**
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>. * Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
@ -480,7 +480,7 @@ public interface XMPPConnection {
* @param exceptionCallback the callback invoked if there is an exception (optional) * @param exceptionCallback the callback invoked if there is an exception (optional)
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, PacketListener callback, public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
ExceptionCallback exceptionCallback) throws NotConnectedException; ExceptionCallback exceptionCallback) throws NotConnectedException;
/** /**
@ -499,7 +499,7 @@ public interface XMPPConnection {
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
final PacketListener callback, final ExceptionCallback exceptionCallback, final StanzaListener callback, final ExceptionCallback exceptionCallback,
long timeout) throws NotConnectedException; long timeout) throws NotConnectedException;
/** /**
@ -511,7 +511,7 @@ public interface XMPPConnection {
* @param callback the callback invoked if there is result response (required) * @param callback the callback invoked if there is result response (required)
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback) throws NotConnectedException; public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException;
/** /**
* Send a IQ stanza and invoke <code>callback</code> if there is a result of * Send a IQ stanza and invoke <code>callback</code> if there is a result of
@ -526,7 +526,7 @@ public interface XMPPConnection {
* @param exceptionCallback the callback invoked if there is an Exception optional * @param exceptionCallback the callback invoked if there is an Exception optional
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback, public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
ExceptionCallback exceptionCallback) throws NotConnectedException; ExceptionCallback exceptionCallback) throws NotConnectedException;
/** /**
@ -543,7 +543,7 @@ public interface XMPPConnection {
* @param timeout the timeout in milliseconds to wait for a response * @param timeout the timeout in milliseconds to wait for a response
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void sendIqWithResponseCallback(IQ iqRequest, final PacketListener callback, public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
final ExceptionCallback exceptionCallback, long timeout) final ExceptionCallback exceptionCallback, long timeout)
throws NotConnectedException; throws NotConnectedException;
@ -554,7 +554,7 @@ public interface XMPPConnection {
* @param callback the callback invoked once the packet filter matches a stanza. * @param callback the callback invoked once the packet filter matches a stanza.
* @param packetFilter the filter to match stanzas or null to match all. * @param packetFilter the filter to match stanzas or null to match all.
*/ */
public void addOneTimeSyncCallback(PacketListener callback, StanzaFilter packetFilter); public void addOneTimeSyncCallback(StanzaListener callback, StanzaFilter packetFilter);
/** /**
* Register an IQ request handler with this connection. * Register an IQ request handler with this connection.

View file

@ -17,7 +17,7 @@
package org.jivesoftware.smack.debugger; package org.jivesoftware.smack.debugger;
import org.jivesoftware.smack.ConnectionListener; import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.ObservableReader; import org.jivesoftware.smack.util.ObservableReader;
@ -35,7 +35,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
private final XMPPConnection connection; private final XMPPConnection connection;
private final PacketListener listener; private final StanzaListener listener;
private final ConnectionListener connListener; private final ConnectionListener connListener;
private final ReaderListener readerListener; private final ReaderListener readerListener;
private final WriterListener writerListener; private final WriterListener writerListener;
@ -67,7 +67,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
// Create a thread that will listen for all incoming packets and write them to // Create a thread that will listen for all incoming packets and write them to
// the GUI. This is what we call "interpreted" packet data, since it's the packet // 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. // data as Smack sees it and not as it's coming in as raw XML.
listener = new PacketListener() { listener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
if (printInterpreted) { if (printInterpreted) {
log("RCV PKT (" + connection.getConnectionCounter() + "): " + packet.toXML()); log("RCV PKT (" + connection.getConnectionCounter() + "): " + packet.toXML());
@ -166,11 +166,11 @@ public abstract class AbstractDebugger implements SmackDebugger {
return writer; return writer;
} }
public PacketListener getReaderListener() { public StanzaListener getReaderListener() {
return listener; return listener;
} }
public PacketListener getWriterListener() { public StanzaListener getWriterListener() {
return null; return null;
} }
} }

View file

@ -20,7 +20,7 @@ package org.jivesoftware.smack.debugger;
import java.io.Reader; import java.io.Reader;
import java.io.Writer; import java.io.Writer;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
/** /**
* Interface that allows for implementing classes to debug XML traffic. That is a GUI window that * Interface that allows for implementing classes to debug XML traffic. That is a GUI window that
@ -84,7 +84,7 @@ public interface SmackDebugger {
* @return the PacketListener that will listen for all incoming packets and write them to * @return the PacketListener that will listen for all incoming packets and write them to
* the GUI * the GUI
*/ */
public abstract PacketListener getReaderListener(); public abstract StanzaListener getReaderListener();
/** /**
* Returns the thread that will listen for all outgoing packets and write them to the GUI. * Returns the thread that will listen for all outgoing packets and write them to the GUI.
@ -92,5 +92,5 @@ public interface SmackDebugger {
* @return the PacketListener that will listen for all sent packets and write them to * @return the PacketListener that will listen for all sent packets and write them to
* the GUI * the GUI
*/ */
public abstract PacketListener getWriterListener(); public abstract StanzaListener getWriterListener();
} }

View file

@ -41,7 +41,7 @@ package org.jivesoftware.smack.filter;
* </pre> * </pre>
* *
* @see org.jivesoftware.smack.PacketCollector * @see org.jivesoftware.smack.PacketCollector
* @see org.jivesoftware.smack.PacketListener * @see org.jivesoftware.smack.StanzaListener
* @author Matt Tucker * @author Matt Tucker
* @deprecated use {@link StanzaFilter} * @deprecated use {@link StanzaFilter}
*/ */

View file

@ -43,7 +43,7 @@ import org.jivesoftware.smack.packet.Stanza;
* </pre> * </pre>
* *
* @see org.jivesoftware.smack.PacketCollector * @see org.jivesoftware.smack.PacketCollector
* @see org.jivesoftware.smack.PacketListener * @see org.jivesoftware.smack.StanzaListener
* @author Matt Tucker * @author Matt Tucker
*/ */
public interface StanzaFilter { public interface StanzaFilter {

View file

@ -19,11 +19,11 @@ package org.jivesoftware.smack.test.util;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
public class WaitForPacketListener implements PacketListener { public class WaitForPacketListener implements StanzaListener {
private CountDownLatch latch = new CountDownLatch(1); private CountDownLatch latch = new CountDownLatch(1);

View file

@ -17,12 +17,12 @@
package org.jivesoftware.smackx.debugger.slf4j; package org.jivesoftware.smackx.debugger.slf4j;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.slf4j.Logger; import org.slf4j.Logger;
class SLF4JLoggingPacketListener implements PacketListener { class SLF4JLoggingPacketListener implements StanzaListener {
private final Logger logger; private final Logger logger;
private final String prefix; private final String prefix;

View file

@ -17,7 +17,7 @@
package org.jivesoftware.smackx.debugger.slf4j; package org.jivesoftware.smackx.debugger.slf4j;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.debugger.SmackDebugger; import org.jivesoftware.smack.debugger.SmackDebugger;
@ -47,8 +47,8 @@ public class SLF4JSmackDebugger implements SmackDebugger {
private final XMPPConnection connection; private final XMPPConnection connection;
private final PacketListener receivedListener = new SLF4JLoggingPacketListener(logger, RECEIVED_TAG); private final StanzaListener receivedListener = new SLF4JLoggingPacketListener(logger, RECEIVED_TAG);
private final PacketListener sentListener = new SLF4JLoggingPacketListener(logger, SENT_TAG); private final StanzaListener sentListener = new SLF4JLoggingPacketListener(logger, SENT_TAG);
private final SLF4JRawXmlListener slf4JRawXmlListener = new SLF4JRawXmlListener(logger); private final SLF4JRawXmlListener slf4JRawXmlListener = new SLF4JRawXmlListener(logger);
private ObservableWriter writer; private ObservableWriter writer;
@ -119,12 +119,12 @@ public class SLF4JSmackDebugger implements SmackDebugger {
} }
@Override @Override
public PacketListener getReaderListener() { public StanzaListener getReaderListener() {
return receivedListener; return receivedListener;
} }
@Override @Override
public PacketListener getWriterListener() { public StanzaListener getWriterListener() {
return sentListener; return sentListener;
} }
} }

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.debugger;
import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionListener; import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.debugger.SmackDebugger; import org.jivesoftware.smack.debugger.SmackDebugger;
@ -148,8 +148,8 @@ public class EnhancedDebugger implements SmackDebugger {
private XMPPConnection connection = null; private XMPPConnection connection = null;
private PacketListener packetReaderListener = null; private StanzaListener packetReaderListener = null;
private PacketListener packetWriterListener = null; private StanzaListener packetWriterListener = null;
private ConnectionListener connListener = null; private ConnectionListener connListener = null;
private Writer writer; private Writer writer;
@ -203,7 +203,7 @@ public class EnhancedDebugger implements SmackDebugger {
// Create a thread that will listen for all incoming packets and write them to // Create a thread that will listen for all incoming packets and write them to
// the GUI. This is what we call "interpreted" packet data, since it's the packet // 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. // data as Smack sees it and not as it's coming in as raw XML.
packetReaderListener = new PacketListener() { packetReaderListener = new StanzaListener() {
SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa"); SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa");
public void processPacket(final Stanza packet) { public void processPacket(final Stanza packet) {
@ -218,7 +218,7 @@ public class EnhancedDebugger implements SmackDebugger {
// Create a thread that will listen for all outgoing packets and write them to // Create a thread that will listen for all outgoing packets and write them to
// the GUI. // the GUI.
packetWriterListener = new PacketListener() { packetWriterListener = new StanzaListener() {
SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa"); SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss:SS aaa");
public void processPacket(final Stanza packet) { public void processPacket(final Stanza packet) {
@ -757,11 +757,11 @@ public class EnhancedDebugger implements SmackDebugger {
return writer; return writer;
} }
public PacketListener getReaderListener() { public StanzaListener getReaderListener() {
return packetReaderListener; return packetReaderListener;
} }
public PacketListener getWriterListener() { public StanzaListener getWriterListener() {
return packetWriterListener; return packetWriterListener;
} }
@ -956,7 +956,7 @@ public class EnhancedDebugger implements SmackDebugger {
*/ */
void cancel() { void cancel() {
connection.removeConnectionListener(connListener); connection.removeConnectionListener(connListener);
connection.removeAsyncPacketListener(packetReaderListener); connection.removeAsyncStanzaListener(packetReaderListener);
connection.removePacketSendingListener(packetWriterListener); connection.removePacketSendingListener(packetWriterListener);
((ObservableReader) reader).removeReaderListener(readerListener); ((ObservableReader) reader).removeReaderListener(readerListener);
((ObservableWriter) writer).removeWriterListener(writerListener); ((ObservableWriter) writer).removeWriterListener(writerListener);

View file

@ -40,7 +40,7 @@ import javax.swing.JScrollPane;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.debugger.SmackDebugger; import org.jivesoftware.smack.debugger.SmackDebugger;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
@ -63,7 +63,7 @@ public class LiteDebugger implements SmackDebugger {
private JFrame frame = null; private JFrame frame = null;
private XMPPConnection connection = null; private XMPPConnection connection = null;
private PacketListener listener = null; private StanzaListener listener = null;
private Writer writer; private Writer writer;
private Reader reader; private Reader reader;
@ -261,7 +261,7 @@ public class LiteDebugger implements SmackDebugger {
// Create a thread that will listen for all incoming packets and write them to // Create a thread that will listen for all incoming packets and write them to
// the GUI. This is what we call "interpreted" packet data, since it's the packet // 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. // data as Smack sees it and not as it's coming in as raw XML.
listener = new PacketListener() { listener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
interpretedText1.append(packet.toXML().toString()); interpretedText1.append(packet.toXML().toString());
interpretedText2.append(packet.toXML().toString()); interpretedText2.append(packet.toXML().toString());
@ -278,7 +278,7 @@ public class LiteDebugger implements SmackDebugger {
* @param evt the event that indicates that the root window is closing * @param evt the event that indicates that the root window is closing
*/ */
public void rootWindowClosing(WindowEvent evt) { public void rootWindowClosing(WindowEvent evt) {
connection.removeAsyncPacketListener(listener); connection.removeAsyncStanzaListener(listener);
((ObservableReader)reader).removeReaderListener(readerListener); ((ObservableReader)reader).removeReaderListener(readerListener);
((ObservableWriter)writer).removeWriterListener(writerListener); ((ObservableWriter)writer).removeWriterListener(writerListener);
} }
@ -345,11 +345,11 @@ public class LiteDebugger implements SmackDebugger {
return writer; return writer;
} }
public PacketListener getReaderListener() { public StanzaListener getReaderListener() {
return listener; return listener;
} }
public PacketListener getWriterListener() { public StanzaListener getWriterListener() {
return null; return null;
} }
} }

View file

@ -25,7 +25,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -119,7 +119,7 @@ public class CarbonManager extends Manager {
public void sendCarbonsEnabled(final boolean new_state) throws NotConnectedException { public void sendCarbonsEnabled(final boolean new_state) throws NotConnectedException {
IQ setIQ = carbonsEnabledIQ(new_state); IQ setIQ = carbonsEnabledIQ(new_state);
connection().sendIqWithResponseCallback(setIQ, new PacketListener() { connection().sendIqWithResponseCallback(setIQ, new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
enabled_state = new_state; enabled_state = new_state;
} }

View file

@ -16,7 +16,7 @@
*/ */
package org.jivesoftware.smackx.bytestreams.ibb; package org.jivesoftware.smackx.bytestreams.ibb;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaFilter;
@ -38,7 +38,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
* *
* @author Henning Staib * @author Henning Staib
*/ */
class DataListener implements PacketListener { class DataListener implements StanzaListener {
/* manager containing the listeners and the XMPP connection */ /* manager containing the listeners and the XMPP connection */
private final InBandBytestreamManager manager; private final InBandBytestreamManager manager;

View file

@ -214,7 +214,7 @@ public class InBandBytestreamManager implements BytestreamManager {
// register bytestream data packet listener // register bytestream data packet listener
this.dataListener = new DataListener(this); this.dataListener = new DataListener(this);
this.connection.addSyncPacketListener(this.dataListener, this.dataListener.getFilter()); this.connection.addSyncStanzaListener(this.dataListener, this.dataListener.getFilter());
// register bytestream close packet listener // register bytestream close packet listener
this.closeListener = new CloseListener(this); this.closeListener = new CloseListener(this);
@ -542,7 +542,7 @@ public class InBandBytestreamManager implements BytestreamManager {
// remove all listeners registered by this manager // remove all listeners registered by this manager
connection.unregisterIQRequestHandler(initiationListener); connection.unregisterIQRequestHandler(initiationListener);
this.connection.removeSyncPacketListener(this.dataListener); this.connection.removeSyncStanzaListener(this.dataListener);
connection.unregisterIQRequestHandler(closeListener); connection.unregisterIQRequestHandler(closeListener);
// shutdown threads // shutdown threads

View file

@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.filter.StanzaTypeFilter; import org.jivesoftware.smack.filter.StanzaTypeFilter;
@ -235,7 +235,7 @@ public class InBandBytestreamSession implements BytestreamSession {
private abstract class IBBInputStream extends InputStream { private abstract class IBBInputStream extends InputStream {
/* the data packet listener to fill the data queue */ /* the data packet listener to fill the data queue */
private final PacketListener dataPacketListener; private final StanzaListener dataPacketListener;
/* queue containing received In-Band Bytestream data packets */ /* queue containing received In-Band Bytestream data packets */
protected final BlockingQueue<DataPacketExtension> dataQueue = new LinkedBlockingQueue<DataPacketExtension>(); protected final BlockingQueue<DataPacketExtension> dataQueue = new LinkedBlockingQueue<DataPacketExtension>();
@ -264,7 +264,7 @@ public class InBandBytestreamSession implements BytestreamSession {
public IBBInputStream() { public IBBInputStream() {
// add data packet listener to connection // add data packet listener to connection
this.dataPacketListener = getDataPacketListener(); this.dataPacketListener = getDataPacketListener();
connection.addSyncPacketListener(this.dataPacketListener, getDataPacketFilter()); connection.addSyncStanzaListener(this.dataPacketListener, getDataPacketFilter());
} }
/** /**
@ -272,7 +272,7 @@ public class InBandBytestreamSession implements BytestreamSession {
* *
* @return the data packet listener * @return the data packet listener
*/ */
protected abstract PacketListener getDataPacketListener(); protected abstract StanzaListener getDataPacketListener();
/** /**
* Returns the packet filter that accepts In-Band Bytestream data packets. * Returns the packet filter that accepts In-Band Bytestream data packets.
@ -431,7 +431,7 @@ public class InBandBytestreamSession implements BytestreamSession {
* Invoked if the session is closed. * Invoked if the session is closed.
*/ */
private void cleanup() { private void cleanup() {
connection.removeSyncPacketListener(this.dataPacketListener); connection.removeSyncStanzaListener(this.dataPacketListener);
} }
} }
@ -442,8 +442,8 @@ public class InBandBytestreamSession implements BytestreamSession {
*/ */
private class IQIBBInputStream extends IBBInputStream { private class IQIBBInputStream extends IBBInputStream {
protected PacketListener getDataPacketListener() { protected StanzaListener getDataPacketListener() {
return new PacketListener() { return new StanzaListener() {
private long lastSequence = -1; private long lastSequence = -1;
@ -505,8 +505,8 @@ public class InBandBytestreamSession implements BytestreamSession {
*/ */
private class MessageIBBInputStream extends IBBInputStream { private class MessageIBBInputStream extends IBBInputStream {
protected PacketListener getDataPacketListener() { protected StanzaListener getDataPacketListener() {
return new PacketListener() { return new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
// get data packet extension // get data packet extension

View file

@ -22,7 +22,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -311,7 +311,7 @@ public class EntityCapsManager extends Manager {
if (autoEnableEntityCaps) if (autoEnableEntityCaps)
enableEntityCaps(); enableEntityCaps();
connection.addAsyncPacketListener(new PacketListener() { connection.addAsyncStanzaListener(new StanzaListener() {
// Listen for remote presence stanzas with the caps extension // Listen for remote presence stanzas with the caps extension
// If we receive such a stanza, record the JID and nodeVer // If we receive such a stanza, record the JID and nodeVer
@Override @Override
@ -326,7 +326,7 @@ public class EntityCapsManager extends Manager {
}, PRESENCES_WITH_CAPS); }, PRESENCES_WITH_CAPS);
connection.addAsyncPacketListener(new PacketListener() { connection.addAsyncStanzaListener(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
// always remove the JID from the map, even if entityCaps are // always remove the JID from the map, even if entityCaps are
@ -336,7 +336,7 @@ public class EntityCapsManager extends Manager {
} }
}, PRESENCES_WITHOUT_CAPS); }, PRESENCES_WITHOUT_CAPS);
connection.addPacketSendingListener(new PacketListener() { connection.addPacketSendingListener(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
presenceSend = true; presenceSend = true;
@ -346,7 +346,7 @@ public class EntityCapsManager extends Manager {
// Intercept presence packages and add caps data when intended. // Intercept presence packages and add caps data when intended.
// XEP-0115 specifies that a client SHOULD include entity capabilities // XEP-0115 specifies that a client SHOULD include entity capabilities
// with every presence notification it sends. // with every presence notification it sends.
PacketListener packetInterceptor = new PacketListener() { StanzaListener packetInterceptor = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
if (!entityCapsEnabled) if (!entityCapsEnabled)
return; return;

View file

@ -24,7 +24,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -134,7 +134,7 @@ public class LastActivityManager extends Manager {
super(connection); super(connection);
// Listen to all the sent messages to reset the idle time on each one // Listen to all the sent messages to reset the idle time on each one
connection.addPacketSendingListener(new PacketListener() { connection.addPacketSendingListener(new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Presence presence = (Presence) packet; Presence presence = (Presence) packet;
Presence.Mode mode = presence.getMode(); Presence.Mode mode = presence.getMode();
@ -151,7 +151,7 @@ public class LastActivityManager extends Manager {
} }
}, StanzaTypeFilter.PRESENCE); }, StanzaTypeFilter.PRESENCE);
connection.addPacketSendingListener(new PacketListener() { connection.addPacketSendingListener(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Message message = (Message) packet; Message message = (Message) packet;

View file

@ -31,7 +31,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.MessageListener; import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.PresenceListener; import org.jivesoftware.smack.PresenceListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
@ -115,11 +115,11 @@ public class MultiUserChat {
*/ */
private final StanzaFilter fromRoomGroupchatFilter; private final StanzaFilter fromRoomGroupchatFilter;
private final PacketListener presenceInterceptor; private final StanzaListener presenceInterceptor;
private final PacketListener messageListener; private final StanzaListener messageListener;
private final PacketListener presenceListener; private final StanzaListener presenceListener;
private final PacketListener subjectListener; private final StanzaListener subjectListener;
private final PacketListener declinesListener; private final StanzaListener declinesListener;
private String subject; private String subject;
private String nickname = null; private String nickname = null;
@ -134,7 +134,7 @@ public class MultiUserChat {
fromRoomFilter = FromMatchesFilter.create(room); fromRoomFilter = FromMatchesFilter.create(room);
fromRoomGroupchatFilter = new AndFilter(fromRoomFilter, MessageTypeFilter.GROUPCHAT); fromRoomGroupchatFilter = new AndFilter(fromRoomFilter, MessageTypeFilter.GROUPCHAT);
messageListener = new PacketListener() { messageListener = new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
Message message = (Message) packet; Message message = (Message) packet;
@ -145,7 +145,7 @@ public class MultiUserChat {
}; };
// Create a listener for subject updates. // Create a listener for subject updates.
subjectListener = new PacketListener() { subjectListener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Message msg = (Message) packet; Message msg = (Message) packet;
// Update the room subject // Update the room subject
@ -158,7 +158,7 @@ public class MultiUserChat {
}; };
// Create a listener for all presence updates. // Create a listener for all presence updates.
presenceListener = new PacketListener() { presenceListener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Presence presence = (Presence) packet; Presence presence = (Presence) packet;
String from = presence.getFrom(); String from = presence.getFrom();
@ -224,7 +224,7 @@ public class MultiUserChat {
// Listens for all messages that include a MUCUser extension and fire the invitation // Listens for all messages that include a MUCUser extension and fire the invitation
// rejection listeners if the message includes an invitation rejection. // rejection listeners if the message includes an invitation rejection.
declinesListener = new PacketListener() { declinesListener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
// Get the MUC User extension // Get the MUC User extension
MUCUser mucUser = MUCUser.from(packet); MUCUser mucUser = MUCUser.from(packet);
@ -237,7 +237,7 @@ public class MultiUserChat {
} }
}; };
presenceInterceptor = new PacketListener() { presenceInterceptor = new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Presence presence = (Presence) packet; Presence presence = (Presence) packet;
@ -295,12 +295,12 @@ public class MultiUserChat {
+ nickname), new StanzaTypeFilter(Presence.class)); + nickname), new StanzaTypeFilter(Presence.class));
// Setup the messageListeners and presenceListeners *before* the join presence is send. // Setup the messageListeners and presenceListeners *before* the join presence is send.
connection.addSyncPacketListener(messageListener, fromRoomGroupchatFilter); connection.addSyncStanzaListener(messageListener, fromRoomGroupchatFilter);
connection.addSyncPacketListener(presenceListener, new AndFilter(fromRoomFilter, connection.addSyncStanzaListener(presenceListener, new AndFilter(fromRoomFilter,
StanzaTypeFilter.PRESENCE)); StanzaTypeFilter.PRESENCE));
connection.addSyncPacketListener(subjectListener, new AndFilter(fromRoomFilter, connection.addSyncStanzaListener(subjectListener, new AndFilter(fromRoomFilter,
MessageWithSubjectFilter.INSTANCE)); MessageWithSubjectFilter.INSTANCE));
connection.addSyncPacketListener(declinesListener, new AndFilter(new StanzaExtensionFilter(MUCUser.ELEMENT, connection.addSyncStanzaListener(declinesListener, new AndFilter(new StanzaExtensionFilter(MUCUser.ELEMENT,
MUCUser.NAMESPACE), new NotFilter(MessageTypeFilter.ERROR))); MUCUser.NAMESPACE), new NotFilter(MessageTypeFilter.ERROR)));
connection.addPacketInterceptor(presenceInterceptor, new AndFilter(new ToFilter(room), connection.addPacketInterceptor(presenceInterceptor, new AndFilter(new ToFilter(room),
StanzaTypeFilter.PRESENCE)); StanzaTypeFilter.PRESENCE));
@ -754,7 +754,7 @@ public class MultiUserChat {
} }
/** /**
* Adds a new {@link PacketListener} that will be invoked every time a new presence * Adds a new {@link StanzaListener} that will be invoked every time a new presence
* is going to be sent by this MultiUserChat to the server. Packet interceptors may * is going to be sent by this MultiUserChat to the server. Packet interceptors may
* add new extensions to the presence that is going to be sent to the MUC service. * add new extensions to the presence that is going to be sent to the MUC service.
* *
@ -765,13 +765,13 @@ public class MultiUserChat {
} }
/** /**
* Removes a {@link PacketListener} that was being invoked every time a new presence * Removes a {@link StanzaListener} that was being invoked every time a new presence
* was being sent by this MultiUserChat to the server. Packet interceptors may * was being sent by this MultiUserChat to the server. Packet interceptors may
* add new extensions to the presence that is going to be sent to the MUC service. * add new extensions to the presence that is going to be sent to the MUC service.
* *
* @param presenceInterceptor the packet interceptor to remove. * @param presenceInterceptor the packet interceptor to remove.
*/ */
public void removePresenceInterceptor(PacketListener presenceInterceptor) { public void removePresenceInterceptor(StanzaListener presenceInterceptor) {
presenceInterceptors.remove(presenceInterceptor); presenceInterceptors.remove(presenceInterceptor);
} }
@ -1724,9 +1724,9 @@ public class MultiUserChat {
* connection. * connection.
*/ */
private void removeConnectionCallbacks() { private void removeConnectionCallbacks() {
connection.removeSyncPacketListener(messageListener); connection.removeSyncStanzaListener(messageListener);
connection.removeSyncPacketListener(presenceListener); connection.removeSyncStanzaListener(presenceListener);
connection.removeSyncPacketListener(declinesListener); connection.removeSyncStanzaListener(declinesListener);
connection.removePacketInterceptor(presenceInterceptor); connection.removePacketInterceptor(presenceInterceptor);
if (messageCollector != null) { if (messageCollector != null) {
messageCollector.cancel(); messageCollector.cancel();

View file

@ -29,7 +29,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
@ -117,7 +117,7 @@ public class MultiUserChatManager extends Manager {
super(connection); super(connection);
// Listens for all messages that include a MUCUser extension and fire the invitation // Listens for all messages that include a MUCUser extension and fire the invitation
// listeners if the message includes an invitation. // listeners if the message includes an invitation.
PacketListener invitationPacketListener = new PacketListener() { StanzaListener invitationPacketListener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
final Message message = (Message) packet; final Message message = (Message) packet;
// Get the MUCUser extension // Get the MUCUser extension
@ -133,7 +133,7 @@ public class MultiUserChatManager extends Manager {
} }
} }
}; };
connection.addAsyncPacketListener(invitationPacketListener, INVITATION_FILTER); connection.addAsyncStanzaListener(invitationPacketListener, INVITATION_FILTER);
} }
/** /**

View file

@ -20,7 +20,7 @@ package org.jivesoftware.smackx.pep;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.StanzaExtensionFilter; import org.jivesoftware.smack.filter.StanzaExtensionFilter;
@ -65,7 +65,7 @@ public class PEPManager {
private XMPPConnection connection; private XMPPConnection connection;
private StanzaFilter packetFilter = new StanzaExtensionFilter("event", "http://jabber.org/protocol/pubsub#event"); private StanzaFilter packetFilter = new StanzaExtensionFilter("event", "http://jabber.org/protocol/pubsub#event");
private PacketListener packetListener; private StanzaListener packetListener;
/** /**
* Creates a new PEP exchange manager. * Creates a new PEP exchange manager.
@ -134,7 +134,7 @@ public class PEPManager {
private void init() { private void init() {
// Listens for all roster exchange packets and fire the roster exchange listeners. // Listens for all roster exchange packets and fire the roster exchange listeners.
packetListener = new PacketListener() { packetListener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Message message = (Message) packet; Message message = (Message) packet;
PEPEvent event = (PEPEvent) message.getExtension("event", "http://jabber.org/protocol/pubsub#event"); PEPEvent event = (PEPEvent) message.getExtension("event", "http://jabber.org/protocol/pubsub#event");
@ -142,12 +142,12 @@ public class PEPManager {
firePEPListeners(message.getFrom(), event); firePEPListeners(message.getFrom(), event);
} }
}; };
connection.addSyncPacketListener(packetListener, packetFilter); connection.addSyncStanzaListener(packetListener, packetFilter);
} }
public void destroy() { public void destroy() {
if (connection != null) if (connection != null)
connection.removeSyncPacketListener(packetListener); connection.removeSyncStanzaListener(packetListener);
} }
protected void finalize() throws Throwable { protected void finalize() throws Throwable {

View file

@ -29,7 +29,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
@ -123,7 +123,7 @@ public class PrivacyListManager extends Manager {
}); });
// cached(Active|Default)ListName handling // cached(Active|Default)ListName handling
connection.addPacketSendingListener(new PacketListener() { connection.addPacketSendingListener(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
XMPPConnection connection = connection(); XMPPConnection connection = connection();
@ -131,7 +131,7 @@ public class PrivacyListManager extends Manager {
StanzaFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection); StanzaFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection);
final String activeListName = privacy.getActiveName(); final String activeListName = privacy.getActiveName();
final boolean declinceActiveList = privacy.isDeclineActiveList(); final boolean declinceActiveList = privacy.isDeclineActiveList();
connection.addOneTimeSyncCallback(new PacketListener() { connection.addOneTimeSyncCallback(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
if (declinceActiveList) { if (declinceActiveList) {
@ -145,7 +145,7 @@ public class PrivacyListManager extends Manager {
}, iqResultReplyFilter); }, iqResultReplyFilter);
} }
}, SetActiveListFilter.INSTANCE); }, SetActiveListFilter.INSTANCE);
connection.addPacketSendingListener(new PacketListener() { connection.addPacketSendingListener(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
XMPPConnection connection = connection(); XMPPConnection connection = connection();
@ -153,7 +153,7 @@ public class PrivacyListManager extends Manager {
StanzaFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection); StanzaFilter iqResultReplyFilter = new IQResultReplyFilter(privacy, connection);
final String defaultListName = privacy.getDefaultName(); final String defaultListName = privacy.getDefaultName();
final boolean declinceDefaultList = privacy.isDeclineDefaultList(); final boolean declinceDefaultList = privacy.isDeclineDefaultList();
connection.addOneTimeSyncCallback(new PacketListener() { connection.addOneTimeSyncCallback(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
if (declinceDefaultList) { if (declinceDefaultList) {
@ -167,7 +167,7 @@ public class PrivacyListManager extends Manager {
}, iqResultReplyFilter); }, iqResultReplyFilter);
} }
}, SetDefaultListFilter.INSTANCE); }, SetDefaultListFilter.INSTANCE);
connection.addSyncPacketListener(new PacketListener() { connection.addSyncStanzaListener(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
Privacy privacy = (Privacy) packet; Privacy privacy = (Privacy) packet;

View file

@ -21,7 +21,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
@ -50,9 +50,9 @@ abstract public class Node
protected String id; protected String id;
protected String to; protected String to;
protected ConcurrentHashMap<ItemEventListener<Item>, PacketListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, PacketListener>(); protected ConcurrentHashMap<ItemEventListener<Item>, StanzaListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, StanzaListener>();
protected ConcurrentHashMap<ItemDeleteListener, PacketListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, PacketListener>(); protected ConcurrentHashMap<ItemDeleteListener, StanzaListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, StanzaListener>();
protected ConcurrentHashMap<NodeConfigListener, PacketListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, PacketListener>(); protected ConcurrentHashMap<NodeConfigListener, StanzaListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, StanzaListener>();
/** /**
* Construct a node associated to the supplied connection with the specified * Construct a node associated to the supplied connection with the specified
@ -397,9 +397,9 @@ abstract public class Node
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void addItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener) public void addItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener)
{ {
PacketListener conListener = new ItemEventTranslator(listener); StanzaListener conListener = new ItemEventTranslator(listener);
itemEventToListenerMap.put(listener, conListener); itemEventToListenerMap.put(listener, conListener);
con.addSyncPacketListener(conListener, new EventContentFilter(EventElementType.items.toString(), "item")); con.addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.items.toString(), "item"));
} }
/** /**
@ -409,10 +409,10 @@ abstract public class Node
*/ */
public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener) public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener)
{ {
PacketListener conListener = itemEventToListenerMap.remove(listener); StanzaListener conListener = itemEventToListenerMap.remove(listener);
if (conListener != null) if (conListener != null)
con.removeSyncPacketListener(conListener); con.removeSyncStanzaListener(conListener);
} }
/** /**
@ -423,9 +423,9 @@ abstract public class Node
*/ */
public void addConfigurationListener(NodeConfigListener listener) public void addConfigurationListener(NodeConfigListener listener)
{ {
PacketListener conListener = new NodeConfigTranslator(listener); StanzaListener conListener = new NodeConfigTranslator(listener);
configEventToListenerMap.put(listener, conListener); configEventToListenerMap.put(listener, conListener);
con.addSyncPacketListener(conListener, new EventContentFilter(EventElementType.configuration.toString())); con.addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.configuration.toString()));
} }
/** /**
@ -435,10 +435,10 @@ abstract public class Node
*/ */
public void removeConfigurationListener(NodeConfigListener listener) public void removeConfigurationListener(NodeConfigListener listener)
{ {
PacketListener conListener = configEventToListenerMap .remove(listener); StanzaListener conListener = configEventToListenerMap .remove(listener);
if (conListener != null) if (conListener != null)
con.removeSyncPacketListener(conListener); con.removeSyncStanzaListener(conListener);
} }
/** /**
@ -449,12 +449,12 @@ abstract public class Node
*/ */
public void addItemDeleteListener(ItemDeleteListener listener) public void addItemDeleteListener(ItemDeleteListener listener)
{ {
PacketListener delListener = new ItemDeleteTranslator(listener); StanzaListener delListener = new ItemDeleteTranslator(listener);
itemDeleteToListenerMap.put(listener, delListener); itemDeleteToListenerMap.put(listener, delListener);
EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract"); EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract");
EventContentFilter purge = new EventContentFilter(EventElementType.purge.toString()); EventContentFilter purge = new EventContentFilter(EventElementType.purge.toString());
con.addSyncPacketListener(delListener, new OrFilter(deleteItem, purge)); con.addSyncStanzaListener(delListener, new OrFilter(deleteItem, purge));
} }
/** /**
@ -464,10 +464,10 @@ abstract public class Node
*/ */
public void removeItemDeleteListener(ItemDeleteListener listener) public void removeItemDeleteListener(ItemDeleteListener listener)
{ {
PacketListener conListener = itemDeleteToListenerMap .remove(listener); StanzaListener conListener = itemDeleteToListenerMap .remove(listener);
if (conListener != null) if (conListener != null)
con.removeSyncPacketListener(conListener); con.removeSyncStanzaListener(conListener);
} }
@Override @Override
@ -515,7 +515,7 @@ abstract public class Node
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ItemEventTranslator implements PacketListener public class ItemEventTranslator implements StanzaListener
{ {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private ItemEventListener listener; private ItemEventListener listener;
@ -541,7 +541,7 @@ abstract public class Node
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ItemDeleteTranslator implements PacketListener public class ItemDeleteTranslator implements StanzaListener
{ {
private ItemDeleteListener listener; private ItemDeleteListener listener;
@ -584,7 +584,7 @@ abstract public class Node
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class NodeConfigTranslator implements PacketListener public class NodeConfigTranslator implements StanzaListener
{ {
private NodeConfigListener listener; private NodeConfigListener listener;
@ -603,7 +603,7 @@ abstract public class Node
} }
/** /**
* Filter for {@link PacketListener} to filter out events not specific to the * Filter for {@link StanzaListener} to filter out events not specific to the
* event type expected for this node. * event type expected for this node.
* *
* @author Robin Collier * @author Robin Collier

View file

@ -26,7 +26,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
@ -127,7 +127,7 @@ public class DeliveryReceiptManager extends Manager {
sdm.addFeature(DeliveryReceipt.NAMESPACE); sdm.addFeature(DeliveryReceipt.NAMESPACE);
// Add the packet listener to handling incoming delivery receipts // Add the packet listener to handling incoming delivery receipts
connection.addAsyncPacketListener(new PacketListener() { connection.addAsyncStanzaListener(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
DeliveryReceipt dr = DeliveryReceipt.from(packet); DeliveryReceipt dr = DeliveryReceipt.from(packet);
@ -139,7 +139,7 @@ public class DeliveryReceiptManager extends Manager {
}, MESSAGES_WITH_DELIVERY_RECEIPT); }, MESSAGES_WITH_DELIVERY_RECEIPT);
// Add the packet listener to handle incoming delivery receipt requests // Add the packet listener to handle incoming delivery receipt requests
connection.addAsyncPacketListener(new PacketListener() { connection.addAsyncStanzaListener(new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
final String from = packet.getFrom(); final String from = packet.getFrom();
@ -232,7 +232,7 @@ public class DeliveryReceiptManager extends Manager {
receiptReceivedListeners.remove(listener); receiptReceivedListeners.remove(listener);
} }
private static final PacketListener AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER = new PacketListener() { private static final StanzaListener AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER = new StanzaListener() {
@Override @Override
public void processPacket(Stanza packet) throws NotConnectedException { public void processPacket(Stanza packet) throws NotConnectedException {
Message message = (Message) packet; Message message = (Message) packet;

View file

@ -25,7 +25,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Random; import java.util.Random;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
@ -260,7 +260,7 @@ public class InBandBytestreamSessionMessageTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build invalid packet with out of order sequence // build invalid packet with out of order sequence
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
@ -300,7 +300,7 @@ public class InBandBytestreamSessionMessageTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// verify data packet and notify listener // verify data packet and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) { for (int i = 0; i < controlData.length / blockSize; i++) {
@ -345,7 +345,7 @@ public class InBandBytestreamSessionMessageTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// verify data packet and notify listener // verify data packet and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) { for (int i = 0; i < controlData.length / blockSize; i++) {

View file

@ -27,7 +27,7 @@ import java.util.Random;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.packet.XMPPError;
@ -307,7 +307,7 @@ public class InBandBytestreamSessionTest {
// insert data to read // insert data to read
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data); DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data);
Data data = new Data(dpe); Data data = new Data(dpe);
@ -341,7 +341,7 @@ public class InBandBytestreamSessionTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data); DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data);
@ -378,7 +378,7 @@ public class InBandBytestreamSessionTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build data packets // build data packets
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
@ -416,7 +416,7 @@ public class InBandBytestreamSessionTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build data packets // build data packets
DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, "AA=BB"); DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, "AA=BB");
@ -450,7 +450,7 @@ public class InBandBytestreamSessionTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build invalid packet with out of order sequence // build invalid packet with out of order sequence
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
@ -491,7 +491,7 @@ public class InBandBytestreamSessionTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// set data packet acknowledgment and notify listener // set data packet acknowledgment and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) { for (int i = 0; i < controlData.length / blockSize; i++) {
@ -538,7 +538,7 @@ public class InBandBytestreamSessionTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// set data packet acknowledgment and notify listener // set data packet acknowledgment and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) { for (int i = 0; i < controlData.length / blockSize; i++) {
@ -579,7 +579,7 @@ public class InBandBytestreamSessionTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build data packet // build data packet
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
@ -622,7 +622,7 @@ public class InBandBytestreamSessionTest {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
final InputStream inputStream = session.getInputStream(); final InputStream inputStream = session.getInputStream();
PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build data packet // build data packet
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");

View file

@ -28,7 +28,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.MessageListener; import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
@ -142,7 +142,7 @@ public class ChatManager extends Manager{
// Add a listener for all message packets so that we can deliver // Add a listener for all message packets so that we can deliver
// messages to the best Chat instance available. // messages to the best Chat instance available.
connection.addSyncPacketListener(new PacketListener() { connection.addSyncStanzaListener(new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Message message = (Message) packet; Message message = (Message) packet;
Chat chat; Chat chat;

View file

@ -38,7 +38,7 @@ import org.jivesoftware.smack.AbstractConnectionClosedListener;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ExceptionCallback; import org.jivesoftware.smack.ExceptionCallback;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
@ -195,7 +195,7 @@ public class Roster extends Manager {
// Listen for any roster packets. // Listen for any roster packets.
connection.registerIQRequestHandler(new RosterPushListener()); connection.registerIQRequestHandler(new RosterPushListener());
// Listen for any presence packets. // Listen for any presence packets.
connection.addSyncPacketListener(presencePacketListener, PRESENCE_PACKET_FILTER); connection.addSyncStanzaListener(presencePacketListener, PRESENCE_PACKET_FILTER);
// Listen for connection events // Listen for connection events
connection.addConnectionListener(new AbstractConnectionClosedListener() { connection.addConnectionListener(new AbstractConnectionClosedListener() {
@ -1159,7 +1159,7 @@ public class Roster extends Manager {
/** /**
* Listens for all presence packets and processes them. * Listens for all presence packets and processes them.
*/ */
private class PresencePacketListener implements PacketListener { private class PresencePacketListener implements StanzaListener {
/** /**
* Retrieve the user presences (a map from resource to {@link Presence}) for a given key (usually a JID without * Retrieve the user presences (a map from resource to {@link Presence}) for a given key (usually a JID without
@ -1282,7 +1282,7 @@ public class Roster extends Manager {
/** /**
* Handles roster reults as described in RFC 6121 2.1.4 * Handles roster reults as described in RFC 6121 2.1.4
*/ */
private class RosterResultListener implements PacketListener { private class RosterResultListener implements StanzaListener {
@Override @Override
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {

View file

@ -51,7 +51,7 @@ public class ChatConnectionTest {
listener = new TestChatManagerListener(); listener = new TestChatManagerListener();
cm.addChatListener(listener); cm.addChatListener(listener);
waitListener = new WaitForPacketListener(); waitListener = new WaitForPacketListener();
dc.addSyncPacketListener(waitListener, null); dc.addSyncStanzaListener(waitListener, null);
} }
@After @After

View file

@ -22,7 +22,7 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPConnectionRegistry;
@ -462,7 +462,7 @@ public class JingleManager implements JingleSessionListener {
jingleSessionRequestListeners = new ArrayList<JingleSessionRequestListener>(); jingleSessionRequestListeners = new ArrayList<JingleSessionRequestListener>();
// Start a packet listener for session initiation requests // Start a packet listener for session initiation requests
connection.addAsyncPacketListener(new PacketListener() { connection.addAsyncStanzaListener(new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
triggerSessionRequested((Jingle) packet); triggerSessionRequested((Jingle) packet);
} }

View file

@ -25,7 +25,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.AbstractConnectionClosedListener; import org.jivesoftware.smack.AbstractConnectionClosedListener;
import org.jivesoftware.smack.ConnectionListener; import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
@ -77,7 +77,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
ConnectionListener connectionListener; ConnectionListener connectionListener;
PacketListener packetListener; StanzaListener packetListener;
StanzaFilter packetFilter; StanzaFilter packetFilter;
@ -651,7 +651,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
*/ */
protected void removeAsyncPacketListener() { protected void removeAsyncPacketListener() {
if (packetListener != null) { if (packetListener != null) {
getConnection().removeAsyncPacketListener(packetListener); getConnection().removeAsyncStanzaListener(packetListener);
LOGGER.fine("JINGLE SESSION: REMOVE PACKET LISTENER"); LOGGER.fine("JINGLE SESSION: REMOVE PACKET LISTENER");
} }
@ -666,7 +666,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
LOGGER.fine("UpdatePacketListener"); LOGGER.fine("UpdatePacketListener");
packetListener = new PacketListener() { packetListener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
try { try {
receivePacketAndRespond((IQ) packet); receivePacketAndRespond((IQ) packet);
@ -723,7 +723,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
} }
}; };
getConnection().addAsyncPacketListener(packetListener, packetFilter); getConnection().addAsyncStanzaListener(packetListener, packetFilter);
} }
// Listeners // Listeners

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.workgroup.agent;
import org.jivesoftware.smackx.workgroup.packet.AgentStatus; import org.jivesoftware.smackx.workgroup.packet.AgentStatus;
import org.jivesoftware.smackx.workgroup.packet.AgentStatusRequest; import org.jivesoftware.smackx.workgroup.packet.AgentStatusRequest;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaFilter;
@ -74,9 +74,9 @@ public class AgentRoster {
presenceMap = new HashMap<String, Map<String, Presence>>(); presenceMap = new HashMap<String, Map<String, Presence>>();
// Listen for any roster packets. // Listen for any roster packets.
StanzaFilter rosterFilter = new StanzaTypeFilter(AgentStatusRequest.class); StanzaFilter rosterFilter = new StanzaTypeFilter(AgentStatusRequest.class);
connection.addAsyncPacketListener(new AgentStatusListener(), rosterFilter); connection.addAsyncStanzaListener(new AgentStatusListener(), rosterFilter);
// Listen for any presence packets. // Listen for any presence packets.
connection.addAsyncPacketListener(new PresencePacketListener(), connection.addAsyncStanzaListener(new PresencePacketListener(),
new StanzaTypeFilter(Presence.class)); new StanzaTypeFilter(Presence.class));
// Send request for roster. // Send request for roster.
@ -281,7 +281,7 @@ public class AgentRoster {
/** /**
* Listens for all presence packets and processes them. * Listens for all presence packets and processes them.
*/ */
private class PresencePacketListener implements PacketListener { private class PresencePacketListener implements StanzaListener {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Presence presence = (Presence)packet; Presence presence = (Presence)packet;
String from = presence.getFrom(); String from = presence.getFrom();
@ -356,7 +356,7 @@ public class AgentRoster {
/** /**
* Listens for all roster packets and processes them. * Listens for all roster packets and processes them.
*/ */
private class AgentStatusListener implements PacketListener { private class AgentStatusListener implements StanzaListener {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
if (packet instanceof AgentStatusRequest) { if (packet instanceof AgentStatusRequest) {

View file

@ -30,7 +30,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -108,7 +108,7 @@ public class AgentSession {
private TranscriptManager transcriptManager; private TranscriptManager transcriptManager;
private TranscriptSearchManager transcriptSearchManager; private TranscriptSearchManager transcriptSearchManager;
private Agent agent; private Agent agent;
private PacketListener packetListener; private StanzaListener packetListener;
/** /**
* Constructs a new agent session instance. Note, the {@link #setOnline(boolean)} * Constructs a new agent session instance. Note, the {@link #setOnline(boolean)}
@ -147,7 +147,7 @@ public class AgentSession {
new StanzaTypeFilter(Presence.class), new StanzaTypeFilter(Presence.class),
new StanzaTypeFilter(Message.class)); new StanzaTypeFilter(Message.class));
packetListener = new PacketListener() { packetListener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
try { try {
handlePacket(packet); handlePacket(packet);
@ -157,7 +157,7 @@ public class AgentSession {
} }
} }
}; };
connection.addAsyncPacketListener(packetListener, filter); connection.addAsyncStanzaListener(packetListener, filter);
// Create the agent associated to this session // Create the agent associated to this session
agent = new Agent(connection, workgroupJID); agent = new Agent(connection, workgroupJID);
} }
@ -167,7 +167,7 @@ public class AgentSession {
* packet listeners that were added by this agent session will be removed. * packet listeners that were added by this agent session will be removed.
*/ */
public void close() { public void close() {
connection.removeAsyncPacketListener(packetListener); connection.removeAsyncStanzaListener(packetListener);
} }
/** /**

View file

@ -22,7 +22,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.jivesoftware.smack.PacketCollector; import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -142,7 +142,7 @@ public class Workgroup {
// Register a packet listener for all the messages sent to this client. // Register a packet listener for all the messages sent to this client.
StanzaFilter typeFilter = new StanzaTypeFilter(Message.class); StanzaFilter typeFilter = new StanzaTypeFilter(Message.class);
connection.addAsyncPacketListener(new PacketListener() { connection.addAsyncStanzaListener(new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
handlePacket(packet); handlePacket(packet);
} }

View file

@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
@ -75,7 +75,7 @@ public class MessageEventManager extends Manager {
private MessageEventManager(XMPPConnection connection) { private MessageEventManager(XMPPConnection connection) {
super(connection); super(connection);
// Listens for all message event packets and fire the proper message event listeners. // Listens for all message event packets and fire the proper message event listeners.
connection.addAsyncPacketListener(new PacketListener() { connection.addAsyncStanzaListener(new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Message message = (Message) packet; Message message = (Message) packet;
MessageEvent messageEvent = MessageEvent messageEvent =

View file

@ -24,7 +24,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.StanzaExtensionFilter; import org.jivesoftware.smack.filter.StanzaExtensionFilter;
@ -57,7 +57,7 @@ public class RosterExchangeManager {
private final Set<RosterExchangeListener> rosterExchangeListeners = Collections.synchronizedSet(new HashSet<RosterExchangeListener>()); private final Set<RosterExchangeListener> rosterExchangeListeners = Collections.synchronizedSet(new HashSet<RosterExchangeListener>());
private final WeakReference<XMPPConnection> weakRefConnection; private final WeakReference<XMPPConnection> weakRefConnection;
private final PacketListener packetListener; private final StanzaListener packetListener;
public synchronized static RosterExchangeManager getInstanceFor(XMPPConnection connection) { public synchronized static RosterExchangeManager getInstanceFor(XMPPConnection connection) {
RosterExchangeManager rosterExchangeManager = INSTANCES.get(connection); RosterExchangeManager rosterExchangeManager = INSTANCES.get(connection);
@ -76,7 +76,7 @@ public class RosterExchangeManager {
public RosterExchangeManager(XMPPConnection connection) { public RosterExchangeManager(XMPPConnection connection) {
weakRefConnection = new WeakReference<XMPPConnection>(connection); weakRefConnection = new WeakReference<XMPPConnection>(connection);
// Listens for all roster exchange packets and fire the roster exchange listeners. // Listens for all roster exchange packets and fire the roster exchange listeners.
packetListener = new PacketListener() { packetListener = new StanzaListener() {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
Message message = (Message) packet; Message message = (Message) packet;
RosterExchange rosterExchange = RosterExchange rosterExchange =
@ -85,7 +85,7 @@ public class RosterExchangeManager {
fireRosterExchangeListeners(message.getFrom(), rosterExchange.getRosterEntries()); fireRosterExchangeListeners(message.getFrom(), rosterExchange.getRosterEntries());
} }
}; };
connection.addAsyncPacketListener(packetListener, PACKET_FILTER); connection.addAsyncStanzaListener(packetListener, PACKET_FILTER);
} }
/** /**

View file

@ -20,7 +20,7 @@ import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.AlreadyConnectedException; import org.jivesoftware.smack.SmackException.AlreadyConnectedException;
@ -264,13 +264,13 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* themselves after they have been invoked. * themselves after they have been invoked.
* </p> * </p>
*/ */
private final Collection<PacketListener> stanzaAcknowledgedListeners = new ConcurrentLinkedQueue<PacketListener>(); private final Collection<StanzaListener> stanzaAcknowledgedListeners = new ConcurrentLinkedQueue<StanzaListener>();
/** /**
* This listeners are invoked for a acknowledged stanza that has the given stanza ID. They will * This listeners are invoked for a acknowledged stanza that has the given stanza ID. They will
* only be invoked once and automatically removed after that. * only be invoked once and automatically removed after that.
*/ */
private final Map<String, PacketListener> stanzaIdAcknowledgedListeners = new ConcurrentHashMap<String, PacketListener>(); private final Map<String, StanzaListener> stanzaIdAcknowledgedListeners = new ConcurrentHashMap<String, StanzaListener>();
/** /**
* Predicates that determine if an stream management ack should be requested from the server. * Predicates that determine if an stream management ack should be requested from the server.
@ -613,7 +613,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// If debugging is enabled, we should start the thread that will listen for // If debugging is enabled, we should start the thread that will listen for
// all packets and then log them. // all packets and then log them.
if (config.isDebuggerEnabled()) { if (config.isDebuggerEnabled()) {
addAsyncPacketListener(debugger.getReaderListener(), null); addAsyncStanzaListener(debugger.getReaderListener(), null);
if (debugger.getWriterListener() != null) { if (debugger.getWriterListener() != null) {
addPacketSendingListener(debugger.getWriterListener(), null); addPacketSendingListener(debugger.getWriterListener(), null);
} }
@ -1556,13 +1556,13 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* Add a Stanza acknowledged listener. * Add a Stanza acknowledged listener.
* <p> * <p>
* Those listeners will be invoked every time a Stanza has been acknowledged by the server. The will not get * Those listeners will be invoked every time a Stanza has been acknowledged by the server. The will not get
* automatically removed. Consider using {@link #addStanzaIdAcknowledgedListener(String, PacketListener)} when * automatically removed. Consider using {@link #addStanzaIdAcknowledgedListener(String, StanzaListener)} when
* possible. * possible.
* </p> * </p>
* *
* @param listener the listener to add. * @param listener the listener to add.
*/ */
public void addStanzaAcknowledgedListener(PacketListener listener) { public void addStanzaAcknowledgedListener(StanzaListener listener) {
stanzaAcknowledgedListeners.add(listener); stanzaAcknowledgedListeners.add(listener);
} }
@ -1572,7 +1572,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* @param listener the listener. * @param listener the listener.
* @return true if the listener was removed. * @return true if the listener was removed.
*/ */
public boolean removeStanzaAcknowledgedListener(PacketListener listener) { public boolean removeStanzaAcknowledgedListener(StanzaListener listener) {
return stanzaAcknowledgedListeners.remove(listener); return stanzaAcknowledgedListeners.remove(listener);
} }
@ -1595,7 +1595,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* @return the previous listener for this stanza ID or null. * @return the previous listener for this stanza ID or null.
* @throws StreamManagementNotEnabledException if Stream Management is not enabled. * @throws StreamManagementNotEnabledException if Stream Management is not enabled.
*/ */
public PacketListener addStanzaIdAcknowledgedListener(final String id, PacketListener listener) throws StreamManagementNotEnabledException { public StanzaListener addStanzaIdAcknowledgedListener(final String id, StanzaListener listener) throws StreamManagementNotEnabledException {
// Prevent users from adding callbacks that will never get removed // Prevent users from adding callbacks that will never get removed
if (!smWasEnabledAtLeastOnce) { if (!smWasEnabledAtLeastOnce) {
throw new StreamManagementException.StreamManagementNotEnabledException(); throw new StreamManagementException.StreamManagementNotEnabledException();
@ -1617,7 +1617,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* @param id the stanza ID. * @param id the stanza ID.
* @return true if the listener was found and removed, false otherwise. * @return true if the listener was found and removed, false otherwise.
*/ */
public PacketListener removeStanzaIdAcknowledgedListener(String id) { public StanzaListener removeStanzaIdAcknowledgedListener(String id) {
return stanzaIdAcknowledgedListeners.remove(id); return stanzaIdAcknowledgedListeners.remove(id);
} }
@ -1739,7 +1739,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
@Override @Override
public void run() { public void run() {
for (Stanza ackedStanza : ackedStanzas) { for (Stanza ackedStanza : ackedStanzas) {
for (PacketListener listener : stanzaAcknowledgedListeners) { for (StanzaListener listener : stanzaAcknowledgedListeners) {
try { try {
listener.processPacket(ackedStanza); listener.processPacket(ackedStanza);
} }
@ -1751,7 +1751,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
if (StringUtils.isNullOrEmpty(id)) { if (StringUtils.isNullOrEmpty(id)) {
continue; continue;
} }
PacketListener listener = stanzaIdAcknowledgedListeners.remove(id); StanzaListener listener = stanzaIdAcknowledgedListeners.remove(id);
if (listener != null) { if (listener != null) {
try { try {
listener.processPacket(ackedStanza); listener.processPacket(ackedStanza);