mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 09:09:38 +02:00
Bump ErrorProne to 2.5.1 and refactor Providers a bit
This also resulted in a refactoring of the Providers and parsing Exceptions. NumberFormatException and ParseException can now be thrown directly, the wrapping in a SmackParsingException is down at a higher layer, i.e. in AbstractProvider.
This commit is contained in:
parent
1df0763f92
commit
a7b3303f3e
136 changed files with 574 additions and 551 deletions
|
@ -26,7 +26,6 @@ import org.jivesoftware.smack.xml.XmlPullParser;
|
|||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
|
||||
import org.jivesoftware.smackx.address.packet.MultipleAddresses.Type;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
|
@ -50,7 +49,7 @@ public class MultipleAddressesProvider extends ExtensionElementProvider<Multiple
|
|||
switch (name) {
|
||||
case MultipleAddresses.Address.ELEMENT:
|
||||
String typeString = parser.getAttributeValue("", "type");
|
||||
Type type = Type.valueOf(typeString);
|
||||
MultipleAddresses.Type type = MultipleAddresses.Type.valueOf(typeString);
|
||||
Jid jid = ParserUtils.getJidAttribute(parser, "jid");
|
||||
String node = parser.getAttributeValue("", "node");
|
||||
String desc = parser.getAttributeValue("", "desc");
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
|
||||
import org.jivesoftware.smackx.blocking.element.BlockContactsIQ;
|
||||
import org.jivesoftware.smackx.blocking.element.BlockListIQ;
|
||||
|
@ -97,7 +96,7 @@ public final class BlockingCommandManager extends Manager {
|
|||
|
||||
// block IQ handler
|
||||
connection.registerIQRequestHandler(
|
||||
new AbstractIqRequestHandler(BlockContactsIQ.ELEMENT, BlockContactsIQ.NAMESPACE, Type.set, Mode.sync) {
|
||||
new AbstractIqRequestHandler(BlockContactsIQ.ELEMENT, BlockContactsIQ.NAMESPACE, IQ.Type.set, Mode.sync) {
|
||||
@Override
|
||||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
BlockContactsIQ blockContactIQ = (BlockContactsIQ) iqRequest;
|
||||
|
@ -119,7 +118,7 @@ public final class BlockingCommandManager extends Manager {
|
|||
|
||||
// unblock IQ handler
|
||||
connection.registerIQRequestHandler(new AbstractIqRequestHandler(UnblockContactsIQ.ELEMENT,
|
||||
UnblockContactsIQ.NAMESPACE, Type.set, Mode.sync) {
|
||||
UnblockContactsIQ.NAMESPACE, IQ.Type.set, Mode.sync) {
|
||||
@Override
|
||||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
UnblockContactsIQ unblockContactIQ = (UnblockContactsIQ) iqRequest;
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
@ -70,7 +70,7 @@ public class BlockListIQProvider extends IQProvider<BlockListIQ> {
|
|||
}
|
||||
|
||||
BlockListIQ blockListIQ = new BlockListIQ(jids);
|
||||
blockListIQ.setType(Type.result);
|
||||
blockListIQ.setType(IQ.Type.result);
|
||||
return blockListIQ;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2016-2020 Fernando Ramirez, Florian Schmaus
|
||||
* Copyright 2016-2021 Fernando Ramirez, Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.util.SHA1;
|
||||
|
||||
import org.jivesoftware.smackx.bob.element.BoBIQ;
|
||||
|
@ -91,7 +90,7 @@ public final class BoBManager extends Manager {
|
|||
serviceDiscoveryManager.addFeature(NAMESPACE);
|
||||
|
||||
connection.registerIQRequestHandler(
|
||||
new AbstractIqRequestHandler(BoBIQ.ELEMENT, BoBIQ.NAMESPACE, Type.get, Mode.async) {
|
||||
new AbstractIqRequestHandler(BoBIQ.ELEMENT, BoBIQ.NAMESPACE, IQ.Type.get, Mode.async) {
|
||||
@Override
|
||||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
BoBIQ bobIQRequest = (BoBIQ) iqRequest;
|
||||
|
@ -105,7 +104,7 @@ public final class BoBManager extends Manager {
|
|||
|
||||
BoBData bobData = bobInfo.getData();
|
||||
BoBIQ responseBoBIQ = new BoBIQ(contentId, bobData);
|
||||
responseBoBIQ.setType(Type.result);
|
||||
responseBoBIQ.setType(IQ.Type.result);
|
||||
responseBoBIQ.setTo(bobIQRequest.getFrom());
|
||||
return responseBoBIQ;
|
||||
}
|
||||
|
@ -146,7 +145,7 @@ public final class BoBManager extends Manager {
|
|||
}
|
||||
|
||||
BoBIQ requestBoBIQ = new BoBIQ(bobHash);
|
||||
requestBoBIQ.setType(Type.get);
|
||||
requestBoBIQ.setType(IQ.Type.get);
|
||||
requestBoBIQ.setTo(to);
|
||||
|
||||
XMPPConnection connection = getAuthenticatedConnectionOrThrow();
|
||||
|
|
|
@ -441,7 +441,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
|||
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
protected void replyRejectPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
void replyRejectPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
IQ error = IQ.createErrorResponse(request, StanzaError.Condition.not_acceptable);
|
||||
connection().sendStanza(error);
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
|||
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
void replyItemNotFoundPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
IQ error = IQ.createErrorResponse(request, StanzaError.Condition.item_not_found);
|
||||
connection().sendStanza(error);
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @return the XMPP connection
|
||||
*/
|
||||
protected XMPPConnection getConnection() {
|
||||
XMPPConnection getConnection() {
|
||||
return connection();
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
|||
* @param initiator the initiator's JID
|
||||
* @return the listener
|
||||
*/
|
||||
protected BytestreamListener getUserListener(Jid initiator) {
|
||||
BytestreamListener getUserListener(Jid initiator) {
|
||||
return this.userListeners.get(initiator);
|
||||
}
|
||||
|
||||
|
@ -497,7 +497,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @return list of listeners
|
||||
*/
|
||||
protected List<BytestreamListener> getAllRequestListeners() {
|
||||
List<BytestreamListener> getAllRequestListeners() {
|
||||
return this.allRequestListeners;
|
||||
}
|
||||
|
||||
|
@ -506,7 +506,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @return the sessions map
|
||||
*/
|
||||
protected Map<String, InBandBytestreamSession> getSessions() {
|
||||
Map<String, InBandBytestreamSession> getSessions() {
|
||||
return sessions;
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @return list of session IDs
|
||||
*/
|
||||
protected List<String> getIgnoredBytestreamRequests() {
|
||||
List<String> getIgnoredBytestreamRequests() {
|
||||
return ignoredBytestreamRequests;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
|
|||
*
|
||||
* @param manager the SOCKS5 Bytestream manager
|
||||
*/
|
||||
protected InitiationListener(Socks5BytestreamManager manager) {
|
||||
InitiationListener(Socks5BytestreamManager manager) {
|
||||
super(Bytestream.ELEMENT, Bytestream.NAMESPACE, IQ.Type.set, Mode.async);
|
||||
this.manager = manager;
|
||||
initiationListenerExecutor = Executors.newCachedThreadPool();
|
||||
|
@ -117,7 +117,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
|
|||
/**
|
||||
* Shuts down the listeners executor service.
|
||||
*/
|
||||
protected void shutdown() {
|
||||
void shutdown() {
|
||||
this.initiationListenerExecutor.shutdownNow();
|
||||
}
|
||||
|
||||
|
|
|
@ -717,7 +717,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
protected void replyRejectPacket(IQ packet) throws NotConnectedException, InterruptedException {
|
||||
void replyRejectPacket(IQ packet) throws NotConnectedException, InterruptedException {
|
||||
StanzaError xmppError = StanzaError.getBuilder(StanzaError.Condition.not_acceptable).build();
|
||||
IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
|
||||
connection().sendStanza(errorIQ);
|
||||
|
@ -760,7 +760,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @return the XMPP connection
|
||||
*/
|
||||
protected XMPPConnection getConnection() {
|
||||
XMPPConnection getConnection() {
|
||||
return connection();
|
||||
}
|
||||
|
||||
|
@ -771,7 +771,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
* @param initiator the initiator's JID
|
||||
* @return the listener
|
||||
*/
|
||||
protected BytestreamListener getUserListener(Jid initiator) {
|
||||
BytestreamListener getUserListener(Jid initiator) {
|
||||
return this.userListeners.get(initiator);
|
||||
}
|
||||
|
||||
|
@ -781,7 +781,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @return list of listeners
|
||||
*/
|
||||
protected List<BytestreamListener> getAllRequestListeners() {
|
||||
List<BytestreamListener> getAllRequestListeners() {
|
||||
return this.allRequestListeners;
|
||||
}
|
||||
|
||||
|
@ -790,7 +790,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @return list of session IDs
|
||||
*/
|
||||
protected List<String> getIgnoredBytestreamRequests() {
|
||||
List<String> getIgnoredBytestreamRequests() {
|
||||
return ignoredBytestreamRequests;
|
||||
}
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
* Cancels the SOCKS5 Bytestream request by sending an error to the initiator and building a
|
||||
* XMPP exception.
|
||||
*
|
||||
* @param streamHosts the stream hosts.
|
||||
* @param streamHostsExceptions the stream hosts and their exceptions.
|
||||
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
* @throws CouldNotConnectToAnyProvidedSocks5Host as expected result.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2009 Jonas Ådahl, 2011-2020 Florian Schmaus
|
||||
* Copyright © 2009 Jonas Ådahl, 2011-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -96,7 +96,7 @@ public final class EntityCapsManager extends Manager {
|
|||
|
||||
private static String DEFAULT_ENTITY_NODE = SmackConfiguration.SMACK_URL_STRING;
|
||||
|
||||
protected static EntityCapsPersistentCache persistentCache;
|
||||
static EntityCapsPersistentCache persistentCache;
|
||||
|
||||
private static boolean autoEnableEntityCaps = true;
|
||||
|
||||
|
@ -595,7 +595,7 @@ public final class EntityCapsManager extends Manager {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo) {
|
||||
static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo) {
|
||||
return generateVerificationString(discoverInfo, null);
|
||||
}
|
||||
|
||||
|
@ -611,7 +611,7 @@ public final class EntityCapsManager extends Manager {
|
|||
* @return The generated verification String or null if the hash is not
|
||||
* supported
|
||||
*/
|
||||
protected static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo, String hash) {
|
||||
static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo, String hash) {
|
||||
if (hash == null) {
|
||||
hash = DEFAULT_HASH;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Collection;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -520,8 +519,8 @@ public final class AdHocCommandManager extends Manager {
|
|||
private void sessionSweeper() {
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
synchronized (this) {
|
||||
for (Iterator<Entry<String, LocalCommand>> it = executingCommands.entrySet().iterator(); it.hasNext();) {
|
||||
Entry<String, LocalCommand> entry = it.next();
|
||||
for (Iterator<Map.Entry<String, LocalCommand>> it = executingCommands.entrySet().iterator(); it.hasNext();) {
|
||||
Map.Entry<String, LocalCommand> entry = it.next();
|
||||
LocalCommand command = entry.getValue();
|
||||
|
||||
long creationStamp = command.getCreationDate();
|
||||
|
@ -561,7 +560,6 @@ public final class AdHocCommandManager extends Manager {
|
|||
*
|
||||
* @param response the response to send.
|
||||
* @param condition the condition of the error.
|
||||
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||
*/
|
||||
private static IQ respondError(AdHocCommandData response,
|
||||
StanzaError.Condition condition) {
|
||||
|
@ -574,7 +572,6 @@ public final class AdHocCommandManager extends Manager {
|
|||
* @param response the response to send.
|
||||
* @param condition the condition of the error.
|
||||
* @param specificCondition the adhoc command error condition.
|
||||
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||
*/
|
||||
private static IQ respondError(AdHocCommandData response, StanzaError.Condition condition,
|
||||
AdHocCommand.SpecificErrorCondition specificCondition) {
|
||||
|
@ -589,7 +586,6 @@ public final class AdHocCommandManager extends Manager {
|
|||
*
|
||||
* @param response the response to send.
|
||||
* @param error the error to send.
|
||||
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||
*/
|
||||
private static IQ respondError(AdHocCommandData response, StanzaError error) {
|
||||
response.setType(IQ.Type.error);
|
||||
|
@ -608,8 +604,8 @@ public final class AdHocCommandManager extends Manager {
|
|||
* @throws NoSuchMethodException if no such method is declared
|
||||
* @throws InvocationTargetException if a reflection-based method or constructor invocation threw.
|
||||
* @throws IllegalArgumentException if an illegal argument was given.
|
||||
* @throws IllegalAccessException
|
||||
* @throws InstantiationException
|
||||
* @throws IllegalAccessException in case of an illegal access.
|
||||
* @throws InstantiationException in case of an instantiation error.
|
||||
*/
|
||||
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID)
|
||||
throws XMPPErrorException, InstantiationException, IllegalAccessException, IllegalArgumentException,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
* Copyright © 2014-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,10 +17,10 @@
|
|||
package org.jivesoftware.smackx.delay.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
@ -32,7 +32,7 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
|
|||
@Override
|
||||
public final DelayInformation parse(XmlPullParser parser,
|
||||
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,
|
||||
IOException, SmackTextParseException {
|
||||
IOException, ParseException {
|
||||
String stampString = parser.getAttributeValue("", "stamp");
|
||||
String from = parser.getAttributeValue("", "from");
|
||||
final String reason;
|
||||
|
@ -54,5 +54,5 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
|
|||
return new DelayInformation(stamp, from, reason);
|
||||
}
|
||||
|
||||
protected abstract Date parseDate(String string) throws SmackTextParseException;
|
||||
protected abstract Date parseDate(String string) throws ParseException;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
* Copyright © 2014-2021 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,9 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.delay.provider;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ public class DelayInformationProvider extends AbstractDelayInformationProvider {
|
|||
public static final DelayInformationProvider INSTANCE = new DelayInformationProvider();
|
||||
|
||||
@Override
|
||||
protected Date parseDate(String string) throws SmackTextParseException {
|
||||
protected Date parseDate(String string) throws ParseException {
|
||||
return ParserUtils.getDateFromXep82String(string);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
* Copyright © 2014-2021 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,9 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.delay.provider;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.util.ParserUtils;
|
|||
public class LegacyDelayInformationProvider extends AbstractDelayInformationProvider {
|
||||
|
||||
@Override
|
||||
protected Date parseDate(String string) throws SmackTextParseException {
|
||||
protected Date parseDate(String string) throws ParseException {
|
||||
return ParserUtils.getDateFromString(string);
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ public final class FileTransferManager extends Manager {
|
|||
* @return The IncomingFileTransfer which manages the download of the file
|
||||
* from the transfer initiator.
|
||||
*/
|
||||
protected IncomingFileTransfer createIncomingFileTransfer(
|
||||
IncomingFileTransfer createIncomingFileTransfer(
|
||||
FileTransferRequest request) {
|
||||
if (request == null) {
|
||||
throw new NullPointerException("ReceiveRequest cannot be null");
|
||||
|
@ -164,7 +164,7 @@ public final class FileTransferManager extends Manager {
|
|||
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
protected void rejectIncomingFileTransfer(FileTransferRequest request) throws NotConnectedException, InterruptedException {
|
||||
void rejectIncomingFileTransfer(FileTransferRequest request) throws NotConnectedException, InterruptedException {
|
||||
StreamInitiation initiation = request.getStreamInitiation();
|
||||
|
||||
// Reject as specified in XEP-95 4.2. Note that this is not to be confused with the Socks 5
|
||||
|
|
|
@ -65,7 +65,7 @@ public final class FileTransferNegotiator extends Manager {
|
|||
|
||||
private static final String STREAM_INIT_PREFIX = "jsi_";
|
||||
|
||||
protected static final String STREAM_DATA_FIELD_NAME = "stream-method";
|
||||
static final String STREAM_DATA_FIELD_NAME = "stream-method";
|
||||
|
||||
private static final Random randomGenerator = new Random();
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.EventManger;
|
||||
import org.jivesoftware.smack.util.EventManger.Callback;
|
||||
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
|
@ -101,7 +100,7 @@ public abstract class StreamNegotiator extends Manager {
|
|||
final String eventKey = initiation.getFrom().toString() + '\t' + initiation.getSessionID();
|
||||
IQ streamMethodInitiation;
|
||||
try {
|
||||
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getReplyTimeout(), new Callback<NotConnectedException>() {
|
||||
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getReplyTimeout(), new EventManger.Callback<NotConnectedException>() {
|
||||
@Override
|
||||
public void action() throws NotConnectedException {
|
||||
try {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2013-2014 Georg Lukas, 2020 Florian Schmaus
|
||||
* Copyright 2013-2014 Georg Lukas, 2020-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.forward.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -45,7 +46,8 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded<?>> {
|
|||
private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName());
|
||||
|
||||
@Override
|
||||
public Forwarded<?> parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
public Forwarded<?> parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||
DelayInformation di = null;
|
||||
Stanza packet = null;
|
||||
|
||||
|
@ -90,13 +92,14 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded<?>> {
|
|||
}
|
||||
|
||||
public static Forwarded<Message> parseForwardedMessage(XmlPullParser parser, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||
return parseForwardedMessage(parser, parser.getDepth(), xmlEnvironment);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Forwarded<Message> parseForwardedMessage(XmlPullParser parser, int initialDepth,
|
||||
XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||
Forwarded<?> forwarded = INSTANCE.parse(parser, initialDepth, xmlEnvironment);
|
||||
if (!forwarded.isForwarded(Message.class)) {
|
||||
throw new SmackParsingException("Expecting a forwarded message, but got " + forwarded);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015-2017 Ishan Khanna, Fernando Ramirez, 2019-2020 Florian Schmaus
|
||||
* Copyright 2015-2017 Ishan Khanna, Fernando Ramirez, 2019-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,12 +17,12 @@
|
|||
package org.jivesoftware.smackx.geoloc.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
@ -38,7 +38,7 @@ public class GeoLocationProvider extends ExtensionElementProvider<GeoLocation> {
|
|||
|
||||
@Override
|
||||
public GeoLocation parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException,
|
||||
SmackTextParseException, SmackUriSyntaxParsingException {
|
||||
SmackUriSyntaxParsingException, ParseException {
|
||||
|
||||
GeoLocation.Builder builder = GeoLocation.builder();
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class GeoLocationProvider extends ExtensionElementProvider<GeoLocation> {
|
|||
|
||||
@Override
|
||||
public GeoLocation parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||
return GeoLocationProvider.INSTANCE.parse(parser, initialDepth, xmlEnvironment);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
|||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -164,7 +163,7 @@ public final class LastActivityManager extends Manager {
|
|||
|
||||
// Register a listener for a last activity query
|
||||
connection.registerIQRequestHandler(new AbstractIqRequestHandler(LastActivity.ELEMENT, LastActivity.NAMESPACE,
|
||||
Type.get, Mode.async) {
|
||||
IQ.Type.get, Mode.async) {
|
||||
@Override
|
||||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
if (!enabled)
|
||||
|
|
|
@ -24,12 +24,10 @@ import java.util.Set;
|
|||
import java.util.WeakHashMap;
|
||||
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.StanzaCollector;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.StanzaIdFilter;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
@ -355,13 +353,11 @@ public final class AccountManager extends Manager {
|
|||
|
||||
/**
|
||||
* Gets the account registration info from the server.
|
||||
*
|
||||
* @throws XMPPErrorException if there was an XMPP error returned.
|
||||
* @throws NoResponseException if there was no response from the remote entity.
|
||||
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*
|
||||
* @throws XMPPException if an error occurs.
|
||||
* @throws SmackException if there was no response from the server.
|
||||
*/
|
||||
private synchronized void getRegistrationInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Registration reg = new Registration();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Florian Schmaus
|
||||
* Copyright 2017-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPConnection;
|
|||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||
|
@ -74,7 +73,7 @@ public final class JingleManager extends Manager {
|
|||
jutil = new JingleUtil(connection);
|
||||
|
||||
connection.registerIQRequestHandler(
|
||||
new AbstractIqRequestHandler(Jingle.ELEMENT, Jingle.NAMESPACE, Type.set, Mode.async) {
|
||||
new AbstractIqRequestHandler(Jingle.ELEMENT, Jingle.NAMESPACE, IQ.Type.set, Mode.async) {
|
||||
@Override
|
||||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
final Jingle jingle = (Jingle) iqRequest;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2020 Florian Schmaus
|
||||
* Copyright 2017-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -76,7 +76,7 @@ public class JingleReason implements FullyQualifiedElement {
|
|||
unsupported_transports,
|
||||
;
|
||||
|
||||
protected static final Map<String, Reason> LUT = new HashMap<>(Reason.values().length);
|
||||
static final Map<String, Reason> LUT = new HashMap<>(Reason.values().length);
|
||||
|
||||
static {
|
||||
for (Reason reason : Reason.values()) {
|
||||
|
@ -84,7 +84,7 @@ public class JingleReason implements FullyQualifiedElement {
|
|||
}
|
||||
}
|
||||
|
||||
protected final String asString;
|
||||
final String asString;
|
||||
|
||||
Reason() {
|
||||
asString = name().replace('_', '-');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2019 Florian Schmaus
|
||||
* Copyright 2017-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.jingle.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
|
@ -30,6 +31,7 @@ public abstract class JingleContentDescriptionProvider<D extends JingleContentDe
|
|||
extends ExtensionElementProvider<D> {
|
||||
|
||||
@Override
|
||||
public abstract D parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException;
|
||||
public abstract D parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ public class JivePropertiesExtensionProvider extends ExtensionElementProvider<Ji
|
|||
* @throws IOException if an I/O error occurred.
|
||||
* @throws XmlPullParserException if an error in the XML parser occurred.
|
||||
*/
|
||||
@SuppressWarnings("BanSerializableRead")
|
||||
@Override
|
||||
public JivePropertiesExtension parse(XmlPullParser parser,
|
||||
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2018 Paul Schaub, 2019 Florian Schmaus
|
||||
* Copyright © 2018 Paul Schaub, 2019-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,8 +20,6 @@ import java.text.ParseException;
|
|||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
|
@ -34,14 +32,9 @@ public class IdleProvider extends ExtensionElementProvider<IdleElement> {
|
|||
public static final IdleProvider TEST_INSTANCE = new IdleProvider();
|
||||
|
||||
@Override
|
||||
public IdleElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws SmackTextParseException {
|
||||
public IdleElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws ParseException {
|
||||
String dateString = parser.getAttributeValue(null, IdleElement.ATTR_SINCE);
|
||||
Date since;
|
||||
try {
|
||||
since = XmppDateTime.parseXEP0082Date(dateString);
|
||||
} catch (ParseException e) {
|
||||
throw new SmackParsingException.SmackTextParseException(e);
|
||||
}
|
||||
Date since = XmppDateTime.parseXEP0082Date(dateString);
|
||||
return new IdleElement(since);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1044,8 +1044,8 @@ public class MultiUserChat {
|
|||
/**
|
||||
* Fires invitation rejection listeners.
|
||||
*
|
||||
* @param invitee the user being invited.
|
||||
* @param reason the reason for the rejection
|
||||
* @param message the message.
|
||||
* @param rejection the information about the rejection.
|
||||
*/
|
||||
private void fireInvitationRejectionListeners(Message message, MUCUser.Decline rejection) {
|
||||
EntityBareJid invitee = rejection.getFrom();
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.util.ExceptionCallback;
|
||||
|
@ -120,7 +119,7 @@ public final class PingManager extends Manager {
|
|||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
sdm.addFeature(Ping.NAMESPACE);
|
||||
|
||||
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Ping.ELEMENT, Ping.NAMESPACE, Type.get, Mode.async) {
|
||||
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Ping.ELEMENT, Ping.NAMESPACE, IQ.Type.get, Mode.async) {
|
||||
@Override
|
||||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
Ping ping = (Ping) iqRequest;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
* Copyright 2015-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.privacy.filter;
|
||||
|
||||
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import org.jivesoftware.smackx.privacy.packet.Privacy;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public final class SetActiveListFilter extends FlexibleStanzaTypeFilter<Privacy>
|
|||
|
||||
@Override
|
||||
protected boolean acceptSpecific(Privacy privacy) {
|
||||
if (privacy.getType() != Type.set) {
|
||||
if (privacy.getType() != IQ.Type.set) {
|
||||
return false;
|
||||
}
|
||||
return privacy.getActiveName() != null || privacy.isDeclineActiveList();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
* Copyright 2015-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.privacy.filter;
|
||||
|
||||
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import org.jivesoftware.smackx.privacy.packet.Privacy;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public final class SetDefaultListFilter extends FlexibleStanzaTypeFilter<Privacy
|
|||
|
||||
@Override
|
||||
protected boolean acceptSpecific(Privacy privacy) {
|
||||
if (privacy.getType() != Type.set) {
|
||||
if (privacy.getType() != IQ.Type.set) {
|
||||
return false;
|
||||
}
|
||||
return privacy.getDefaultName() != null || privacy.isDeclineDefaultList();
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
|
|||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.pubsub.form.ConfigureForm;
|
||||
|
@ -90,7 +90,7 @@ public class LeafNode extends Node {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public <T extends Item> List<T> getItems(String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId));
|
||||
PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId(), subscriptionId));
|
||||
return getItems(request);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class LeafNode extends Node {
|
|||
for (String id : ids) {
|
||||
itemList.add(new Item(id));
|
||||
}
|
||||
PubSub request = createPubsubPacket(Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
|
||||
PubSub request = createPubsubPacket(IQ.Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
|
||||
return getItems(request);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class LeafNode extends Node {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public <T extends Item> List<T> getItems(int maxItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), maxItems));
|
||||
PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId(), maxItems));
|
||||
return getItems(request);
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class LeafNode extends Node {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId, maxItems));
|
||||
PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId(), subscriptionId, maxItems));
|
||||
return getItems(request);
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ public class LeafNode extends Node {
|
|||
public <T extends Item> List<T> getItems(List<ExtensionElement> additionalExtensions,
|
||||
List<ExtensionElement> returnedExtensions) throws NoResponseException,
|
||||
XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId()));
|
||||
PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId()));
|
||||
request.addExtensions(additionalExtensions);
|
||||
return getItems(request, returnedExtensions);
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ public class LeafNode extends Node {
|
|||
*
|
||||
*/
|
||||
public void publish() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
|
||||
PubSub packet = createPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
|
||||
|
||||
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ public class LeafNode extends Node {
|
|||
*
|
||||
*/
|
||||
public <T extends Item> void publish(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub packet = createPubsubPacket(Type.set, new PublishItem<>(getId(), items));
|
||||
PubSub packet = createPubsubPacket(IQ.Type.set, new PublishItem<>(getId(), items));
|
||||
|
||||
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ public class LeafNode extends Node {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub request = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()));
|
||||
PubSub request = createPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()));
|
||||
|
||||
pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ public class LeafNode extends Node {
|
|||
for (String id : itemIds) {
|
||||
items.add(new Item(id));
|
||||
}
|
||||
PubSub request = createPubsubPacket(Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items));
|
||||
PubSub request = createPubsubPacket(IQ.Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items));
|
||||
pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|||
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
|
||||
import org.jivesoftware.smack.filter.OrFilter;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
|
@ -94,7 +94,7 @@ public abstract class Node {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(
|
||||
PubSub pubSub = createPubsubPacket(IQ.Type.get, new NodeExtension(
|
||||
PubSubElementType.CONFIGURE_OWNER, getId()));
|
||||
Stanza reply = sendPubsubPacket(pubSub);
|
||||
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
|
||||
|
@ -110,7 +110,7 @@ public abstract class Node {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public void sendConfigurationForm(FillableConfigureForm configureForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub packet = createPubsubPacket(Type.set, new FormNode(FormNodeType.CONFIGURE_OWNER,
|
||||
PubSub packet = createPubsubPacket(IQ.Type.set, new FormNode(FormNodeType.CONFIGURE_OWNER,
|
||||
getId(), configureForm.getDataFormToSubmit()));
|
||||
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ public abstract class Node {
|
|||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSubElementType pubSubElementType = subscriptionsNamespace.type;
|
||||
|
||||
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(pubSubElementType, getId()));
|
||||
PubSub pubSub = createPubsubPacket(IQ.Type.get, new NodeExtension(pubSubElementType, getId()));
|
||||
if (additionalExtensions != null) {
|
||||
for (ExtensionElement pe : additionalExtensions) {
|
||||
pubSub.addExtension(pe);
|
||||
|
@ -251,7 +251,7 @@ public abstract class Node {
|
|||
public PubSub modifySubscriptionsAsOwner(List<Subscription> changedSubs)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
|
||||
PubSub pubSub = createPubsubPacket(Type.set,
|
||||
PubSub pubSub = createPubsubPacket(IQ.Type.set,
|
||||
new SubscriptionsExtension(SubscriptionsNamespace.owner, getId(), changedSubs));
|
||||
return sendPubsubPacket(pubSub);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ public abstract class Node {
|
|||
NotConnectedException, InterruptedException {
|
||||
PubSubElementType pubSubElementType = affiliationsNamespace.type;
|
||||
|
||||
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(pubSubElementType, getId()));
|
||||
PubSub pubSub = createPubsubPacket(IQ.Type.get, new NodeExtension(pubSubElementType, getId()));
|
||||
if (additionalExtensions != null) {
|
||||
for (ExtensionElement pe : additionalExtensions) {
|
||||
pubSub.addExtension(pe);
|
||||
|
@ -375,7 +375,7 @@ public abstract class Node {
|
|||
}
|
||||
}
|
||||
|
||||
PubSub pubSub = createPubsubPacket(Type.set, new AffiliationsExtension(AffiliationNamespace.owner, affiliations, getId()));
|
||||
PubSub pubSub = createPubsubPacket(IQ.Type.set, new AffiliationsExtension(AffiliationNamespace.owner, affiliations, getId()));
|
||||
return sendPubsubPacket(pubSub);
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ public abstract class Node {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public Subscription subscribe(Jid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub pubSub = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId()));
|
||||
PubSub pubSub = createPubsubPacket(IQ.Type.set, new SubscribeExtension(jid, getId()));
|
||||
PubSub reply = sendPubsubPacket(pubSub);
|
||||
return reply.getExtension(PubSubElementType.SUBSCRIPTION);
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ public abstract class Node {
|
|||
*/
|
||||
public Subscription subscribe(Jid jid, FillableSubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
DataForm submitForm = subForm.getDataFormToSubmit();
|
||||
PubSub request = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId()));
|
||||
PubSub request = createPubsubPacket(IQ.Type.set, new SubscribeExtension(jid, getId()));
|
||||
request.addExtension(new FormNode(FormNodeType.OPTIONS, submitForm));
|
||||
PubSub reply = sendPubsubPacket(request);
|
||||
return reply.getExtension(PubSubElementType.SUBSCRIPTION);
|
||||
|
@ -529,7 +529,7 @@ public abstract class Node {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public void unsubscribe(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
sendPubsubPacket(createPubsubPacket(Type.set, new UnsubscribeExtension(jid, getId(), subscriptionId)));
|
||||
sendPubsubPacket(createPubsubPacket(IQ.Type.set, new UnsubscribeExtension(jid, getId(), subscriptionId)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -563,7 +563,7 @@ public abstract class Node {
|
|||
*
|
||||
*/
|
||||
public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub packet = sendPubsubPacket(createPubsubPacket(Type.get, new OptionsExtension(jid, getId(), subscriptionId)));
|
||||
PubSub packet = sendPubsubPacket(createPubsubPacket(IQ.Type.get, new OptionsExtension(jid, getId(), subscriptionId)));
|
||||
FormNode ext = packet.getExtension(PubSubElementType.OPTIONS);
|
||||
return new SubscribeForm(ext.getForm());
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ public abstract class Node {
|
|||
return super.toString() + " " + getClass().getName() + " id: " + id;
|
||||
}
|
||||
|
||||
protected PubSub createPubsubPacket(Type type, NodeExtension ext) {
|
||||
protected PubSub createPubsubPacket(IQ.Type type, NodeExtension ext) {
|
||||
return PubSub.createPubsubPacket(pubSubManager.getServiceJid(), type, ext);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|||
import org.jivesoftware.smack.packet.EmptyResultIQ;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StanzaError.Condition;
|
||||
|
@ -217,7 +216,7 @@ public final class PubSubManager extends Manager {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null);
|
||||
PubSub reply = sendPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.CREATE), null);
|
||||
QName qname = new QName(PubSubNamespace.basic.getXmlns(), "create");
|
||||
NodeExtension elem = (NodeExtension) reply.getExtension(qname);
|
||||
|
||||
|
@ -257,7 +256,7 @@ public final class PubSubManager extends Manager {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public Node createNode(String nodeId, FillableConfigureForm config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub request = PubSub.createPubsubPacket(pubSubService, Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId));
|
||||
PubSub request = PubSub.createPubsubPacket(pubSubService, IQ.Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId));
|
||||
boolean isLeafNode = true;
|
||||
|
||||
if (config != null) {
|
||||
|
@ -507,7 +506,7 @@ public final class PubSubManager extends Manager {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
|
||||
Stanza reply = sendPubsubPacket(IQ.Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
|
||||
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtensionElement(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
|
||||
return subElem.getSubscriptions();
|
||||
}
|
||||
|
@ -523,7 +522,7 @@ public final class PubSubManager extends Manager {
|
|||
*
|
||||
*/
|
||||
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null);
|
||||
PubSub reply = sendPubsubPacket(IQ.Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null);
|
||||
AffiliationsExtension listElem = reply.getExtension(PubSubElementType.AFFILIATIONS);
|
||||
return listElem.getAffiliations();
|
||||
}
|
||||
|
@ -541,7 +540,7 @@ public final class PubSubManager extends Manager {
|
|||
public boolean deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
boolean res = true;
|
||||
try {
|
||||
sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
|
||||
sendPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
|
||||
} catch (XMPPErrorException e) {
|
||||
if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) {
|
||||
res = false;
|
||||
|
@ -565,7 +564,7 @@ public final class PubSubManager extends Manager {
|
|||
public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
// Errors will cause exceptions in getReply, so it only returns
|
||||
// on success.
|
||||
PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace());
|
||||
PubSub reply = sendPubsubPacket(IQ.Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace());
|
||||
return NodeUtils.getFormFromPacket(reply, PubSubElementType.DEFAULT);
|
||||
}
|
||||
|
||||
|
@ -644,7 +643,7 @@ public final class PubSubManager extends Manager {
|
|||
return true;
|
||||
}
|
||||
|
||||
private PubSub sendPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns)
|
||||
private PubSub sendPubsubPacket(IQ.Type type, ExtensionElement ext, PubSubNamespace ns)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
return sendPubsubPacket(pubSubService, type, Collections.singletonList(ext), ns);
|
||||
}
|
||||
|
@ -653,7 +652,7 @@ public final class PubSubManager extends Manager {
|
|||
return connection();
|
||||
}
|
||||
|
||||
PubSub sendPubsubPacket(Jid to, Type type, List<ExtensionElement> extList, PubSubNamespace ns)
|
||||
PubSub sendPubsubPacket(Jid to, IQ.Type type, List<ExtensionElement> extList, PubSubNamespace ns)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException,
|
||||
InterruptedException {
|
||||
// CHECKSTYLE:OFF
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.jivesoftware.smackx.xdata.TextSingleFormField;
|
|||
import org.jivesoftware.smackx.xdata.form.FilledForm;
|
||||
import org.jivesoftware.smackx.xdata.form.Form;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
|
||||
|
||||
/**
|
||||
* {@link Form} that contains the software information.
|
||||
|
@ -145,7 +144,7 @@ public final class SoftwareInfoForm extends FilledForm {
|
|||
DataForm.Builder dataFormBuilder;
|
||||
|
||||
private Builder() {
|
||||
dataFormBuilder = DataForm.builder(Type.result);
|
||||
dataFormBuilder = DataForm.builder(DataForm.Type.result);
|
||||
TextSingleFormField formField = FormField.buildHiddenFormType(FORM_TYPE);
|
||||
dataFormBuilder.addField(formField);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014 Florian Schmaus
|
||||
* Copyright 2014-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StanzaError.Condition;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
@ -72,7 +71,7 @@ public final class EntityTimeManager extends Manager {
|
|||
if (autoEnable)
|
||||
enable();
|
||||
|
||||
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, Type.get,
|
||||
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, IQ.Type.get,
|
||||
Mode.async) {
|
||||
@Override
|
||||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.security.MessageDigest;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -612,10 +611,10 @@ public final class VCard extends IQ {
|
|||
xml.optElement("ORGUNIT", organizationUnit);
|
||||
xml.closeElement("ORG");
|
||||
}
|
||||
for (Entry<String, String> entry : otherSimpleFields.entrySet()) {
|
||||
for (Map.Entry<String, String> entry : otherSimpleFields.entrySet()) {
|
||||
xml.optElement(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (Entry<String, String> entry : otherUnescapableFields.entrySet()) {
|
||||
for (Map.Entry<String, String> entry : otherUnescapableFields.entrySet()) {
|
||||
final String value = entry.getValue();
|
||||
if (value == null) {
|
||||
continue;
|
||||
|
@ -646,7 +645,7 @@ public final class VCard extends IQ {
|
|||
xml.element("USERID", emailHome);
|
||||
xml.closeElement("EMAIL");
|
||||
}
|
||||
for (Entry<String, String> phone : workPhones.entrySet()) {
|
||||
for (Map.Entry<String, String> phone : workPhones.entrySet()) {
|
||||
final String number = phone.getValue();
|
||||
if (number == null) {
|
||||
continue;
|
||||
|
@ -657,7 +656,7 @@ public final class VCard extends IQ {
|
|||
xml.element("NUMBER", number);
|
||||
xml.closeElement("TEL");
|
||||
}
|
||||
for (Entry<String, String> phone : homePhones.entrySet()) {
|
||||
for (Map.Entry<String, String> phone : homePhones.entrySet()) {
|
||||
final String number = phone.getValue();
|
||||
if (number == null) {
|
||||
continue;
|
||||
|
@ -671,7 +670,7 @@ public final class VCard extends IQ {
|
|||
if (!workAddr.isEmpty()) {
|
||||
xml.openElement("ADR");
|
||||
xml.emptyElement("WORK");
|
||||
for (Entry<String, String> entry : workAddr.entrySet()) {
|
||||
for (Map.Entry<String, String> entry : workAddr.entrySet()) {
|
||||
final String value = entry.getValue();
|
||||
if (value == null) {
|
||||
continue;
|
||||
|
@ -683,7 +682,7 @@ public final class VCard extends IQ {
|
|||
if (!homeAddr.isEmpty()) {
|
||||
xml.openElement("ADR");
|
||||
xml.emptyElement("HOME");
|
||||
for (Entry<String, String> entry : homeAddr.entrySet()) {
|
||||
for (Map.Entry<String, String> entry : homeAddr.entrySet()) {
|
||||
final String value = entry.getValue();
|
||||
if (value == null) {
|
||||
continue;
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.Set;
|
|||
import org.jivesoftware.smackx.xdata.AbstractMultiFormField;
|
||||
import org.jivesoftware.smackx.xdata.AbstractSingleStringValueFormField;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.FormField.Type;
|
||||
import org.jivesoftware.smackx.xdata.FormFieldChildElement;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
|
@ -202,7 +201,7 @@ public class FillableForm extends FilledForm {
|
|||
|
||||
public void setAnswer(String fieldName, boolean answer) {
|
||||
FormField blankField = getFieldOrThrow(fieldName);
|
||||
if (blankField.getType() != Type.bool) {
|
||||
if (blankField.getType() != FormField.Type.bool) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2020 Florian Schmaus
|
||||
* Copyright 2020-2021 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.util.StringUtils;
|
|||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.TextSingleFormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
|
||||
|
||||
public abstract class FilledForm implements FormReader {
|
||||
|
||||
|
@ -36,7 +35,7 @@ public abstract class FilledForm implements FormReader {
|
|||
if (StringUtils.isNullOrEmpty(formType)) {
|
||||
throw new IllegalArgumentException("The provided data form has no hidden FROM_TYPE field.");
|
||||
}
|
||||
if (dataForm.getType() == Type.cancel) {
|
||||
if (dataForm.getType() == DataForm.Type.cancel) {
|
||||
throw new IllegalArgumentException("Forms of type 'cancel' are not filled nor fillable");
|
||||
}
|
||||
formTypeFormField = dataForm.getHiddenFormTypeField();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2020 Florian Schmaus
|
||||
* Copyright 2020-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,13 +19,12 @@ package org.jivesoftware.smackx.xdata.form;
|
|||
import org.jivesoftware.smack.packet.StanzaView;
|
||||
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
|
||||
|
||||
public class Form extends FilledForm {
|
||||
|
||||
public Form(DataForm dataForm) {
|
||||
super(dataForm);
|
||||
if (dataForm.getType() != Type.form) {
|
||||
if (dataForm.getType() != DataForm.Type.form) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +35,7 @@ public class Form extends FilledForm {
|
|||
|
||||
public static Form from(StanzaView stanzaView) {
|
||||
DataForm dataForm = DataForm.from(stanzaView);
|
||||
if (dataForm == null || dataForm.getType() != Type.form) {
|
||||
if (dataForm == null || dataForm.getType() != DataForm.Type.form) {
|
||||
return null;
|
||||
}
|
||||
return new Form(dataForm);
|
||||
|
|
|
@ -112,6 +112,8 @@ public abstract class ValidateElement implements FormFieldChildElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* Append XML.
|
||||
*
|
||||
* @param buf TODO javadoc me please
|
||||
*/
|
||||
protected abstract void appendXML(XmlStringBuilder buf);
|
||||
|
@ -458,6 +460,8 @@ public abstract class ValidateElement implements FormFieldChildElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that the field being build is not of type multi (or hidden).
|
||||
*
|
||||
* @param formField TODO javadoc me please
|
||||
* @param method TODO javadoc me please
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.blocking;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
|
@ -42,7 +41,7 @@ public class GetBlockingListTest {
|
|||
@Test
|
||||
public void checkGetBlockingListIQStanza() throws Exception {
|
||||
BlockListIQ getBlockListIQ = new BlockListIQ(null);
|
||||
getBlockListIQ.setType(Type.get);
|
||||
getBlockListIQ.setType(IQ.Type.get);
|
||||
getBlockListIQ.setStanzaId("blocklist1");
|
||||
assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
@ -46,7 +46,7 @@ public class BoBIQTest extends SmackTestSuite {
|
|||
BoBIQ createdBoBIQ = new BoBIQ(bobHash);
|
||||
createdBoBIQ.setStanzaId("sarasa");
|
||||
createdBoBIQ.setTo(JidCreate.from("ladymacbeth@shakespeare.lit/castle"));
|
||||
createdBoBIQ.setType(Type.get);
|
||||
createdBoBIQ.setType(IQ.Type.get);
|
||||
|
||||
assertEquals(sampleBoBIQRequest, createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class BoBIQTest extends SmackTestSuite {
|
|||
BoBIQ createdBoBIQ = new BoBIQ(bobHash, bobData);
|
||||
createdBoBIQ.setStanzaId("sarasa");
|
||||
createdBoBIQ.setTo(JidCreate.from("doctor@shakespeare.lit/pda"));
|
||||
createdBoBIQ.setType(Type.result);
|
||||
createdBoBIQ.setType(IQ.Type.result);
|
||||
|
||||
assertEquals(bobIQ.getContentId().getHash(), createdBoBIQ.getContentId().getHash());
|
||||
assertEquals(bobIQ.getContentId().getHashType(), createdBoBIQ.getContentId().getHashType());
|
||||
|
|
|
@ -237,7 +237,7 @@ public class PingTest extends SmackTestSuite {
|
|||
/**
|
||||
* The returned connection won't send replies to IQs
|
||||
*
|
||||
* @return
|
||||
* @return a dummy connection.
|
||||
* @throws XMPPException if an XMPP protocol error was received.
|
||||
* @throws IOException if an I/O error occurred.
|
||||
* @throws SmackException if Smack detected an exceptional situation.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2020 Florian Schmaus
|
||||
* Copyright 2017-2021 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 java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smackx.pubsub.Affiliation.Type;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -35,7 +34,7 @@ public class AffiliationsExtensionTest {
|
|||
@Test
|
||||
public void testAffiliationsExtensionToXml() throws SAXException, IOException {
|
||||
BareJid affiliatedJid = JidTestUtil.BARE_JID_1;
|
||||
Affiliation affiliation = new Affiliation(affiliatedJid, Type.member);
|
||||
Affiliation affiliation = new Affiliation(affiliatedJid, Affiliation.Type.member);
|
||||
List<Affiliation> affiliationsList = new ArrayList<>();
|
||||
affiliationsList.add(affiliation);
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.jivesoftware.smack.ThreadedDummyConnection;
|
|||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StanzaError.Condition;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
@ -63,7 +62,7 @@ public class ConfigureFormTest extends SmackTestSuite {
|
|||
Node node = mgr.getNode("princely_musings");
|
||||
|
||||
PubSub errorIq = new PubSub();
|
||||
errorIq.setType(Type.error);
|
||||
errorIq.setType(IQ.Type.error);
|
||||
errorIq.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
|
||||
StanzaError error = StanzaError.getBuilder(Condition.forbidden).build();
|
||||
errorIq.setError(error);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2018 Timothy Pitt, Florian Schmaus
|
||||
* Copyright 2018 Timothy Pitt, 2018-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.SmackException;
|
|||
import org.jivesoftware.smack.ThreadedDummyConnection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
@ -89,7 +89,7 @@ public class PubSubNodeTest extends SmackTestSuite {
|
|||
new Affiliation(JidTestUtil.BARE_JID_2, Affiliation.Type.publisher)
|
||||
);
|
||||
AffiliationsExtension affiliationsExtension = new AffiliationsExtension(AffiliationNamespace.owner, affiliations);
|
||||
PubSub response = new PubSub(JidTestUtil.PUBSUB_EXAMPLE_ORG, Type.result, PubSubNamespace.owner);
|
||||
PubSub response = new PubSub(JidTestUtil.PUBSUB_EXAMPLE_ORG, IQ.Type.result, PubSubNamespace.owner);
|
||||
response.addExtension(affiliationsExtension);
|
||||
protocol.addResponse(response);
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm;
|
|||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.TextSingleFormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -85,21 +84,21 @@ public class SoftwareInfoFormTest extends SmackTestSuite {
|
|||
|
||||
@Test
|
||||
public void faultySoftwareInfoFormsTest() {
|
||||
DataForm.Builder dataFormbuilder = DataForm.builder(Type.result);
|
||||
DataForm.Builder dataFormbuilder = DataForm.builder(DataForm.Type.result);
|
||||
TextSingleFormField formField = FormField.buildHiddenFormType("faulty_formtype");
|
||||
dataFormbuilder.addField(formField);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
SoftwareInfoForm.getBuilder().setDataForm(dataFormbuilder.build()).build();
|
||||
});
|
||||
|
||||
DataForm.Builder builderWithoutFormType = DataForm.builder(Type.result);
|
||||
DataForm.Builder builderWithoutFormType = DataForm.builder(DataForm.Type.result);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
SoftwareInfoForm.getBuilder().setDataForm(builderWithoutFormType.build()).build();
|
||||
});
|
||||
}
|
||||
|
||||
public static SoftwareInfoForm createSoftwareInfoFormUsingDataForm() throws URISyntaxException {
|
||||
DataForm.Builder dataFormBuilder = DataForm.builder(Type.result);
|
||||
DataForm.Builder dataFormBuilder = DataForm.builder(DataForm.Type.result);
|
||||
TextSingleFormField formField = FormField.buildHiddenFormType(SoftwareInfoForm.FORM_TYPE);
|
||||
dataFormBuilder.addField(formField);
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.jivesoftware.smackx.mediaelement.element.MediaElement;
|
|||
import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
|
||||
|
||||
import org.jivesoftware.util.ConnectionUtils;
|
||||
import org.jivesoftware.util.Protocol;
|
||||
|
@ -70,7 +69,7 @@ public class SoftwareInfoManagerTest {
|
|||
}
|
||||
|
||||
public static SoftwareInfoForm buildSoftwareInfoFromDataForm() throws URISyntaxException {
|
||||
DataForm.Builder dataFormBuilder = DataForm.builder(Type.result);
|
||||
DataForm.Builder dataFormBuilder = DataForm.builder(DataForm.Type.result);
|
||||
dataFormBuilder.addField(FormField.buildHiddenFormType(SoftwareInfoForm.FORM_TYPE));
|
||||
dataFormBuilder.addField(FormField.builder("icon")
|
||||
.addFormFieldChildElement(createMediaElement())
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.FormField.Type;
|
||||
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
|
||||
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout;
|
||||
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Fieldref;
|
||||
|
@ -151,6 +150,6 @@ public class DataFormTest extends SmackTestSuite {
|
|||
public void testFixedField() throws Exception {
|
||||
final String formWithFixedField = "<x xmlns='jabber:x:data' type='form'><instructions>InstructionTest1</instructions><field type='fixed'><value>Fixed field value</value></field></x>";
|
||||
DataForm df = pr.parse(PacketParserUtils.getParserFor(formWithFixedField));
|
||||
assertEquals(Type.fixed, df.getFields().get(0).getType());
|
||||
assertEquals(FormField.Type.fixed, df.getFields().get(0).getType());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.provider.AbstractProvider;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
@ -145,7 +146,7 @@ public class DataValidationTest extends SmackTestSuite {
|
|||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void testRangeFailure(SmackTestUtil.XmlPullParserKind parserKind) throws IOException, XmlPullParserException {
|
||||
assertThrows(NumberFormatException.class,
|
||||
assertThrows(AbstractProvider.NumberFormatParseException.class,
|
||||
() -> SmackTestUtil.parse(TEST_OUTPUT_FAIL, DataValidationProvider.class, parserKind));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue