Skip to content

Commit

Permalink
Merge 71d2b9c into 78ffcae
Browse files Browse the repository at this point in the history
  • Loading branch information
ibauersachs committed Apr 2, 2022
2 parents 78ffcae + 71d2b9c commit 093ac94
Show file tree
Hide file tree
Showing 93 changed files with 438 additions and 267 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;

import org.jivesoftware.smack.packet.Bind;
import org.jivesoftware.smack.packet.IqData;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
Expand All @@ -27,10 +28,10 @@
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.jid.parts.Resourcepart;

public class BindIQProvider extends IQProvider<Bind> {
public class BindIQProvider extends IqProvider<Bind> {

@Override
public Bind parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
public Bind parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
String name;
Bind bind = null;
outerloop: while (true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public final class IQProviderInfo extends AbstractProviderInfo {

/**
* Defines an IQ provider which implements the <code>IQProvider</code> interface.
* Defines an IQ provider which implements the {@link IqProvider} interface.
*
* @param elementName Element that provider parses.
* @param namespace Namespace that provider parses.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
Expand All @@ -42,7 +43,7 @@ public class IntrospectionProvider{
*/
// TODO: Remove in Smack 4.6.
@Deprecated
public abstract static class IQIntrospectionProvider<I extends IQ> extends IQProvider<I> {
public abstract static class IQIntrospectionProvider<I extends IQ> extends IqProvider<I> {
private final Class<I> elementClass;

protected IQIntrospectionProvider(Class<I> elementClass) {
Expand All @@ -51,7 +52,7 @@ protected IQIntrospectionProvider(Class<I> elementClass) {

@SuppressWarnings("unchecked")
@Override
public I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
public I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
try {
return (I) parseWithIntrospection(elementClass, parser, initialDepth);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
* abstract class <b>must</b> have a public, no-argument constructor.
*
* @author Matt Tucker
* @deprecated Use {@link IqProvider} instead
*/
public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
@Deprecated
// TODO: Remove in Smack 4.6.
public abstract class LegacyIQProvider<I extends IQ> extends IqProvider<I> {

public final I parse(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException {
return parse(parser, (XmlEnvironment) null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.jivesoftware.smack.xml.XmlPullParser;

/**
* Loads the {@link IQProvider} and {@link ExtensionElementProvider} information from a standard provider file in preparation
* Loads the {@link IqProvider} and {@link ExtensionElementProvider} information from a standard provider file in preparation
* for loading into the {@link ProviderManager}.
*
* @author Robin Collier
Expand Down Expand Up @@ -76,7 +76,7 @@ public ProviderFileLoader(InputStream providerStream, ClassLoader classLoader) {
switch (typeName) {
case "iqProvider":
// Attempt to load the provider class and then create
// a new instance if it's an IQProvider. Otherwise, if it's
// a new instance if it's an IqProvider. Otherwise, if it's
// an IQ class, add the class object itself, then we'll use
// reflection later to create instances of the class.
// Add the provider to the map.
Expand All @@ -85,7 +85,7 @@ public ProviderFileLoader(InputStream providerStream, ClassLoader classLoader) {
iqProviders.add(new IQProviderInfo(elementName, namespace, iqProvider));
}
else {
exceptions.add(new IllegalArgumentException(className + " is not a IQProvider"));
exceptions.add(new IllegalArgumentException(className + " is not a IqProvider"));
}
break;
case "extensionProvider":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
/**
* Manages providers for parsing custom XML sub-documents of XMPP packets. Two types of
* providers exist:<ul>
* <li>IQProvider -- parses IQ requests into Java objects.
* <li>IqProvider -- parses IQ requests into Java objects.
* <li>PacketExtension -- parses XML sub-documents attached to packets into
* PacketExtension instances.</ul>
*
* <b>IQProvider</b><p>
* <b>IqProvider</b><p>
*
* By default, Smack only knows how to process IQ packets with sub-packets that
* are in a few namespaces such as:<ul>
Expand All @@ -63,8 +63,8 @@
*
* Each IQ provider is associated with an element name and a namespace. If multiple provider
* entries attempt to register to handle the same namespace, the first entry loaded from the
* classpath will take precedence. The IQ provider class can either implement the IQProvider
* interface, or extend the IQ class. In the former case, each IQProvider is responsible for
* classpath will take precedence. The IQ provider class can either implement the IqProvider
* interface, or extend the IQ class. In the former case, each IqProvider is responsible for
* parsing the raw XML stream to create an IQ instance. In the latter case, bean introspection
* is used to try to automatically set properties of the IQ instance using the values found
* in the IQ stanza XML. For example, an XMPP time stanza resembles the following:
Expand Down Expand Up @@ -173,11 +173,11 @@ public static IqProvider<IQ> getIQProvider(String elementName, String namespace)
}

/**
* Returns an unmodifiable collection of all IQProvider instances. Each object
* in the collection will either be an IQProvider instance, or a Class object
* that implements the IQProvider interface.
* Returns an unmodifiable collection of all IqProvider instances. Each object
* in the collection will either be an IqProvider instance, or a Class object
* that implements the IqProvider interface.
*
* @return all IQProvider instances.
* @return all IqProvider instances.
*/
public static List<IqProvider<IQ>> getIQProviders() {
List<IqProvider<IQ>> providers = new ArrayList<>(iqProviders.size());
Expand All @@ -186,7 +186,7 @@ public static List<IqProvider<IQ>> getIQProviders() {
}

/**
* Adds an IQ provider (must be an instance of IQProvider or Class object that is an IQ)
* Adds an IQ provider (must be an instance of IqProvider or Class object that is an IQ)
* with the specified element name and name space. The provider will override any providers
* loaded through the classpath.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
*/
package org.jivesoftware.smack.provider;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.FileUtils;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;

import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -60,10 +64,12 @@ public void addClasspathFileLoaderProvider() throws Exception {
Assert.assertNotNull(ProviderManager.getIQProvider("provider", "test:file_provider"));
}

public static class TestIQProvider extends IQProvider<IQ> {
public static class TestIQProvider extends IqProvider<IQ> {

@Override
public IQ parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) {
public IQ parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException {
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@

import static org.junit.Assert.assertTrue;

import java.io.IOException;

import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;

import org.junit.Test;

Expand All @@ -37,10 +42,12 @@ public void shouldInitializeSmackTest() throws Exception {
assertTrue(SmackConfiguration.isSmackInitialized());
}

public static class TestIQProvider extends IQProvider<IQ> {
public static class TestIQProvider extends IqProvider<IQ> {

@Override
public IQ parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) {
public IQ parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException {
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@

import java.io.IOException;

import org.jivesoftware.smack.packet.IqData;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.provider.IqProvider;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;

import org.jivesoftware.smackx.dox.element.DnsIq;

public class DnsIqProvider extends IQProvider<DnsIq> {
public class DnsIqProvider extends IqProvider<DnsIq> {

@Override
public DnsIq parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
public DnsIq parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException {
String base64DnsMessage = parser.nextText();
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
return new DnsIq(base64DnsMessage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.provider.IqProvider;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
Expand All @@ -35,7 +35,7 @@
* @author Andriy Tsykholyas
* @see <a href="http://xmpp.org/extensions/xep-0332.html">XEP-0332: HTTP over XMPP transport</a>
*/
public abstract class AbstractHttpOverXmppProvider<H extends AbstractHttpOverXmpp> extends IQProvider<H> {
public abstract class AbstractHttpOverXmppProvider<H extends AbstractHttpOverXmpp> extends IqProvider<H> {

private static final String ELEMENT_DATA = "data";
private static final String ELEMENT_TEXT = "text";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;

import org.jivesoftware.smack.packet.IqData;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.util.ParserUtils;
Expand All @@ -40,7 +41,7 @@ public class HttpOverXmppReqProvider extends AbstractHttpOverXmppProvider<HttpOv
private static final String ATTRIBUTE_MAX_CHUNK_SIZE = "maxChunkSize";

@Override
public HttpOverXmppReq parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackParsingException {
public HttpOverXmppReq parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackParsingException {
HttpOverXmppReq.Builder builder = HttpOverXmppReq.builder();
builder.setResource(parser.getAttributeValue("", ATTRIBUTE_RESOURCE));
builder.setVersion(parser.getAttributeValue("", ATTRIBUTE_VERSION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;

import org.jivesoftware.smack.packet.IqData;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.xml.XmlPullParser;
Expand All @@ -39,7 +40,7 @@ public class HttpOverXmppRespProvider extends AbstractHttpOverXmppProvider<HttpO
private static final String ATTRIBUTE_STATUS_CODE = "statusCode";

@Override
public HttpOverXmppResp parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackParsingException {
public HttpOverXmppResp parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackParsingException {
String version = parser.getAttributeValue("", ATTRIBUTE_VERSION);
String statusMessage = parser.getAttributeValue("", ATTRIBUTE_STATUS_MESSAGE);
String statusCodeString = parser.getAttributeValue("", ATTRIBUTE_STATUS_CODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
import java.util.HashMap;
import java.util.Map;

import org.jivesoftware.smack.packet.IqData;
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.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
Expand All @@ -38,10 +39,10 @@
* @author Grigory Fedorov
* @see <a href="http://xmpp.org/extensions/xep-0363.html">XEP-0363: HTTP File Upload</a>
*/
public class SlotProvider extends IQProvider<Slot> {
public class SlotProvider extends IqProvider<Slot> {

@Override
public Slot parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
public Slot parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
final String namespace = parser.getNamespace();

final UploadService.Version version = HttpFileUploadManager.namespaceToVersion(namespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import java.util.ArrayList;
import java.util.List;

import org.jivesoftware.smack.packet.IqData;
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.XmlPullParserException;

Expand All @@ -32,10 +33,10 @@
import org.jivesoftware.smackx.iot.control.element.SetIntData;
import org.jivesoftware.smackx.iot.control.element.SetLongData;

public class IoTSetRequestProvider extends IQProvider<IoTSetRequest> {
public class IoTSetRequestProvider extends IqProvider<IoTSetRequest> {

@Override
public IoTSetRequest parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
public IoTSetRequest parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
List<SetData> data = new ArrayList<>(4);
outerloop: while (true) {
final XmlPullParser.Event eventType = parser.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@
*/
package org.jivesoftware.smackx.iot.control.provider;

import java.io.IOException;

import org.jivesoftware.smack.packet.IqData;
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.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;

import org.jivesoftware.smackx.iot.control.element.IoTSetResponse;

public class IoTSetResponseProvider extends IQProvider<IoTSetResponse> {
public class IoTSetResponseProvider extends IqProvider<IoTSetResponse> {

@Override
public IoTSetResponse parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) {
public IoTSetResponse parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException {
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
return new IoTSetResponse();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@

import java.io.IOException;

import org.jivesoftware.smack.packet.IqData;
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.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;

import org.jivesoftware.smackx.iot.data.element.IoTDataReadOutAccepted;

public class IoTDataReadOutAcceptedProvider extends IQProvider<IoTDataReadOutAccepted> {
public class IoTDataReadOutAcceptedProvider extends IqProvider<IoTDataReadOutAccepted> {

@Override
public IoTDataReadOutAccepted parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException {
public IoTDataReadOutAccepted parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws IOException, XmlPullParserException {
int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number");
boolean queued = ParserUtils.getBooleanAttribute(parser, "queued", false);
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
return new IoTDataReadOutAccepted(seqNr, queued);
}

Expand Down

0 comments on commit 093ac94

Please sign in to comment.