1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 06:12:05 +01:00

Fix warnings

This commit is contained in:
Florian Schmaus 2017-08-16 14:10:00 +02:00
parent 6203d163c4
commit 80eaaf2d71
15 changed files with 73 additions and 95 deletions

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2016 Florian Schmaus * Copyright © 2016-2017 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.junit.Test;
import org.jxmpp.jid.JidTestUtil; import org.jxmpp.jid.JidTestUtil;
import org.jxmpp.stringprep.XmppStringprepException;
public class ToStringTest { public class ToStringTest {
@ -43,7 +42,7 @@ public class ToStringTest {
} }
@Test @Test
public void iqTest() throws XmppStringprepException { public void iqTest() {
Bind bindIq = Bind.newResult(JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE); Bind bindIq = Bind.newResult(JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE);
bindIq.setStanzaId("bind-id"); bindIq.setStanzaId("bind-id");
String string = bindIq.toString(); String string = bindIq.toString();

View file

@ -52,7 +52,10 @@ import org.jivesoftware.smackx.hashes.element.HashElement;
import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.jce.provider.BouncyCastleProvider;
/** /**
* Manager that can be used to determine support for hash functions. * Manager that can be used to determine support for hash functions. By default the Manager announces support for
* XEP-0300, as well as for the recommended set of hash algorithms. Those contain SHA256, SHA384, SHA512, SHA3-256,
* SHA3-384, SHA3-512, BLAKE2B256, BLAKE2B384 and BLAKE2B512. Those algorithms got recommended here:
* <a href="https://xmpp.org/extensions/xep-0300.html#recommendations">https://xmpp.org/extensions/xep-0300.html#recommendations</a>.
*/ */
public final class HashManager extends Manager { public final class HashManager extends Manager {
@ -88,9 +91,7 @@ public final class HashManager extends Manager {
/** /**
* Constructor of the HashManager. * Constructor of the HashManager.
* By default the Manager announces support for XEP-0300, as well as for the RECOMMENDED set of hash algorithms. *
* Those contain SHA256, SHA384, SHA512, SHA3-256, SHA3-384, SHA3-512, BLAKE2B256, BLAKE2B384 and BLAKE2B512.
* Those algorithms got recommended here: https://xmpp.org/extensions/xep-0300.html#recommendations
* @param connection connection * @param connection connection
*/ */
private HashManager(XMPPConnection connection) { private HashManager(XMPPConnection connection) {
@ -122,9 +123,9 @@ public final class HashManager extends Manager {
/** /**
* Get an instance of the HashManager for the given connection. * Get an instance of the HashManager for the given connection.
* @param connection * @param connection
* @return * @return the manager for the given connection.
*/ */
public HashManager getInstanceFor(XMPPConnection connection) { public static synchronized HashManager getInstanceFor(XMPPConnection connection) {
HashManager hashManager = INSTANCES.get(connection); HashManager hashManager = INSTANCES.get(connection);
if (hashManager == null) { if (hashManager == null) {
hashManager = new HashManager(connection); hashManager = new HashManager(connection);
@ -457,11 +458,11 @@ public final class HashManager extends Manager {
return blake2b384(utf8(data)); return blake2b384(utf8(data));
} }
public String blake2b384HexString(byte[] data) { public static String blake2b384HexString(byte[] data) {
return hex(blake2b384(data)); return hex(blake2b384(data));
} }
public String blake2b384HexString(String data) { public static String blake2b384HexString(String data) {
return hex(blake2b384(data)); return hex(blake2b384(data));
} }
@ -473,11 +474,11 @@ public final class HashManager extends Manager {
return blake2b512(utf8(data)); return blake2b512(utf8(data));
} }
public String blake2b512HexString(byte[] data) { public static String blake2b512HexString(byte[] data) {
return hex(blake2b512(data)); return hex(blake2b512(data));
} }
public String blake2b512HexString(String data) { public static String blake2b512HexString(String data) {
return hex(blake2b512(data)); return hex(blake2b512(data));
} }

View file

@ -62,7 +62,8 @@ public class HashElement implements ExtensionElement {
/** /**
* Return the hash algorithm used in this HashElement. * Return the hash algorithm used in this HashElement.
* @return algorithm *
* @return algorithm the algorithm.
*/ */
public HashManager.ALGORITHM getAlgorithm() { public HashManager.ALGORITHM getAlgorithm() {
return algorithm; return algorithm;
@ -70,7 +71,8 @@ public class HashElement implements ExtensionElement {
/** /**
* Return the checksum as a byte array. * Return the checksum as a byte array.
* @return *
* @return the hash.
*/ */
public byte[] getHash() { public byte[] getHash() {
return hash; return hash;
@ -78,7 +80,8 @@ public class HashElement implements ExtensionElement {
/** /**
* Return the checksum as a base16 (hex) string. * Return the checksum as a base16 (hex) string.
* @return *
* @return the hash.
*/ */
public String getHashB64() { public String getHashB64() {
return hashB64; return hashB64;

View file

@ -25,7 +25,7 @@ public class UploadService {
enum Version { enum Version {
v0_2, v0_2,
v0_3, v0_3,
}; }
private final DomainBareJid address; private final DomainBareJid address;
private final Version version; private final Version version;

View file

@ -146,6 +146,7 @@ public class MultiUserChatLight {
* for the newly created chat. * for the newly created chat.
* @return new Chat for sending private messages to a given room occupant. * @return new Chat for sending private messages to a given room occupant.
*/ */
@SuppressWarnings("deprecation")
@Deprecated @Deprecated
// Do not re-use Chat API, which was designed for XMPP-IM 1:1 chats and not MUClight private chats. // Do not re-use Chat API, which was designed for XMPP-IM 1:1 chats and not MUClight private chats.
public org.jivesoftware.smack.chat.Chat createPrivateChat(EntityJid occupant, ChatMessageListener listener) { public org.jivesoftware.smack.chat.Chat createPrivateChat(EntityJid occupant, ChatMessageListener listener) {

View file

@ -68,7 +68,7 @@ public class MUCLightBlockingIQProvider extends IQProvider<MUCLightBlockingIQ> {
return mucLightBlockingIQ; return mucLightBlockingIQ;
} }
private HashMap<Jid, Boolean> parseBlocking(XmlPullParser parser, HashMap<Jid, Boolean> map) private static HashMap<Jid, Boolean> parseBlocking(XmlPullParser parser, HashMap<Jid, Boolean> map)
throws XmppStringprepException, XmlPullParserException, IOException { throws XmppStringprepException, XmlPullParserException, IOException {
if (map == null) { if (map == null) {
map = new HashMap<>(); map = new HashMap<>();

View file

@ -93,7 +93,7 @@ public class MUCLightInfoIQProvider extends IQProvider<MUCLightInfoIQ> {
return new MUCLightInfoIQ(version, new MUCLightRoomConfiguration(roomName, subject, customConfigs), occupants); return new MUCLightInfoIQ(version, new MUCLightRoomConfiguration(roomName, subject, customConfigs), occupants);
} }
private HashMap<Jid, MUCLightAffiliation> iterateOccupants(XmlPullParser parser) throws Exception { private static HashMap<Jid, MUCLightAffiliation> iterateOccupants(XmlPullParser parser) throws Exception {
HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>(); HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>();
int depth = parser.getDepth(); int depth = parser.getDepth();

View file

@ -20,11 +20,8 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.jingle.element.Jingle; import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle.element.JingleContent; import org.jivesoftware.smackx.jingle.element.JingleContent;
@ -33,7 +30,6 @@ import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
import org.jxmpp.jid.FullJid; import org.jxmpp.jid.FullJid;
public abstract class JingleSession implements JingleSessionHandler { public abstract class JingleSession implements JingleSessionHandler {
private static final Logger LOGGER = Logger.getLogger(JingleSession.class.getName());
protected HashSet<String> failedTransportMethods = new HashSet<>(); protected HashSet<String> failedTransportMethods = new HashSet<>();
protected final FullJid local; protected final FullJid local;
@ -135,47 +131,43 @@ public abstract class JingleSession implements JingleSessionHandler {
@Override @Override
public IQ handleJingleSessionRequest(Jingle jingle) { public IQ handleJingleSessionRequest(Jingle jingle) {
try { switch (jingle.getAction()) {
switch (jingle.getAction()) { case content_accept:
case content_accept: return handleContentAccept(jingle);
return handleContentAccept(jingle); case content_add:
case content_add: return handleContentAdd(jingle);
return handleContentAdd(jingle); case content_modify:
case content_modify: return handleContentModify(jingle);
return handleContentModify(jingle); case content_reject:
case content_reject: return handleContentReject(jingle);
return handleContentReject(jingle); case content_remove:
case content_remove: return handleContentRemove(jingle);
return handleContentRemove(jingle); case description_info:
case description_info: return handleDescriptionInfo(jingle);
return handleDescriptionInfo(jingle); case session_info:
case session_info: return handleSessionInfo(jingle);
return handleSessionInfo(jingle); case security_info:
case security_info: return handleSecurityInfo(jingle);
return handleSecurityInfo(jingle); case session_accept:
case session_accept: return handleSessionAccept(jingle);
return handleSessionAccept(jingle); case transport_accept:
case transport_accept: return handleTransportAccept(jingle);
return handleTransportAccept(jingle); case transport_info:
case transport_info: return transportSession.handleTransportInfo(jingle);
return transportSession.handleTransportInfo(jingle); case session_initiate:
case session_initiate: return handleSessionInitiate(jingle);
return handleSessionInitiate(jingle); case transport_reject:
case transport_reject: return handleTransportReject(jingle);
return handleTransportReject(jingle); case session_terminate:
case session_terminate: return handleSessionTerminate(jingle);
return handleSessionTerminate(jingle); case transport_replace:
case transport_replace: return handleTransportReplace(jingle);
return handleTransportReplace(jingle); default:
default: return IQ.createResultIQ(jingle);
return IQ.createResultIQ(jingle);
}
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
return null; //TODO:
} }
} }
protected IQ handleSessionInitiate(Jingle sessionInitiate) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { protected IQ handleSessionInitiate(Jingle sessionInitiate) {
return IQ.createResultIQ(sessionInitiate); return IQ.createResultIQ(sessionInitiate);
} }
@ -187,7 +179,7 @@ public abstract class JingleSession implements JingleSessionHandler {
return IQ.createResultIQ(sessionInfo); return IQ.createResultIQ(sessionInfo);
} }
protected IQ handleSessionAccept(Jingle sessionAccept) throws SmackException.NotConnectedException, InterruptedException { protected IQ handleSessionAccept(Jingle sessionAccept) {
return IQ.createResultIQ(sessionAccept); return IQ.createResultIQ(sessionAccept);
} }
@ -219,13 +211,11 @@ public abstract class JingleSession implements JingleSessionHandler {
return IQ.createResultIQ(securityInfo); return IQ.createResultIQ(securityInfo);
} }
protected IQ handleTransportAccept(Jingle transportAccept) throws SmackException.NotConnectedException, InterruptedException { protected IQ handleTransportAccept(Jingle transportAccept) {
return IQ.createResultIQ(transportAccept); return IQ.createResultIQ(transportAccept);
} }
protected IQ handleTransportReplace(Jingle transportReplace) protected IQ handleTransportReplace(Jingle transportReplace) {
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
return IQ.createResultIQ(transportReplace); return IQ.createResultIQ(transportReplace);
} }

View file

@ -87,7 +87,7 @@ public final class JingleTransportMethodManager extends Manager {
return getTransportManager(transport.getNamespace()); return getTransportManager(transport.getNamespace());
} }
public JingleTransportManager<?> getBestAvailableTransportManager(XMPPConnection connection) { public static JingleTransportManager<?> getBestAvailableTransportManager(XMPPConnection connection) {
return getInstanceFor(connection).getBestAvailableTransportManager(); return getInstanceFor(connection).getBestAvailableTransportManager();
} }

View file

@ -99,8 +99,7 @@ public class JingleUtil {
JingleContent.Senders contentSenders, JingleContent.Senders contentSenders,
JingleContentDescription description, JingleContentDescription description,
JingleContentTransport transport) JingleContentTransport transport)
throws SmackException.NotConnectedException, InterruptedException, throws SmackException.NotConnectedException, InterruptedException {
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionInitiate(recipient, sessionId, contentCreator, contentName, contentSenders, Jingle jingle = createSessionInitiate(recipient, sessionId, contentCreator, contentName, contentSenders,
description, transport); description, transport);
@ -142,8 +141,7 @@ public class JingleUtil {
JingleContent.Senders contentSenders, JingleContent.Senders contentSenders,
JingleContentDescription description, JingleContentDescription description,
JingleContentTransport transport) JingleContentTransport transport)
throws SmackException.NotConnectedException, InterruptedException, throws SmackException.NotConnectedException, InterruptedException {
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionAccept(recipient, sessionId, contentCreator, contentName, contentSenders, Jingle jingle = createSessionAccept(recipient, sessionId, contentCreator, contentName, contentSenders,
description, transport); description, transport);
@ -168,22 +166,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, new JingleReason(reason)); return createSessionTerminate(recipient, sessionId, new JingleReason(reason));
} }
private IQ sendSessionTerminate(FullJid recipient, String sessionId, JingleReason.Reason reason)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
return sendSessionTerminate(recipient, sessionId, new JingleReason(reason));
}
private IQ sendSessionTerminate(FullJid recipient, String sessionId, JingleReason reason)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminate(recipient, sessionId, reason);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
public Jingle createSessionTerminateDecline(FullJid recipient, String sessionId) { public Jingle createSessionTerminateDecline(FullJid recipient, String sessionId) {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.decline); return createSessionTerminate(recipient, sessionId, JingleReason.Reason.decline);
} }

View file

@ -465,7 +465,7 @@ public class MultiUserChat {
* @deprecated use {@link #createOrJoin(MucEnterConfiguration)} instead. * @deprecated use {@link #createOrJoin(MucEnterConfiguration)} instead.
*/ */
@Deprecated @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 { throws NoResponseException, XMPPErrorException, InterruptedException, MucAlreadyJoinedException, NotConnectedException, NotAMucServiceException {
MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword( MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword(
password).timeoutAfter(timeout); password).timeoutAfter(timeout);
@ -666,7 +666,7 @@ public class MultiUserChat {
public void join( public void join(
Resourcepart nickname, Resourcepart nickname,
String password, String password,
DiscussionHistory history, @SuppressWarnings("deprecation") DiscussionHistory history,
long timeout) long timeout)
throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException, NotAMucServiceException { throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException, NotAMucServiceException {
MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword( 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. * to true, otherwise it will be null.
* </ul> * </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> * <ul>
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is * <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 * 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 * 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. * 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()} * 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()} * set to false, no <tt>Item</tt> is sent to the node, you have to use the {@link LeafNode#publish()}
* methods in this case. * method in this case.
*/ */
public Item() public Item()
{ {

View file

@ -34,7 +34,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* to true, otherwise it will be null.</li> * to true, otherwise it will be null.</li>
* </ul> * </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> * <ul>
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is * <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 * 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 * Enables automatic requests of delivery receipts for outgoing messages of
* {@link Message.Type#normal}, {@link Message.Type#chat} or {@link Message.Type#headline}, and * {@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 Message.Body} extension. * with a {@link org.jivesoftware.smack.packet.Message.Body} extension.
* *
* @since 4.1 * @since 4.1
* @see #dontAutoAddDeliveryReceiptRequests() * @see #dontAutoAddDeliveryReceiptRequests()

View file

@ -189,6 +189,7 @@ public class JingleS5BTransportTest extends SmackTestSuite {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void transportCandidateIllegalPriorityTest() throws XmppStringprepException { public void transportCandidateIllegalPriorityTest() throws XmppStringprepException {
FullJid jid = JidCreate.fullFrom("test@test.test/test"); FullJid jid = JidCreate.fullFrom("test@test.test/test");
@SuppressWarnings("unused")
JingleS5BTransportCandidate candidate = new JingleS5BTransportCandidate( JingleS5BTransportCandidate candidate = new JingleS5BTransportCandidate(
"cid", "host", jid, 5555, -30, JingleS5BTransportCandidate.Type.proxy); "cid", "host", jid, 5555, -30, JingleS5BTransportCandidate.Type.proxy);
} }
@ -196,6 +197,7 @@ public class JingleS5BTransportTest extends SmackTestSuite {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void transportCandidateIllegalPortTest() throws XmppStringprepException { public void transportCandidateIllegalPortTest() throws XmppStringprepException {
FullJid jid = JidCreate.fullFrom("test@test.test/test"); FullJid jid = JidCreate.fullFrom("test@test.test/test");
@SuppressWarnings("unused")
JingleS5BTransportCandidate candidate = new JingleS5BTransportCandidate( JingleS5BTransportCandidate candidate = new JingleS5BTransportCandidate(
"cid", "host", jid, -5555, 30, JingleS5BTransportCandidate.Type.proxy); "cid", "host", jid, -5555, 30, JingleS5BTransportCandidate.Type.proxy);
} }