1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 20:47:57 +01:00

Remove API parts scheduled to be removed in Smack 4.3

This commit is contained in:
Florian Schmaus 2017-08-16 14:31:46 +02:00
parent 80eaaf2d71
commit ba323b51f9
11 changed files with 39 additions and 158 deletions

View file

@ -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();

View file

@ -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;

View file

@ -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

View file

@ -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.
*

View file

@ -607,23 +607,6 @@ public final class MamManager extends Manager {
return serviceDiscoveryManager.supportsFeature(myBareJid, MamElements.NAMESPACE);
}
/**
* Returns true if Message Archive Management is supported by the server.
*
* @return true if Message Archive Management is supported by the server.
* @throws NotConnectedException
* @throws XMPPErrorException
* @throws NoResponseException
* @throws InterruptedException
* @depreacted use {@link #isSupported()} instead.
*/
@Deprecated
// TODO Remove in Smack 4.3
public boolean isSupportedByServer()
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(MamElements.NAMESPACE);
}
private static DataForm getNewMamForm() {
FormField field = new FormField(FormField.FORM_TYPE);
field.setType(FormField.Type.hidden);

View file

@ -75,7 +75,7 @@ public interface BytestreamManager {
*
* @param initiatorJID the JID of the user the listener should be removed
*/
public void removeIncomingBytestreamListener(String initiatorJID);
public void removeIncomingBytestreamListener(Jid initiatorJID);
/**
* Establishes a bytestream with the given user and returns the session to send/receive data

View file

@ -282,9 +282,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* @param initiatorJID the JID of the user the listener should be removed
*/
@Override
// TODO: Change argument to Jid in Smack 4.3.
@SuppressWarnings("CollectionIncompatibleType")
public void removeIncomingBytestreamListener(String initiatorJID) {
public void removeIncomingBytestreamListener(Jid initiatorJID) {
this.userListeners.remove(initiatorJID);
}

View file

@ -245,10 +245,8 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
*
* @param initiatorJID the JID of the user the listener should be removed
*/
// TODO: Change parameter to Jid in Smack 4.3.
@Override
@SuppressWarnings("CollectionIncompatibleType")
public void removeIncomingBytestreamListener(String initiatorJID) {
public void removeIncomingBytestreamListener(Jid initiatorJID) {
this.userListeners.remove(initiatorJID);
}

View file

@ -408,9 +408,7 @@ public final class EntityCapsManager extends Manager {
* @param user
* the user (Full JID)
*/
// TODO: Change parameter type to Jid in Smack 4.3.
@SuppressWarnings("CollectionIncompatibleType")
public static void removeUserCapsNode(String user) {
public static void removeUserCapsNode(Jid user) {
// While JID_TO_NODEVER_CHACHE has the generic types <Jid, NodeVerHash>, it is ok to call remove with String
// arguments, since the same Jid and String representations would be equal and have the same hash code.
JID_TO_NODEVER_CACHE.remove(user);

View file

@ -205,15 +205,8 @@ public final class AdHocCommandManager extends Manager {
public void registerCommand(String node, String name, final Class<? extends LocalCommand> clazz) {
registerCommand(node, name, new LocalCommandFactory() {
@Override
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException {
try {
return clazz.getConstructor().newInstance();
}
catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException
| SecurityException e) {
// TODO: Throw those method in Smack 4.3.
throw new IllegalStateException(e);
}
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
return clazz.getConstructor().newInstance();
}
});
}
@ -361,7 +354,15 @@ public final class AdHocCommandManager extends Manager {
try {
// Create a new instance of the command with the
// corresponding sessioid
LocalCommand command = newInstanceOfCmd(commandNode, sessionId);
LocalCommand command;
try {
command = newInstanceOfCmd(commandNode, sessionId);
}
catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
XMPPError.Builder xmppError = XMPPError.getBuilder().setCondition(XMPPError.Condition.internal_server_error).setDescriptiveEnText(e.getMessage());
return respondError(response, xmppError);
}
response.setType(IQ.Type.result);
command.setData(response);
@ -627,26 +628,22 @@ public final class AdHocCommandManager extends Manager {
* @param sessionID the session id of this execution.
* @return the command instance to execute.
* @throws XMPPErrorException if there is problem creating the new instance.
* @throws SecurityException
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws InstantiationException
*/
@SuppressWarnings("deprecation")
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID) throws XMPPErrorException
{
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID)
throws XMPPErrorException, InstantiationException, IllegalAccessException, IllegalArgumentException,
InvocationTargetException, NoSuchMethodException, SecurityException {
AdHocCommandInfo commandInfo = commands.get(commandNode);
LocalCommand command;
try {
command = commandInfo.getCommandInstance();
command.setSessionID(sessionID);
command.setName(commandInfo.getName());
command.setNode(commandInfo.getNode());
}
catch (InstantiationException e) {
throw new XMPPErrorException(XMPPError.getBuilder(
XMPPError.Condition.internal_server_error));
}
catch (IllegalAccessException e) {
throw new XMPPErrorException(XMPPError.getBuilder(
XMPPError.Condition.internal_server_error));
}
LocalCommand command = commandInfo.getCommandInstance();
command.setSessionID(sessionID);
command.setName(commandInfo.getName());
command.setNode(commandInfo.getNode());
return command;
}
@ -680,7 +677,7 @@ public final class AdHocCommandManager extends Manager {
}
public LocalCommand getCommandInstance() throws InstantiationException,
IllegalAccessException
IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException
{
return factory.getInstance();
}

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.commands;
import java.lang.reflect.InvocationTargetException;
/**
* A factory for creating local commands. It's useful in cases where instantiation
* of a command is more complicated than just using the default constructor. For example,
@ -34,7 +36,11 @@ public interface LocalCommandFactory {
* @return a LocalCommand instance.
* @throws InstantiationException if creating an instance failed.
* @throws IllegalAccessException if creating an instance is not allowed.
* @throws SecurityException
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalArgumentException
*/
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException;
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException;
}