From 23190604bdb6a36d12593619cb40b0ca484a4384 Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Sun, 4 Jun 2017 20:41:27 +0200 Subject: [PATCH] Fix typos and xml issues --- .../jivesoftware/smackx/jingle/JingleHandler.java | 2 +- .../jivesoftware/smackx/jingle/JingleManager.java | 8 ++++---- .../smackx/jingle/JingleSessionHandler.java | 2 +- .../jivesoftware/smackx/jingle/element/Jingle.java | 1 + .../smackx/jingle/element/JingleContent.java | 2 +- .../jingle/element/JingleContentDescription.java | 7 ++++--- ...ava => JingleContentDescriptionChildElement.java} | 2 +- .../jingle/element/JingleContentTransport.java | 12 +++++++++--- .../smackx/jingle/element/JingleError.java | 2 +- .../smackx/jingle/element/JingleReason.java | 2 +- .../provider/JingleContentProviderManager.java | 4 ++-- 11 files changed, 26 insertions(+), 18 deletions(-) rename smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/{JingleContentDescriptionPayloadType.java => JingleContentDescriptionChildElement.java} (91%) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleHandler.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleHandler.java index 4f183fc7c..2322a06ac 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleHandler.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleHandler.java @@ -21,6 +21,6 @@ import org.jivesoftware.smackx.jingle.element.Jingle; public interface JingleHandler { - IQ handleRequest(Jingle jingle); + IQ handleJingleRequest(Jingle jingle); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleManager.java index 03fd4fe40..e040e59b6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleManager.java @@ -23,8 +23,8 @@ import java.util.logging.Logger; import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; +import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ.Type; import org.jivesoftware.smackx.jingle.element.Jingle; @@ -72,7 +72,7 @@ public final class JingleManager extends Manager { // TODO handle non existing jingle session handler. return null; } - return jingleSessionHandler.handleRequest(jingle, sid); + return jingleSessionHandler.handleJingleSessionRequest(jingle, sid); } if (jingle.getContents().size() > 1) { @@ -88,7 +88,7 @@ public final class JingleManager extends Manager { // TODO handle non existing content description handler. return null; } - return jingleDescriptionHandler.handleRequest(jingle); + return jingleDescriptionHandler.handleJingleRequest(jingle); } }); } @@ -102,7 +102,7 @@ public final class JingleManager extends Manager { return jingleSessionHandlers.put(fullJidAndSessionId, sessionHandler); } - public JingleSessionHandler unregisterJingleSessionhandler(FullJid otherJid, String sessionId, JingleSessionHandler sessionHandler) { + public JingleSessionHandler unregisterJingleSessionHandler(FullJid otherJid, String sessionId, JingleSessionHandler sessionHandler) { FullJidAndSessionId fullJidAndSessionId = new FullJidAndSessionId(otherJid, sessionId); return jingleSessionHandlers.remove(fullJidAndSessionId); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleSessionHandler.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleSessionHandler.java index db3cc2f98..b830bdbe6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleSessionHandler.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleSessionHandler.java @@ -21,6 +21,6 @@ import org.jivesoftware.smackx.jingle.element.Jingle; public interface JingleSessionHandler { - IQ handleRequest(Jingle jingle, String sessionId); + IQ handleJingleSessionRequest(Jingle jingle, String sessionId); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/Jingle.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/Jingle.java index 1c5661158..210874ce3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/Jingle.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/Jingle.java @@ -78,6 +78,7 @@ public final class Jingle extends IQ { else { this.contents = Collections.emptyList(); } + setType(Type.set); } /** diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContent.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContent.java index ca5696bff..c50307eed 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContent.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContent.java @@ -140,7 +140,7 @@ public final class JingleContent implements NamedElement { @Override public XmlStringBuilder toXML() { - XmlStringBuilder xml = new XmlStringBuilder(); + XmlStringBuilder xml = new XmlStringBuilder(this); xml.attribute(CREATOR_ATTRIBUTE_NAME, creator); xml.optAttribute(DISPOSITION_ATTRIBUTE_NAME, disposition); xml.attribute(NAME_ATTRIBUTE_NAME, name); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescription.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescription.java index 7a1e6463f..90bb96867 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescription.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescription.java @@ -30,9 +30,9 @@ public abstract class JingleContentDescription implements ExtensionElement { public static final String ELEMENT = "description"; - private final List payloads; + private final List payloads; - protected JingleContentDescription(List payloads) { + protected JingleContentDescription(List payloads) { if (payloads != null) { this.payloads = Collections.unmodifiableList(payloads); } @@ -46,7 +46,7 @@ public abstract class JingleContentDescription implements ExtensionElement { return ELEMENT; } - public List getJinglePayloadTypes() { + public List getJingleContentDescriptionChildren() { return payloads; } @@ -62,6 +62,7 @@ public abstract class JingleContentDescription implements ExtensionElement { xml.append(payloads); + xml.closeElement(this); return xml; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescriptionPayloadType.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescriptionChildElement.java similarity index 91% rename from smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescriptionPayloadType.java rename to smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescriptionChildElement.java index ff525b0c1..bb09f205d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescriptionPayloadType.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentDescriptionChildElement.java @@ -22,7 +22,7 @@ import org.jivesoftware.smack.packet.NamedElement; * An element found usually in 'description' elements. * */ -public abstract class JingleContentDescriptionPayloadType implements NamedElement { +public abstract class JingleContentDescriptionChildElement implements NamedElement { public static final String ELEMENT = "payload-type"; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentTransport.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentTransport.java index 5885c5ad8..de8213ca1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentTransport.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleContentTransport.java @@ -58,11 +58,17 @@ public abstract class JingleContentTransport implements ExtensionElement { public final XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); addExtraAttributes(xml); - xml.rightAngleBracket(); - xml.append(candidates); + if (candidates.isEmpty()) { + xml.closeEmptyElement(); + + } else { + + xml.rightAngleBracket(); + xml.append(candidates); + xml.closeElement(this); + } - xml.closeElement(this); return xml; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleError.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleError.java index 6fa132893..9fc717e01 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleError.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleError.java @@ -39,7 +39,7 @@ public final class JingleError implements ExtensionElement { /** * Creates a new error with the specified code and errorName. * - * @param message a message describing the error. + * @param errorName a name describing the error. */ private JingleError(final String errorName) { this.errorName = errorName; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleReason.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleReason.java index b150832d3..f2726f7f0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleReason.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleReason.java @@ -96,7 +96,7 @@ public class JingleReason implements NamedElement { XmlStringBuilder xml = new XmlStringBuilder(this); xml.rightAngleBracket(); - xml.emptyElement(reason); + xml.emptyElement(reason.asString); xml.closeElement(this); return xml; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleContentProviderManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleContentProviderManager.java index a4592e45d..2144d1d01 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleContentProviderManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleContentProviderManager.java @@ -25,7 +25,7 @@ public class JingleContentProviderManager { private static final Map> jingleContentTransportProviders = new ConcurrentHashMap<>(); - public static JingleContentDescriptionProvider addJingleContentDescrptionProvider(String namespace, + public static JingleContentDescriptionProvider addJingleContentDescriptionProvider(String namespace, JingleContentDescriptionProvider provider) { return jingleContentDescriptionProviders.put(namespace, provider); } @@ -34,7 +34,7 @@ public class JingleContentProviderManager { return jingleContentDescriptionProviders.get(namespace); } - public static JingleContentTransportProvider addJingleContentDescrptionProvider(String namespace, + public static JingleContentTransportProvider addJingleContentTransportProvider(String namespace, JingleContentTransportProvider provider) { return jingleContentTransportProviders.put(namespace, provider); }