mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-02 00:42:07 +01:00
Compare commits
No commits in common. "f2e1d7ddd594e6bda1bb4c650fe3c83c7a6d1d3e" and "5b23b9a6ae137fffbf6a8ee341dc126dc40dd4e5" have entirely different histories.
f2e1d7ddd5
...
5b23b9a6ae
135 changed files with 1126 additions and 1132 deletions
|
@ -35,8 +35,7 @@ install: gradle assemble --stacktrace
|
|||
# archive to additionaly test if artifact creation is
|
||||
# functional. Which hasn't always be the case in the past, see
|
||||
# 90cbcaebc7a89f4f771f733a33ac9f389df85be2
|
||||
# Also run javadocAll to ensure it works.
|
||||
script: gradle check install javadocAll --stacktrace
|
||||
script: gradle check install --stacktrace
|
||||
|
||||
after_success:
|
||||
- JAVAC_VERSION=$((javac -version) 2>&1)
|
||||
|
|
22
build.gradle
22
build.gradle
|
@ -15,7 +15,7 @@ buildscript {
|
|||
|
||||
plugins {
|
||||
id 'ru.vyarus.animalsniffer' version '1.5.0'
|
||||
id 'net.ltgt.errorprone' version '0.8.1'
|
||||
id 'net.ltgt.errorprone' version '0.8'
|
||||
}
|
||||
|
||||
apply plugin: 'org.kordamp.gradle.markdown'
|
||||
|
@ -203,11 +203,7 @@ allprojects {
|
|||
'-Werror',
|
||||
]
|
||||
options.errorprone {
|
||||
error(
|
||||
"UnusedVariable",
|
||||
"UnusedMethod",
|
||||
"MethodCanBeStatic",
|
||||
)
|
||||
error("UnusedVariable", "UnusedMethod")
|
||||
errorproneArgs = [
|
||||
// Disable errorprone checks
|
||||
'-Xep:TypeParameterUnusedInFormals:OFF',
|
||||
|
@ -297,25 +293,13 @@ task copyAllJavadocDocFiles(type: Copy) {
|
|||
|
||||
task javadocAll(type: Javadoc, dependsOn: copyAllJavadocDocFiles) {
|
||||
source javadocAllProjects.collect {project ->
|
||||
project.sourceSets.main.allJava.findAll {
|
||||
// Filter out symbolic links to avoid
|
||||
// "warning: a package-info.java file has already been seen for package"
|
||||
// javadoc warnings.
|
||||
!java.nio.file.Files.isSymbolicLink(it.toPath())
|
||||
}
|
||||
}
|
||||
project.sourceSets.main.allJava }
|
||||
destinationDir = javadocAllDir
|
||||
// Might need a classpath
|
||||
classpath = files(subprojects.collect {project ->
|
||||
project.sourceSets.main.compileClasspath})
|
||||
classpath += files(androidBootClasspath)
|
||||
options {
|
||||
// Add source compatiblitiy statement to work around bug in JDK 11
|
||||
// See
|
||||
// - https://bugs.openjdk.java.net/browse/JDK-8217177
|
||||
// - http://hg.openjdk.java.net/jdk/jdk/rev/8ce4083fc831
|
||||
// - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=920020
|
||||
source = sourceCompatibility
|
||||
linkSource = true
|
||||
use = true
|
||||
links = [
|
||||
|
|
|
@ -90,7 +90,6 @@ Experimental Smack Extensions and currently supported XEPs of smack-experimental
|
|||
| [Internet of Things - Sensor Data](iot.md) | [XEP-0323](https://xmpp.org/extensions/xep-0323.html) | n/a | Sensor data interchange over XMPP. |
|
||||
| [Internet of Things - Provisioning](iot.md) | [XEP-0324](https://xmpp.org/extensions/xep-0324.html) | n/a | Provisioning, access rights and user privileges for the Internet of Things. |
|
||||
| [Internet of Things - Control](iot.md) | [XEP-0325](https://xmpp.org/extensions/xep-0325.html) | n/a | Describes how to control devices or actuators in an XMPP-based sensor network. |
|
||||
| Jid Prep | [XEP-0328](https://xmpp.org/extensions/xep-0328.html) | 0.1 | Describes a way for an XMPP client to request an XMPP server to prep and normalize a given JID. |
|
||||
| [HTTP over XMPP transport](hoxt.md) | [XEP-0332](https://xmpp.org/extensions/xep-0332.html) | n/a | Allows to transport HTTP communication over XMPP peer-to-peer networks. |
|
||||
| Chat Markers | [XEP-0333](https://xmpp.org/extensions/xep-0333.html) | n/a | A solution of marking the last received, displayed and acknowledged message in a chat. |
|
||||
| Message Processing Hints | [XEP-0334](https://xmpp.org/extensions/xep-0334.html) | n/a | Hints to entities routing or receiving a message. |
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../smack-extensions/src/main/java/org/jivesoftware/smackx/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO describe me.
|
||||
*/
|
||||
package org.jivesoftware.smackx;
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../../smack-extensions/src/main/java/org/jivesoftware/smackx/ping/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO describe me.
|
||||
*/
|
||||
package org.jivesoftware.smackx.ping;
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../smack-core/src/main/java/org/jivesoftware/smack/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO describe me.
|
||||
*/
|
||||
package org.jivesoftware.smack;
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../../smack-core/src/main/java/org/jivesoftware/smack/util/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO describe me.
|
||||
*/
|
||||
package org.jivesoftware.smack.util;
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../../../smack-core/src/main/java/org/jivesoftware/smack/util/stringencoder/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO describe me.
|
||||
*/
|
||||
package org.jivesoftware.smack.util.stringencoder;
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../../smack-debug/src/main/java/org/jivesoftware/smackx/debugger/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smack optional Debuggers.
|
||||
*/
|
||||
package org.jivesoftware.smackx.debugger;
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../smack-extensions/src/main/java/org/jivesoftware/smackx/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO describe me.
|
||||
*/
|
||||
package org.jivesoftware.smackx;
|
|
@ -3,6 +3,6 @@ Compression with jzlib
|
|||
Allow to compress the XMPP stream with help of jzlib."""
|
||||
|
||||
dependencies {
|
||||
compile project(':smack-core')
|
||||
compile project(path: ':smack-core')
|
||||
compile 'com.jcraft:jzlib:[1.1,1.2)'
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../../smack-core/src/main/java/org/jivesoftware/smack/compression/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Classes and interfaces for XMPP stream compression (XEP-138).
|
||||
*/
|
||||
package org.jivesoftware.smack.compression;
|
|
@ -114,7 +114,9 @@ public class AbstractError {
|
|||
xml.escape(text);
|
||||
xml.closeElement("text");
|
||||
}
|
||||
xml.append(extensions);
|
||||
for (ExtensionElement packetExtension : extensions) {
|
||||
xml.append(packetExtension.toXML());
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class Builder<B extends Builder<B>> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2017-2019 Florian Schmaus
|
||||
* Copyright © 2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,7 +38,8 @@ public abstract class AbstractTextElement implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.optXmlLangAttribute(lang);
|
||||
xml.rightAngleBracket();
|
||||
xml.escape(text);
|
||||
xml.closeElement(this);
|
||||
|
@ -49,19 +50,6 @@ public abstract class AbstractTextElement implements ExtensionElement {
|
|||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getLanguage() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @return deprecated
|
||||
* @deprecated use {@link #getLanguage()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.5.
|
||||
public final String getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
|
|
@ -32,13 +32,4 @@ public interface FullyQualifiedElement extends NamedElement {
|
|||
String localPart = getElementName();
|
||||
return new QName(namespaceURI, localPart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the xml:lang of this XML element, or null if one has not been set.
|
||||
*
|
||||
* @return the xml:lang of this XML element, or null.
|
||||
*/
|
||||
default String getLanguage() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,10 @@ public abstract class IQ extends Stanza {
|
|||
this.childElementQName = iq.childElementQName;
|
||||
}
|
||||
|
||||
protected IQ(String childElementName) {
|
||||
this(childElementName, null);
|
||||
}
|
||||
|
||||
protected IQ(String childElementName, String childElementNamespace) {
|
||||
this.childElementName = childElementName;
|
||||
this.childElementNamespace = childElementNamespace;
|
||||
|
@ -132,11 +136,6 @@ public abstract class IQ extends Stanza {
|
|||
return childElementNamespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getElementName() {
|
||||
return IQ_ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -151,8 +150,9 @@ public abstract class IQ extends Stanza {
|
|||
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this, enclosingXmlEnvironment);
|
||||
addCommonAttributes(buf);
|
||||
XmlStringBuilder buf = new XmlStringBuilder(enclosingXmlEnvironment);
|
||||
buf.halfOpenElement(IQ_ELEMENT);
|
||||
addCommonAttributes(buf, enclosingXmlEnvironment);
|
||||
if (type == null) {
|
||||
buf.attribute("type", "get");
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public abstract class IQ extends Stanza {
|
|||
buf.attribute("type", type.toString());
|
||||
}
|
||||
buf.rightAngleBracket();
|
||||
appendInnerXml(buf);
|
||||
buf.append(getChildElementXML(enclosingXmlEnvironment));
|
||||
buf.closeElement(IQ_ELEMENT);
|
||||
return buf;
|
||||
}
|
||||
|
@ -171,53 +171,45 @@ public abstract class IQ extends Stanza {
|
|||
*
|
||||
* @return the child element section of the IQ XML.
|
||||
*/
|
||||
// TODO: This method should not be part of the public API as it is mostly used for testing purposes, with the one
|
||||
// exception of AdHocCommand.getRaw().
|
||||
public final XmlStringBuilder getChildElementXML() {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
appendInnerXml(xml);
|
||||
return xml;
|
||||
return getChildElementXML(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append the sub-element XML section of the IQ stanza.
|
||||
* Returns the sub-element XML section of the IQ packet, or the empty String if there
|
||||
* isn't one.
|
||||
*
|
||||
* @param xml the XmlStringBuilder to append to.
|
||||
* @param enclosingXmlEnvironment the enclosing XML namespace.
|
||||
* @return the child element section of the IQ XML.
|
||||
* @since 4.3.0
|
||||
*/
|
||||
private void appendInnerXml(XmlStringBuilder xml) {
|
||||
public final XmlStringBuilder getChildElementXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
if (type == Type.error) {
|
||||
// Add the error sub-packet, if there is one.
|
||||
appendErrorIfExists(xml);
|
||||
return;
|
||||
appendErrorIfExists(xml, enclosingXmlEnvironment);
|
||||
}
|
||||
if (childElementName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
else if (childElementName != null) {
|
||||
// Add the query section if there is one.
|
||||
IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(
|
||||
new IQChildElementXmlStringBuilder(this));
|
||||
// TOOD: Document the cases where iqChildElement is null but childElementName not. And if there are none, change
|
||||
// the logic.
|
||||
if (iqChildElement == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this));
|
||||
if (iqChildElement != null) {
|
||||
xml.append(iqChildElement);
|
||||
|
||||
List<ExtensionElement> extensionsXml = getExtensions();
|
||||
if (iqChildElement.isEmptyElement) {
|
||||
if (extensionsXml.isEmpty()) {
|
||||
xml.closeEmptyElement();
|
||||
return;
|
||||
}
|
||||
|
||||
return xml;
|
||||
} else {
|
||||
xml.rightAngleBracket();
|
||||
}
|
||||
|
||||
}
|
||||
xml.append(extensionsXml);
|
||||
xml.closeElement(iqChildElement.element);
|
||||
}
|
||||
}
|
||||
return xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method must be overwritten by IQ subclasses to create their child content. It is important you don't use the builder
|
||||
|
|
|
@ -467,11 +467,6 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
return language;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -486,8 +481,9 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this, enclosingXmlEnvironment);
|
||||
addCommonAttributes(buf);
|
||||
XmlStringBuilder buf = new XmlStringBuilder(enclosingXmlEnvironment);
|
||||
buf.halfOpenElement(ELEMENT);
|
||||
enclosingXmlEnvironment = addCommonAttributes(buf, enclosingXmlEnvironment);
|
||||
buf.optAttribute("type", type);
|
||||
buf.rightAngleBracket();
|
||||
|
||||
|
@ -501,16 +497,16 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
// Skip the default language
|
||||
if (subject.equals(defaultSubject))
|
||||
continue;
|
||||
buf.append(subject);
|
||||
buf.append(subject.toXML());
|
||||
}
|
||||
buf.optElement("thread", thread);
|
||||
// Append the error subpacket if the message type is an error.
|
||||
if (type == Type.error) {
|
||||
appendErrorIfExists(buf);
|
||||
appendErrorIfExists(buf, enclosingXmlEnvironment);
|
||||
}
|
||||
|
||||
// Add extension elements, if any are defined.
|
||||
buf.append(getExtensions());
|
||||
buf.append(getExtensions(), enclosingXmlEnvironment);
|
||||
|
||||
buf.closeElement(ELEMENT);
|
||||
return buf;
|
||||
|
@ -548,7 +544,11 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
this.subject = subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Returns the language of this message subject.
|
||||
*
|
||||
* @return the language of this message subject.
|
||||
*/
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
@ -592,8 +592,8 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
xml.rightAngleBracket();
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(getElementName()).optXmlLangAttribute(getLanguage()).rightAngleBracket();
|
||||
xml.escape(subject);
|
||||
xml.closeElement(getElementName());
|
||||
return xml;
|
||||
|
@ -642,7 +642,12 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
this.namespace = Objects.requireNonNull(namespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Returns the language of this message body or {@code null} if the body extension element does not explicitly
|
||||
* set a language, but instead inherits it from the outer element (usually a {@link Message} stanza).
|
||||
*
|
||||
* @return the language of this message body or {@code null}.
|
||||
*/
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
@ -687,7 +692,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingXmlEnvironment);
|
||||
xml.rightAngleBracket();
|
||||
xml.optXmlLangAttribute(getLanguage()).rightAngleBracket();
|
||||
xml.escape(message);
|
||||
xml.closeElement(getElementName());
|
||||
return xml;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
* Copyright © 2014 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,13 +18,8 @@
|
|||
package org.jivesoftware.smack.packet;
|
||||
|
||||
/**
|
||||
* Interface to represent a XML element. This is similar to {@link ExtensionElement}, but does not carry a single
|
||||
* namespace, but instead is used with multiple namespaces. Examples for this include MUC's <destroy/> element.
|
||||
* <p>
|
||||
* Please note that usage of this interface is <b>discouraged</b>. The reason is that every XML element is fully
|
||||
* qualified, i.e., it is qualified by a namespace. The namespace may not be explicitly given, but instead, is inherited
|
||||
* from an outer element. Use {@link FullyQualifiedElement} instead when possible.
|
||||
* </p>
|
||||
* Interface to represent a XML element. This is similar to {@link ExtensionElement}, but does not
|
||||
* carry a namespace and is usually included as child element of an stanza extension.
|
||||
*/
|
||||
public interface NamedElement extends Element {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
* Copyright © 2014-2015 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,6 @@ package org.jivesoftware.smack.packet;
|
|||
* @author Florian Schmaus
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0360.html">XEP-0360: Nonzas (are not Stanzas)</a>
|
||||
*/
|
||||
public interface Nonza extends TopLevelStreamElement {
|
||||
public interface Nonza extends TopLevelStreamElement, FullyQualifiedElement {
|
||||
|
||||
}
|
||||
|
|
|
@ -113,7 +113,11 @@ public interface Packet extends TopLevelStreamElement {
|
|||
*/
|
||||
void setError(StanzaError error);
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Returns the xml:lang of this Stanza, or null if one has not been set.
|
||||
*
|
||||
* @return the xml:lang of this Stanza, or null.
|
||||
*/
|
||||
String getLanguage();
|
||||
|
||||
/**
|
||||
|
|
|
@ -256,11 +256,6 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
|
|||
this.mode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -282,8 +277,9 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this, enclosingNamespace);
|
||||
addCommonAttributes(buf);
|
||||
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
|
||||
buf.halfOpenElement(ELEMENT);
|
||||
addCommonAttributes(buf, enclosingNamespace);
|
||||
if (type != Type.available) {
|
||||
buf.attribute("type", type);
|
||||
}
|
||||
|
@ -295,10 +291,10 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
|
|||
buf.element("show", mode);
|
||||
}
|
||||
|
||||
buf.append(getExtensions());
|
||||
buf.append(getExtensions(), enclosingNamespace);
|
||||
|
||||
// Add the error sub-packet, if there is one.
|
||||
appendErrorIfExists(buf);
|
||||
appendErrorIfExists(buf, enclosingNamespace);
|
||||
|
||||
buf.closeElement(ELEMENT);
|
||||
|
||||
|
|
|
@ -59,10 +59,6 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
|
||||
private final MultiMap<QName, ExtensionElement> extensionElements = new MultiMap<>();
|
||||
|
||||
// Assume that all stanzas Smack handles are in the client namespace, since Smack is an XMPP client library. We can
|
||||
// change this behavior later if it is required.
|
||||
private final String namespace = StreamOpen.CLIENT_NAMESPACE;
|
||||
|
||||
private String id = null;
|
||||
private Jid to;
|
||||
private Jid from;
|
||||
|
@ -287,7 +283,11 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
error = xmppErrorBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Returns the xml:lang of this Stanza, or null if one has not been set.
|
||||
*
|
||||
* @return the xml:lang of this Stanza, or null.
|
||||
*/
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
@ -491,11 +491,6 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
@Override
|
||||
public abstract String toString();
|
||||
|
||||
@Override
|
||||
public final String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default language used for all messages containing localized content.
|
||||
*
|
||||
|
@ -506,14 +501,33 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add to, from, and id attributes.
|
||||
* Add to, from, id and 'xml:lang' attributes
|
||||
*
|
||||
* @param xml the {@link XmlStringBuilder}.
|
||||
* @param enclosingXmlEnvironment the enclosing XML namespace.
|
||||
* @return the XML environment for this stanza.
|
||||
*/
|
||||
protected final void addCommonAttributes(XmlStringBuilder xml) {
|
||||
protected XmlEnvironment addCommonAttributes(XmlStringBuilder xml, XmlEnvironment enclosingXmlEnvironment) {
|
||||
String language = getLanguage();
|
||||
String namespace = StreamOpen.CLIENT_NAMESPACE;
|
||||
if (enclosingXmlEnvironment != null) {
|
||||
String effectiveEnclosingNamespace = enclosingXmlEnvironment.getEffectiveNamespaceOrUse(namespace);
|
||||
switch (effectiveEnclosingNamespace) {
|
||||
case StreamOpen.CLIENT_NAMESPACE:
|
||||
case StreamOpen.SERVER_NAMESPACE:
|
||||
break;
|
||||
default:
|
||||
namespace = effectiveEnclosingNamespace;
|
||||
}
|
||||
}
|
||||
|
||||
xml.xmlnsAttribute(namespace);
|
||||
xml.optAttribute("to", getTo());
|
||||
xml.optAttribute("from", getFrom());
|
||||
xml.optAttribute("id", getStanzaId());
|
||||
xml.xmllangAttribute(language);
|
||||
|
||||
return new XmlEnvironment(namespace, language);
|
||||
}
|
||||
|
||||
protected void logCommonAttributes(StringBuilder sb) {
|
||||
|
@ -532,11 +546,12 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
* Append an XMPPError is this stanza has one set.
|
||||
*
|
||||
* @param xml the XmlStringBuilder to append the error to.
|
||||
* @param enclosingXmlEnvironment the enclosing XML environment.
|
||||
*/
|
||||
protected void appendErrorIfExists(XmlStringBuilder xml) {
|
||||
protected void appendErrorIfExists(XmlStringBuilder xml, XmlEnvironment enclosingXmlEnvironment) {
|
||||
StanzaError error = getError();
|
||||
if (error != null) {
|
||||
xml.append(error);
|
||||
xml.append(error.toXML(enclosingXmlEnvironment));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
* Copyright © 2014-2018 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,6 +20,6 @@ package org.jivesoftware.smack.packet;
|
|||
* A XMPP top level stream element. This is either a stanza ({@link Stanza}) or
|
||||
* just a plain stream element ({@link Nonza}).
|
||||
*/
|
||||
public interface TopLevelStreamElement extends FullyQualifiedElement {
|
||||
public interface TopLevelStreamElement extends Element {
|
||||
|
||||
}
|
||||
|
|
|
@ -106,29 +106,6 @@ public class XmlEnvironment {
|
|||
return effectiveLanguage;
|
||||
}
|
||||
|
||||
public boolean effectiveLanguageEquals(String language) {
|
||||
String effectiveLanguage = getEffectiveLanguage();
|
||||
if (effectiveLanguage == null) {
|
||||
return false;
|
||||
}
|
||||
return effectiveLanguage.equals(language);
|
||||
}
|
||||
|
||||
private transient String toStringCache;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (toStringCache == null) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(XmlEnvironment.class.getSimpleName()).append(' ');
|
||||
sb.append("xmlns=").append(getEffectiveNamespace()).append(' ');
|
||||
sb.append("xmllang=").append(getEffectiveLanguage()).append(' ');
|
||||
|
||||
toStringCache = sb.toString();
|
||||
}
|
||||
return toStringCache;
|
||||
}
|
||||
|
||||
public static XmlEnvironment from(XmlPullParser parser) {
|
||||
return from(parser, null);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public class PacketParserUtils {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <S extends Stanza> S parseStanza(String stanza) throws XmlPullParserException, SmackParsingException, IOException {
|
||||
return (S) parseStanza(getParserFor(stanza), XmlEnvironment.EMPTY);
|
||||
return (S) parseStanza(getParserFor(stanza), null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,22 +121,8 @@ public class PacketParserUtils {
|
|||
}
|
||||
}
|
||||
|
||||
private static void parseCommonStanzaAttributes(Stanza stanza, XmlPullParser parser, XmlEnvironment xmlEnvironment) throws XmppStringprepException {
|
||||
String id = parser.getAttributeValue("id");
|
||||
stanza.setStanzaId(id);
|
||||
|
||||
Jid to = ParserUtils.getJidAttribute(parser, "to");
|
||||
stanza.setTo(to);
|
||||
|
||||
Jid from = ParserUtils.getJidAttribute(parser, "from");
|
||||
stanza.setFrom(from);
|
||||
|
||||
String language = ParserUtils.getXmlLang(parser, xmlEnvironment);
|
||||
stanza.setLanguage(language);
|
||||
}
|
||||
|
||||
public static Message parseMessage(XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
return parseMessage(parser, XmlEnvironment.EMPTY);
|
||||
return parseMessage(parser, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,11 +142,15 @@ public class PacketParserUtils {
|
|||
XmlEnvironment messageXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
||||
final int initialDepth = parser.getDepth();
|
||||
Message message = new Message();
|
||||
parseCommonStanzaAttributes(message, parser, outerXmlEnvironment);
|
||||
message.setStanzaId(parser.getAttributeValue("", "id"));
|
||||
message.setTo(ParserUtils.getJidAttribute(parser, "to"));
|
||||
message.setFrom(ParserUtils.getJidAttribute(parser, "from"));
|
||||
String typeString = parser.getAttributeValue("", "type");
|
||||
if (typeString != null) {
|
||||
message.setType(Message.Type.fromString(typeString));
|
||||
}
|
||||
String language = ParserUtils.getXmlLang(parser);
|
||||
message.setLanguage(language);
|
||||
|
||||
// Parse sub-elements. We include extra logic to make sure the values
|
||||
// are only read once. This is because it's possible for the names to appear
|
||||
|
@ -419,7 +409,7 @@ public class PacketParserUtils {
|
|||
}
|
||||
|
||||
public static Presence parsePresence(XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
return parsePresence(parser, XmlEnvironment.EMPTY);
|
||||
return parsePresence(parser, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -443,7 +433,14 @@ public class PacketParserUtils {
|
|||
type = Presence.Type.fromString(typeString);
|
||||
}
|
||||
Presence presence = new Presence(type);
|
||||
parseCommonStanzaAttributes(presence, parser, outerXmlEnvironment);
|
||||
presence.setTo(ParserUtils.getJidAttribute(parser, "to"));
|
||||
presence.setFrom(ParserUtils.getJidAttribute(parser, "from"));
|
||||
presence.setStanzaId(parser.getAttributeValue("", "id"));
|
||||
|
||||
String language = ParserUtils.getXmlLang(parser);
|
||||
if (language != null && !"".equals(language.trim())) {
|
||||
presence.setLanguage(language);
|
||||
}
|
||||
|
||||
// Parse sub-elements
|
||||
outerloop: while (true) {
|
||||
|
|
|
@ -27,7 +27,6 @@ import javax.xml.namespace.QName;
|
|||
|
||||
import org.jivesoftware.smack.datatypes.UInt16;
|
||||
import org.jivesoftware.smack.datatypes.UInt32;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
|
||||
|
@ -342,14 +341,6 @@ public class ParserUtils {
|
|||
return text;
|
||||
}
|
||||
|
||||
public static String getXmlLang(XmlPullParser parser, XmlEnvironment xmlEnvironment) {
|
||||
String currentXmlLang = getXmlLang(parser);
|
||||
if (currentXmlLang != null) {
|
||||
return currentXmlLang;
|
||||
}
|
||||
return xmlEnvironment.getEffectiveLanguage();
|
||||
}
|
||||
|
||||
public static String getXmlLang(XmlPullParser parser) {
|
||||
return parser.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang");
|
||||
}
|
||||
|
|
|
@ -38,12 +38,17 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
private final XmlEnvironment effectiveXmlEnvironment;
|
||||
|
||||
public XmlStringBuilder() {
|
||||
this((XmlEnvironment) null);
|
||||
}
|
||||
|
||||
public XmlStringBuilder(XmlEnvironment effectiveXmlEnvironment) {
|
||||
sb = new LazyStringBuilder();
|
||||
effectiveXmlEnvironment = null;
|
||||
this.effectiveXmlEnvironment = effectiveXmlEnvironment;
|
||||
}
|
||||
|
||||
public XmlStringBuilder(ExtensionElement pe) {
|
||||
this(pe, null);
|
||||
this();
|
||||
prelude(pe);
|
||||
}
|
||||
|
||||
public XmlStringBuilder(NamedElement e) {
|
||||
|
@ -51,29 +56,9 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
halfOpenElement(e.getElementName());
|
||||
}
|
||||
|
||||
public XmlStringBuilder(FullyQualifiedElement element, XmlEnvironment enclosingXmlEnvironment) {
|
||||
sb = new LazyStringBuilder();
|
||||
halfOpenElement(element);
|
||||
|
||||
String xmlNs = element.getNamespace();
|
||||
String xmlLang = element.getLanguage();
|
||||
if (enclosingXmlEnvironment == null) {
|
||||
xmlnsAttribute(xmlNs);
|
||||
xmllangAttribute(xmlLang);
|
||||
} else {
|
||||
if (!enclosingXmlEnvironment.effectiveNamespaceEquals(xmlNs)) {
|
||||
xmlnsAttribute(xmlNs);
|
||||
}
|
||||
if (!enclosingXmlEnvironment.effectiveLanguageEquals(xmlLang)) {
|
||||
xmllangAttribute(xmlLang);
|
||||
}
|
||||
}
|
||||
|
||||
effectiveXmlEnvironment = XmlEnvironment.builder()
|
||||
.withNamespace(xmlNs)
|
||||
.withLanguage(xmlLang)
|
||||
.withNext(enclosingXmlEnvironment)
|
||||
.build();
|
||||
public XmlStringBuilder(FullyQualifiedElement ee, XmlEnvironment enclosingXmlEnvironment) {
|
||||
this(enclosingXmlEnvironment);
|
||||
prelude(ee);
|
||||
}
|
||||
|
||||
public XmlStringBuilder escapedElement(String name, String escapedContent) {
|
||||
|
@ -131,15 +116,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());
|
||||
|
@ -177,7 +153,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
|
||||
public XmlStringBuilder optElement(Element element) {
|
||||
if (element != null) {
|
||||
append(element);
|
||||
append(element.toXML());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -451,7 +427,6 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
}
|
||||
|
||||
public XmlStringBuilder xmllangAttribute(String value) {
|
||||
// TODO: This should probably be attribute(), not optAttribute().
|
||||
optAttribute("xml:lang", value);
|
||||
return this;
|
||||
}
|
||||
|
@ -486,11 +461,11 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
return escape(text.toString());
|
||||
}
|
||||
|
||||
protected XmlStringBuilder prelude(FullyQualifiedElement pe) {
|
||||
public XmlStringBuilder prelude(FullyQualifiedElement pe) {
|
||||
return prelude(pe.getElementName(), pe.getNamespace());
|
||||
}
|
||||
|
||||
protected XmlStringBuilder prelude(String elementName, String namespace) {
|
||||
public XmlStringBuilder prelude(String elementName, String namespace) {
|
||||
halfOpenElement(elementName);
|
||||
xmlnsAttribute(namespace);
|
||||
return this;
|
||||
|
@ -516,13 +491,13 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
return this;
|
||||
}
|
||||
|
||||
public XmlStringBuilder append(Element element) {
|
||||
return append(element.toXML(effectiveXmlEnvironment));
|
||||
public XmlStringBuilder append(Collection<? extends Element> elements) {
|
||||
return append(elements, null);
|
||||
}
|
||||
|
||||
public XmlStringBuilder append(Collection<? extends Element> elements) {
|
||||
public XmlStringBuilder append(Collection<? extends Element> elements, XmlEnvironment enclosingXmlEnvironment) {
|
||||
for (Element element : elements) {
|
||||
append(element);
|
||||
append(element.toXML(enclosingXmlEnvironment));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -616,10 +591,21 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
* @throws IOException if an I/O error occured.
|
||||
*/
|
||||
public void write(Writer writer, String enclosingNamespace) throws IOException {
|
||||
XmlEnvironment enclosingXmlEnvironment = XmlEnvironment.builder()
|
||||
.withNamespace(enclosingNamespace)
|
||||
.build();
|
||||
appendXmlTo(writer, enclosingXmlEnvironment);
|
||||
for (CharSequence csq : sb.getAsList()) {
|
||||
if (csq instanceof XmlStringBuilder) {
|
||||
((XmlStringBuilder) csq).write(writer, enclosingNamespace);
|
||||
}
|
||||
else if (csq instanceof XmlNsAttribute) {
|
||||
XmlNsAttribute xmlNsAttribute = (XmlNsAttribute) csq;
|
||||
if (!xmlNsAttribute.value.equals(enclosingNamespace)) {
|
||||
writer.write(xmlNsAttribute.toString());
|
||||
enclosingNamespace = xmlNsAttribute.value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
writer.write(csq.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<CharSequence> getCharSequenceIterator() {
|
||||
|
@ -629,19 +615,14 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
@Override
|
||||
public CharSequence toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
try {
|
||||
appendXmlTo(res, enclosingXmlEnvironment);
|
||||
} catch (IOException e) {
|
||||
// Should never happen.
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private void appendXmlTo(Appendable appendable, XmlEnvironment enclosingXmlEnvironment) throws IOException {
|
||||
private void appendXmlTo(StringBuilder res, XmlEnvironment enclosingXmlEnvironment) {
|
||||
for (CharSequence csq : sb.getAsList()) {
|
||||
if (csq instanceof XmlStringBuilder) {
|
||||
((XmlStringBuilder) csq).appendXmlTo(appendable, enclosingXmlEnvironment);
|
||||
((XmlStringBuilder) csq).appendXmlTo(res, enclosingXmlEnvironment);
|
||||
}
|
||||
else if (csq instanceof XmlNsAttribute) {
|
||||
XmlNsAttribute xmlNsAttribute = (XmlNsAttribute) csq;
|
||||
|
@ -651,7 +632,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
}
|
||||
}
|
||||
else {
|
||||
appendable.append(csq);
|
||||
res.append(csq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,10 +188,5 @@ public class StanzaCollectorTest {
|
|||
public String toString() {
|
||||
return toXML().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return "packetId";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -738,6 +738,10 @@ public class PacketParserUtilsTest {
|
|||
.a("type", "chat")
|
||||
.a("xml:lang", "en")
|
||||
.e("body")
|
||||
// TODO: Remove the following xml:lang once Smack's serialization toXml() API is aware of a potential
|
||||
// scoping xml:lang value. The out message stanza already declares an xml:lang with the exact same
|
||||
// value, hence this statement is redundant.
|
||||
.a("xml:lang", "en")
|
||||
.t("This is a test of the emergency broadcast system, 1.")
|
||||
.up()
|
||||
.e("body")
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../../smack-debug/src/main/java/org/jivesoftware/smackx/debugger/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smack optional Debuggers.
|
||||
*/
|
||||
package org.jivesoftware.smackx.debugger;
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../smack-extensions/src/main/java/org/jivesoftware/smackx/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO describe me.
|
||||
*/
|
||||
package org.jivesoftware.smackx;
|
|
@ -943,11 +943,6 @@ public class EnhancedDebugger extends SmackDebugger {
|
|||
public String toString() {
|
||||
return toXML((XmlEnvironment) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../smack-extensions/src/main/java/org/jivesoftware/smackx/package-info.java
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO describe me.
|
||||
*/
|
||||
package org.jivesoftware.smackx;
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
|
@ -146,19 +145,12 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
protected abstract B getThis();
|
||||
}
|
||||
|
||||
private abstract static class HoxExtensionElement implements ExtensionElement {
|
||||
@Override
|
||||
public final String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Representation of Data element.
|
||||
* <p>
|
||||
* This class is immutable.
|
||||
*/
|
||||
public static class Data extends HoxExtensionElement {
|
||||
public static class Data implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "data";
|
||||
|
||||
|
@ -180,9 +172,9 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
*/
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.append(child);
|
||||
xml.element(child);
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
|
@ -207,7 +199,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
* <p>
|
||||
* This class is immutable.
|
||||
*/
|
||||
public static class Text extends HoxExtensionElement {
|
||||
public static class Text implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "text";
|
||||
|
||||
|
@ -224,7 +216,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.optAppend(text);
|
||||
xml.closeElement(this);
|
||||
|
@ -251,7 +243,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
* <p>
|
||||
* This class is immutable.
|
||||
*/
|
||||
public static class Base64 extends HoxExtensionElement {
|
||||
public static class Base64 implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "base64";
|
||||
|
||||
|
@ -268,7 +260,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.optAppend(text);
|
||||
xml.closeElement(this);
|
||||
|
@ -295,7 +287,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
* <p>
|
||||
* This class is immutable.
|
||||
*/
|
||||
public static class Xml extends HoxExtensionElement {
|
||||
public static class Xml implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "xml";
|
||||
|
||||
|
@ -312,7 +304,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.optAppend(text);
|
||||
xml.closeElement(this);
|
||||
|
@ -339,7 +331,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
* <p>
|
||||
* This class is immutable.
|
||||
*/
|
||||
public static class ChunkedBase64 extends HoxExtensionElement {
|
||||
public static class ChunkedBase64 implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "chunkedBase64";
|
||||
|
||||
|
@ -356,7 +348,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("streamId", streamId);
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
|
@ -382,7 +374,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
* <p>
|
||||
* This class is immutable.
|
||||
*/
|
||||
public static class Ibb extends HoxExtensionElement {
|
||||
public static class Ibb implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "ibb";
|
||||
|
||||
|
@ -399,7 +391,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("sid", sid);
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016-2019 Florian Schmaus
|
||||
* Copyright © 2016 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,10 +18,10 @@ package org.jivesoftware.smackx.iot.control.element;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public abstract class SetData implements ExtensionElement {
|
||||
public abstract class SetData implements NamedElement {
|
||||
|
||||
public enum Type {
|
||||
BOOL,
|
||||
|
@ -76,11 +76,6 @@ public abstract class SetData implements ExtensionElement {
|
|||
return getType().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getNamespace() {
|
||||
return IoTSetRequest.NAMESPACE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML representation of this Element.
|
||||
*
|
||||
|
@ -88,7 +83,7 @@ public abstract class SetData implements ExtensionElement {
|
|||
*/
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("name", name);
|
||||
xml.attribute("value", value);
|
||||
xml.closeEmptyElement();
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.iot.data.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
public abstract class IoTDataExtensionElement implements ExtensionElement {
|
||||
|
||||
@Override
|
||||
public final String getNamespace() {
|
||||
return IoTFieldsExtension.NAMESPACE;
|
||||
}
|
||||
|
||||
}
|
|
@ -16,9 +16,10 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.iot.data.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public abstract class IoTDataField extends IoTDataExtensionElement {
|
||||
public abstract class IoTDataField implements NamedElement {
|
||||
|
||||
enum Type {
|
||||
integer("int"),
|
||||
|
@ -52,7 +53,7 @@ public abstract class IoTDataField extends IoTDataExtensionElement {
|
|||
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("name", name).attribute("value", getValueString());
|
||||
// TODO handle 'unit' attribute as special case if <numeric/> is implemented.
|
||||
xml.closeEmptyElement();
|
||||
|
|
|
@ -19,10 +19,12 @@ package org.jivesoftware.smackx.iot.data.element;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
import org.jivesoftware.smackx.iot.element.NodeInfo;
|
||||
|
||||
public class NodeElement extends IoTDataExtensionElement {
|
||||
public class NodeElement implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "node";
|
||||
|
||||
|
@ -49,7 +51,7 @@ public class NodeElement extends IoTDataExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
nodeInfo.appendTo(xml);
|
||||
xml.rightAngleBracket();
|
||||
|
||||
|
|
|
@ -20,9 +20,10 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public class TimestampElement extends IoTDataExtensionElement {
|
||||
public class TimestampElement implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "timestamp";
|
||||
|
||||
|
@ -45,7 +46,7 @@ public class TimestampElement extends IoTDataExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("value", date);
|
||||
xml.rightAngleBracket();
|
||||
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jid_prep;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.jid_prep.element.JidPrepIq;
|
||||
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
public class JidPrepManager extends Manager {
|
||||
|
||||
public static final String NAMESPACE = JidPrepIq.NAMESPACE;
|
||||
|
||||
private static final Map<XMPPConnection, JidPrepManager> INSTANCES = new WeakHashMap<>();
|
||||
|
||||
private final ServiceDiscoveryManager serviceDiscoveryManager;
|
||||
|
||||
public static synchronized JidPrepManager getInstanceFor(XMPPConnection connection) {
|
||||
JidPrepManager manager = INSTANCES.get(connection);
|
||||
if (manager == null) {
|
||||
manager = new JidPrepManager(connection);
|
||||
INSTANCES.put(connection, manager);
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
public JidPrepManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
|
||||
serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
}
|
||||
|
||||
public String requestJidPrep(String jidToBePrepped)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
DomainBareJid serviceAddress = serviceDiscoveryManager.findService(NAMESPACE, true);
|
||||
return requestJidPrep(serviceAddress, jidToBePrepped);
|
||||
}
|
||||
|
||||
public String requestJidPrep(Jid jidPrepService, String jidToBePrepped)
|
||||
throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException {
|
||||
JidPrepIq jidPrepRequest = new JidPrepIq(jidToBePrepped);
|
||||
jidPrepRequest.setTo(jidPrepService);
|
||||
|
||||
JidPrepIq jidPrepResponse;
|
||||
try {
|
||||
jidPrepResponse = connection().sendIqRequestAndWaitForResponse(jidPrepRequest);
|
||||
} catch (XMPPErrorException e) {
|
||||
StanzaError stanzaError = e.getStanzaError();
|
||||
if (stanzaError.getCondition() == StanzaError.Condition.jid_malformed) {
|
||||
// jid-malformed is, sadly, returned if the jid can not be normalized. This means we can not distinguish
|
||||
// if the error is returned because e.g. the IQ's 'to' address was malformed (c.f. RFC 6120 § 8.3.3.8)
|
||||
// or if the JID to prep was malformed. Assume the later is the case and return 'null'.
|
||||
return null;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
return jidPrepResponse.getJid();
|
||||
}
|
||||
|
||||
public boolean isSupported(Jid jid)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
return serviceDiscoveryManager.supportsFeature(jid, NAMESPACE);
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jid_prep.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
public class JidPrepIq extends IQ {
|
||||
|
||||
public static final String ELEMENT = "jid";
|
||||
public static final String NAMESPACE = "urn:xmpp:jidprep:0";
|
||||
|
||||
private final String jid;
|
||||
|
||||
public JidPrepIq(String jid) {
|
||||
super(ELEMENT, NAMESPACE);
|
||||
this.jid = jid;
|
||||
}
|
||||
|
||||
public String getJid() {
|
||||
return jid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
xml.escape(jid);
|
||||
|
||||
return xml;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* XML elements for XEP-0328: JID Prep.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jid_prep.element;
|
|
@ -1,23 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smack's API for XEP-0328: JID Prep.
|
||||
*
|
||||
* @see <a href="https://xmpp.org/extensions/xep-0328.html">XEP-0328: JID Prep</a>
|
||||
*/
|
||||
package org.jivesoftware.smackx.jid_prep;
|
|
@ -1,38 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jid_prep.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
import org.jivesoftware.smackx.jid_prep.element.JidPrepIq;
|
||||
|
||||
public class JidPrepIqProvider extends IQProvider<JidPrepIq> {
|
||||
|
||||
@Override
|
||||
public JidPrepIq parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String jid = parser.nextText();
|
||||
|
||||
return new JidPrepIq(jid);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Providers for XEP-0328: JID Prep.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jid_prep.provider;
|
|
@ -52,7 +52,7 @@ public class Checksum implements ExtensionElement {
|
|||
sb.optAttribute(ATTR_CREATOR, creator);
|
||||
sb.optAttribute(ATTR_NAME, name);
|
||||
sb.rightAngleBracket();
|
||||
sb.append(file);
|
||||
sb.element(file);
|
||||
sb.closeElement(this);
|
||||
return sb;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Paul Schaub, 2019 Florian Schmaus
|
||||
* Copyright 2017 Paul Schaub
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.jingle_filetransfer.element;
|
|||
import java.io.File;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
|
@ -28,10 +27,8 @@ import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildEleme
|
|||
/**
|
||||
* Content of type File.
|
||||
*/
|
||||
public class JingleFileTransferChild implements JingleContentDescriptionChildElement {
|
||||
public class JingleFileTransferChild extends JingleContentDescriptionChildElement {
|
||||
public static final String ELEMENT = "file";
|
||||
public static final String NAMESPACE = JingleFileTransfer.NAMESPACE_V5;
|
||||
|
||||
public static final String ELEM_DATE = "date";
|
||||
public static final String ELEM_DESC = "desc";
|
||||
public static final String ELEM_MEDIA_TYPE = "media-type";
|
||||
|
@ -90,13 +87,8 @@ public class JingleFileTransferChild implements JingleContentDescriptionChildEle
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder sb = new XmlStringBuilder(this, enclosingNamespace);
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder sb = new XmlStringBuilder(this);
|
||||
sb.rightAngleBracket();
|
||||
|
||||
sb.optElement(ELEM_DATE, date);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle_filetransfer.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
|
@ -24,11 +24,9 @@ import org.jivesoftware.smackx.hashes.element.HashElement;
|
|||
/**
|
||||
* RangeElement which specifies, which range of a file shall be transferred.
|
||||
*/
|
||||
public class Range implements FullyQualifiedElement {
|
||||
public class Range implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "range";
|
||||
public static final String NAMESPACE = JingleFileTransferChild.NAMESPACE;
|
||||
|
||||
public static final String ATTR_OFFSET = "offset";
|
||||
public static final String ATTR_LENGTH = "length";
|
||||
|
||||
|
@ -101,11 +99,6 @@ public class Range implements FullyQualifiedElement {
|
|||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder sb = new XmlStringBuilder(this);
|
||||
|
@ -115,7 +108,7 @@ public class Range implements FullyQualifiedElement {
|
|||
|
||||
if (hash != null) {
|
||||
sb.rightAngleBracket();
|
||||
sb.append(hash);
|
||||
sb.element(hash);
|
||||
sb.closeElement(this);
|
||||
} else {
|
||||
sb.closeEmptyElement();
|
||||
|
|
|
@ -126,14 +126,15 @@ public class MamElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.xmlnsAttribute(NAMESPACE);
|
||||
xml.optAttribute("queryid", getQueryId());
|
||||
xml.optAttribute("id", getId());
|
||||
xml.rightAngleBracket();
|
||||
|
||||
xml.append(getForwarded());
|
||||
xml.element(getForwarded());
|
||||
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
|
|
|
@ -124,7 +124,7 @@ public class MamFinIQ extends IQ {
|
|||
xml.setEmptyElement();
|
||||
} else {
|
||||
xml.rightAngleBracket();
|
||||
xml.append(rsmSet);
|
||||
xml.element(rsmSet);
|
||||
}
|
||||
return xml;
|
||||
}
|
||||
|
|
|
@ -134,12 +134,12 @@ public class MamPrefsIQ extends IQ {
|
|||
|
||||
if (alwaysJids != null) {
|
||||
MamElements.AlwaysJidListElement alwaysElement = new AlwaysJidListElement(alwaysJids);
|
||||
xml.append(alwaysElement);
|
||||
xml.element(alwaysElement);
|
||||
}
|
||||
|
||||
if (neverJids != null) {
|
||||
MamElements.NeverJidListElement neverElement = new NeverJidListElement(neverJids);
|
||||
xml.append(neverElement);
|
||||
xml.element(neverElement);
|
||||
}
|
||||
|
||||
return xml;
|
||||
|
|
|
@ -16,10 +16,14 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.message_markup.element;
|
||||
|
||||
public class BlockQuoteElement extends MarkupElement.BlockLevelMarkupElement {
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public class BlockQuoteElement implements MarkupElement.BlockLevelMarkupElement {
|
||||
|
||||
public static final String ELEMENT = "bquote";
|
||||
|
||||
private final int start, end;
|
||||
|
||||
/**
|
||||
* Create a new Block Quote element.
|
||||
*
|
||||
|
@ -27,7 +31,18 @@ public class BlockQuoteElement extends MarkupElement.BlockLevelMarkupElement {
|
|||
* @param end end index
|
||||
*/
|
||||
public BlockQuoteElement(int start, int end) {
|
||||
super(start, end);
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,4 +50,13 @@ public class BlockQuoteElement extends MarkupElement.BlockLevelMarkupElement {
|
|||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
xml.attribute(ATTR_END, getEnd());
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,14 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.message_markup.element;
|
||||
|
||||
public class CodeBlockElement extends MarkupElement.BlockLevelMarkupElement {
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public class CodeBlockElement implements MarkupElement.BlockLevelMarkupElement {
|
||||
|
||||
public static final String ELEMENT = "bcode";
|
||||
|
||||
private final int start, end;
|
||||
|
||||
/**
|
||||
* Create a new Code Block element.
|
||||
*
|
||||
|
@ -27,7 +31,18 @@ public class CodeBlockElement extends MarkupElement.BlockLevelMarkupElement {
|
|||
* @param end end index
|
||||
*/
|
||||
public CodeBlockElement(int start, int end) {
|
||||
super(start, end);
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,4 +50,13 @@ public class CodeBlockElement extends MarkupElement.BlockLevelMarkupElement {
|
|||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
xml.attribute(ATTR_END, getEnd());
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,15 @@ package org.jivesoftware.smackx.message_markup.element;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public class ListElement extends MarkupElement.NonEmptyChildElement {
|
||||
public class ListElement implements MarkupElement.MarkupChildElement {
|
||||
|
||||
public static final String ELEMENT = "list";
|
||||
public static final String ELEM_LI = "li";
|
||||
|
||||
private final int start, end;
|
||||
private final List<ListEntryElement> entries;
|
||||
|
||||
/**
|
||||
|
@ -37,10 +38,21 @@ public class ListElement extends MarkupElement.NonEmptyChildElement {
|
|||
* @param entries list entries
|
||||
*/
|
||||
public ListElement(int start, int end, List<ListEntryElement> entries) {
|
||||
super(start, end);
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.entries = Collections.unmodifiableList(entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all list entries.
|
||||
*
|
||||
|
@ -56,11 +68,22 @@ public class ListElement extends MarkupElement.NonEmptyChildElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void appendInnerXml(XmlStringBuilder xml) {
|
||||
xml.append(getEntries());
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
xml.attribute(ATTR_END, getEnd());
|
||||
xml.rightAngleBracket();
|
||||
|
||||
for (ListEntryElement li : getEntries()) {
|
||||
xml.append(li.toXML());
|
||||
}
|
||||
|
||||
public static class ListEntryElement implements ExtensionElement {
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
|
||||
public static class ListEntryElement implements NamedElement {
|
||||
|
||||
private final int start;
|
||||
|
||||
|
@ -86,15 +109,11 @@ public class ListElement extends MarkupElement.NonEmptyChildElement {
|
|||
return ELEM_LI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return MarkupElement.NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
xml.attribute(MarkupElement.MarkupChildElement.ATTR_START, getStart());
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public class MarkupElement implements ExtensionElement {
|
||||
|
@ -266,89 +267,46 @@ public class MarkupElement implements ExtensionElement {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface for child elements.
|
||||
*/
|
||||
public abstract static class MarkupChildElement implements ExtensionElement {
|
||||
public interface MarkupChildElement extends NamedElement {
|
||||
|
||||
public static final String ATTR_START = "start";
|
||||
public static final String ATTR_END = "end";
|
||||
|
||||
private final int start, end;
|
||||
|
||||
protected MarkupChildElement(int start, int end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
String ATTR_START = "start";
|
||||
String ATTR_END = "end";
|
||||
|
||||
/**
|
||||
* Return the start index of this element.
|
||||
*
|
||||
* @return start index
|
||||
*/
|
||||
public final int getStart() {
|
||||
return start;
|
||||
}
|
||||
int getStart();
|
||||
|
||||
/**
|
||||
* Return the end index of this element.
|
||||
*
|
||||
* @return end index
|
||||
*/
|
||||
public final int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
xml.attribute(ATTR_END, getEnd());
|
||||
|
||||
afterXmlPrelude(xml);
|
||||
return xml;
|
||||
}
|
||||
|
||||
protected abstract void afterXmlPrelude(XmlStringBuilder xml);
|
||||
}
|
||||
|
||||
public abstract static class NonEmptyChildElement extends MarkupChildElement {
|
||||
|
||||
protected NonEmptyChildElement(int start, int end) {
|
||||
super(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void afterXmlPrelude(XmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
|
||||
appendInnerXml(xml);
|
||||
|
||||
xml.closeElement(this);
|
||||
}
|
||||
|
||||
protected abstract void appendInnerXml(XmlStringBuilder xml);
|
||||
|
||||
int getEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for block level child elements.
|
||||
*/
|
||||
public abstract static class BlockLevelMarkupElement extends MarkupChildElement {
|
||||
|
||||
protected BlockLevelMarkupElement(int start, int end) {
|
||||
super(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void afterXmlPrelude(XmlStringBuilder xml) {
|
||||
xml.closeEmptyElement();
|
||||
}
|
||||
public interface BlockLevelMarkupElement extends MarkupChildElement {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,11 @@ import java.util.Set;
|
|||
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public class SpanElement extends MarkupElement.NonEmptyChildElement {
|
||||
public class SpanElement implements MarkupElement.MarkupChildElement {
|
||||
|
||||
public static final String ELEMENT = "span";
|
||||
|
||||
private final int start, end;
|
||||
private final Set<SpanStyle> styles;
|
||||
|
||||
/**
|
||||
|
@ -35,10 +36,21 @@ public class SpanElement extends MarkupElement.NonEmptyChildElement {
|
|||
* @param styles list of styles that apply to this span
|
||||
*/
|
||||
public SpanElement(int start, int end, Set<SpanStyle> styles) {
|
||||
super(start, end);
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.styles = Collections.unmodifiableSet(styles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all styles of this span.
|
||||
*
|
||||
|
@ -64,9 +76,18 @@ public class SpanElement extends MarkupElement.NonEmptyChildElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void appendInnerXml(XmlStringBuilder xml) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
xml.attribute(ATTR_END, getEnd());
|
||||
xml.rightAngleBracket();
|
||||
|
||||
for (SpanStyle style : getStyles()) {
|
||||
xml.emptyElement(style);
|
||||
}
|
||||
xml.halfOpenElement(style.toString()).closeEmptyElement();
|
||||
}
|
||||
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MUCLightAffiliationsIQ extends IQ {
|
|||
Iterator<Map.Entry<Jid, MUCLightAffiliation>> it = affiliations.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Jid, MUCLightAffiliation> pair = it.next();
|
||||
xml.append(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
|
||||
xml.element(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
|
||||
}
|
||||
|
||||
return xml;
|
||||
|
|
|
@ -86,11 +86,11 @@ public class MUCLightBlockingIQ extends IQ {
|
|||
return xml;
|
||||
}
|
||||
|
||||
private static void parseBlocking(IQChildElementXmlStringBuilder xml, HashMap<Jid, Boolean> map, boolean isRoom) {
|
||||
private void parseBlocking(IQChildElementXmlStringBuilder xml, HashMap<Jid, Boolean> map, boolean isRoom) {
|
||||
Iterator<Map.Entry<Jid, Boolean>> it = map.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Jid, Boolean> pair = it.next();
|
||||
xml.append(new BlockingElement(pair.getKey(), pair.getValue(), isRoom));
|
||||
xml.element(new BlockingElement(pair.getKey(), pair.getValue(), isRoom));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public class MUCLightChangeAffiliationsIQ extends IQ {
|
|||
Iterator<Map.Entry<Jid, MUCLightAffiliation>> it = affiliations.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Jid, MUCLightAffiliation> pair = it.next();
|
||||
xml.append(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
|
||||
xml.element(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class MUCLightConfigurationIQ extends IQ {
|
|||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
xml.optElement("version", version);
|
||||
xml.append(new ConfigurationElement(configuration));
|
||||
xml.element(new ConfigurationElement(configuration));
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,10 +99,10 @@ public class MUCLightCreateIQ extends IQ {
|
|||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
xml.append(new ConfigurationElement(configuration));
|
||||
xml.element(new ConfigurationElement(configuration));
|
||||
|
||||
if (!occupants.isEmpty()) {
|
||||
xml.append(new OccupantsElement(occupants));
|
||||
xml.element(new OccupantsElement(occupants));
|
||||
}
|
||||
|
||||
return xml;
|
||||
|
|
|
@ -104,7 +104,7 @@ public abstract class MUCLightElements {
|
|||
Iterator<Map.Entry<Jid, MUCLightAffiliation>> it = affiliations.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Jid, MUCLightAffiliation> pair = it.next();
|
||||
xml.append(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
|
||||
xml.element(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
|
||||
}
|
||||
|
||||
xml.closeElement(this);
|
||||
|
@ -303,7 +303,7 @@ public abstract class MUCLightElements {
|
|||
Iterator<Map.Entry<Jid, MUCLightAffiliation>> it = occupants.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Jid, MUCLightAffiliation> pair = it.next();
|
||||
xml.append(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
|
||||
xml.element(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
|
||||
}
|
||||
|
||||
xml.closeElement("occupants");
|
||||
|
|
|
@ -62,8 +62,8 @@ public class MUCLightInfoIQ extends IQ {
|
|||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
xml.optElement("version", version);
|
||||
xml.append(new ConfigurationElement(configuration));
|
||||
xml.append(new OccupantsElement(occupants));
|
||||
xml.element(new ConfigurationElement(configuration));
|
||||
xml.element(new OccupantsElement(occupants));
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ public class EnablePushNotificationsIQ extends IQ {
|
|||
dataForm.addField(field.build());
|
||||
}
|
||||
|
||||
xml.append(dataForm);
|
||||
xml.element(dataForm);
|
||||
}
|
||||
|
||||
return xml;
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.jivesoftware.smack.XMPPConnectionRegistry;
|
|||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.MessageTypeFilter;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.ToTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -36,15 +35,6 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.sid.element.OriginIdElement;
|
||||
|
||||
/**
|
||||
* Manager class for Stable and Unique Stanza IDs.
|
||||
*
|
||||
* In order to start automatically appending origin ids to outgoing messages, use {@link #enable()}.
|
||||
* This will announce support via the {@link ServiceDiscoveryManager}. If you want to stop appending origin-ids
|
||||
* and de-announce support, call {@link #disable()}.
|
||||
*
|
||||
* @see <a href="https://xmpp.org/extensions/xep-0359.html">XEP-0359: Stable and Unique Stanza IDs</a>
|
||||
*/
|
||||
public final class StableUniqueStanzaIdManager extends Manager {
|
||||
|
||||
public static final String NAMESPACE = "urn:xmpp:sid:0";
|
||||
|
@ -56,9 +46,6 @@ public final class StableUniqueStanzaIdManager extends Manager {
|
|||
MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE,
|
||||
ToTypeFilter.ENTITY_FULL_OR_BARE_JID);
|
||||
|
||||
// Filter that filters for messages with an origin id
|
||||
private static final StanzaFilter ORIGIN_ID_FILTER = new StanzaExtensionFilter(OriginIdElement.ELEMENT, NAMESPACE);
|
||||
|
||||
// Listener for outgoing stanzas that adds origin-ids to outgoing stanzas.
|
||||
private static final StanzaListener ADD_ORIGIN_ID_INTERCEPTOR = new StanzaListener() {
|
||||
@Override
|
||||
|
@ -79,7 +66,7 @@ public final class StableUniqueStanzaIdManager extends Manager {
|
|||
|
||||
/**
|
||||
* Private constructor.
|
||||
* @param connection XMPP connection
|
||||
* @param connection TODO javadoc me please
|
||||
*/
|
||||
private StableUniqueStanzaIdManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
|
@ -106,8 +93,7 @@ public final class StableUniqueStanzaIdManager extends Manager {
|
|||
*/
|
||||
public synchronized void enable() {
|
||||
ServiceDiscoveryManager.getInstanceFor(connection()).addFeature(NAMESPACE);
|
||||
// We need a filter for outgoing messages that do not carry an origin-id already
|
||||
StanzaFilter filter = new AndFilter(OUTGOING_FILTER, new NotFilter(ORIGIN_ID_FILTER));
|
||||
StanzaFilter filter = new AndFilter(OUTGOING_FILTER, new NotFilter(OUTGOING_FILTER));
|
||||
connection().addStanzaInterceptor(ADD_ORIGIN_ID_INTERCEPTOR, filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,12 @@ public class SpoilerElement implements ExtensionElement {
|
|||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Return the language of the hint.
|
||||
* May be null.
|
||||
*
|
||||
* @return language of hint text
|
||||
*/
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
@ -148,7 +153,8 @@ public class SpoilerElement implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.optXmlLangAttribute(getLanguage());
|
||||
if (getHint() == null) {
|
||||
xml.closeEmptyElement();
|
||||
} else {
|
||||
|
|
|
@ -324,11 +324,4 @@
|
|||
<className>org.jivesoftware.smackx.dox.provider.DnsIqProvider</className>
|
||||
</iqProvider>
|
||||
|
||||
<!-- XEP-0328: JID Prep -->
|
||||
<iqProvider>
|
||||
<elementName>jid</elementName>
|
||||
<namespace>urn:xmpp:jidprep:0</namespace>
|
||||
<className>org.jivesoftware.smackx.jid_prep.provider.JidPrepIqProvider</className>
|
||||
</iqProvider>
|
||||
|
||||
</smackProviders>
|
||||
|
|
|
@ -47,7 +47,7 @@ public class PagingTest extends MamTest {
|
|||
|
||||
assertEquals(mamQueryIQ.getDataForm(), dataForm);
|
||||
assertEquals(mamQueryIQ.getDataForm().getFields().get(0).getValues().get(0).toString(), "urn:xmpp:mam:1");
|
||||
assertEquals(pagingStanza, mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), pagingStanza);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,7 +82,8 @@ public class QueryArchiveTest extends MamTest {
|
|||
|
||||
message.addExtension(new MamResultExtension("g27", "34482-21985-73620", forwarded));
|
||||
|
||||
assertEquals(mamQueryResultExample, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
// FIXME: The order of assertEquals is reversed, fix it by switching it.
|
||||
assertEquals(message.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamQueryResultExample);
|
||||
|
||||
MamResultExtension mamResultExtension = MamResultExtension.from(message);
|
||||
|
||||
|
|
|
@ -212,19 +212,19 @@ public class MultipleRecipientManager {
|
|||
if (to != null) {
|
||||
for (Jid jid : to) {
|
||||
packet.setTo(jid);
|
||||
connection.sendStanza(new PacketCopy(packet));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (cc != null) {
|
||||
for (Jid jid : cc) {
|
||||
packet.setTo(jid);
|
||||
connection.sendStanza(new PacketCopy(packet));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (bcc != null) {
|
||||
for (Jid jid : bcc) {
|
||||
packet.setTo(jid);
|
||||
connection.sendStanza(new PacketCopy(packet));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +297,6 @@ public class MultipleRecipientManager {
|
|||
*/
|
||||
private static final class PacketCopy extends Stanza {
|
||||
|
||||
private final String elementName;
|
||||
private final CharSequence text;
|
||||
|
||||
/**
|
||||
|
@ -306,9 +305,8 @@ public class MultipleRecipientManager {
|
|||
*
|
||||
* @param text the whole text of the stanza to send
|
||||
*/
|
||||
private PacketCopy(Stanza stanza) {
|
||||
this.elementName = stanza.getElementName();
|
||||
this.text = stanza.toXML();
|
||||
private PacketCopy(CharSequence text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -321,11 +319,6 @@ public class MultipleRecipientManager {
|
|||
return toXML().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return elementName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
@ -128,7 +129,7 @@ public class MultipleAddresses implements ExtensionElement {
|
|||
return buf;
|
||||
}
|
||||
|
||||
public static final class Address implements ExtensionElement {
|
||||
public static final class Address implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "address";
|
||||
|
||||
|
@ -192,15 +193,10 @@ public class MultipleAddresses implements ExtensionElement {
|
|||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this, enclosingNamespace);
|
||||
buf.attribute("type", type);
|
||||
XmlStringBuilder buf = new XmlStringBuilder();
|
||||
buf.halfOpenElement(this).attribute("type", type);
|
||||
buf.optAttribute("jid", jid);
|
||||
buf.optAttribute("node", node);
|
||||
buf.optAttribute("desc", description);
|
||||
|
@ -213,6 +209,5 @@ public class MultipleAddresses implements ExtensionElement {
|
|||
buf.closeEmptyElement();
|
||||
return buf;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.InternetAddress;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -260,20 +260,13 @@ public class Bytestream extends IQ {
|
|||
return xml;
|
||||
}
|
||||
|
||||
private abstract static class BytestreamExtensionElement implements ExtensionElement {
|
||||
@Override
|
||||
public final String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stanza extension that represents a potential SOCKS5 proxy for the file transfer. Stream hosts
|
||||
* are forwarded to the target of the file transfer who then chooses and connects to one.
|
||||
*
|
||||
* @author Alexander Wenckus
|
||||
*/
|
||||
public static class StreamHost extends BytestreamExtensionElement {
|
||||
public static class StreamHost implements NamedElement {
|
||||
|
||||
public static String ELEMENTNAME = "streamhost";
|
||||
|
||||
|
@ -349,7 +342,7 @@ public class Bytestream extends IQ {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("jid", getJID());
|
||||
xml.attribute("host", address);
|
||||
if (getPort() != 0) {
|
||||
|
@ -373,7 +366,7 @@ public class Bytestream extends IQ {
|
|||
*
|
||||
* @author Alexander Wenckus
|
||||
*/
|
||||
public static class StreamHostUsed extends BytestreamExtensionElement {
|
||||
public static class StreamHostUsed implements NamedElement {
|
||||
|
||||
public static String ELEMENTNAME = "streamhost-used";
|
||||
|
||||
|
@ -404,7 +397,7 @@ public class Bytestream extends IQ {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("jid", getJID());
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
|
@ -416,7 +409,7 @@ public class Bytestream extends IQ {
|
|||
*
|
||||
* @author Alexander Wenckus
|
||||
*/
|
||||
public static class Activate extends BytestreamExtensionElement {
|
||||
public static class Activate implements NamedElement {
|
||||
|
||||
public static String ELEMENTNAME = "activate";
|
||||
|
||||
|
@ -447,13 +440,12 @@ public class Bytestream extends IQ {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.escape(getTarget());
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -103,7 +103,7 @@ public class DelayInformation implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("stamp", XmppDateTime.formatXEP0082Date(stamp));
|
||||
xml.optAttribute("from", from);
|
||||
xml.rightAngleBracket();
|
||||
|
|
|
@ -72,10 +72,10 @@ public class Forwarded implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.optElement(getDelayInformation());
|
||||
xml.append(forwardedPacket);
|
||||
xml.append(forwardedPacket.toXML(NAMESPACE));
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2019 Florian Schmaus
|
||||
* Copyright 2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,8 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -25,10 +24,9 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
/**
|
||||
* Jingle content element.
|
||||
*/
|
||||
public final class JingleContent implements FullyQualifiedElement {
|
||||
public final class JingleContent implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "content";
|
||||
public static final String NAMESPACE = Jingle.NAMESPACE;
|
||||
|
||||
public static final String CREATOR_ATTRIBUTE_NAME = "creator";
|
||||
|
||||
|
@ -134,13 +132,8 @@ public final class JingleContent implements FullyQualifiedElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingXmlEnvironment);
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute(CREATOR_ATTRIBUTE_NAME, creator);
|
||||
xml.optAttribute(DISPOSITION_ATTRIBUTE_NAME, disposition);
|
||||
xml.attribute(NAME_ATTRIBUTE_NAME, name);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
* Copyright © 2014-2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +16,18 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
|
||||
/**
|
||||
* An element found usually in 'description' elements.
|
||||
*
|
||||
*/
|
||||
public interface JingleContentDescriptionChildElement extends FullyQualifiedElement {
|
||||
public abstract class JingleContentDescriptionChildElement implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "payload-type";
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2019 Florian Schmaus
|
||||
* Copyright 2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
/**
|
||||
|
@ -67,8 +66,8 @@ public abstract class JingleContentTransport implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, xmlEnvironment);
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
addExtraAttributes(xml);
|
||||
|
||||
if (candidates.isEmpty() && info == null) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2019 Florian Schmaus
|
||||
* Copyright 2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,13 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
|
||||
/**
|
||||
* An element found usually in Jingle 'transport' elements.
|
||||
*
|
||||
*/
|
||||
public abstract class JingleContentTransportCandidate implements FullyQualifiedElement {
|
||||
public abstract class JingleContentTransportCandidate implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "candidate";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Paul Schaub, 2019 Florian Schmaus
|
||||
* Copyright 2017 Paul Schaub
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
|
||||
/**
|
||||
* Abstract JingleContentTransportInfo element.
|
||||
*/
|
||||
public interface JingleContentTransportInfo extends FullyQualifiedElement {
|
||||
public abstract class JingleContentTransportInfo implements NamedElement {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2019 Florian Schmaus
|
||||
* Copyright 2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,8 +19,7 @@ package org.jivesoftware.smackx.jingle.element;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
|
@ -30,10 +29,9 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
* @see <a href="https://xmpp.org/extensions/xep-0166.html#def-reason">XEP-0166 § 7.4</a>
|
||||
*
|
||||
*/
|
||||
public class JingleReason implements FullyQualifiedElement {
|
||||
public class JingleReason implements NamedElement {
|
||||
|
||||
public static final String ELEMENT = "reason";
|
||||
public static final String NAMESPACE = Jingle.NAMESPACE;
|
||||
|
||||
public static AlternativeSession AlternativeSession(String sessionId) {
|
||||
return new AlternativeSession(sessionId);
|
||||
|
@ -116,16 +114,11 @@ public class JingleReason implements FullyQualifiedElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingXmlEnvironment);
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
|
||||
xml.emptyElement(reason);
|
||||
xml.emptyElement(reason.asString);
|
||||
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.util.InternetAddress;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
@ -34,8 +33,6 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
|||
*/
|
||||
public final class JingleS5BTransportCandidate extends JingleContentTransportCandidate {
|
||||
|
||||
public static final String NAMESPACE = JingleS5BTransport.NAMESPACE_V1;
|
||||
|
||||
public static final String ATTR_CID = "cid";
|
||||
public static final String ATTR_HOST = "host";
|
||||
public static final String ATTR_JID = "jid";
|
||||
|
@ -133,15 +130,10 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan
|
|||
return new Bytestream.StreamHost(jid, host, port);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingXmlEnvironment);
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_CID, cid);
|
||||
xml.attribute(ATTR_HOST, host);
|
||||
xml.attribute(ATTR_JID, jid);
|
||||
|
@ -215,5 +207,4 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan
|
|||
return new JingleS5BTransportCandidate(cid, host, jid, port, priority, type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfo;
|
||||
|
@ -24,14 +23,7 @@ import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfo;
|
|||
/**
|
||||
* Class representing possible SOCKS5 TransportInfo elements.
|
||||
*/
|
||||
public abstract class JingleS5BTransportInfo implements JingleContentTransportInfo {
|
||||
|
||||
public static final String NAMESPACE = JingleS5BTransport.NAMESPACE_V1;
|
||||
|
||||
@Override
|
||||
public final String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
public abstract class JingleS5BTransportInfo extends JingleContentTransportInfo {
|
||||
|
||||
public abstract static class JingleS5BCandidateTransportInfo extends JingleS5BTransportInfo {
|
||||
public static final String ATTR_CID = "cid";
|
||||
|
@ -47,8 +39,9 @@ public abstract class JingleS5BTransportInfo implements JingleContentTransportIn
|
|||
}
|
||||
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, xmlEnvironment);
|
||||
public final XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_CID, getCandidateId());
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
|
|
|
@ -87,7 +87,7 @@ public class MediaElement implements FormFieldChildElement {
|
|||
.optAttribute("width", width)
|
||||
.rightAngleBracket();
|
||||
|
||||
xml.append(uris);
|
||||
xml.append(uris, xmlEnvironment);
|
||||
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
|
|
|
@ -74,7 +74,7 @@ public class MediaElementProvider extends FormFieldChildElementProvider<MediaEle
|
|||
return mediaElementBuilder.build();
|
||||
}
|
||||
|
||||
private static MediaElement.Uri parseUri(XmlPullParser parser)
|
||||
private MediaElement.Uri parseUri(XmlPullParser parser)
|
||||
throws SmackUriSyntaxParsingException, XmlPullParserException, IOException {
|
||||
String type = parser.getAttributeValue("type");
|
||||
URI uri = ParserUtils.getUriFromNextText(parser);
|
||||
|
|
|
@ -17,10 +17,8 @@
|
|||
package org.jivesoftware.smackx.mood.element;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
|
@ -109,8 +107,8 @@ public class MoodElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, xmlEnvironment);
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
|
||||
if (mood == null && text == null) {
|
||||
// Empty mood element used as STOP signal
|
||||
|
@ -154,7 +152,7 @@ public class MoodElement implements ExtensionElement {
|
|||
* {@link NamedElement} which represents the mood.
|
||||
* This element has the element name of the mood selected from {@link Mood}.
|
||||
*/
|
||||
public static class MoodSubjectElement implements FullyQualifiedElement {
|
||||
public static class MoodSubjectElement implements NamedElement {
|
||||
|
||||
private final Mood mood;
|
||||
private final MoodConcretisation concretisation;
|
||||
|
@ -170,17 +168,16 @@ public class MoodElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, xmlEnvironment);
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
|
||||
if (concretisation == null) {
|
||||
return xml.closeEmptyElement();
|
||||
return xml.emptyElement(getElementName());
|
||||
}
|
||||
|
||||
xml.rightAngleBracket()
|
||||
.append(concretisation)
|
||||
.closeElement(this);
|
||||
return xml;
|
||||
return xml.openElement(getElementName())
|
||||
.append(concretisation.toXML())
|
||||
.closeElement(getElementName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,10 +197,5 @@ public class MoodElement implements ExtensionElement {
|
|||
public MoodConcretisation getConcretisation() {
|
||||
return concretisation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ public class MUCUser implements ExtensionElement {
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Decline implements ExtensionElement {
|
||||
public static class Decline implements NamedElement {
|
||||
public static final String ELEMENT = "decline";
|
||||
|
||||
private final String reason;
|
||||
|
@ -370,7 +370,7 @@ public class MUCUser implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.optAttribute("to", getTo());
|
||||
xml.optAttribute("from", getFrom());
|
||||
xml.rightAngleBracket();
|
||||
|
@ -383,11 +383,6 @@ public class MUCUser implements ExtensionElement {
|
|||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -417,7 +417,7 @@ public final class FormField implements FullyQualifiedElement {
|
|||
} else {
|
||||
buf.rightAngleBracket();
|
||||
|
||||
buf.append(formFieldChildElements);
|
||||
buf.append(formFieldChildElements, enclosingNamespace);
|
||||
|
||||
buf.closeElement(this);
|
||||
}
|
||||
|
|
|
@ -325,10 +325,15 @@ public class DataForm implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this, xmlEnvironment);
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
buf.attribute("type", getType());
|
||||
buf.rightAngleBracket();
|
||||
|
||||
XmlEnvironment dataFormxmlEnvironment = XmlEnvironment.builder()
|
||||
.withNamespace(NAMESPACE)
|
||||
.withNext(xmlEnvironment)
|
||||
.build();
|
||||
|
||||
buf.optElement("title", getTitle());
|
||||
for (String instruction : getInstructions()) {
|
||||
buf.element("instructions", instruction);
|
||||
|
@ -342,7 +347,7 @@ public class DataForm implements ExtensionElement {
|
|||
buf.append(item.toXML());
|
||||
}
|
||||
// Add all form fields.
|
||||
buf.append(getFields());
|
||||
buf.append(getFields(), dataFormxmlEnvironment);
|
||||
for (Element element : extensionElements) {
|
||||
buf.append(element.toXML());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014 Anno van Vliet, 2019 Florian Schmaus
|
||||
* Copyright 2014 Anno van Vliet
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
/**
|
||||
|
@ -95,14 +96,24 @@ public class DataLayout implements ExtensionElement {
|
|||
buf.optAttribute("label", getLabel());
|
||||
buf.rightAngleBracket();
|
||||
|
||||
buf.append(getPageLayout());
|
||||
walkList(buf, getPageLayout());
|
||||
|
||||
buf.closeElement(this);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
public static class Fieldref extends DataFormLayoutElement{
|
||||
/**
|
||||
* @param buf TODO javadoc me please
|
||||
* @param pageLayout TODO javadoc me please
|
||||
*/
|
||||
private static void walkList(XmlStringBuilder buf, List<DataFormLayoutElement> pageLayout) {
|
||||
for (DataFormLayoutElement object : pageLayout) {
|
||||
buf.append(object.toXML());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Fieldref implements DataFormLayoutElement{
|
||||
|
||||
public static final String ELEMENT = "fieldref";
|
||||
private final String var;
|
||||
|
@ -117,7 +128,7 @@ public class DataLayout implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
buf.attribute("var", getVar());
|
||||
buf.closeEmptyElement();
|
||||
return buf;
|
||||
|
@ -139,7 +150,7 @@ public class DataLayout implements ExtensionElement {
|
|||
|
||||
}
|
||||
|
||||
public static class Section extends DataFormLayoutElement{
|
||||
public static class Section implements DataFormLayoutElement{
|
||||
|
||||
public static final String ELEMENT = "section";
|
||||
private final List<DataFormLayoutElement> sectionLayout = new ArrayList<>();
|
||||
|
@ -177,12 +188,11 @@ public class DataLayout implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
buf.optAttribute("label", getLabel());
|
||||
buf.rightAngleBracket();
|
||||
|
||||
buf.append(getSectionLayout());
|
||||
|
||||
walkList(buf, getSectionLayout());
|
||||
buf.closeElement(ELEMENT);
|
||||
return buf;
|
||||
}
|
||||
|
@ -203,13 +213,13 @@ public class DataLayout implements ExtensionElement {
|
|||
|
||||
}
|
||||
|
||||
public static class Reportedref extends DataFormLayoutElement{
|
||||
public static class Reportedref implements DataFormLayoutElement{
|
||||
|
||||
public static final String ELEMENT = "reportedref";
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this, enclosingNamespace);
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
buf.closeEmptyElement();
|
||||
return buf;
|
||||
}
|
||||
|
@ -221,7 +231,7 @@ public class DataLayout implements ExtensionElement {
|
|||
|
||||
}
|
||||
|
||||
public static class Text extends DataFormLayoutElement{
|
||||
public static class Text implements DataFormLayoutElement{
|
||||
public static final String ELEMENT = "text";
|
||||
private final String text;
|
||||
|
||||
|
@ -235,10 +245,8 @@ public class DataLayout implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this, enclosingNamespace);
|
||||
buf.rightAngleBracket();
|
||||
buf.escape(getText());
|
||||
buf.closeElement(this);
|
||||
XmlStringBuilder buf = new XmlStringBuilder();
|
||||
buf.element(ELEMENT, getText());
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -258,11 +266,7 @@ public class DataLayout implements ExtensionElement {
|
|||
|
||||
}
|
||||
|
||||
public abstract static class DataFormLayoutElement implements ExtensionElement {
|
||||
@Override
|
||||
public final String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
public interface DataFormLayoutElement extends NamedElement {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue