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

Merge pull request #458 from Flowdalic/errorprone

Bump ErrorProne to 2.5.1 and refactor Providers a bit
This commit is contained in:
Florian Schmaus 2021-01-29 09:45:24 +01:00 committed by GitHub
commit 86b48fbf00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
136 changed files with 574 additions and 551 deletions

View file

@ -12,7 +12,7 @@ buildscript {
plugins { plugins {
id 'ru.vyarus.animalsniffer' version '1.5.0' id 'ru.vyarus.animalsniffer' version '1.5.0'
id 'net.ltgt.errorprone' version '1.1.1' id 'net.ltgt.errorprone' version '1.3.0'
// Use e.g. "gradle <task> taskTree" to show its dependency tree. // Use e.g. "gradle <task> taskTree" to show its dependency tree.
id 'com.dorongold.task-tree' version '1.5' id 'com.dorongold.task-tree' version '1.5'
id 'com.github.kt3k.coveralls' version '2.10.2' id 'com.github.kt3k.coveralls' version '2.10.2'
@ -218,6 +218,8 @@ allprojects {
// Disabled but should be re-enabled at some point // Disabled but should be re-enabled at some point
//'-Xep:InconsistentCapitalization:OFF', //'-Xep:InconsistentCapitalization:OFF',
'-Xep:MixedMutabilityReturnType:OFF', '-Xep:MixedMutabilityReturnType:OFF',
// TODO: Re-enable once Smack's minimum Android SDK level is 26 or higher.
'-Xep:JavaUtilDate:OFF',
] ]
} }
} }
@ -293,7 +295,7 @@ tasks.withType(Javadoc) {
testImplementation 'org.mockito:mockito-inline:3.3.3' testImplementation 'org.mockito:mockito-inline:3.3.3'
testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2' testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
errorprone 'com.google.errorprone:error_prone_core:2.3.4' errorprone 'com.google.errorprone:error_prone_core:2.5.1'
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1') errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2017 Florian Schmaus * Copyright © 2014-2021 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.
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.ping.android;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -113,14 +112,14 @@ public final class ServerPingWithAlarmManager extends Manager {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
LOGGER.fine("Ping Alarm broadcast received"); LOGGER.fine("Ping Alarm broadcast received");
Set<Entry<XMPPConnection, ServerPingWithAlarmManager>> managers; Set<Map.Entry<XMPPConnection, ServerPingWithAlarmManager>> managers;
synchronized (ServerPingWithAlarmManager.class) { synchronized (ServerPingWithAlarmManager.class) {
// Make a copy to avoid ConcurrentModificationException when // Make a copy to avoid ConcurrentModificationException when
// iterating directly over INSTANCES and the Set is modified // iterating directly over INSTANCES and the Set is modified
// concurrently by creating a new ServerPingWithAlarmManager. // concurrently by creating a new ServerPingWithAlarmManager.
managers = new HashSet<>(INSTANCES.entrySet()); managers = new HashSet<>(INSTANCES.entrySet());
} }
for (Entry<XMPPConnection, ServerPingWithAlarmManager> entry : managers) { for (Map.Entry<XMPPConnection, ServerPingWithAlarmManager> entry : managers) {
XMPPConnection connection = entry.getKey(); XMPPConnection connection = entry.getKey();
if (entry.getValue().isEnabled()) { if (entry.getValue().isEnabled()) {
LOGGER.fine("Calling pingServerIfNecessary for connection " LOGGER.fine("Calling pingServerIfNecessary for connection "

View file

@ -249,7 +249,6 @@ public final class SASLAuthentication {
* Notification message saying that SASL authentication was successful. The next step * Notification message saying that SASL authentication was successful. The next step
* would be to bind the resource. * would be to bind the resource.
* @param success result of the authentication. * @param success result of the authentication.
* @throws SmackException if Smack detected an exceptional situation.
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
* @throws NotConnectedException if the XMPP connection is not connected. * @throws NotConnectedException if the XMPP connection is not connected.
* @throws SmackSaslException if a SASL specific error occurred. * @throws SmackSaslException if a SASL specific error occurred.

View file

@ -343,7 +343,7 @@ public final class StanzaCollector implements AutoCloseable {
* *
* @param packet the stanza to process. * @param packet the stanza to process.
*/ */
protected void processStanza(Stanza packet) { void processStanza(Stanza packet) {
if (packetFilter == null || packetFilter.accept(packet)) { if (packetFilter == null || packetFilter.accept(packet)) {
synchronized (this) { synchronized (this) {
if (resultQueue.size() == maxQueueSize) { if (resultQueue.size() == maxQueueSize) {

View file

@ -99,7 +99,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
private boolean featuresReceived; private boolean featuresReceived;
protected boolean streamResumed; private boolean streamResumed;
private GraphVertex<State> currentStateVertex; private GraphVertex<State> currentStateVertex;
@ -264,7 +264,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
walkStateGraph(walkStateGraphContext); walkStateGraph(walkStateGraphContext);
} }
protected WalkStateGraphContext.Builder buildNewWalkTo(Class<? extends StateDescriptor> finalStateClass) { private WalkStateGraphContext.Builder buildNewWalkTo(Class<? extends StateDescriptor> finalStateClass) {
return WalkStateGraphContext.builder(currentStateVertex.getElement().getStateDescriptor().getClass(), finalStateClass); return WalkStateGraphContext.builder(currentStateVertex.getElement().getStateDescriptor().getClass(), finalStateClass);
} }
@ -279,7 +279,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
revertedState.resetState(); revertedState.resetState();
} }
protected void walkStateGraph(WalkStateGraphContext walkStateGraphContext) private void walkStateGraph(WalkStateGraphContext walkStateGraphContext)
throws XMPPException, IOException, SmackException, InterruptedException { throws XMPPException, IOException, SmackException, InterruptedException {
// Save a copy of the current state // Save a copy of the current state
GraphVertex<State> previousStateVertex = currentStateVertex; GraphVertex<State> previousStateVertex = currentStateVertex;
@ -491,7 +491,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
} }
} }
protected SSLSession getSSLSession() { private SSLSession getSSLSession() {
final XmppClientToServerTransport transport = activeTransport; final XmppClientToServerTransport transport = activeTransport;
if (transport == null) { if (transport == null) {
return null; return null;
@ -505,7 +505,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
notifyWaitingThreads(); notifyWaitingThreads();
} }
protected void parseAndProcessElement(String element) { private void parseAndProcessElement(String element) {
try { try {
XmlPullParser parser = PacketParserUtils.getParserFor(element); XmlPullParser parser = PacketParserUtils.getParserFor(element);
@ -556,11 +556,11 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
} }
} }
protected synchronized void prepareToWaitForFeaturesReceived() { private synchronized void prepareToWaitForFeaturesReceived() {
featuresReceived = false; featuresReceived = false;
} }
protected void waitForFeaturesReceived(String waitFor) private void waitForFeaturesReceived(String waitFor)
throws InterruptedException, SmackException, XMPPException { throws InterruptedException, SmackException, XMPPException {
waitForConditionOrThrowConnectionException(() -> featuresReceived, waitFor); waitForConditionOrThrowConnectionException(() -> featuresReceived, waitFor);
} }
@ -571,7 +571,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
return streamOpenAndCloseFactory.createStreamOpen(to, from, id, lang); return streamOpenAndCloseFactory.createStreamOpen(to, from, id, lang);
} }
protected void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException, private void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
SmackException, XMPPException { SmackException, XMPPException {
prepareToWaitForFeaturesReceived(); prepareToWaitForFeaturesReceived();
@ -1028,7 +1028,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
return connectionStateMachineListeners.remove(connectionStateMachineListener); return connectionStateMachineListeners.remove(connectionStateMachineListener);
} }
protected void invokeConnectionStateMachineListener(ConnectionStateEvent connectionStateEvent) { private void invokeConnectionStateMachineListener(ConnectionStateEvent connectionStateEvent) {
if (connectionStateMachineListeners.isEmpty()) { if (connectionStateMachineListeners.isEmpty()) {
return; return;
} }
@ -1056,7 +1056,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
walkStateGraph(walkStateGraphContext); walkStateGraph(walkStateGraphContext);
} }
protected Map<String, Object> getFilterStats() { private Map<String, Object> getFilterStats() {
Collection<XmppInputOutputFilter> filters; Collection<XmppInputOutputFilter> filters;
synchronized (this) { synchronized (this) {
if (inputOutputFilters.isEmpty() && previousInputOutputFilters != null) { if (inputOutputFilters.isEmpty() && previousInputOutputFilters != null) {

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.util.Objects;
* @author Alexander Wenckus * @author Alexander Wenckus
* *
*/ */
@SuppressWarnings("BadImport")
public final class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> { public final class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> {
public static final StanzaFilter GET = new IQTypeFilter(Type.get); public static final StanzaFilter GET = new IQTypeFilter(Type.get);

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.packet.Message.Type;
* @see org.jivesoftware.smack.packet.Message.Type * @see org.jivesoftware.smack.packet.Message.Type
* @author Ward Harold * @author Ward Harold
*/ */
@SuppressWarnings("BadImport")
public final class MessageTypeFilter extends FlexibleStanzaTypeFilter<Message> { public final class MessageTypeFilter extends FlexibleStanzaTypeFilter<Message> {
public static final StanzaFilter NORMAL = new MessageTypeFilter(Type.normal); public static final StanzaFilter NORMAL = new MessageTypeFilter(Type.normal);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2014 Florian Schmaus * Copyright 2014-2021 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.
@ -24,6 +24,7 @@ import org.jivesoftware.smack.util.Objects;
* A filter for Presence types. Returns true only if the stanza is an Presence stanza and it matches the type provided in the * A filter for Presence types. Returns true only if the stanza is an Presence stanza and it matches the type provided in the
* constructor. * constructor.
*/ */
@SuppressWarnings("BadImport")
public final class PresenceTypeFilter extends FlexibleStanzaTypeFilter<Presence> { public final class PresenceTypeFilter extends FlexibleStanzaTypeFilter<Presence> {
public static final PresenceTypeFilter AVAILABLE = new PresenceTypeFilter(Type.available); public static final PresenceTypeFilter AVAILABLE = new PresenceTypeFilter(Type.available);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2015 Florian Schmaus * Copyright 2015-2021 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.
@ -17,7 +17,6 @@
package org.jivesoftware.smack.iqrequest; package org.jivesoftware.smack.iqrequest;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
/** /**
* Convenience class to create IQ requests handlers. * Convenience class to create IQ requests handlers.
@ -26,10 +25,10 @@ public abstract class AbstractIqRequestHandler implements IQRequestHandler {
private final String element; private final String element;
private final String namespace; private final String namespace;
private final Type type; private final IQ.Type type;
private final Mode mode; private final Mode mode;
protected AbstractIqRequestHandler(String element, String namespace, Type type, Mode mode) { protected AbstractIqRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {
switch (type) { switch (type) {
case set: case set:
case get: case get:
@ -52,7 +51,7 @@ public abstract class AbstractIqRequestHandler implements IQRequestHandler {
} }
@Override @Override
public Type getType() { public IQ.Type getType() {
return type; return type;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2019-2020 Florian Schmaus * Copyright 2019-2021 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.
@ -34,12 +34,24 @@ public class SmackParsingException extends Exception {
super(message); super(message);
} }
/**
* Deprecated, do not import.
* @deprecated do not import.
*/
@Deprecated
// TODO: Remove in Smack 4.6.
public static class SmackTextParseException extends SmackParsingException { public static class SmackTextParseException extends SmackParsingException {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* Deprecated, do not use.
* @param parsingException the exception.
* @deprecated do not use, simply throw ParseException.
*/
@Deprecated
public SmackTextParseException(ParseException parsingException) { public SmackTextParseException(ParseException parsingException) {
super(parsingException); super(parsingException);
} }

View file

@ -16,11 +16,15 @@
*/ */
package org.jivesoftware.smack.provider; package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable; import java.lang.reflect.TypeVariable;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Element; import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.xml.XmlPullParserException;
public class AbstractProvider<E extends Element> { public class AbstractProvider<E extends Element> {
@ -55,4 +59,51 @@ public class AbstractProvider<E extends Element> {
public final Class<E> getElementClass() { public final Class<E> getElementClass() {
return elementClass; return elementClass;
} }
public static final class TextParseException extends SmackParsingException {
/**
*
*/
private static final long serialVersionUID = 1L;
private final ParseException parseException;
private TextParseException(ParseException parseException) {
super(parseException);
this.parseException = parseException;
}
public ParseException getParseException() {
return parseException;
}
}
public static final class NumberFormatParseException extends SmackParsingException {
/**
*
*/
private static final long serialVersionUID = 1L;
private NumberFormatParseException(NumberFormatException numberFormatException) {
super(numberFormatException);
}
}
protected interface WrappableParser<E> {
E parse() throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}
protected static <E> E wrapExceptions(WrappableParser<E> parser)
throws XmlPullParserException, IOException, SmackParsingException {
E e;
try {
e = parser.parse();
} catch (ParseException parseException) {
throw new TextParseException(parseException);
} catch (NumberFormatException numberFormatException) {
throw new NumberFormatParseException(numberFormatException);
}
return e;
}
} }

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smack.provider; package org.jivesoftware.smack.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData; import org.jivesoftware.smack.packet.IqData;
@ -50,7 +51,7 @@ public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
final int initialDepth = parser.getDepth(); final int initialDepth = parser.getDepth();
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment); final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
I e = parse(parser, initialDepth, xmlEnvironment); I e = wrapExceptions(() -> parse(parser, initialDepth, xmlEnvironment));
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element // XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth); ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
@ -59,11 +60,12 @@ public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
@Override @Override
public final I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) public final I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException { throws XmlPullParserException, IOException, SmackParsingException, ParseException {
// Old-style IQ parsers do not need IqData. // Old-style IQ parsers do not need IqData.
return parse(parser, initialDepth, xmlEnvironment); return parse(parser, initialDepth, xmlEnvironment);
} }
public abstract I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException; public abstract I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2019 Florian Schmaus * Copyright © 2014-2021 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.
@ -117,7 +117,7 @@ public class IntrospectionProvider{
* @param type the type of the property. * @param type the type of the property.
* @param value the encode String value to decode. * @param value the encode String value to decode.
* @return the String value decoded into the specified type. * @return the String value decoded into the specified type.
* @throws ClassNotFoundException * @throws ClassNotFoundException if the provided class was not found.
*/ */
private static Object decode(Class<?> type, String value) throws ClassNotFoundException { private static Object decode(Class<?> type, String value) throws ClassNotFoundException {
String name = type.getName(); String name = type.getName();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2019 Florian Schmaus * Copyright 2019-2021 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.
@ -17,6 +17,7 @@
package org.jivesoftware.smack.provider; package org.jivesoftware.smack.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData; import org.jivesoftware.smack.packet.IqData;
@ -37,10 +38,12 @@ public abstract class IqProvider<I extends IQ> extends AbstractProvider<I> {
final int initialDepth = parser.getDepth(); final int initialDepth = parser.getDepth();
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment); final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
return parse(parser, initialDepth, iqData, xmlEnvironment); I i = wrapExceptions(() -> parse(parser, initialDepth, iqData, xmlEnvironment));
return i;
} }
public abstract I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) public abstract I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException; throws XmlPullParserException, IOException, SmackParsingException, ParseException;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2019 Florian Schmaus * Copyright © 2014-2021 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.
@ -18,6 +18,7 @@
package org.jivesoftware.smack.provider; package org.jivesoftware.smack.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Element; import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
@ -50,12 +51,13 @@ public abstract class Provider<E extends Element> extends AbstractProvider<E> {
final int initialDepth = parser.getDepth(); final int initialDepth = parser.getDepth();
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment); final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
E e = parse(parser, initialDepth, xmlEnvironment); E e = wrapExceptions(() -> parse(parser, initialDepth, xmlEnvironment));
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element // XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth); ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
return e; return e;
} }
public abstract E parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException; public abstract E parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2014-2020 Florian Schmaus * Copyright 2014-2021 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.
@ -26,7 +26,6 @@ import java.util.Random;
import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.CallbackHandler;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.SmackSaslException; import org.jivesoftware.smack.SmackException.SmackSaslException;
import org.jivesoftware.smack.sasl.SASLMechanism; import org.jivesoftware.smack.sasl.SASLMechanism;
import org.jivesoftware.smack.util.ByteUtils; import org.jivesoftware.smack.util.ByteUtils;
@ -263,6 +262,7 @@ public abstract class ScramMechanism extends SASLMechanism {
} }
/** /**
* Get the channel binding data.
* *
* @return the Channel Binding data. * @return the Channel Binding data.
* @throws SmackSaslException if a SASL specific error occurred. * @throws SmackSaslException if a SASL specific error occurred.
@ -361,7 +361,7 @@ public abstract class ScramMechanism extends SASLMechanism {
* @param key TODO javadoc me please * @param key TODO javadoc me please
* @param str TODO javadoc me please * @param str TODO javadoc me please
* @return the HMAC-SHA1 value of the input. * @return the HMAC-SHA1 value of the input.
* @throws SmackException if Smack detected an exceptional situation. * @throws SmackSaslException if Smack detected an exceptional situation.
*/ */
private byte[] hmac(byte[] key, byte[] str) throws SmackSaslException { private byte[] hmac(byte[] key, byte[] str) throws SmackSaslException {
try { try {

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2015-2020 Florian Schmaus * Copyright © 2015-2021 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 java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
/** /**
@ -251,7 +250,7 @@ public class MultiMap<K, V> {
public MultiMap<K, V> asUnmodifiableMultiMap() { public MultiMap<K, V> asUnmodifiableMultiMap() {
LinkedHashMap<K, List<V>> mapCopy = new LinkedHashMap<>(map.size()); LinkedHashMap<K, List<V>> mapCopy = new LinkedHashMap<>(map.size());
for (Entry<K, List<V>> entry : map.entrySet()) { for (Map.Entry<K, List<V>> entry : map.entrySet()) {
K key = entry.getKey(); K key = entry.getKey();
List<V> values = entry.getValue(); List<V> values = entry.getValue();
@ -266,7 +265,7 @@ public class MultiMap<K, V> {
Map<K, List<V>> clonedMap = new LinkedHashMap<>(map.size()); Map<K, List<V>> clonedMap = new LinkedHashMap<>(map.size());
// TODO: Use Map.forEach() once Smack's minimum Android API is 24 or higher. // TODO: Use Map.forEach() once Smack's minimum Android API is 24 or higher.
for (Entry<K, List<V>> entry : map.entrySet()) { for (Map.Entry<K, List<V>> entry : map.entrySet()) {
List<V> clonedList = CollectionUtil.newListWith(entry.getValue()); List<V> clonedList = CollectionUtil.newListWith(entry.getValue());
clonedMap.put(entry.getKey(), clonedList); clonedMap.put(entry.getKey(), clonedList);
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2019 Florian Schmaus * Copyright © 2014-2021 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.
@ -30,7 +30,6 @@ import org.jivesoftware.smack.datatypes.UInt32;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.RequiredAttributeMissingException; import org.jivesoftware.smack.parsing.SmackParsingException.RequiredAttributeMissingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException; import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException; import org.jivesoftware.smack.xml.XmlPullParserException;
@ -308,30 +307,23 @@ public class ParserUtils {
return s; return s;
} }
public static Date getDateFromOptionalXep82String(String dateString) throws SmackTextParseException { public static Date getDateFromOptionalXep82String(String dateString) throws ParseException {
if (dateString == null) { if (dateString == null) {
return null; return null;
} }
return getDateFromXep82String(dateString); return getDateFromXep82String(dateString);
} }
public static Date getDateFromXep82String(String dateString) throws SmackTextParseException { public static Date getDateFromXep82String(String dateString) throws ParseException {
try { return XmppDateTime.parseXEP0082Date(dateString);
return XmppDateTime.parseXEP0082Date(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
} }
public static Date getDateFromString(String dateString) throws SmackTextParseException { public static Date getDateFromString(String dateString) throws ParseException {
try { return XmppDateTime.parseDate(dateString);
return XmppDateTime.parseDate(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
} }
public static Date getDateFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException { public static Date getDateFromNextText(XmlPullParser parser)
throws XmlPullParserException, IOException, ParseException {
String dateString = parser.nextText(); String dateString = parser.nextText();
return getDateFromString(dateString); return getDateFromString(dateString);
} }

View file

@ -104,6 +104,8 @@ public class Base32 {
for (int j = 0; j < blocklen; j++) for (int j = 0; j < blocklen; j++)
ds.writeByte((byte) (t[j] & 0xFF)); ds.writeByte((byte) (t[j] & 0xFF));
} catch (IOException e) { } catch (IOException e) {
// This should not happen.
throw new AssertionError(e);
} }
} }

View file

@ -53,7 +53,7 @@ public class ConnectionConfigurationTest {
private static final class DummyConnectionConfiguration extends ConnectionConfiguration { private static final class DummyConnectionConfiguration extends ConnectionConfiguration {
protected DummyConnectionConfiguration(Builder builder) { DummyConnectionConfiguration(Builder builder) {
super(builder); super(builder);
} }

View file

@ -20,17 +20,14 @@ import static org.junit.Assert.assertEquals;
import java.util.Map; import java.util.Map;
import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smack.packet.StanzaError.Type;
import org.junit.Test; import org.junit.Test;
public class XMPPErrorTest { public class XMPPErrorTest {
@Test @Test
public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException { public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException {
Map<Condition, Type> conditionToTypeMap = StanzaError.CONDITION_TO_TYPE; Map<StanzaError.Condition, StanzaError.Type> conditionToTypeMap = StanzaError.CONDITION_TO_TYPE;
assertEquals("CONDITION_TO_TYPE map is likely out of sync with Condition enum", assertEquals("CONDITION_TO_TYPE map is likely out of sync with Condition enum",
Condition.values().length, StanzaError.Condition.values().length,
conditionToTypeMap.size()); conditionToTypeMap.size());
} }
} }

View file

@ -0,0 +1,70 @@
/**
*
* Copyright 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.provider;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.junit.jupiter.api.Test;
public class AbstractProviderTest {
private static final ExtensionElementProvider<ExtensionElement> NUMBER_FORMAT_THROWING_PROVIDER = new ExtensionElementProvider<ExtensionElement>() {
@Override
public ExtensionElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
throw new NumberFormatException();
}
};
private static final String MESSAGE = "dummy message";
private static final int VALUE = 14768234;
private static final ExtensionElementProvider<ExtensionElement> PARSE_EXCEPTION_THROWING_PROVIDER = new ExtensionElementProvider<ExtensionElement>() {
@Override
public ExtensionElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
throw new ParseException(MESSAGE, VALUE);
}
};
@Test
public void testWrapsNumberFormatException() throws XmlPullParserException, IOException {
XmlPullParser parser = SmackTestUtil.createDummyParser();
assertThrows(AbstractProvider.NumberFormatParseException.class,
() -> NUMBER_FORMAT_THROWING_PROVIDER.parse(parser));
}
@Test
public void testWrapsParseException() throws XmlPullParserException, IOException {
XmlPullParser parser = SmackTestUtil.createDummyParser();
AbstractProvider.TextParseException testParseException = assertThrows(AbstractProvider.TextParseException.class,
() -> PARSE_EXCEPTION_THROWING_PROVIDER.parse(parser));
ParseException parseException = testParseException.getParseException();
assertEquals(MESSAGE, parseException.getMessage());
assertEquals(VALUE, parseException.getErrorOffset());
}
}

View file

@ -24,7 +24,6 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
@ -58,7 +57,7 @@ public class ThreadedDummyConnection extends DummyConnection {
replyPacket.setStanzaId(packet.getStanzaId()); replyPacket.setStanzaId(packet.getStanzaId());
replyPacket.setTo(packet.getFrom()); replyPacket.setTo(packet.getFrom());
if (replyPacket.getType() == null) { if (replyPacket.getType() == null) {
replyPacket.setType(Type.result); replyPacket.setType(IQ.Type.result);
} }
new ProcessQueue(replyQ).start(); new ProcessQueue(replyQ).start();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2019 Florian Schmaus * Copyright 2019-2021 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.
@ -30,6 +30,7 @@ import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.Element; import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.Provider; import org.jivesoftware.smack.provider.Provider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException; import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParserFactory; import org.jivesoftware.smack.xml.XmlPullParserFactory;
@ -125,6 +126,11 @@ public class SmackTestUtil {
return parser; return parser;
} }
public static XmlPullParser createDummyParser() throws XmlPullParserException, IOException {
String dummyElement = "<empty-element/>";
return PacketParserUtils.getParserFor(dummyElement);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static <E extends Element, P extends Provider<E>> P providerClassToProvider(Class<P> providerClass) { private static <E extends Element, P extends Provider<E>> P providerClassToProvider(Class<P> providerClass) {
P provider; P provider;

View file

@ -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"); * 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.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.carbons.provider; package org.jivesoftware.smackx.carbons.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
@ -40,7 +41,8 @@ import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtension> { public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtension> {
@Override @Override
public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Direction dir = Direction.valueOf(parser.getName()); Direction dir = Direction.valueOf(parser.getName());
Forwarded<Message> fwd = null; Forwarded<Message> fwd = null;

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2019 Florian Schmaus * Copyright 2019-2021 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.
@ -31,7 +31,6 @@ import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError; import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.packet.StanzaError.Condition; import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smack.packet.StanzaError.Type;
import org.jivesoftware.smack.util.RandomUtil; import org.jivesoftware.smack.util.RandomUtil;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -89,7 +88,7 @@ public final class DnsOverXmppManager extends Manager {
response = resolver.resolve(query); response = resolver.resolve(query);
} catch (IOException exception) { } catch (IOException exception) {
StanzaError errorBuilder = StanzaError.getBuilder() StanzaError errorBuilder = StanzaError.getBuilder()
.setType(Type.CANCEL) .setType(StanzaError.Type.CANCEL)
.setCondition(Condition.internal_server_error) .setCondition(Condition.internal_server_error)
.setDescriptiveEnText("Exception while resolving your DNS query", exception) .setDescriptiveEnText("Exception while resolving your DNS query", exception)
.build() .build()

View file

@ -27,7 +27,6 @@ import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.logging.Level; import java.util.logging.Level;
@ -437,7 +436,7 @@ public final class HttpFileUploadManager extends Manager {
urlConnection.setDoOutput(true); urlConnection.setDoOutput(true);
urlConnection.setFixedLengthStreamingMode(fileSize); urlConnection.setFixedLengthStreamingMode(fileSize);
urlConnection.setRequestProperty("Content-Type", "application/octet-stream"); urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
for (Entry<String, String> header : slot.getHeaders().entrySet()) { for (Map.Entry<String, String> header : slot.getHeaders().entrySet()) {
urlConnection.setRequestProperty(header.getKey(), header.getValue()); urlConnection.setRequestProperty(header.getKey(), header.getValue());
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2021 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.Manager;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.iot.provisioning.IoTProvisioningManager; import org.jivesoftware.smackx.iot.provisioning.IoTProvisioningManager;
@ -70,7 +69,7 @@ public abstract class IoTManager extends Manager {
protected abstract class IoTIqRequestHandler extends AbstractIqRequestHandler { protected abstract class IoTIqRequestHandler extends AbstractIqRequestHandler {
protected IoTIqRequestHandler(String element, String namespace, Type type, Mode mode) { protected IoTIqRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {
super(element, namespace, type, mode); super(element, namespace, type, mode);
} }

View file

@ -23,7 +23,6 @@ import java.util.Iterator;
import org.jivesoftware.smackx.iot.control.ThingControlRequest; import org.jivesoftware.smackx.iot.control.ThingControlRequest;
import org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutRequest; import org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutRequest;
import org.jivesoftware.smackx.iot.discovery.element.Tag; import org.jivesoftware.smackx.iot.discovery.element.Tag;
import org.jivesoftware.smackx.iot.discovery.element.Tag.Type;
import org.jivesoftware.smackx.iot.element.NodeInfo; import org.jivesoftware.smackx.iot.element.NodeInfo;
public final class Thing { public final class Thing {
@ -112,35 +111,35 @@ public final class Thing {
public Builder setSerialNumber(String sn) { public Builder setSerialNumber(String sn) {
final String name = "SN"; final String name = "SN";
Tag tag = new Tag(name, Type.str, sn); Tag tag = new Tag(name, Tag.Type.str, sn);
metaTags.put(name, tag); metaTags.put(name, tag);
return this; return this;
} }
public Builder setKey(String key) { public Builder setKey(String key) {
final String name = "KEY"; final String name = "KEY";
Tag tag = new Tag(name, Type.str, key); Tag tag = new Tag(name, Tag.Type.str, key);
metaTags.put(name, tag); metaTags.put(name, tag);
return this; return this;
} }
public Builder setManufacturer(String manufacturer) { public Builder setManufacturer(String manufacturer) {
final String name = "MAN"; final String name = "MAN";
Tag tag = new Tag(name, Type.str, manufacturer); Tag tag = new Tag(name, Tag.Type.str, manufacturer);
metaTags.put(name, tag); metaTags.put(name, tag);
return this; return this;
} }
public Builder setModel(String model) { public Builder setModel(String model) {
final String name = "MODEL"; final String name = "MODEL";
Tag tag = new Tag(name, Type.str, model); Tag tag = new Tag(name, Tag.Type.str, model);
metaTags.put(name, tag); metaTags.put(name, tag);
return this; return this;
} }
public Builder setVersion(String version) { public Builder setVersion(String version) {
final String name = "V"; final String name = "V";
Tag tag = new Tag(name, Type.num, version); Tag tag = new Tag(name, Tag.Type.num, version);
metaTags.put(name, tag); metaTags.put(name, tag);
return this; return this;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2016-2019 Florian Schmaus * Copyright © 2016-2021 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.
@ -24,8 +24,6 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.packet.XmlEnvironment; 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.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
@ -45,7 +43,8 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
private static final Logger LOGGER = Logger.getLogger(IoTFieldsExtensionProvider.class.getName()); private static final Logger LOGGER = Logger.getLogger(IoTFieldsExtensionProvider.class.getName());
@Override @Override
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackTextParseException { public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws IOException, XmlPullParserException, ParseException {
int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number"); int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number");
boolean done = ParserUtils.getBooleanAttribute(parser, "done", false); boolean done = ParserUtils.getBooleanAttribute(parser, "done", false);
List<NodeElement> nodes = new ArrayList<>(); List<NodeElement> nodes = new ArrayList<>();
@ -74,7 +73,7 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
return new IoTFieldsExtension(seqNr, done, nodes); return new IoTFieldsExtension(seqNr, done, nodes);
} }
public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException { public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
final int initialDepth = parser.getDepth(); final int initialDepth = parser.getDepth();
final NodeInfo nodeInfo = NodeInfoParser.parse(parser); final NodeInfo nodeInfo = NodeInfoParser.parse(parser);
List<TimestampElement> timestampElements = new ArrayList<>(); List<TimestampElement> timestampElements = new ArrayList<>();
@ -103,15 +102,11 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
return new NodeElement(nodeInfo, timestampElements); return new NodeElement(nodeInfo, timestampElements);
} }
public TimestampElement parseTimestampElement(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException { public TimestampElement parseTimestampElement(XmlPullParser parser)
throws XmlPullParserException, IOException, ParseException {
final int initialDepth = parser.getDepth(); final int initialDepth = parser.getDepth();
final String dateString = parser.getAttributeValue(null, "value"); final String dateString = parser.getAttributeValue(null, "value");
Date date; Date date = XmppDateTime.parseDate(dateString);
try {
date = XmppDateTime.parseDate(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
List<IoTDataField> fields = new ArrayList<>(); List<IoTDataField> fields = new ArrayList<>();
outerloop: while (true) { outerloop: while (true) {
final XmlPullParser.Event eventType = parser.next(); final XmlPullParser.Event eventType = parser.next();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016-2019 Florian Schmaus * Copyright 2016-2021 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.
@ -39,7 +39,6 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
@ -201,7 +200,7 @@ public final class IoTProvisioningManager extends Manager {
}, FRIEND_MESSAGE); }, FRIEND_MESSAGE);
connection.registerIQRequestHandler( connection.registerIQRequestHandler(
new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, Type.set, Mode.async) { new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, IQ.Type.set, Mode.async) {
@Override @Override
public IQ handleIQRequest(IQ iqRequest) { public IQ handleIQRequest(IQ iqRequest) {
if (!isFromProvisioningService(iqRequest, true)) { if (!isFromProvisioningService(iqRequest, true)) {

View file

@ -44,7 +44,7 @@ public class JingleFileTransferProvider
extends JingleContentDescriptionProvider<JingleFileTransfer> { extends JingleContentDescriptionProvider<JingleFileTransfer> {
@Override @Override
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { public JingleFileTransfer parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException, ParseException {
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>(); ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder(); JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder();
@ -59,11 +59,7 @@ public class JingleFileTransferProvider
elementName = parser.getName(); elementName = parser.getName();
switch (elementName) { switch (elementName) {
case JingleFileTransferChild.ELEM_DATE: case JingleFileTransferChild.ELEM_DATE:
try {
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText())); builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
break; break;
case JingleFileTransferChild.ELEM_DESC: case JingleFileTransferChild.ELEM_DESC:

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Fernando Ramirez, 2020 Florian Schmaus * Copyright 2016 Fernando Ramirez, 2020-2021 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.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.mam.provider; package org.jivesoftware.smackx.mam.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
@ -40,7 +41,8 @@ import org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension;
public class MamResultProvider extends ExtensionElementProvider<MamResultExtension> { public class MamResultProvider extends ExtensionElementProvider<MamResultExtension> {
@Override @Override
public MamResultExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { public MamResultExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Forwarded<Message> forwarded = null; Forwarded<Message> forwarded = null;
String queryId = parser.getAttributeValue("", "queryid"); String queryId = parser.getAttributeValue("", "queryid");
String id = parser.getAttributeValue("", "id"); String id = parser.getAttributeValue("", "id");

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.message_retraction.provider; package org.jivesoftware.smackx.message_retraction.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.Date; import java.util.Date;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
@ -34,7 +35,7 @@ public class RetractedElementProvider extends ExtensionElementProvider<Retracted
@Override @Override
public RetractedElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) public RetractedElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException { throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Date date = ParserUtils.getDateFromXep82String(parser.getAttributeValue("", RetractedElement.ATTR_STAMP)); Date date = ParserUtils.getDateFromXep82String(parser.getAttributeValue("", RetractedElement.ATTR_STAMP));
OriginIdElement originIdElement = null; OriginIdElement originIdElement = null;

View file

@ -31,7 +31,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.IQReplyFilter; import org.jivesoftware.smack.filter.IQReplyFilter;
import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverItems; import org.jivesoftware.smackx.disco.packet.DiscoverItems;
@ -228,7 +227,7 @@ public final class MultiUserChatLightManager extends Manager {
private MUCLightBlockingIQ getBlockingList(DomainBareJid mucLightService) private MUCLightBlockingIQ getBlockingList(DomainBareJid mucLightService)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null);
mucLightBlockingIQ.setType(Type.get); mucLightBlockingIQ.setType(IQ.Type.get);
mucLightBlockingIQ.setTo(mucLightService); mucLightBlockingIQ.setTo(mucLightService);
StanzaFilter responseFilter = new IQReplyFilter(mucLightBlockingIQ, connection()); StanzaFilter responseFilter = new IQReplyFilter(mucLightBlockingIQ, connection());
@ -278,7 +277,7 @@ public final class MultiUserChatLightManager extends Manager {
private void sendBlockRooms(DomainBareJid mucLightService, HashMap<Jid, Boolean> rooms) private void sendBlockRooms(DomainBareJid mucLightService, HashMap<Jid, Boolean> rooms)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService); mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow(); connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
} }
@ -322,7 +321,7 @@ public final class MultiUserChatLightManager extends Manager {
private void sendBlockUsers(DomainBareJid mucLightService, HashMap<Jid, Boolean> users) private void sendBlockUsers(DomainBareJid mucLightService, HashMap<Jid, Boolean> users)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService); mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow(); connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
} }
@ -366,7 +365,7 @@ public final class MultiUserChatLightManager extends Manager {
private void sendUnblockRooms(DomainBareJid mucLightService, HashMap<Jid, Boolean> rooms) private void sendUnblockRooms(DomainBareJid mucLightService, HashMap<Jid, Boolean> rooms)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService); mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow(); connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
} }
@ -410,7 +409,7 @@ public final class MultiUserChatLightManager extends Manager {
private void sendUnblockUsers(DomainBareJid mucLightService, HashMap<Jid, Boolean> users) private void sendUnblockUsers(DomainBareJid mucLightService, HashMap<Jid, Boolean> users)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService); mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow(); connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
} }

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.muclight.provider;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import org.jivesoftware.smack.packet.IQ.Type; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
@ -65,7 +65,7 @@ public class MUCLightBlockingIQProvider extends IQProvider<MUCLightBlockingIQ> {
} }
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
mucLightBlockingIQ.setType(Type.result); mucLightBlockingIQ.setType(IQ.Type.result);
return mucLightBlockingIQ; return mucLightBlockingIQ;
} }

View file

@ -28,7 +28,6 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.push_notifications.element.DisablePushNotificationsIQ; import org.jivesoftware.smackx.push_notifications.element.DisablePushNotificationsIQ;
@ -166,7 +165,7 @@ public final class PushNotificationsManager extends Manager {
throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException { throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
final XMPPConnection connection = connection(); final XMPPConnection connection = connection();
IQ responseIQ = connection.createStanzaCollectorAndSend(iq).nextResultOrThrow(); IQ responseIQ = connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
return responseIQ.getType() != Type.error; return responseIQ.getType() != IQ.Type.error;
} }
} }

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.stanza_content_encryption.provider; package org.jivesoftware.smackx.stanza_content_encryption.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.Date; import java.util.Date;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
@ -42,7 +43,7 @@ public class ContentElementProvider extends ExtensionElementProvider<ContentElem
@Override @Override
public ContentElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) public ContentElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException { throws XmlPullParserException, IOException, ParseException, SmackParsingException {
ContentElement.Builder builder = ContentElement.builder(); ContentElement.Builder builder = ContentElement.builder();
while (true) { while (true) {
@ -117,7 +118,7 @@ public class ContentElementProvider extends ExtensionElementProvider<ContentElem
} }
private static void parseTimestampAffix(XmlPullParser parser, ContentElement.Builder builder) private static void parseTimestampAffix(XmlPullParser parser, ContentElement.Builder builder)
throws SmackParsingException.SmackTextParseException { throws ParseException {
Date timestamp = ParserUtils.getDateFromXep82String( Date timestamp = ParserUtils.getDateFromXep82String(
parser.getAttributeValue("", TimestampAffixElement.ATTR_STAMP)); parser.getAttributeValue("", TimestampAffixElement.ATTR_STAMP));
builder.setTimestamp(timestamp); builder.setTimestamp(timestamp);

View file

@ -22,7 +22,6 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
@ -68,7 +67,7 @@ public class MamFinProviderTest extends MamTest {
IQ iq = PacketParserUtils.parseStanza(IQ_LIMITED_RESULTS_EXAMPLE); IQ iq = PacketParserUtils.parseStanza(IQ_LIMITED_RESULTS_EXAMPLE);
MamFinIQ mamFinIQ = (MamFinIQ) iq; MamFinIQ mamFinIQ = (MamFinIQ) iq;
assertEquals(mamFinIQ.getType(), Type.result); assertEquals(mamFinIQ.getType(), IQ.Type.result);
assertTrue(mamFinIQ.isComplete()); assertTrue(mamFinIQ.isComplete());
assertEquals(mamFinIQ.getRSMSet().getCount(), 16); assertEquals(mamFinIQ.getRSMSet().getCount(), 16);

View file

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.mam.element.MamQueryIQ; import org.jivesoftware.smackx.mam.element.MamQueryIQ;
@ -57,7 +56,7 @@ public class MamQueryIQProviderTest {
IQ iq1 = PacketParserUtils.parseStanza(exampleMamQueryIQ1); IQ iq1 = PacketParserUtils.parseStanza(exampleMamQueryIQ1);
MamQueryIQ mamQueryIQ1 = (MamQueryIQ) iq1; MamQueryIQ mamQueryIQ1 = (MamQueryIQ) iq1;
assertEquals(mamQueryIQ1.getType(), Type.set); assertEquals(mamQueryIQ1.getType(), IQ.Type.set);
assertEquals(mamQueryIQ1.getQueryId(), "test"); assertEquals(mamQueryIQ1.getQueryId(), "test");
DataForm dataForm1 = (DataForm) mamQueryIQ1.getExtension(DataForm.NAMESPACE); DataForm dataForm1 = (DataForm) mamQueryIQ1.getExtension(DataForm.NAMESPACE);
@ -73,7 +72,7 @@ public class MamQueryIQProviderTest {
IQ iq2 = PacketParserUtils.parseStanza(exampleMamQueryIQ2); IQ iq2 = PacketParserUtils.parseStanza(exampleMamQueryIQ2);
MamQueryIQ mamQueryIQ2 = (MamQueryIQ) iq2; MamQueryIQ mamQueryIQ2 = (MamQueryIQ) iq2;
assertEquals(mamQueryIQ2.getType(), Type.result); assertEquals(mamQueryIQ2.getType(), IQ.Type.result);
assertNull(mamQueryIQ2.getQueryId()); assertNull(mamQueryIQ2.getQueryId());
DataForm dataForm2 = (DataForm) mamQueryIQ2.getExtension(DataForm.NAMESPACE); DataForm dataForm2 = (DataForm) mamQueryIQ2.getExtension(DataForm.NAMESPACE);

View file

@ -24,7 +24,6 @@ import java.util.TimeZone;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.StanzaBuilder; import org.jivesoftware.smack.packet.StanzaBuilder;
import org.jivesoftware.smack.packet.StreamOpen; import org.jivesoftware.smack.packet.StreamOpen;
@ -75,7 +74,7 @@ public class QueryArchiveTest extends MamTest {
DelayInformation delay = new DelayInformation(date); DelayInformation delay = new DelayInformation(date);
Message forwardedMessage = StanzaBuilder.buildMessage("162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2") Message forwardedMessage = StanzaBuilder.buildMessage("162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2")
.from(JidCreate.from("coven@chat.shakespeare.lit/firstwitch")) .from(JidCreate.from("coven@chat.shakespeare.lit/firstwitch"))
.ofType(Type.chat) .ofType(Message.Type.chat)
.setBody("Thrice the brinded cat hath mew.") .setBody("Thrice the brinded cat hath mew.")
.build(); .build();
@ -93,7 +92,7 @@ public class QueryArchiveTest extends MamTest {
Message resultMessage = mamResultExtension.getForwarded().getForwardedStanza(); Message resultMessage = mamResultExtension.getForwarded().getForwardedStanza();
assertEquals(resultMessage.getFrom(), JidCreate.from("coven@chat.shakespeare.lit/firstwitch")); assertEquals(resultMessage.getFrom(), JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
assertEquals(resultMessage.getStanzaId(), "162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2"); assertEquals(resultMessage.getStanzaId(), "162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
assertEquals(resultMessage.getType(), Type.chat); assertEquals(resultMessage.getType(), Message.Type.chat);
assertEquals(resultMessage.getBody(), "Thrice the brinded cat hath mew."); assertEquals(resultMessage.getBody(), "Thrice the brinded cat hath mew.");
} }

View file

@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap; import java.util.HashMap;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.StreamOpen; import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
@ -59,7 +58,7 @@ public class MUCLightBlockingTest {
@Test @Test
public void checkGetBlockingListIQ() throws Exception { public void checkGetBlockingListIQ() throws Exception {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null);
mucLightBlockingIQ.setType(Type.get); mucLightBlockingIQ.setType(IQ.Type.get);
mucLightBlockingIQ.setStanzaId("getblock1"); mucLightBlockingIQ.setStanzaId("getblock1");
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit")); mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
@ -86,7 +85,7 @@ public class MUCLightBlockingTest {
rooms.put(JidCreate.from("chapel@shakespeare.lit"), false); rooms.put(JidCreate.from("chapel@shakespeare.lit"), false);
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit")); mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
mucLightBlockingIQ.setStanzaId("block1"); mucLightBlockingIQ.setStanzaId("block1");
@ -100,7 +99,7 @@ public class MUCLightBlockingTest {
users.put(JidCreate.from("hag66@shakespeare.lit"), false); users.put(JidCreate.from("hag66@shakespeare.lit"), false);
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit")); mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
mucLightBlockingIQ.setStanzaId("block2"); mucLightBlockingIQ.setStanzaId("block2");
@ -116,7 +115,7 @@ public class MUCLightBlockingTest {
rooms.put(JidCreate.from("coven@muclight.shakespeare.lit"), true); rooms.put(JidCreate.from("coven@muclight.shakespeare.lit"), true);
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit")); mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
mucLightBlockingIQ.setStanzaId("unblock1"); mucLightBlockingIQ.setStanzaId("unblock1");

View file

@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.StandardExtensionElement; import org.jivesoftware.smack.packet.StandardExtensionElement;
@ -40,7 +41,7 @@ import org.jxmpp.jid.impl.JidCreate;
public class ContentElementProviderTest { public class ContentElementProviderTest {
@Test @Test
public void testParsing() throws XmlPullParserException, IOException, SmackParsingException { public void testParsing() throws XmlPullParserException, IOException, SmackParsingException, ParseException {
String xml = "" + String xml = "" +
"<content xmlns='urn:xmpp:sce:0'>\n" + "<content xmlns='urn:xmpp:sce:0'>\n" +
" <payload>\n" + " <payload>\n" +

View file

@ -26,7 +26,6 @@ import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException; import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.address.packet.MultipleAddresses; import org.jivesoftware.smackx.address.packet.MultipleAddresses;
import org.jivesoftware.smackx.address.packet.MultipleAddresses.Type;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
@ -50,7 +49,7 @@ public class MultipleAddressesProvider extends ExtensionElementProvider<Multiple
switch (name) { switch (name) {
case MultipleAddresses.Address.ELEMENT: case MultipleAddresses.Address.ELEMENT:
String typeString = parser.getAttributeValue("", "type"); String typeString = parser.getAttributeValue("", "type");
Type type = Type.valueOf(typeString); MultipleAddresses.Type type = MultipleAddresses.Type.valueOf(typeString);
Jid jid = ParserUtils.getJidAttribute(parser, "jid"); Jid jid = ParserUtils.getJidAttribute(parser, "jid");
String node = parser.getAttributeValue("", "node"); String node = parser.getAttributeValue("", "node");
String desc = parser.getAttributeValue("", "desc"); String desc = parser.getAttributeValue("", "desc");

View file

@ -35,7 +35,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ; 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.BlockContactsIQ;
import org.jivesoftware.smackx.blocking.element.BlockListIQ; import org.jivesoftware.smackx.blocking.element.BlockListIQ;
@ -97,7 +96,7 @@ public final class BlockingCommandManager extends Manager {
// block IQ handler // block IQ handler
connection.registerIQRequestHandler( connection.registerIQRequestHandler(
new AbstractIqRequestHandler(BlockContactsIQ.ELEMENT, BlockContactsIQ.NAMESPACE, Type.set, Mode.sync) { new AbstractIqRequestHandler(BlockContactsIQ.ELEMENT, BlockContactsIQ.NAMESPACE, IQ.Type.set, Mode.sync) {
@Override @Override
public IQ handleIQRequest(IQ iqRequest) { public IQ handleIQRequest(IQ iqRequest) {
BlockContactsIQ blockContactIQ = (BlockContactsIQ) iqRequest; BlockContactsIQ blockContactIQ = (BlockContactsIQ) iqRequest;
@ -119,7 +118,7 @@ public final class BlockingCommandManager extends Manager {
// unblock IQ handler // unblock IQ handler
connection.registerIQRequestHandler(new AbstractIqRequestHandler(UnblockContactsIQ.ELEMENT, connection.registerIQRequestHandler(new AbstractIqRequestHandler(UnblockContactsIQ.ELEMENT,
UnblockContactsIQ.NAMESPACE, Type.set, Mode.sync) { UnblockContactsIQ.NAMESPACE, IQ.Type.set, Mode.sync) {
@Override @Override
public IQ handleIQRequest(IQ iqRequest) { public IQ handleIQRequest(IQ iqRequest) {
UnblockContactsIQ unblockContactIQ = (UnblockContactsIQ) iqRequest; UnblockContactsIQ unblockContactIQ = (UnblockContactsIQ) iqRequest;

View file

@ -20,7 +20,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -70,7 +70,7 @@ public class BlockListIQProvider extends IQProvider<BlockListIQ> {
} }
BlockListIQ blockListIQ = new BlockListIQ(jids); BlockListIQ blockListIQ = new BlockListIQ(jids);
blockListIQ.setType(Type.result); blockListIQ.setType(IQ.Type.result);
return blockListIQ; return blockListIQ;
} }

View file

@ -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"); * 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.
@ -33,7 +33,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.SHA1; import org.jivesoftware.smack.util.SHA1;
import org.jivesoftware.smackx.bob.element.BoBIQ; import org.jivesoftware.smackx.bob.element.BoBIQ;
@ -91,7 +90,7 @@ public final class BoBManager extends Manager {
serviceDiscoveryManager.addFeature(NAMESPACE); serviceDiscoveryManager.addFeature(NAMESPACE);
connection.registerIQRequestHandler( connection.registerIQRequestHandler(
new AbstractIqRequestHandler(BoBIQ.ELEMENT, BoBIQ.NAMESPACE, Type.get, Mode.async) { new AbstractIqRequestHandler(BoBIQ.ELEMENT, BoBIQ.NAMESPACE, IQ.Type.get, Mode.async) {
@Override @Override
public IQ handleIQRequest(IQ iqRequest) { public IQ handleIQRequest(IQ iqRequest) {
BoBIQ bobIQRequest = (BoBIQ) iqRequest; BoBIQ bobIQRequest = (BoBIQ) iqRequest;
@ -105,7 +104,7 @@ public final class BoBManager extends Manager {
BoBData bobData = bobInfo.getData(); BoBData bobData = bobInfo.getData();
BoBIQ responseBoBIQ = new BoBIQ(contentId, bobData); BoBIQ responseBoBIQ = new BoBIQ(contentId, bobData);
responseBoBIQ.setType(Type.result); responseBoBIQ.setType(IQ.Type.result);
responseBoBIQ.setTo(bobIQRequest.getFrom()); responseBoBIQ.setTo(bobIQRequest.getFrom());
return responseBoBIQ; return responseBoBIQ;
} }
@ -146,7 +145,7 @@ public final class BoBManager extends Manager {
} }
BoBIQ requestBoBIQ = new BoBIQ(bobHash); BoBIQ requestBoBIQ = new BoBIQ(bobHash);
requestBoBIQ.setType(Type.get); requestBoBIQ.setType(IQ.Type.get);
requestBoBIQ.setTo(to); requestBoBIQ.setTo(to);
XMPPConnection connection = getAuthenticatedConnectionOrThrow(); XMPPConnection connection = getAuthenticatedConnectionOrThrow();

View file

@ -441,7 +441,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* @throws NotConnectedException if the XMPP connection is not connected. * @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted. * @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); IQ error = IQ.createErrorResponse(request, StanzaError.Condition.not_acceptable);
connection().sendStanza(error); 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 NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted. * @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); IQ error = IQ.createErrorResponse(request, StanzaError.Condition.item_not_found);
connection().sendStanza(error); connection().sendStanza(error);
} }
@ -476,7 +476,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* *
* @return the XMPP connection * @return the XMPP connection
*/ */
protected XMPPConnection getConnection() { XMPPConnection getConnection() {
return connection(); return connection();
} }
@ -487,7 +487,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* @param initiator the initiator's JID * @param initiator the initiator's JID
* @return the listener * @return the listener
*/ */
protected BytestreamListener getUserListener(Jid initiator) { BytestreamListener getUserListener(Jid initiator) {
return this.userListeners.get(initiator); return this.userListeners.get(initiator);
} }
@ -497,7 +497,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* *
* @return list of listeners * @return list of listeners
*/ */
protected List<BytestreamListener> getAllRequestListeners() { List<BytestreamListener> getAllRequestListeners() {
return this.allRequestListeners; return this.allRequestListeners;
} }
@ -506,7 +506,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* *
* @return the sessions map * @return the sessions map
*/ */
protected Map<String, InBandBytestreamSession> getSessions() { Map<String, InBandBytestreamSession> getSessions() {
return sessions; return sessions;
} }
@ -515,7 +515,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* *
* @return list of session IDs * @return list of session IDs
*/ */
protected List<String> getIgnoredBytestreamRequests() { List<String> getIgnoredBytestreamRequests() {
return ignoredBytestreamRequests; return ignoredBytestreamRequests;
} }

View file

@ -52,7 +52,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
* *
* @param manager the SOCKS5 Bytestream manager * @param manager the SOCKS5 Bytestream manager
*/ */
protected InitiationListener(Socks5BytestreamManager manager) { InitiationListener(Socks5BytestreamManager manager) {
super(Bytestream.ELEMENT, Bytestream.NAMESPACE, IQ.Type.set, Mode.async); super(Bytestream.ELEMENT, Bytestream.NAMESPACE, IQ.Type.set, Mode.async);
this.manager = manager; this.manager = manager;
initiationListenerExecutor = Executors.newCachedThreadPool(); initiationListenerExecutor = Executors.newCachedThreadPool();
@ -117,7 +117,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
/** /**
* Shuts down the listeners executor service. * Shuts down the listeners executor service.
*/ */
protected void shutdown() { void shutdown() {
this.initiationListenerExecutor.shutdownNow(); this.initiationListenerExecutor.shutdownNow();
} }

View file

@ -717,7 +717,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* @throws NotConnectedException if the XMPP connection is not connected. * @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted. * @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(); StanzaError xmppError = StanzaError.getBuilder(StanzaError.Condition.not_acceptable).build();
IQ errorIQ = IQ.createErrorResponse(packet, xmppError); IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
connection().sendStanza(errorIQ); connection().sendStanza(errorIQ);
@ -760,7 +760,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* *
* @return the XMPP connection * @return the XMPP connection
*/ */
protected XMPPConnection getConnection() { XMPPConnection getConnection() {
return connection(); return connection();
} }
@ -771,7 +771,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* @param initiator the initiator's JID * @param initiator the initiator's JID
* @return the listener * @return the listener
*/ */
protected BytestreamListener getUserListener(Jid initiator) { BytestreamListener getUserListener(Jid initiator) {
return this.userListeners.get(initiator); return this.userListeners.get(initiator);
} }
@ -781,7 +781,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* *
* @return list of listeners * @return list of listeners
*/ */
protected List<BytestreamListener> getAllRequestListeners() { List<BytestreamListener> getAllRequestListeners() {
return this.allRequestListeners; return this.allRequestListeners;
} }
@ -790,7 +790,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* *
* @return list of session IDs * @return list of session IDs
*/ */
protected List<String> getIgnoredBytestreamRequests() { List<String> getIgnoredBytestreamRequests() {
return ignoredBytestreamRequests; return ignoredBytestreamRequests;
} }

View file

@ -311,7 +311,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
* Cancels the SOCKS5 Bytestream request by sending an error to the initiator and building a * Cancels the SOCKS5 Bytestream request by sending an error to the initiator and building a
* XMPP exception. * 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 NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
* @throws CouldNotConnectToAnyProvidedSocks5Host as expected result. * @throws CouldNotConnectToAnyProvidedSocks5Host as expected result.

View file

@ -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"); * 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.
@ -96,7 +96,7 @@ public final class EntityCapsManager extends Manager {
private static String DEFAULT_ENTITY_NODE = SmackConfiguration.SMACK_URL_STRING; private static String DEFAULT_ENTITY_NODE = SmackConfiguration.SMACK_URL_STRING;
protected static EntityCapsPersistentCache persistentCache; static EntityCapsPersistentCache persistentCache;
private static boolean autoEnableEntityCaps = true; private static boolean autoEnableEntityCaps = true;
@ -595,7 +595,7 @@ public final class EntityCapsManager extends Manager {
return true; return true;
} }
protected static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo) { static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo) {
return generateVerificationString(discoverInfo, null); 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 * @return The generated verification String or null if the hash is not
* supported * supported
*/ */
protected static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo, String hash) { static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo, String hash) {
if (hash == null) { if (hash == null) {
hash = DEFAULT_HASH; hash = DEFAULT_HASH;
} }

View file

@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -520,8 +519,8 @@ public final class AdHocCommandManager extends Manager {
private void sessionSweeper() { private void sessionSweeper() {
final long currentTime = System.currentTimeMillis(); final long currentTime = System.currentTimeMillis();
synchronized (this) { synchronized (this) {
for (Iterator<Entry<String, LocalCommand>> it = executingCommands.entrySet().iterator(); it.hasNext();) { for (Iterator<Map.Entry<String, LocalCommand>> it = executingCommands.entrySet().iterator(); it.hasNext();) {
Entry<String, LocalCommand> entry = it.next(); Map.Entry<String, LocalCommand> entry = it.next();
LocalCommand command = entry.getValue(); LocalCommand command = entry.getValue();
long creationStamp = command.getCreationDate(); long creationStamp = command.getCreationDate();
@ -561,7 +560,6 @@ public final class AdHocCommandManager extends Manager {
* *
* @param response the response to send. * @param response the response to send.
* @param condition the condition of the error. * @param condition the condition of the error.
* @throws NotConnectedException if the XMPP connection is not connected.
*/ */
private static IQ respondError(AdHocCommandData response, private static IQ respondError(AdHocCommandData response,
StanzaError.Condition condition) { StanzaError.Condition condition) {
@ -574,7 +572,6 @@ public final class AdHocCommandManager extends Manager {
* @param response the response to send. * @param response the response to send.
* @param condition the condition of the error. * @param condition the condition of the error.
* @param specificCondition the adhoc command error condition. * @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, private static IQ respondError(AdHocCommandData response, StanzaError.Condition condition,
AdHocCommand.SpecificErrorCondition specificCondition) { AdHocCommand.SpecificErrorCondition specificCondition) {
@ -589,7 +586,6 @@ public final class AdHocCommandManager extends Manager {
* *
* @param response the response to send. * @param response the response to send.
* @param error the error 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) { private static IQ respondError(AdHocCommandData response, StanzaError error) {
response.setType(IQ.Type.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 NoSuchMethodException if no such method is declared
* @throws InvocationTargetException if a reflection-based method or constructor invocation threw. * @throws InvocationTargetException if a reflection-based method or constructor invocation threw.
* @throws IllegalArgumentException if an illegal argument was given. * @throws IllegalArgumentException if an illegal argument was given.
* @throws IllegalAccessException * @throws IllegalAccessException in case of an illegal access.
* @throws InstantiationException * @throws InstantiationException in case of an instantiation error.
*/ */
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID) private LocalCommand newInstanceOfCmd(String commandNode, String sessionID)
throws XMPPErrorException, InstantiationException, IllegalAccessException, IllegalArgumentException, throws XMPPErrorException, InstantiationException, IllegalAccessException, IllegalArgumentException,

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2019 Florian Schmaus * Copyright © 2014-2021 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.
@ -17,10 +17,10 @@
package org.jivesoftware.smackx.delay.provider; package org.jivesoftware.smackx.delay.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.Date; import java.util.Date;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException; import org.jivesoftware.smack.xml.XmlPullParserException;
@ -32,7 +32,7 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
@Override @Override
public final DelayInformation parse(XmlPullParser parser, public final DelayInformation parse(XmlPullParser parser,
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,
IOException, SmackTextParseException { IOException, ParseException {
String stampString = parser.getAttributeValue("", "stamp"); String stampString = parser.getAttributeValue("", "stamp");
String from = parser.getAttributeValue("", "from"); String from = parser.getAttributeValue("", "from");
final String reason; final String reason;
@ -54,5 +54,5 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
return new DelayInformation(stamp, from, reason); return new DelayInformation(stamp, from, reason);
} }
protected abstract Date parseDate(String string) throws SmackTextParseException; protected abstract Date parseDate(String string) throws ParseException;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2019 Florian Schmaus * Copyright © 2014-2021 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.
@ -16,9 +16,9 @@
*/ */
package org.jivesoftware.smackx.delay.provider; package org.jivesoftware.smackx.delay.provider;
import java.text.ParseException;
import java.util.Date; import java.util.Date;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
/** /**
@ -31,7 +31,7 @@ public class DelayInformationProvider extends AbstractDelayInformationProvider {
public static final DelayInformationProvider INSTANCE = new DelayInformationProvider(); public static final DelayInformationProvider INSTANCE = new DelayInformationProvider();
@Override @Override
protected Date parseDate(String string) throws SmackTextParseException { protected Date parseDate(String string) throws ParseException {
return ParserUtils.getDateFromXep82String(string); return ParserUtils.getDateFromXep82String(string);
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2019 Florian Schmaus * Copyright © 2014-2021 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.
@ -16,9 +16,9 @@
*/ */
package org.jivesoftware.smackx.delay.provider; package org.jivesoftware.smackx.delay.provider;
import java.text.ParseException;
import java.util.Date; import java.util.Date;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
/** /**
@ -29,7 +29,7 @@ import org.jivesoftware.smack.util.ParserUtils;
public class LegacyDelayInformationProvider extends AbstractDelayInformationProvider { public class LegacyDelayInformationProvider extends AbstractDelayInformationProvider {
@Override @Override
protected Date parseDate(String string) throws SmackTextParseException { protected Date parseDate(String string) throws ParseException {
return ParserUtils.getDateFromString(string); return ParserUtils.getDateFromString(string);
} }

View file

@ -142,7 +142,7 @@ public final class FileTransferManager extends Manager {
* @return The IncomingFileTransfer which manages the download of the file * @return The IncomingFileTransfer which manages the download of the file
* from the transfer initiator. * from the transfer initiator.
*/ */
protected IncomingFileTransfer createIncomingFileTransfer( IncomingFileTransfer createIncomingFileTransfer(
FileTransferRequest request) { FileTransferRequest request) {
if (request == null) { if (request == null) {
throw new NullPointerException("ReceiveRequest cannot be 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 NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted. * @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(); StreamInitiation initiation = request.getStreamInitiation();
// Reject as specified in XEP-95 4.2. Note that this is not to be confused with the Socks 5 // Reject as specified in XEP-95 4.2. Note that this is not to be confused with the Socks 5

View file

@ -65,7 +65,7 @@ public final class FileTransferNegotiator extends Manager {
private static final String STREAM_INIT_PREFIX = "jsi_"; 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(); private static final Random randomGenerator = new Random();

View file

@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.EventManger; import org.jivesoftware.smack.util.EventManger;
import org.jivesoftware.smack.util.EventManger.Callback;
import org.jivesoftware.smackx.si.packet.StreamInitiation; import org.jivesoftware.smackx.si.packet.StreamInitiation;
import org.jivesoftware.smackx.xdata.FormField; 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(); final String eventKey = initiation.getFrom().toString() + '\t' + initiation.getSessionID();
IQ streamMethodInitiation; IQ streamMethodInitiation;
try { try {
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getReplyTimeout(), new Callback<NotConnectedException>() { streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getReplyTimeout(), new EventManger.Callback<NotConnectedException>() {
@Override @Override
public void action() throws NotConnectedException { public void action() throws NotConnectedException {
try { try {

View file

@ -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"); * 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.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.forward.provider; package org.jivesoftware.smackx.forward.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.packet.Message; 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()); private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName());
@Override @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; DelayInformation di = null;
Stanza packet = null; Stanza packet = null;
@ -90,13 +92,14 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded<?>> {
} }
public static Forwarded<Message> parseForwardedMessage(XmlPullParser parser, XmlEnvironment xmlEnvironment) public static Forwarded<Message> parseForwardedMessage(XmlPullParser parser, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException { throws XmlPullParserException, IOException, SmackParsingException, ParseException {
return parseForwardedMessage(parser, parser.getDepth(), xmlEnvironment); return parseForwardedMessage(parser, parser.getDepth(), xmlEnvironment);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static Forwarded<Message> parseForwardedMessage(XmlPullParser parser, int initialDepth, 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); Forwarded<?> forwarded = INSTANCE.parse(parser, initialDepth, xmlEnvironment);
if (!forwarded.isForwarded(Message.class)) { if (!forwarded.isForwarded(Message.class)) {
throw new SmackParsingException("Expecting a forwarded message, but got " + forwarded); throw new SmackParsingException("Expecting a forwarded message, but got " + forwarded);

View file

@ -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"); * 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.
@ -17,12 +17,12 @@
package org.jivesoftware.smackx.geoloc.provider; package org.jivesoftware.smackx.geoloc.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException; import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -38,7 +38,7 @@ public class GeoLocationProvider extends ExtensionElementProvider<GeoLocation> {
@Override @Override
public GeoLocation parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, public GeoLocation parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException,
SmackTextParseException, SmackUriSyntaxParsingException { SmackUriSyntaxParsingException, ParseException {
GeoLocation.Builder builder = GeoLocation.builder(); GeoLocation.Builder builder = GeoLocation.builder();
@ -153,7 +153,7 @@ public class GeoLocationProvider extends ExtensionElementProvider<GeoLocation> {
@Override @Override
public GeoLocation parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) 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); return GeoLocationProvider.INSTANCE.parse(parser, initialDepth, xmlEnvironment);
} }

View file

@ -32,7 +32,6 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
@ -164,7 +163,7 @@ public final class LastActivityManager extends Manager {
// Register a listener for a last activity query // Register a listener for a last activity query
connection.registerIQRequestHandler(new AbstractIqRequestHandler(LastActivity.ELEMENT, LastActivity.NAMESPACE, connection.registerIQRequestHandler(new AbstractIqRequestHandler(LastActivity.ELEMENT, LastActivity.NAMESPACE,
Type.get, Mode.async) { IQ.Type.get, Mode.async) {
@Override @Override
public IQ handleIQRequest(IQ iqRequest) { public IQ handleIQRequest(IQ iqRequest) {
if (!enabled) if (!enabled)

View file

@ -24,12 +24,10 @@ import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.StanzaCollector; import org.jivesoftware.smack.StanzaCollector;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.StanzaIdFilter; import org.jivesoftware.smack.filter.StanzaIdFilter;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
@ -355,13 +353,11 @@ public final class AccountManager extends Manager {
/** /**
* Gets the account registration info from the server. * Gets the account registration info from the server.
*
* @throws XMPPErrorException if there was an XMPP error returned. * @throws XMPPErrorException if there was an XMPP error returned.
* @throws NoResponseException if there was no response from the remote entity. * @throws NoResponseException if there was no response from the remote entity.
* @throws NotConnectedException if the XMPP connection is not connected. * @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted. * @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 { private synchronized void getRegistrationInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Registration reg = new Registration(); Registration reg = new Registration();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus * Copyright 2017-2021 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.
@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.jingle.element.Jingle; import org.jivesoftware.smackx.jingle.element.Jingle;
@ -74,7 +73,7 @@ public final class JingleManager extends Manager {
jutil = new JingleUtil(connection); jutil = new JingleUtil(connection);
connection.registerIQRequestHandler( connection.registerIQRequestHandler(
new AbstractIqRequestHandler(Jingle.ELEMENT, Jingle.NAMESPACE, Type.set, Mode.async) { new AbstractIqRequestHandler(Jingle.ELEMENT, Jingle.NAMESPACE, IQ.Type.set, Mode.async) {
@Override @Override
public IQ handleIQRequest(IQ iqRequest) { public IQ handleIQRequest(IQ iqRequest) {
final Jingle jingle = (Jingle) iqRequest; final Jingle jingle = (Jingle) iqRequest;

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017-2020 Florian Schmaus * Copyright 2017-2021 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.
@ -76,7 +76,7 @@ public class JingleReason implements FullyQualifiedElement {
unsupported_transports, 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 { static {
for (Reason reason : Reason.values()) { for (Reason reason : Reason.values()) {
@ -84,7 +84,7 @@ public class JingleReason implements FullyQualifiedElement {
} }
} }
protected final String asString; final String asString;
Reason() { Reason() {
asString = name().replace('_', '-'); asString = name().replace('_', '-');

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017-2019 Florian Schmaus * Copyright 2017-2021 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.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.jingle.provider; package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.parsing.SmackParsingException;
@ -30,6 +31,7 @@ public abstract class JingleContentDescriptionProvider<D extends JingleContentDe
extends ExtensionElementProvider<D> { extends ExtensionElementProvider<D> {
@Override @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;
} }

View file

@ -51,6 +51,7 @@ public class JivePropertiesExtensionProvider extends ExtensionElementProvider<Ji
* @throws IOException if an I/O error occurred. * @throws IOException if an I/O error occurred.
* @throws XmlPullParserException if an error in the XML parser occurred. * @throws XmlPullParserException if an error in the XML parser occurred.
*/ */
@SuppressWarnings("BanSerializableRead")
@Override @Override
public JivePropertiesExtension parse(XmlPullParser parser, public JivePropertiesExtension parse(XmlPullParser parser,
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,

View file

@ -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"); * 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.
@ -20,8 +20,6 @@ import java.text.ParseException;
import java.util.Date; import java.util.Date;
import org.jivesoftware.smack.packet.XmlEnvironment; 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.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
@ -34,14 +32,9 @@ public class IdleProvider extends ExtensionElementProvider<IdleElement> {
public static final IdleProvider TEST_INSTANCE = new IdleProvider(); public static final IdleProvider TEST_INSTANCE = new IdleProvider();
@Override @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); String dateString = parser.getAttributeValue(null, IdleElement.ATTR_SINCE);
Date since; Date since = XmppDateTime.parseXEP0082Date(dateString);
try {
since = XmppDateTime.parseXEP0082Date(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
return new IdleElement(since); return new IdleElement(since);
} }
} }

View file

@ -1044,8 +1044,8 @@ public class MultiUserChat {
/** /**
* Fires invitation rejection listeners. * Fires invitation rejection listeners.
* *
* @param invitee the user being invited. * @param message the message.
* @param reason the reason for the rejection * @param rejection the information about the rejection.
*/ */
private void fireInvitationRejectionListeners(Message message, MUCUser.Decline rejection) { private void fireInvitationRejectionListeners(Message message, MUCUser.Decline rejection) {
EntityBareJid invitee = rejection.getFrom(); EntityBareJid invitee = rejection.getFrom();

View file

@ -37,7 +37,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError; import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.util.ExceptionCallback; import org.jivesoftware.smack.util.ExceptionCallback;
@ -120,7 +119,7 @@ public final class PingManager extends Manager {
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(Ping.NAMESPACE); 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 @Override
public IQ handleIQRequest(IQ iqRequest) { public IQ handleIQRequest(IQ iqRequest) {
Ping ping = (Ping) iqRequest; Ping ping = (Ping) iqRequest;

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2015 Florian Schmaus * Copyright 2015-2021 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.
@ -17,7 +17,7 @@
package org.jivesoftware.smackx.privacy.filter; package org.jivesoftware.smackx.privacy.filter;
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter; 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; import org.jivesoftware.smackx.privacy.packet.Privacy;
@ -30,7 +30,7 @@ public final class SetActiveListFilter extends FlexibleStanzaTypeFilter<Privacy>
@Override @Override
protected boolean acceptSpecific(Privacy privacy) { protected boolean acceptSpecific(Privacy privacy) {
if (privacy.getType() != Type.set) { if (privacy.getType() != IQ.Type.set) {
return false; return false;
} }
return privacy.getActiveName() != null || privacy.isDeclineActiveList(); return privacy.getActiveName() != null || privacy.isDeclineActiveList();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2015 Florian Schmaus * Copyright 2015-2021 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.
@ -17,7 +17,7 @@
package org.jivesoftware.smackx.privacy.filter; package org.jivesoftware.smackx.privacy.filter;
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter; 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; import org.jivesoftware.smackx.privacy.packet.Privacy;
@ -30,7 +30,7 @@ public final class SetDefaultListFilter extends FlexibleStanzaTypeFilter<Privacy
@Override @Override
protected boolean acceptSpecific(Privacy privacy) { protected boolean acceptSpecific(Privacy privacy) {
if (privacy.getType() != Type.set) { if (privacy.getType() != IQ.Type.set) {
return false; return false;
} }
return privacy.getDefaultName() != null || privacy.isDeclineDefaultList(); return privacy.getDefaultName() != null || privacy.isDeclineDefaultList();

View file

@ -24,7 +24,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.ExtensionElement; 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.disco.packet.DiscoverItems;
import org.jivesoftware.smackx.pubsub.form.ConfigureForm; import org.jivesoftware.smackx.pubsub.form.ConfigureForm;
@ -90,7 +90,7 @@ public class LeafNode extends Node {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public <T extends Item> List<T> getItems(String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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); return getItems(request);
} }
@ -116,7 +116,7 @@ public class LeafNode extends Node {
for (String id : ids) { for (String id : ids) {
itemList.add(new Item(id)); 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); return getItems(request);
} }
@ -133,7 +133,7 @@ public class LeafNode extends Node {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public <T extends Item> List<T> getItems(int maxItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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); return getItems(request);
} }
@ -154,7 +154,7 @@ public class LeafNode extends Node {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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); return getItems(request);
} }
@ -180,7 +180,7 @@ public class LeafNode extends Node {
public <T extends Item> List<T> getItems(List<ExtensionElement> additionalExtensions, public <T extends Item> List<T> getItems(List<ExtensionElement> additionalExtensions,
List<ExtensionElement> returnedExtensions) throws NoResponseException, List<ExtensionElement> returnedExtensions) throws NoResponseException,
XMPPErrorException, NotConnectedException, InterruptedException { XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId())); PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId()));
request.addExtensions(additionalExtensions); request.addExtensions(additionalExtensions);
return getItems(request, returnedExtensions); return getItems(request, returnedExtensions);
} }
@ -276,7 +276,7 @@ public class LeafNode extends Node {
* *
*/ */
public void publish() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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(); 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 { 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(); pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
} }
@ -341,7 +341,7 @@ public class LeafNode extends Node {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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(); pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
} }
@ -376,7 +376,7 @@ public class LeafNode extends Node {
for (String id : itemIds) { for (String id : itemIds) {
items.add(new Item(id)); 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(); pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
} }
} }

View file

@ -29,7 +29,7 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter; import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
import org.jivesoftware.smack.filter.OrFilter; import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.packet.ExtensionElement; 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.Message;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
@ -94,7 +94,7 @@ public abstract class Node {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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())); PubSubElementType.CONFIGURE_OWNER, getId()));
Stanza reply = sendPubsubPacket(pubSub); Stanza reply = sendPubsubPacket(pubSub);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER); return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
@ -110,7 +110,7 @@ public abstract class Node {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public void sendConfigurationForm(FillableConfigureForm configureForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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())); getId(), configureForm.getDataFormToSubmit()));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
} }
@ -218,7 +218,7 @@ public abstract class Node {
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSubElementType pubSubElementType = subscriptionsNamespace.type; 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) { if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) { for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe); pubSub.addExtension(pe);
@ -251,7 +251,7 @@ public abstract class Node {
public PubSub modifySubscriptionsAsOwner(List<Subscription> changedSubs) public PubSub modifySubscriptionsAsOwner(List<Subscription> changedSubs)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub pubSub = createPubsubPacket(Type.set, PubSub pubSub = createPubsubPacket(IQ.Type.set,
new SubscriptionsExtension(SubscriptionsNamespace.owner, getId(), changedSubs)); new SubscriptionsExtension(SubscriptionsNamespace.owner, getId(), changedSubs));
return sendPubsubPacket(pubSub); return sendPubsubPacket(pubSub);
} }
@ -337,7 +337,7 @@ public abstract class Node {
NotConnectedException, InterruptedException { NotConnectedException, InterruptedException {
PubSubElementType pubSubElementType = affiliationsNamespace.type; 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) { if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) { for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe); 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); return sendPubsubPacket(pubSub);
} }
@ -398,7 +398,7 @@ public abstract class Node {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public Subscription subscribe(Jid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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); PubSub reply = sendPubsubPacket(pubSub);
return reply.getExtension(PubSubElementType.SUBSCRIPTION); 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 { public Subscription subscribe(Jid jid, FillableSubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
DataForm submitForm = subForm.getDataFormToSubmit(); 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)); request.addExtension(new FormNode(FormNodeType.OPTIONS, submitForm));
PubSub reply = sendPubsubPacket(request); PubSub reply = sendPubsubPacket(request);
return reply.getExtension(PubSubElementType.SUBSCRIPTION); return reply.getExtension(PubSubElementType.SUBSCRIPTION);
@ -529,7 +529,7 @@ public abstract class Node {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public void unsubscribe(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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 { 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); FormNode ext = packet.getExtension(PubSubElementType.OPTIONS);
return new SubscribeForm(ext.getForm()); return new SubscribeForm(ext.getForm());
} }
@ -651,7 +651,7 @@ public abstract class Node {
return super.toString() + " " + getClass().getName() + " id: " + id; 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); return PubSub.createPubsubPacket(pubSubManager.getServiceJid(), type, ext);
} }

View file

@ -35,7 +35,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.EmptyResultIQ; import org.jivesoftware.smack.packet.EmptyResultIQ;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError; import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.packet.StanzaError.Condition; 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. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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"); QName qname = new QName(PubSubNamespace.basic.getXmlns(), "create");
NodeExtension elem = (NodeExtension) reply.getExtension(qname); NodeExtension elem = (NodeExtension) reply.getExtension(qname);
@ -257,7 +256,7 @@ public final class PubSubManager extends Manager {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public Node createNode(String nodeId, FillableConfigureForm config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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; boolean isLeafNode = true;
if (config != null) { if (config != null) {
@ -507,7 +506,7 @@ public final class PubSubManager extends Manager {
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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()); SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtensionElement(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
return subElem.getSubscriptions(); return subElem.getSubscriptions();
} }
@ -523,7 +522,7 @@ public final class PubSubManager extends Manager {
* *
*/ */
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { 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); AffiliationsExtension listElem = reply.getExtension(PubSubElementType.AFFILIATIONS);
return listElem.getAffiliations(); return listElem.getAffiliations();
} }
@ -541,7 +540,7 @@ public final class PubSubManager extends Manager {
public boolean deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { public boolean deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
boolean res = true; boolean res = true;
try { 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) { } catch (XMPPErrorException e) {
if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) { if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) {
res = false; res = false;
@ -565,7 +564,7 @@ public final class PubSubManager extends Manager {
public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// Errors will cause exceptions in getReply, so it only returns // Errors will cause exceptions in getReply, so it only returns
// on success. // 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); return NodeUtils.getFormFromPacket(reply, PubSubElementType.DEFAULT);
} }
@ -644,7 +643,7 @@ public final class PubSubManager extends Manager {
return true; 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 { throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return sendPubsubPacket(pubSubService, type, Collections.singletonList(ext), ns); return sendPubsubPacket(pubSubService, type, Collections.singletonList(ext), ns);
} }
@ -653,7 +652,7 @@ public final class PubSubManager extends Manager {
return connection(); 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, throws NoResponseException, XMPPErrorException, NotConnectedException,
InterruptedException { InterruptedException {
// CHECKSTYLE:OFF // CHECKSTYLE:OFF

View file

@ -27,7 +27,6 @@ import org.jivesoftware.smackx.xdata.TextSingleFormField;
import org.jivesoftware.smackx.xdata.form.FilledForm; import org.jivesoftware.smackx.xdata.form.FilledForm;
import org.jivesoftware.smackx.xdata.form.Form; import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
/** /**
* {@link Form} that contains the software information. * {@link Form} that contains the software information.
@ -145,7 +144,7 @@ public final class SoftwareInfoForm extends FilledForm {
DataForm.Builder dataFormBuilder; DataForm.Builder dataFormBuilder;
private Builder() { private Builder() {
dataFormBuilder = DataForm.builder(Type.result); dataFormBuilder = DataForm.builder(DataForm.Type.result);
TextSingleFormField formField = FormField.buildHiddenFormType(FORM_TYPE); TextSingleFormField formField = FormField.buildHiddenFormType(FORM_TYPE);
dataFormBuilder.addField(formField); dataFormBuilder.addField(formField);
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2014 Florian Schmaus * Copyright 2014-2021 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.
@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.StanzaError.Condition; import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -72,7 +71,7 @@ public final class EntityTimeManager extends Manager {
if (autoEnable) if (autoEnable)
enable(); enable();
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, Type.get, connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, IQ.Type.get,
Mode.async) { Mode.async) {
@Override @Override
public IQ handleIQRequest(IQ iqRequest) { public IQ handleIQRequest(IQ iqRequest) {

View file

@ -28,7 +28,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -612,10 +611,10 @@ public final class VCard extends IQ {
xml.optElement("ORGUNIT", organizationUnit); xml.optElement("ORGUNIT", organizationUnit);
xml.closeElement("ORG"); xml.closeElement("ORG");
} }
for (Entry<String, String> entry : otherSimpleFields.entrySet()) { for (Map.Entry<String, String> entry : otherSimpleFields.entrySet()) {
xml.optElement(entry.getKey(), entry.getValue()); 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(); final String value = entry.getValue();
if (value == null) { if (value == null) {
continue; continue;
@ -646,7 +645,7 @@ public final class VCard extends IQ {
xml.element("USERID", emailHome); xml.element("USERID", emailHome);
xml.closeElement("EMAIL"); xml.closeElement("EMAIL");
} }
for (Entry<String, String> phone : workPhones.entrySet()) { for (Map.Entry<String, String> phone : workPhones.entrySet()) {
final String number = phone.getValue(); final String number = phone.getValue();
if (number == null) { if (number == null) {
continue; continue;
@ -657,7 +656,7 @@ public final class VCard extends IQ {
xml.element("NUMBER", number); xml.element("NUMBER", number);
xml.closeElement("TEL"); xml.closeElement("TEL");
} }
for (Entry<String, String> phone : homePhones.entrySet()) { for (Map.Entry<String, String> phone : homePhones.entrySet()) {
final String number = phone.getValue(); final String number = phone.getValue();
if (number == null) { if (number == null) {
continue; continue;
@ -671,7 +670,7 @@ public final class VCard extends IQ {
if (!workAddr.isEmpty()) { if (!workAddr.isEmpty()) {
xml.openElement("ADR"); xml.openElement("ADR");
xml.emptyElement("WORK"); xml.emptyElement("WORK");
for (Entry<String, String> entry : workAddr.entrySet()) { for (Map.Entry<String, String> entry : workAddr.entrySet()) {
final String value = entry.getValue(); final String value = entry.getValue();
if (value == null) { if (value == null) {
continue; continue;
@ -683,7 +682,7 @@ public final class VCard extends IQ {
if (!homeAddr.isEmpty()) { if (!homeAddr.isEmpty()) {
xml.openElement("ADR"); xml.openElement("ADR");
xml.emptyElement("HOME"); xml.emptyElement("HOME");
for (Entry<String, String> entry : homeAddr.entrySet()) { for (Map.Entry<String, String> entry : homeAddr.entrySet()) {
final String value = entry.getValue(); final String value = entry.getValue();
if (value == null) { if (value == null) {
continue; continue;

View file

@ -29,7 +29,6 @@ import java.util.Set;
import org.jivesoftware.smackx.xdata.AbstractMultiFormField; import org.jivesoftware.smackx.xdata.AbstractMultiFormField;
import org.jivesoftware.smackx.xdata.AbstractSingleStringValueFormField; import org.jivesoftware.smackx.xdata.AbstractSingleStringValueFormField;
import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormField.Type;
import org.jivesoftware.smackx.xdata.FormFieldChildElement; import org.jivesoftware.smackx.xdata.FormFieldChildElement;
import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.packet.DataForm;
@ -202,7 +201,7 @@ public class FillableForm extends FilledForm {
public void setAnswer(String fieldName, boolean answer) { public void setAnswer(String fieldName, boolean answer) {
FormField blankField = getFieldOrThrow(fieldName); FormField blankField = getFieldOrThrow(fieldName);
if (blankField.getType() != Type.bool) { if (blankField.getType() != FormField.Type.bool) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2020 Florian Schmaus * Copyright 2020-2021 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.util.StringUtils;
import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.TextSingleFormField; import org.jivesoftware.smackx.xdata.TextSingleFormField;
import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
public abstract class FilledForm implements FormReader { public abstract class FilledForm implements FormReader {
@ -36,7 +35,7 @@ public abstract class FilledForm implements FormReader {
if (StringUtils.isNullOrEmpty(formType)) { if (StringUtils.isNullOrEmpty(formType)) {
throw new IllegalArgumentException("The provided data form has no hidden FROM_TYPE field."); 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"); throw new IllegalArgumentException("Forms of type 'cancel' are not filled nor fillable");
} }
formTypeFormField = dataForm.getHiddenFormTypeField(); formTypeFormField = dataForm.getHiddenFormTypeField();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2020 Florian Schmaus * Copyright 2020-2021 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.
@ -19,13 +19,12 @@ package org.jivesoftware.smackx.xdata.form;
import org.jivesoftware.smack.packet.StanzaView; import org.jivesoftware.smack.packet.StanzaView;
import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
public class Form extends FilledForm { public class Form extends FilledForm {
public Form(DataForm dataForm) { public Form(DataForm dataForm) {
super(dataForm); super(dataForm);
if (dataForm.getType() != Type.form) { if (dataForm.getType() != DataForm.Type.form) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }
@ -36,7 +35,7 @@ public class Form extends FilledForm {
public static Form from(StanzaView stanzaView) { public static Form from(StanzaView stanzaView) {
DataForm dataForm = DataForm.from(stanzaView); DataForm dataForm = DataForm.from(stanzaView);
if (dataForm == null || dataForm.getType() != Type.form) { if (dataForm == null || dataForm.getType() != DataForm.Type.form) {
return null; return null;
} }
return new Form(dataForm); return new Form(dataForm);

View file

@ -112,6 +112,8 @@ public abstract class ValidateElement implements FormFieldChildElement {
} }
/** /**
* Append XML.
*
* @param buf TODO javadoc me please * @param buf TODO javadoc me please
*/ */
protected abstract void appendXML(XmlStringBuilder buf); 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 formField TODO javadoc me please
* @param method TODO javadoc me please * @param method TODO javadoc me please
*/ */

View file

@ -19,7 +19,6 @@ package org.jivesoftware.smackx.blocking;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.StreamOpen; import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
@ -42,7 +41,7 @@ public class GetBlockingListTest {
@Test @Test
public void checkGetBlockingListIQStanza() throws Exception { public void checkGetBlockingListIQStanza() throws Exception {
BlockListIQ getBlockListIQ = new BlockListIQ(null); BlockListIQ getBlockListIQ = new BlockListIQ(null);
getBlockListIQ.setType(Type.get); getBlockListIQ.setType(IQ.Type.get);
getBlockListIQ.setStanzaId("blocklist1"); getBlockListIQ.setStanzaId("blocklist1");
assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
} }

View file

@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import java.nio.charset.StandardCharsets; 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.packet.StreamOpen;
import org.jivesoftware.smack.test.util.SmackTestSuite; import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
@ -46,7 +46,7 @@ public class BoBIQTest extends SmackTestSuite {
BoBIQ createdBoBIQ = new BoBIQ(bobHash); BoBIQ createdBoBIQ = new BoBIQ(bobHash);
createdBoBIQ.setStanzaId("sarasa"); createdBoBIQ.setStanzaId("sarasa");
createdBoBIQ.setTo(JidCreate.from("ladymacbeth@shakespeare.lit/castle")); 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()); assertEquals(sampleBoBIQRequest, createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
} }
@ -61,7 +61,7 @@ public class BoBIQTest extends SmackTestSuite {
BoBIQ createdBoBIQ = new BoBIQ(bobHash, bobData); BoBIQ createdBoBIQ = new BoBIQ(bobHash, bobData);
createdBoBIQ.setStanzaId("sarasa"); createdBoBIQ.setStanzaId("sarasa");
createdBoBIQ.setTo(JidCreate.from("doctor@shakespeare.lit/pda")); 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().getHash(), createdBoBIQ.getContentId().getHash());
assertEquals(bobIQ.getContentId().getHashType(), createdBoBIQ.getContentId().getHashType()); assertEquals(bobIQ.getContentId().getHashType(), createdBoBIQ.getContentId().getHashType());

View file

@ -237,7 +237,7 @@ public class PingTest extends SmackTestSuite {
/** /**
* The returned connection won't send replies to IQs * The returned connection won't send replies to IQs
* *
* @return * @return a dummy connection.
* @throws XMPPException if an XMPP protocol error was received. * @throws XMPPException if an XMPP protocol error was received.
* @throws IOException if an I/O error occurred. * @throws IOException if an I/O error occurred.
* @throws SmackException if Smack detected an exceptional situation. * @throws SmackException if Smack detected an exceptional situation.

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017-2020 Florian Schmaus * Copyright 2017-2021 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 java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jivesoftware.smackx.pubsub.Affiliation.Type;
import org.jivesoftware.smackx.pubsub.packet.PubSub; import org.jivesoftware.smackx.pubsub.packet.PubSub;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -35,7 +34,7 @@ public class AffiliationsExtensionTest {
@Test @Test
public void testAffiliationsExtensionToXml() throws SAXException, IOException { public void testAffiliationsExtensionToXml() throws SAXException, IOException {
BareJid affiliatedJid = JidTestUtil.BARE_JID_1; 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<>(); List<Affiliation> affiliationsList = new ArrayList<>();
affiliationsList.add(affiliation); affiliationsList.add(affiliation);

View file

@ -28,7 +28,6 @@ import org.jivesoftware.smack.ThreadedDummyConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; 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;
import org.jivesoftware.smack.packet.StanzaError.Condition; import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smack.test.util.SmackTestSuite; import org.jivesoftware.smack.test.util.SmackTestSuite;
@ -63,7 +62,7 @@ public class ConfigureFormTest extends SmackTestSuite {
Node node = mgr.getNode("princely_musings"); Node node = mgr.getNode("princely_musings");
PubSub errorIq = new PubSub(); PubSub errorIq = new PubSub();
errorIq.setType(Type.error); errorIq.setType(IQ.Type.error);
errorIq.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE); errorIq.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
StanzaError error = StanzaError.getBuilder(Condition.forbidden).build(); StanzaError error = StanzaError.getBuilder(Condition.forbidden).build();
errorIq.setError(error); errorIq.setError(error);

View file

@ -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"); * 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.
@ -26,7 +26,7 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.ThreadedDummyConnection; import org.jivesoftware.smack.ThreadedDummyConnection;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; 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.SmackTestSuite;
import org.jivesoftware.smack.test.util.TestUtils; import org.jivesoftware.smack.test.util.TestUtils;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
@ -89,7 +89,7 @@ public class PubSubNodeTest extends SmackTestSuite {
new Affiliation(JidTestUtil.BARE_JID_2, Affiliation.Type.publisher) new Affiliation(JidTestUtil.BARE_JID_2, Affiliation.Type.publisher)
); );
AffiliationsExtension affiliationsExtension = new AffiliationsExtension(AffiliationNamespace.owner, affiliations); 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); response.addExtension(affiliationsExtension);
protocol.addResponse(response); protocol.addResponse(response);

View file

@ -29,7 +29,6 @@ import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm;
import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.TextSingleFormField; import org.jivesoftware.smackx.xdata.TextSingleFormField;
import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -85,21 +84,21 @@ public class SoftwareInfoFormTest extends SmackTestSuite {
@Test @Test
public void faultySoftwareInfoFormsTest() { public void faultySoftwareInfoFormsTest() {
DataForm.Builder dataFormbuilder = DataForm.builder(Type.result); DataForm.Builder dataFormbuilder = DataForm.builder(DataForm.Type.result);
TextSingleFormField formField = FormField.buildHiddenFormType("faulty_formtype"); TextSingleFormField formField = FormField.buildHiddenFormType("faulty_formtype");
dataFormbuilder.addField(formField); dataFormbuilder.addField(formField);
assertThrows(IllegalArgumentException.class, () -> { assertThrows(IllegalArgumentException.class, () -> {
SoftwareInfoForm.getBuilder().setDataForm(dataFormbuilder.build()).build(); SoftwareInfoForm.getBuilder().setDataForm(dataFormbuilder.build()).build();
}); });
DataForm.Builder builderWithoutFormType = DataForm.builder(Type.result); DataForm.Builder builderWithoutFormType = DataForm.builder(DataForm.Type.result);
assertThrows(IllegalArgumentException.class, () -> { assertThrows(IllegalArgumentException.class, () -> {
SoftwareInfoForm.getBuilder().setDataForm(builderWithoutFormType.build()).build(); SoftwareInfoForm.getBuilder().setDataForm(builderWithoutFormType.build()).build();
}); });
} }
public static SoftwareInfoForm createSoftwareInfoFormUsingDataForm() throws URISyntaxException { 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); TextSingleFormField formField = FormField.buildHiddenFormType(SoftwareInfoForm.FORM_TYPE);
dataFormBuilder.addField(formField); dataFormBuilder.addField(formField);

View file

@ -30,7 +30,6 @@ import org.jivesoftware.smackx.mediaelement.element.MediaElement;
import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm; import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm;
import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
import org.jivesoftware.util.ConnectionUtils; import org.jivesoftware.util.ConnectionUtils;
import org.jivesoftware.util.Protocol; import org.jivesoftware.util.Protocol;
@ -70,7 +69,7 @@ public class SoftwareInfoManagerTest {
} }
public static SoftwareInfoForm buildSoftwareInfoFromDataForm() throws URISyntaxException { 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.buildHiddenFormType(SoftwareInfoForm.FORM_TYPE));
dataFormBuilder.addField(FormField.builder("icon") dataFormBuilder.addField(FormField.builder("icon")
.addFormFieldChildElement(createMediaElement()) .addFormFieldChildElement(createMediaElement())

View file

@ -25,7 +25,6 @@ import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormField.Type;
import org.jivesoftware.smackx.xdata.provider.DataFormProvider; import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout; import org.jivesoftware.smackx.xdatalayout.packet.DataLayout;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Fieldref; import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Fieldref;
@ -151,6 +150,6 @@ public class DataFormTest extends SmackTestSuite {
public void testFixedField() throws Exception { 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>"; 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)); DataForm df = pr.parse(PacketParserUtils.getParserFor(formWithFixedField));
assertEquals(Type.fixed, df.getFields().get(0).getType()); assertEquals(FormField.Type.fixed, df.getFields().get(0).getType());
} }
} }

View file

@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException; import java.io.IOException;
import org.jivesoftware.smack.parsing.SmackParsingException; 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.SmackTestSuite;
import org.jivesoftware.smack.test.util.SmackTestUtil; import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smack.xml.XmlPullParserException; import org.jivesoftware.smack.xml.XmlPullParserException;
@ -145,7 +146,7 @@ public class DataValidationTest extends SmackTestSuite {
@ParameterizedTest @ParameterizedTest
@EnumSource(SmackTestUtil.XmlPullParserKind.class) @EnumSource(SmackTestUtil.XmlPullParserKind.class)
public void testRangeFailure(SmackTestUtil.XmlPullParserKind parserKind) throws IOException, XmlPullParserException { public void testRangeFailure(SmackTestUtil.XmlPullParserKind parserKind) throws IOException, XmlPullParserException {
assertThrows(NumberFormatException.class, assertThrows(AbstractProvider.NumberFormatParseException.class,
() -> SmackTestUtil.parse(TEST_OUTPUT_FAIL, DataValidationProvider.class, parserKind)); () -> SmackTestUtil.parse(TEST_OUTPUT_FAIL, DataValidationProvider.class, parserKind));
} }

View file

@ -39,7 +39,6 @@ import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.filter.ThreadFilter; import org.jivesoftware.smack.filter.ThreadFilter;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
@ -110,7 +109,7 @@ public final class ChatManager extends Manager{
@Override @Override
protected boolean acceptSpecific(Message message) { protected boolean acceptSpecific(Message message) {
return normalIncluded ? message.getType() == Type.normal : false; return normalIncluded ? message.getType() == Message.Type.normal : false;
} }
}); });

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2003-2007 Jive Software, 2016-2019 Florian Schmaus. * Copyright 2003-2007 Jive Software, 2016-2021 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.
@ -25,7 +25,6 @@ import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -54,7 +53,6 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.filter.ToMatchesFilter; import org.jivesoftware.smack.filter.ToMatchesFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.PresenceBuilder; import org.jivesoftware.smack.packet.PresenceBuilder;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
@ -151,7 +149,17 @@ public final class Roster extends Manager {
private static int defaultNonRosterPresenceMapMaxSize = INITIAL_DEFAULT_NON_ROSTER_PRESENCE_MAP_SIZE; private static int defaultNonRosterPresenceMapMaxSize = INITIAL_DEFAULT_NON_ROSTER_PRESENCE_MAP_SIZE;
private RosterStore rosterStore; private RosterStore rosterStore;
private final Map<String, RosterGroup> groups = new ConcurrentHashMap<>();
/**
* The groups of this roster.
* <p>
* Note that we use {@link ConcurrentHashMap} also as static type of this field, since we use the fact that the same
* thread can modify this collection, e.g. remove items, while iterating over it. This is done, for example in
* {@link #deleteEntry(Collection, RosterEntry)}. If we do not denote the static type to ConcurrentHashMap, but
* {@link Map} instead, then error prone would report a ModifyCollectionInEnhancedForLoop but.
* </p>
*/
private final ConcurrentHashMap<String, RosterGroup> groups = new ConcurrentHashMap<>();
/** /**
* Concurrent hash map from JID to its roster entry. * Concurrent hash map from JID to its roster entry.
@ -508,7 +516,7 @@ public final class Roster extends Manager {
return true; return true;
} }
protected boolean waitUntilLoaded() throws InterruptedException { boolean waitUntilLoaded() throws InterruptedException {
long waitTime = connection().getReplyTimeout(); long waitTime = connection().getReplyTimeout();
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
while (!isLoaded()) { while (!isLoaded()) {
@ -1416,7 +1424,7 @@ public final class Roster extends Manager {
move(user, presenceMap, nonRosterPresenceMap); move(user, presenceMap, nonRosterPresenceMap);
deletedEntries.add(user); deletedEntries.add(user);
for (Entry<String, RosterGroup> e : groups.entrySet()) { for (Map.Entry<String, RosterGroup> e : groups.entrySet()) {
RosterGroup group = e.getValue(); RosterGroup group = e.getValue();
group.removeEntryLocal(entry); group.removeEntryLocal(entry);
if (group.getEntryCount() == 0) { if (group.getEntryCount() == 0) {
@ -1787,7 +1795,7 @@ public final class Roster extends Manager {
private final class RosterPushListener extends AbstractIqRequestHandler { private final class RosterPushListener extends AbstractIqRequestHandler {
private RosterPushListener() { private RosterPushListener() {
super(RosterPacket.ELEMENT, RosterPacket.NAMESPACE, Type.set, Mode.sync); super(RosterPacket.ELEMENT, RosterPacket.NAMESPACE, IQ.Type.set, Mode.sync);
} }
@Override @Override

View file

@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
import org.jivesoftware.smack.roster.packet.RosterPacket; import org.jivesoftware.smack.roster.packet.RosterPacket;
import org.jivesoftware.smack.util.EqualsUtil; import org.jivesoftware.smack.util.EqualsUtil;
@ -221,7 +220,7 @@ public final class RosterEntry extends Manager {
XMPPConnection connection = connection(); XMPPConnection connection = connection();
Presence unsubscribed = connection.getStanzaFactory().buildPresenceStanza() Presence unsubscribed = connection.getStanzaFactory().buildPresenceStanza()
.to(item.getJid()) .to(item.getJid())
.ofType(Type.unsubscribed) .ofType(Presence.Type.unsubscribed)
.build(); .build();
connection.sendStanza(unsubscribed); connection.sendStanza(unsubscribed);
} }

View file

@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
import org.jivesoftware.smack.DummyConnection; import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.MessageBuilder; import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaBuilder; import org.jivesoftware.smack.packet.StanzaBuilder;
@ -92,7 +91,7 @@ public class ChatConnectionTest {
@Test @Test
public void validateMessageTypeWithDefaults1() { public void validateMessageTypeWithDefaults1() {
MessageBuilder incomingChat = createChatPacket("134", true); MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.chat); incomingChat.ofType(Message.Type.chat);
processServerMessage(incomingChat.build()); processServerMessage(incomingChat.build());
assertNotNull(listener.getNewChat()); assertNotNull(listener.getNewChat());
} }
@ -100,14 +99,14 @@ public class ChatConnectionTest {
@Test @Test
public void validateMessageTypeWithDefaults2() { public void validateMessageTypeWithDefaults2() {
MessageBuilder incomingChat = createChatPacket("134", true); MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.normal); incomingChat.ofType(Message.Type.normal);
processServerMessage(incomingChat.build()); processServerMessage(incomingChat.build());
assertNotNull(listener.getNewChat()); assertNotNull(listener.getNewChat());
} }
@Test @Test
public void validateMessageTypeWithDefaults3() { public void validateMessageTypeWithDefaults3() {
MessageBuilder incomingChat = createChatPacket("134", true); MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.groupchat); incomingChat.ofType(Message.Type.groupchat);
processServerMessage(incomingChat.build()); processServerMessage(incomingChat.build());
assertNull(listener.getNewChat()); assertNull(listener.getNewChat());
} }
@ -115,7 +114,7 @@ public class ChatConnectionTest {
@Test @Test
public void validateMessageTypeWithDefaults4() { public void validateMessageTypeWithDefaults4() {
MessageBuilder incomingChat = createChatPacket("134", true); MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.headline); incomingChat.ofType(Message.Type.headline);
assertNull(listener.getNewChat()); assertNull(listener.getNewChat());
} }
@ -123,7 +122,7 @@ public class ChatConnectionTest {
public void validateMessageTypeWithNoNormal1() { public void validateMessageTypeWithNoNormal1() {
cm.setNormalIncluded(false); cm.setNormalIncluded(false);
MessageBuilder incomingChat = createChatPacket("134", true); MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.chat); incomingChat.ofType(Message.Type.chat);
processServerMessage(incomingChat.build()); processServerMessage(incomingChat.build());
assertNotNull(listener.getNewChat()); assertNotNull(listener.getNewChat());
} }
@ -132,7 +131,7 @@ public class ChatConnectionTest {
public void validateMessageTypeWithNoNormal2() { public void validateMessageTypeWithNoNormal2() {
cm.setNormalIncluded(false); cm.setNormalIncluded(false);
MessageBuilder incomingChat = createChatPacket("134", true); MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.normal); incomingChat.ofType(Message.Type.normal);
processServerMessage(incomingChat.build()); processServerMessage(incomingChat.build());
assertNull(listener.getNewChat()); assertNull(listener.getNewChat());
} }
@ -318,7 +317,7 @@ public class ChatConnectionTest {
cm.setNormalIncluded(false); cm.setNormalIncluded(false);
MessageBuilder incomingChat = createChatPacket(null, false); MessageBuilder incomingChat = createChatPacket(null, false);
incomingChat.ofType(Type.normal); incomingChat.ofType(Message.Type.normal);
processServerMessage(incomingChat.build()); processServerMessage(incomingChat.build());
assertNull(listener.getNewChat()); assertNull(listener.getNewChat());

View file

@ -35,7 +35,6 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.im.InitSmackIm; import org.jivesoftware.smack.im.InitSmackIm;
import org.jivesoftware.smack.packet.ErrorIQ; import org.jivesoftware.smack.packet.ErrorIQ;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError.Condition; import org.jivesoftware.smack.packet.StanzaError.Condition;
@ -385,7 +384,7 @@ public class RosterTest extends InitSmackIm {
public void testIgnoreInvalidFrom() throws XmppStringprepException { public void testIgnoreInvalidFrom() throws XmppStringprepException {
final BareJid spammerJid = JidCreate.entityBareFrom("spam@example.com"); final BareJid spammerJid = JidCreate.entityBareFrom("spam@example.com");
RosterPacket packet = new RosterPacket(); RosterPacket packet = new RosterPacket();
packet.setType(Type.set); packet.setType(IQ.Type.set);
packet.setTo(connection.getUser()); packet.setTo(connection.getUser());
packet.setFrom(JidCreate.entityBareFrom("mallory@example.com")); packet.setFrom(JidCreate.entityBareFrom("mallory@example.com"));
packet.addRosterItem(new Item(spammerJid, "Cool products!")); packet.addRosterItem(new Item(spammerJid, "Cool products!"));
@ -530,7 +529,7 @@ public class RosterTest extends InitSmackIm {
for (RosterEntry entry : roster.getEntries()) { for (RosterEntry entry : roster.getEntries()) {
// prepare the roster push packet // prepare the roster push packet
final RosterPacket rosterPush = new RosterPacket(); final RosterPacket rosterPush = new RosterPacket();
rosterPush.setType(Type.set); rosterPush.setType(IQ.Type.set);
rosterPush.setTo(connection.getUser()); rosterPush.setTo(connection.getUser());
// prepare the buddy's item entry which should be removed // prepare the buddy's item entry which should be removed
@ -555,7 +554,7 @@ public class RosterTest extends InitSmackIm {
roster.reload(); roster.reload();
while (true) { while (true) {
final Stanza sentPacket = connection.getSentPacket(); final Stanza sentPacket = connection.getSentPacket();
if (sentPacket instanceof RosterPacket && ((IQ) sentPacket).getType() == Type.get) { if (sentPacket instanceof RosterPacket && ((IQ) sentPacket).getType() == IQ.Type.get) {
// setup the roster get request // setup the roster get request
final RosterPacket rosterRequest = (RosterPacket) sentPacket; final RosterPacket rosterRequest = (RosterPacket) sentPacket;
assertSame("The <query/> element MUST NOT contain any <item/> child elements!", assertSame("The <query/> element MUST NOT contain any <item/> child elements!",
@ -565,7 +564,7 @@ public class RosterTest extends InitSmackIm {
// prepare the roster result // prepare the roster result
final RosterPacket rosterResult = new RosterPacket(); final RosterPacket rosterResult = new RosterPacket();
rosterResult.setTo(connection.getUser()); rosterResult.setTo(connection.getUser());
rosterResult.setType(Type.result); rosterResult.setType(IQ.Type.result);
rosterResult.setStanzaId(rosterRequest.getStanzaId()); rosterResult.setStanzaId(rosterRequest.getStanzaId());
// prepare romeo's roster entry // prepare romeo's roster entry
@ -674,7 +673,7 @@ public class RosterTest extends InitSmackIm {
try { try {
while (true) { while (true) {
final Stanza packet = connection.getSentPacket(); final Stanza packet = connection.getSentPacket();
if (packet instanceof RosterPacket && ((IQ) packet).getType() == Type.set) { if (packet instanceof RosterPacket && ((IQ) packet).getType() == IQ.Type.set) {
final RosterPacket rosterRequest = (RosterPacket) packet; final RosterPacket rosterRequest = (RosterPacket) packet;
// Prepare and process the roster push // Prepare and process the roster push
@ -683,7 +682,7 @@ public class RosterTest extends InitSmackIm {
if (item.getItemType() != ItemType.remove) { if (item.getItemType() != ItemType.remove) {
item.setItemType(ItemType.none); item.setItemType(ItemType.none);
} }
rosterPush.setType(Type.set); rosterPush.setType(IQ.Type.set);
rosterPush.setTo(connection.getUser()); rosterPush.setTo(connection.getUser());
rosterPush.addRosterItem(item); rosterPush.addRosterItem(item);
connection.processStanza(rosterPush); connection.processStanza(rosterPush);

View file

@ -30,7 +30,6 @@ import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.roster.RosterTest.TestRosterListener; import org.jivesoftware.smack.roster.RosterTest.TestRosterListener;
import org.jivesoftware.smack.roster.packet.RosterPacket; import org.jivesoftware.smack.roster.packet.RosterPacket;
@ -146,7 +145,7 @@ public class RosterVersioningTest {
RosterPacket sentRP = (RosterPacket) sentPacket; RosterPacket sentRP = (RosterPacket) sentPacket;
RosterPacket answer = new RosterPacket(); RosterPacket answer = new RosterPacket();
answer.setStanzaId(sentRP.getStanzaId()); answer.setStanzaId(sentRP.getStanzaId());
answer.setType(Type.result); answer.setType(IQ.Type.result);
answer.setTo(sentRP.getFrom()); answer.setTo(sentRP.getFrom());
answer.setVersion("newVersion"); answer.setVersion("newVersion");
@ -188,7 +187,7 @@ public class RosterVersioningTest {
{ {
RosterPacket rosterPush = new RosterPacket(); RosterPacket rosterPush = new RosterPacket();
rosterPush.setTo(JidCreate.from("rostertest@example.com/home")); rosterPush.setTo(JidCreate.from("rostertest@example.com/home"));
rosterPush.setType(Type.set); rosterPush.setType(IQ.Type.set);
rosterPush.setVersion("v97"); rosterPush.setVersion("v97");
Item pushedItem = vaglafItem(); Item pushedItem = vaglafItem();
@ -214,7 +213,7 @@ public class RosterVersioningTest {
{ {
RosterPacket rosterPush = new RosterPacket(); RosterPacket rosterPush = new RosterPacket();
rosterPush.setTo(JidCreate.from("rostertest@example.com/home")); rosterPush.setTo(JidCreate.from("rostertest@example.com/home"));
rosterPush.setType(Type.set); rosterPush.setType(IQ.Type.set);
rosterPush.setVersion("v98"); rosterPush.setVersion("v98");
Item item = new Item(JidCreate.entityBareFrom("vaglaf@example.com"), "vaglaf the only"); Item item = new Item(JidCreate.entityBareFrom("vaglaf@example.com"), "vaglaf the only");

View file

@ -26,7 +26,6 @@ import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException; import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
import org.jivesoftware.smack.im.InitSmackIm; import org.jivesoftware.smack.im.InitSmackIm;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.roster.RosterTest.TestRosterListener; import org.jivesoftware.smack.roster.RosterTest.TestRosterListener;
@ -161,7 +160,7 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
try { try {
while (true) { while (true) {
final Stanza packet = connection.getSentPacket(); final Stanza packet = connection.getSentPacket();
if (packet instanceof RosterPacket && ((IQ) packet).getType() == Type.set) { if (packet instanceof RosterPacket && ((IQ) packet).getType() == IQ.Type.set) {
final RosterPacket rosterRequest = (RosterPacket) packet; final RosterPacket rosterRequest = (RosterPacket) packet;
// Prepare and process the roster push // Prepare and process the roster push
@ -170,7 +169,7 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
if (item.getItemType() != ItemType.remove) { if (item.getItemType() != ItemType.remove) {
item.setItemType(ItemType.none); item.setItemType(ItemType.none);
} }
rosterPush.setType(Type.set); rosterPush.setType(IQ.Type.set);
rosterPush.setTo(connection.getUser()); rosterPush.setTo(connection.getUser());
rosterPush.addRosterItem(item); rosterPush.addRosterItem(item);
connection.processStanza(rosterPush); connection.processStanza(rosterPush);

View file

@ -24,7 +24,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -447,7 +447,7 @@ public final class Configuration {
// Properties set via the system override the file properties // Properties set via the system override the file properties
Properties systemProperties = System.getProperties(); Properties systemProperties = System.getProperties();
for (Entry<Object, Object> entry : systemProperties.entrySet()) { for (Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
String key = (String) entry.getKey(); String key = (String) entry.getKey();
if (!key.startsWith(SINTTEST)) { if (!key.startsWith(SINTTEST)) {
continue; continue;

Some files were not shown because too many files have changed in this diff Show more