1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00
This commit is contained in:
vanitasvitae 2017-07-17 20:18:08 +02:00
parent 59e79ef668
commit 7658369d63
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
26 changed files with 268 additions and 356 deletions

View file

@ -83,7 +83,7 @@ public final class JingleTransportMethodManager extends Manager {
return null;
}
JingleContentTransport transport = content.getJingleTransport();
JingleContentTransport transport = content.getTransport();
if (transport == null) {
return null;
}

View file

@ -16,12 +16,10 @@
*/
package org.jivesoftware.smackx.jingle;
import java.util.Collections;
import java.util.List;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.jingle.element.Jingle;
@ -50,150 +48,68 @@ public class JingleUtil {
* XEP-0166 Example 10.
* @param recipient recipient of the stanza.
* @param sessionId sessionId
* @param contentCreator creator of the content.
* @param contentName name of the content.
* @param contentSenders sender of the content.
* @param description description of the content.
* @param transport used transport.
* @param content content
* @return session-initiate stanza.
*/
public Jingle createSessionInitiate(FullJid recipient,
String sessionId,
JingleContent.Creator contentCreator,
String contentName,
JingleContent.Senders contentSenders,
JingleContentDescription description,
JingleContentTransport transport,
List<Element> additionalElements) {
JingleContent content) {
return createSessionInitiate(recipient, sessionId, Collections.singletonList(content));
}
Jingle.Builder jb = Jingle.getBuilder();
jb.setAction(JingleAction.session_initiate)
public Jingle createSessionInitiate(FullJid recipient,
String sessionId,
List<JingleContent> contents) {
Jingle.Builder builder = Jingle.getBuilder();
builder.setAction(JingleAction.session_initiate)
.setSessionId(sessionId)
.setInitiator(connection.getUser());
JingleContent.Builder cb = JingleContent.getBuilder();
cb.setCreator(contentCreator)
.setName(contentName)
.setSenders(contentSenders)
.setDescription(description)
.setTransport(transport)
.addAdditionalElements(additionalElements);
for (JingleContent content : contents) {
builder.addJingleContent(content);
}
Jingle jingle = jb.addJingleContent(cb.build()).build();
Jingle jingle = builder.build();
jingle.setFrom(connection.getUser());
jingle.setTo(recipient);
return jingle;
}
/**
* Initiate a file transfer session.
* XEP-0234 Example 1.
* @param recipient recipient of the file transfer.
* @param sessionId sessionId.
* @param contentCreator creator of the content.
* @param contentName name of the content.
* @param description description of the content.
* @param transport used transport.
* @return session-initiate stanza.
*/
public Jingle createSessionInitiateFileOffer(FullJid recipient,
String sessionId,
JingleContent.Creator contentCreator,
String contentName,
JingleContentDescription description,
JingleContentTransport transport,
List<Element> additionalElements) {
return createSessionInitiate(recipient, sessionId, contentCreator, contentName,
JingleContent.Senders.initiator, description, transport, additionalElements);
}
public IQ sendSessionInitiateFileOffer(FullJid recipient,
String sessionId,
JingleContent.Creator contentCreator,
String contentName,
JingleContentDescription description,
JingleContentTransport transport,
List<Element> additionalElements)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionInitiateFileOffer(recipient, sessionId, contentCreator, contentName, description, transport, additionalElements);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
public IQ sendSessionInitiate(FullJid recipient,
String sessionId,
JingleContent.Creator contentCreator,
String contentName,
JingleContent.Senders contentSenders,
JingleContentDescription description,
JingleContentTransport transport,
List<Element> additionalElements)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionInitiate(recipient, sessionId, contentCreator, contentName, contentSenders,
description, transport, additionalElements);
return connection.createStanzaCollectorAndSend(jingle).nextResult();
}
/**
* Accept a session.
* XEP-0166 Example 17.
* @param recipient recipient of the stanza.
* @param sessionId sessionId.
* @param contentCreator creator of the content.
* @param contentName name of the content.
* @param contentSenders sender of the content.
* @param description description of the content.
* @param transport proposed transport.
* @param content content
* @return session-accept stanza.
*/
public Jingle createSessionAccept(FullJid recipient,
String sessionId,
JingleContent.Creator contentCreator,
String contentName,
JingleContent.Senders contentSenders,
JingleContentDescription description,
JingleContentTransport transport) {
JingleContent content) {
return createSessionAccept(recipient, sessionId, Collections.singletonList(content));
}
public Jingle createSessionAccept(FullJid recipient,
String sessionId,
List<JingleContent> contents) {
Jingle.Builder jb = Jingle.getBuilder();
jb.setResponder(connection.getUser())
.setAction(JingleAction.session_accept)
.setSessionId(sessionId);
JingleContent.Builder cb = JingleContent.getBuilder();
cb.setCreator(contentCreator)
.setName(contentName)
.setSenders(contentSenders)
.setDescription(description)
.setTransport(transport);
for (JingleContent content : contents) {
jb.addJingleContent(content);
}
Jingle jingle = jb.addJingleContent(cb.build()).build();
Jingle jingle = jb.build();
jingle.setTo(recipient);
jingle.setFrom(connection.getUser());
return jingle;
}
public IQ sendSessionAccept(FullJid recipient,
String sessionId,
JingleContent.Creator contentCreator,
String contentName,
JingleContent.Senders contentSenders,
JingleContentDescription description,
JingleContentTransport transport)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionAccept(recipient, sessionId, contentCreator, contentName, contentSenders,
description, transport);
return connection.createStanzaCollectorAndSend(jingle).nextResult();
}
/**
* Create a session-terminate stanza.
* XEP-0166 §6.7.
@ -227,22 +143,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, new JingleReason(reason));
}
private IQ sendSessionTerminate(FullJid recipient, String sessionId, JingleReason.Reason reason)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
return sendSessionTerminate(recipient, sessionId, new JingleReason(reason));
}
private IQ sendSessionTerminate(FullJid recipient, String sessionId, JingleReason reason)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminate(recipient, sessionId, reason);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Terminate the session by declining.
* XEP-0166 Example 21.
@ -254,14 +154,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.decline);
}
public IQ sendSessionTerminateDecline(FullJid recipient, String sessionId)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateDecline(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Terminate the session due to success.
* XEP-0166 Example 19.
@ -273,14 +165,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.success);
}
public IQ sendSessionTerminateSuccess(FullJid recipient, String sessionId)
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateSuccess(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Terminate the session due to being busy.
* XEP-0166 Example 20.
@ -292,14 +176,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.busy);
}
public IQ sendSessionTerminateBusy(FullJid recipient, String sessionId)
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateBusy(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Terminate the session due to the existence of an alternative session.
* XEP-0166 Example 22.
@ -312,14 +188,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.AlternativeSession(altSessionId));
}
public IQ sendSessionTerminateAlternativeSession(FullJid recipient, String sessionId, String altSessionId)
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateAlternativeSession(recipient, sessionId, altSessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Cancel all active transfers of the session.
* XEP-0234 Example 9.
@ -331,15 +199,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.cancel);
}
public IQ sendSessionTerminateCancel(FullJid recipient,
String sessionId)
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateCancel(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Cancel a single contents transfer.
* XEP-0234 Example 10.
@ -365,14 +224,6 @@ public class JingleUtil {
return jingle;
}
public IQ sendSessionTerminateContentCancel(FullJid recipient, String sessionId,
JingleContent.Creator contentCreator, String contentName)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateContentCancel(recipient, sessionId, contentCreator, contentName);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Terminate the session due to unsupported transport methods.
* XEP-0166 Example 23.
@ -384,13 +235,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.unsupported_transports);
}
public IQ sendSessionTerminateUnsupportedTransports(FullJid recipient, String sessionId)
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateUnsupportedTransports(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Terminate the session due to failed transports.
* XEP-0166 Example 24.
@ -402,13 +246,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.failed_transport);
}
public IQ sendSessionTerminateFailedTransport(FullJid recipient, String sessionId)
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateFailedTransport(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Terminate the session due to unsupported applications.
* XEP-0166 Example 25.
@ -420,13 +257,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.unsupported_applications);
}
public IQ sendSessionTerminateUnsupportedApplications(FullJid recipient, String sessionId)
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateUnsupportedApplications(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Terminate the session due to failed application.
* XEP-0166 Example 26.
@ -438,13 +268,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.failed_application);
}
public IQ sendSessionTerminateFailedApplication(FullJid recipient, String sessionId)
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateFailedApplication(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Terminate session due to incompatible parameters.
* XEP-0166 Example 27.
@ -456,13 +279,6 @@ public class JingleUtil {
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.incompatible_parameters);
}
public IQ sendSessionTerminateIncompatibleParameters(FullJid recipient, String sessionId)
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateIncompatibleParameters(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
public IQ sendContentRejectFileNotAvailable(FullJid recipient, String sessionId, JingleContentDescription description) {
return null; //TODO Later
}
@ -486,13 +302,6 @@ public class JingleUtil {
return jingle;
}
public IQ sendSessionPing(FullJid recipient, String sessionId)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionPing(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Acknowledge the receipt of a stanza.
* XEP-0166 Example 5.
@ -503,10 +312,6 @@ public class JingleUtil {
return IQ.createResultIQ(jingle);
}
public void sendAck(Jingle jingle) throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createAck(jingle));
}
/**
* Replace a transport with another one.
* XEP-0260 Example 15.
@ -536,15 +341,6 @@ public class JingleUtil {
return jingle;
}
public IQ sendTransportReplace(FullJid recipient, FullJid initiator, String sessionId,
JingleContent.Creator contentCreator, String contentName,
JingleContentTransport transport)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createTransportReplace(recipient, initiator, sessionId, contentCreator, contentName, transport);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Accept a transport.
* XEP-0260 Example 17.
@ -574,15 +370,6 @@ public class JingleUtil {
return jingle;
}
public IQ sendTransportAccept(FullJid recipient, FullJid initiator, String sessionId,
JingleContent.Creator contentCreator, String contentName,
JingleContentTransport transport)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createTransportAccept(recipient, initiator, sessionId, contentCreator, contentName, transport);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/**
* Reject a transport.
* XEP-0166 §7.2.14.
@ -612,15 +399,6 @@ public class JingleUtil {
return jingle;
}
public IQ sendTransportReject(FullJid recipient, FullJid initiator, String sessionId,
JingleContent.Creator contentCreator, String contentName,
JingleContentTransport transport)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createTransportReject(recipient, initiator, sessionId, contentCreator, contentName, transport);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
/*
* ####################################################################################################
*/
@ -638,11 +416,6 @@ public class JingleUtil {
return IQ.createErrorResponse(request, error);
}
public void sendErrorUnknownSession(Jingle request)
throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createErrorUnknownSession(request));
}
/**
* Create an error response to a request coming from a unknown initiator.
* XEP-0166 Example 12.
@ -654,11 +427,6 @@ public class JingleUtil {
return IQ.createErrorResponse(request, b);
}
public void sendErrorUnknownInitiator(Jingle request)
throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createErrorUnknownInitiator(request));
}
/**
* Create an error response to a request with an unsupported info.
* XEP-0166 Example 31.
@ -672,11 +440,6 @@ public class JingleUtil {
return IQ.createErrorResponse(request, error);
}
public void sendErrorUnsupportedInfo(Jingle request)
throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createErrorUnsupportedInfo(request));
}
/**
* Create an error response to a tie-breaking request.
* XEP-0166 Example 34.
@ -690,11 +453,6 @@ public class JingleUtil {
return IQ.createErrorResponse(request, error);
}
public void sendErrorTieBreak(Jingle request)
throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createErrorTieBreak(request));
}
/**
* Create an error response to a request that was out of order.
* TODO: Find example.
@ -708,11 +466,6 @@ public class JingleUtil {
return IQ.createErrorResponse(request, error);
}
public void sendErrorOutOfOrder(Jingle request)
throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createErrorOutOfOrder(request));
}
/**
* Create an error response to a malformed request.
* XEP-0166 Ex. 16
@ -725,9 +478,4 @@ public class JingleUtil {
error.setCondition(XMPPError.Condition.bad_request);
return IQ.createErrorResponse(request, error);
}
public void sendErrorMalformedRequest(Jingle request)
throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createErrorMalformedRequest(request));
}
}

View file

@ -16,10 +16,6 @@
*/
package org.jivesoftware.smackx.jingle.element;
import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
@ -27,6 +23,11 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
/**
* Jingle content element.
* <jingle>
* <content> <- Me.
* ...
* </content>
* </jingle>
*/
public final class JingleContent implements NamedElement {
@ -72,22 +73,20 @@ public final class JingleContent implements NamedElement {
private final JingleContentTransport transport;
private final List<Element> additionalElements = new ArrayList<>();
private final JingleContentSecurity security;
/**
* Creates a content description..
*/
private JingleContent(Creator creator, String disposition, String name, Senders senders,
JingleContentDescription description, JingleContentTransport transport, List<Element> additionalElements) {
JingleContentDescription description, JingleContentTransport transport, JingleContentSecurity security) {
this.creator = Objects.requireNonNull(creator, "Jingle content creator must not be null");
this.disposition = disposition;
this.name = StringUtils.requireNotNullOrEmpty(name, "Jingle content name must not be null or empty");
this.senders = senders;
this.description = description;
this.transport = transport;
if (additionalElements != null) {
this.additionalElements.addAll(additionalElements);
}
this.security = security;
}
public Creator getCreator() {
@ -120,12 +119,12 @@ public final class JingleContent implements NamedElement {
*
* @return an Iterator for the JingleTransports in the packet.
*/
public JingleContentTransport getJingleTransport() {
public JingleContentTransport getTransport() {
return transport;
}
public List<Element> getAdditionalElements() {
return additionalElements;
public JingleContentSecurity getSecurity() {
return security;
}
@Override
@ -144,10 +143,7 @@ public final class JingleContent implements NamedElement {
xml.optAppend(description);
xml.optElement(transport);
for (Element element : additionalElements) {
xml.element(element);
}
xml.optElement(security);
xml.closeElement(this);
return xml;
@ -170,7 +166,7 @@ public final class JingleContent implements NamedElement {
private JingleContentTransport transport;
private List<Element> additionalElements = new ArrayList<>();
private JingleContentSecurity security;
private Builder() {
}
@ -208,15 +204,13 @@ public final class JingleContent implements NamedElement {
return this;
}
public Builder addAdditionalElements(List<Element> elements) {
if (elements != null) {
additionalElements.addAll(elements);
}
public Builder setSecurity(JingleContentSecurity element) {
this.security = element;
return this;
}
public JingleContent build() {
return new JingleContent(creator, disposition, name, senders, description, transport, additionalElements);
return new JingleContent(creator, disposition, name, senders, description, transport, security);
}
}
}

View file

@ -24,6 +24,13 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
/**
* Jingle content description.
* <jingle>
* <content>
* <description/> <- This element is us.
* <transport/>
* <security/>
* </content>
* </jingle>
*
*/
public abstract class JingleContentDescription implements ExtensionElement {

View file

@ -20,6 +20,15 @@ import org.jivesoftware.smack.packet.NamedElement;
/**
* An element found usually in 'description' elements.
* <jingle>
* <content>
* <description>
* <XYZ/> <- We live here.
* </description>
* <transport/>
* <security/>
* </content>
* </jingle>
*
*/
public abstract class JingleContentDescriptionChildElement implements NamedElement {

View file

@ -0,0 +1,40 @@
/**
*
* 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.
* 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 org.jivesoftware.smack.packet.ExtensionElement;
/**
* Jingle security element.
* <jingle>
* <content>
* <description/>
* <transport/>
* <security/> <- That's me :)
* </content>
* </jingle>
*/
public abstract class JingleContentSecurity implements ExtensionElement {
public static final String ELEMENT = "security";
@Override
public String getElementName() {
return ELEMENT;
}
}

View file

@ -24,6 +24,13 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
/**
* A jingle transport extension.
* <jingle>
* <content>
* <description/>
* <transport/> <- Voila.
* <security/>
* </content>
* </jingle>
*
*/
public abstract class JingleContentTransport implements ExtensionElement {

View file

@ -20,6 +20,15 @@ import org.jivesoftware.smack.packet.NamedElement;
/**
* An element found usually in Jingle 'transport' elements.
* <jingle>
* <content>
* <description/>
* <transport>
* <candidate/> <- We are those guys.
* <candidate/> <-/
* </transport>
* </content>
* </jingle>
*
*/
public abstract class JingleContentTransportCandidate implements NamedElement {

View file

@ -20,6 +20,17 @@ import org.jivesoftware.smack.packet.NamedElement;
/**
* Abstract JingleContentTransportInfo element.
* The JingleContentTransportInfo element can have certain states defined by the respective Transport XEP.
* Examples are Jingle Socks5Bytestream's <candidate-used/> (Example 5), <candidate-error/> (Example 7) etc.
* <jingle>
* <content>
* <description/>
* <transport>
* <xyz/> <- This is us.
* </transport>
* <security/>
* </content>
* </jingle>
*/
public abstract class JingleContentTransportInfo implements NamedElement {

View file

@ -41,7 +41,7 @@ public abstract class JingleTransportSession<T extends JingleContentTransport> {
}
JingleContent content = jingle.getContents().get(0);
JingleContentTransport t = content.getJingleTransport();
JingleContentTransport t = content.getTransport();
if (t != null && t.getNamespace().equals(getNamespace())) {
setTheirProposal(t);

View file

@ -189,7 +189,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
@Override
public IQ handleTransportInfo(Jingle transportInfo) {
JingleS5BTransportInfo info = (JingleS5BTransportInfo) transportInfo.getContents().get(0).getJingleTransport().getInfo();
JingleS5BTransportInfo info = (JingleS5BTransportInfo) transportInfo.getContents().get(0).getTransport().getInfo();
switch (info.getElementName()) {
case JingleS5BTransportInfo.CandidateUsed.ELEMENT:
@ -209,7 +209,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
}
public IQ handleCandidateUsed(Jingle jingle) {
JingleS5BTransportInfo info = (JingleS5BTransportInfo) jingle.getContents().get(0).getJingleTransport().getInfo();
JingleS5BTransportInfo info = (JingleS5BTransportInfo) jingle.getContents().get(0).getTransport().getInfo();
String candidateId = ((JingleS5BTransportInfo.CandidateUsed) info).getCandidateId();
theirChoice = new UsedCandidate(ourProposal, ourProposal.getCandidate(candidateId), null);

View file

@ -0,0 +1,13 @@
package org.jivesoftware.smackx.jingle3;
import java.util.ArrayList;
import org.jivesoftware.smackx.jingle.element.JingleContent;
/**
* Created by vanitas on 17.07.17.
*/
public class JingleSession {
private final ArrayList<JingleContent> contents
}

View file

@ -0,0 +1,42 @@
package org.jivesoftware.smackx.jingle3;
import org.jivesoftware.smackx.jingle.element.JingleContent;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
import org.jivesoftware.smackx.jingle.element.JingleContentSecurity;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
/**
* Internal class that holds the state of a content in a modifiable form.
*/
public class JingleSessionContent {
private JingleContent.Creator creator;
private String name;
private JingleContent.Senders senders;
private JingleContentDescription description;
private JingleContentTransport transport;
private JingleContentSecurity security;
public JingleContent.Creator getCreator() {
return creator;
}
public String getName() {
return name;
}
public JingleContent.Senders getSenders() {
return senders;
}
public JingleContentDescription getDescription() {
return description;
}
public JingleContentTransport getTransport() {
return transport;
}
public JingleContentSecurity getSecurity() {
return security;
}
}