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

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
* specified filter. The collector lets you perform blocking and polling
* operations on the result queue. So, a PacketCollector is more suitable to
* use than a {@link PacketListener} when you need to wait for a specific
* use than a {@link StanzaListener} when you need to wait for a specific
* result.<p>
*
* Each packet collector will queue up a configured number of packets for processing before

View file

@ -17,37 +17,10 @@
package org.jivesoftware.smack;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Stanza;
/**
* Provides a mechanism to listen for packets that pass a specified filter.
* This allows event-style programming -- every time a new packet is found,
* the {@link #processPacket(Stanza)} method will be called. This is the
* opposite approach to the functionality provided by a {@link PacketCollector}
* which lets you block while waiting for results.
* <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
* @deprecated use {@link StanzaListener} instead
*/
public interface PacketListener {
/**
* 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;
@Deprecated
public interface PacketListener extends StanzaListener {
}

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,7 +20,7 @@ import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.AlreadyConnectedException;
@ -264,13 +264,13 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* themselves after they have been invoked.
* </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
* 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.
@ -613,7 +613,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// If debugging is enabled, we should start the thread that will listen for
// all packets and then log them.
if (config.isDebuggerEnabled()) {
addAsyncPacketListener(debugger.getReaderListener(), null);
addAsyncStanzaListener(debugger.getReaderListener(), null);
if (debugger.getWriterListener() != null) {
addPacketSendingListener(debugger.getWriterListener(), null);
}
@ -1556,13 +1556,13 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* Add a Stanza acknowledged listener.
* <p>
* 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.
* </p>
*
* @param listener the listener to add.
*/
public void addStanzaAcknowledgedListener(PacketListener listener) {
public void addStanzaAcknowledgedListener(StanzaListener listener) {
stanzaAcknowledgedListeners.add(listener);
}
@ -1572,7 +1572,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* @param listener the listener.
* @return true if the listener was removed.
*/
public boolean removeStanzaAcknowledgedListener(PacketListener listener) {
public boolean removeStanzaAcknowledgedListener(StanzaListener listener) {
return stanzaAcknowledgedListeners.remove(listener);
}
@ -1595,7 +1595,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* @return the previous listener for this stanza ID or null.
* @throws StreamManagementNotEnabledException if Stream Management is not enabled.
*/
public PacketListener addStanzaIdAcknowledgedListener(final String id, PacketListener listener) throws StreamManagementNotEnabledException {
public StanzaListener addStanzaIdAcknowledgedListener(final String id, StanzaListener listener) throws StreamManagementNotEnabledException {
// Prevent users from adding callbacks that will never get removed
if (!smWasEnabledAtLeastOnce) {
throw new StreamManagementException.StreamManagementNotEnabledException();
@ -1617,7 +1617,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
* @param id the stanza ID.
* @return true if the listener was found and removed, false otherwise.
*/
public PacketListener removeStanzaIdAcknowledgedListener(String id) {
public StanzaListener removeStanzaIdAcknowledgedListener(String id) {
return stanzaIdAcknowledgedListeners.remove(id);
}
@ -1739,7 +1739,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
@Override
public void run() {
for (Stanza ackedStanza : ackedStanzas) {
for (PacketListener listener : stanzaAcknowledgedListeners) {
for (StanzaListener listener : stanzaAcknowledgedListeners) {
try {
listener.processPacket(ackedStanza);
}
@ -1751,7 +1751,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
if (StringUtils.isNullOrEmpty(id)) {
continue;
}
PacketListener listener = stanzaIdAcknowledgedListeners.remove(id);
StanzaListener listener = stanzaIdAcknowledgedListeners.remove(id);
if (listener != null) {
try {
listener.processPacket(ackedStanza);