- * This does not perform a deep clone, as extension elements are shared between the new and old
- * instance.
- *
- * @return a clone of this message.
- * @deprecated use {@link #asBuilder()} instead.
- */
- // TODO: Remove in Smack 4.5.
- @Deprecated
- @Override
- public Message clone() {
- return new Message(this);
- }
-
/**
* Represents a message subject, its language and the content of the subject.
*/
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/MessageOrPresence.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/MessageOrPresence.java
index f48b794a0..c3aa3d180 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/MessageOrPresence.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/MessageOrPresence.java
@@ -20,11 +20,6 @@ import org.jivesoftware.smack.XMPPConnection;
public abstract class MessageOrPresence> extends Stanza {
- @Deprecated
- // TODO: Remove in Smack 4.5.
- protected MessageOrPresence() {
- }
-
protected MessageOrPresence(StanzaBuilder> stanzaBuilder) {
super(stanzaBuilder);
}
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Nonza.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Nonza.java
index a86a4e1db..ece665543 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Nonza.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Nonza.java
@@ -18,7 +18,7 @@
package org.jivesoftware.smack.packet;
/**
- * A Nonza, i.e everything that is not a stanza as defined
+ * A Nonza, i.e. everything that is not a stanza as defined
* RFC 6120 8. Stanzas are {@link Message}, {@link Presence} and {@link IQ}.
* Everything else should sublcass this class instead of {@link Stanza}.
*
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java
index 3490e1a23..caa3942dc 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2003-2007 Jive Software, 2020-2021 Florian Schmaus.
+ * Copyright 2003-2007 Jive Software, 2020-2024 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,12 +21,9 @@ import java.util.List;
import java.util.Locale;
import org.jivesoftware.smack.XMPPConnection;
-import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder;
-import org.jxmpp.jid.Jid;
-
/**
* Represents XMPP presence stanzas. Every presence stanza has a type, which is one of
* the following values:
@@ -78,55 +75,6 @@ public final class Presence extends MessageOrPresence
private Mode mode = null;
- /**
- * Creates a new presence update. Status, priority, and mode are left un-set.
- *
- * @param type the type.
- * @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public Presence(Type type) {
- // Ensure that the stanza ID is set by calling super().
- super();
- setType(type);
- }
-
- /**
- * Creates a new presence with the given type and using the given XMPP address as recipient.
- *
- * @param to the recipient.
- * @param type the type.
- * @since 4.2
- * @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public Presence(Jid to, Type type) {
- this(type);
- setTo(to);
- }
-
- /**
- * Creates a new presence update with a specified status, priority, and mode.
- *
- * @param type the type.
- * @param status a text message describing the presence update.
- * @param priority the priority of this presence update.
- * @param mode the mode type for this presence update.
- * @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public Presence(Type type, String status, int priority, Mode mode) {
- // Ensure that the stanza ID is set by calling super().
- super();
- setType(type);
- setStatus(status);
- setPriority(priority);
- setMode(mode);
- }
-
Presence(PresenceBuilder presenceBuilder) {
super(presenceBuilder);
type = presenceBuilder.type;
@@ -186,36 +134,11 @@ public final class Presence extends MessageOrPresence
return type;
}
- /**
- * Sets the type of the presence packet.
- *
- * @param type the type of the presence packet.
- * @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public void setType(Type type) {
- this.type = Objects.requireNonNull(type, "Type cannot be null");
- }
-
@Override
public String getStatus() {
return status;
}
- /**
- * Sets the status message of the presence update. The status is free-form text
- * describing a user's presence (i.e., "gone to lunch").
- *
- * @param status the status message.
- * @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public void setStatus(String status) {
- this.status = status;
- }
-
@Override
public int getPriority() {
return getPriorityByte();
@@ -233,20 +156,11 @@ public final class Presence extends MessageOrPresence
* Sets the priority of the presence. The valid range is -128 through 127.
*
* @param priority the priority of the presence.
- * @throws IllegalArgumentException if the priority is outside the valid range.
* @see RFC 6121 § 4.7.2.3. Priority Element
* @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
*/
@Deprecated
- // TODO: Remove in Smack 4.5.
- public void setPriority(int priority) {
- if (priority < -128 || priority > 127) {
- throw new IllegalArgumentException("Priority value " + priority +
- " is not valid. Valid range is -128 through 127.");
- }
- setPriority((byte) priority);
- }
-
+ // TODO: Remove in Smack 4.6.
public void setPriority(byte priority) {
this.priority = priority;
}
@@ -259,19 +173,6 @@ public final class Presence extends MessageOrPresence
return mode;
}
- /**
- * Sets the mode of the presence update. A null presence mode value is interpreted
- * to be the same thing as {@link Presence.Mode#available}.
- *
- * @param mode the mode.
- * @deprecated use {@link PresenceBuilder} or {@link org.jivesoftware.smack.XMPPConnection#getStanzaFactory} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public void setMode(Mode mode) {
- this.mode = mode;
- }
-
@Override
public String getElementName() {
return ELEMENT;
@@ -346,37 +247,6 @@ public final class Presence extends MessageOrPresence
return buf;
}
- /**
- * Creates and returns a copy of this presence stanza.
- *
- * This does not perform a deep clone, as extension elements are shared between the new and old
- * instance.
- *
- * @return a clone of this presence.
- * @deprecated use {@link #asBuilder()} instead.
- */
- // TODO: Remove in Smack 4.5.
- @Deprecated
- @Override
- public Presence clone() {
- return new Presence(this);
- }
-
- /**
- * Clone this presence and set a newly generated stanza ID as the clone's ID.
- *
- * @return a "clone" of this presence with a different stanza ID.
- * @since 4.1.2
- * @deprecated use {@link #asBuilder(XMPPConnection)} or {@link #asBuilder(String)}instead.
- */
- // TODO: Remove in Smack 4.5.
- @Deprecated
- public Presence cloneWithNewId() {
- Presence clone = clone();
- clone.setNewStanzaId();
- return clone;
- }
-
/**
* An enum to represent the presence type. Note that presence type is often confused
* with presence mode. Generally, if a user is signed in to a server, they have a presence
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Session.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Session.java
index 48e0330c6..7e6331bb8 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Session.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Session.java
@@ -39,6 +39,7 @@ public class Session extends SimpleIQ {
public static final String ELEMENT = "session";
public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-session";
+ @SuppressWarnings("this-escape")
public Session() {
super(ELEMENT, NAMESPACE);
setType(IQ.Type.set);
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/StandardExtensionElement.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/StandardExtensionElement.java
index 8ae1f5a7a..9f1959460 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/StandardExtensionElement.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/StandardExtensionElement.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2015-2021 Florian Schmaus.
+ * Copyright 2015-2024 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,9 +53,7 @@ public final class StandardExtensionElement implements XmlElement {
/**
* Constructs a new extension element with the given name and namespace and nothing else.
- *
* This is meant to construct extension elements used as simple flags in Stanzas.
- *
*
* @param name the name of the extension element.
* @param namespace the namespace of the extension element.
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
index 7123e82f8..88c30bbfa 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
@@ -98,7 +98,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
protected Stanza(StanzaBuilder> stanzaBuilder) {
if (stanzaBuilder.stanzaIdSource != null) {
id = stanzaBuilder.stanzaIdSource.getNewStanzaId();
- // Note that some stanza ID sources, e.g. StanzaBuilder.PresenceBuilder.EMPTY return null here. Hence we
+ // Note that some stanza ID sources, e.g. StanzaBuilder.PresenceBuilder.EMPTY return null here. Hence, we
// only check that the returned string is not empty.
assert StringUtils.isNullOrNotEmpty(id);
usedStanzaIdSource = stanzaBuilder.stanzaIdSource;
@@ -159,22 +159,6 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
return id != null;
}
- /**
- * Set the stanza id if none is set.
- *
- * @return the stanza id.
- * @since 4.2
- * @deprecated use {@link StanzaBuilder} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public String setStanzaId() {
- if (!hasStanzaIdSet()) {
- setNewStanzaId();
- }
- return getStanzaId();
- }
-
/**
* Throws an {@link IllegalArgumentException} if this stanza has no stanza ID set.
*
@@ -219,7 +203,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
* @param to who the packet is being sent to.
*/
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
- public void setTo(Jid to) {
+ public final void setTo(Jid to) {
this.to = to;
}
@@ -255,34 +239,11 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
error = stanzaError;
}
- /**
- * Deprecated.
- * @param stanzaError the stanza error.
- * @deprecated use {@link StanzaBuilder} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public void setError(StanzaError.Builder stanzaError) {
- setError(stanzaError.build());
- }
-
@Override
public final String getLanguage() {
return language;
}
- /**
- * Sets the xml:lang of this Stanza.
- *
- * @param language the xml:lang of this Stanza.
- * @deprecated use {@link StanzaBuilder#setLanguage(String)} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public void setLanguage(String language) {
- this.language = language;
- }
-
@Override
public final List getExtensions() {
synchronized (extensionElements) {
@@ -374,22 +335,6 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
return packetExtension;
}
- /**
- * This method is deprecated. Use preferably {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)}.
- *
- * @param the type to cast to.
- * @param elementName the XML element name of the extension. (May be null)
- * @param namespace the XML element namespace of the extension.
- * @return the extension, or null
if it doesn't exist.
- * @deprecated use {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)} instead.
- */
- // TODO: Remove in Smack 4.5.
- @SuppressWarnings("unchecked")
- @Deprecated
- public final E getExtension(String elementName, String namespace) {
- return (E) getExtensionElement(elementName, namespace);
- }
-
@Override
public final XmlElement getExtension(QName qname) {
synchronized (extensionElements) {
@@ -501,27 +446,6 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
}
}
- /**
- * Removes a stanza extension from the packet.
- *
- * @param extension the stanza extension to remove.
- * @return the removed stanza extension or null.
- * @deprecated use {@link StanzaBuilder} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public final XmlElement removeExtension(XmlElement extension) {
- QName key = extension.getQName();
- synchronized (extensionElements) {
- List list = extensionElements.getAll(key);
- boolean removed = list.remove(extension);
- if (removed) {
- return extension;
- }
- }
- return null;
- }
-
/**
* Returns a short String describing the Stanza. This method is suited for log purposes.
*/
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaBuilder.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaBuilder.java
index ec8bdac3c..2cc2a20ed 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaBuilder.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaBuilder.java
@@ -87,9 +87,9 @@ public abstract class StanzaBuilder> implements Stanz
}
/**
- * Set the recipent address of the stanza.
+ * Set the recipient address of the stanza.
*
- * @param to whoe the stanza is being sent to.
+ * @param to whom the stanza is being sent.
* @return a reference to this builder.
* @throws XmppStringprepException if the provided character sequence is not a valid XMPP address.
* @see #to(Jid)
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaView.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaView.java
index 85c4af1a9..e435d7159 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaView.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaView.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2019-2021 Florian Schmaus
+ * Copyright 2019-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public interface StanzaView extends XmlLangElement {
/**
* Returns who the stanza is being sent "to", or null
if
* the value is not set. The XMPP protocol often makes the "to"
- * attribute optional, so it does not always need to be set.
+ * attribute optional, so it does not always need to be set.
*
* @return who the stanza is being sent to, or null
if the
* value has not been set.
@@ -46,7 +46,7 @@ public interface StanzaView extends XmlLangElement {
/**
* Returns who the stanza is being sent "from" or null
if
* the value is not set. The XMPP protocol often makes the "from"
- * attribute optional, so it does not always need to be set.
+ * attribute optional, so it does not always need to be set.
*
* @return who the stanza is being sent from, or null
if the
* value has not been set.
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/StreamError.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/StreamError.java
index f034be9d3..a58599de8 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/StreamError.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/StreamError.java
@@ -58,9 +58,9 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* stream has been authenticated
*
policy-violation | the entity has violated some local service
* policy. |
- * remote-connection-failed | Rthe server is unable to properly connect
+ * |
remote-connection-failed | the server is unable to properly connect
* to a remote entity. |
- * resource-constraint | Rthe server lacks the system resources necessary
+ * |
resource-constraint | the server lacks the system resources necessary
* to service the stream. |
* restricted-xml | the entity has attempted to send restricted XML
* features. |
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/UnparsedIQ.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/UnparsedIQ.java
index e363d2e30..8cd2146f8 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/UnparsedIQ.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/UnparsedIQ.java
@@ -16,6 +16,8 @@
*/
package org.jivesoftware.smack.packet;
+import org.jivesoftware.smack.util.StringUtils;
+
/**
* An IQ stanzas that could not be parsed because no provider was found.
*/
@@ -34,7 +36,12 @@ public class UnparsedIQ extends IQ {
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
- xml.escape(content);
+ if (StringUtils.isEmpty(content)) {
+ xml.setEmptyElement();
+ } else {
+ xml.rightAngleBracket();
+ xml.escape(content);
+ }
return xml;
}
}
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java
index 11da95318..2781fe0d9 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java
@@ -17,9 +17,9 @@
package org.jivesoftware.smack.provider;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -39,11 +39,11 @@ import org.jivesoftware.smack.xml.XmlPullParser;
public class ProviderFileLoader implements ProviderLoader {
private static final Logger LOGGER = Logger.getLogger(ProviderFileLoader.class.getName());
- private final Collection iqProviders = new LinkedList();
- private final Collection extProviders = new LinkedList();
- private final Collection sfProviders = new LinkedList();
+ private final Collection iqProviders = new ArrayList();
+ private final Collection extProviders = new ArrayList();
+ private final Collection sfProviders = new ArrayList();
- private List exceptions = new LinkedList();
+ private List exceptions = new ArrayList();
public ProviderFileLoader(InputStream providerStream) {
this(providerStream, ProviderFileLoader.class.getClassLoader());
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java
index 0943f31d6..b2f08cc3a 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java
@@ -97,6 +97,7 @@ import org.jivesoftware.smack.util.XmppElementUtil;
* </extensionProvider>
* </smackProviders>
*
+ *
* If multiple provider entries attempt to register to handle the same element name and namespace,
* the first entry loaded from the classpath will take precedence. Whenever a stanza extension
* is found in a packet, parsing will be passed to the correct provider. Each provider
@@ -106,7 +107,8 @@ import org.jivesoftware.smack.util.XmppElementUtil;
* set the properties of th class using the values in the stanza extension sub-element. When an
* extension provider is not registered for an element name and namespace combination, Smack will
* store all top-level elements of the sub-packet in DefaultPacketExtension object and then
- * attach it to the packet.
+ * attach it to the packet.
+ *
*
* @author Matt Tucker
*/
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/package-info.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/package-info.java
index 5e40c5639..21fafdfcb 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/provider/package-info.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/package-info.java
@@ -16,7 +16,7 @@
*/
/**
- * The Smack provider architecture is a system for plugging in custom XML parsing of staza extensions
+ * The Smack provider architecture is a system for plugging in custom XML parsing of stanza extensions
* ({@link org.jivesoftware.smack.packet.ExtensionElement}, {@link org.jivesoftware.smack.packet.IQ} stanzas and
* {@link org.jivesoftware.smack.packet.Nonza}. Hence, there are the the following providers:
*
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/HTTPProxySocketConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/HTTPProxySocketConnection.java
index 549406423..bdf0cf390 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/HTTPProxySocketConnection.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/HTTPProxySocketConnection.java
@@ -23,6 +23,7 @@ import java.io.StringReader;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.nio.charset.StandardCharsets;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -58,7 +59,7 @@ class HTTPProxySocketConnection implements ProxySocketConnection {
proxyLine = "\r\nProxy-Authorization: Basic " + Base64.encode(username + ":" + password);
}
socket.getOutputStream().write((hostport + " HTTP/1.1\r\nHost: "
- + host + ":" + port + proxyLine + "\r\n\r\n").getBytes("UTF-8"));
+ + host + ":" + port + proxyLine + "\r\n\r\n").getBytes(StandardCharsets.UTF_8));
InputStream in = socket.getInputStream();
StringBuilder got = new StringBuilder(100);
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyInfo.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyInfo.java
index 402a106a4..90433c5c8 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyInfo.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyInfo.java
@@ -41,6 +41,7 @@ public class ProxyInfo {
private ProxyType proxyType;
private final ProxySocketConnection proxySocketConnection;
+ @SuppressWarnings("this-escape")
public ProxyInfo(ProxyType pType, String pHost, int pPort, String pUser,
String pPass) {
this.proxyType = pType;
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java b/smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java
index f1c00ef19..24330a6ac 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java
@@ -358,7 +358,7 @@ public abstract class SASLMechanism implements Comparable {
* SASLprep the given String. The resulting String is in UTF-8.
*
* @param string the String to sasl prep.
- * @return the given String SASL preped
+ * @return the given String SASL prepped
* @see RFC 4013 - SASLprep: Stringprep Profile for User Names and Passwords
*/
protected static String saslPrep(String string) {
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/sasl/core/ScramMechanism.java b/smack-core/src/main/java/org/jivesoftware/smack/sasl/core/ScramMechanism.java
index 8f4133c81..6dc482ce3 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/sasl/core/ScramMechanism.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/sasl/core/ScramMechanism.java
@@ -271,6 +271,7 @@ public abstract class ScramMechanism extends SASLMechanism {
return null;
}
+ @SuppressWarnings("MixedMutabilityReturnType")
private static Map parseAttributes(String string) throws SmackSaslException {
if (string.length() == 0) {
return Collections.emptyMap();
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/CollectionUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/CollectionUtil.java
index 408e00bfd..c3566c6c0 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/CollectionUtil.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/CollectionUtil.java
@@ -55,6 +55,7 @@ public class CollectionUtil {
boolean test(T t);
}
+ @SuppressWarnings("NonApiType")
public static ArrayList newListWith(Collection extends T> collection) {
if (collection == null) {
return null;
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/LazyStringBuilder.java b/smack-core/src/main/java/org/jivesoftware/smack/util/LazyStringBuilder.java
index 752fda1cf..6e0ded134 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/LazyStringBuilder.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/LazyStringBuilder.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2014-2019 Florian Schmaus
+ * Copyright 2014-2023 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,10 +24,12 @@ public class LazyStringBuilder implements Appendable, CharSequence {
private final List list;
- private String cache;
+ private transient String cache;
+ private int cachedLength = -1;
private void invalidateCache() {
cache = null;
+ cachedLength = -1;
}
public LazyStringBuilder() {
@@ -65,9 +67,10 @@ public class LazyStringBuilder implements Appendable, CharSequence {
@Override
public int length() {
- if (cache != null) {
- return cache.length();
+ if (cachedLength >= 0) {
+ return cachedLength;
}
+
int length = 0;
try {
for (CharSequence csq : list) {
@@ -78,6 +81,8 @@ public class LazyStringBuilder implements Appendable, CharSequence {
StringBuilder sb = safeToStringBuilder();
throw new RuntimeException("The following LazyStringBuilder threw a NullPointerException: " + sb, npe);
}
+
+ cachedLength = length;
return length;
}
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/MAC.java b/smack-core/src/main/java/org/jivesoftware/smack/util/MAC.java
index 4d78d24f8..df177204e 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/MAC.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/MAC.java
@@ -33,7 +33,7 @@ public class MAC {
HMAC_SHA1 = Mac.getInstance(HMACSHA1);
}
catch (NoSuchAlgorithmException e) {
- // Smack wont be able to function normally if this exception is thrown, wrap it into
+ // Smack won't be able to function normally if this exception is thrown, wrap it into
// an ISE and make the user aware of the problem.
throw new IllegalStateException(e);
}
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/MD5.java b/smack-core/src/main/java/org/jivesoftware/smack/util/MD5.java
index 26c0547fd..d81c4de5a 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/MD5.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/MD5.java
@@ -31,7 +31,7 @@ public class MD5 {
MD5_DIGEST = MessageDigest.getInstance(StringUtils.MD5);
}
catch (NoSuchAlgorithmException e) {
- // Smack wont be able to function normally if this exception is thrown, wrap it into
+ // Smack won't be able to function normally if this exception is thrown, wrap it into
// an ISE and make the user aware of the problem.
throw new IllegalStateException(e);
}
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java b/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java
index 852e01bf7..7e9889e57 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2015-2021 Florian Schmaus
+ * Copyright © 2015-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -184,13 +184,14 @@ public class MultiMap {
}
/**
- * Remove the given number of values for a given key. May return less values then requested.
+ * Remove the given number of values for a given key. May return less values than requested.
*
* @param key the key to remove from.
* @param num the number of values to remove.
* @return a list of the removed values.
* @since 4.4.0
*/
+ @SuppressWarnings("MixedMutabilityReturnType")
public List remove(K key, int num) {
List values = map.get(key);
if (values == null) {
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java
index 98635309d..836796248 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2015-2020 Florian Schmaus
+ * Copyright © 2015-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,18 +18,6 @@ package org.jivesoftware.smack.util;
public class NumberUtil {
- /**
- * Checks if the given long is within the range of an unsigned 32-bit integer, the XML type "xs:unsignedInt".
- *
- * @param value TODO javadoc me please
- * @deprecated use {@link #requireUInt32(long)} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public static void checkIfInUInt32Range(long value) {
- requireUInt32(value);
- }
-
/**
* Checks if the given long is within the range of an unsigned 32-bit integer, the XML type "xs:unsignedInt".
*
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
index 042402299..69f0aaca2 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2003-2007 Jive Software, 2019-2023 Florian Schmaus.
+ * Copyright 2003-2007 Jive Software, 2019-2024 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@@ -87,7 +86,7 @@ public class PacketParserUtils {
return parser;
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public static S parseStanza(String stanza) throws XmlPullParserException, SmackParsingException, IOException {
return (S) parseStanza(getParserFor(stanza), XmlEnvironment.EMPTY);
}
@@ -230,7 +229,7 @@ public class PacketParserUtils {
// Assume this is the end tag of the start tag at the
// beginning of this method. Typical examples where this
// happens are body elements containing the empty string,
- // ie. , which appears to be valid XMPP, or a
+ // i.e. , which appears to be valid XMPP, or a
// least it's not explicitly forbidden by RFC 6121 5.2.3
return "";
} else {
@@ -644,7 +643,7 @@ public class PacketParserUtils {
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
String name;
final int initialDepth = parser.getDepth();
- List methods = new LinkedList<>();
+ List methods = new ArrayList<>();
outerloop: while (true) {
XmlPullParser.Event eventType = parser.next();
switch (eventType) {
@@ -850,7 +849,7 @@ public class PacketParserUtils {
throws XmlPullParserException, IOException {
ParserUtils.assertAtStartTag(parser);
assert parser.getNamespace().equals(StartTls.NAMESPACE);
- int initalDepth = parser.getDepth();
+ int initialDepth = parser.getDepth();
boolean required = false;
outerloop: while (true) {
XmlPullParser.Event event = parser.next();
@@ -864,7 +863,7 @@ public class PacketParserUtils {
}
break;
case END_ELEMENT:
- if (parser.getDepth() == initalDepth) {
+ if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketUtil.java
index a68e91dd0..40da6f4d6 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketUtil.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketUtil.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2014-2021 Florian Schmaus
+ * Copyright © 2014-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ public class PacketUtil {
*
* @return the extension element
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public static PE extensionElementFrom(Collection collection,
String element, String namespace) {
for (XmlElement packetExtension : collection) {
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/Pair.java b/smack-core/src/main/java/org/jivesoftware/smack/util/Pair.java
index 08bf41234..13e65e881 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/Pair.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/Pair.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2020 Florian Schmaus.
+ * Copyright 2020-2024 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,11 +26,12 @@ public final class Pair {
this.second = second;
}
- public static Pair create(F first, S second) {
+ public static Pair create(F first, S second) {
return new Pair<>(first, second);
}
- public static Pair createAndInitHashCode(F first, S second) {
+ @SuppressWarnings("ReturnValueIgnored")
+ public static Pair createAndInitHashCode(F first, S second) {
Pair pair = new Pair<>(first, second);
pair.hashCode();
return pair;
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java
index 64c18a7fb..7c58f8a12 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2014-2023 Florian Schmaus
+ * Copyright © 2014-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +23,6 @@ import java.text.ParseException;
import java.util.Date;
import java.util.Locale;
-import javax.xml.namespace.QName;
-
import org.jivesoftware.smack.datatypes.UInt16;
import org.jivesoftware.smack.datatypes.UInt32;
import org.jivesoftware.smack.packet.XmlEnvironment;
@@ -146,7 +144,7 @@ public class ParserUtils {
}
/**
- * Prase a string to a boolean value as per "xs:boolean". Valid input strings are "true", "1" for true, and "false", "0" for false.
+ * Phrase a string to a boolean value as per "xs:boolean". Valid input strings are "true", "1" for true, and "false", "0" for false.
*
* @param booleanString the input string.
* @return the boolean representation of the input string
@@ -367,19 +365,6 @@ public class ParserUtils {
return parser.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang");
}
- /**
- * Get the QName of the current element.
- *
- * @param parser the parser.
- * @return the Qname.
- * @deprecated use {@link XmlPullParser#getQName()} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5
- public static QName getQName(XmlPullParser parser) {
- return parser.getQName();
- }
-
public static InternetAddress getInternetAddressIngoringZoneIdAttribute(XmlPullParser parser, String attribute) {
String inetAddressString = parser.getAttributeValue(attribute);
if (inetAddressString == null) {
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/SHA1.java b/smack-core/src/main/java/org/jivesoftware/smack/util/SHA1.java
index 89144530b..3c7d53ac4 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/SHA1.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/SHA1.java
@@ -31,7 +31,7 @@ public class SHA1 {
SHA1_DIGEST = MessageDigest.getInstance(StringUtils.SHA1);
}
catch (NoSuchAlgorithmException e) {
- // Smack wont be able to function normally if this exception is thrown, wrap it into
+ // Smack won't be able to function normally if this exception is thrown, wrap it into
// an ISE and make the user aware of the problem.
throw new IllegalStateException(e);
}
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/SecurityUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/SecurityUtil.java
index 3521279df..c796ab23e 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/SecurityUtil.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/SecurityUtil.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2019 Florian Schmaus.
+ * Copyright 2019-2024 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ public class SecurityUtil {
private static final LruCache, Void> INSERTED_PROVIDERS_CACHE = new LruCache<>(8);
+ @SuppressWarnings("LockOnNonEnclosingClassLiteral")
public static void ensureProviderAtFirstPosition(Class extends Provider> providerClass) {
if (INSERTED_PROVIDERS_CACHE.containsKey(providerClass)) {
return;
@@ -41,7 +42,7 @@ public class SecurityUtil {
String providerName = provider.getName();
- int installedPosition ;
+ int installedPosition;
synchronized (Security.class) {
Security.removeProvider(providerName);
installedPosition = Security.insertProviderAt(provider, 1);
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java
index 5ebe4c116..83c9f40bb 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2003-2007 Jive Software, 2016-2021 Florian Schmaus.
+ * Copyright 2003-2007 Jive Software, 2016-2024 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,24 +36,6 @@ public class StringUtils {
public static final String MD5 = "MD5";
public static final String SHA1 = "SHA-1";
- /**
- * Deprecated, do not use.
- *
- * @deprecated use StandardCharsets.UTF_8 instead.
- */
- // TODO: Remove in Smack 4.5.
- @Deprecated
- public static final String UTF8 = "UTF-8";
-
- /**
- * Deprecated, do not use.
- *
- * @deprecated use StandardCharsets.US_ASCII instead.
- */
- // TODO: Remove in Smack 4.5.
- @Deprecated
- public static final String USASCII = "US-ASCII";
-
public static final String QUOTE_ENCODE = """;
public static final String APOS_ENCODE = "'";
public static final String AMP_ENCODE = "&";
@@ -343,11 +325,14 @@ public class StringUtils {
try {
randomString(charBuffer, random, alphabet, numRandomChars);
} catch (IOException e) {
- // This should never happen if we calcuate the buffer size correctly.
+ // This should never happen if we calculate the buffer size correctly.
throw new AssertionError(e);
}
- return charBuffer.flip().toString();
+ // Workaround for Android API not matching Java >=9 API.
+ // See https://issuetracker.google.com/issues/369219141
+ ((java.nio.Buffer) charBuffer).flip();
+ return charBuffer.toString();
}
private static void randomString(Appendable appendable, Random random, char[] alphabet, int numRandomChars)
@@ -479,7 +464,7 @@ public class StringUtils {
appendTo(collection, ", ", sb);
}
- public static void appendTo(Collection collection, StringBuilder sb,
+ public static void appendTo(Collection collection, StringBuilder sb,
Consumer appendFunction) {
appendTo(collection, ", ", sb, appendFunction);
}
@@ -488,7 +473,7 @@ public class StringUtils {
appendTo(collection, delimiter, sb, o -> sb.append(o));
}
- public static void appendTo(Collection collection, String delimiter, StringBuilder sb,
+ public static void appendTo(Collection collection, String delimiter, StringBuilder sb,
Consumer appendFunction) {
for (Iterator it = collection.iterator(); it.hasNext();) {
O cs = it.next();
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/TLSUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/TLSUtils.java
index c1af8ba61..47469f721 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/TLSUtils.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/TLSUtils.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2014-2020 Florian Schmaus
+ * Copyright 2014-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,52 +68,6 @@ public class TLSUtils {
return builder;
}
- /**
- * Enable only TLS. Connections created with the given ConnectionConfiguration will only support TLS.
- *
- * According to the Encrypted
- * XMPP Manifesto, TLSv1.2 shall be deployed, providing fallback support for SSLv3 and
- * TLSv1.1. This method goes one step beyond and upgrades the handshake to use TLSv1 or better.
- * This method requires the underlying OS to support all of TLSv1.2 , 1.1 and 1.0.
- *
- *
- * @param builder the configuration builder to apply this setting to
- * @param Type of the ConnectionConfiguration builder.
- *
- * @return the given builder
- * @deprecated use {@link #setEnabledTlsProtocolsToRecommended(org.jivesoftware.smack.ConnectionConfiguration.Builder)} instead.
- */
- // TODO: Remove in Smack 4.5.
- @Deprecated
- public static > B setTLSOnly(B builder) {
- builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1 });
- return builder;
- }
-
- /**
- * Enable only TLS and SSLv3. Connections created with the given ConnectionConfiguration will
- * only support TLS and SSLv3.
- *
- * According to the Encrypted
- * XMPP Manifesto, TLSv1.2 shall be deployed, providing fallback support for SSLv3 and
- * TLSv1.1.
- *
- *
- * @param builder the configuration builder to apply this setting to
- * @param Type of the ConnectionConfiguration builder.
- *
- * @return the given builder
- * @deprecated use {@link #setEnabledTlsProtocolsToRecommended(org.jivesoftware.smack.ConnectionConfiguration.Builder)} instead.
- */
- // TODO: Remove in Smack 4.5.
- @Deprecated
- public static > B setSSLv3AndTLSOnly(B builder) {
- builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1, PROTO_SSL3 });
- return builder;
- }
-
/**
* Accept all TLS certificates.
*
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java b/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java
index 21b192b4c..5c327157b 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2014-2021 Florian Schmaus
+ * Copyright 2014-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
+import org.jxmpp.jid.Jid;
import org.jxmpp.util.XmppDateTime;
public class XmlStringBuilder implements Appendable, CharSequence, Element {
@@ -46,6 +47,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
this(pe, null);
}
+ @SuppressWarnings("this-escape")
public XmlStringBuilder(NamedElement e) {
this();
halfOpenElement(e.getElementName());
@@ -55,6 +57,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
this(element.getElementName(), element.getNamespace(), element.getLanguage(), enclosingXmlEnvironment);
}
+ @SuppressWarnings("this-escape")
public XmlStringBuilder(String elementName, String xmlNs, String xmlLang, XmlEnvironment enclosingXmlEnvironment) {
sb = new LazyStringBuilder();
halfOpenElement(elementName);
@@ -137,20 +140,6 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
return this;
}
- /**
- * Deprecated.
- *
- * @param element deprecated.
- * @return deprecated.
- * @deprecated use {@link #append(Element)} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public XmlStringBuilder element(Element element) {
- assert element != null;
- return append(element.toXML());
- }
-
public XmlStringBuilder optElement(String name, String content) {
if (content != null) {
element(name, content);
@@ -311,6 +300,18 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
return attribute(name, String.valueOf(value));
}
+ public XmlStringBuilder jidAttribute(Jid jid) {
+ assert jid != null;
+ return attribute("jid", jid);
+ }
+
+ public XmlStringBuilder optJidAttribute(Jid jid) {
+ if (jid != null) {
+ attribute("jid", jid);
+ }
+ return this;
+ }
+
public XmlStringBuilder optAttribute(String name, String value) {
if (value != null) {
attribute(name, value);
@@ -593,10 +594,49 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
return this;
}
+ enum AppendApproach {
+ /**
+ * Simply add the given CharSequence to this builder.
+ */
+ SINGLE,
+
+ /**
+ * If the given CharSequence is a {@link XmlStringBuilder} or {@link LazyStringBuilder}, then copy the
+ * references of the lazy strings parts into this builder. This approach flattens the string builders into one,
+ * yielding a different performance characteristic.
+ */
+ FLAT,
+ }
+
+ private static AppendApproach APPEND_APPROACH = AppendApproach.SINGLE;
+
+ /**
+ * Set the builders approach on how to append new char sequences.
+ *
+ * @param appendApproach the append approach.
+ */
+ public static void setAppendMethod(AppendApproach appendApproach) {
+ Objects.requireNonNull(appendApproach);
+ APPEND_APPROACH = appendApproach;
+ }
+
@Override
public XmlStringBuilder append(CharSequence csq) {
assert csq != null;
- sb.append(csq);
+ switch (APPEND_APPROACH) {
+ case SINGLE:
+ sb.append(csq);
+ break;
+ case FLAT:
+ if (csq instanceof XmlStringBuilder) {
+ sb.append(((XmlStringBuilder) csq).sb);
+ } else if (csq instanceof LazyStringBuilder) {
+ sb.append((LazyStringBuilder) csq);
+ } else {
+ sb.append(csq);
+ }
+ break;
+ }
return this;
}
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/XmppElementUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/XmppElementUtil.java
index 5639a7e5f..7ffe2f2eb 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/XmppElementUtil.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/XmppElementUtil.java
@@ -71,6 +71,7 @@ public class XmppElementUtil {
return qname;
}
+ @SuppressWarnings("MixedMutabilityReturnType")
public static List getElementsFrom(
MultiMap elementMap, Class extensionElementClass) {
QName qname = XmppElementUtil.getQNameFor(extensionElementClass);
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/dns/package-info.java b/smack-core/src/main/java/org/jivesoftware/smack/util/dns/package-info.java
index f06cdab84..1fb7e9b3b 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/util/dns/package-info.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/util/dns/package-info.java
@@ -61,8 +61,8 @@
*
* Best Practices
*
- * We recommend that applications using Smack's DNSSEC API do not ask the user if DNSSEC is avaialble. Instead they
- * should check for DNSSEC suport on every connection attempt. Once DNSSEC support has been discovered, the application
+ * We recommend that applications using Smack's DNSSEC API do not ask the user if DNSSEC is available. Instead they
+ * should check for DNSSEC support on every connection attempt. Once DNSSEC support has been discovered, the application
* should use the `needsDnssec` mode for all future connection attempts. The same scheme can be applied when using DANE.
* This approach is similar to the scheme established by to HTTP Strict
* Transport Security" (HSTS, RFC 6797.
diff --git a/smack-core/src/test/java/org/jivesoftware/smack/packet/IqTest.java b/smack-core/src/test/java/org/jivesoftware/smack/packet/IqTest.java
index b8f192bd7..2101daca4 100644
--- a/smack-core/src/test/java/org/jivesoftware/smack/packet/IqTest.java
+++ b/smack-core/src/test/java/org/jivesoftware/smack/packet/IqTest.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2023 Florian Schmaus
+ * Copyright © 2023-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,13 @@ package org.jivesoftware.smack.packet;
import static org.jivesoftware.smack.test.util.XmlAssertUtil.assertXmlSimilar;
+import org.jivesoftware.smack.test.util.SmackTestUtil;
+import org.jivesoftware.smack.util.PacketParserUtils;
+import org.jivesoftware.smack.xml.XmlPullParser;
+
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
public class IqTest {
@@ -35,4 +41,36 @@ public class IqTest {
assertXmlSimilar(expected, errorIq.toXML());
}
+ @ParameterizedTest
+ @EnumSource(SmackTestUtil.XmlPullParserKind.class)
+ public void testIqWithXmlns(SmackTestUtil.XmlPullParserKind parserKind) throws Exception {
+ final String iqXml = "" +
+ "" +
+ "foo@tigase.mydomain.org/myresource" +
+ "" +
+ "";
+ final String xml =
+ "" +
+ iqXml +
+ "";
+
+ XmlPullParser parser = SmackTestUtil.getParserFor(xml, "iq", parserKind);
+ IQ iq = PacketParserUtils.parseIQ(parser);
+ assertXmlSimilar(iqXml, iq.toXML());
+ }
+
+ @ParameterizedTest
+ @EnumSource(SmackTestUtil.XmlPullParserKind.class)
+ public void testUnparsedIq(SmackTestUtil.XmlPullParserKind parserKind) throws Exception {
+ final String iqXml = "" +
+ "" +
+ "";
+ final String expected = ""
+ + "<query xmlns='jabber:iq:version'/>"
+ + "";
+
+ XmlPullParser parser = SmackTestUtil.getParserFor(iqXml, "iq", parserKind);
+ IQ iq = PacketParserUtils.parseIQ(parser);
+ assertXmlSimilar(expected, iq.toXML());
+ }
}
diff --git a/smack-core/src/testFixtures/java/org/jivesoftware/smack/DummyConnection.java b/smack-core/src/testFixtures/java/org/jivesoftware/smack/DummyConnection.java
index 7e105d58b..320bb1f9e 100644
--- a/smack-core/src/testFixtures/java/org/jivesoftware/smack/DummyConnection.java
+++ b/smack-core/src/testFixtures/java/org/jivesoftware/smack/DummyConnection.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2010 Jive Software, 2022 Florian Schmaus.
+ * Copyright 2010 Jive Software, 2022-2024 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,9 +39,9 @@ import org.jxmpp.stringprep.XmppStringprepException;
* A dummy implementation of {@link XMPPConnection}, intended to be used during
* unit tests.
*
- * Instances store any packets that are delivered to be send using the
+ * Instances store any packets that are delivered to be sent using the
* {@link #sendStanza(Stanza)} method in a blocking queue. The content of this queue
- * can be inspected using {@link #getSentPacket()}. Typically these queues are
+ * can be inspected using {@link #getSentPacket()}. Typically, these queues are
* used to retrieve a message that was generated by the client.
*
* Packets that should be processed by the client to simulate a received stanza
@@ -82,6 +82,7 @@ public class DummyConnection extends AbstractXMPPConnection {
}
}
+ @SuppressWarnings("this-escape")
public DummyConnection(DummyConnectionConfiguration configuration) {
super(configuration);
@@ -91,6 +92,7 @@ public class DummyConnection extends AbstractXMPPConnection {
user = getUserJid();
}
+ @SuppressWarnings("JavaUtilDate")
@Override
protected void connectInternal() {
connected = true;
@@ -162,6 +164,7 @@ public class DummyConnection extends AbstractXMPPConnection {
* @param
the top level stream element class.
* @return a sent packet.
*/
+ @SuppressWarnings("TypeParameterUnusedInFormals")
public
P getSentPacket() {
return getSentPacket(5 * 60);
}
@@ -176,7 +179,7 @@ public class DummyConnection extends AbstractXMPPConnection {
* @param
the top level stream element class.
* @return a sent packet.
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public
P getSentPacket(int wait) {
try {
return (P) queue.poll(wait, TimeUnit.SECONDS);
diff --git a/smack-core/src/testFixtures/java/org/jivesoftware/smack/test/util/MemoryLeakTestUtil.java b/smack-core/src/testFixtures/java/org/jivesoftware/smack/test/util/MemoryLeakTestUtil.java
index 6746e8f13..1eccfd75a 100644
--- a/smack-core/src/testFixtures/java/org/jivesoftware/smack/test/util/MemoryLeakTestUtil.java
+++ b/smack-core/src/testFixtures/java/org/jivesoftware/smack/test/util/MemoryLeakTestUtil.java
@@ -41,7 +41,7 @@ import org.jxmpp.stringprep.XmppStringprepException;
* Note that this test is based on the assumption that it is possible to trigger a full garbage collection run, which is
* not the case. See also this
* stackoverflow
- * question. Hence the {@link #triggerGarbageCollection()} method defined in this class is not portable and depends
+ * question. Hence, the {@link #triggerGarbageCollection()} method defined in this class is not portable and depends
* on implementation depended Java Virtual Machine behavior.
*
*
diff --git a/smack-debug-slf4j/build.gradle b/smack-debug-slf4j/build.gradle
index 9c2272729..71eae05b4 100644
--- a/smack-debug-slf4j/build.gradle
+++ b/smack-debug-slf4j/build.gradle
@@ -1,3 +1,7 @@
+plugins {
+ id 'org.igniterealtime.smack.java-common-conventions'
+}
+
description = """\
Smack slf4j debugger.
Inspect the exchanged XMPP stanzas.
@@ -5,5 +9,5 @@ Connect your favourite slf4j backend of choice to get output inside of it"""
dependencies {
api project(':smack-core')
- implementation 'org.slf4j:slf4j-api:[1.7,1.8)'
+ implementation 'org.slf4j:slf4j-api:[1.7,2.0)'
}
diff --git a/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/package-info.java b/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/package-info.java
index 7ebe86244..bce3b6064 120000
--- a/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/package-info.java
+++ b/smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/package-info.java
@@ -1 +1 @@
-../../../../../../../smack-java8-full/src/main/java/org/jivesoftware/smackx/package-info.java
\ No newline at end of file
+../../../../../../../smack-java11-full/src/main/java/org/jivesoftware/smackx/package-info.java
\ No newline at end of file
diff --git a/smack-debug/build.gradle b/smack-debug/build.gradle
index 959caff4f..7c9fdc0f1 100644
--- a/smack-debug/build.gradle
+++ b/smack-debug/build.gradle
@@ -1,3 +1,7 @@
+plugins {
+ id 'org.igniterealtime.smack.java-common-conventions'
+}
+
description = """\
Smack GUI debugger.
Inspect the exchanged XMPP stanzas."""
diff --git a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
index 40d2e5263..e57b4aaaa 100644
--- a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
+++ b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
@@ -160,6 +160,7 @@ public class EnhancedDebugger extends SmackDebugger {
private ReaderListener readerListener;
private WriterListener writerListener;
+ @SuppressWarnings("JavaUtilDate")
private Date creationTime = new Date();
// Statistics variables
@@ -177,6 +178,7 @@ public class EnhancedDebugger extends SmackDebugger {
JTabbedPane tabbedPane;
+ @SuppressWarnings("this-escape")
public EnhancedDebugger(XMPPConnection connection) {
super(connection);
@@ -756,6 +758,7 @@ public class EnhancedDebugger extends SmackDebugger {
* @param dateFormatter the SimpleDateFormat to use to format Dates
* @param packet the read stanza to add to the table
*/
+ @SuppressWarnings("JavaUtilDate")
private void addReadPacketToTable(final SimpleDateFormat dateFormatter, final TopLevelStreamElement packet) {
SwingUtilities.invokeLater(new Runnable() {
@Override
@@ -827,6 +830,7 @@ public class EnhancedDebugger extends SmackDebugger {
* @param dateFormatter the SimpleDateFormat to use to format Dates
* @param packet the sent stanza to add to the table
*/
+ @SuppressWarnings("JavaUtilDate")
private void addSentPacketToTable(final SimpleDateFormat dateFormatter, final TopLevelStreamElement packet) {
SwingUtilities.invokeLater(new Runnable() {
@Override
diff --git a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java
index 5755207d8..cadcb0b53 100644
--- a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java
+++ b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java
@@ -204,7 +204,7 @@ public final class EnhancedDebuggerWindow {
* Creates the main debug window that provides information about Smack and also shows
* a tab panel for each connection that is being debugged.
*/
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({ "rawtypes", "unchecked", "JdkObsolete" })
private void createDebug() {
frame = new JFrame("Smack Debug Window");
diff --git a/smack-debug/src/main/java/org/jivesoftware/smackx/package-info.java b/smack-debug/src/main/java/org/jivesoftware/smackx/package-info.java
index 7ebe86244..bce3b6064 120000
--- a/smack-debug/src/main/java/org/jivesoftware/smackx/package-info.java
+++ b/smack-debug/src/main/java/org/jivesoftware/smackx/package-info.java
@@ -1 +1 @@
-../../../../../../../smack-java8-full/src/main/java/org/jivesoftware/smackx/package-info.java
\ No newline at end of file
+../../../../../../../smack-java11-full/src/main/java/org/jivesoftware/smackx/package-info.java
\ No newline at end of file
diff --git a/smack-examples/build.gradle b/smack-examples/build.gradle
new file mode 100644
index 000000000..244040dd7
--- /dev/null
+++ b/smack-examples/build.gradle
@@ -0,0 +1,14 @@
+plugins {
+ id 'org.igniterealtime.smack.java-common-conventions'
+}
+
+description = """\
+Examples and test applications for Smack"""
+
+dependencies {
+ // Smack's integration test framework (sintest) depends on
+ // smack-java*-full and since we may want to use parts of sinttest
+ // in smack-examples, we simply depend sinttest.
+ api project(':smack-integration-test')
+ api project(':smack-omemo-signal')
+}
diff --git a/smack-java8-full/src/main/java/org/jivesoftware/smack/full/BoshConnectionTest.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/BoshConnectionTest.java
similarity index 65%
rename from smack-java8-full/src/main/java/org/jivesoftware/smack/full/BoshConnectionTest.java
rename to smack-examples/src/main/java/org/igniterealtime/smack/examples/BoshConnectionTest.java
index 4063c72ff..3d18c7365 100644
--- a/smack-java8-full/src/main/java/org/jivesoftware/smack/full/BoshConnectionTest.java
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/BoshConnectionTest.java
@@ -2,19 +2,23 @@
*
* Copyright 2022 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
+ * This file is part of smack-examples.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * smack-examples is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
*
- * 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.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.jivesoftware.smack.full;
+package org.igniterealtime.smack.examples;
import java.io.IOException;
diff --git a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/DoX.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/DoX.java
similarity index 94%
rename from smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/DoX.java
rename to smack-examples/src/main/java/org/igniterealtime/smack/examples/DoX.java
index 093a5aea9..cd3745437 100644
--- a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/DoX.java
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/DoX.java
@@ -2,9 +2,9 @@
*
* Copyright 2019 Florian Schmaus
*
- * This file is part of smack-repl.
+ * This file is part of smack-examples.
*
- * smack-repl is free software; you can redistribute it and/or modify
+ * smack-examples is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.igniterealtime.smack.smackrepl;
+package org.igniterealtime.smack.examples;
import java.io.IOException;
diff --git a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/IoT.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/IoT.java
similarity index 98%
rename from smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/IoT.java
rename to smack-examples/src/main/java/org/igniterealtime/smack/examples/IoT.java
index 66a968c31..12c74fb2a 100644
--- a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/IoT.java
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/IoT.java
@@ -2,9 +2,9 @@
*
* Copyright 2016 Florian Schmaus
*
- * This file is part of smack-repl.
+ * This file is part of smack-examples.
*
- * smack-repl is free software; you can redistribute it and/or modify
+ * smack-examples is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.igniterealtime.smack.smackrepl;
+package org.igniterealtime.smack.examples;
import java.util.Collections;
import java.util.List;
diff --git a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/Nio.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/Nio.java
similarity index 96%
rename from smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/Nio.java
rename to smack-examples/src/main/java/org/igniterealtime/smack/examples/Nio.java
index 09d296bb5..81ef164cb 100644
--- a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/Nio.java
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/Nio.java
@@ -2,9 +2,9 @@
*
* Copyright 2018-2021 Florian Schmaus
*
- * This file is part of smack-repl.
+ * This file is part of smack-examples.
*
- * smack-repl is free software; you can redistribute it and/or modify
+ * smack-examples is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.igniterealtime.smack.smackrepl;
+package org.igniterealtime.smack.examples;
import java.io.BufferedWriter;
import java.io.IOException;
diff --git a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/OmemoClient.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/OmemoClient.java
similarity index 97%
rename from smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/OmemoClient.java
rename to smack-examples/src/main/java/org/igniterealtime/smack/examples/OmemoClient.java
index dc4b343e6..9c8652107 100644
--- a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/OmemoClient.java
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/OmemoClient.java
@@ -2,9 +2,9 @@
*
* Copyright 2019 Paul Schaub
*
- * This file is part of smack-repl.
+ * This file is part of smack-examples.
*
- * smack-repl is free software; you can redistribute it and/or modify
+ * smack-examples is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.igniterealtime.smack.smackrepl;
+package org.igniterealtime.smack.examples;
import java.io.IOException;
import java.nio.file.Files;
@@ -185,7 +185,7 @@ public class OmemoClient {
BareJid contact = JidCreate.bareFrom(com[1]);
- HashMap devices;
+ Map devices;
try {
devices = omemoManager.getActiveFingerprints(contact);
} catch (CorruptedOmemoKeyException | CannotEstablishOmemoSessionException | SmackException.NoResponseException e) {
diff --git a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/TlsTest.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/TlsTest.java
similarity index 96%
rename from smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/TlsTest.java
rename to smack-examples/src/main/java/org/igniterealtime/smack/examples/TlsTest.java
index 08bd25b6d..0e924fa9a 100644
--- a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/TlsTest.java
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/TlsTest.java
@@ -2,9 +2,9 @@
*
* Copyright 2016 Florian Schmaus
*
- * This file is part of smack-repl.
+ * This file is part of smack-examples.
*
- * smack-repl is free software; you can redistribute it and/or modify
+ * smack-examples is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.igniterealtime.smack.smackrepl;
+package org.igniterealtime.smack.examples;
import java.io.IOException;
import java.security.KeyManagementException;
diff --git a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebSocketConnection.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/WebSocketConnection.java
similarity index 95%
rename from smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebSocketConnection.java
rename to smack-examples/src/main/java/org/igniterealtime/smack/examples/WebSocketConnection.java
index f693fb739..9e4e5856f 100644
--- a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebSocketConnection.java
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/WebSocketConnection.java
@@ -2,9 +2,9 @@
*
* Copyright 2021 Florian Schmaus
*
- * This file is part of smack-repl.
+ * This file is part of smack-examples.
*
- * smack-repl is free software; you can redistribute it and/or modify
+ * smack-examples is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.igniterealtime.smack.smackrepl;
+package org.igniterealtime.smack.examples;
import java.io.IOException;
import java.net.URISyntaxException;
diff --git a/smack-examples/src/main/java/org/igniterealtime/smack/examples/XmlStringBuilderTest.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/XmlStringBuilderTest.java
new file mode 100644
index 000000000..b02e5cf81
--- /dev/null
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/XmlStringBuilderTest.java
@@ -0,0 +1,118 @@
+/**
+ *
+ * Copyright 2023 Florian Schmaus
+ *
+ * This file is part of smack-examples.
+ *
+ * smack-examples is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.igniterealtime.smack.examples;
+
+import java.util.function.Supplier;
+
+import org.jivesoftware.smack.util.XmlStringBuilder;
+
+public class XmlStringBuilderTest {
+ static int COUNT_OUTER = 500;
+ static int COUNT_INNER = 50;
+
+ public static void main(String[] args) throws Exception {
+ test1();
+ test2();
+ test3();
+ }
+
+ public static void test1() throws Exception {
+ // CHECKSTYLE:OFF
+ System.out.println("Test 1");
+ // CHECKSTYLE:ON
+ XmlStringBuilder parent = new XmlStringBuilder();
+ XmlStringBuilder child = new XmlStringBuilder();
+ XmlStringBuilder child2 = new XmlStringBuilder();
+
+ for (int i = 1; i < COUNT_OUTER; i++) {
+ XmlStringBuilder cs = new XmlStringBuilder();
+ for (int j = 0; j < COUNT_INNER; j++) {
+ cs.append("abc");
+ }
+ child2.append((CharSequence) cs);
+ }
+
+ child.append((CharSequence) child2);
+ parent.append((CharSequence) child);
+
+ time("test1: parent", () -> "len=" + parent.toString().length());
+ time("test1: child", () -> "len=" + child.toString().length());
+ time("test1: child2", () -> "len=" + child2.toString().length());
+ }
+
+ public static void test2() throws Exception {
+ // CHECKSTYLE:OFF
+ System.out.println("Test 2: evaluate children first");
+ // CHECKSTYLE:ON
+ XmlStringBuilder parent = new XmlStringBuilder();
+ XmlStringBuilder child = new XmlStringBuilder();
+ XmlStringBuilder child2 = new XmlStringBuilder();
+
+ for (int i = 1; i < COUNT_OUTER; i++) {
+ XmlStringBuilder cs = new XmlStringBuilder();
+ for (int j = 0; j < COUNT_INNER; j++) {
+ cs.append("abc");
+ }
+ child2.append((CharSequence) cs);
+ }
+
+ child.append((CharSequence) child2);
+ parent.append((CharSequence) child);
+
+ time("test2: child2", () -> "len=" + child2.toString().length());
+ time("test2: child", () -> "len=" + child.toString().length());
+ time("test2: parent", () -> "len=" + parent.toString().length());
+ }
+
+ public static void test3() throws Exception {
+ // CHECKSTYLE:OFF
+ System.out.println("Test 3: use append(XmlStringBuilder)");
+ // CHECKSTYLE:ON
+ XmlStringBuilder parent = new XmlStringBuilder();
+ XmlStringBuilder child = new XmlStringBuilder();
+ XmlStringBuilder child2 = new XmlStringBuilder();
+
+ for (int i = 1; i < COUNT_OUTER; i++) {
+ XmlStringBuilder cs = new XmlStringBuilder();
+ for (int j = 0; j < COUNT_INNER; j++) {
+ cs.append("abc");
+ }
+ child2.append(cs);
+ }
+
+ child.append(child2);
+ parent.append(child);
+
+ time("test3: parent", () -> "len=" + parent.toString().length());
+ time("test3: child", () -> "len=" + child.toString().length());
+ time("test3: child2", () -> "len=" + child2.toString().length());
+ }
+
+ static void time(String name, Supplier block) {
+ long start = System.currentTimeMillis();
+ String result = block.get();
+ long end = System.currentTimeMillis();
+
+ // CHECKSTYLE:OFF
+ System.out.println(name + " took " + (end - start) + "ms: " + result);
+ // CHECKSTYLE:ONy
+ }
+}
diff --git a/smack-examples/src/main/java/org/igniterealtime/smack/examples/XmppConnectionTool.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/XmppConnectionTool.java
new file mode 100644
index 000000000..c44adb157
--- /dev/null
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/XmppConnectionTool.java
@@ -0,0 +1,82 @@
+/**
+ *
+ * Copyright 2024 Florian Schmaus.
+ *
+ * This file is part of smack-examples.
+ *
+ * smack-examples is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.igniterealtime.smack.examples;
+
+import java.io.IOException;
+
+import org.jivesoftware.smack.SmackException;
+import org.jivesoftware.smack.SmackException.NoResponseException;
+import org.jivesoftware.smack.SmackException.NotConnectedException;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.XMPPException.XMPPErrorException;
+import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection;
+import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionConfiguration;
+import org.jivesoftware.smack.debugger.ConsoleDebugger;
+import org.jivesoftware.smack.debugger.SmackDebuggerFactory;
+import org.jivesoftware.smackx.omemo.util.OmemoConstants;
+import org.jivesoftware.smackx.pep.PepManager;
+import org.jivesoftware.smackx.pubsub.PubSubManager;
+
+import org.jxmpp.stringprep.XmppStringprepException;
+
+public class XmppConnectionTool {
+
+ public final ModularXmppClientToServerConnection connection;
+
+ public XmppConnectionTool(ModularXmppClientToServerConnection connection) {
+ this.connection = connection;
+ }
+
+ public boolean purgeOmemoInformation()
+ throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
+ PepManager pepManager = PepManager.getInstanceFor(connection);
+ PubSubManager pepPubSubManager = pepManager.getPepPubSubManager();
+
+ // TODO: Also delete "bundles" nodes.
+ return pepPubSubManager.deleteNode(OmemoConstants.PEP_NODE_DEVICE_LIST);
+ }
+
+ public static XmppConnectionTool of(String jid, String password, boolean debug)
+ throws XMPPException, SmackException, IOException, InterruptedException {
+ ModularXmppClientToServerConnection connection = createConnectionFor(jid, password, debug);
+ connection.connect().login();
+ return new XmppConnectionTool(connection);
+ }
+
+ public static ModularXmppClientToServerConnection createConnectionFor(String jid, String password, boolean debug)
+ throws XmppStringprepException {
+
+ final SmackDebuggerFactory smackDebuggerFactory;
+ if (debug) {
+ smackDebuggerFactory = ConsoleDebugger.Factory.INSTANCE;
+ } else {
+ smackDebuggerFactory = null;
+ }
+
+ ModularXmppClientToServerConnectionConfiguration.Builder configurationBuilder = ModularXmppClientToServerConnectionConfiguration
+ .builder().setXmppAddressAndPassword(jid, password).setDebuggerFactory(smackDebuggerFactory);
+
+ ModularXmppClientToServerConnectionConfiguration configuration = configurationBuilder.build();
+
+ ModularXmppClientToServerConnection connection = new ModularXmppClientToServerConnection(configuration);
+ return connection;
+ }
+}
diff --git a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/XmppTools.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/XmppTools.java
similarity index 96%
rename from smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/XmppTools.java
rename to smack-examples/src/main/java/org/igniterealtime/smack/examples/XmppTools.java
index eeb6c7a40..70bb9f1f2 100644
--- a/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/XmppTools.java
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/XmppTools.java
@@ -1,10 +1,10 @@
/**
*
- * Copyright 2016-2021 Florian Schmaus
+ * Copyright 2016-2024 Florian Schmaus
*
- * This file is part of smack-repl.
+ * This file is part of smack-examples.
*
- * smack-repl is free software; you can redistribute it and/or modify
+ * smack-examples is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.igniterealtime.smack.smackrepl;
+package org.igniterealtime.smack.examples;
import java.io.IOException;
import java.security.KeyManagementException;
@@ -136,6 +136,7 @@ public class XmppTools {
// CHECKSTYLE:ON
}
+ @SuppressWarnings("JavaUtilDate")
public static void sendItsAlive(String to, XMPPConnection connection)
throws XmppStringprepException, NotConnectedException, InterruptedException {
if (to == null) {
diff --git a/smack-examples/src/main/java/org/igniterealtime/smack/examples/package-info.java b/smack-examples/src/main/java/org/igniterealtime/smack/examples/package-info.java
new file mode 100644
index 000000000..ed3cf17e7
--- /dev/null
+++ b/smack-examples/src/main/java/org/igniterealtime/smack/examples/package-info.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2023 Florian Schmaus
+ *
+ * This file is part of smack-examples.
+ *
+ * smack-examples is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * Examples and tests for Smack.
+ */
+package org.igniterealtime.smack.examples;
diff --git a/smack-examples/src/test/java/org/igniterealtime/smack/examples/SmackExamplesTest.java b/smack-examples/src/test/java/org/igniterealtime/smack/examples/SmackExamplesTest.java
new file mode 100644
index 000000000..35aa7190d
--- /dev/null
+++ b/smack-examples/src/test/java/org/igniterealtime/smack/examples/SmackExamplesTest.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2023 Florian Schmaus
+ *
+ * This file is part of smack-examples.
+ *
+ * smack-examples is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.igniterealtime.smack.examples;
+
+import org.junit.jupiter.api.Test;
+
+public class SmackExamplesTest {
+ /**
+ * Just here to ensure jacoco is not complaining.
+ */
+ @Test
+ public void emptyTest() {
+ }
+
+}
diff --git a/smack-experimental/build.gradle b/smack-experimental/build.gradle
index 9e945e0d5..7484d56f8 100644
--- a/smack-experimental/build.gradle
+++ b/smack-experimental/build.gradle
@@ -1,3 +1,8 @@
+plugins {
+ id 'org.igniterealtime.smack.java-common-conventions'
+ id 'org.igniterealtime.smack.android-conventions'
+}
+
description = """\
Smack experimental extensions.
Classes and methods for XEPs that are in status 'experimental' or that should
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/packet/Carbon.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/packet/Carbon.java
index 8f303cdff..77ef518f6 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/packet/Carbon.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/packet/Carbon.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2014 Florian Schmaus
+ * Copyright © 2014-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ public class Carbon {
public static class Enable extends SimpleIQ {
public static final String ELEMENT = "enable";
+ @SuppressWarnings("this-escape")
public Enable() {
super(ELEMENT, NAMESPACE);
setType(Type.set);
@@ -37,6 +38,7 @@ public class Carbon {
public static class Disable extends SimpleIQ {
public static final String ELEMENT = "disable";
+ @SuppressWarnings("this-escape")
public Disable() {
super(ELEMENT, NAMESPACE);
setType(Type.set);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java
index b2f99bd76..60b125742 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java
@@ -174,7 +174,10 @@ public final class ChatMarkersManager extends Manager {
* @throws XMPPErrorException in case an error response was received.
* @throws NoResponseException if no response was received.
* @throws InterruptedException if the connection is interrupted.
+ * @deprecated This method serves no purpose, as servers do not announce this feature.
*/
+ // TODO: Remove in Smack 4.6.
+ @Deprecated
public boolean isSupportedByServer()
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return ServiceDiscoveryManager.getInstanceFor(connection())
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/dox/element/DnsIq.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/dox/element/DnsIq.java
index 77c626eae..590906549 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/dox/element/DnsIq.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/dox/element/DnsIq.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2019 Florian Schmaus
+ * Copyright 2019-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@ public class DnsIq extends IQ {
this(new DnsMessage(dnsMessage));
}
+ @SuppressWarnings("this-escape")
public DnsIq(DnsMessage dnsQuery, Jid to) {
this(dnsQuery);
setTo(to);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/element/FileMetadataElement.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/element/FileMetadataElement.java
new file mode 100644
index 000000000..e9f2976bb
--- /dev/null
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/element/FileMetadataElement.java
@@ -0,0 +1,312 @@
+/**
+ *
+ * Copyright 2020 Paul Schaub
+ *
+ * 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.smackx.file_metadata.element;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jivesoftware.smack.packet.ExtensionElement;
+import org.jivesoftware.smack.packet.XmlEnvironment;
+import org.jivesoftware.smack.util.CollectionUtil;
+import org.jivesoftware.smack.util.EqualsUtil;
+import org.jivesoftware.smack.util.HashCode;
+import org.jivesoftware.smack.util.StringUtils;
+import org.jivesoftware.smack.util.XmlStringBuilder;
+import org.jivesoftware.smackx.hashes.HashManager;
+import org.jivesoftware.smackx.hashes.element.HashElement;
+import org.jivesoftware.smackx.thumbnails.element.ThumbnailElement;
+
+/**
+ * File metadata element as defined in XEP-0446: File Metadata Element.
+ * This element is used in a generic way to provide information about files, e.g. during file sharing.
+ */
+public final class FileMetadataElement implements ExtensionElement {
+
+ public static final String ELEMENT = "file";
+ public static final String NAMESPACE = "urn:xmpp:file:metadata:0";
+ public static final String ELEM_DATE = "date";
+ public static final String ELEM_HEIGHT = "height";
+ public static final String ELEM_WIDTH = "width";
+ public static final String ELEM_DESC = "desc";
+ public static final String ELEM_LENGTH = "length";
+ public static final String ELEM_MEDIA_TYPE = "media-type";
+ public static final String ELEM_NAME = "name";
+ public static final String ELEM_SIZE = "size";
+
+
+ private final Date date;
+ private final Integer height;
+ private final Integer width;
+ private final Map descriptions;
+ private final Map hashElements;
+ private final Long length;
+ private final String mediaType;
+ private final String name;
+ private final Long size;
+ private final List thumbnails;
+
+ private FileMetadataElement(Date date, Integer height, Integer width, Map descriptions,
+ Map hashElements, Long length,
+ String mediaType, String name, Long size,
+ List thumbnails) {
+ this.date = date;
+ this.height = height;
+ this.width = width;
+ this.descriptions = CollectionUtil.cloneAndSeal(descriptions);
+ this.hashElements = CollectionUtil.cloneAndSeal(hashElements);
+ this.length = length;
+ this.mediaType = mediaType;
+ this.name = name;
+ this.size = size;
+ this.thumbnails = CollectionUtil.cloneAndSeal(thumbnails);
+ }
+
+ @Override
+ public XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) {
+ XmlStringBuilder sb = new XmlStringBuilder(this)
+ .rightAngleBracket()
+ .optElement(ELEM_DATE, date)
+ .optElement(ELEM_HEIGHT, height)
+ .optElement(ELEM_WIDTH, width);
+ for (String key : descriptions.keySet()) {
+ sb.halfOpenElement(ELEM_DESC)
+ .optXmlLangAttribute(key)
+ .rightAngleBracket()
+ .append(descriptions.get(key))
+ .closeElement(ELEM_DESC);
+ }
+ sb.append(hashElements.values())
+ .optElement(ELEM_LENGTH, length != null ? Long.toString(length) : null)
+ .optElement(ELEM_MEDIA_TYPE, mediaType)
+ .optElement(ELEM_NAME, name)
+ .optElement(ELEM_SIZE, size != null ? Long.toString(size) : null)
+ .append(thumbnails);
+ return sb.closeElement(this);
+ }
+
+ @Override
+ public String getNamespace() {
+ return NAMESPACE;
+ }
+
+ @Override
+ public String getElementName() {
+ return ELEMENT;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public Integer getHeight() {
+ return height;
+ }
+
+ public Integer getWidth() {
+ return width;
+ }
+
+ public Map getDescriptions() {
+ return Collections.unmodifiableMap(descriptions);
+ }
+
+ public String getDescription() {
+ return getDescription(getLanguage());
+ }
+
+ public String getDescription(String lang) {
+ return descriptions.get(lang != null ? lang : "");
+ }
+
+ public Map getHashElements() {
+ return Collections.unmodifiableMap(hashElements);
+ }
+
+ public HashElement getHashElement(HashManager.ALGORITHM algorithm) {
+ return hashElements.get(algorithm);
+ }
+
+ public Long getLength() {
+ return length;
+ }
+
+ public String getMediaType() {
+ return mediaType;
+ }
+
+ /**
+ * Return the name of the file.
+ *
+ * @return escaped name
+ */
+ public String getName() {
+ if (name == null) {
+ return null;
+ }
+ try {
+ return URLEncoder.encode(name, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new AssertionError(e); // UTF-8 MUST be supported
+ }
+ }
+
+ public String getRawName() {
+ return name;
+ }
+
+ public Long getSize() {
+ return size;
+ }
+
+ public List getThumbnails() {
+ return Collections.unmodifiableList(thumbnails);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCode.builder()
+ .append(getElementName())
+ .append(getNamespace())
+ .append(getDate())
+ .append(getDescriptions())
+ .append(getHeight())
+ .append(getWidth())
+ .append(getHashElements())
+ .append(getLength())
+ .append(getMediaType())
+ .append(getRawName())
+ .append(getSize())
+ .append(getThumbnails())
+ .build();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return EqualsUtil.equals(this, other, (equalsBuilder, o) -> equalsBuilder
+ .append(getElementName(), o.getElementName())
+ .append(getNamespace(), o.getNamespace())
+ .append(getDate(), o.getDate())
+ .append(getDescriptions(), o.getDescriptions())
+ .append(getHeight(), o.getHeight())
+ .append(getWidth(), o.getWidth())
+ .append(getHashElements(), o.getHashElements())
+ .append(getLength(), o.getLength())
+ .append(getMediaType(), o.getMediaType())
+ .append(getRawName(), o.getRawName())
+ .append(getSize(), o.getSize())
+ .append(getThumbnails(), o.getThumbnails()));
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+
+ private Date date;
+ private Integer height;
+ private Integer width;
+ private Map descriptions = new HashMap<>();
+ private Map hashElements = new HashMap<>();
+ private Long length;
+ private String mediaType;
+ private String name;
+ private Long size;
+ private List thumbnails = new ArrayList<>();
+
+ public Builder setModificationDate(Date date) {
+ this.date = date;
+ return this;
+ }
+
+ public Builder setDimensions(int width, int height) {
+ return setHeight(height).setWidth(width);
+ }
+
+ public Builder setHeight(int height) {
+ if (height <= 0) {
+ throw new IllegalArgumentException("Height must be a positive number");
+ }
+ this.height = height;
+ return this;
+ }
+
+ public Builder setWidth(int width) {
+ if (width <= 0) {
+ throw new IllegalArgumentException("Width must be a positive number");
+ }
+ this.width = width;
+ return this;
+ }
+
+ public Builder addDescription(String description) {
+ return addDescription(description, null);
+ }
+
+ public Builder addDescription(String description, String language) {
+ this.descriptions.put(language != null ? language : "", StringUtils.requireNotNullNorEmpty(description, "Description MUST NOT be null nor empty"));
+ return this;
+ }
+
+ public Builder addHash(HashElement hashElement) {
+ hashElements.put(hashElement.getAlgorithm(), hashElement);
+ return this;
+ }
+
+ public Builder setLength(long length) {
+ if (length < 0) {
+ throw new IllegalArgumentException("Length cannot be negative.");
+ }
+ this.length = length;
+ return this;
+ }
+
+ public Builder setMediaType(String mediaType) {
+ this.mediaType = StringUtils.requireNotNullNorEmpty(mediaType, "Media-Type MUST NOT be null nor empty");
+ return this;
+ }
+
+ public Builder setName(String name) {
+ this.name = StringUtils.requireNotNullNorEmpty(name, "Name MUST NOT be null nor empty");
+ return this;
+ }
+
+ public Builder setSize(long size) {
+ if (size < 0) {
+ throw new IllegalArgumentException("Size MUST NOT be negative.");
+ }
+ this.size = size;
+ return this;
+ }
+
+ public Builder addThumbnail(ThumbnailElement thumbnail) {
+ thumbnails.add(thumbnail);
+ return this;
+ }
+
+ public FileMetadataElement build() {
+ return new FileMetadataElement(date, height, width, descriptions, hashElements, length,
+ mediaType, name, size, thumbnails);
+ }
+ }
+}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/element/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/element/package-info.java
new file mode 100644
index 000000000..dbea97273
--- /dev/null
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/element/package-info.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * Copyright 2020 Paul Schaub
+ *
+ * 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.
+ */
+/**
+ * Smacks implementation of XEP-0446: File Metadata Element.
+ */
+package org.jivesoftware.smackx.file_metadata.element;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/package-info.java
new file mode 100644
index 000000000..8d9825d6c
--- /dev/null
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/package-info.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * Copyright 2020 Paul Schaub
+ *
+ * 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.
+ */
+/**
+ * Smacks implementation of XEP-0446: File Metadata Element.
+ */
+package org.jivesoftware.smackx.file_metadata;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/provider/FileMetadataElementProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/provider/FileMetadataElementProvider.java
new file mode 100644
index 000000000..e4212b0ce
--- /dev/null
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/provider/FileMetadataElementProvider.java
@@ -0,0 +1,102 @@
+/**
+ *
+ * Copyright 2020 Paul Schaub
+ *
+ * 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.smackx.file_metadata.provider;
+
+import java.io.IOException;
+import java.text.ParseException;
+
+import org.jivesoftware.smack.packet.XmlEnvironment;
+import org.jivesoftware.smack.parsing.SmackParsingException;
+import org.jivesoftware.smack.provider.ExtensionElementProvider;
+import org.jivesoftware.smack.util.ParserUtils;
+import org.jivesoftware.smack.xml.XmlPullParser;
+import org.jivesoftware.smack.xml.XmlPullParserException;
+import org.jivesoftware.smackx.file_metadata.element.FileMetadataElement;
+import org.jivesoftware.smackx.hashes.element.HashElement;
+import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
+import org.jivesoftware.smackx.thumbnails.element.ThumbnailElement;
+import org.jivesoftware.smackx.thumbnails.provider.ThumbnailElementProvider;
+
+public class FileMetadataElementProvider extends ExtensionElementProvider {
+
+ @Override
+ public FileMetadataElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
+ throws XmlPullParserException, IOException, SmackParsingException, ParseException {
+ FileMetadataElement.Builder builder = FileMetadataElement.builder();
+
+ outerloop: while (true) {
+ XmlPullParser.Event event = parser.next();
+ switch (event) {
+ case START_ELEMENT:
+ String name = parser.getName();
+ switch (name) {
+ case FileMetadataElement.ELEMENT:
+ parser.next();
+ break;
+ case FileMetadataElement.ELEM_DATE:
+ builder.setModificationDate(ParserUtils.getDateFromNextText(parser));
+ break;
+ case FileMetadataElement.ELEM_DESC:
+ String lang = ParserUtils.getXmlLang(parser);
+ builder.addDescription(ParserUtils.getRequiredNextText(parser), lang);
+ break;
+ case "dimensions": // was replaced with width and height
+ String dimensions = ParserUtils.getRequiredNextText(parser);
+ String[] split = dimensions.split("x");
+ if (split.length != 2) {
+ throw new IllegalArgumentException("Invalid dimensions.");
+ }
+ builder.setWidth(Integer.parseInt(split[0]));
+ builder.setHeight(Integer.parseInt(split[1]));
+ break;
+ case FileMetadataElement.ELEM_WIDTH:
+ builder.setWidth(Integer.parseInt(ParserUtils.getRequiredNextText(parser)));
+ break;
+ case FileMetadataElement.ELEM_HEIGHT:
+ builder.setHeight(Integer.parseInt(ParserUtils.getRequiredNextText(parser)));
+ break;
+ case FileMetadataElement.ELEM_LENGTH:
+ builder.setLength(Long.parseLong(ParserUtils.getRequiredNextText(parser)));
+ break;
+ case FileMetadataElement.ELEM_MEDIA_TYPE:
+ builder.setMediaType(ParserUtils.getRequiredNextText(parser));
+ break;
+ case FileMetadataElement.ELEM_NAME:
+ builder.setName(ParserUtils.getRequiredNextText(parser));
+ break;
+ case FileMetadataElement.ELEM_SIZE:
+ builder.setSize(Long.parseLong(ParserUtils.getRequiredNextText(parser)));
+ break;
+ case HashElement.ELEMENT:
+ builder.addHash(HashElementProvider.INSTANCE.parse(parser, parser.getDepth(), xmlEnvironment));
+ break;
+ case ThumbnailElement.ELEMENT:
+ ThumbnailElementProvider provider = new ThumbnailElementProvider();
+ builder.addThumbnail(provider.parse(parser, parser.getDepth(), xmlEnvironment));
+ }
+ break;
+ case END_ELEMENT:
+ if (parser.getDepth() == initialDepth) break outerloop;
+ break;
+ default:
+ // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
+ break;
+ }
+ }
+ return builder.build();
+ }
+}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/provider/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/provider/package-info.java
new file mode 100644
index 000000000..e28f0d94b
--- /dev/null
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/provider/package-info.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * Copyright 2020 Paul Schaub
+ *
+ * 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.
+ */
+/**
+ * File metadata element provider.
+ */
+package org.jivesoftware.smackx.file_metadata.provider;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hashes/HashManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hashes/HashManager.java
index b3f0c3db4..68aa79ba7 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hashes/HashManager.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hashes/HashManager.java
@@ -47,7 +47,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.hashes.element.HashElement;
/**
- * Manager that can be used to determine support for hash functions. By default the Manager announces support for
+ * Manager that can be used to determine support for hash functions. By default,the Manager announces support for
* XEP-0300, as well as for the recommended set of hash algorithms. Those contain SHA256, SHA384, SHA512, SHA3-256,
* SHA3-384, SHA3-512, BLAKE2B256, BLAKE2B384 and BLAKE2B512. Those algorithms got recommended here:
* https://xmpp.org/extensions/xep-0300.html#recommendations.
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/package-info.java
index 1b357afa8..9ca583637 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/package-info.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/package-info.java
@@ -103,7 +103,7 @@
* AbstractHttpOverXmpp.Data data = new AbstractHttpOverXmpp.Data(child);
*
* // create request
- * HttpOverXmppReq req = HttpOverXmppReq.buider()
+ * HttpOverXmppReq req = HttpOverXmppReq.builder()
* .setMethod(HttpMethod.POST)
* .setResource("/mailbox")
* .setHeaders(headers)
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/element/Slot.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/element/Slot.java
index 274e59bc0..48c61bec7 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/element/Slot.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/element/Slot.java
@@ -46,6 +46,7 @@ public class Slot extends IQ {
this(putUrl, getUrl, headers, NAMESPACE);
}
+ @SuppressWarnings("this-escape")
protected Slot(URL putUrl, URL getUrl, Map headers, String namespace) {
super(ELEMENT, namespace);
setType(Type.result);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/element/SlotRequest.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/element/SlotRequest.java
index 961fc27e1..0fa8b484c 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/element/SlotRequest.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/element/SlotRequest.java
@@ -53,6 +53,7 @@ public class SlotRequest extends IQ {
this(uploadServiceAddress, filename, size, contentType, NAMESPACE);
}
+ @SuppressWarnings("this-escape")
protected SlotRequest(DomainBareJid uploadServiceAddress, String filename, long size, String contentType, String namespace) {
super(ELEMENT, namespace);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/element/IoTSetRequest.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/element/IoTSetRequest.java
index cd6d0b553..a3dad0268 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/element/IoTSetRequest.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/element/IoTSetRequest.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2016-2017 Florian Schmaus
+ * Copyright © 2016-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ public class IoTSetRequest extends IQ {
private final Collection setData;
+ @SuppressWarnings("this-escape")
public IoTSetRequest(Collection extends SetData> setData) {
super(ELEMENT, NAMESPACE);
setType(Type.set);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/element/IoTDataReadOutAccepted.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/element/IoTDataReadOutAccepted.java
index 20d0a125d..279476cd2 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/element/IoTDataReadOutAccepted.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/element/IoTDataReadOutAccepted.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2016 Florian Schmaus
+ * Copyright © 2016-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ public class IoTDataReadOutAccepted extends IQ {
private final boolean queued;
+ @SuppressWarnings("this-escape")
public IoTDataReadOutAccepted(int seqNr, boolean queued) {
super(ELEMENT, NAMESPACE);
this.seqNr = seqNr;
@@ -37,6 +38,7 @@ public class IoTDataReadOutAccepted extends IQ {
setType(Type.result);
}
+ @SuppressWarnings("this-escape")
public IoTDataReadOutAccepted(IoTDataRequest dataRequest) {
this(dataRequest.getSequenceNr(), false);
setStanzaId(dataRequest.getStanzaId());
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/element/IoTFieldsExtension.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/element/IoTFieldsExtension.java
index cb280745f..721b1b657 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/element/IoTFieldsExtension.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/element/IoTFieldsExtension.java
@@ -83,6 +83,7 @@ public class IoTFieldsExtension implements ExtensionElement {
return xml;
}
+ @SuppressWarnings("JavaUtilDate")
public static IoTFieldsExtension buildFor(int seqNr, boolean done, NodeInfo nodeInfo,
List extends IoTDataField> data) {
TimestampElement timestampElement = new TimestampElement(new Date(), data);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/element/IoTUnregister.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/element/IoTUnregister.java
index bdc536f97..3b510e55f 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/element/IoTUnregister.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/element/IoTUnregister.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2016 Florian Schmaus
+ * Copyright 2016-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ public class IoTUnregister extends IQ {
private final NodeInfo nodeInfo;
+ @SuppressWarnings("this-escape")
public IoTUnregister(NodeInfo nodeInfo) {
super(ELEMENT, NAMESPACE);
this.nodeInfo = nodeInfo;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/package-info.java
index 0b3803a4f..c4b261a27 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/package-info.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/package-info.java
@@ -146,7 +146,7 @@
*
*
* IoTDiscoveryManager iotDiscoveryManager = IoTDiscoveryManager.getInstanceFor(connection);
- * iotDiscovyerManager.registerThing(thing);
+ * iotDiscoveryManager.registerThing(thing);
*
*
*
@@ -162,7 +162,7 @@
* Things can usually only be used by other things if they are friends. Since a
* thing normally can't decide on its own if an incoming friendship request
* should be granted or not, we can delegate this decision to a provisioning
- * service. Smack provides the `IoTProvisinoManager` to deal with friendship and
+ * service. Smack provides the `IoTProvisionManager` to deal with friendship and
* provisioning.
*
*
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/element/ClearCache.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/element/ClearCache.java
index fe98b32b3..d17e46c94 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/element/ClearCache.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/element/ClearCache.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2016 Florian Schmaus
+ * Copyright © 2016-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ public class ClearCache extends SimpleIQ {
public static final String ELEMENT = "clearCache";
public static final String NAMESPACE = Constants.IOT_PROVISIONING_NAMESPACE;
+ @SuppressWarnings("this-escape")
public ClearCache() {
super(ELEMENT, NAMESPACE);
// IQs are always of type 'get' (XEP-0324 § 3.5.1, see also the XEPs history remarks)
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/element/ClearCacheResponse.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/element/ClearCacheResponse.java
index 1c229d153..1abfb731c 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/element/ClearCacheResponse.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/element/ClearCacheResponse.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2016 Florian Schmaus
+ * Copyright © 2016-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,12 +23,14 @@ public class ClearCacheResponse extends SimpleIQ {
public static final String ELEMENT = "clearCacheResponse";
public static final String NAMESPACE = Constants.IOT_PROVISIONING_NAMESPACE;
+ @SuppressWarnings("this-escape")
public ClearCacheResponse() {
super(ELEMENT, NAMESPACE);
// IQs are always of type 'result' (XEP-0324 § 3.5.1, see also the XEPs history remarks)
setType(Type.result);
}
+ @SuppressWarnings("this-escape")
public ClearCacheResponse(ClearCache clearCacheRequest) {
this();
setStanzaId(clearCacheRequest.getStanzaId());
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferChild.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferChild.java
index b4e9021ec..cab86e550 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferChild.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferChild.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2017 Paul Schaub, 2019 Florian Schmaus
+ * Copyright 2017 Paul Schaub, 2019-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -167,6 +167,7 @@ public class JingleFileTransferChild implements JingleContentDescriptionChildEle
return new JingleFileTransferChild(date, desc, hash, mediaType, name, size, range);
}
+ @SuppressWarnings("JavaUtilDate")
public Builder setFile(File file) {
return setDate(new Date(file.lastModified()))
.setName(file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf("/") + 1))
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java
index 94dfc2f07..6ce58bdea 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright © 2017-2020 Florian Schmaus, 2016-2017 Fernando Ramirez
+ * Copyright © 2017-2024 Florian Schmaus, 2016-2017 Fernando Ramirez
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +44,8 @@ import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
+import org.jivesoftware.smackx.commands.AdHocCommand;
import org.jivesoftware.smackx.commands.AdHocCommandManager;
-import org.jivesoftware.smackx.commands.RemoteCommand;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
@@ -233,7 +233,7 @@ public final class MamManager extends Manager {
super(connection);
this.archiveAddress = archiveAddress;
serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
- adHocCommandManager = AdHocCommandManager.getAddHocCommandsManager(connection);
+ adHocCommandManager = AdHocCommandManager.getInstance(connection);
}
/**
@@ -387,6 +387,7 @@ public final class MamManager extends Manager {
return this;
}
+ @SuppressWarnings("JavaUtilDate")
public Builder limitResultsSince(Date start) {
if (start == null) {
return this;
@@ -415,6 +416,7 @@ public final class MamManager extends Manager {
return this;
}
+ @SuppressWarnings("JavaUtilDate")
public Builder limitResultsBefore(Date end) {
if (end == null) {
return this;
@@ -759,7 +761,7 @@ public final class MamManager extends Manager {
return false;
}
- public RemoteCommand getAdvancedConfigurationCommand() throws InterruptedException, XMPPException, SmackException {
+ public AdHocCommand getAdvancedConfigurationCommand() throws InterruptedException, XMPPException, SmackException {
DiscoverItems discoverItems = adHocCommandManager.discoverCommands(archiveAddress);
for (DiscoverItems.Item item : discoverItems.getItems()) {
if (item.getNode().equals(ADVANCED_CONFIG_NODE))
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/element/MamPrefsIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/element/MamPrefsIQ.java
index e5898f4c3..1a5535135 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/element/MamPrefsIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/element/MamPrefsIQ.java
@@ -81,6 +81,7 @@ public class MamPrefsIQ extends IQ {
* @param neverJids TODO javadoc me please
* @param defaultBehavior TODO javadoc me please
*/
+ @SuppressWarnings("this-escape")
public MamPrefsIQ(MamVersion version, List alwaysJids, List neverJids, DefaultBehavior defaultBehavior) {
super(ELEMENT, version.getNamespace());
setType(Type.set);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/element/MamQueryIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/element/MamQueryIQ.java
index 3909b077c..17b8a5cae 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/element/MamQueryIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/element/MamQueryIQ.java
@@ -45,6 +45,7 @@ public class MamQueryIQ extends IQ {
* @param version TODO javadoc me please
* @param queryId TODO javadoc me please
*/
+ @SuppressWarnings("this-escape")
public MamQueryIQ(MamVersion version, String queryId) {
this(version, queryId, null, null);
setType(IQ.Type.get);
@@ -79,6 +80,7 @@ public class MamQueryIQ extends IQ {
* @param node TODO javadoc me please
* @param dataForm TODO javadoc me please
*/
+ @SuppressWarnings("this-escape")
public MamQueryIQ(MamVersion version, String queryId, String node, DataForm dataForm) {
super(ELEMENT, version.getNamespace());
this.queryId = queryId;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/message_markup/element/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/message_markup/element/package-info.java
index 5246c33ff..f1d6e981e 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/message_markup/element/package-info.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/message_markup/element/package-info.java
@@ -21,7 +21,7 @@
* Usage
*
* The most important class is the {@link org.jivesoftware.smackx.message_markup.element.MarkupElement} class, which
- * contains a Builder to construct message markup..
+ * contains a Builder to construct message markup.
*
*
* To start creating a Message Markup Extension, call
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MUCLightRoomConfiguration.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MUCLightRoomConfiguration.java
index aab822087..7f0595871 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MUCLightRoomConfiguration.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MUCLightRoomConfiguration.java
@@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.muclight;
-import java.util.HashMap;
+import java.util.Map;
/**
* MUC Light room configuration class.
@@ -28,7 +28,7 @@ public class MUCLightRoomConfiguration {
private final String roomName;
private final String subject;
- private final HashMap customConfigs;
+ private final Map customConfigs;
/**
* MUC Light room configuration model constructor.
@@ -37,7 +37,7 @@ public class MUCLightRoomConfiguration {
* @param subject TODO javadoc me please
* @param customConfigs TODO javadoc me please
*/
- public MUCLightRoomConfiguration(String roomName, String subject, HashMap customConfigs) {
+ public MUCLightRoomConfiguration(String roomName, String subject, Map customConfigs) {
this.roomName = roomName;
this.subject = subject;
this.customConfigs = customConfigs;
@@ -66,7 +66,7 @@ public class MUCLightRoomConfiguration {
*
* @return the custom configurations of the room.
*/
- public HashMap getCustomConfigs() {
+ public Map getCustomConfigs() {
return customConfigs;
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MUCLightRoomInfo.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MUCLightRoomInfo.java
index b41066d54..532f64bf4 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MUCLightRoomInfo.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MUCLightRoomInfo.java
@@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.muclight;
-import java.util.HashMap;
+import java.util.Map;
import org.jxmpp.jid.Jid;
@@ -30,7 +30,7 @@ public class MUCLightRoomInfo {
private final String version;
private final Jid room;
private final MUCLightRoomConfiguration configuration;
- private final HashMap occupants;
+ private final Map occupants;
/**
* MUC Light room info model constructor.
@@ -41,7 +41,7 @@ public class MUCLightRoomInfo {
* @param occupants TODO javadoc me please
*/
public MUCLightRoomInfo(String version, Jid roomJid, MUCLightRoomConfiguration configuration,
- HashMap occupants) {
+ Map occupants) {
this.version = version;
this.room = roomJid;
this.configuration = configuration;
@@ -80,7 +80,7 @@ public class MUCLightRoomInfo {
*
* @return the occupants of the room.
*/
- public HashMap getOccupants() {
+ public Map getOccupants() {
return occupants;
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
index 5ebd11197..58e5b367d 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
@@ -18,6 +18,7 @@ package org.jivesoftware.smackx.muclight;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
@@ -181,21 +182,6 @@ public class MultiUserChatLight {
;
}
- /**
- * Sends a Message to the chat room.
- *
- * @param message TODO javadoc me please
- * the message.
- * @throws NotConnectedException if the XMPP connection is not connected.
- * @throws InterruptedException if the calling thread was interrupted.
- * @deprecated use {@link #sendMessage(MessageBuilder)} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public void sendMessage(Message message) throws NotConnectedException, InterruptedException {
- sendMessage(message.asBuilder());
- }
-
/**
* Sends a Message to the chat room.
*
@@ -294,7 +280,7 @@ public class MultiUserChatLight {
* @param occupants TODO javadoc me please
* @throws Exception TODO javadoc me please
*/
- public void create(String roomName, String subject, HashMap customConfigs, List occupants)
+ public void create(String roomName, String subject, Map customConfigs, List occupants)
throws Exception {
MUCLightCreateIQ createMUCLightIQ = new MUCLightCreateIQ(room, roomName, occupants);
@@ -328,7 +314,7 @@ public class MultiUserChatLight {
* @throws XMPPErrorException if there was an XMPP error returned.
*/
public void leave() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
- HashMap affiliations = new HashMap<>();
+ Map affiliations = new HashMap<>();
affiliations.put(connection.getUser(), MUCLightAffiliation.none);
MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations);
@@ -417,7 +403,7 @@ public class MultiUserChatLight {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
- public HashMap getAffiliations(String version)
+ public Map getAffiliations(String version)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightGetAffiliationsIQ mucLightGetAffiliationsIQ = new MUCLightGetAffiliationsIQ(room, version);
@@ -436,7 +422,7 @@ public class MultiUserChatLight {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
- public HashMap getAffiliations()
+ public Map getAffiliations()
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return getAffiliations(null);
}
@@ -450,7 +436,7 @@ public class MultiUserChatLight {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
- public void changeAffiliations(HashMap affiliations)
+ public void changeAffiliations(Map affiliations)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations);
connection.sendIqRequestAndWaitForResponse(changeAffiliationsIQ);
@@ -513,7 +499,7 @@ public class MultiUserChatLight {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
- public void setRoomConfigs(HashMap customConfigs)
+ public void setRoomConfigs(Map customConfigs)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
setRoomConfigs(null, customConfigs);
}
@@ -528,7 +514,7 @@ public class MultiUserChatLight {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
- public void setRoomConfigs(String roomName, HashMap customConfigs)
+ public void setRoomConfigs(String roomName, Map customConfigs)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, roomName, customConfigs);
connection.sendIqRequestAndWaitForResponse(mucLightSetConfigIQ);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
index d153d499d..58f030499 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
@@ -274,7 +274,7 @@ public final class MultiUserChatLightManager extends Manager {
sendBlockRooms(mucLightService, rooms);
}
- private void sendBlockRooms(DomainBareJid mucLightService, HashMap rooms)
+ private void sendBlockRooms(DomainBareJid mucLightService, Map rooms)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(IQ.Type.set);
@@ -318,7 +318,7 @@ public final class MultiUserChatLightManager extends Manager {
sendBlockUsers(mucLightService, users);
}
- private void sendBlockUsers(DomainBareJid mucLightService, HashMap users)
+ private void sendBlockUsers(DomainBareJid mucLightService, Map users)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(IQ.Type.set);
@@ -362,7 +362,7 @@ public final class MultiUserChatLightManager extends Manager {
sendUnblockRooms(mucLightService, rooms);
}
- private void sendUnblockRooms(DomainBareJid mucLightService, HashMap rooms)
+ private void sendUnblockRooms(DomainBareJid mucLightService, Map rooms)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(IQ.Type.set);
@@ -406,7 +406,7 @@ public final class MultiUserChatLightManager extends Manager {
sendUnblockUsers(mucLightService, users);
}
- private void sendUnblockUsers(DomainBareJid mucLightService, HashMap users)
+ private void sendUnblockUsers(DomainBareJid mucLightService, Map users)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(IQ.Type.set);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightAffiliationsIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightAffiliationsIQ.java
index c9e0ead62..047c7af50 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightAffiliationsIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightAffiliationsIQ.java
@@ -16,7 +16,6 @@
*/
package org.jivesoftware.smackx.muclight.element;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -40,7 +39,7 @@ public class MUCLightAffiliationsIQ extends IQ {
public static final String NAMESPACE = MultiUserChatLight.NAMESPACE + MultiUserChatLight.AFFILIATIONS;
private final String version;
- private HashMap affiliations;
+ private Map affiliations;
/**
* MUC Light affiliations response IQ constructor.
@@ -48,7 +47,8 @@ public class MUCLightAffiliationsIQ extends IQ {
* @param version TODO javadoc me please
* @param affiliations TODO javadoc me please
*/
- public MUCLightAffiliationsIQ(String version, HashMap affiliations) {
+ @SuppressWarnings("this-escape")
+ public MUCLightAffiliationsIQ(String version, Map affiliations) {
super(ELEMENT, NAMESPACE);
this.version = version;
this.affiliations = affiliations;
@@ -82,7 +82,7 @@ public class MUCLightAffiliationsIQ extends IQ {
*
* @return the affiliations of the room
*/
- public HashMap getAffiliations() {
+ public Map getAffiliations() {
return affiliations;
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightBlockingIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightBlockingIQ.java
index f3334b651..fa6264ff0 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightBlockingIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightBlockingIQ.java
@@ -16,7 +16,6 @@
*/
package org.jivesoftware.smackx.muclight.element;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -38,8 +37,8 @@ public class MUCLightBlockingIQ extends IQ {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = MultiUserChatLight.NAMESPACE + MultiUserChatLight.BLOCKING;
- private final HashMap rooms;
- private final HashMap users;
+ private final Map rooms;
+ private final Map users;
/**
* MUC Light blocking IQ constructor.
@@ -47,7 +46,7 @@ public class MUCLightBlockingIQ extends IQ {
* @param rooms TODO javadoc me please
* @param users TODO javadoc me please
*/
- public MUCLightBlockingIQ(HashMap rooms, HashMap users) {
+ public MUCLightBlockingIQ(Map rooms, Map users) {
super(ELEMENT, NAMESPACE);
this.rooms = rooms;
this.users = users;
@@ -58,7 +57,7 @@ public class MUCLightBlockingIQ extends IQ {
*
* @return the rooms JIDs with booleans (true if allow, false if deny)
*/
- public HashMap getRooms() {
+ public Map getRooms() {
return rooms;
}
@@ -67,7 +66,7 @@ public class MUCLightBlockingIQ extends IQ {
*
* @return the users JIDs with booleans (true if allow, false if deny)
*/
- public HashMap getUsers() {
+ public Map getUsers() {
return users;
}
@@ -86,7 +85,7 @@ public class MUCLightBlockingIQ extends IQ {
return xml;
}
- private static void parseBlocking(IQChildElementXmlStringBuilder xml, HashMap map, boolean isRoom) {
+ private static void parseBlocking(IQChildElementXmlStringBuilder xml, Map map, boolean isRoom) {
Iterator> it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = it.next();
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightChangeAffiliationsIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightChangeAffiliationsIQ.java
index 494a7a4d7..e472c84e1 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightChangeAffiliationsIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightChangeAffiliationsIQ.java
@@ -16,7 +16,6 @@
*/
package org.jivesoftware.smackx.muclight.element;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -39,7 +38,7 @@ public class MUCLightChangeAffiliationsIQ extends IQ {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = MultiUserChatLight.NAMESPACE + MultiUserChatLight.AFFILIATIONS;
- private HashMap affiliations;
+ private Map affiliations;
/**
* MUCLight change affiliations IQ constructor.
@@ -47,7 +46,8 @@ public class MUCLightChangeAffiliationsIQ extends IQ {
* @param room TODO javadoc me please
* @param affiliations TODO javadoc me please
*/
- public MUCLightChangeAffiliationsIQ(Jid room, HashMap affiliations) {
+ @SuppressWarnings("this-escape")
+ public MUCLightChangeAffiliationsIQ(Jid room, Map affiliations) {
super(ELEMENT, NAMESPACE);
this.setType(Type.set);
this.setTo(room);
@@ -59,7 +59,7 @@ public class MUCLightChangeAffiliationsIQ extends IQ {
*
* @return the affiliations
*/
- public HashMap getAffiliations() {
+ public Map getAffiliations() {
return affiliations;
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightCreateIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightCreateIQ.java
index d15d47db5..ea0db3b21 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightCreateIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightCreateIQ.java
@@ -18,6 +18,7 @@ package org.jivesoftware.smackx.muclight.element;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.jivesoftware.smack.packet.IQ;
@@ -42,7 +43,7 @@ public class MUCLightCreateIQ extends IQ {
public static final String NAMESPACE = MultiUserChatLight.NAMESPACE + MultiUserChatLight.CREATE;
private MUCLightRoomConfiguration configuration;
- private final HashMap occupants;
+ private final Map occupants;
/**
* MUCLight create IQ constructor.
@@ -53,7 +54,8 @@ public class MUCLightCreateIQ extends IQ {
* @param customConfigs TODO javadoc me please
* @param occupants TODO javadoc me please
*/
- public MUCLightCreateIQ(EntityJid room, String roomName, String subject, HashMap customConfigs,
+ @SuppressWarnings("this-escape")
+ public MUCLightCreateIQ(EntityJid room, String roomName, String subject, Map customConfigs,
List occupants) {
super(ELEMENT, NAMESPACE);
this.configuration = new MUCLightRoomConfiguration(roomName, subject, customConfigs);
@@ -92,7 +94,7 @@ public class MUCLightCreateIQ extends IQ {
*
* @return the room occupants
*/
- public HashMap getOccupants() {
+ public Map getOccupants() {
return occupants;
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightDestroyIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightDestroyIQ.java
index 8198007cf..6606ae035 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightDestroyIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightDestroyIQ.java
@@ -38,6 +38,7 @@ public class MUCLightDestroyIQ extends IQ {
*
* @param roomJid TODO javadoc me please
*/
+ @SuppressWarnings("this-escape")
public MUCLightDestroyIQ(Jid roomJid) {
super(ELEMENT, NAMESPACE);
this.setType(Type.set);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightElements.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightElements.java
index 33861b29e..27dcbd2e7 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightElements.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightElements.java
@@ -16,7 +16,6 @@
*/
package org.jivesoftware.smackx.muclight.element;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -48,11 +47,11 @@ public abstract class MUCLightElements {
public static final String NAMESPACE = MultiUserChatLight.NAMESPACE + MultiUserChatLight.AFFILIATIONS;
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
- private final HashMap affiliations;
+ private final Map affiliations;
private final String prevVersion;
private final String version;
- public AffiliationsChangeExtension(HashMap affiliations, String prevVersion,
+ public AffiliationsChangeExtension(Map affiliations, String prevVersion,
String version) {
this.affiliations = affiliations;
this.prevVersion = prevVersion;
@@ -74,7 +73,7 @@ public abstract class MUCLightElements {
*
* @return the affiliations
*/
- public HashMap getAffiliations() {
+ public Map getAffiliations() {
return affiliations;
}
@@ -135,7 +134,7 @@ public abstract class MUCLightElements {
private final String version;
private final String roomName;
private final String subject;
- private final HashMap customConfigs;
+ private final Map customConfigs;
/**
* Configurations change extension constructor.
@@ -147,7 +146,7 @@ public abstract class MUCLightElements {
* @param customConfigs TODO javadoc me please
*/
public ConfigurationsChangeExtension(String prevVersion, String version, String roomName, String subject,
- HashMap customConfigs) {
+ Map customConfigs) {
this.prevVersion = prevVersion;
this.version = version;
this.roomName = roomName;
@@ -206,7 +205,7 @@ public abstract class MUCLightElements {
*
* @return the room custom configurations
*/
- public HashMap getCustomConfigs() {
+ public Map getCustomConfigs() {
return customConfigs;
}
@@ -287,14 +286,14 @@ public abstract class MUCLightElements {
*/
public static class OccupantsElement implements Element {
- private HashMap occupants;
+ private Map occupants;
/**
* Occupants element constructor.
*
* @param occupants TODO javadoc me please
*/
- public OccupantsElement(HashMap occupants) {
+ public OccupantsElement(Map occupants) {
this.occupants = occupants;
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetAffiliationsIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetAffiliationsIQ.java
index 67cd26481..70249914c 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetAffiliationsIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetAffiliationsIQ.java
@@ -41,6 +41,7 @@ public class MUCLightGetAffiliationsIQ extends IQ {
* @param roomJid TODO javadoc me please
* @param version TODO javadoc me please
*/
+ @SuppressWarnings("this-escape")
public MUCLightGetAffiliationsIQ(Jid roomJid, String version) {
super(ELEMENT, NAMESPACE);
this.version = version;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetConfigsIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetConfigsIQ.java
index 15ce3e1f9..aff4283ee 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetConfigsIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetConfigsIQ.java
@@ -41,6 +41,7 @@ public class MUCLightGetConfigsIQ extends IQ {
* @param roomJid TODO javadoc me please
* @param version TODO javadoc me please
*/
+ @SuppressWarnings("this-escape")
public MUCLightGetConfigsIQ(Jid roomJid, String version) {
super(ELEMENT, NAMESPACE);
this.version = version;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetInfoIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetInfoIQ.java
index 112ec1935..6e3d1daa0 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetInfoIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightGetInfoIQ.java
@@ -41,6 +41,7 @@ public class MUCLightGetInfoIQ extends IQ {
* @param roomJid TODO javadoc me please
* @param version TODO javadoc me please
*/
+ @SuppressWarnings("this-escape")
public MUCLightGetInfoIQ(Jid roomJid, String version) {
super(ELEMENT, NAMESPACE);
this.version = version;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightInfoIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightInfoIQ.java
index 42a2b9308..ef33d4b77 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightInfoIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightInfoIQ.java
@@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.muclight.element;
-import java.util.HashMap;
+import java.util.Map;
import org.jivesoftware.smack.packet.IQ;
@@ -41,7 +41,7 @@ public class MUCLightInfoIQ extends IQ {
private final String version;
private final MUCLightRoomConfiguration configuration;
- private final HashMap occupants;
+ private final Map occupants;
/**
* MUCLight info response IQ constructor.
@@ -51,7 +51,7 @@ public class MUCLightInfoIQ extends IQ {
* @param occupants TODO javadoc me please
*/
public MUCLightInfoIQ(String version, MUCLightRoomConfiguration configuration,
- HashMap occupants) {
+ Map occupants) {
super(ELEMENT, NAMESPACE);
this.version = version;
this.configuration = configuration;
@@ -90,7 +90,7 @@ public class MUCLightInfoIQ extends IQ {
*
* @return the occupants of the room
*/
- public HashMap getOccupants() {
+ public Map getOccupants() {
return occupants;
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightSetConfigsIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightSetConfigsIQ.java
index 0751b582f..3e332194a 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightSetConfigsIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/element/MUCLightSetConfigsIQ.java
@@ -16,7 +16,6 @@
*/
package org.jivesoftware.smackx.muclight.element;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -39,7 +38,7 @@ public class MUCLightSetConfigsIQ extends IQ {
private String roomName;
private String subject;
- private HashMap customConfigs;
+ private Map customConfigs;
/**
* MUC Light set configuration IQ constructor.
@@ -49,7 +48,8 @@ public class MUCLightSetConfigsIQ extends IQ {
* @param subject TODO javadoc me please
* @param customConfigs TODO javadoc me please
*/
- public MUCLightSetConfigsIQ(Jid roomJid, String roomName, String subject, HashMap customConfigs) {
+ @SuppressWarnings("this-escape")
+ public MUCLightSetConfigsIQ(Jid roomJid, String roomName, String subject, Map customConfigs) {
super(ELEMENT, NAMESPACE);
this.roomName = roomName;
this.subject = subject;
@@ -65,7 +65,7 @@ public class MUCLightSetConfigsIQ extends IQ {
* @param roomName TODO javadoc me please
* @param customConfigs TODO javadoc me please
*/
- public MUCLightSetConfigsIQ(Jid roomJid, String roomName, HashMap customConfigs) {
+ public MUCLightSetConfigsIQ(Jid roomJid, String roomName, Map customConfigs) {
this(roomJid, roomName, null, customConfigs);
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/provider/MUCLightBlockingIQProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/provider/MUCLightBlockingIQProvider.java
index b89dba5c8..1412b2900 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/provider/MUCLightBlockingIQProvider.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/provider/MUCLightBlockingIQProvider.java
@@ -18,6 +18,7 @@ package org.jivesoftware.smackx.muclight.provider;
import java.io.IOException;
import java.util.HashMap;
+import java.util.Map;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData;
@@ -42,8 +43,8 @@ public class MUCLightBlockingIQProvider extends IqProvider {
@Override
public MUCLightBlockingIQ parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
- HashMap rooms = null;
- HashMap users = null;
+ Map rooms = null;
+ Map users = null;
outerloop: while (true) {
XmlPullParser.Event eventType = parser.next();
@@ -70,7 +71,7 @@ public class MUCLightBlockingIQProvider extends IqProvider {
return mucLightBlockingIQ;
}
- private static HashMap parseBlocking(XmlPullParser parser, HashMap map)
+ private static Map parseBlocking(XmlPullParser parser, Map map)
throws XmppStringprepException, XmlPullParserException, IOException {
if (map == null) {
map = new HashMap<>();
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/provider/MUCLightInfoIQProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/provider/MUCLightInfoIQProvider.java
index 54d0a4218..50d30bca4 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/provider/MUCLightInfoIQProvider.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/provider/MUCLightInfoIQProvider.java
@@ -18,6 +18,7 @@ package org.jivesoftware.smackx.muclight.provider;
import java.io.IOException;
import java.util.HashMap;
+import java.util.Map;
import org.jivesoftware.smack.packet.IqData;
import org.jivesoftware.smack.packet.XmlEnvironment;
@@ -45,8 +46,8 @@ public class MUCLightInfoIQProvider extends IqProvider {
String version = null;
String roomName = null;
String subject = null;
- HashMap customConfigs = null;
- HashMap occupants = new HashMap<>();
+ Map customConfigs = null;
+ Map occupants = new HashMap<>();
outerloop: while (true) {
XmlPullParser.Event eventType = parser.next();
@@ -97,8 +98,8 @@ public class MUCLightInfoIQProvider extends IqProvider {
return new MUCLightInfoIQ(version, new MUCLightRoomConfiguration(roomName, subject, customConfigs), occupants);
}
- private static HashMap iterateOccupants(XmlPullParser parser) throws XmlPullParserException, IOException {
- HashMap occupants = new HashMap<>();
+ private static Map iterateOccupants(XmlPullParser parser) throws XmlPullParserException, IOException {
+ Map occupants = new HashMap<>();
int depth = parser.getDepth();
outerloop: while (true) {
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java
index ff62d96eb..8615b4759 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java
@@ -16,7 +16,6 @@
*/
package org.jivesoftware.smackx.push_notifications;
-import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
@@ -122,7 +121,7 @@ public final class PushNotificationsManager extends Manager {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
- public boolean enable(Jid pushJid, String node, HashMap publishOptions)
+ public boolean enable(Jid pushJid, String node, Map publishOptions)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
EnablePushNotificationsIQ enablePushNotificationsIQ = new EnablePushNotificationsIQ(pushJid, node,
publishOptions);
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/element/DisablePushNotificationsIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/element/DisablePushNotificationsIQ.java
index bedf8be02..08342811b 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/element/DisablePushNotificationsIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/element/DisablePushNotificationsIQ.java
@@ -43,6 +43,7 @@ public class DisablePushNotificationsIQ extends IQ {
private final Jid jid;
private final String node;
+ @SuppressWarnings("this-escape")
public DisablePushNotificationsIQ(Jid jid, String node) {
super(ELEMENT, NAMESPACE);
this.jid = jid;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/element/EnablePushNotificationsIQ.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/element/EnablePushNotificationsIQ.java
index 428b41b67..c6f8199b4 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/element/EnablePushNotificationsIQ.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/element/EnablePushNotificationsIQ.java
@@ -16,7 +16,6 @@
*/
package org.jivesoftware.smackx.push_notifications.element;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -51,9 +50,10 @@ public class EnablePushNotificationsIQ extends IQ {
private final Jid jid;
private final String node;
- private final HashMap publishOptions;
+ private final Map publishOptions;
- public EnablePushNotificationsIQ(Jid jid, String node, HashMap publishOptions) {
+ @SuppressWarnings("this-escape")
+ public EnablePushNotificationsIQ(Jid jid, String node, Map publishOptions) {
super(ELEMENT, NAMESPACE);
this.jid = jid;
this.node = node;
@@ -88,7 +88,7 @@ public class EnablePushNotificationsIQ extends IQ {
*
* @return the publish options
*/
- public HashMap getPublishOptions() {
+ public Map getPublishOptions() {
return publishOptions;
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/package-info.java
index 821577179..fc8f020be 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/package-info.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/package-info.java
@@ -29,7 +29,7 @@
*
*
*
- * Message message = new Message("Alice is a realy nice person.");
+ * Message message = new Message("Alice is a really nice person.");
* BareJid alice = JidCreate.bareFrom("alice@capulet.lit");
* ReferenceManager.addMention(message, 0, 5, alice);
*
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/OriginIdElement.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/OriginIdElement.java
index a50fd99e2..f0766de8b 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/OriginIdElement.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/OriginIdElement.java
@@ -38,28 +38,6 @@ public class OriginIdElement extends StableAndUniqueIdElement {
super(id);
}
- /**
- * Add an origin-id element to a message and set the stanzas id to the same id as in the origin-id element.
- *
- * @param message message.
- * @return the added origin-id element.
- * @deprecated use {@link #addTo(MessageBuilder)} instead.
- */
- @Deprecated
- // TODO: Remove in Smack 4.5.
- public static OriginIdElement addOriginId(Message message) {
- OriginIdElement originId = message.getExtension(OriginIdElement.class);
- if (originId != null) {
- return originId;
- }
-
- originId = new OriginIdElement();
- message.addExtension(originId);
- // TODO: Find solution to have both the originIds stanzaId and a nice to look at incremental stanzaID.
- // message.setStanzaId(originId.getId());
- return originId;
- }
-
/**
* Add an origin-id element to a message and set the stanzas id to the same id as in the origin-id element.
*
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java
index 6d5c02fd6..b18a5af5c 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java
@@ -114,6 +114,7 @@ public class SpoilerElement implements ExtensionElement {
* @param message message
* @return map of spoilers
*/
+ @SuppressWarnings("MixedMutabilityReturnType")
public static Map getSpoilers(Message message) {
if (!containsSpoiler(message)) {
return Collections.emptyMap();
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/stanza_content_encryption/element/TimestampAffixElement.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/stanza_content_encryption/element/TimestampAffixElement.java
index 0c48f7b7a..eee726085 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/stanza_content_encryption/element/TimestampAffixElement.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/stanza_content_encryption/element/TimestampAffixElement.java
@@ -56,6 +56,7 @@ public class TimestampAffixElement implements NamedElement, AffixElement {
return EqualsUtil.equals(this, obj, (e, o) -> e.append(getTimestamp(), o.getTimestamp()));
}
+ @SuppressWarnings("JavaUtilDate")
@Override
public int hashCode() {
return timestamp.hashCode();
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/element/ThumbnailElement.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/element/ThumbnailElement.java
new file mode 100644
index 000000000..3bcd4b045
--- /dev/null
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/element/ThumbnailElement.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2023 Paul Schaub
+ *
+ * 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.smackx.thumbnails.element;
+
+import org.jivesoftware.smack.packet.ExtensionElement;
+import org.jivesoftware.smack.packet.XmlEnvironment;
+import org.jivesoftware.smack.util.Objects;
+import org.jivesoftware.smack.util.XmlStringBuilder;
+
+public class ThumbnailElement implements ExtensionElement {
+
+ public static final String ELEMENT = "thumbnail";
+ public static final String NAMESPACE = "urn:xmpp:thumbs:1";
+ public static final String ELEM_URI = "uri";
+ public static final String ELEM_MEDIA_TYPE = "media-type";
+ public static final String ELEM_WIDTH = "width";
+ public static final String ELEM_HEIGHT = "height";
+
+ private final String uri;
+ private final String mediaType;
+ private final Integer width;
+ private final Integer height;
+
+ public ThumbnailElement(String uri) {
+ this(uri, null, null, null);
+ }
+
+ public ThumbnailElement(String uri, String mediaType, Integer width, Integer height) {
+ this.uri = Objects.requireNonNull(uri);
+ this.mediaType = mediaType;
+
+ if (width != null && width < 0) {
+ throw new IllegalArgumentException("Width cannot be negative.");
+ }
+ this.width = width;
+
+ if (height != null && height < 0) {
+ throw new IllegalArgumentException("Height cannot be negative.");
+ }
+ this.height = height;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public String getMediaType() {
+ return mediaType;
+ }
+
+ public Integer getWidth() {
+ return width;
+ }
+
+ public Integer getHeight() {
+ return height;
+ }
+
+ @Override
+ public CharSequence toXML(XmlEnvironment xmlEnvironment) {
+ XmlStringBuilder sb = new XmlStringBuilder(this, xmlEnvironment);
+ return sb.attribute(ELEM_URI, uri)
+ .optAttribute(ELEM_MEDIA_TYPE, mediaType)
+ .optAttribute(ELEM_WIDTH, width)
+ .optAttribute(ELEM_HEIGHT, height)
+ .closeEmptyElement();
+ }
+
+ @Override
+ public String getElementName() {
+ return ELEMENT;
+ }
+
+ @Override
+ public String getNamespace() {
+ return NAMESPACE;
+ }
+}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/element/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/element/package-info.java
new file mode 100644
index 000000000..a13671247
--- /dev/null
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/element/package-info.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * Copyright 2023 Paul Schaub
+ *
+ * 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.
+ */
+/**
+ * Smacks implementation of XEP-0264: Jingle Content Thumbnails.
+ */
+package org.jivesoftware.smackx.thumbnails.element;
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/provider/ThumbnailElementProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/provider/ThumbnailElementProvider.java
new file mode 100644
index 000000000..6fc174002
--- /dev/null
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/provider/ThumbnailElementProvider.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2023 Paul Schaub
+ *
+ * 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.smackx.thumbnails.provider;
+
+import java.io.IOException;
+import java.text.ParseException;
+
+import org.jivesoftware.smack.packet.XmlEnvironment;
+import org.jivesoftware.smack.parsing.SmackParsingException;
+import org.jivesoftware.smack.provider.ExtensionElementProvider;
+import org.jivesoftware.smack.util.ParserUtils;
+import org.jivesoftware.smack.xml.XmlPullParser;
+import org.jivesoftware.smack.xml.XmlPullParserException;
+import org.jivesoftware.smackx.thumbnails.element.ThumbnailElement;
+
+public class ThumbnailElementProvider extends ExtensionElementProvider {
+ @Override
+ public ThumbnailElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
+ throws XmlPullParserException, IOException, SmackParsingException, ParseException {
+ String uri = parser.getAttributeValue(ThumbnailElement.ELEM_URI);
+ String mediaType = parser.getAttributeValue(ThumbnailElement.ELEM_MEDIA_TYPE);
+ Integer width = ParserUtils.getIntegerAttribute(parser, ThumbnailElement.ELEM_WIDTH);
+ Integer height = ParserUtils.getIntegerAttribute(parser, ThumbnailElement.ELEM_HEIGHT);
+
+ return new ThumbnailElement(
+ uri,
+ mediaType,
+ width,
+ height
+ );
+ }
+}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/provider/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/provider/package-info.java
new file mode 100644
index 000000000..20816c2ce
--- /dev/null
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/thumbnails/provider/package-info.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * Copyright 2023 Paul Schaub
+ *
+ * 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.
+ */
+/**
+ * Smacks implementation of XEP-0264: Jingle Content Thumbnails.
+ */
+package org.jivesoftware.smackx.thumbnails.provider;
diff --git a/smack-experimental/src/main/resources/org.jivesoftware.smack.experimental/experimental.providers b/smack-experimental/src/main/resources/org.jivesoftware.smack.experimental/experimental.providers
index eb0c1a45f..822bc5837 100644
--- a/smack-experimental/src/main/resources/org.jivesoftware.smack.experimental/experimental.providers
+++ b/smack-experimental/src/main/resources/org.jivesoftware.smack.experimental/experimental.providers
@@ -2,6 +2,13 @@
+
+
+ thumbnail
+ urn:xmpp:thumbs:1
+ org.jivesoftware.smackx.thumbnails.provider.ThumbnailElementProvider
+
+
sent
@@ -345,6 +352,13 @@
org.jivesoftware.smackx.fallback_indication.provider.FallbackIndicationElementProvider
+
+
+ file
+ urn:xmpp:file:metadata:0
+ org.jivesoftware.smackx.file_metadata.provider.FileMetadataElementProvider
+
+
query
diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/eme/ExplicitMessageEncryptionElementTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/eme/ExplicitMessageEncryptionElementTest.java
index dc14db131..b9364b01f 100644
--- a/smack-experimental/src/test/java/org/jivesoftware/smackx/eme/ExplicitMessageEncryptionElementTest.java
+++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/eme/ExplicitMessageEncryptionElementTest.java
@@ -39,7 +39,7 @@ public class ExplicitMessageEncryptionElementTest extends SmackTestSuite {
public void addToMessageTest() {
Message message = StanzaBuilder.buildMessage().build();
- // Check inital state (no elements)
+ // Check initial state (no elements)
assertNull(ExplicitMessageEncryptionElement.from(message));
assertFalse(ExplicitMessageEncryptionElement.hasProtocol(message,
ExplicitMessageEncryptionElement.ExplicitMessageEncryptionProtocol.omemoVAxolotl));
@@ -75,7 +75,7 @@ public class ExplicitMessageEncryptionElementTest extends SmackTestSuite {
assertTrue(ExplicitMessageEncryptionElement.hasProtocol(message,
ExplicitMessageEncryptionElement.ExplicitMessageEncryptionProtocol.omemoVAxolotl));
- // Check, if adding additional OMEMO wont add another element
+ // Check, if adding additional OMEMO won't add another element
ExplicitMessageEncryptionElement.set(messageBuilder,
ExplicitMessageEncryptionElement.ExplicitMessageEncryptionProtocol.omemoVAxolotl);
diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/file_metadata/FileMetadataElementTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/file_metadata/FileMetadataElementTest.java
new file mode 100644
index 000000000..229581308
--- /dev/null
+++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/file_metadata/FileMetadataElementTest.java
@@ -0,0 +1,190 @@
+/**
+ *
+ * Copyright 2020 Paul Schaub
+ *
+ * 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.smackx.file_metadata;
+
+import static org.jivesoftware.smack.test.util.XmlAssertUtil.assertXmlSimilar;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.text.ParseException;
+import java.util.Date;
+
+import org.jivesoftware.smack.test.util.SmackTestSuite;
+import org.jivesoftware.smack.test.util.SmackTestUtil;
+import org.jivesoftware.smackx.file_metadata.element.FileMetadataElement;
+import org.jivesoftware.smackx.file_metadata.provider.FileMetadataElementProvider;
+import org.jivesoftware.smackx.hashes.HashManager;
+import org.jivesoftware.smackx.hashes.element.HashElement;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+import org.jxmpp.util.XmppDateTime;
+
+public class FileMetadataElementTest extends SmackTestSuite {
+
+ private static final Date date;
+ static {
+ try {
+ date = XmppDateTime.parseDate("2015-07-26T21:46:00+01:00");
+ } catch (ParseException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private static final FileMetadataElement metadataElement = FileMetadataElement.builder()
+ .setModificationDate(date)
+ .setWidth(1920)
+ .setHeight(1080)
+ .addDescription("Picture of 24th XSF Summit")
+ .addDescription("Foto vom 24. XSF Summit", "de")
+ .addHash(new HashElement(HashManager.ALGORITHM.SHA_256, "2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU="))
+ .setLength(63000)
+ .setMediaType("text/plain")
+ .setName("text.txt")
+ .setSize(6144)
+ .build();
+
+ private static final String expectedXml = "" +
+ "2015-07-26T20:46:00.000+00:00" +
+ "1920" +
+ "1080" +
+ "Picture of 24th XSF Summit" +
+ "Foto vom 24. XSF Summit" +
+ "2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU=" +
+ "63000" +
+ "text/plain" +
+ "text.txt" +
+ "6144" +
+ "";
+
+ private static final String expectedLegacyXml = "" +
+ "2015-07-26T20:46:00.000+00:00" +
+ "1920x1080" +
+ "Picture of 24th XSF Summit" +
+ "Foto vom 24. XSF Summit" +
+ "2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU=" +
+ "63000" +
+ "text/plain" +
+ "text.txt" +
+ "6144" +
+ "";
+
+ @Test
+ public void testSerialization() {
+ assertXmlSimilar(expectedXml, metadataElement.toXML().toString());
+ }
+
+ @ParameterizedTest
+ @EnumSource(SmackTestUtil.XmlPullParserKind.class)
+ public void testParsing(SmackTestUtil.XmlPullParserKind parserKind) throws Exception {
+ FileMetadataElement parsed = SmackTestUtil.parse(expectedXml, FileMetadataElementProvider.class, parserKind);
+
+ assertEquals(metadataElement, parsed);
+ }
+
+ @ParameterizedTest
+ @EnumSource(SmackTestUtil.XmlPullParserKind.class)
+ public void testLegacyParsing(SmackTestUtil.XmlPullParserKind parserKind) throws Exception {
+ FileMetadataElement parsed = SmackTestUtil.parse(expectedLegacyXml, FileMetadataElementProvider.class, parserKind);
+
+ assertEquals(metadataElement, parsed);
+ }
+
+ @ParameterizedTest
+ @EnumSource(SmackTestUtil.XmlPullParserKind.class)
+ public void testParseUnknownExtension(SmackTestUtil.XmlPullParserKind parserKind) throws Exception {
+ final String xml = "" +
+ "2015-07-26T20:46:00.000+00:00" +
+ "1920" +
+ "1080" +
+ "foo" +
+ "Picture of 24th XSF Summit" +
+ "Foto vom 24. XSF Summit" +
+ "2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU=" +
+ "63000" +
+ "text/plain" +
+ "text.txt" +
+ "6144" +
+ "";
+
+ FileMetadataElement parsed = SmackTestUtil.parse(xml, FileMetadataElementProvider.class, parserKind);
+
+ assertEquals(metadataElement, parsed);
+ }
+
+ @Test
+ public void nameIsEscaped() {
+ FileMetadataElement e = FileMetadataElement.builder().setName("/etc/passwd").build();
+ assertEquals("%2Fetc%2Fpasswd", e.getName());
+ }
+
+ @Test
+ public void rejectNegativeSize() {
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().setSize(-1));
+ }
+
+ @Test
+ public void rejectNegativeLength() {
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().setLength(-1));
+ }
+
+ @Test
+ public void rejectNegativeWidth() {
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().setWidth(-1));
+ }
+
+ @Test
+ public void rejectNegativeHeight() {
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().setHeight(-1));
+ }
+
+ @Test
+ public void rejectEmptyDescription() {
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().addDescription(""));
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().addDescription(null));
+ }
+
+ @Test
+ public void rejectEmptyNameElement() {
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().setName(""));
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().setName(null));
+ }
+
+ @Test
+ public void rejectEmptyMediaTypeElement() {
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().setMediaType(""));
+ assertThrows(IllegalArgumentException.class, () -> FileMetadataElement.builder().setMediaType(null));
+ }
+
+ @Test
+ public void getDescTest() {
+ FileMetadataElement metadataElement = FileMetadataElement.builder()
+ .addDescription("Foo", "br")
+ .addDescription("Baz")
+ .addDescription("Bag", "en")
+ .build();
+
+ assertEquals("Foo", metadataElement.getDescription("br"));
+ assertEquals("Baz", metadataElement.getDescription(null));
+ assertEquals("Baz", metadataElement.getDescription());
+ assertEquals("Bag", metadataElement.getDescription("en"));
+ assertNull(metadataElement.getDescription("null"));
+ assertEquals(3, metadataElement.getDescriptions().size());
+ }
+}
diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/mam/FiltersTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/mam/FiltersTest.java
index b5c974dce..df14ea279 100644
--- a/smack-experimental/src/test/java/org/jivesoftware/smackx/mam/FiltersTest.java
+++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/mam/FiltersTest.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2016 Fernando Ramirez, 2018-2020 Florian Schmaus
+ * Copyright 2016 Fernando Ramirez, 2018-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,6 +46,7 @@ public class FiltersTest extends MamTest {
return xml;
}
+ @SuppressWarnings("JavaUtilDate")
@Test
public void checkStartDateFilter() throws Exception {
Date date = new Date();
@@ -61,6 +62,7 @@ public class FiltersTest extends MamTest {
assertEquals(getMamXMemberWith(fields, values), dataForm.toXML().toString());
}
+ @SuppressWarnings("JavaUtilDate")
@Test
public void checkEndDateFilter() throws Exception {
Date date = new Date();
diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightAffiliationsChangeExtensionTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightAffiliationsChangeExtensionTest.java
index a07577748..ab9e53750 100644
--- a/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightAffiliationsChangeExtensionTest.java
+++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightAffiliationsChangeExtensionTest.java
@@ -18,7 +18,7 @@ package org.jivesoftware.smackx.muclight;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.util.HashMap;
+import java.util.Map;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.util.PacketParserUtils;
@@ -55,7 +55,7 @@ public class MUCLightAffiliationsChangeExtensionTest {
AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension
.from(changeAffiliationsMessage);
- HashMap affiliations = affiliationsChangeExtension.getAffiliations();
+ Map affiliations = affiliationsChangeExtension.getAffiliations();
assertEquals(affiliations.size(), 3);
assertEquals(affiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
@@ -68,7 +68,7 @@ public class MUCLightAffiliationsChangeExtensionTest {
AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension
.from(changeAffiliationsMessage);
- HashMap affiliations = affiliationsChangeExtension.getAffiliations();
+ Map affiliations = affiliationsChangeExtension.getAffiliations();
assertEquals(affiliations.size(), 2);
assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
assertEquals(affiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
@@ -83,7 +83,7 @@ public class MUCLightAffiliationsChangeExtensionTest {
AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension
.from(changeAffiliationsMessage);
- HashMap affiliations = affiliationsChangeExtension.getAffiliations();
+ Map affiliations = affiliationsChangeExtension.getAffiliations();
assertEquals(affiliations.size(), 2);
assertEquals(affiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightChangeAffiliationsIQTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightChangeAffiliationsIQTest.java
index efbb22da7..ca0e1e4cb 100644
--- a/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightChangeAffiliationsIQTest.java
+++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightChangeAffiliationsIQTest.java
@@ -19,6 +19,7 @@ package org.jivesoftware.smackx.muclight;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
+import java.util.Map;
import org.jivesoftware.smack.packet.IQ;
@@ -32,7 +33,7 @@ public class MUCLightChangeAffiliationsIQTest {
@Test
public void checkChangeAffiliationsMUCLightStanza() throws Exception {
- HashMap affiliations = new HashMap<>();
+ Map affiliations = new HashMap<>();
affiliations.put(JidCreate.from("sarasa2@shakespeare.lit"), MUCLightAffiliation.owner);
affiliations.put(JidCreate.from("sarasa1@shakespeare.lit"), MUCLightAffiliation.member);
affiliations.put(JidCreate.from("sarasa3@shakespeare.lit"), MUCLightAffiliation.none);
@@ -44,7 +45,7 @@ public class MUCLightChangeAffiliationsIQTest {
assertEquals(mucLightChangeAffiliationsIQ.getTo(), "coven@muclight.shakespeare.lit");
assertEquals(mucLightChangeAffiliationsIQ.getType(), IQ.Type.set);
- HashMap iqAffiliations = mucLightChangeAffiliationsIQ.getAffiliations();
+ Map iqAffiliations = mucLightChangeAffiliationsIQ.getAffiliations();
assertEquals(iqAffiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
assertEquals(iqAffiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
assertEquals(iqAffiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightCreateIQTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightCreateIQTest.java
index 216a2a494..4a92da24e 100644
--- a/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightCreateIQTest.java
+++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightCreateIQTest.java
@@ -19,8 +19,8 @@ package org.jivesoftware.smackx.muclight;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ;
@@ -43,7 +43,7 @@ public class MUCLightCreateIQTest {
assertEquals(mucLightCreateIQ.getConfiguration().getRoomName(), "test");
- HashMap