mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Temp
This commit is contained in:
parent
520f77112d
commit
59e79ef668
5 changed files with 182 additions and 18 deletions
|
@ -16,9 +16,12 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle;
|
||||
|
||||
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;
|
||||
|
@ -60,7 +63,8 @@ public class JingleUtil {
|
|||
String contentName,
|
||||
JingleContent.Senders contentSenders,
|
||||
JingleContentDescription description,
|
||||
JingleContentTransport transport) {
|
||||
JingleContentTransport transport,
|
||||
List<Element> additionalElements) {
|
||||
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
jb.setAction(JingleAction.session_initiate)
|
||||
|
@ -72,7 +76,8 @@ public class JingleUtil {
|
|||
.setName(contentName)
|
||||
.setSenders(contentSenders)
|
||||
.setDescription(description)
|
||||
.setTransport(transport);
|
||||
.setTransport(transport)
|
||||
.addAdditionalElements(additionalElements);
|
||||
|
||||
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
||||
jingle.setFrom(connection.getUser());
|
||||
|
@ -97,9 +102,10 @@ public class JingleUtil {
|
|||
JingleContent.Creator contentCreator,
|
||||
String contentName,
|
||||
JingleContentDescription description,
|
||||
JingleContentTransport transport) {
|
||||
JingleContentTransport transport,
|
||||
List<Element> additionalElements) {
|
||||
return createSessionInitiate(recipient, sessionId, contentCreator, contentName,
|
||||
JingleContent.Senders.initiator, description, transport);
|
||||
JingleContent.Senders.initiator, description, transport, additionalElements);
|
||||
}
|
||||
|
||||
public IQ sendSessionInitiateFileOffer(FullJid recipient,
|
||||
|
@ -107,11 +113,12 @@ public class JingleUtil {
|
|||
JingleContent.Creator contentCreator,
|
||||
String contentName,
|
||||
JingleContentDescription description,
|
||||
JingleContentTransport transport)
|
||||
JingleContentTransport transport,
|
||||
List<Element> additionalElements)
|
||||
throws SmackException.NotConnectedException, InterruptedException,
|
||||
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
||||
|
||||
Jingle jingle = createSessionInitiateFileOffer(recipient, sessionId, contentCreator, contentName, description, transport);
|
||||
Jingle jingle = createSessionInitiateFileOffer(recipient, sessionId, contentCreator, contentName, description, transport, additionalElements);
|
||||
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
|
||||
}
|
||||
|
||||
|
@ -121,12 +128,13 @@ public class JingleUtil {
|
|||
String contentName,
|
||||
JingleContent.Senders contentSenders,
|
||||
JingleContentDescription description,
|
||||
JingleContentTransport transport)
|
||||
JingleContentTransport transport,
|
||||
List<Element> additionalElements)
|
||||
throws SmackException.NotConnectedException, InterruptedException,
|
||||
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
||||
|
||||
Jingle jingle = createSessionInitiate(recipient, sessionId, contentCreator, contentName, contentSenders,
|
||||
description, transport);
|
||||
description, transport, additionalElements);
|
||||
|
||||
return connection.createStanzaCollectorAndSend(jingle).nextResult();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
*/
|
||||
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;
|
||||
|
@ -68,17 +72,22 @@ public final class JingleContent implements NamedElement {
|
|||
|
||||
private final JingleContentTransport transport;
|
||||
|
||||
private final List<Element> additionalElements = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a content description..
|
||||
*/
|
||||
private JingleContent(Creator creator, String disposition, String name, Senders senders,
|
||||
JingleContentDescription description, JingleContentTransport transport) {
|
||||
JingleContentDescription description, JingleContentTransport transport, List<Element> additionalElements) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public Creator getCreator() {
|
||||
|
@ -115,6 +124,10 @@ public final class JingleContent implements NamedElement {
|
|||
return transport;
|
||||
}
|
||||
|
||||
public List<Element> getAdditionalElements() {
|
||||
return additionalElements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
|
@ -132,6 +145,10 @@ public final class JingleContent implements NamedElement {
|
|||
xml.optAppend(description);
|
||||
xml.optElement(transport);
|
||||
|
||||
for (Element element : additionalElements) {
|
||||
xml.element(element);
|
||||
}
|
||||
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
|
@ -153,6 +170,8 @@ public final class JingleContent implements NamedElement {
|
|||
|
||||
private JingleContentTransport transport;
|
||||
|
||||
private List<Element> additionalElements = new ArrayList<>();
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
|
@ -189,8 +208,15 @@ public final class JingleContent implements NamedElement {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder addAdditionalElements(List<Element> elements) {
|
||||
if (elements != null) {
|
||||
additionalElements.addAll(elements);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public JingleContent build() {
|
||||
return new JingleContent(creator, disposition, name, senders, description, transport);
|
||||
return new JingleContent(creator, disposition, name, senders, description, transport, additionalElements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue