mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Merge upstream
This commit is contained in:
commit
aeab6504a7
35 changed files with 262 additions and 357 deletions
|
@ -963,52 +963,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
replyTimeout = timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default value used to determine if new connection will reply to unknown IQ requests. The pre-configured
|
||||
* default is 'true'.
|
||||
*
|
||||
* @param replyToUnkownIqDefault
|
||||
* @see #setReplyToUnknownIq(boolean)
|
||||
* @deprecated Use {@link SmackConfiguration#setUnknownIqRequestReplyMode(org.jivesoftware.smack.SmackConfiguration.UnknownIqRequestReplyMode)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// TODO Remove in Smack 4.3
|
||||
public static void setReplyToUnknownIqDefault(boolean replyToUnkownIqDefault) {
|
||||
SmackConfiguration.UnknownIqRequestReplyMode mode;
|
||||
if (replyToUnkownIqDefault) {
|
||||
mode = SmackConfiguration.UnknownIqRequestReplyMode.replyServiceUnavailable;
|
||||
} else {
|
||||
mode = SmackConfiguration.UnknownIqRequestReplyMode.doNotReply;
|
||||
}
|
||||
SmackConfiguration.setUnknownIqRequestReplyMode(mode);
|
||||
}
|
||||
|
||||
private SmackConfiguration.UnknownIqRequestReplyMode unknownIqRequestReplyMode = SmackConfiguration.getUnknownIqRequestReplyMode();
|
||||
|
||||
public void setUnknownIqRequestReplyMode(UnknownIqRequestReplyMode unknownIqRequestReplyMode) {
|
||||
this.unknownIqRequestReplyMode = Objects.requireNonNull(unknownIqRequestReplyMode, "Mode must not be null");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if Smack will automatically send
|
||||
* {@link org.jivesoftware.smack.packet.XMPPError.Condition#feature_not_implemented} when a request IQ without a
|
||||
* registered {@link IQRequestHandler} is received.
|
||||
*
|
||||
* @param replyToUnknownIq
|
||||
* @deprecated use {@link #setUnknownIqRequestReplyMode(UnknownIqRequestReplyMode)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// TODO Remove in Smack 4.3
|
||||
public void setReplyToUnknownIq(boolean replyToUnknownIq) {
|
||||
SmackConfiguration.UnknownIqRequestReplyMode mode;
|
||||
if (replyToUnknownIq) {
|
||||
mode = SmackConfiguration.UnknownIqRequestReplyMode.replyServiceUnavailable;
|
||||
} else {
|
||||
mode = SmackConfiguration.UnknownIqRequestReplyMode.doNotReply;
|
||||
}
|
||||
unknownIqRequestReplyMode = mode;
|
||||
}
|
||||
|
||||
protected void parseAndProcessStanza(XmlPullParser parser) throws Exception {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
int parserDepth = parser.getDepth();
|
||||
|
@ -1476,12 +1436,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
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)
|
||||
|
@ -1571,7 +1533,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
return future;
|
||||
}
|
||||
|
||||
@SuppressWarnings("FutureReturnValueIgnored")
|
||||
@SuppressWarnings({ "FutureReturnValueIgnored", "deprecation" })
|
||||
@Override
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter,
|
||||
final StanzaListener callback, final ExceptionCallback exceptionCallback,
|
||||
|
@ -1624,18 +1586,21 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,12 @@
|
|||
*/
|
||||
package org.jivesoftware.smack;
|
||||
|
||||
/**
|
||||
* This interface has been deprecated. Please use org.jivesoftware.smack.util.ExceptionCallback instead.
|
||||
*
|
||||
* @deprecated use {@link org.jivesoftware.smack.util.ExceptionCallback} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ExceptionCallback {
|
||||
|
||||
public void processException(Exception exception);
|
||||
|
|
|
@ -345,8 +345,7 @@ public final class SmackConfiguration {
|
|||
replyServiceUnavailable,
|
||||
}
|
||||
|
||||
// TODO Change to replyFeatureNotImplemented in Smack 4.3
|
||||
private static UnknownIqRequestReplyMode unknownIqRequestReplyMode = UnknownIqRequestReplyMode.replyServiceUnavailable;
|
||||
private static UnknownIqRequestReplyMode unknownIqRequestReplyMode = UnknownIqRequestReplyMode.replyFeatureNotImplemented;
|
||||
|
||||
public static UnknownIqRequestReplyMode getUnknownIqRequestReplyMode() {
|
||||
return unknownIqRequestReplyMode;
|
||||
|
|
|
@ -106,14 +106,9 @@ public abstract class SmackFuture<V, E extends Exception> implements Future<V>,
|
|||
return getOrThrowExecutionException();
|
||||
}
|
||||
|
||||
public synchronized final V getOrThrow() throws E {
|
||||
public synchronized final V getOrThrow() throws E, InterruptedException {
|
||||
while (result == null && exception == null && !cancelled) {
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
wait();
|
||||
}
|
||||
|
||||
if (exception != null) {
|
||||
|
|
|
@ -428,7 +428,6 @@ public interface XMPPConnection {
|
|||
*/
|
||||
public boolean hasFeature(String element, String namespace);
|
||||
|
||||
|
||||
/**
|
||||
* Send an IQ request asynchronously. The connection's default reply timeout will be used.
|
||||
*
|
||||
|
@ -447,7 +446,8 @@ public interface XMPPConnection {
|
|||
public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout);
|
||||
|
||||
/**
|
||||
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter. The connection's default reply timeout will be used.
|
||||
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter. The
|
||||
* connection's default reply timeout will be used.
|
||||
*
|
||||
* @param stanza the stanza to send.
|
||||
* @param replyFilter the filter used for the response stanza.
|
||||
|
@ -477,9 +477,11 @@ public interface XMPPConnection {
|
|||
* @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
|
||||
* @throws InterruptedException
|
||||
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter)} instead.
|
||||
*/
|
||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.4.
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
StanzaListener callback) throws NotConnectedException, InterruptedException;
|
||||
|
||||
|
@ -497,10 +499,12 @@ public interface XMPPConnection {
|
|||
* @param exceptionCallback the callback invoked if there is an exception (optional)
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter)} instead.
|
||||
*/
|
||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API. And do not forget to mark smack.ExceptionCallback deprecated too.
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.4.
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
|
||||
ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
||||
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
|
||||
|
@ -517,10 +521,12 @@ public interface XMPPConnection {
|
|||
* @param timeout the timeout in milliseconds to wait for a response
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter, long)} instead.
|
||||
*/
|
||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.4.
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
final StanzaListener callback, final ExceptionCallback exceptionCallback,
|
||||
final StanzaListener callback, @SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback,
|
||||
long timeout) throws NotConnectedException, InterruptedException;
|
||||
|
||||
/**
|
||||
|
@ -532,8 +538,10 @@ public interface XMPPConnection {
|
|||
* @param callback the callback invoked if there is result response (required)
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @deprecated use {@link #sendIqRequestAsync(IQ)} instead.
|
||||
*/
|
||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.4.
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException, InterruptedException;
|
||||
|
||||
/**
|
||||
|
@ -549,10 +557,12 @@ public interface XMPPConnection {
|
|||
* @param exceptionCallback the callback invoked if there is an Exception optional
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @deprecated use {@link #sendIqRequestAsync(IQ)} instead.
|
||||
*/
|
||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.4.
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
|
||||
ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
||||
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
|
||||
|
@ -568,10 +578,12 @@ public interface XMPPConnection {
|
|||
* @param timeout the timeout in milliseconds to wait for a response
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @deprecated use {@link #sendIqRequestAsync(IQ, long)} instead.
|
||||
*/
|
||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.4.
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
|
||||
final ExceptionCallback exceptionCallback, long timeout)
|
||||
@SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback, long timeout)
|
||||
throws NotConnectedException, InterruptedException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software, 2015 Florian Schmaus
|
||||
* Copyright 2003-2007 Jive Software, 2015-2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -102,50 +101,6 @@ public class XMPPError extends AbstractError {
|
|||
private final Type type;
|
||||
private final Stanza stanza;
|
||||
|
||||
// TODO: Deprecated constructors
|
||||
// deprecate in 4.3
|
||||
|
||||
/**
|
||||
* Create a new XMPPError.
|
||||
*
|
||||
* @param condition
|
||||
* @deprecated use {@link Builder} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public XMPPError(Condition condition) {
|
||||
this(condition, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new XMPPError.
|
||||
*
|
||||
* @param condition
|
||||
* @param applicationSpecificCondition
|
||||
* @deprecated use {@link Builder} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public XMPPError(Condition condition, ExtensionElement applicationSpecificCondition) {
|
||||
this(condition, null, null, null, null, Arrays.asList(applicationSpecificCondition), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new error with the specified type, condition and message.
|
||||
* This constructor is used when the condition is not recognized automatically by XMPPError
|
||||
* i.e. there is not a defined instance of ErrorCondition or it does not apply the default
|
||||
* specification.
|
||||
*
|
||||
* @param type the error type.
|
||||
* @param condition the error condition.
|
||||
* @param descriptiveTexts
|
||||
* @param extensions list of stanza(/packet) extensions
|
||||
* @deprecated use {@link Builder} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public XMPPError(Condition condition, String conditionText, String errorGenerator, Type type, Map<String, String> descriptiveTexts,
|
||||
List<ExtensionElement> extensions) {
|
||||
this(condition, conditionText, errorGenerator, type, descriptiveTexts, extensions, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new error with the specified type, condition and message.
|
||||
* This constructor is used when the condition is not recognized automatically by XMPPError
|
||||
|
|
|
@ -303,7 +303,7 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
|
|||
protected abstract SASLMechanism newInstance();
|
||||
|
||||
protected static byte[] toBytes(String string) {
|
||||
return StringUtils.toBytes(string);
|
||||
return StringUtils.toUtf8Bytes(string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@ public class MD5 {
|
|||
}
|
||||
|
||||
public static byte[] bytes(String string) {
|
||||
return bytes(StringUtils.toBytes(string));
|
||||
return bytes(StringUtils.toUtf8Bytes(string));
|
||||
}
|
||||
|
||||
public static String hex(byte[] bytes) {
|
||||
|
@ -50,7 +50,7 @@ public class MD5 {
|
|||
}
|
||||
|
||||
public static String hex(String string) {
|
||||
return hex(StringUtils.toBytes(string));
|
||||
return hex(StringUtils.toUtf8Bytes(string));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class SHA1 {
|
|||
}
|
||||
|
||||
public static byte[] bytes(String string) {
|
||||
return bytes(StringUtils.toBytes(string));
|
||||
return bytes(StringUtils.toUtf8Bytes(string));
|
||||
}
|
||||
|
||||
public static String hex(byte[] bytes) {
|
||||
|
@ -51,7 +51,7 @@ public class SHA1 {
|
|||
}
|
||||
|
||||
public static String hex(String string) {
|
||||
return hex(StringUtils.toBytes(string));
|
||||
return hex(StringUtils.toUtf8Bytes(string));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,19 +41,6 @@ public class StringUtils {
|
|||
|
||||
public static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
|
||||
|
||||
/**
|
||||
* Escape <code>input</code> for XML.
|
||||
*
|
||||
* @param input the input to escape.
|
||||
* @return the XML escaped variant of <code>input</code>.
|
||||
* @deprecated use {@link #escapeForXml(CharSequence)} instead.
|
||||
*/
|
||||
// Remove in 4.3.
|
||||
@Deprecated
|
||||
public static CharSequence escapeForXML(CharSequence input) {
|
||||
return escapeForXml(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape <code>input</code> for XML.
|
||||
*
|
||||
|
@ -257,7 +244,7 @@ public class StringUtils {
|
|||
return new String(hexChars);
|
||||
}
|
||||
|
||||
public static byte[] toBytes(String string) {
|
||||
public static byte[] toUtf8Bytes(String string) {
|
||||
try {
|
||||
return string.getBytes(StringUtils.UTF8);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016 Florian Schmaus
|
||||
* Copyright © 2016-2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,7 +22,6 @@ import org.jivesoftware.smack.packet.Presence.Mode;
|
|||
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
public class ToStringTest {
|
||||
|
||||
|
@ -43,7 +42,7 @@ public class ToStringTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void iqTest() throws XmppStringprepException {
|
||||
public void iqTest() {
|
||||
Bind bindIq = Bind.newResult(JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE);
|
||||
bindIq.setStanzaId("bind-id");
|
||||
String string = bindIq.toString();
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
|||
public class DigestMd5SaslTest extends AbstractSaslTest {
|
||||
|
||||
protected static final String challenge = "realm=\"xmpp.org\",nonce=\"jgGgnz+cQcmyVaAs2n88kQ==\",qop=\"auth\",charset=utf-8,algorithm=md5-sess";
|
||||
protected static final byte[] challengeBytes = StringUtils.toBytes(challenge);
|
||||
protected static final byte[] challengeBytes = StringUtils.toUtf8Bytes(challenge);
|
||||
|
||||
public DigestMd5SaslTest(SASLMechanism saslMechanism) {
|
||||
super(saslMechanism);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue