1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

Merge upstream

This commit is contained in:
vanitasvitae 2017-08-16 15:46:32 +02:00
commit aeab6504a7
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
35 changed files with 262 additions and 357 deletions

View file

@ -42,6 +42,7 @@ public final class Chat extends Manager {
public void send(CharSequence message) throws NotConnectedException, InterruptedException {
Message stanza = new Message();
stanza.setBody(message);
stanza.setType(Message.Type.chat);
send(stanza);
}

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

View file

@ -236,11 +236,10 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
private void establishBytestreamSession(XMPPConnection connection)
throws SmackException.NotConnectedException, InterruptedException {
Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr);
JingleS5BTransportManager transportManager = JingleS5BTransportManager.getInstanceFor(connection);
this.ourSelectedCandidate = connectToCandidates(MAX_TIMEOUT);
if (ourSelectedCandidate == CANDIDATE_FAILURE) {
connection.createStanzaCollectorAndSend(transportManager.createCandidateError(this));
connection.createStanzaCollectorAndSend(JingleS5BTransportManager.createCandidateError(this));
return;
}
@ -248,7 +247,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
throw new AssertionError("MUST NOT BE NULL.");
}
connection.createStanzaCollectorAndSend(transportManager.createCandidateUsed(this, ourSelectedCandidate));
connection.createStanzaCollectorAndSend(JingleS5BTransportManager.createCandidateUsed(this, ourSelectedCandidate));
connectIfReady();
}
@ -281,7 +280,6 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
@SuppressWarnings("ReferenceEquality")
private void connectIfReady() {
final JingleS5BTransportManager jingleS5BTransportManager = JingleS5BTransportManager.getInstanceFor(getParent().getParent().getJingleManager().getConnection());
final JingleSession session = getParent().getParent();
if (ourSelectedCandidate == null || theirSelectedCandidate == null) {
@ -331,7 +329,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
@Override
public void run() {
try {
session.getJingleManager().getConnection().createStanzaCollectorAndSend(jingleS5BTransportManager.createProxyError(JingleS5BTransport.this));
session.getJingleManager().getConnection().createStanzaCollectorAndSend(JingleS5BTransportManager.createProxyError(JingleS5BTransport.this));
} catch (SmackException.NotConnectedException | InterruptedException e1) {
LOGGER.log(Level.SEVERE, "Could not send proxy error: " + e, e);
}
@ -344,7 +342,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
if (isProxy) {
LOGGER.log(Level.INFO, "Send candidate-activate.");
JingleElement candidateActivate = jingleS5BTransportManager.createCandidateActivated((JingleS5BTransport) nominated.getParent(), nominated);
JingleElement candidateActivate = JingleS5BTransportManager.createCandidateActivated((JingleS5BTransport) nominated.getParent(), nominated);
try {
session.getJingleManager().getConnection().createStanzaCollectorAndSend(candidateActivate)

View file

@ -465,7 +465,7 @@ public class MultiUserChat {
* @deprecated use {@link #createOrJoin(MucEnterConfiguration)} instead.
*/
@Deprecated
public MucCreateConfigFormHandle createOrJoin(Resourcepart nickname, String password, DiscussionHistory history, long timeout)
public MucCreateConfigFormHandle createOrJoin(Resourcepart nickname, String password, @SuppressWarnings("deprecation") DiscussionHistory history, long timeout)
throws NoResponseException, XMPPErrorException, InterruptedException, MucAlreadyJoinedException, NotConnectedException, NotAMucServiceException {
MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword(
password).timeoutAfter(timeout);
@ -666,7 +666,7 @@ public class MultiUserChat {
public void join(
Resourcepart nickname,
String password,
DiscussionHistory history,
@SuppressWarnings("deprecation") DiscussionHistory history,
long timeout)
throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException, NotAMucServiceException {
MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword(

View file

@ -33,7 +33,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* to true, otherwise it will be null.
* </ul>
*
* <h3>An Item created to send to a node (via {@link LeafNode#send()} or {@link LeafNode#publish()}</h3>
* <h3>An Item created to send to a node (via {@link LeafNode#publish()} or {@link LeafNode#publish()}</h3>
* <ul>
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is
* meaningful in the context of the node. This value must be unique within the node that it is sent to, since
@ -57,8 +57,8 @@ public class Item extends NodeExtension
* Create an empty <tt>Item</tt> with no id. This is a valid item for nodes which are configured
* so that {@link ConfigureForm#isDeliverPayloads()} is false. In most cases an id will be generated by the server.
* For nodes configured with {@link ConfigureForm#isDeliverPayloads()} and {@link ConfigureForm#isPersistItems()}
* set to false, no <tt>Item</tt> is sent to the node, you have to use {@link LeafNode#send()} or {@link LeafNode#publish()}
* methods in this case.
* set to false, no <tt>Item</tt> is sent to the node, you have to use the {@link LeafNode#publish()}
* method in this case.
*/
public Item()
{

View file

@ -34,7 +34,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* to true, otherwise it will be null.</li>
* </ul>
*
* <h3>An Item created to send to a node (via {@link LeafNode#send()} or {@link LeafNode#publish()}</h3>
* <h3>An Item created to send to a node (via {@link LeafNode#publish()}</h3>
* <ul>
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is
* meaningful in the context of the node. This value must be unique within the node that it is sent to, since

View file

@ -272,8 +272,8 @@ public final class DeliveryReceiptManager extends Manager {
/**
* Enables automatic requests of delivery receipts for outgoing messages of
* {@link Message.Type#normal}, {@link Message.Type#chat} or {@link Message.Type#headline}, and
* with a {@link Message.Body} extension.
* {@link org.jivesoftware.smack.packet.Message.Type#normal}, {@link org.jivesoftware.smack.packet.Message.Type#chat} or {@link org.jivesoftware.smack.packet.Message.Type#headline}, and
* with a {@link org.jivesoftware.smack.packet.Message.Body} extension.
*
* @since 4.1
* @see #dontAutoAddDeliveryReceiptRequests()