1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 02:27:58 +01:00

Merge pull request #209 from fuentesj11/rename-deprecate-xmppconnection-methods

Rename and deprecate XMPPConnection methods
This commit is contained in:
Florian Schmaus 2018-03-28 12:11:32 +02:00 committed by GitHub
commit 5b9254aff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 103 additions and 23 deletions

View file

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

View file

@ -849,8 +849,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
}
@Deprecated
@Override
public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter) {
addStanzaSendingListener(packetListener, packetFilter);
}
@Override
public void addStanzaSendingListener(StanzaListener packetListener, StanzaFilter packetFilter) {
if (packetListener == null) {
throw new NullPointerException("Packet listener is null.");
}
@ -860,8 +866,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
}
@Deprecated
@Override
public void removePacketSendingListener(StanzaListener packetListener) {
removeStanzaSendingListener(packetListener);
}
@Override
public void removeStanzaSendingListener(StanzaListener packetListener) {
synchronized (sendListeners) {
sendListeners.remove(packetListener);
}
@ -905,8 +917,15 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
});
}
@Deprecated
@Override
public void addPacketInterceptor(StanzaListener packetInterceptor,
StanzaFilter packetFilter) {
addStanzaInterceptor(packetInterceptor, packetFilter);
}
@Override
public void addStanzaInterceptor(StanzaListener packetInterceptor,
StanzaFilter packetFilter) {
if (packetInterceptor == null) {
throw new NullPointerException("Packet interceptor is null.");
@ -917,8 +936,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
}
@Deprecated
@Override
public void removePacketInterceptor(StanzaListener packetInterceptor) {
removeStanzaInterceptor(packetInterceptor);
}
@Override
public void removeStanzaInterceptor(StanzaListener packetInterceptor) {
synchronized (interceptors) {
interceptors.remove(packetInterceptor);
}

View file

@ -30,7 +30,7 @@ import org.jivesoftware.smack.packet.Stanza;
* <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,
* by using {@link XMPPConnection#addStanzaInterceptor(StanzaListener,
* org.jivesoftware.smack.filter.StanzaFilter)}
* </p>
*

View file

@ -321,7 +321,7 @@ public interface XMPPConnection {
*
* @param packetListener the stanza(/packet) listener to notify of new received packets.
* @param packetFilter the stanza(/packet) filter to use.
* @see #addPacketInterceptor(StanzaListener, StanzaFilter)
* @see #addStanzaInterceptor(StanzaListener, StanzaFilter)
* @since 4.1
*/
public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
@ -347,7 +347,7 @@ public interface XMPPConnection {
*
* @param packetListener the stanza(/packet) listener to notify of new received packets.
* @param packetFilter the stanza(/packet) filter to use.
* @see #addPacketInterceptor(StanzaListener, StanzaFilter)
* @see #addStanzaInterceptor(StanzaListener, StanzaFilter)
* @since 4.1
*/
public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
@ -371,16 +371,42 @@ public interface XMPPConnection {
*
* @param packetListener the stanza(/packet) listener to notify of sent packets.
* @param packetFilter the stanza(/packet) filter to use.
* @deprecated use {@link #addStanzaSendingListener} instead
*/
// TODO Remove in Smack 4.4
@Deprecated
public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter);
/**
* Registers a stanza(/packet) listener with this connection. The listener will be
* notified of every stanza(/packet) that this connection sends. A stanza(/packet) filter determines
* which packets will be delivered to the listener. Note that the thread
* that writes packets will be used to invoke the listeners. Therefore, each
* stanza(/packet) listener should complete all operations quickly or use a different
* thread for processing.
*
* @param packetListener the stanza(/packet) listener to notify of sent packets.
* @param packetFilter the stanza(/packet) filter to use.
*/
public void addStanzaSendingListener(StanzaListener packetListener, StanzaFilter packetFilter);
/**
* Removes a stanza(/packet) listener for sending packets from this connection.
*
* @param packetListener the stanza(/packet) listener to remove.
* @deprecated use {@link #removeStanzaSendingListener} instead
*/
// TODO Remove in Smack 4.4
@Deprecated
public void removePacketSendingListener(StanzaListener packetListener);
/**
* Removes a stanza(/packet) listener for sending packets from this connection.
*
* @param packetListener the stanza(/packet) listener to remove.
*/
public void removeStanzaSendingListener(StanzaListener packetListener);
/**
* Registers a stanza(/packet) interceptor with this connection. The interceptor will be
* invoked every time a stanza(/packet) is about to be sent by this connection. Interceptors
@ -389,18 +415,47 @@ public interface XMPPConnection {
*
* <p>
* NOTE: For a similar functionality on incoming packets, see {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}.
* </p>
*
* @param packetInterceptor the stanza(/packet) interceptor to notify of packets about to be sent.
* @param packetFilter the stanza(/packet) filter to use.
* @deprecated use {@link #addStanzaInterceptor} instead
*/
// TODO Remove in Smack 4.4
@Deprecated
public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter);
/**
* Registers a stanza(/packet) interceptor with this connection. The interceptor will be
* invoked every time a stanza(/packet) is about to be sent by this connection. Interceptors
* may modify the stanza(/packet) to be sent. A stanza(/packet) filter determines which packets
* will be delivered to the interceptor.
*
* <p>
* NOTE: For a similar functionality on incoming packets, see {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}.
* </p>
*
* @param packetInterceptor the stanza(/packet) interceptor to notify of packets about to be sent.
* @param packetFilter the stanza(/packet) filter to use.
*/
public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter);
public void addStanzaInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter);
/**
* Removes a stanza(/packet) interceptor.
*
* @param packetInterceptor the stanza(/packet) interceptor to remove.
* @deprecated user {@link #removeStanzaInterceptor} instead
*/
// TODO Remove in Smack 4.4
@Deprecated
public void removePacketInterceptor(StanzaListener packetInterceptor);
/**
* Removes a stanza(/packet) interceptor.
*
* @param packetInterceptor the stanza(/packet) interceptor to remove.
*/
public void removePacketInterceptor(StanzaListener packetInterceptor);
public void removeStanzaInterceptor(StanzaListener packetInterceptor);
/**
* Returns the current value of the reply timeout in milliseconds for request for this

View file

@ -1013,7 +1013,7 @@ public class EnhancedDebugger implements SmackDebugger {
void cancel() {
connection.removeConnectionListener(connListener);
connection.removeAsyncStanzaListener(packetReaderListener);
connection.removePacketSendingListener(packetWriterListener);
connection.removeStanzaSendingListener(packetWriterListener);
((ObservableReader) reader).removeReaderListener(readerListener);
((ObservableWriter) writer).removeWriterListener(writerListener);
messagesTable = null;

View file

@ -95,7 +95,7 @@ public final class StableUniqueStanzaIdManager extends Manager {
public synchronized void enable() {
ServiceDiscoveryManager.getInstanceFor(connection()).addFeature(NAMESPACE);
StanzaFilter filter = new AndFilter(OUTGOING_FILTER, new NotFilter(OUTGOING_FILTER));
connection().addPacketInterceptor(stanzaListener, filter);
connection().addStanzaInterceptor(stanzaListener, filter);
}
/**
@ -103,7 +103,7 @@ public final class StableUniqueStanzaIdManager extends Manager {
*/
public synchronized void disable() {
ServiceDiscoveryManager.getInstanceFor(connection()).removeFeature(NAMESPACE);
connection().removePacketInterceptor(stanzaListener);
connection().removeStanzaInterceptor(stanzaListener);
}
/**

View file

@ -116,7 +116,7 @@ public final class ChatManager extends Manager {
}
}, INCOMING_MESSAGE_FILTER);
connection.addPacketInterceptor(new StanzaListener() {
connection.addStanzaInterceptor(new StanzaListener() {
@Override
public void processStanza(Stanza stanza) throws NotConnectedException, InterruptedException {
Message message = (Message) stanza;

View file

@ -339,7 +339,7 @@ public final class EntityCapsManager extends Manager {
}
});
connection.addPacketSendingListener(new StanzaListener() {
connection.addStanzaSendingListener(new StanzaListener() {
@Override
public void processStanza(Stanza packet) {
presenceSend = (Presence) packet;
@ -362,7 +362,7 @@ public final class EntityCapsManager extends Manager {
packet.overrideExtension(caps);
}
};
connection.addPacketInterceptor(packetInterceptor, PresenceTypeFilter.AVAILABLE);
connection.addStanzaInterceptor(packetInterceptor, PresenceTypeFilter.AVAILABLE);
// It's important to do this as last action. Since it changes the
// behavior of the SDM in some ways
sdm.setEntityCapsManager(this);

View file

@ -134,7 +134,7 @@ public final class LastActivityManager extends Manager {
super(connection);
// Listen to all the sent messages to reset the idle time on each one
connection.addPacketSendingListener(new StanzaListener() {
connection.addStanzaSendingListener(new StanzaListener() {
@Override
public void processStanza(Stanza packet) {
Presence presence = (Presence) packet;
@ -153,7 +153,7 @@ public final class LastActivityManager extends Manager {
}
}, StanzaTypeFilter.PRESENCE);
connection.addPacketSendingListener(new StanzaListener() {
connection.addStanzaSendingListener(new StanzaListener() {
@Override
public void processStanza(Stanza packet) {
Message message = (Message) packet;

View file

@ -334,7 +334,7 @@ public class MultiUserChat {
);
// @formatter:on
connection.addSyncStanzaListener(declinesListener, new AndFilter(fromRoomFilter, DECLINE_FILTER));
connection.addPacketInterceptor(presenceInterceptor, new AndFilter(ToMatchesFilter.create(room),
connection.addStanzaInterceptor(presenceInterceptor, new AndFilter(ToMatchesFilter.create(room),
StanzaTypeFilter.PRESENCE));
messageCollector = connection.createStanzaCollector(fromRoomGroupchatFilter);
@ -2021,7 +2021,7 @@ public class MultiUserChat {
connection.removeSyncStanzaListener(presenceListener);
connection.removeSyncStanzaListener(subjectListener);
connection.removeSyncStanzaListener(declinesListener);
connection.removePacketInterceptor(presenceInterceptor);
connection.removeStanzaInterceptor(presenceInterceptor);
if (messageCollector != null) {
messageCollector.cancel();
messageCollector = null;

View file

@ -126,7 +126,7 @@ public final class PrivacyListManager extends Manager {
});
// cached(Active|Default)ListName handling
connection.addPacketSendingListener(new StanzaListener() {
connection.addStanzaSendingListener(new StanzaListener() {
@Override
public void processStanza(Stanza packet) throws NotConnectedException {
XMPPConnection connection = connection();
@ -148,7 +148,7 @@ public final class PrivacyListManager extends Manager {
}, iqResultReplyFilter);
}
}, SetActiveListFilter.INSTANCE);
connection.addPacketSendingListener(new StanzaListener() {
connection.addStanzaSendingListener(new StanzaListener() {
@Override
public void processStanza(Stanza packet) throws NotConnectedException {
XMPPConnection connection = connection();

View file

@ -279,7 +279,7 @@ public final class DeliveryReceiptManager extends Manager {
* @see #dontAutoAddDeliveryReceiptRequests()
*/
public void autoAddDeliveryReceiptRequests() {
connection().addPacketInterceptor(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER,
connection().addStanzaInterceptor(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER,
MESSAGES_TO_REQUEST_RECEIPTS_FOR);
}
@ -290,7 +290,7 @@ public final class DeliveryReceiptManager extends Manager {
* @see #autoAddDeliveryReceiptRequests()
*/
public void dontAutoAddDeliveryReceiptRequests() {
connection().removePacketInterceptor(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER);
connection().removeStanzaInterceptor(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER);
}
/**

View file

@ -335,7 +335,7 @@ public final class Roster extends Manager {
});
connection.addPacketSendingListener(new StanzaListener() {
connection.addStanzaSendingListener(new StanzaListener() {
@Override
public void processStanza(Stanza stanzav) throws NotConnectedException, InterruptedException {
// Once we send an unavailable presence, the server is allowed to suppress sending presence status

View file

@ -134,7 +134,7 @@ public class EntityCapsTest extends AbstractSmackIntegrationTest {
@SmackIntegrationTest
public void testPreventDiscoInfo() throws Exception {
final String dummyFeature = getNewDummyFeature();
conOne.addPacketSendingListener(new StanzaListener() {
conOne.addStanzaSendingListener(new StanzaListener() {
@Override
public void processStanza(Stanza stanza) {

View file

@ -643,7 +643,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
if (config.isDebuggerEnabled()) {
addAsyncStanzaListener(debugger.getReaderListener(), null);
if (debugger.getWriterListener() != null) {
addPacketSendingListener(debugger.getWriterListener(), null);
addStanzaSendingListener(debugger.getWriterListener(), null);
}
}
}