mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Merge pull request #426 from Flowdalic/getstreamopen
Get stream-open-like element from transport
This commit is contained in:
commit
5d32735ad7
6 changed files with 27 additions and 9 deletions
|
@ -2229,7 +2229,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendStreamOpen() throws NotConnectedException, InterruptedException {
|
protected final void sendStreamOpen() throws NotConnectedException, InterruptedException {
|
||||||
// If possible, provide the receiving entity of the stream open tag, i.e. the server, as much information as
|
// If possible, provide the receiving entity of the stream open tag, i.e. the server, as much information as
|
||||||
// possible. The 'to' attribute is *always* available. The 'from' attribute if set by the user and no external
|
// possible. The 'to' attribute is *always* available. The 'from' attribute if set by the user and no external
|
||||||
// mechanism is used to determine the local entity (user). And the 'id' attribute is available after the first
|
// mechanism is used to determine the local entity (user). And the 'id' attribute is available after the first
|
||||||
|
@ -2241,12 +2241,17 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
from = XmppStringUtils.completeJidFrom(localpart, to);
|
from = XmppStringUtils.completeJidFrom(localpart, to);
|
||||||
}
|
}
|
||||||
String id = getStreamId();
|
String id = getStreamId();
|
||||||
|
String lang = config.getXmlLang();
|
||||||
|
|
||||||
StreamOpen streamOpen = new StreamOpen(to, from, id, config.getXmlLang(), StreamOpen.StreamContentNamespace.client);
|
AbstractStreamOpen streamOpen = getStreamOpen(to, from, id, lang);
|
||||||
sendNonza(streamOpen);
|
sendNonza(streamOpen);
|
||||||
updateOutgoingStreamXmlEnvironmentOnStreamOpen(streamOpen);
|
updateOutgoingStreamXmlEnvironmentOnStreamOpen(streamOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected AbstractStreamOpen getStreamOpen(CharSequence to, CharSequence from, String id, String lang) {
|
||||||
|
return new StreamOpen(to, from, id, lang);
|
||||||
|
}
|
||||||
|
|
||||||
protected void updateOutgoingStreamXmlEnvironmentOnStreamOpen(AbstractStreamOpen streamOpen) {
|
protected void updateOutgoingStreamXmlEnvironmentOnStreamOpen(AbstractStreamOpen streamOpen) {
|
||||||
XmlEnvironment.Builder xmlEnvironmentBuilder = XmlEnvironment.builder();
|
XmlEnvironment.Builder xmlEnvironmentBuilder = XmlEnvironment.builder();
|
||||||
xmlEnvironmentBuilder.with(streamOpen);
|
xmlEnvironmentBuilder.with(streamOpen);
|
||||||
|
|
|
@ -560,6 +560,12 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
waitForConditionOrThrowConnectionException(() -> featuresReceived, waitFor);
|
waitForConditionOrThrowConnectionException(() -> featuresReceived, waitFor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AbstractStreamOpen getStreamOpen(CharSequence to, CharSequence from, String id, String lang) {
|
||||||
|
StreamOpenAndCloseFactory streamOpenAndCloseFactory = activeTransport.getStreamOpenAndCloseFactory();
|
||||||
|
return streamOpenAndCloseFactory.createStreamOpen(to, from, id, lang);
|
||||||
|
}
|
||||||
|
|
||||||
protected void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
|
protected void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
|
||||||
SmackException, XMPPException {
|
SmackException, XMPPException {
|
||||||
prepareToWaitForFeaturesReceived();
|
prepareToWaitForFeaturesReceived();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2020 Aditya Borikar
|
* Copyright 2020 Florian Schmaus, Aditya Borikar
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -60,6 +60,10 @@ public abstract class AbstractStreamOpen implements Nonza {
|
||||||
*/
|
*/
|
||||||
protected final String contentNamespace;
|
protected final String contentNamespace;
|
||||||
|
|
||||||
|
public AbstractStreamOpen(CharSequence to, CharSequence from, String id, String lang) {
|
||||||
|
this(to, from, id, lang, StreamContentNamespace.client);
|
||||||
|
}
|
||||||
|
|
||||||
public AbstractStreamOpen(CharSequence to, CharSequence from, String id, String lang, StreamContentNamespace ns) {
|
public AbstractStreamOpen(CharSequence to, CharSequence from, String id, String lang, StreamContentNamespace ns) {
|
||||||
this.to = StringUtils.maybeToString(to);
|
this.to = StringUtils.maybeToString(to);
|
||||||
this.from = StringUtils.maybeToString(from);
|
this.from = StringUtils.maybeToString(from);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2019 Florian Schmaus
|
* Copyright © 2014-2020 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -33,6 +33,10 @@ public final class StreamOpen extends AbstractStreamOpen {
|
||||||
this(to, from, id, "en", StreamContentNamespace.client);
|
this(to, from, id, "en", StreamContentNamespace.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StreamOpen(CharSequence to, CharSequence from, String id, String lang) {
|
||||||
|
super(to, from, id, lang);
|
||||||
|
}
|
||||||
|
|
||||||
public StreamOpen(CharSequence to, CharSequence from, String id, String lang, StreamContentNamespace ns) {
|
public StreamOpen(CharSequence to, CharSequence from, String id, String lang, StreamContentNamespace ns) {
|
||||||
super(to, from, id, lang, ns);
|
super(to, from, id, lang, ns);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014-2019 Florian Schmaus
|
* Copyright 2014-2020 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,7 +24,6 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Element;
|
import org.jivesoftware.smack.packet.Element;
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
|
||||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||||
import org.jivesoftware.smack.packet.NamedElement;
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
|
@ -43,7 +42,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
||||||
effectiveXmlEnvironment = null;
|
effectiveXmlEnvironment = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlStringBuilder(ExtensionElement pe) {
|
public XmlStringBuilder(FullyQualifiedElement pe) {
|
||||||
this(pe, null);
|
this(pe, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2017-2019 Florian Schmaus
|
* Copyright 2017-2020 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -151,7 +151,7 @@ public class JingleReason implements FullyQualifiedElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||||
xml.rightAngleBracket();
|
xml.rightAngleBracket();
|
||||||
|
|
||||||
xml.openElement(reason.asString);
|
xml.openElement(reason.asString);
|
||||||
|
|
Loading…
Reference in a new issue