mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-21 19:42:05 +01:00
Merge branch '4.4'
This commit is contained in:
commit
e842195b71
28 changed files with 282 additions and 86 deletions
14
build.gradle
14
build.gradle
|
@ -6,6 +6,7 @@ buildscript {
|
|||
}
|
||||
dependencies {
|
||||
classpath 'org.kordamp.gradle:clirr-gradle-plugin:0.2.2'
|
||||
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:6.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,6 +451,7 @@ subprojects {
|
|||
apply plugin: 'signing'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'org.kordamp.gradle.clirr'
|
||||
apply plugin: 'biz.aQute.bnd.builder'
|
||||
|
||||
checkstyle {
|
||||
toolVersion = '8.27'
|
||||
|
@ -612,9 +614,15 @@ project(':smack-omemo').clirr.enabled = false
|
|||
project(':smack-omemo-signal').clirr.enabled = false
|
||||
|
||||
subprojects*.jar {
|
||||
manifest {
|
||||
from sharedManifest
|
||||
}
|
||||
manifest {
|
||||
from sharedManifest
|
||||
}
|
||||
bundle {
|
||||
bnd(
|
||||
'-removeheaders': 'Tool, Bnd-*',
|
||||
'-exportcontents': '*',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
configure(subprojects - gplLicensedProjects) {
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.jivesoftware.smack.packet.StanzaError;
|
|||
import org.jivesoftware.smack.util.CloseableUtil;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.igniterealtime.jbosh.AbstractBody;
|
||||
import org.igniterealtime.jbosh.BOSHClient;
|
||||
|
@ -200,6 +201,13 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
+ getHost() + ":" + getPort() + ".";
|
||||
throw new SmackException.SmackMessageException(errorMessage);
|
||||
}
|
||||
|
||||
try {
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor("<stream:stream xmlns='jabber:client'/>");
|
||||
onStreamOpen(parser);
|
||||
} catch (XmlPullParserException | IOException e) {
|
||||
throw new AssertionError("Failed to setup stream environment", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -511,7 +519,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
parseAndProcessStanza(parser);
|
||||
break;
|
||||
case "features":
|
||||
parseFeatures(parser);
|
||||
parseFeaturesAndNotify(parser);
|
||||
break;
|
||||
case "error":
|
||||
// Some BOSH error isn't stream error.
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
// Note that this is also declared in the main build.gradle for
|
||||
// subprojects, but since evaluationDependsOnChildren is enabled we
|
||||
// need to declare it here too to have bundle{bnd{...}} available
|
||||
apply plugin: 'biz.aQute.bnd.builder'
|
||||
|
||||
description = """\
|
||||
Smack core components."""
|
||||
|
||||
|
@ -55,3 +60,11 @@ task createVersionResource(type: CreateFileTask) {
|
|||
}
|
||||
|
||||
compileJava.dependsOn(createVersionResource)
|
||||
|
||||
jar {
|
||||
bundle {
|
||||
bnd(
|
||||
'DynamicImport-Package': '*',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -405,7 +405,7 @@ public abstract class ConnectionConfiguration {
|
|||
|
||||
/**
|
||||
* Returns the TLS security mode used when making the connection. By default,
|
||||
* the mode is {@link SecurityMode#ifpossible}.
|
||||
* the mode is {@link SecurityMode#required}.
|
||||
*
|
||||
* @return the security mode.
|
||||
*/
|
||||
|
@ -960,7 +960,7 @@ public abstract class ConnectionConfiguration {
|
|||
|
||||
/**
|
||||
* Sets the TLS security mode used when making the connection. By default,
|
||||
* the mode is {@link SecurityMode#ifpossible}.
|
||||
* the mode is {@link SecurityMode#required}.
|
||||
*
|
||||
* @param securityMode the security mode.
|
||||
* @return a reference to this builder.
|
||||
|
|
|
@ -120,6 +120,16 @@ public abstract class XMPPException extends Exception {
|
|||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stanza associated with this exception.
|
||||
*
|
||||
* @return the stanza from which this exception was created or {@code null} if the exception is not from a
|
||||
* stanza.
|
||||
*/
|
||||
public Stanza getStanza() {
|
||||
return stanza;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request which triggered the error response causing this exception.
|
||||
*
|
||||
|
|
|
@ -202,7 +202,7 @@ public abstract class IQ extends Stanza implements IqView {
|
|||
|
||||
// Add the query section if there is one.
|
||||
IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(
|
||||
new IQChildElementXmlStringBuilder(this));
|
||||
new IQChildElementXmlStringBuilder(getChildElementName(), getChildElementNamespace(), null, xml.getXmlEnvironment()));
|
||||
// TOOD: Document the cases where iqChildElement is null but childElementName not. And if there are none, change
|
||||
// the logic.
|
||||
if (iqChildElement == null) {
|
||||
|
@ -399,17 +399,16 @@ public abstract class IQ extends Stanza implements IqView {
|
|||
|
||||
private boolean isEmptyElement;
|
||||
|
||||
private IQChildElementXmlStringBuilder(IQ iq) {
|
||||
this(iq.getChildElementName(), iq.getChildElementNamespace());
|
||||
public IQChildElementXmlStringBuilder(ExtensionElement extensionElement,
|
||||
XmlEnvironment enclosingXmlEnvironment) {
|
||||
this(extensionElement.getElementName(), extensionElement.getNamespace(), extensionElement.getLanguage(),
|
||||
enclosingXmlEnvironment);
|
||||
}
|
||||
|
||||
public IQChildElementXmlStringBuilder(ExtensionElement pe) {
|
||||
this(pe.getElementName(), pe.getNamespace());
|
||||
}
|
||||
|
||||
private IQChildElementXmlStringBuilder(String element, String namespace) {
|
||||
prelude(element, namespace);
|
||||
this.element = element;
|
||||
private IQChildElementXmlStringBuilder(String elementName, String xmlNs, String xmlLang,
|
||||
XmlEnvironment enclosingXmlEnvironment) {
|
||||
super(elementName, xmlNs, xmlLang, enclosingXmlEnvironment);
|
||||
this.element = elementName;
|
||||
}
|
||||
|
||||
public void setEmptyElement() {
|
||||
|
|
|
@ -60,4 +60,8 @@ public class SASLAnonymous extends SASLMechanism {
|
|||
// SASL Anonymous is always successful :)
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresPassword() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ public class ParserUtils {
|
|||
throws XmlPullParserException, IOException {
|
||||
XmlPullParser.Event event = parser.getEventType();
|
||||
while (!(event == XmlPullParser.Event.END_ELEMENT && parser.getDepth() == depth)) {
|
||||
assert event != XmlPullParser.Event.END_DOCUMENT;
|
||||
event = parser.next();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014-2020 Florian Schmaus
|
||||
* Copyright 2014-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -52,11 +52,13 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
}
|
||||
|
||||
public XmlStringBuilder(XmlElement element, XmlEnvironment enclosingXmlEnvironment) {
|
||||
sb = new LazyStringBuilder();
|
||||
halfOpenElement(element);
|
||||
this(element.getElementName(), element.getNamespace(), element.getLanguage(), enclosingXmlEnvironment);
|
||||
}
|
||||
|
||||
public XmlStringBuilder(String elementName, String xmlNs, String xmlLang, XmlEnvironment enclosingXmlEnvironment) {
|
||||
sb = new LazyStringBuilder();
|
||||
halfOpenElement(elementName);
|
||||
|
||||
String xmlNs = element.getNamespace();
|
||||
String xmlLang = element.getLanguage();
|
||||
if (enclosingXmlEnvironment == null) {
|
||||
xmlnsAttribute(xmlNs);
|
||||
xmllangAttribute(xmlLang);
|
||||
|
|
|
@ -154,8 +154,7 @@ public final class CarbonManager extends Manager {
|
|||
// because we also reset in authenticated() if the stream got not resumed, but for maximum correctness,
|
||||
// also reset here.
|
||||
enabled_state = false;
|
||||
boolean removed = connection().removeSyncStanzaListener(carbonsListener);
|
||||
assert removed;
|
||||
connection().removeSyncStanzaListener(carbonsListener);
|
||||
}
|
||||
@Override
|
||||
public void authenticated(XMPPConnection connection, boolean resumed) {
|
||||
|
|
|
@ -153,7 +153,7 @@ public class DataPacketExtension implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this));
|
||||
XmlStringBuilder xml = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this, enclosingNamespace));
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
|
|
|
@ -615,9 +615,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
if (annouceLocalStreamHost) {
|
||||
// add local proxy on first position if exists
|
||||
List<StreamHost> localProxies = getLocalStreamHost();
|
||||
if (localProxies != null) {
|
||||
streamHosts.addAll(localProxies);
|
||||
}
|
||||
streamHosts.addAll(localProxies);
|
||||
}
|
||||
|
||||
// query SOCKS5 proxies for network settings
|
||||
|
@ -652,12 +650,14 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
|
||||
/**
|
||||
* Returns the stream host information of the local SOCKS5 proxy containing the IP address and
|
||||
* the port or null if local SOCKS5 proxy is not running.
|
||||
* the port. The returned list may be empty if the local SOCKS5 proxy is not running.
|
||||
*
|
||||
* @return the stream host information of the local SOCKS5 proxy or null if local SOCKS5 proxy
|
||||
* is not running
|
||||
* @return the stream host information of the local SOCKS5 proxy
|
||||
*/
|
||||
public List<StreamHost> getLocalStreamHost() {
|
||||
// Ensure that the local SOCKS5 proxy is running (if enabled).
|
||||
Socks5Proxy.getSocks5Proxy();
|
||||
|
||||
List<StreamHost> streamHosts = new ArrayList<>();
|
||||
|
||||
XMPPConnection connection = connection();
|
||||
|
|
|
@ -258,6 +258,14 @@ public class DiscoverInfo extends IQ implements DiscoverInfoView {
|
|||
return features.contains(new Feature(feature));
|
||||
}
|
||||
|
||||
public static boolean nullSafeContainsFeature(DiscoverInfo discoverInfo, CharSequence feature) {
|
||||
if (discoverInfo == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return discoverInfo.containsFeature(feature);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.optAttribute("node", getNode());
|
||||
|
|
|
@ -53,7 +53,7 @@ public class JingleUtil {
|
|||
JingleContentDescription description,
|
||||
JingleContentTransport transport) {
|
||||
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection);
|
||||
jb.setAction(JingleAction.session_initiate)
|
||||
.setSessionId(sessionId)
|
||||
.setInitiator(connection.getUser());
|
||||
|
@ -118,7 +118,7 @@ public class JingleUtil {
|
|||
JingleContentDescription description,
|
||||
JingleContentTransport transport) {
|
||||
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection);
|
||||
jb.setResponder(connection.getUser())
|
||||
.setAction(JingleAction.session_accept)
|
||||
.setSessionId(sessionId);
|
||||
|
@ -153,7 +153,7 @@ public class JingleUtil {
|
|||
}
|
||||
|
||||
public Jingle createSessionTerminate(FullJid recipient, String sessionId, JingleReason reason) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection);
|
||||
jb.setAction(JingleAction.session_terminate)
|
||||
.setSessionId(sessionId)
|
||||
.setReason(reason);
|
||||
|
@ -232,7 +232,7 @@ public class JingleUtil {
|
|||
|
||||
public Jingle createSessionTerminateContentCancel(FullJid recipient, String sessionId,
|
||||
JingleContent.Creator contentCreator, String contentName) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection);
|
||||
jb.setAction(JingleAction.session_terminate)
|
||||
.setSessionId(sessionId);
|
||||
|
||||
|
@ -314,7 +314,7 @@ public class JingleUtil {
|
|||
}
|
||||
|
||||
public Jingle createSessionPing(FullJid recipient, String sessionId) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection);
|
||||
jb.setSessionId(sessionId)
|
||||
.setAction(JingleAction.session_info);
|
||||
|
||||
|
@ -343,7 +343,7 @@ public class JingleUtil {
|
|||
public Jingle createTransportReplace(FullJid recipient, FullJid initiator, String sessionId,
|
||||
JingleContent.Creator contentCreator, String contentName,
|
||||
JingleContentTransport transport) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection);
|
||||
jb.setInitiator(initiator)
|
||||
.setSessionId(sessionId)
|
||||
.setAction(JingleAction.transport_replace);
|
||||
|
@ -370,7 +370,7 @@ public class JingleUtil {
|
|||
public Jingle createTransportAccept(FullJid recipient, FullJid initiator, String sessionId,
|
||||
JingleContent.Creator contentCreator, String contentName,
|
||||
JingleContentTransport transport) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection);
|
||||
jb.setAction(JingleAction.transport_accept)
|
||||
.setInitiator(initiator)
|
||||
.setSessionId(sessionId);
|
||||
|
@ -397,7 +397,7 @@ public class JingleUtil {
|
|||
public Jingle createTransportReject(FullJid recipient, FullJid initiator, String sessionId,
|
||||
JingleContent.Creator contentCreator, String contentName,
|
||||
JingleContentTransport transport) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection);
|
||||
jb.setAction(JingleAction.transport_reject)
|
||||
.setInitiator(initiator)
|
||||
.setSessionId(sessionId);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software, 2014-2017 Florian Schmaus
|
||||
* Copyright 2003-2007 Jive Software, 2014-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -21,7 +21,11 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.packet.id.StandardStanzaIdSource;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
|
@ -65,9 +69,9 @@ public final class Jingle extends IQ {
|
|||
|
||||
private final List<JingleContent> contents;
|
||||
|
||||
private Jingle(String sessionId, JingleAction action, FullJid initiator, FullJid responder, JingleReason reason,
|
||||
private Jingle(Builder builder, String sessionId, JingleAction action, FullJid initiator, FullJid responder, JingleReason reason,
|
||||
List<JingleContent> contents) {
|
||||
super(ELEMENT, NAMESPACE);
|
||||
super(builder, ELEMENT, NAMESPACE);
|
||||
this.sessionId = StringUtils.requireNotNullNorEmpty(sessionId, "Jingle session ID must not be null");
|
||||
this.action = Objects.requireNonNull(action, "Jingle action must not be null");
|
||||
this.initiator = initiator;
|
||||
|
@ -169,11 +173,31 @@ public final class Jingle extends IQ {
|
|||
return xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated, do not use.
|
||||
*
|
||||
* @return a builder.
|
||||
* @deprecated use {@link #builder(XMPPConnection)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.6.
|
||||
public static Builder getBuilder() {
|
||||
return new Builder();
|
||||
return builder(StandardStanzaIdSource.DEFAULT.getNewStanzaId());
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
public static Builder builder(XMPPConnection connection) {
|
||||
return new Builder(connection);
|
||||
}
|
||||
|
||||
public static Builder builder(IqData iqData) {
|
||||
return new Builder(iqData);
|
||||
}
|
||||
|
||||
public static Builder builder(String stanzaId) {
|
||||
return new Builder(stanzaId);
|
||||
}
|
||||
|
||||
public static final class Builder extends IqBuilder<Builder, Jingle> {
|
||||
private String sid;
|
||||
|
||||
private JingleAction action;
|
||||
|
@ -186,7 +210,16 @@ public final class Jingle extends IQ {
|
|||
|
||||
private List<JingleContent> contents;
|
||||
|
||||
private Builder() {
|
||||
Builder(IqData iqCommon) {
|
||||
super(iqCommon);
|
||||
}
|
||||
|
||||
Builder(XMPPConnection connection) {
|
||||
super(connection);
|
||||
}
|
||||
|
||||
Builder(String stanzaId) {
|
||||
super(stanzaId);
|
||||
}
|
||||
|
||||
public Builder setSessionId(String sessionId) {
|
||||
|
@ -228,8 +261,14 @@ public final class Jingle extends IQ {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Jingle build() {
|
||||
return new Jingle(sid, action, initiator, responder, reason, contents);
|
||||
return new Jingle(this, sid, action, initiator, responder, reason, contents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder getThis() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,11 @@ public final class JingleContent implements XmlElement {
|
|||
xml.optAttribute(DISPOSITION_ATTRIBUTE_NAME, disposition);
|
||||
xml.attribute(NAME_ATTRIBUTE_NAME, name);
|
||||
xml.optAttribute(SENDERS_ATTRIBUTE_NAME, senders);
|
||||
|
||||
if (description == null && transport == null) {
|
||||
return xml.closeEmptyElement();
|
||||
}
|
||||
|
||||
xml.rightAngleBracket();
|
||||
|
||||
xml.optAppend(description);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2019 Florian Schmaus
|
||||
* Copyright 2017-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,11 +19,12 @@ package org.jivesoftware.smackx.jingle.provider;
|
|||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.packet.StandardExtensionElement;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.parsing.StandardExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.provider.IqProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
@ -40,13 +41,13 @@ import org.jivesoftware.smackx.jingle.element.UnknownJingleContentTransport;
|
|||
|
||||
import org.jxmpp.jid.FullJid;
|
||||
|
||||
public class JingleProvider extends IQProvider<Jingle> {
|
||||
public class JingleProvider extends IqProvider<Jingle> {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(JingleProvider.class.getName());
|
||||
|
||||
@Override
|
||||
public Jingle parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
Jingle.Builder builder = Jingle.getBuilder();
|
||||
public Jingle parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
Jingle.Builder builder = Jingle.builder(iqData);
|
||||
|
||||
String actionString = parser.getAttributeValue("", Jingle.ACTION_ATTRIBUTE_NAME);
|
||||
if (actionString != null) {
|
||||
|
|
|
@ -36,6 +36,10 @@ public abstract class JingleTransportManager<D extends JingleContentTransport> i
|
|||
}
|
||||
|
||||
public XMPPConnection getConnection() {
|
||||
return connection();
|
||||
}
|
||||
|
||||
public XMPPConnection connection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
|
|||
public Jingle createCandidateUsed(FullJid recipient, FullJid initiator, String sessionId, JingleContent.Senders contentSenders,
|
||||
JingleContent.Creator contentCreator, String contentName, String streamId,
|
||||
String candidateId) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection());
|
||||
jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);
|
||||
|
||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||
|
@ -165,7 +165,7 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
|
|||
}
|
||||
|
||||
public Jingle createCandidateError(FullJid remote, FullJid initiator, String sessionId, JingleContent.Senders senders, JingleContent.Creator creator, String name, String streamId) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection());
|
||||
jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);
|
||||
|
||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||
|
@ -184,7 +184,7 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
|
|||
public Jingle createProxyError(FullJid remote, FullJid initiator, String sessionId,
|
||||
JingleContent.Senders senders, JingleContent.Creator creator,
|
||||
String name, String streamId) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection());
|
||||
jb.setSessionId(sessionId).setAction(JingleAction.transport_info).setInitiator(initiator);
|
||||
|
||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||
|
@ -202,7 +202,7 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
|
|||
public Jingle createCandidateActivated(FullJid remote, FullJid initiator, String sessionId,
|
||||
JingleContent.Senders senders, JingleContent.Creator creator,
|
||||
String name, String streamId, String candidateId) {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
Jingle.Builder jb = Jingle.builder(connection());
|
||||
jb.setInitiator(initiator).setSessionId(sessionId).setAction(JingleAction.transport_info);
|
||||
|
||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||
|
|
|
@ -212,7 +212,12 @@ public class MultiUserChat {
|
|||
switch (presence.getType()) {
|
||||
case available:
|
||||
Presence oldPresence = occupantsMap.put(from, presence);
|
||||
if (oldPresence != null) {
|
||||
if (mucUser.getStatus().contains(MUCUser.Status.PRESENCE_TO_SELF_110)) {
|
||||
processedReflectedSelfPresence = true;
|
||||
synchronized (this) {
|
||||
notify();
|
||||
}
|
||||
} else if (oldPresence != null) {
|
||||
// Get the previous occupant's affiliation & role
|
||||
MUCUser mucExtension = MUCUser.from(oldPresence);
|
||||
MUCAffiliation oldAffiliation = mucExtension.getItem().getAffiliation();
|
||||
|
@ -228,11 +233,6 @@ public class MultiUserChat {
|
|||
newAffiliation,
|
||||
isUserStatusModification,
|
||||
from);
|
||||
} else if (mucUser.getStatus().contains(MUCUser.Status.PRESENCE_TO_SELF_110)) {
|
||||
processedReflectedSelfPresence = true;
|
||||
synchronized (this) {
|
||||
notify();
|
||||
}
|
||||
} else {
|
||||
// A new occupant has joined the room
|
||||
for (ParticipantStatusListener listener : participantStatusListeners) {
|
||||
|
@ -259,23 +259,24 @@ public class MultiUserChat {
|
|||
listener.left(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Destroy destroy = mucUser.getDestroy();
|
||||
// The room has been destroyed.
|
||||
if (destroy != null) {
|
||||
EntityBareJid alternateMucJid = destroy.getJid();
|
||||
final MultiUserChat alternateMuc;
|
||||
if (alternateMucJid == null) {
|
||||
alternateMuc = null;
|
||||
} else {
|
||||
alternateMuc = multiUserChatManager.getMultiUserChat(alternateMucJid);
|
||||
}
|
||||
Destroy destroy = mucUser.getDestroy();
|
||||
// The room has been destroyed.
|
||||
if (destroy != null) {
|
||||
EntityBareJid alternateMucJid = destroy.getJid();
|
||||
final MultiUserChat alternateMuc;
|
||||
if (alternateMucJid == null) {
|
||||
alternateMuc = null;
|
||||
} else {
|
||||
alternateMuc = multiUserChatManager.getMultiUserChat(alternateMucJid);
|
||||
}
|
||||
|
||||
for (UserStatusListener listener : userStatusListeners) {
|
||||
listener.roomDestroyed(alternateMuc, destroy.getReason());
|
||||
}
|
||||
for (UserStatusListener listener : userStatusListeners) {
|
||||
listener.roomDestroyed(alternateMuc, destroy.getReason());
|
||||
}
|
||||
}
|
||||
|
||||
if (isUserStatusModification) {
|
||||
for (UserStatusListener listener : userStatusListeners) {
|
||||
listener.removed(mucUser, presence);
|
||||
|
@ -793,11 +794,14 @@ public class MultiUserChat {
|
|||
|
||||
StanzaFilter reflectedLeavePresenceFilter = new AndFilter(reflectedLeavePresenceFilters);
|
||||
|
||||
// Reset occupant information first so that we are assume that we left the room even if sendStanza() would
|
||||
// throw.
|
||||
userHasLeft();
|
||||
|
||||
Presence reflectedLeavePresence = connection.createStanzaCollectorAndSend(reflectedLeavePresenceFilter, leavePresence).nextResultOrThrow();
|
||||
Presence reflectedLeavePresence;
|
||||
try {
|
||||
reflectedLeavePresence = connection.createStanzaCollectorAndSend(reflectedLeavePresenceFilter, leavePresence).nextResultOrThrow();
|
||||
} finally {
|
||||
// Reset occupant information after we send the leave presence. This ensures that we only call userHasLeft()
|
||||
// and reset the local MUC state after we successfully left the MUC (or if an exception occurred).
|
||||
userHasLeft();
|
||||
}
|
||||
|
||||
return reflectedLeavePresence;
|
||||
}
|
||||
|
@ -2579,7 +2583,7 @@ public class MultiUserChat {
|
|||
}
|
||||
|
||||
public boolean serviceSupportsStableIds() {
|
||||
return mucServiceDiscoInfo.containsFeature(MultiUserChatConstants.STABLE_ID_FEATURE);
|
||||
return DiscoverInfo.nullSafeContainsFeature(mucServiceDiscoInfo, MultiUserChatConstants.STABLE_ID_FEATURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -75,8 +75,7 @@ public class JingleContentTest extends SmackTestSuite {
|
|||
assertEquals(content1.toXML().toString(), builder.build().toXML().toString());
|
||||
|
||||
String xml =
|
||||
"<content xmlns='urn:xmpp:jingle:1' creator='initiator' disposition='session' name='A name' senders='both'>" +
|
||||
"</content>";
|
||||
"<content xmlns='urn:xmpp:jingle:1' creator='initiator' disposition='session' name='A name' senders='both'/>";
|
||||
assertEquals(xml, content1.toXML().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class JingleTest extends SmackTestSuite {
|
|||
|
||||
@Test
|
||||
public void emptyBuilderTest() {
|
||||
Jingle.Builder builder = Jingle.getBuilder();
|
||||
Jingle.Builder builder = Jingle.builder("id");
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
builder.build();
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ public class JingleTest extends SmackTestSuite {
|
|||
public void onlySessionIdBuilderTest() {
|
||||
String sessionId = "testSessionId";
|
||||
|
||||
Jingle.Builder builder = Jingle.getBuilder();
|
||||
Jingle.Builder builder = Jingle.builder("id");
|
||||
builder.setSessionId(sessionId);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
builder.build();
|
||||
|
@ -59,7 +59,7 @@ public class JingleTest extends SmackTestSuite {
|
|||
public void parserTest() throws XmppStringprepException {
|
||||
String sessionId = "testSessionId";
|
||||
|
||||
Jingle.Builder builder = Jingle.getBuilder();
|
||||
Jingle.Builder builder = Jingle.builder("id");
|
||||
builder.setSessionId(sessionId);
|
||||
builder.setAction(JingleAction.session_initiate);
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jingle.element;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class JingleTest {
|
||||
|
||||
@Test
|
||||
public void noRedundantNamespaceTest() {
|
||||
Jingle.Builder jingleBuilder = Jingle.builder("test-id");
|
||||
jingleBuilder.setSessionId("MySession");
|
||||
jingleBuilder.setAction(JingleAction.content_accept);
|
||||
|
||||
JingleContent.Builder jingleContentBuilder = JingleContent.getBuilder();
|
||||
jingleContentBuilder.setName("Hello world");
|
||||
jingleContentBuilder.setCreator(JingleContent.Creator.initiator);
|
||||
|
||||
jingleBuilder.addJingleContent(jingleContentBuilder.build());
|
||||
Jingle iq = jingleBuilder.build();
|
||||
|
||||
String actualXml = iq.toXML(StreamOpen.CLIENT_NAMESPACE).toString();
|
||||
String expectedXml
|
||||
= "<iq id='test-id' type='set'>"
|
||||
+ "<jingle xmlns='urn:xmpp:jingle:1' action='content-accept' sid='MySession'>"
|
||||
+ "<content creator='initiator' name='Hello world'/>"
|
||||
+ "</jingle></iq>";
|
||||
assertEquals(expectedXml, actualXml);
|
||||
}
|
||||
}
|
|
@ -118,7 +118,7 @@ public class RoomInvitation implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this));
|
||||
XmlStringBuilder xml = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this, enclosingNamespace));
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class RoomTransfer implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this));
|
||||
XmlStringBuilder xml = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this, enclosingNamespace));
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
// Note that this is also declared in the main build.gradle for
|
||||
// subprojects, but since evaluationDependsOnChildren is enabled we
|
||||
// need to declare it here too to have bundle{bnd{...}} available
|
||||
apply plugin: 'biz.aQute.bnd.builder'
|
||||
|
||||
description = """\
|
||||
Smack XML parser using Stax."""
|
||||
|
||||
|
@ -5,3 +10,13 @@ dependencies {
|
|||
api project(':smack-xmlparser')
|
||||
//testCompile project(path: ":smack-xmlparser", configuration: "testRuntime")
|
||||
}
|
||||
|
||||
jar {
|
||||
bundle {
|
||||
bnd(
|
||||
// see http://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.loader.html
|
||||
'Require-Capability': 'osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)"',
|
||||
'Provide-Capability': "osgi.serviceloader;osgi.serviceloader=org.jivesoftware.smack.xml.XmlPullParserFactory;register:=org.jivesoftware.smack.xml.stax.StaxXmlPullParserFactory",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
// Note that this is also declared in the main build.gradle for
|
||||
// subprojects, but since evaluationDependsOnChildren is enabled we
|
||||
// need to declare it here too to have bundle{bnd{...}} available
|
||||
apply plugin: 'biz.aQute.bnd.builder'
|
||||
|
||||
description = """\
|
||||
Smack XML parser using XPP3."""
|
||||
|
||||
|
@ -11,3 +16,13 @@ dependencies {
|
|||
api project(':smack-xmlparser')
|
||||
//testCompile project(path: ":smack-xmlparser", configuration: "testRuntime")
|
||||
}
|
||||
|
||||
jar {
|
||||
bundle {
|
||||
bnd(
|
||||
// see http://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.loader.html
|
||||
'Require-Capability': 'osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)"',
|
||||
'Provide-Capability': "osgi.serviceloader;osgi.serviceloader=org.jivesoftware.smack.xml.XmlPullParserFactory;register:=org.jivesoftware.smack.xml.xpp3.Xpp3XmlPullParserFactory",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,16 @@
|
|||
// Note that this is also declared in the main build.gradle for
|
||||
// subprojects, but since evaluationDependsOnChildren is enabled we
|
||||
// need to declare it here too to have bundle{bnd{...}} available
|
||||
apply plugin: 'biz.aQute.bnd.builder'
|
||||
|
||||
description = """\
|
||||
Smack XML parser fundamentals"""
|
||||
|
||||
jar {
|
||||
bundle {
|
||||
bnd(
|
||||
// see http://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.loader.html
|
||||
'Require-Capability': 'osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)"',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue