1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 15:52:06 +01:00

Remove deprecated methods in XMPPConnection

This commit is contained in:
Florian Schmaus 2018-06-14 10:00:37 +02:00
parent 9f786fc70d
commit 9e18ba2327
2 changed files with 0 additions and 299 deletions

View file

@ -80,7 +80,6 @@ import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.sasl.core.SASLAnonymous; import org.jivesoftware.smack.sasl.core.SASLAnonymous;
import org.jivesoftware.smack.util.Async;
import org.jivesoftware.smack.util.DNSUtil; import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
@ -859,12 +858,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
} }
@Deprecated
@Override
public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter) {
addStanzaSendingListener(packetListener, packetFilter);
}
@Override @Override
public void addStanzaSendingListener(StanzaListener packetListener, StanzaFilter packetFilter) { public void addStanzaSendingListener(StanzaListener packetListener, StanzaFilter packetFilter) {
if (packetListener == null) { if (packetListener == null) {
@ -876,12 +869,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
} }
@Deprecated
@Override
public void removePacketSendingListener(StanzaListener packetListener) {
removeStanzaSendingListener(packetListener);
}
@Override @Override
public void removeStanzaSendingListener(StanzaListener packetListener) { public void removeStanzaSendingListener(StanzaListener packetListener) {
synchronized (sendListeners) { synchronized (sendListeners) {
@ -932,13 +919,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}); });
} }
@Deprecated
@Override
public void addPacketInterceptor(StanzaListener packetInterceptor,
StanzaFilter packetFilter) {
addStanzaInterceptor(packetInterceptor, packetFilter);
}
@Override @Override
public void addStanzaInterceptor(StanzaListener packetInterceptor, public void addStanzaInterceptor(StanzaListener packetInterceptor,
StanzaFilter packetFilter) { StanzaFilter packetFilter) {
@ -951,12 +931,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
} }
@Deprecated
@Override
public void removePacketInterceptor(StanzaListener packetInterceptor) {
removeStanzaInterceptor(packetInterceptor);
}
@Override @Override
public void removeStanzaInterceptor(StanzaListener packetInterceptor) { public void removeStanzaInterceptor(StanzaListener packetInterceptor) {
synchronized (interceptors) { synchronized (interceptors) {
@ -1453,22 +1427,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
streamFeatures.put(key, feature); streamFeatures.put(key, feature);
} }
@SuppressWarnings("deprecation")
@Override
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
StanzaListener callback) throws NotConnectedException, InterruptedException {
sendStanzaWithResponseCallback(stanza, replyFilter, callback, null);
}
@SuppressWarnings("deprecation")
@Override
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
StanzaListener callback, ExceptionCallback exceptionCallback)
throws NotConnectedException, InterruptedException {
sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback,
getReplyTimeout());
}
@Override @Override
public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request) { public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request) {
return sendIqRequestAsync(request, getReplyTimeout()); return sendIqRequestAsync(request, getReplyTimeout());
@ -1550,88 +1508,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
return future; return future;
} }
@SuppressWarnings({ "FutureReturnValueIgnored", "deprecation" })
@Override
public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter,
final StanzaListener callback, final ExceptionCallback exceptionCallback,
long timeout) throws NotConnectedException, InterruptedException {
Objects.requireNonNull(stanza, "stanza must not be null");
// While Smack allows to add PacketListeners with a PacketFilter value of 'null', we
// disallow it here in the async API as it makes no sense
Objects.requireNonNull(replyFilter, "replyFilter must not be null");
Objects.requireNonNull(callback, "callback must not be null");
final StanzaListener packetListener = new StanzaListener() {
@Override
public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException, NotLoggedInException {
boolean removed = removeAsyncStanzaListener(this);
if (!removed) {
// We lost a race against the "no response" handling runnable. Avoid calling the callback, as the
// exception callback will be invoked (if any).
return;
}
try {
XMPPErrorException.ifHasErrorThenThrow(packet);
callback.processStanza(packet);
}
catch (XMPPErrorException e) {
if (exceptionCallback != null) {
exceptionCallback.processException(e);
}
}
}
};
schedule(new Runnable() {
@Override
public void run() {
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) {
Exception exception;
if (!isConnected()) {
// If the connection is no longer connected, throw a not connected exception.
exception = new NotConnectedException(AbstractXMPPConnection.this, replyFilter);
} else {
exception = NoResponseException.newWith(AbstractXMPPConnection.this, replyFilter);
}
final Exception exceptionToProcess = exception;
Async.go(new Runnable() {
@Override
public void run() {
exceptionCallback.processException(exceptionToProcess);
}
});
}
}
}, timeout, TimeUnit.MILLISECONDS);
addAsyncStanzaListener(packetListener, replyFilter);
sendStanza(stanza);
}
@SuppressWarnings("deprecation")
@Override
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback)
throws NotConnectedException, InterruptedException {
sendIqWithResponseCallback(iqRequest, callback, null);
}
@SuppressWarnings("deprecation")
@Override
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException {
sendIqWithResponseCallback(iqRequest, callback, exceptionCallback, getReplyTimeout());
}
@SuppressWarnings("deprecation")
@Override
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
final ExceptionCallback exceptionCallback, long timeout)
throws NotConnectedException, InterruptedException {
StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this);
sendStanzaWithResponseCallback(iqRequest, replyFilter, callback, exceptionCallback, timeout);
}
@SuppressWarnings("FutureReturnValueIgnored") @SuppressWarnings("FutureReturnValueIgnored")
@Override @Override
public void addOneTimeSyncCallback(final StanzaListener callback, final StanzaFilter packetFilter) { public void addOneTimeSyncCallback(final StanzaListener callback, final StanzaFilter packetFilter) {

View file

@ -366,22 +366,6 @@ public interface XMPPConnection {
*/ */
boolean removeAsyncStanzaListener(StanzaListener stanzaListener); boolean removeAsyncStanzaListener(StanzaListener stanzaListener);
/**
* Registers a stanza listener with this connection. The listener will be
* notified of every stanza that this connection sends. A stanza filter determines
* which stanzas will be delivered to the listener. Note that the thread
* that writes stanzas will be used to invoke the listeners. Therefore, each
* stanza listener should complete all operations quickly or use a different
* thread for processing.
*
* @param stanzaListener the stanza listener to notify of sent stanzas.
* @param stanzaFilter the stanza filter to use.
* @deprecated use {@link #addStanzaSendingListener} instead
*/
// TODO Remove in Smack 4.4
@Deprecated
void addPacketSendingListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
/** /**
* Registers a stanza listener with this connection. The listener will be * Registers a stanza listener with this connection. The listener will be
* notified of every stanza that this connection sends. A stanza filter determines * notified of every stanza that this connection sends. A stanza filter determines
@ -395,16 +379,6 @@ public interface XMPPConnection {
*/ */
void addStanzaSendingListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter); void addStanzaSendingListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
/**
* Removes a stanza listener for sending stanzas from this connection.
*
* @param stanzaListener the stanza listener to remove.
* @deprecated use {@link #removeStanzaSendingListener} instead
*/
// TODO Remove in Smack 4.4
@Deprecated
void removePacketSendingListener(StanzaListener stanzaListener);
/** /**
* Removes a stanza listener for sending stanzas from this connection. * Removes a stanza listener for sending stanzas from this connection.
* *
@ -412,24 +386,6 @@ public interface XMPPConnection {
*/ */
void removeStanzaSendingListener(StanzaListener stanzaListener); void removeStanzaSendingListener(StanzaListener stanzaListener);
/**
* Registers a stanza interceptor with this connection. The interceptor will be
* invoked every time a stanza is about to be sent by this connection. Interceptors
* may modify the stanza to be sent. A stanza filter determines which stanzas
* will be delivered to the interceptor.
*
* <p>
* NOTE: For a similar functionality on incoming stanzas, see {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}.
* </p>
*
* @param stanzaInterceptor the stanza interceptor to notify of stanzas about to be sent.
* @param stanzaFilter the stanza filter to use.
* @deprecated use {@link #addStanzaInterceptor} instead
*/
// TODO Remove in Smack 4.4
@Deprecated
void addPacketInterceptor(StanzaListener stanzaInterceptor, StanzaFilter stanzaFilter);
/** /**
* Registers a stanza interceptor with this connection. The interceptor will be * Registers a stanza interceptor with this connection. The interceptor will be
* invoked every time a stanza is about to be sent by this connection. Interceptors * invoked every time a stanza is about to be sent by this connection. Interceptors
@ -445,16 +401,6 @@ public interface XMPPConnection {
*/ */
void addStanzaInterceptor(StanzaListener stanzaInterceptor, StanzaFilter stanzaFilter); void addStanzaInterceptor(StanzaListener stanzaInterceptor, StanzaFilter stanzaFilter);
/**
* Removes a stanza interceptor.
*
* @param stanzaInterceptor the stanza interceptor to remove.
* @deprecated user {@link #removeStanzaInterceptor} instead
*/
// TODO Remove in Smack 4.4
@Deprecated
void removePacketInterceptor(StanzaListener stanzaInterceptor);
/** /**
* Removes a stanza interceptor. * Removes a stanza interceptor.
* *
@ -576,127 +522,6 @@ public interface XMPPConnection {
*/ */
<S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter, long timeout); <S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter, long timeout);
/**
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
* <p>
* If there is a response, then <code>callback</code> will be invoked. The callback will be
* invoked at most once and it will be not invoked after the connections default reply timeout
* has been elapsed.
* </p>
*
* @param stanza the stanza to send (required)
* @param replyFilter the filter used to determine response stanza (required)
* @param callback the callback invoked if there is a response (required)
* @throws NotConnectedException
* @throws InterruptedException
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter)} instead.
*/
@Deprecated
// TODO: Remove in Smack 4.4.
void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
StanzaListener callback) throws NotConnectedException, InterruptedException;
/**
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
* <p>
* If there is a response, then <code>callback</code> will be invoked. If there is no response
* after the connections default reply timeout, then <code>exceptionCallback</code> will be invoked
* with a {@link SmackException.NoResponseException}. The callback will be invoked at most once.
* </p>
*
* @param stanza the stanza to send (required)
* @param replyFilter the filter used to determine response stanza (required)
* @param callback the callback invoked if there is a response (required)
* @param exceptionCallback the callback invoked if there is an exception (optional)
* @throws NotConnectedException
* @throws InterruptedException
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter)} instead.
*/
@Deprecated
// TODO: Remove in Smack 4.4.
void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
/**
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
* <p>
* If there is a response, then <code>callback</code> will be invoked. If there is no response
* after <code>timeout</code> milliseconds, then <code>exceptionCallback</code> will be invoked
* with a {@link SmackException.NoResponseException}. The callback will be invoked at most once.
* </p>
*
* @param stanza the stanza to send (required)
* @param replyFilter the filter used to determine response stanza (required)
* @param callback the callback invoked if there is a response (required)
* @param exceptionCallback the callback invoked if there is an exception (optional)
* @param timeout the timeout in milliseconds to wait for a response
* @throws NotConnectedException
* @throws InterruptedException
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter, long)} instead.
*/
@Deprecated
// TODO: Remove in Smack 4.4.
void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
StanzaListener callback, @SuppressWarnings("deprecation") ExceptionCallback exceptionCallback,
long timeout) throws NotConnectedException, InterruptedException;
/**
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
* {@link org.jivesoftware.smack.packet.IQ.Type#result} with that result IQ. The callback will
* not be invoked after the connections default reply timeout has been elapsed.
*
* @param iqRequest the IQ stanza to send (required)
* @param callback the callback invoked if there is result response (required)
* @throws NotConnectedException
* @throws InterruptedException
* @deprecated use {@link #sendIqRequestAsync(IQ)} instead.
*/
@Deprecated
// TODO: Remove in Smack 4.4.
void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException, InterruptedException;
/**
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
* {@link org.jivesoftware.smack.packet.IQ.Type#result} with that result IQ. If there is an
* error response <code>exceptionCallback</code> will be invoked, if not null, with the received
* error as {@link XMPPException.XMPPErrorException}. If there is no response after the
* connections default reply timeout, then <code>exceptionCallback</code> will be invoked with a
* {@link SmackException.NoResponseException}.
*
* @param iqRequest the IQ stanza to send (required)
* @param callback the callback invoked if there is result response (required)
* @param exceptionCallback the callback invoked if there is an Exception optional
* @throws NotConnectedException
* @throws InterruptedException
* @deprecated use {@link #sendIqRequestAsync(IQ)} instead.
*/
@Deprecated
// TODO: Remove in Smack 4.4.
void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
/**
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
* {@link org.jivesoftware.smack.packet.IQ.Type#result} with that result IQ. If there is an
* error response <code>exceptionCallback</code> will be invoked, if not null, with the received
* error as {@link XMPPException.XMPPErrorException}. If there is no response after
* <code>timeout</code>, then <code>exceptionCallback</code> will be invoked with a
* {@link SmackException.NoResponseException}.
*
* @param iqRequest the IQ stanza to send (required)
* @param callback the callback invoked if there is result response (required)
* @param exceptionCallback the callback invoked if there is an Exception optional
* @param timeout the timeout in milliseconds to wait for a response
* @throws NotConnectedException
* @throws InterruptedException
* @deprecated use {@link #sendIqRequestAsync(IQ, long)} instead.
*/
@Deprecated
// TODO: Remove in Smack 4.4.
void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback, long timeout)
throws NotConnectedException, InterruptedException;
/** /**
* Add a callback that is called exactly once and synchronously with the incoming stanza that matches the given * Add a callback that is called exactly once and synchronously with the incoming stanza that matches the given
* stanza filter. * stanza filter.