Heavy reworking in progress
This commit is contained in:
parent
7658369d63
commit
6818a52da7
|
@ -107,7 +107,9 @@ public class ParserUtils {
|
||||||
}
|
}
|
||||||
Jid jid = JidCreate.from(jidString);
|
Jid jid = JidCreate.from(jidString);
|
||||||
|
|
||||||
if (!jid.hasLocalpart()) return null;
|
if (!jid.hasLocalpart()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
EntityFullJid fullJid = jid.asEntityFullJidIfPossible();
|
EntityFullJid fullJid = jid.asEntityFullJidIfPossible();
|
||||||
if (fullJid != null) {
|
if (fullJid != null) {
|
||||||
|
@ -135,14 +137,16 @@ public class ParserUtils {
|
||||||
*/
|
*/
|
||||||
public static Boolean getBooleanAttribute(XmlPullParser parser, String name) {
|
public static Boolean getBooleanAttribute(XmlPullParser parser, String name) {
|
||||||
String valueString = parser.getAttributeValue("", name);
|
String valueString = parser.getAttributeValue("", name);
|
||||||
if (valueString == null)
|
if (valueString == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
valueString = valueString.toLowerCase(Locale.US);
|
valueString = valueString.toLowerCase(Locale.US);
|
||||||
if (valueString.equals("true") || valueString.equals("0")) {
|
if (valueString.equals("true") || valueString.equals("0")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getBooleanAttribute(XmlPullParser parser, String name,
|
public static boolean getBooleanAttribute(XmlPullParser parser, String name,
|
||||||
|
@ -151,10 +155,8 @@ public class ParserUtils {
|
||||||
if (bool == null) {
|
if (bool == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return bool;
|
return bool;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static int getIntegerAttributeOrThrow(XmlPullParser parser, String name, String throwMessage) throws SmackException {
|
public static int getIntegerAttributeOrThrow(XmlPullParser parser, String name, String throwMessage) throws SmackException {
|
||||||
Integer res = getIntegerAttribute(parser, name);
|
Integer res = getIntegerAttribute(parser, name);
|
||||||
|
@ -166,8 +168,9 @@ public class ParserUtils {
|
||||||
|
|
||||||
public static Integer getIntegerAttribute(XmlPullParser parser, String name) {
|
public static Integer getIntegerAttribute(XmlPullParser parser, String name) {
|
||||||
String valueString = parser.getAttributeValue("", name);
|
String valueString = parser.getAttributeValue("", name);
|
||||||
if (valueString == null)
|
if (valueString == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return Integer.valueOf(valueString);
|
return Integer.valueOf(valueString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,10 +179,8 @@ public class ParserUtils {
|
||||||
if (integer == null) {
|
if (integer == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return integer;
|
return integer;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static int getIntegerFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException {
|
public static int getIntegerFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
String intString = parser.nextText();
|
String intString = parser.nextText();
|
||||||
|
@ -188,8 +189,9 @@ public class ParserUtils {
|
||||||
|
|
||||||
public static Long getLongAttribute(XmlPullParser parser, String name) {
|
public static Long getLongAttribute(XmlPullParser parser, String name) {
|
||||||
String valueString = parser.getAttributeValue("", name);
|
String valueString = parser.getAttributeValue("", name);
|
||||||
if (valueString == null)
|
if (valueString == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return Long.valueOf(valueString);
|
return Long.valueOf(valueString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,10 +200,8 @@ public class ParserUtils {
|
||||||
if (l == null) {
|
if (l == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static double getDoubleFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException {
|
public static double getDoubleFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
String doubleString = parser.nextText();
|
String doubleString = parser.nextText();
|
||||||
|
@ -210,8 +210,9 @@ public class ParserUtils {
|
||||||
|
|
||||||
public static Double getDoubleAttribute(XmlPullParser parser, String name) {
|
public static Double getDoubleAttribute(XmlPullParser parser, String name) {
|
||||||
String valueString = parser.getAttributeValue("", name);
|
String valueString = parser.getAttributeValue("", name);
|
||||||
if (valueString == null)
|
if (valueString == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return Double.valueOf(valueString);
|
return Double.valueOf(valueString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,9 +221,23 @@ public class ParserUtils {
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Short getShortAttribute(XmlPullParser parser, String name) {
|
||||||
|
String valueString = parser.getAttributeValue("", name);
|
||||||
|
if (valueString == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Short.valueOf(valueString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static short getShortAttribute(XmlPullParser parser, String name, short defaultValue) {
|
||||||
|
Short s = getShortAttribute(parser, name);
|
||||||
|
if (s == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getDateFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
|
public static Date getDateFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
|
||||||
|
|
|
@ -37,9 +37,9 @@ import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smackx.jet.element.JetSecurityElement;
|
import org.jivesoftware.smackx.jet.element.JetSecurityElement;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleUtil;
|
import org.jivesoftware.smackx.jingle.JingleUtil;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionChildElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.OutgoingJingleFileOffer;
|
import org.jivesoftware.smackx.jingle_filetransfer.OutgoingJingleFileOffer;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
||||||
|
@ -150,15 +150,15 @@ public final class JetManager extends Manager {
|
||||||
JingleFileTransferChild fileTransferChild = JingleFileTransferChild.getBuilder().setFile(file).build();
|
JingleFileTransferChild fileTransferChild = JingleFileTransferChild.getBuilder().setFile(file).build();
|
||||||
JingleFileTransfer fileTransfer = new JingleFileTransfer(Collections.<JingleContentDescriptionChildElement>singletonList(fileTransferChild));
|
JingleFileTransfer fileTransfer = new JingleFileTransfer(Collections.<JingleContentDescriptionChildElement>singletonList(fileTransferChild));
|
||||||
|
|
||||||
JingleContent content = JingleContent.getBuilder()
|
JingleContentElement content = JingleContentElement.getBuilder()
|
||||||
.setCreator(JingleContent.Creator.initiator)
|
.setCreator(JingleContentElement.Creator.initiator)
|
||||||
.setName(contentName)
|
.setName(contentName)
|
||||||
.setTransport(offer.getTransportSession().createTransport())
|
.setTransport(offer.getTransportSession().createTransport())
|
||||||
.setSecurity(securityElement)
|
.setSecurity(securityElement)
|
||||||
.setDescription(fileTransfer)
|
.setDescription(fileTransfer)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Jingle initiate = jutil.createSessionInitiate(recipient, JingleManager.randomId(), content);
|
JingleElement initiate = jutil.createSessionInitiate(recipient, JingleManager.randomId(), content);
|
||||||
return offer;
|
return offer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jet.element;
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smackx.jet.JetManager;
|
import org.jivesoftware.smackx.jet.JetManager;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentSecurity;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentSecurityElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Jingle security element as specified in XEP-XXXX (Jingle Encrypted Transfers).
|
* Implementation of the Jingle security element as specified in XEP-XXXX (Jingle Encrypted Transfers).
|
||||||
|
@ -31,7 +31,7 @@ import org.jivesoftware.smackx.jingle.element.JingleContentSecurity;
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
*/
|
*/
|
||||||
public class JetSecurityElement extends JingleContentSecurity {
|
public class JetSecurityElement extends JingleContentSecurityElement {
|
||||||
public static final String ATTR_NAME = "name";
|
public static final String ATTR_NAME = "name";
|
||||||
public static final String ATTR_TYPE = "type";
|
public static final String ATTR_TYPE = "type";
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@ import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportMethodManager;
|
import org.jivesoftware.smackx.jingle.JingleTransportMethodManager;
|
||||||
import org.jivesoftware.smackx.jingle.Role;
|
import org.jivesoftware.smackx.jingle.Role;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback;
|
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback;
|
||||||
|
@ -45,7 +45,7 @@ import org.jxmpp.jid.FullJid;
|
||||||
*/
|
*/
|
||||||
public class IncomingJingleFileOffer extends JingleFileTransferSession implements IncomingFileOfferCallback {
|
public class IncomingJingleFileOffer extends JingleFileTransferSession implements IncomingFileOfferCallback {
|
||||||
private static final Logger LOGGER = Logger.getLogger(IncomingJingleFileOffer.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(IncomingJingleFileOffer.class.getName());
|
||||||
private Jingle pendingSessionInitiate = null;
|
private JingleElement pendingSessionInitiate = null;
|
||||||
private ReceiveTask receivingThread;
|
private ReceiveTask receivingThread;
|
||||||
private File target;
|
private File target;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
queued.remove(task);
|
queued.remove(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyEndedListeners(JingleReason.Reason.cancel);
|
notifyEndedListeners(JingleReasonElement.Reason.cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,12 +77,12 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
state = State.fresh;
|
state = State.fresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IncomingJingleFileOffer(XMPPConnection connection, Jingle request) {
|
public IncomingJingleFileOffer(XMPPConnection connection, JingleElement request) {
|
||||||
this(connection, request.getInitiator(), request.getSid());
|
this(connection, request.getInitiator(), request.getSid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleSessionInitiate(final Jingle initiate)
|
public IQ handleSessionInitiate(final JingleElement initiate)
|
||||||
throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
|
throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
|
||||||
SmackException.NoResponseException {
|
SmackException.NoResponseException {
|
||||||
JingleTransportMethodManager tm = JingleTransportMethodManager.getInstanceFor(connection);
|
JingleTransportMethodManager tm = JingleTransportMethodManager.getInstanceFor(connection);
|
||||||
|
@ -130,7 +130,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleTransportReplace(final Jingle transportReplace)
|
public IQ handleTransportReplace(final JingleElement transportReplace)
|
||||||
throws InterruptedException, XMPPException.XMPPErrorException,
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
||||||
SmackException.NotConnectedException, SmackException.NoResponseException {
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||||
final JingleTransportManager<?> replacementManager = JingleTransportMethodManager.getInstanceFor(connection)
|
final JingleTransportManager<?> replacementManager = JingleTransportMethodManager.getInstanceFor(connection)
|
||||||
|
@ -179,7 +179,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleTransportAccept(Jingle transportAccept) {
|
public IQ handleTransportAccept(JingleElement transportAccept) {
|
||||||
LOGGER.log(Level.INFO, "Received transport-accept.");
|
LOGGER.log(Level.INFO, "Received transport-accept.");
|
||||||
if (state != State.sent_transport_replace) {
|
if (state != State.sent_transport_replace) {
|
||||||
LOGGER.log(Level.WARNING, "Session is in state " + state + ", so the transport-accept is out of order.");
|
LOGGER.log(Level.WARNING, "Session is in state " + state + ", so the transport-accept is out of order.");
|
||||||
|
@ -199,7 +199,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileTransferHandler acceptIncomingFileOffer(final Jingle request, final File target) {
|
public FileTransferHandler acceptIncomingFileOffer(final JingleElement request, final File target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
LOGGER.log(Level.INFO, "Client accepted incoming file offer. Try to start receiving.");
|
LOGGER.log(Level.INFO, "Client accepted incoming file offer. Try to start receiving.");
|
||||||
if (transportSession == null) {
|
if (transportSession == null) {
|
||||||
|
@ -218,7 +218,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
|
|
||||||
try {
|
try {
|
||||||
jutil.sendSessionAccept(getInitiator(), sid, getContents().get(0).getCreator(),
|
jutil.sendSessionAccept(getInitiator(), sid, getContents().get(0).getCreator(),
|
||||||
getContents().get(0).getName(), JingleContent.Senders.initiator, file,
|
getContents().get(0).getName(), JingleContentElement.Senders.initiator, file,
|
||||||
transportSession.createTransport());
|
transportSession.createTransport());
|
||||||
} catch (SmackException.NotConnectedException | SmackException.NoResponseException |
|
} catch (SmackException.NotConnectedException | SmackException.NoResponseException |
|
||||||
XMPPException.XMPPErrorException | InterruptedException e) {
|
XMPPException.XMPPErrorException | InterruptedException e) {
|
||||||
|
@ -245,7 +245,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void declineIncomingFileOffer(Jingle request) {
|
public void declineIncomingFileOffer(JingleElement request) {
|
||||||
state = State.terminated;
|
state = State.terminated;
|
||||||
try {
|
try {
|
||||||
jutil.sendSessionTerminateDecline(request.getInitiator(), request.getSid());
|
jutil.sendSessionTerminateDecline(request.getInitiator(), request.getSid());
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jingle_filetransfer;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.Role;
|
import org.jivesoftware.smackx.jingle.Role;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class JingleFileRequest extends JingleFileTransferSession {
|
||||||
JingleManager.randomId());
|
JingleManager.randomId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JingleFileRequest createIncomingFileRequest(XMPPConnection connection, Jingle request) {
|
public static JingleFileRequest createIncomingFileRequest(XMPPConnection connection, JingleElement request) {
|
||||||
return new JingleFileRequest(connection, request.getInitiator(), connection.getUser().asFullJidOrThrow(), Role.responder,
|
return new JingleFileRequest(connection, request.getInitiator(), connection.getUser().asFullJidOrThrow(), Role.responder,
|
||||||
request.getSid());
|
request.getSid());
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,11 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleHandler;
|
import org.jivesoftware.smackx.jingle.JingleHandler;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleUtil;
|
import org.jivesoftware.smackx.jingle.JingleUtil;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionChildElement;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentProviderManager;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback;
|
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
||||||
|
@ -85,7 +85,7 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleJingleRequest(Jingle jingle) {
|
public IQ handleJingleRequest(JingleElement jingle) {
|
||||||
FullJid fullJid = jingle.getFrom().asFullJidOrThrow();
|
FullJid fullJid = jingle.getFrom().asFullJidOrThrow();
|
||||||
String sid = jingle.getSid();
|
String sid = jingle.getSid();
|
||||||
|
|
||||||
|
@ -107,18 +107,18 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private JingleFileTransferSession createSessionHandler(Jingle request) {
|
private JingleFileTransferSession createSessionHandler(JingleElement request) {
|
||||||
if (request.getAction() != JingleAction.session_initiate) {
|
if (request.getAction() != JingleAction.session_initiate) {
|
||||||
LOGGER.log(Level.WARNING, "First received action must be session-initiate.");
|
LOGGER.log(Level.WARNING, "First received action must be session-initiate.");
|
||||||
throw new IllegalArgumentException("Requests action MUST be session-initiate.");
|
throw new IllegalArgumentException("Requests action MUST be session-initiate.");
|
||||||
}
|
}
|
||||||
|
|
||||||
JingleContent content = request.getContents().get(0);
|
JingleContentElement content = request.getContents().get(0);
|
||||||
//File Offer
|
//File Offer
|
||||||
if (content.getSenders() == JingleContent.Senders.initiator) {
|
if (content.getSenders() == JingleContentElement.Senders.initiator) {
|
||||||
return new IncomingJingleFileOffer(connection(), request);
|
return new IncomingJingleFileOffer(connection(), request);
|
||||||
} //File Request
|
} //File Request
|
||||||
else if (content.getSenders() == JingleContent.Senders.responder) {
|
else if (content.getSenders() == JingleContentElement.Senders.responder) {
|
||||||
return JingleFileRequest.createIncomingFileRequest(connection(), request);
|
return JingleFileRequest.createIncomingFileRequest(connection(), request);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -129,7 +129,7 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyIncomingFileOffer(Jingle initiate, IncomingFileOfferCallback callback) {
|
public void notifyIncomingFileOffer(JingleElement initiate, IncomingFileOfferCallback callback) {
|
||||||
for (JingleFileTransferOfferListener l : jingleFileTransferOfferListeners) {
|
for (JingleFileTransferOfferListener l : jingleFileTransferOfferListeners) {
|
||||||
l.onFileOffer(initiate, callback);
|
l.onFileOffer(initiate, callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.JingleUtil;
|
import org.jivesoftware.smackx.jingle.JingleUtil;
|
||||||
import org.jivesoftware.smackx.jingle.Role;
|
import org.jivesoftware.smackx.jingle.Role;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler;
|
import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public abstract class JingleFileTransferSession extends JingleSession implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyEndedListeners(JingleReason.Reason reason) {
|
public void notifyEndedListeners(JingleReasonElement.Reason reason) {
|
||||||
ended = true;
|
ended = true;
|
||||||
for (EndedListener e : endedListeners) {
|
for (EndedListener e : endedListeners) {
|
||||||
e.onEnded(reason);
|
e.onEnded(reason);
|
||||||
|
|
|
@ -31,9 +31,9 @@ import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportMethodManager;
|
import org.jivesoftware.smackx.jingle.JingleTransportMethodManager;
|
||||||
import org.jivesoftware.smackx.jingle.Role;
|
import org.jivesoftware.smackx.jingle.Role;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
||||||
|
@ -65,7 +65,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
jutil.sendSessionTerminateCancel(getRemote(), getSessionId());
|
jutil.sendSessionTerminateCancel(getRemote(), getSessionId());
|
||||||
notifyEndedListeners(JingleReason.Reason.cancel);
|
notifyEndedListeners(JingleReasonElement.Reason.cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
|
@ -96,7 +96,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
String contentName = JingleManager.randomId();
|
String contentName = JingleManager.randomId();
|
||||||
JingleFileTransfer transfer = JingleFileTransferManager.fileTransferFromFile(file);
|
JingleFileTransfer transfer = JingleFileTransferManager.fileTransferFromFile(file);
|
||||||
|
|
||||||
initiateFileOffer(transfer, JingleContent.Creator.initiator, contentName);
|
initiateFileOffer(transfer, JingleContentElement.Creator.initiator, contentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SmackFuture<?> sendAsync(File file) {
|
public SmackFuture<?> sendAsync(File file) {
|
||||||
|
@ -106,7 +106,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
return null; //TODO
|
return null; //TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initiateFileOffer(JingleFileTransfer file, JingleContent.Creator creator, String name) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
|
public void initiateFileOffer(JingleFileTransfer file, JingleContentElement.Creator creator, String name) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||||
if (state != State.fresh) {
|
if (state != State.fresh) {
|
||||||
throw new IllegalStateException("This session is not fresh.");
|
throw new IllegalStateException("This session is not fresh.");
|
||||||
}
|
}
|
||||||
|
@ -122,14 +122,14 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
|
|
||||||
state = State.pending;
|
state = State.pending;
|
||||||
|
|
||||||
Jingle initiate = jutil.createSessionInitiateFileOffer(getResponder(), getSessionId(), creator, name, file, transportSession.createTransport(), null);
|
JingleElement initiate = jutil.createSessionInitiateFileOffer(getResponder(), getSessionId(), creator, name, file, transportSession.createTransport(), null);
|
||||||
this.contents.addAll(initiate.getContents());
|
this.contents.addAll(initiate.getContents());
|
||||||
|
|
||||||
connection.sendStanza(initiate);
|
connection.sendStanza(initiate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleSessionAccept(Jingle sessionAccept) throws SmackException.NotConnectedException, InterruptedException {
|
public IQ handleSessionAccept(JingleElement sessionAccept) throws SmackException.NotConnectedException, InterruptedException {
|
||||||
// Out of order?
|
// Out of order?
|
||||||
if (state != State.pending) {
|
if (state != State.pending) {
|
||||||
LOGGER.log(Level.WARNING, "Session state is " + state + ", so session-accept is out of order.");
|
LOGGER.log(Level.WARNING, "Session state is " + state + ", so session-accept is out of order.");
|
||||||
|
@ -158,13 +158,13 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleSessionTerminate(Jingle sessionTerminate) {
|
public IQ handleSessionTerminate(JingleElement sessionTerminate) {
|
||||||
state = State.terminated;
|
state = State.terminated;
|
||||||
return jutil.createAck(sessionTerminate);
|
return jutil.createAck(sessionTerminate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleTransportReplace(final Jingle transportReplace)
|
public IQ handleTransportReplace(final JingleElement transportReplace)
|
||||||
throws InterruptedException, XMPPException.XMPPErrorException,
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
||||||
SmackException.NotConnectedException, SmackException.NoResponseException {
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||||
final JingleTransportManager<?> replacementManager = JingleTransportMethodManager.getInstanceFor(connection)
|
final JingleTransportManager<?> replacementManager = JingleTransportMethodManager.getInstanceFor(connection)
|
||||||
|
@ -196,7 +196,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleTransportAccept(Jingle transportAccept)
|
public IQ handleTransportAccept(JingleElement transportAccept)
|
||||||
throws SmackException.NotConnectedException, InterruptedException {
|
throws SmackException.NotConnectedException, InterruptedException {
|
||||||
|
|
||||||
return handleSessionAccept(transportAccept);
|
return handleSessionAccept(transportAccept);
|
||||||
|
@ -205,7 +205,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
@Override
|
@Override
|
||||||
public void onTransportMethodFailed(String namespace) {
|
public void onTransportMethodFailed(String namespace) {
|
||||||
state = State.pending;
|
state = State.pending;
|
||||||
JingleContent content = contents.get(0);
|
JingleContentElement content = contents.get(0);
|
||||||
failedTransportMethods.add(namespace);
|
failedTransportMethods.add(namespace);
|
||||||
JingleTransportMethodManager tm = JingleTransportMethodManager.getInstanceFor(getConnection());
|
JingleTransportMethodManager tm = JingleTransportMethodManager.getInstanceFor(getConnection());
|
||||||
JingleTransportManager<?> next = tm.getBestAvailableTransportManager(failedTransportMethods);
|
JingleTransportManager<?> next = tm.getBestAvailableTransportManager(failedTransportMethods);
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class ReceiveTask implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.notifyEndedListeners(JingleReason.Reason.success);
|
session.notifyEndedListeners(JingleReasonElement.Reason.success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by vanitas on 21.06.17.
|
* Created by vanitas on 21.06.17.
|
||||||
|
@ -78,7 +78,7 @@ public class SendTask implements Runnable {
|
||||||
LOGGER.log(Level.SEVERE, "Could not close session.", e);
|
LOGGER.log(Level.SEVERE, "Could not close session.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
session.notifyEndedListeners(JingleReason.Reason.success);
|
session.notifyEndedListeners(JingleReasonElement.Reason.success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.jingle_filetransfer.callback;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler;
|
import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler;
|
||||||
*/
|
*/
|
||||||
public interface IncomingFileOfferCallback {
|
public interface IncomingFileOfferCallback {
|
||||||
|
|
||||||
FileTransferHandler acceptIncomingFileOffer(Jingle request, File target);
|
FileTransferHandler acceptIncomingFileOffer(JingleElement request, File target);
|
||||||
|
|
||||||
void declineIncomingFileOffer(Jingle request);
|
void declineIncomingFileOffer(JingleElement request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,14 @@ package org.jivesoftware.smackx.jingle_filetransfer.callback;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback used to accept/decline file requests.
|
* Callback used to accept/decline file requests.
|
||||||
*/
|
*/
|
||||||
public interface IncomingFileRequestCallback {
|
public interface IncomingFileRequestCallback {
|
||||||
|
|
||||||
void acceptIncomingFileRequest(Jingle request, File source);
|
void acceptIncomingFileRequest(JingleElement request, File source);
|
||||||
|
|
||||||
void declineIncomingFileRequest(Jingle request);
|
void declineIncomingFileRequest(JingleElement request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jingle_filetransfer.element;
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.util.Objects;
|
import org.jivesoftware.smack.util.Objects;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checksum element.
|
* Checksum element.
|
||||||
|
@ -29,11 +29,11 @@ public class Checksum implements ExtensionElement {
|
||||||
public static final String ATTR_CREATOR = "creator";
|
public static final String ATTR_CREATOR = "creator";
|
||||||
public static final String ATTR_NAME = "name";
|
public static final String ATTR_NAME = "name";
|
||||||
|
|
||||||
private final JingleContent.Creator creator;
|
private final JingleContentElement.Creator creator;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final JingleFileTransferChild file;
|
private final JingleFileTransferChild file;
|
||||||
|
|
||||||
public Checksum(JingleContent.Creator creator, String name, JingleFileTransferChild file) {
|
public Checksum(JingleContentElement.Creator creator, String name, JingleFileTransferChild file) {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.file = Objects.requireNonNull(file, "file MUST NOT be null.");
|
this.file = Objects.requireNonNull(file, "file MUST NOT be null.");
|
||||||
|
|
|
@ -18,13 +18,13 @@ package org.jivesoftware.smackx.jingle_filetransfer.element;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionChildElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File element.
|
* File element.
|
||||||
*/
|
*/
|
||||||
public class JingleFileTransfer extends JingleContentDescription {
|
public class JingleFileTransfer extends JingleContentDescriptionElement {
|
||||||
public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5";
|
public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5";
|
||||||
|
|
||||||
public JingleFileTransfer(List<JingleContentDescriptionChildElement> payloads) {
|
public JingleFileTransfer(List<JingleContentDescriptionChildElement> payloads) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Date;
|
||||||
|
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionChildElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content of type File.
|
* Content of type File.
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.jingle_filetransfer.handler;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler that provides some control over the JingleFileOffer session.
|
* Handler that provides some control over the JingleFileOffer session.
|
||||||
|
@ -57,7 +57,7 @@ public interface FileTransferHandler {
|
||||||
/**
|
/**
|
||||||
* Notify all registered FinishedListeners that the file transfer has ended.
|
* Notify all registered FinishedListeners that the file transfer has ended.
|
||||||
*/
|
*/
|
||||||
void notifyEndedListeners(JingleReason.Reason reason);
|
void notifyEndedListeners(JingleReasonElement.Reason reason);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify all registered AcceptedListeners that the file transfer session has been accepted by the remote user.
|
* Notify all registered AcceptedListeners that the file transfer session has been accepted by the remote user.
|
||||||
|
@ -68,7 +68,7 @@ public interface FileTransferHandler {
|
||||||
* A FinishedListener will be notified by the SendFileHandler when the corresponding file transfer is ended.
|
* A FinishedListener will be notified by the SendFileHandler when the corresponding file transfer is ended.
|
||||||
*/
|
*/
|
||||||
interface EndedListener {
|
interface EndedListener {
|
||||||
void onEnded(JingleReason.Reason reason);
|
void onEnded(JingleReasonElement.Reason reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle_filetransfer.listener;
|
package org.jivesoftware.smackx.jingle_filetransfer.listener;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback;
|
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,5 +24,5 @@ import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCal
|
||||||
*/
|
*/
|
||||||
public interface JingleFileTransferOfferListener {
|
public interface JingleFileTransferOfferListener {
|
||||||
|
|
||||||
void onFileOffer(Jingle request, IncomingFileOfferCallback callback);
|
void onFileOffer(JingleElement request, IncomingFileOfferCallback callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||||
import org.jivesoftware.smack.util.ParserUtils;
|
import org.jivesoftware.smack.util.ParserUtils;
|
||||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Checksum;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.Checksum;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
||||||
|
@ -36,10 +36,10 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
public class ChecksumProvider extends ExtensionElementProvider<Checksum> {
|
public class ChecksumProvider extends ExtensionElementProvider<Checksum> {
|
||||||
@Override
|
@Override
|
||||||
public Checksum parse(XmlPullParser parser, int initialDepth) throws Exception {
|
public Checksum parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||||
JingleContent.Creator creator = null;
|
JingleContentElement.Creator creator = null;
|
||||||
String creatorString = parser.getAttributeValue(null, Checksum.ATTR_CREATOR);
|
String creatorString = parser.getAttributeValue(null, Checksum.ATTR_CREATOR);
|
||||||
if (creatorString != null) {
|
if (creatorString != null) {
|
||||||
creator = JingleContent.Creator.valueOf(creatorString);
|
creator = JingleContentElement.Creator.valueOf(creatorString);
|
||||||
}
|
}
|
||||||
String name = parser.getAttributeValue(null, Checksum.ATTR_NAME);
|
String name = parser.getAttributeValue(null, Checksum.ATTR_NAME);
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ import java.util.ArrayList;
|
||||||
import org.jivesoftware.smack.util.ParserUtils;
|
import org.jivesoftware.smack.util.ParserUtils;
|
||||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionChildElement;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider;
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentDescriptionProvider;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
import org.jivesoftware.smack.test.util.TestUtils;
|
import org.jivesoftware.smack.test.util.TestUtils;
|
||||||
import org.jivesoftware.smackx.hashes.HashManager;
|
import org.jivesoftware.smackx.hashes.HashManager;
|
||||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Checksum;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.Checksum;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
||||||
|
@ -39,7 +39,7 @@ public class ChecksumTest extends SmackTestSuite {
|
||||||
public void parserTest() throws Exception {
|
public void parserTest() throws Exception {
|
||||||
HashElement hash = new HashElement(HashManager.ALGORITHM.SHA_256, "f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=");
|
HashElement hash = new HashElement(HashManager.ALGORITHM.SHA_256, "f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=");
|
||||||
JingleFileTransferChild file = new JingleFileTransferChild(null, null, hash, null, null, -1, null);
|
JingleFileTransferChild file = new JingleFileTransferChild(null, null, hash, null, null, -1, null);
|
||||||
Checksum checksum = new Checksum(JingleContent.Creator.initiator, "name", file);
|
Checksum checksum = new Checksum(JingleContentElement.Creator.initiator, "name", file);
|
||||||
|
|
||||||
String xml = "<checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5' creator='initiator' name='name'>" +
|
String xml = "<checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5' creator='initiator' name='name'>" +
|
||||||
"<file>" +
|
"<file>" +
|
||||||
|
@ -52,7 +52,7 @@ public class ChecksumTest extends SmackTestSuite {
|
||||||
|
|
||||||
Range range = new Range(12L,34L);
|
Range range = new Range(12L,34L);
|
||||||
file = new JingleFileTransferChild(null, null, hash, null, null, -1, range);
|
file = new JingleFileTransferChild(null, null, hash, null, null, -1, range);
|
||||||
checksum = new Checksum(JingleContent.Creator.initiator, "name", file);
|
checksum = new Checksum(JingleContentElement.Creator.initiator, "name", file);
|
||||||
|
|
||||||
xml = "<checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5' creator='initiator' name='name'>" +
|
xml = "<checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5' creator='initiator' name='name'>" +
|
||||||
"<file>" +
|
"<file>" +
|
||||||
|
|
|
@ -32,10 +32,10 @@ import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleUtil;
|
import org.jivesoftware.smackx.jingle.JingleUtil;
|
||||||
import org.jivesoftware.smackx.jingle.JingleUtilTest;
|
import org.jivesoftware.smackx.jingle.JingleUtilTest;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionChildElement;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
||||||
|
@ -80,9 +80,9 @@ public class JingleUtilFileTransferTest extends SmackTestSuite {
|
||||||
|
|
||||||
String contentName = "content";
|
String contentName = "content";
|
||||||
|
|
||||||
Jingle initiate = jutil.createSessionInitiate(juliet, "letsstart", JingleContent.Creator.initiator, contentName, JingleContent.Senders.initiator, description, transport);
|
JingleElement initiate = jutil.createSessionInitiate(juliet, "letsstart", JingleContentElement.Creator.initiator, contentName, JingleContentElement.Senders.initiator, description, transport);
|
||||||
Jingle accept = jutil.createSessionAccept(juliet, "acceptID", JingleContent.Creator.initiator, contentName, JingleContent.Senders.initiator, description, transport);
|
JingleElement accept = jutil.createSessionAccept(juliet, "acceptID", JingleContentElement.Creator.initiator, contentName, JingleContentElement.Senders.initiator, description, transport);
|
||||||
Jingle fileOffer = jutil.createSessionInitiateFileOffer(juliet, "fileOffer", JingleContent.Creator.initiator, contentName, description, transport);
|
JingleElement fileOffer = jutil.createSessionInitiateFileOffer(juliet, "fileOffer", JingleContentElement.Creator.initiator, contentName, description, transport);
|
||||||
|
|
||||||
assertEquals(JingleAction.session_initiate, initiate.getAction());
|
assertEquals(JingleAction.session_initiate, initiate.getAction());
|
||||||
assertEquals(JingleAction.session_accept, accept.getAction());
|
assertEquals(JingleAction.session_accept, accept.getAction());
|
||||||
|
@ -99,13 +99,13 @@ public class JingleUtilFileTransferTest extends SmackTestSuite {
|
||||||
assertEquals(1, initiate.getContents().size());
|
assertEquals(1, initiate.getContents().size());
|
||||||
assertEquals(1, accept.getContents().size());
|
assertEquals(1, accept.getContents().size());
|
||||||
|
|
||||||
JingleContent content = initiate.getContents().get(0);
|
JingleContentElement content = initiate.getContents().get(0);
|
||||||
assertEquals(content.toXML().toString(), initiate.getContents().get(0).toXML().toString());
|
assertEquals(content.toXML().toString(), initiate.getContents().get(0).toXML().toString());
|
||||||
assertEquals(content.toXML().toString(), accept.getContents().get(0).toXML().toString());
|
assertEquals(content.toXML().toString(), accept.getContents().get(0).toXML().toString());
|
||||||
|
|
||||||
assertEquals("content", content.getName());
|
assertEquals("content", content.getName());
|
||||||
assertEquals(JingleContent.Creator.initiator, content.getCreator());
|
assertEquals(JingleContentElement.Creator.initiator, content.getCreator());
|
||||||
assertEquals(JingleContent.Senders.initiator, content.getSenders());
|
assertEquals(JingleContentElement.Senders.initiator, content.getSenders());
|
||||||
|
|
||||||
assertEquals(1, description.getJingleContentDescriptionChildren().size());
|
assertEquals(1, description.getJingleContentDescriptionChildren().size());
|
||||||
assertEquals(file, description.getJingleContentDescriptionChildren().get(0));
|
assertEquals(file, description.getJingleContentDescriptionChildren().get(0));
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
|
||||||
public interface JingleHandler {
|
public interface JingleHandler {
|
||||||
|
|
||||||
IQ handleJingleRequest(Jingle jingle);
|
IQ handleJingleRequest(JingleElement jingle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,12 @@ import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
import org.jivesoftware.smack.packet.IQ.Type;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionElement;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.JingleIBBTransportManager;
|
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.JingleIBBTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.JingleS5BTransportManager;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.JingleS5BTransportManager;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
||||||
|
@ -73,10 +73,10 @@ public final class JingleManager extends Manager {
|
||||||
jutil = new JingleUtil(connection);
|
jutil = new JingleUtil(connection);
|
||||||
|
|
||||||
connection.registerIQRequestHandler(
|
connection.registerIQRequestHandler(
|
||||||
new AbstractIqRequestHandler(Jingle.ELEMENT, Jingle.NAMESPACE, Type.set, Mode.async) {
|
new AbstractIqRequestHandler(JingleElement.ELEMENT, JingleElement.NAMESPACE, Type.set, Mode.async) {
|
||||||
@Override
|
@Override
|
||||||
public IQ handleIQRequest(IQ iqRequest) {
|
public IQ handleIQRequest(IQ iqRequest) {
|
||||||
final Jingle jingle = (Jingle) iqRequest;
|
final JingleElement jingle = (JingleElement) iqRequest;
|
||||||
|
|
||||||
FullJid fullFrom = jingle.getFrom().asFullJidOrThrow();
|
FullJid fullFrom = jingle.getFrom().asFullJidOrThrow();
|
||||||
String sid = jingle.getSid();
|
String sid = jingle.getSid();
|
||||||
|
@ -90,8 +90,8 @@ public final class JingleManager extends Manager {
|
||||||
|
|
||||||
if (jingle.getAction() == JingleAction.session_initiate) {
|
if (jingle.getAction() == JingleAction.session_initiate) {
|
||||||
|
|
||||||
JingleContent content = jingle.getContents().get(0);
|
JingleContentElement content = jingle.getContents().get(0);
|
||||||
JingleContentDescription description = content.getDescription();
|
JingleContentDescriptionElement description = content.getDescription();
|
||||||
JingleHandler jingleDescriptionHandler = descriptionHandlers.get(
|
JingleHandler jingleDescriptionHandler = descriptionHandlers.get(
|
||||||
description.getNamespace());
|
description.getNamespace());
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
@ -45,7 +45,7 @@ public abstract class JingleSession implements JingleSessionHandler {
|
||||||
|
|
||||||
protected final String sid;
|
protected final String sid;
|
||||||
|
|
||||||
protected final List<JingleContent> contents = new ArrayList<>();
|
protected final List<JingleContentElement> contents = new ArrayList<>();
|
||||||
|
|
||||||
protected ArrayList<Future<?>> queued = new ArrayList<>();
|
protected ArrayList<Future<?>> queued = new ArrayList<>();
|
||||||
protected JingleTransportSession<?> transportSession;
|
protected JingleTransportSession<?> transportSession;
|
||||||
|
@ -54,7 +54,7 @@ public abstract class JingleSession implements JingleSessionHandler {
|
||||||
this(initiator, responder, role, sid, null);
|
this(initiator, responder, role, sid, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleSession(FullJid initiator, FullJid responder, Role role, String sid, List<JingleContent> contents) {
|
public JingleSession(FullJid initiator, FullJid responder, Role role, String sid, List<JingleContentElement> contents) {
|
||||||
if (role == Role.initiator) {
|
if (role == Role.initiator) {
|
||||||
this.local = initiator;
|
this.local = initiator;
|
||||||
this.remote = responder;
|
this.remote = responder;
|
||||||
|
@ -102,7 +102,7 @@ public abstract class JingleSession implements JingleSessionHandler {
|
||||||
return new FullJidAndSessionId(remote, sid);
|
return new FullJidAndSessionId(remote, sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JingleContent> getContents() {
|
public List<JingleContentElement> getContents() {
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ public abstract class JingleSession implements JingleSessionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleJingleSessionRequest(Jingle jingle) {
|
public IQ handleJingleSessionRequest(JingleElement jingle) {
|
||||||
try {
|
try {
|
||||||
switch (jingle.getAction()) {
|
switch (jingle.getAction()) {
|
||||||
case content_accept:
|
case content_accept:
|
||||||
|
@ -177,61 +177,61 @@ public abstract class JingleSession implements JingleSessionHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleSessionInitiate(Jingle sessionInitiate) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
|
protected IQ handleSessionInitiate(JingleElement sessionInitiate) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||||
return IQ.createResultIQ(sessionInitiate);
|
return IQ.createResultIQ(sessionInitiate);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleSessionTerminate(Jingle sessionTerminate) {
|
protected IQ handleSessionTerminate(JingleElement sessionTerminate) {
|
||||||
return IQ.createResultIQ(sessionTerminate);
|
return IQ.createResultIQ(sessionTerminate);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleSessionInfo(Jingle sessionInfo) {
|
protected IQ handleSessionInfo(JingleElement sessionInfo) {
|
||||||
return IQ.createResultIQ(sessionInfo);
|
return IQ.createResultIQ(sessionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleSessionAccept(Jingle sessionAccept) throws SmackException.NotConnectedException, InterruptedException {
|
protected IQ handleSessionAccept(JingleElement sessionAccept) throws SmackException.NotConnectedException, InterruptedException {
|
||||||
return IQ.createResultIQ(sessionAccept);
|
return IQ.createResultIQ(sessionAccept);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleContentAdd(Jingle contentAdd) {
|
protected IQ handleContentAdd(JingleElement contentAdd) {
|
||||||
return IQ.createResultIQ(contentAdd);
|
return IQ.createResultIQ(contentAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleContentAccept(Jingle contentAccept) {
|
protected IQ handleContentAccept(JingleElement contentAccept) {
|
||||||
return IQ.createResultIQ(contentAccept);
|
return IQ.createResultIQ(contentAccept);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleContentModify(Jingle contentModify) {
|
protected IQ handleContentModify(JingleElement contentModify) {
|
||||||
return IQ.createResultIQ(contentModify);
|
return IQ.createResultIQ(contentModify);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleContentReject(Jingle contentReject) {
|
protected IQ handleContentReject(JingleElement contentReject) {
|
||||||
return IQ.createResultIQ(contentReject);
|
return IQ.createResultIQ(contentReject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleContentRemove(Jingle contentRemove) {
|
protected IQ handleContentRemove(JingleElement contentRemove) {
|
||||||
return IQ.createResultIQ(contentRemove);
|
return IQ.createResultIQ(contentRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleDescriptionInfo(Jingle descriptionInfo) {
|
protected IQ handleDescriptionInfo(JingleElement descriptionInfo) {
|
||||||
return IQ.createResultIQ(descriptionInfo);
|
return IQ.createResultIQ(descriptionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleSecurityInfo(Jingle securityInfo) {
|
protected IQ handleSecurityInfo(JingleElement securityInfo) {
|
||||||
return IQ.createResultIQ(securityInfo);
|
return IQ.createResultIQ(securityInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleTransportAccept(Jingle transportAccept) throws SmackException.NotConnectedException, InterruptedException {
|
protected IQ handleTransportAccept(JingleElement transportAccept) throws SmackException.NotConnectedException, InterruptedException {
|
||||||
return IQ.createResultIQ(transportAccept);
|
return IQ.createResultIQ(transportAccept);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleTransportReplace(Jingle transportReplace)
|
protected IQ handleTransportReplace(JingleElement transportReplace)
|
||||||
throws InterruptedException, XMPPException.XMPPErrorException,
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
||||||
SmackException.NotConnectedException, SmackException.NoResponseException {
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||||
return IQ.createResultIQ(transportReplace);
|
return IQ.createResultIQ(transportReplace);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IQ handleTransportReject(Jingle transportReject) {
|
protected IQ handleTransportReject(JingleElement transportReject) {
|
||||||
return IQ.createResultIQ(transportReject);
|
return IQ.createResultIQ(transportReject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
|
||||||
public interface JingleSessionHandler {
|
public interface JingleSessionHandler {
|
||||||
|
|
||||||
IQ handleJingleSessionRequest(Jingle jingle);
|
IQ handleJingleSessionRequest(JingleElement jingle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,12 @@ import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager where TransportMethods are registered.
|
* Manager where TransportMethods are registered.
|
||||||
|
@ -73,17 +73,17 @@ public final class JingleTransportMethodManager extends Manager {
|
||||||
return transportManagers.get(namespace);
|
return transportManagers.get(namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JingleTransportManager<?> getTransportManager(XMPPConnection connection, Jingle request) {
|
public static JingleTransportManager<?> getTransportManager(XMPPConnection connection, JingleElement request) {
|
||||||
return getInstanceFor(connection).getTransportManager(request);
|
return getInstanceFor(connection).getTransportManager(request);
|
||||||
}
|
}
|
||||||
public JingleTransportManager<?> getTransportManager(Jingle request) {
|
public JingleTransportManager<?> getTransportManager(JingleElement request) {
|
||||||
|
|
||||||
JingleContent content = request.getContents().get(0);
|
JingleContentElement content = request.getContents().get(0);
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
JingleContentTransport transport = content.getTransport();
|
JingleContentTransportElement transport = content.getTransport();
|
||||||
if (transport == null) {
|
if (transport == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,12 @@ import java.util.List;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.XMPPError;
|
import org.jivesoftware.smack.packet.XMPPError;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle3.element.JingleErrorElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleError;
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
||||||
|
@ -51,26 +50,26 @@ public class JingleUtil {
|
||||||
* @param content content
|
* @param content content
|
||||||
* @return session-initiate stanza.
|
* @return session-initiate stanza.
|
||||||
*/
|
*/
|
||||||
public Jingle createSessionInitiate(FullJid recipient,
|
public JingleElement createSessionInitiate(FullJid recipient,
|
||||||
String sessionId,
|
String sessionId,
|
||||||
JingleContent content) {
|
JingleContentElement content) {
|
||||||
return createSessionInitiate(recipient, sessionId, Collections.singletonList(content));
|
return createSessionInitiate(recipient, sessionId, Collections.singletonList(content));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jingle createSessionInitiate(FullJid recipient,
|
public JingleElement createSessionInitiate(FullJid recipient,
|
||||||
String sessionId,
|
String sessionId,
|
||||||
List<JingleContent> contents) {
|
List<JingleContentElement> contents) {
|
||||||
|
|
||||||
Jingle.Builder builder = Jingle.getBuilder();
|
JingleElement.Builder builder = JingleElement.getBuilder();
|
||||||
builder.setAction(JingleAction.session_initiate)
|
builder.setAction(JingleAction.session_initiate)
|
||||||
.setSessionId(sessionId)
|
.setSessionId(sessionId)
|
||||||
.setInitiator(connection.getUser());
|
.setInitiator(connection.getUser());
|
||||||
|
|
||||||
for (JingleContent content : contents) {
|
for (JingleContentElement content : contents) {
|
||||||
builder.addJingleContent(content);
|
builder.addJingleContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
Jingle jingle = builder.build();
|
JingleElement jingle = builder.build();
|
||||||
jingle.setFrom(connection.getUser());
|
jingle.setFrom(connection.getUser());
|
||||||
jingle.setTo(recipient);
|
jingle.setTo(recipient);
|
||||||
|
|
||||||
|
@ -85,120 +84,31 @@ public class JingleUtil {
|
||||||
* @param content content
|
* @param content content
|
||||||
* @return session-accept stanza.
|
* @return session-accept stanza.
|
||||||
*/
|
*/
|
||||||
public Jingle createSessionAccept(FullJid recipient,
|
public JingleElement createSessionAccept(FullJid recipient,
|
||||||
String sessionId,
|
String sessionId,
|
||||||
JingleContent content) {
|
JingleContentElement content) {
|
||||||
return createSessionAccept(recipient, sessionId, Collections.singletonList(content));
|
return createSessionAccept(recipient, sessionId, Collections.singletonList(content));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jingle createSessionAccept(FullJid recipient,
|
public JingleElement createSessionAccept(FullJid recipient,
|
||||||
String sessionId,
|
String sessionId,
|
||||||
List<JingleContent> contents) {
|
List<JingleContentElement> contents) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setResponder(connection.getUser())
|
jb.setResponder(connection.getUser())
|
||||||
.setAction(JingleAction.session_accept)
|
.setAction(JingleAction.session_accept)
|
||||||
.setSessionId(sessionId);
|
.setSessionId(sessionId);
|
||||||
|
|
||||||
for (JingleContent content : contents) {
|
for (JingleContentElement content : contents) {
|
||||||
jb.addJingleContent(content);
|
jb.addJingleContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
Jingle jingle = jb.build();
|
JingleElement jingle = jb.build();
|
||||||
jingle.setTo(recipient);
|
jingle.setTo(recipient);
|
||||||
jingle.setFrom(connection.getUser());
|
jingle.setFrom(connection.getUser());
|
||||||
|
|
||||||
return jingle;
|
return jingle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a session-terminate stanza.
|
|
||||||
* XEP-0166 §6.7.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @param reason reason of termination.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminate(FullJid recipient, String sessionId, JingleReason reason) {
|
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
|
||||||
jb.setAction(JingleAction.session_terminate)
|
|
||||||
.setSessionId(sessionId)
|
|
||||||
.setReason(reason);
|
|
||||||
|
|
||||||
Jingle jingle = jb.build();
|
|
||||||
jingle.setFrom(connection.getUser());
|
|
||||||
jingle.setTo(recipient);
|
|
||||||
|
|
||||||
return jingle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a session-terminate stanza.
|
|
||||||
* XEP-0166 §6.7.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @param reason reason of termination.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminate(FullJid recipient, String sessionId, JingleReason.Reason reason) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, new JingleReason(reason));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate the session by declining.
|
|
||||||
* XEP-0166 Example 21.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateDecline(FullJid recipient, String sessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.decline);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate the session due to success.
|
|
||||||
* XEP-0166 Example 19.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateSuccess(FullJid recipient, String sessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.success);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate the session due to being busy.
|
|
||||||
* XEP-0166 Example 20.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateBusy(FullJid recipient, String sessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.busy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate the session due to the existence of an alternative session.
|
|
||||||
* XEP-0166 Example 22.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @param altSessionId id of the alternative session.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateAlternativeSession(FullJid recipient, String sessionId, String altSessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.AlternativeSession(altSessionId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancel all active transfers of the session.
|
|
||||||
* XEP-0234 Example 9.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateCancel(FullJid recipient, String sessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.cancel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel a single contents transfer.
|
* Cancel a single contents transfer.
|
||||||
* XEP-0234 Example 10.
|
* XEP-0234 Example 10.
|
||||||
|
@ -208,81 +118,22 @@ public class JingleUtil {
|
||||||
* @param contentName name of the content.
|
* @param contentName name of the content.
|
||||||
* @return session-terminate stanza.
|
* @return session-terminate stanza.
|
||||||
*/
|
*/
|
||||||
public Jingle createSessionTerminateContentCancel(FullJid recipient, String sessionId,
|
public JingleElement createSessionTerminateContentCancel(FullJid recipient, String sessionId,
|
||||||
JingleContent.Creator contentCreator, String contentName) {
|
JingleContentElement.Creator contentCreator, String contentName) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setAction(JingleAction.session_terminate)
|
jb.setAction(JingleAction.session_terminate)
|
||||||
.setSessionId(sessionId).setReason(JingleReason.Reason.cancel);
|
.setSessionId(sessionId).setReason(JingleReasonElement.Reason.cancel);
|
||||||
|
|
||||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
cb.setCreator(contentCreator).setName(contentName);
|
cb.setCreator(contentCreator).setName(contentName);
|
||||||
|
|
||||||
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
JingleElement jingle = jb.addJingleContent(cb.build()).build();
|
||||||
jingle.setFrom(connection.getUser());
|
jingle.setFrom(connection.getUser());
|
||||||
jingle.setTo(recipient);
|
jingle.setTo(recipient);
|
||||||
|
|
||||||
return jingle;
|
return jingle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate the session due to unsupported transport methods.
|
|
||||||
* XEP-0166 Example 23.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateUnsupportedTransports(FullJid recipient, String sessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.unsupported_transports);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate the session due to failed transports.
|
|
||||||
* XEP-0166 Example 24.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateFailedTransport(FullJid recipient, String sessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.failed_transport);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate the session due to unsupported applications.
|
|
||||||
* XEP-0166 Example 25.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateUnsupportedApplications(FullJid recipient, String sessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.unsupported_applications);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate the session due to failed application.
|
|
||||||
* XEP-0166 Example 26.
|
|
||||||
* @param recipient recipient of the stanza.
|
|
||||||
* @param sessionId sessionId.
|
|
||||||
* @return session-terminate stanza.
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateFailedApplication(FullJid recipient, String sessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.failed_application);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate session due to incompatible parameters.
|
|
||||||
* XEP-0166 Example 27.
|
|
||||||
* @param recipient recipient of the stanza
|
|
||||||
* @param sessionId sessionId
|
|
||||||
* @return session-terminate stanza
|
|
||||||
*/
|
|
||||||
public Jingle createSessionTerminateIncompatibleParameters(FullJid recipient, String sessionId) {
|
|
||||||
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.incompatible_parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQ sendContentRejectFileNotAvailable(FullJid recipient, String sessionId, JingleContentDescription description) {
|
|
||||||
return null; //TODO Later
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a session ping stanza.
|
* Create a session ping stanza.
|
||||||
* XEP-0166 Example 32.
|
* XEP-0166 Example 32.
|
||||||
|
@ -290,12 +141,12 @@ public class JingleUtil {
|
||||||
* @param sessionId id of the session
|
* @param sessionId id of the session
|
||||||
* @return ping stanza
|
* @return ping stanza
|
||||||
*/
|
*/
|
||||||
public Jingle createSessionPing(FullJid recipient, String sessionId) {
|
public JingleElement createSessionPing(FullJid recipient, String sessionId) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setSessionId(sessionId)
|
jb.setSessionId(sessionId)
|
||||||
.setAction(JingleAction.session_info);
|
.setAction(JingleAction.session_info);
|
||||||
|
|
||||||
Jingle jingle = jb.build();
|
JingleElement jingle = jb.build();
|
||||||
jingle.setFrom(connection.getUser());
|
jingle.setFrom(connection.getUser());
|
||||||
jingle.setTo(recipient);
|
jingle.setTo(recipient);
|
||||||
|
|
||||||
|
@ -308,7 +159,7 @@ public class JingleUtil {
|
||||||
* @param jingle stanza that was received
|
* @param jingle stanza that was received
|
||||||
* @return acknowledgement
|
* @return acknowledgement
|
||||||
*/
|
*/
|
||||||
public IQ createAck(Jingle jingle) {
|
public IQ createAck(JingleElement jingle) {
|
||||||
return IQ.createResultIQ(jingle);
|
return IQ.createResultIQ(jingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,17 +174,17 @@ public class JingleUtil {
|
||||||
* @param transport proposed transport
|
* @param transport proposed transport
|
||||||
* @return transport-replace stanza
|
* @return transport-replace stanza
|
||||||
*/
|
*/
|
||||||
public Jingle createTransportReplace(FullJid recipient, FullJid initiator, String sessionId,
|
public JingleElement createTransportReplace(FullJid recipient, FullJid initiator, String sessionId,
|
||||||
JingleContent.Creator contentCreator, String contentName,
|
JingleContentElement.Creator contentCreator, String contentName,
|
||||||
JingleContentTransport transport) {
|
JingleContentTransportElement transport) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setInitiator(initiator)
|
jb.setInitiator(initiator)
|
||||||
.setSessionId(sessionId)
|
.setSessionId(sessionId)
|
||||||
.setAction(JingleAction.transport_replace);
|
.setAction(JingleAction.transport_replace);
|
||||||
|
|
||||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
cb.setName(contentName).setCreator(contentCreator).setTransport(transport);
|
cb.setName(contentName).setCreator(contentCreator).setTransport(transport);
|
||||||
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
JingleElement jingle = jb.addJingleContent(cb.build()).build();
|
||||||
|
|
||||||
jingle.setTo(recipient);
|
jingle.setTo(recipient);
|
||||||
jingle.setFrom(connection.getUser());
|
jingle.setFrom(connection.getUser());
|
||||||
|
@ -352,18 +203,18 @@ public class JingleUtil {
|
||||||
* @param transport transport to accept
|
* @param transport transport to accept
|
||||||
* @return transport-accept stanza
|
* @return transport-accept stanza
|
||||||
*/
|
*/
|
||||||
public Jingle createTransportAccept(FullJid recipient, FullJid initiator, String sessionId,
|
public JingleElement createTransportAccept(FullJid recipient, FullJid initiator, String sessionId,
|
||||||
JingleContent.Creator contentCreator, String contentName,
|
JingleContentElement.Creator contentCreator, String contentName,
|
||||||
JingleContentTransport transport) {
|
JingleContentTransportElement transport) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setAction(JingleAction.transport_accept)
|
jb.setAction(JingleAction.transport_accept)
|
||||||
.setInitiator(initiator)
|
.setInitiator(initiator)
|
||||||
.setSessionId(sessionId);
|
.setSessionId(sessionId);
|
||||||
|
|
||||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
|
cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
|
||||||
|
|
||||||
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
JingleElement jingle = jb.addJingleContent(cb.build()).build();
|
||||||
jingle.setTo(recipient);
|
jingle.setTo(recipient);
|
||||||
jingle.setFrom(connection.getUser());
|
jingle.setFrom(connection.getUser());
|
||||||
|
|
||||||
|
@ -381,18 +232,18 @@ public class JingleUtil {
|
||||||
* @param transport transport to reject
|
* @param transport transport to reject
|
||||||
* @return transport-reject stanza
|
* @return transport-reject stanza
|
||||||
*/
|
*/
|
||||||
public Jingle createTransportReject(FullJid recipient, FullJid initiator, String sessionId,
|
public JingleElement createTransportReject(FullJid recipient, FullJid initiator, String sessionId,
|
||||||
JingleContent.Creator contentCreator, String contentName,
|
JingleContentElement.Creator contentCreator, String contentName,
|
||||||
JingleContentTransport transport) {
|
JingleContentTransportElement transport) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setAction(JingleAction.transport_reject)
|
jb.setAction(JingleAction.transport_reject)
|
||||||
.setInitiator(initiator)
|
.setInitiator(initiator)
|
||||||
.setSessionId(sessionId);
|
.setSessionId(sessionId);
|
||||||
|
|
||||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
|
cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
|
||||||
|
|
||||||
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
JingleElement jingle = jb.addJingleContent(cb.build()).build();
|
||||||
jingle.setTo(recipient);
|
jingle.setTo(recipient);
|
||||||
jingle.setFrom(connection.getUser());
|
jingle.setFrom(connection.getUser());
|
||||||
|
|
||||||
|
@ -409,10 +260,10 @@ public class JingleUtil {
|
||||||
* @param request request with unknown sessionId.
|
* @param request request with unknown sessionId.
|
||||||
* @return error stanza.
|
* @return error stanza.
|
||||||
*/
|
*/
|
||||||
public IQ createErrorUnknownSession(Jingle request) {
|
public IQ createErrorUnknownSession(JingleElement request) {
|
||||||
XMPPError.Builder error = XMPPError.getBuilder();
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
error.setCondition(XMPPError.Condition.item_not_found)
|
error.setCondition(XMPPError.Condition.item_not_found)
|
||||||
.addExtension(JingleError.UNKNOWN_SESSION);
|
.addExtension(JingleErrorElement.UNKNOWN_SESSION);
|
||||||
return IQ.createErrorResponse(request, error);
|
return IQ.createErrorResponse(request, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +273,7 @@ public class JingleUtil {
|
||||||
* @param request request from unknown initiator.
|
* @param request request from unknown initiator.
|
||||||
* @return error stanza.
|
* @return error stanza.
|
||||||
*/
|
*/
|
||||||
public IQ createErrorUnknownInitiator(Jingle request) {
|
public IQ createErrorUnknownInitiator(JingleElement request) {
|
||||||
XMPPError.Builder b = XMPPError.getBuilder().setType(XMPPError.Type.CANCEL).setCondition(XMPPError.Condition.service_unavailable);
|
XMPPError.Builder b = XMPPError.getBuilder().setType(XMPPError.Type.CANCEL).setCondition(XMPPError.Condition.service_unavailable);
|
||||||
return IQ.createErrorResponse(request, b);
|
return IQ.createErrorResponse(request, b);
|
||||||
}
|
}
|
||||||
|
@ -433,10 +284,10 @@ public class JingleUtil {
|
||||||
* @param request request with unsupported info.
|
* @param request request with unsupported info.
|
||||||
* @return error stanza.
|
* @return error stanza.
|
||||||
*/
|
*/
|
||||||
public IQ createErrorUnsupportedInfo(Jingle request) {
|
public IQ createErrorUnsupportedInfo(JingleElement request) {
|
||||||
XMPPError.Builder error = XMPPError.getBuilder();
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
error.setCondition(XMPPError.Condition.feature_not_implemented)
|
error.setCondition(XMPPError.Condition.feature_not_implemented)
|
||||||
.addExtension(JingleError.UNSUPPORTED_INFO).setType(XMPPError.Type.MODIFY);
|
.addExtension(JingleErrorElement.UNSUPPORTED_INFO).setType(XMPPError.Type.MODIFY);
|
||||||
return IQ.createErrorResponse(request, error);
|
return IQ.createErrorResponse(request, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,10 +297,10 @@ public class JingleUtil {
|
||||||
* @param request tie-breaking request
|
* @param request tie-breaking request
|
||||||
* @return error stanza
|
* @return error stanza
|
||||||
*/
|
*/
|
||||||
public IQ createErrorTieBreak(Jingle request) {
|
public IQ createErrorTieBreak(JingleElement request) {
|
||||||
XMPPError.Builder error = XMPPError.getBuilder();
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
error.setCondition(XMPPError.Condition.conflict)
|
error.setCondition(XMPPError.Condition.conflict)
|
||||||
.addExtension(JingleError.TIE_BREAK);
|
.addExtension(JingleErrorElement.TIE_BREAK);
|
||||||
return IQ.createErrorResponse(request, error);
|
return IQ.createErrorResponse(request, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,10 +310,10 @@ public class JingleUtil {
|
||||||
* @param request request out of order.
|
* @param request request out of order.
|
||||||
* @return error stanza.
|
* @return error stanza.
|
||||||
*/
|
*/
|
||||||
public IQ createErrorOutOfOrder(Jingle request) {
|
public IQ createErrorOutOfOrder(JingleElement request) {
|
||||||
XMPPError.Builder error = XMPPError.getBuilder();
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
error.setCondition(XMPPError.Condition.unexpected_request)
|
error.setCondition(XMPPError.Condition.unexpected_request)
|
||||||
.addExtension(JingleError.OUT_OF_ORDER);
|
.addExtension(JingleErrorElement.OUT_OF_ORDER);
|
||||||
return IQ.createErrorResponse(request, error);
|
return IQ.createErrorResponse(request, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +323,7 @@ public class JingleUtil {
|
||||||
* @param request malformed request
|
* @param request malformed request
|
||||||
* @return error stanza.
|
* @return error stanza.
|
||||||
*/
|
*/
|
||||||
public IQ createErrorMalformedRequest(Jingle request) {
|
public IQ createErrorMalformedRequest(JingleElement request) {
|
||||||
XMPPError.Builder error = XMPPError.getBuilder();
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
error.setType(XMPPError.Type.CANCEL);
|
error.setType(XMPPError.Type.CANCEL);
|
||||||
error.setCondition(XMPPError.Condition.bad_request);
|
error.setCondition(XMPPError.Condition.bad_request);
|
||||||
|
|
|
@ -1,215 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2003-2007 Jive Software, 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.
|
|
||||||
* 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 java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
|
||||||
import org.jivesoftware.smack.util.Objects;
|
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Jingle element.
|
|
||||||
*
|
|
||||||
* @author Florian Schmaus
|
|
||||||
*/
|
|
||||||
public final class Jingle extends IQ {
|
|
||||||
|
|
||||||
public static final String NAMESPACE = "urn:xmpp:jingle:1";
|
|
||||||
|
|
||||||
public static final String ACTION_ATTRIBUTE_NAME = "action";
|
|
||||||
|
|
||||||
public static final String INITIATOR_ATTRIBUTE_NAME = "initiator";
|
|
||||||
|
|
||||||
public static final String RESPONDER_ATTRIBUTE_NAME = "responder";
|
|
||||||
|
|
||||||
public static final String SESSION_ID_ATTRIBUTE_NAME = "sid";
|
|
||||||
|
|
||||||
public static final String ELEMENT = "jingle";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The session ID related to this session. The session ID is a unique identifier generated by the initiator. This
|
|
||||||
* should match the XML Nmtoken production so that XML character escaping is not needed for characters such as &.
|
|
||||||
*/
|
|
||||||
private final String sessionId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The jingle action. This attribute is required.
|
|
||||||
*/
|
|
||||||
private final JingleAction action;
|
|
||||||
|
|
||||||
private final FullJid initiator;
|
|
||||||
|
|
||||||
private final FullJid responder;
|
|
||||||
|
|
||||||
private final JingleReason reason;
|
|
||||||
|
|
||||||
private final List<JingleContent> contents;
|
|
||||||
|
|
||||||
private Jingle(String sessionId, JingleAction action, FullJid initiator, FullJid responder, JingleReason reason,
|
|
||||||
List<JingleContent> contents) {
|
|
||||||
super(ELEMENT, NAMESPACE);
|
|
||||||
this.sessionId = StringUtils.requireNotNullOrEmpty(sessionId, "Jingle session ID must not be null");
|
|
||||||
this.action = Objects.requireNonNull(action, "Jingle action must not be null");
|
|
||||||
this.initiator = initiator;
|
|
||||||
this.responder = responder;
|
|
||||||
this.reason = reason;
|
|
||||||
if (contents != null) {
|
|
||||||
this.contents = Collections.unmodifiableList(contents);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.contents = Collections.emptyList();
|
|
||||||
}
|
|
||||||
setType(Type.set);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the initiator. The initiator will be the full JID of the entity that has initiated the flow (which may be
|
|
||||||
* different to the "from" address in the IQ)
|
|
||||||
*
|
|
||||||
* @return the initiator
|
|
||||||
*/
|
|
||||||
public FullJid getInitiator() {
|
|
||||||
return initiator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the responder. The responder is the full JID of the entity that has replied to the initiation (which may be
|
|
||||||
* different to the "to" addresss in the IQ).
|
|
||||||
*
|
|
||||||
* @return the responder
|
|
||||||
*/
|
|
||||||
public FullJid getResponder() {
|
|
||||||
return responder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the session ID related to the session. The session ID is a unique identifier generated by the initiator.
|
|
||||||
* This should match the XML Nmtoken production so that XML character escaping is not needed for characters such as
|
|
||||||
* &.
|
|
||||||
*
|
|
||||||
* @return Returns the session ID related to the session.
|
|
||||||
*/
|
|
||||||
public String getSid() {
|
|
||||||
return sessionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the action specified in the jingle IQ.
|
|
||||||
*
|
|
||||||
* @return the action.
|
|
||||||
*/
|
|
||||||
public JingleAction getAction() {
|
|
||||||
return action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JingleReason getReason() {
|
|
||||||
return reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a List of the contents.
|
|
||||||
*
|
|
||||||
* @return the contents.
|
|
||||||
*/
|
|
||||||
public List<JingleContent> getContents() {
|
|
||||||
return contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
|
||||||
xml.optAttribute(INITIATOR_ATTRIBUTE_NAME, getInitiator());
|
|
||||||
xml.optAttribute(RESPONDER_ATTRIBUTE_NAME, getResponder());
|
|
||||||
xml.optAttribute(ACTION_ATTRIBUTE_NAME, getAction());
|
|
||||||
xml.optAttribute(SESSION_ID_ATTRIBUTE_NAME, getSid());
|
|
||||||
xml.rightAngleBracket();
|
|
||||||
|
|
||||||
xml.optElement(reason);
|
|
||||||
|
|
||||||
xml.append(contents);
|
|
||||||
|
|
||||||
return xml;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder getBuilder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class Builder {
|
|
||||||
private String sid;
|
|
||||||
|
|
||||||
private JingleAction action;
|
|
||||||
|
|
||||||
private FullJid initiator;
|
|
||||||
|
|
||||||
private FullJid responder;
|
|
||||||
|
|
||||||
private JingleReason reason;
|
|
||||||
|
|
||||||
private List<JingleContent> contents;
|
|
||||||
|
|
||||||
private Builder() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setSessionId(String sessionId) {
|
|
||||||
this.sid = sessionId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setAction(JingleAction action) {
|
|
||||||
this.action = action;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setInitiator(FullJid initator) {
|
|
||||||
this.initiator = initator;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setResponder(FullJid responder) {
|
|
||||||
this.responder = responder;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder addJingleContent(JingleContent content) {
|
|
||||||
if (contents == null) {
|
|
||||||
contents = new ArrayList<>(1);
|
|
||||||
}
|
|
||||||
contents.add(content);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setReason(JingleReason.Reason reason) {
|
|
||||||
this.reason = new JingleReason(reason);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setReason(JingleReason reason) {
|
|
||||||
this.reason = reason;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Jingle build() {
|
|
||||||
return new Jingle(sid, action, initiator, responder, reason, contents);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 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.transports;
|
|
||||||
|
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback for bytestream session creation of TransportManagers.
|
|
||||||
*/
|
|
||||||
public interface JingleTransportInitiationCallback {
|
|
||||||
|
|
||||||
void onSessionInitiated(BytestreamSession bytestreamSession);
|
|
||||||
|
|
||||||
void onException(Exception e);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 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.transports;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by vanitas on 25.06.17.
|
|
||||||
*/
|
|
||||||
public abstract class JingleTransportInitiationException extends Exception {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
|
|
||||||
public static class ProxyError extends JingleTransportInitiationException {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CandidateError extends JingleTransportInitiationException {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 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.transports;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
|
||||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manager for a JingleTransport method.
|
|
||||||
* @param <D> JingleContentTransport.
|
|
||||||
*/
|
|
||||||
public abstract class JingleTransportManager<D extends JingleContentTransport> implements ConnectionListener {
|
|
||||||
|
|
||||||
private final XMPPConnection connection;
|
|
||||||
|
|
||||||
public JingleTransportManager(XMPPConnection connection) {
|
|
||||||
this.connection = connection;
|
|
||||||
connection.addConnectionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public XMPPConnection getConnection() {
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String getNamespace();
|
|
||||||
|
|
||||||
public abstract JingleTransportSession<D> transportSession(JingleSession jingleSession);
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void connected(XMPPConnection connection) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void connectionClosed() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void connectionClosedOnError(Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnectionSuccessful() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnectingIn(int seconds) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnectionFailed(Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 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.transports;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
|
||||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by vanitas on 20.06.17.
|
|
||||||
*/
|
|
||||||
public abstract class JingleTransportSession<T extends JingleContentTransport> {
|
|
||||||
protected final JingleSession jingleSession;
|
|
||||||
protected T ourProposal, theirProposal;
|
|
||||||
|
|
||||||
public JingleTransportSession(JingleSession session) {
|
|
||||||
this.jingleSession = session;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract T createTransport();
|
|
||||||
|
|
||||||
public void processJingle(Jingle jingle) {
|
|
||||||
if (jingle.getContents().size() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
JingleContent content = jingle.getContents().get(0);
|
|
||||||
JingleContentTransport t = content.getTransport();
|
|
||||||
|
|
||||||
if (t != null && t.getNamespace().equals(getNamespace())) {
|
|
||||||
setTheirProposal(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void setTheirProposal(JingleContentTransport transport);
|
|
||||||
|
|
||||||
public abstract void initiateOutgoingSession(JingleTransportInitiationCallback callback);
|
|
||||||
|
|
||||||
public abstract void initiateIncomingSession(JingleTransportInitiationCallback callback);
|
|
||||||
|
|
||||||
public abstract String getNamespace();
|
|
||||||
|
|
||||||
public abstract IQ handleTransportInfo(Jingle transportInfo);
|
|
||||||
|
|
||||||
public abstract JingleTransportManager<T> transportManager();
|
|
||||||
}
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle3.internal.Content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public abstract class Callback {
|
||||||
|
|
||||||
|
private final Content content;
|
||||||
|
|
||||||
|
public Callback(Content content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle3.callbacks.ContentAddCallback;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.internal.Content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 19.07.17.
|
||||||
|
*/
|
||||||
|
public interface JingleDescriptionManager {
|
||||||
|
|
||||||
|
String getNamespace();
|
||||||
|
|
||||||
|
JingleElement notifyContentListeners(Content content, ContentAddCallback callback);
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3;
|
||||||
|
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.Manager;
|
||||||
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
import org.jivesoftware.smackx.jingle3.adapter.JingleDescriptionAdapter;
|
||||||
|
import org.jivesoftware.smackx.jingle3.adapter.JingleSecurityAdapter;
|
||||||
|
import org.jivesoftware.smackx.jingle3.adapter.JingleTransportAdapter;
|
||||||
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentDescriptionProvider;
|
||||||
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentSecurityProvider;
|
||||||
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentTransportProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public final class JingleExtensionManager extends Manager {
|
||||||
|
|
||||||
|
private static final WeakHashMap<XMPPConnection, JingleExtensionManager> INSTANCES = new WeakHashMap<>();
|
||||||
|
|
||||||
|
private static final WeakHashMap<String, JingleContentDescriptionProvider<?>> descriptionProviders = new WeakHashMap<>();
|
||||||
|
private static final WeakHashMap<String, JingleContentTransportProvider<?>> transportProviders = new WeakHashMap<>();
|
||||||
|
private static final WeakHashMap<String, JingleContentSecurityProvider<?>> securityProviders = new WeakHashMap<>();
|
||||||
|
|
||||||
|
private static final WeakHashMap<String, JingleDescriptionAdapter<?>> descriptionAdapters = new WeakHashMap<>();
|
||||||
|
private static final WeakHashMap<String, JingleTransportAdapter<?>> transportAdapters = new WeakHashMap<>();
|
||||||
|
private static final WeakHashMap<String, JingleSecurityAdapter<?>> securityAdapters = new WeakHashMap<>();
|
||||||
|
|
||||||
|
public final WeakHashMap<String, JingleDescriptionManager> descriptionManagers = new WeakHashMap<>();
|
||||||
|
public final WeakHashMap<String, JingleTransportManager> transportManagers = new WeakHashMap<>();
|
||||||
|
public final WeakHashMap<String, JingleSecurityManager> securityManagers = new WeakHashMap<>();
|
||||||
|
|
||||||
|
private JingleExtensionManager(XMPPConnection connection) {
|
||||||
|
super(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleExtensionManager getInstanceFor(XMPPConnection connection) {
|
||||||
|
JingleExtensionManager manager = INSTANCES.get(connection);
|
||||||
|
|
||||||
|
if (manager == null) {
|
||||||
|
manager = new JingleExtensionManager(connection);
|
||||||
|
INSTANCES.put(connection, manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerDescriptionProvider(JingleContentDescriptionProvider<?> provider) {
|
||||||
|
descriptionProviders.put(provider.getNamespace(), provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleContentDescriptionProvider<?> getDescriptionProvider(String namespace) {
|
||||||
|
return descriptionProviders.get(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerTransportProvider(JingleContentTransportProvider<?> provider) {
|
||||||
|
transportProviders.put(provider.getNamespace(), provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleContentTransportProvider<?> getTransportProvider(String namespace) {
|
||||||
|
return transportProviders.get(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerSecurityProvider(JingleContentSecurityProvider<?> provider) {
|
||||||
|
securityProviders.put(provider.getNamespace(), provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleContentSecurityProvider<?> getSecurityProvider(String namespace) {
|
||||||
|
return securityProviders.get(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addJingleDescriptionAdapter(JingleDescriptionAdapter<?> adapter) {
|
||||||
|
descriptionAdapters.put(adapter.getNamespace(), adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addJingleTransportAdapter(JingleTransportAdapter<?> adapter) {
|
||||||
|
transportAdapters.put(adapter.getNamespace(), adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addJingleSecurityAdapter(JingleSecurityAdapter<?> adapter) {
|
||||||
|
securityAdapters.put(adapter.getNamespace(), adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleDescriptionAdapter<?> getJingleDescriptionAdapter(String namespace) {
|
||||||
|
return descriptionAdapters.get(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleTransportAdapter<?> getJingleTransportAdapter(String namespace) {
|
||||||
|
return transportAdapters.get(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleSecurityAdapter<?> getJingleSecurityAdapter(String namespace) {
|
||||||
|
return securityAdapters.get(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addJingleDescriptionManager(JingleDescriptionManager manager) {
|
||||||
|
descriptionManagers.put(manager.getNamespace(), manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleDescriptionManager getDescriptionManager(String namespace) {
|
||||||
|
return descriptionManagers.get(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addJingleTransportManager(JingleTransportManager manager) {
|
||||||
|
transportManagers.put(manager.getNamespace(), manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleTransportManager getTransportManager(String namespace) {
|
||||||
|
return transportManagers.get(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addJingleSecurityManager(JingleSecurityManager manager) {
|
||||||
|
securityManagers.put(manager.getNamespace(), manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleSecurityManager getSecurityManager(String namespace) {
|
||||||
|
return securityManagers.get(namespace);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3;
|
||||||
|
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.Manager;
|
||||||
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||||
|
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
||||||
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smackx.jingle.FullJidAndSessionId;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.exception.UnsupportedDescriptionException;
|
||||||
|
import org.jivesoftware.smackx.jingle3.exception.UnsupportedSecurityException;
|
||||||
|
import org.jivesoftware.smackx.jingle3.exception.UnsupportedTransportException;
|
||||||
|
import org.jivesoftware.smackx.jingle3.internal.Session;
|
||||||
|
|
||||||
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public class JingleManager extends Manager {
|
||||||
|
private static final WeakHashMap<XMPPConnection, JingleManager> INSTANCES = new WeakHashMap<>();
|
||||||
|
|
||||||
|
private final ConcurrentHashMap<FullJidAndSessionId, Session> jingleSessions = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private JingleManager(XMPPConnection connection) {
|
||||||
|
super(connection);
|
||||||
|
|
||||||
|
connection.registerIQRequestHandler(
|
||||||
|
new AbstractIqRequestHandler(JingleElement.ELEMENT, JingleElement.NAMESPACE, IQ.Type.set, IQRequestHandler.Mode.async) {
|
||||||
|
@Override
|
||||||
|
public IQ handleIQRequest(IQ iqRequest) {
|
||||||
|
final JingleElement jingle = (JingleElement) iqRequest;
|
||||||
|
|
||||||
|
FullJid fullFrom = jingle.getFrom().asFullJidOrThrow();
|
||||||
|
String sid = jingle.getSid();
|
||||||
|
FullJidAndSessionId fullJidAndSessionId = new FullJidAndSessionId(fullFrom, sid);
|
||||||
|
|
||||||
|
Session session = jingleSessions.get(fullJidAndSessionId);
|
||||||
|
|
||||||
|
// We have not seen this session before.
|
||||||
|
// Either it is fresh, or unknown.
|
||||||
|
if (session == null) {
|
||||||
|
|
||||||
|
if (jingle.getAction() == JingleAction.session_initiate) {
|
||||||
|
//fresh. phew!
|
||||||
|
try {
|
||||||
|
session = Session.fromSessionInitiate(JingleManager.this, jingle);
|
||||||
|
} catch (UnsupportedDescriptionException e) {
|
||||||
|
return JingleElement.createSessionTerminate(jingle.getFrom().asFullJidOrThrow(),
|
||||||
|
jingle.getSid(), JingleReasonElement.Reason.unsupported_applications);
|
||||||
|
} catch (UnsupportedTransportException e) {
|
||||||
|
return JingleElement.createSessionTerminate(jingle.getFrom().asFullJidOrThrow(),
|
||||||
|
jingle.getSid(), JingleReasonElement.Reason.unsupported_transports);
|
||||||
|
} catch (UnsupportedSecurityException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Unknown session. Error!
|
||||||
|
return JingleElement.createJingleErrorUnknownSession(jingle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return session.handleJingleRequest(jingle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleManager getInstanceFor(XMPPConnection connection) {
|
||||||
|
JingleManager manager = INSTANCES.get(connection);
|
||||||
|
|
||||||
|
if (manager == null) {
|
||||||
|
manager = new JingleManager(connection);
|
||||||
|
INSTANCES.put(connection, manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public XMPPConnection getConnection() {
|
||||||
|
return connection();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 19.07.17.
|
||||||
|
*/
|
||||||
|
public interface JingleSecurityManager {
|
||||||
|
|
||||||
|
String getNamespace();
|
||||||
|
}
|
|
@ -1,13 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 19.07.17.
|
||||||
|
*/
|
||||||
|
public interface JingleTransportManager {
|
||||||
|
|
||||||
|
String getNamespace();
|
||||||
|
}
|
|
@ -14,8 +14,10 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
package org.jivesoftware.smackx.jingle3;
|
||||||
|
|
||||||
/**
|
public enum Role {
|
||||||
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
|
initiator,
|
||||||
*/
|
responder,
|
||||||
package org.jivesoftware.smackx.jingle.transports;
|
;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.adapter;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.internal.Description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public interface JingleDescriptionAdapter<D extends Description<?>> {
|
||||||
|
|
||||||
|
D descriptionFromElement(JingleContentDescriptionElement element);
|
||||||
|
|
||||||
|
String getNamespace();
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.adapter;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentSecurityElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.internal.Security;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public interface JingleSecurityAdapter<S extends Security<?>> {
|
||||||
|
|
||||||
|
S securityFromElement(JingleContentSecurityElement element);
|
||||||
|
|
||||||
|
String getNamespace();
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.adapter;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.internal.Transport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public interface JingleTransportAdapter<T extends Transport<?>> {
|
||||||
|
|
||||||
|
T transportFromElement(JingleContentTransportElement xml);
|
||||||
|
|
||||||
|
String getNamespace();
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.callbacks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 19.07.17.
|
||||||
|
*/
|
||||||
|
public interface ContentAddCallback {
|
||||||
|
|
||||||
|
void acceptContentAdd();
|
||||||
|
|
||||||
|
void rejectContentAdd();
|
||||||
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.NamedElement;
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -33,13 +33,13 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
* </jingle>
|
* </jingle>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentDescription implements ExtensionElement {
|
public abstract class JingleContentDescriptionElement implements ExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "description";
|
public static final String ELEMENT = "description";
|
||||||
|
|
||||||
private final List<JingleContentDescriptionChildElement> payloads;
|
private final List<JingleContentDescriptionChildElement> payloads;
|
||||||
|
|
||||||
protected JingleContentDescription(List<JingleContentDescriptionChildElement> payloads) {
|
protected JingleContentDescriptionElement(List<JingleContentDescriptionChildElement> payloads) {
|
||||||
if (payloads != null) {
|
if (payloads != null) {
|
||||||
this.payloads = Collections.unmodifiableList(payloads);
|
this.payloads = Collections.unmodifiableList(payloads);
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.NamedElement;
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
import org.jivesoftware.smack.util.Objects;
|
import org.jivesoftware.smack.util.Objects;
|
||||||
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
*/
|
*/
|
||||||
public final class JingleContent implements NamedElement {
|
public final class JingleContentElement implements NamedElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "content";
|
public static final String ELEMENT = "content";
|
||||||
|
|
||||||
|
@ -69,17 +69,17 @@ public final class JingleContent implements NamedElement {
|
||||||
*/
|
*/
|
||||||
private final Senders senders;
|
private final Senders senders;
|
||||||
|
|
||||||
private final JingleContentDescription description;
|
private final JingleContentDescriptionElement description;
|
||||||
|
|
||||||
private final JingleContentTransport transport;
|
private final JingleContentTransportElement transport;
|
||||||
|
|
||||||
private final JingleContentSecurity security;
|
private final JingleContentSecurityElement security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a content description..
|
* Creates a content description..
|
||||||
*/
|
*/
|
||||||
private JingleContent(Creator creator, String disposition, String name, Senders senders,
|
private JingleContentElement(Creator creator, String disposition, String name, Senders senders,
|
||||||
JingleContentDescription description, JingleContentTransport transport, JingleContentSecurity security) {
|
JingleContentDescriptionElement description, JingleContentTransportElement transport, JingleContentSecurityElement security) {
|
||||||
this.creator = Objects.requireNonNull(creator, "Jingle content creator must not be null");
|
this.creator = Objects.requireNonNull(creator, "Jingle content creator must not be null");
|
||||||
this.disposition = disposition;
|
this.disposition = disposition;
|
||||||
this.name = StringUtils.requireNotNullOrEmpty(name, "Jingle content name must not be null or empty");
|
this.name = StringUtils.requireNotNullOrEmpty(name, "Jingle content name must not be null or empty");
|
||||||
|
@ -110,7 +110,7 @@ public final class JingleContent implements NamedElement {
|
||||||
*
|
*
|
||||||
* @return The description.
|
* @return The description.
|
||||||
*/
|
*/
|
||||||
public JingleContentDescription getDescription() {
|
public JingleContentDescriptionElement getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,11 +119,11 @@ public final class JingleContent implements NamedElement {
|
||||||
*
|
*
|
||||||
* @return an Iterator for the JingleTransports in the packet.
|
* @return an Iterator for the JingleTransports in the packet.
|
||||||
*/
|
*/
|
||||||
public JingleContentTransport getTransport() {
|
public JingleContentTransportElement getTransport() {
|
||||||
return transport;
|
return transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleContentSecurity getSecurity() {
|
public JingleContentSecurityElement getSecurity() {
|
||||||
return security;
|
return security;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,11 +162,11 @@ public final class JingleContent implements NamedElement {
|
||||||
|
|
||||||
private Senders senders;
|
private Senders senders;
|
||||||
|
|
||||||
private JingleContentDescription description;
|
private JingleContentDescriptionElement description;
|
||||||
|
|
||||||
private JingleContentTransport transport;
|
private JingleContentTransportElement transport;
|
||||||
|
|
||||||
private JingleContentSecurity security;
|
private JingleContentSecurityElement security;
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ public final class JingleContent implements NamedElement {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setDescription(JingleContentDescription description) {
|
public Builder setDescription(JingleContentDescriptionElement description) {
|
||||||
if (this.description != null) {
|
if (this.description != null) {
|
||||||
throw new IllegalStateException("Jingle content description already set");
|
throw new IllegalStateException("Jingle content description already set");
|
||||||
}
|
}
|
||||||
|
@ -199,18 +199,18 @@ public final class JingleContent implements NamedElement {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setTransport(JingleContentTransport transport) {
|
public Builder setTransport(JingleContentTransportElement transport) {
|
||||||
this.transport = transport;
|
this.transport = transport;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setSecurity(JingleContentSecurity element) {
|
public Builder setSecurity(JingleContentSecurityElement element) {
|
||||||
this.security = element;
|
this.security = element;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleContent build() {
|
public JingleContentElement build() {
|
||||||
return new JingleContent(creator, disposition, name, senders, description, transport, security);
|
return new JingleContentElement(creator, disposition, name, senders, description, transport, security);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
|
|
||||||
|
@ -28,13 +28,17 @@ import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentSecurity implements ExtensionElement {
|
public abstract class JingleContentSecurityElement implements ExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "security";
|
public static final String ELEMENT = "security";
|
||||||
|
private JingleContentSecurityInfoElement securityInfo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENT;
|
return ELEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JingleContentSecurityInfoElement getSecurityInfo() {
|
||||||
|
return securityInfo;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 19.07.17.
|
||||||
|
*/
|
||||||
|
public abstract class JingleContentSecurityInfoElement implements NamedElement {
|
||||||
|
|
||||||
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.NamedElement;
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ import org.jivesoftware.smack.packet.NamedElement;
|
||||||
* </jingle>
|
* </jingle>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentTransportCandidate implements NamedElement {
|
public abstract class JingleContentTransportCandidateElement implements NamedElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "candidate";
|
public static final String ELEMENT = "candidate";
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -33,18 +33,18 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
* </jingle>
|
* </jingle>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentTransport implements ExtensionElement {
|
public abstract class JingleContentTransportElement implements ExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "transport";
|
public static final String ELEMENT = "transport";
|
||||||
|
|
||||||
protected final List<JingleContentTransportCandidate> candidates;
|
protected final List<JingleContentTransportCandidateElement> candidates;
|
||||||
protected final JingleContentTransportInfo info;
|
protected final JingleContentTransportInfoElement info;
|
||||||
|
|
||||||
protected JingleContentTransport(List<JingleContentTransportCandidate> candidates) {
|
protected JingleContentTransportElement(List<JingleContentTransportCandidateElement> candidates) {
|
||||||
this(candidates, null);
|
this(candidates, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JingleContentTransport(List<JingleContentTransportCandidate> candidates, JingleContentTransportInfo info) {
|
protected JingleContentTransportElement(List<JingleContentTransportCandidateElement> candidates, JingleContentTransportInfoElement info) {
|
||||||
if (candidates != null) {
|
if (candidates != null) {
|
||||||
this.candidates = Collections.unmodifiableList(candidates);
|
this.candidates = Collections.unmodifiableList(candidates);
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,11 @@ public abstract class JingleContentTransport implements ExtensionElement {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JingleContentTransportCandidate> getCandidates() {
|
public List<JingleContentTransportCandidateElement> getCandidates() {
|
||||||
return candidates;
|
return candidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleContentTransportInfo getInfo() {
|
public JingleContentTransportInfoElement getInfo() {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.NamedElement;
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
|
|
||||||
|
@ -32,6 +32,6 @@ import org.jivesoftware.smack.packet.NamedElement;
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentTransportInfo implements NamedElement {
|
public abstract class JingleContentTransportInfoElement implements NamedElement {
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,371 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 2003-2007 Jive Software, 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.
|
||||||
|
* 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.jingle3.element;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.XMPPError;
|
||||||
|
import org.jivesoftware.smack.util.Objects;
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
|
||||||
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Jingle element.
|
||||||
|
*
|
||||||
|
* @author Florian Schmaus
|
||||||
|
*/
|
||||||
|
public final class JingleElement extends IQ {
|
||||||
|
|
||||||
|
public static final String NAMESPACE = "urn:xmpp:jingle:1";
|
||||||
|
|
||||||
|
public static final String ACTION_ATTRIBUTE_NAME = "action";
|
||||||
|
|
||||||
|
public static final String INITIATOR_ATTRIBUTE_NAME = "initiator";
|
||||||
|
|
||||||
|
public static final String RESPONDER_ATTRIBUTE_NAME = "responder";
|
||||||
|
|
||||||
|
public static final String SESSION_ID_ATTRIBUTE_NAME = "sid";
|
||||||
|
|
||||||
|
public static final String ELEMENT = "jingle";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The session ID related to this session. The session ID is a unique identifier generated by the initiator. This
|
||||||
|
* should match the XML Nmtoken production so that XML character escaping is not needed for characters such as &.
|
||||||
|
*/
|
||||||
|
private final String sessionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The jingle action. This attribute is required.
|
||||||
|
*/
|
||||||
|
private final JingleAction action;
|
||||||
|
|
||||||
|
private final FullJid initiator;
|
||||||
|
|
||||||
|
private final FullJid responder;
|
||||||
|
|
||||||
|
private final JingleReasonElement reason;
|
||||||
|
|
||||||
|
private final List<JingleContentElement> contents;
|
||||||
|
|
||||||
|
private JingleElement(String sessionId, JingleAction action, FullJid initiator, FullJid responder, JingleReasonElement reason,
|
||||||
|
List<JingleContentElement> contents) {
|
||||||
|
super(ELEMENT, NAMESPACE);
|
||||||
|
this.sessionId = StringUtils.requireNotNullOrEmpty(sessionId, "Jingle session ID must not be null");
|
||||||
|
this.action = Objects.requireNonNull(action, "Jingle action must not be null");
|
||||||
|
this.initiator = initiator;
|
||||||
|
this.responder = responder;
|
||||||
|
this.reason = reason;
|
||||||
|
if (contents != null) {
|
||||||
|
this.contents = Collections.unmodifiableList(contents);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.contents = Collections.emptyList();
|
||||||
|
}
|
||||||
|
setType(Type.set);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the initiator. The initiator will be the full JID of the entity that has initiated the flow (which may be
|
||||||
|
* different to the "from" address in the IQ)
|
||||||
|
*
|
||||||
|
* @return the initiator
|
||||||
|
*/
|
||||||
|
public FullJid getInitiator() {
|
||||||
|
return initiator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the responder. The responder is the full JID of the entity that has replied to the initiation (which may be
|
||||||
|
* different to the "to" addresss in the IQ).
|
||||||
|
*
|
||||||
|
* @return the responder
|
||||||
|
*/
|
||||||
|
public FullJid getResponder() {
|
||||||
|
return responder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the session ID related to the session. The session ID is a unique identifier generated by the initiator.
|
||||||
|
* This should match the XML Nmtoken production so that XML character escaping is not needed for characters such as
|
||||||
|
* &.
|
||||||
|
*
|
||||||
|
* @return Returns the session ID related to the session.
|
||||||
|
*/
|
||||||
|
public String getSid() {
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the action specified in the jingle IQ.
|
||||||
|
*
|
||||||
|
* @return the action.
|
||||||
|
*/
|
||||||
|
public JingleAction getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleReasonElement getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a List of the contents.
|
||||||
|
*
|
||||||
|
* @return the contents.
|
||||||
|
*/
|
||||||
|
public List<JingleContentElement> getContents() {
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||||
|
xml.optAttribute(INITIATOR_ATTRIBUTE_NAME, getInitiator());
|
||||||
|
xml.optAttribute(RESPONDER_ATTRIBUTE_NAME, getResponder());
|
||||||
|
xml.optAttribute(ACTION_ATTRIBUTE_NAME, getAction());
|
||||||
|
xml.optAttribute(SESSION_ID_ATTRIBUTE_NAME, getSid());
|
||||||
|
xml.rightAngleBracket();
|
||||||
|
|
||||||
|
xml.optElement(reason);
|
||||||
|
|
||||||
|
xml.append(contents);
|
||||||
|
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder getBuilder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private String sid;
|
||||||
|
|
||||||
|
private JingleAction action;
|
||||||
|
|
||||||
|
private FullJid initiator;
|
||||||
|
|
||||||
|
private FullJid responder;
|
||||||
|
|
||||||
|
private JingleReasonElement reason;
|
||||||
|
|
||||||
|
private List<JingleContentElement> contents;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setSessionId(String sessionId) {
|
||||||
|
this.sid = sessionId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setAction(JingleAction action) {
|
||||||
|
this.action = action;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setInitiator(FullJid initator) {
|
||||||
|
this.initiator = initator;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setResponder(FullJid responder) {
|
||||||
|
this.responder = responder;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder addJingleContent(JingleContentElement content) {
|
||||||
|
if (contents == null) {
|
||||||
|
contents = new ArrayList<>(1);
|
||||||
|
}
|
||||||
|
contents.add(content);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setReason(JingleReasonElement.Reason reason) {
|
||||||
|
this.reason = new JingleReasonElement(reason);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setReason(JingleReasonElement reason) {
|
||||||
|
this.reason = reason;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleElement build() {
|
||||||
|
return new JingleElement(sid, action, initiator, responder, reason, contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleElement createContentAccept(FullJid recipient, String sessionId, List<JingleContentElement> contents) {
|
||||||
|
JingleElement.Builder builder = JingleElement.getBuilder().setAction(JingleAction.content_accept).setSessionId(sessionId);
|
||||||
|
|
||||||
|
for (JingleContentElement element : contents) {
|
||||||
|
builder.addJingleContent(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
JingleElement jingleElement = builder.build();
|
||||||
|
jingleElement.setTo(recipient);
|
||||||
|
|
||||||
|
return jingleElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a session-terminate stanza.
|
||||||
|
* XEP-0166 §6.7.
|
||||||
|
* @param recipient recipient of the stanza.
|
||||||
|
* @param sessionId sessionId.
|
||||||
|
* @param reason reason of termination.
|
||||||
|
* @return session-terminate stanza.
|
||||||
|
*/
|
||||||
|
public static JingleElement createSessionTerminate(FullJid recipient, String sessionId, JingleReasonElement reason) {
|
||||||
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
|
jb.setAction(JingleAction.session_terminate)
|
||||||
|
.setSessionId(sessionId)
|
||||||
|
.setReason(reason);
|
||||||
|
|
||||||
|
JingleElement jingle = jb.build();
|
||||||
|
jingle.setTo(recipient);
|
||||||
|
|
||||||
|
return jingle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a session-terminate stanza.
|
||||||
|
* XEP-0166 §6.7.
|
||||||
|
* @param recipient recipient of the stanza.
|
||||||
|
* @param sessionId sessionId.
|
||||||
|
* @param reason reason of termination.
|
||||||
|
* @return session-terminate stanza.
|
||||||
|
*/
|
||||||
|
public static JingleElement createSessionTerminate(FullJid recipient, String sessionId, JingleReasonElement.Reason reason) {
|
||||||
|
return createSessionTerminate(recipient, sessionId, new JingleReasonElement(reason));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleElement createTransportAccept(FullJid initiator, FullJid recipient, String sessionId,
|
||||||
|
JingleContentElement.Creator contentCreator,
|
||||||
|
String contentName, JingleContentTransportElement transport) {
|
||||||
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
|
jb.setAction(JingleAction.transport_accept)
|
||||||
|
.setInitiator(initiator)
|
||||||
|
.setSessionId(sessionId);
|
||||||
|
|
||||||
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
|
cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
|
||||||
|
|
||||||
|
JingleElement jingle = jb.addJingleContent(cb.build()).build();
|
||||||
|
jingle.setTo(recipient);
|
||||||
|
|
||||||
|
return jingle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JingleElement createTransportReject(FullJid initiator, FullJid recipient, String sessionId,
|
||||||
|
JingleContentElement.Creator contentCreator,
|
||||||
|
String contentName, JingleContentTransportElement transport) {
|
||||||
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
|
jb.setAction(JingleAction.transport_reject)
|
||||||
|
.setInitiator(initiator)
|
||||||
|
.setSessionId(sessionId);
|
||||||
|
|
||||||
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
|
cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
|
||||||
|
|
||||||
|
JingleElement jingle = jb.addJingleContent(cb.build()).build();
|
||||||
|
jingle.setTo(recipient);
|
||||||
|
|
||||||
|
return jingle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an error response to a request with an unknown session id.
|
||||||
|
* XEP-0166 Example 29.
|
||||||
|
* @param request request with unknown sessionId.
|
||||||
|
* @return error stanza.
|
||||||
|
*/
|
||||||
|
public static IQ createJingleErrorUnknownSession(JingleElement request) {
|
||||||
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
|
error.setCondition(XMPPError.Condition.item_not_found)
|
||||||
|
.addExtension(JingleErrorElement.UNKNOWN_SESSION);
|
||||||
|
return IQ.createErrorResponse(request, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an error response to a request coming from a unknown initiator.
|
||||||
|
* XEP-0166 Example 12.
|
||||||
|
* @param request request from unknown initiator.
|
||||||
|
* @return error stanza.
|
||||||
|
*/
|
||||||
|
public static IQ createJingleErrorUnknownInitiator(JingleElement request) {
|
||||||
|
XMPPError.Builder b = XMPPError.getBuilder().setType(XMPPError.Type.CANCEL).setCondition(XMPPError.Condition.service_unavailable);
|
||||||
|
return IQ.createErrorResponse(request, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an error response to a request with an unsupported info.
|
||||||
|
* XEP-0166 Example 31.
|
||||||
|
* @param request request with unsupported info.
|
||||||
|
* @return error stanza.
|
||||||
|
*/
|
||||||
|
public static IQ createJingleErrorUnsupportedInfo(JingleElement request) {
|
||||||
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
|
error.setCondition(XMPPError.Condition.feature_not_implemented)
|
||||||
|
.addExtension(JingleErrorElement.UNSUPPORTED_INFO).setType(XMPPError.Type.MODIFY);
|
||||||
|
return IQ.createErrorResponse(request, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an error response to a tie-breaking request.
|
||||||
|
* XEP-0166 Example 34.
|
||||||
|
* @param request tie-breaking request
|
||||||
|
* @return error stanza
|
||||||
|
*/
|
||||||
|
public static IQ createJingleErrorTieBreak(JingleElement request) {
|
||||||
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
|
error.setCondition(XMPPError.Condition.conflict)
|
||||||
|
.addExtension(JingleErrorElement.TIE_BREAK);
|
||||||
|
return IQ.createErrorResponse(request, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an error response to a request that was out of order.
|
||||||
|
* TODO: Find example.
|
||||||
|
* @param request request out of order.
|
||||||
|
* @return error stanza.
|
||||||
|
*/
|
||||||
|
public static IQ createJingleErrorOutOfOrder(JingleElement request) {
|
||||||
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
|
error.setCondition(XMPPError.Condition.unexpected_request)
|
||||||
|
.addExtension(JingleErrorElement.OUT_OF_ORDER);
|
||||||
|
return IQ.createErrorResponse(request, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an error response to a malformed request.
|
||||||
|
* XEP-0166 Ex. 16
|
||||||
|
* @param request malformed request
|
||||||
|
* @return error stanza.
|
||||||
|
*/
|
||||||
|
public static IQ createJingleErrorMalformedRequest(JingleElement request) {
|
||||||
|
XMPPError.Builder error = XMPPError.getBuilder();
|
||||||
|
error.setType(XMPPError.Type.CANCEL);
|
||||||
|
error.setCondition(XMPPError.Condition.bad_request);
|
||||||
|
return IQ.createErrorResponse(request, error);
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,24 +15,24 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
public final class JingleError implements ExtensionElement {
|
public final class JingleErrorElement implements ExtensionElement {
|
||||||
|
|
||||||
public static String NAMESPACE = "urn:xmpp:jingle:errors:1";
|
public static String NAMESPACE = "urn:xmpp:jingle:errors:1";
|
||||||
|
|
||||||
public static final JingleError OUT_OF_ORDER = new JingleError("out-of-order");
|
public static final JingleErrorElement OUT_OF_ORDER = new JingleErrorElement("out-of-order");
|
||||||
|
|
||||||
public static final JingleError TIE_BREAK = new JingleError("tie-break");
|
public static final JingleErrorElement TIE_BREAK = new JingleErrorElement("tie-break");
|
||||||
|
|
||||||
public static final JingleError UNKNOWN_SESSION = new JingleError("unknown-session");
|
public static final JingleErrorElement UNKNOWN_SESSION = new JingleErrorElement("unknown-session");
|
||||||
|
|
||||||
public static final JingleError UNSUPPORTED_INFO = new JingleError("unsupported-info");
|
public static final JingleErrorElement UNSUPPORTED_INFO = new JingleErrorElement("unsupported-info");
|
||||||
|
|
||||||
private final String errorName;
|
private final String errorName;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public final class JingleError implements ExtensionElement {
|
||||||
*
|
*
|
||||||
* @param errorName a name describing the error.
|
* @param errorName a name describing the error.
|
||||||
*/
|
*/
|
||||||
private JingleError(final String errorName) {
|
private JingleErrorElement(final String errorName) {
|
||||||
this.errorName = errorName;
|
this.errorName = errorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public final class JingleError implements ExtensionElement {
|
||||||
/**
|
/**
|
||||||
* Returns a Action instance associated with the String value.
|
* Returns a Action instance associated with the String value.
|
||||||
*/
|
*/
|
||||||
public static JingleError fromString(String value) {
|
public static JingleErrorElement fromString(String value) {
|
||||||
value = value.toLowerCase(Locale.US);
|
value = value.toLowerCase(Locale.US);
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case "out-of-order":
|
case "out-of-order":
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
* @see <a href="https://xmpp.org/extensions/xep-0166.html#def-reason">XEP-0166 § 7.4</a>
|
* @see <a href="https://xmpp.org/extensions/xep-0166.html#def-reason">XEP-0166 § 7.4</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class JingleReason implements NamedElement {
|
public class JingleReasonElement implements NamedElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "reason";
|
public static final String ELEMENT = "reason";
|
||||||
|
|
||||||
|
@ -37,22 +37,22 @@ public class JingleReason implements NamedElement {
|
||||||
return new AlternativeSession(sessionId);
|
return new AlternativeSession(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final JingleReason Busy = new JingleReason(Reason.busy);
|
public static final JingleReasonElement Busy = new JingleReasonElement(Reason.busy);
|
||||||
public static final JingleReason Cancel = new JingleReason(Reason.cancel);
|
public static final JingleReasonElement Cancel = new JingleReasonElement(Reason.cancel);
|
||||||
public static final JingleReason ConnectivityError = new JingleReason(Reason.connectivity_error);
|
public static final JingleReasonElement ConnectivityError = new JingleReasonElement(Reason.connectivity_error);
|
||||||
public static final JingleReason Decline = new JingleReason(Reason.decline);
|
public static final JingleReasonElement Decline = new JingleReasonElement(Reason.decline);
|
||||||
public static final JingleReason Expired = new JingleReason(Reason.expired);
|
public static final JingleReasonElement Expired = new JingleReasonElement(Reason.expired);
|
||||||
public static final JingleReason FailedApplication = new JingleReason(Reason.failed_application);
|
public static final JingleReasonElement FailedApplication = new JingleReasonElement(Reason.failed_application);
|
||||||
public static final JingleReason FailedTransport = new JingleReason(Reason.failed_transport);
|
public static final JingleReasonElement FailedTransport = new JingleReasonElement(Reason.failed_transport);
|
||||||
public static final JingleReason GeneralError = new JingleReason(Reason.general_error);
|
public static final JingleReasonElement GeneralError = new JingleReasonElement(Reason.general_error);
|
||||||
public static final JingleReason Gone = new JingleReason(Reason.gone);
|
public static final JingleReasonElement Gone = new JingleReasonElement(Reason.gone);
|
||||||
public static final JingleReason IncompatibleParameters = new JingleReason(Reason.incompatible_parameters);
|
public static final JingleReasonElement IncompatibleParameters = new JingleReasonElement(Reason.incompatible_parameters);
|
||||||
public static final JingleReason MediaError = new JingleReason(Reason.media_error);
|
public static final JingleReasonElement MediaError = new JingleReasonElement(Reason.media_error);
|
||||||
public static final JingleReason SecurityError = new JingleReason(Reason.security_error);
|
public static final JingleReasonElement SecurityError = new JingleReasonElement(Reason.security_error);
|
||||||
public static final JingleReason Success = new JingleReason(Reason.success);
|
public static final JingleReasonElement Success = new JingleReasonElement(Reason.success);
|
||||||
public static final JingleReason Timeout = new JingleReason(Reason.timeout);
|
public static final JingleReasonElement Timeout = new JingleReasonElement(Reason.timeout);
|
||||||
public static final JingleReason UnsupportedApplications = new JingleReason(Reason.unsupported_applications);
|
public static final JingleReasonElement UnsupportedApplications = new JingleReasonElement(Reason.unsupported_applications);
|
||||||
public static final JingleReason UnsupportedTransports = new JingleReason(Reason.unsupported_transports);
|
public static final JingleReasonElement UnsupportedTransports = new JingleReasonElement(Reason.unsupported_transports);
|
||||||
|
|
||||||
public enum Reason {
|
public enum Reason {
|
||||||
alternative_session,
|
alternative_session,
|
||||||
|
@ -104,7 +104,7 @@ public class JingleReason implements NamedElement {
|
||||||
|
|
||||||
protected final Reason reason;
|
protected final Reason reason;
|
||||||
|
|
||||||
public JingleReason(Reason reason) {
|
public JingleReasonElement(Reason reason) {
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public class JingleReason implements NamedElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class AlternativeSession extends JingleReason {
|
public static class AlternativeSession extends JingleReasonElement {
|
||||||
|
|
||||||
public static final String SID = "sid";
|
public static final String SID = "sid";
|
||||||
private final String sessionId;
|
private final String sessionId;
|
|
@ -18,4 +18,4 @@
|
||||||
/**
|
/**
|
||||||
* Stanzas and Extension Elements for <a href="https://xmpp.org/extensions/xep-0166.html">XEP-0166: Jingle</a>.
|
* Stanzas and Extension Elements for <a href="https://xmpp.org/extensions/xep-0166.html">XEP-0166: Jingle</a>.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.element;
|
package org.jivesoftware.smackx.jingle3.element;
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public class UnsupportedDescriptionException extends Exception {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final String namespace;
|
||||||
|
|
||||||
|
public UnsupportedDescriptionException(String namespace) {
|
||||||
|
super("Description with namespace " + namespace + " not supported.");
|
||||||
|
this.namespace = namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNamespace() {
|
||||||
|
return namespace;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public class UnsupportedSecurityException extends Exception {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final String namespace;
|
||||||
|
|
||||||
|
public UnsupportedSecurityException(String namespace) {
|
||||||
|
super("Security with namespace " + namespace + " not supported.");
|
||||||
|
this.namespace = namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNamespace() {
|
||||||
|
return namespace;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public class UnsupportedTransportException extends Exception {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final String namespace;
|
||||||
|
|
||||||
|
public UnsupportedTransportException(String namespace) {
|
||||||
|
super("Transport with namespace " + namespace + " not supported.");
|
||||||
|
this.namespace = namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNamespace() {
|
||||||
|
return namespace;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,145 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.internal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
import org.jivesoftware.smackx.jingle3.Callback;
|
||||||
|
import org.jivesoftware.smackx.jingle3.JingleExtensionManager;
|
||||||
|
import org.jivesoftware.smackx.jingle3.adapter.JingleDescriptionAdapter;
|
||||||
|
import org.jivesoftware.smackx.jingle3.adapter.JingleSecurityAdapter;
|
||||||
|
import org.jivesoftware.smackx.jingle3.adapter.JingleTransportAdapter;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentSecurityElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal class that holds the state of a content in a modifiable form.
|
||||||
|
*/
|
||||||
|
public class Content {
|
||||||
|
|
||||||
|
private Session session;
|
||||||
|
private JingleContentElement.Creator creator;
|
||||||
|
private String name;
|
||||||
|
private String disposition;
|
||||||
|
private JingleContentElement.Senders senders;
|
||||||
|
private Description description;
|
||||||
|
private Transport transport;
|
||||||
|
private Security security;
|
||||||
|
|
||||||
|
private final List<Callback> callbacks = Collections.synchronizedList(new ArrayList<Callback>());
|
||||||
|
private final Set<String> transportBlacklist = Collections.synchronizedSet(new HashSet<String>());
|
||||||
|
|
||||||
|
public Content(Description description, Transport transport, Security security, String name, String disposition, JingleContentElement.Creator creator, JingleContentElement.Senders senders) {
|
||||||
|
this.description = description;
|
||||||
|
this.transport = transport;
|
||||||
|
this.security = security;
|
||||||
|
this.name = name;
|
||||||
|
this.disposition = disposition;
|
||||||
|
this.creator = creator;
|
||||||
|
this.senders = senders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Content fromElement(JingleContentElement content) {
|
||||||
|
Description<?> description = null;
|
||||||
|
Transport<?> transport = null;
|
||||||
|
Security<?> security = null;
|
||||||
|
|
||||||
|
JingleContentDescriptionElement descriptionElement = content.getDescription();
|
||||||
|
if (descriptionElement != null) {
|
||||||
|
JingleDescriptionAdapter<?> descriptionAdapter = JingleExtensionManager.getJingleDescriptionAdapter(content.getDescription().getNamespace());
|
||||||
|
if (descriptionAdapter != null) {
|
||||||
|
description = descriptionAdapter.descriptionFromElement(descriptionElement);
|
||||||
|
} else {
|
||||||
|
throw new AssertionError("DescriptionProvider for " + descriptionElement.getNamespace() +
|
||||||
|
" seems to be registered, but no corresponding JingleDescriptionAdapter was found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JingleContentTransportElement transportElement = content.getTransport();
|
||||||
|
if (transportElement != null) {
|
||||||
|
JingleTransportAdapter<?> transportAdapter = JingleExtensionManager.getJingleTransportAdapter(content.getTransport().getNamespace());
|
||||||
|
if (transportAdapter != null) {
|
||||||
|
transport = transportAdapter.transportFromElement(transportElement);
|
||||||
|
} else {
|
||||||
|
throw new AssertionError("DescriptionProvider for " + transportElement.getNamespace() +
|
||||||
|
" seems to be registered, but no corresponding JingleTransportAdapter was found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JingleContentSecurityElement securityElement = content.getSecurity();
|
||||||
|
if (securityElement != null) {
|
||||||
|
JingleSecurityAdapter<?> securityAdapter = JingleExtensionManager.getJingleSecurityAdapter(content.getSecurity().getNamespace());
|
||||||
|
if (securityAdapter != null) {
|
||||||
|
security = securityAdapter.securityFromElement(securityElement);
|
||||||
|
} else {
|
||||||
|
throw new AssertionError("SecurityProvider for " + securityElement.getNamespace() +
|
||||||
|
" seems to be registered, but no corresponding JingleSecurityAdapter was found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Content(description, transport, security, content.getName(), content.getDisposition(), content.getCreator(), content.getSenders());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCallback(Callback callback) {
|
||||||
|
callbacks.add(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleContentElement getElement() {
|
||||||
|
return JingleContentElement.getBuilder()
|
||||||
|
.setName(name)
|
||||||
|
.setCreator(creator)
|
||||||
|
.setSenders(senders)
|
||||||
|
.setDescription(description.getElement())
|
||||||
|
.setTransport(transport.getElement())
|
||||||
|
.setSecurity(security.getElement())
|
||||||
|
.setDisposition(disposition)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getTransportBlacklist() {
|
||||||
|
return transportBlacklist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleContentElement.Creator getCreator() {
|
||||||
|
return creator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleContentElement.Senders getSenders() {
|
||||||
|
return senders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Description getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Transport<?> getTransport() {
|
||||||
|
return transport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransport(Transport<?> transport) {
|
||||||
|
this.transport = transport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSession(Session session) {
|
||||||
|
if (this.session != session) {
|
||||||
|
this.session = session;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Security getSecurity() {
|
||||||
|
return security;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String randomName() {
|
||||||
|
return "cont-" + StringUtils.randomString(16);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.internal;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public abstract class Description<D extends JingleContentDescriptionElement> {
|
||||||
|
|
||||||
|
public abstract D getElement();
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.internal;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 19.07.17.
|
||||||
|
*/
|
||||||
|
public abstract class PendingJingleAction {
|
||||||
|
private final JingleAction action;
|
||||||
|
private final Content affectedContent;
|
||||||
|
|
||||||
|
public PendingJingleAction(JingleAction action, Content content) {
|
||||||
|
this.action = action;
|
||||||
|
this.affectedContent = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleAction getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Content getAffectedContent() {
|
||||||
|
return affectedContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TransportReplace extends PendingJingleAction {
|
||||||
|
private final Transport<?> newTransport;
|
||||||
|
|
||||||
|
public TransportReplace(Content content, Transport<?> newTransport) {
|
||||||
|
super(JingleAction.transport_replace, content);
|
||||||
|
this.newTransport = newTransport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Transport<?> getNewTransport() {
|
||||||
|
return newTransport;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.internal;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentSecurityElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentSecurityInfoElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public abstract class Security<D extends JingleContentSecurityElement> {
|
||||||
|
|
||||||
|
public abstract D getElement();
|
||||||
|
|
||||||
|
public abstract JingleElement handleSecurityInfo(JingleContentSecurityInfoElement element);
|
||||||
|
}
|
|
@ -0,0 +1,388 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.internal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.SmackException;
|
||||||
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smackx.jingle3.JingleDescriptionManager;
|
||||||
|
import org.jivesoftware.smackx.jingle3.JingleExtensionManager;
|
||||||
|
import org.jivesoftware.smackx.jingle3.JingleManager;
|
||||||
|
import org.jivesoftware.smackx.jingle3.Role;
|
||||||
|
import org.jivesoftware.smackx.jingle3.adapter.JingleTransportAdapter;
|
||||||
|
import org.jivesoftware.smackx.jingle3.callbacks.ContentAddCallback;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.exception.UnsupportedDescriptionException;
|
||||||
|
import org.jivesoftware.smackx.jingle3.exception.UnsupportedSecurityException;
|
||||||
|
import org.jivesoftware.smackx.jingle3.exception.UnsupportedTransportException;
|
||||||
|
|
||||||
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 17.07.17.
|
||||||
|
*/
|
||||||
|
public class Session {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(Session.class.getName());
|
||||||
|
|
||||||
|
private final ConcurrentHashMap<String, Content> contents = new ConcurrentHashMap<>();
|
||||||
|
private final JingleManager jingleManager;
|
||||||
|
|
||||||
|
private final FullJid initiator, responder;
|
||||||
|
private final Role role;
|
||||||
|
private final String sessionId;
|
||||||
|
|
||||||
|
private final Map<Content, PendingJingleAction> pendingJingleActions =
|
||||||
|
Collections.synchronizedMap(new HashMap<Content, PendingJingleAction>());
|
||||||
|
|
||||||
|
public Session(JingleManager manager, FullJid initiator, FullJid responder, Role role, String sessionId) {
|
||||||
|
this.jingleManager = manager;
|
||||||
|
this.initiator = initiator;
|
||||||
|
this.responder = responder;
|
||||||
|
this.role = role;
|
||||||
|
this.sessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addContent(Content content) {
|
||||||
|
contents.put(content.getName(), content);
|
||||||
|
content.setSession(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addContent(JingleContentElement content)
|
||||||
|
throws UnsupportedSecurityException, UnsupportedTransportException, UnsupportedDescriptionException {
|
||||||
|
addContent(Content.fromElement(content));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Session fromSessionInitiate(JingleManager manager, JingleElement initiate)
|
||||||
|
throws UnsupportedSecurityException, UnsupportedDescriptionException, UnsupportedTransportException {
|
||||||
|
if (initiate.getAction() != JingleAction.session_initiate) {
|
||||||
|
throw new IllegalArgumentException("Jingle-Action MUST be 'session-initiate'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Session session = new Session(manager, initiate.getInitiator(), initiate.getResponder(), Role.responder, initiate.getSid());
|
||||||
|
List<JingleContentElement> initiateContents = initiate.getContents();
|
||||||
|
|
||||||
|
for (JingleContentElement content : initiateContents) {
|
||||||
|
session.addContent(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQ handleJingleRequest(JingleElement request) {
|
||||||
|
switch (request.getAction()) {
|
||||||
|
case content_accept:
|
||||||
|
return handleContentAccept(request);
|
||||||
|
case content_add:
|
||||||
|
return handleContentAdd(request);
|
||||||
|
case content_modify:
|
||||||
|
return handleContentModify(request);
|
||||||
|
case content_reject:
|
||||||
|
return handleContentReject(request);
|
||||||
|
case content_remove:
|
||||||
|
return handleContentRemove(request);
|
||||||
|
case description_info:
|
||||||
|
return handleDescriptionInfo(request);
|
||||||
|
case session_info:
|
||||||
|
return handleSessionInfo(request);
|
||||||
|
case security_info:
|
||||||
|
return handleSecurityInfo(request);
|
||||||
|
case session_accept:
|
||||||
|
return handleSessionAccept(request);
|
||||||
|
case transport_accept:
|
||||||
|
return handleTransportAccept(request);
|
||||||
|
case transport_info:
|
||||||
|
return handleTransportInfo(request);
|
||||||
|
case session_initiate:
|
||||||
|
return handleSessionInitiate(request);
|
||||||
|
case transport_reject:
|
||||||
|
return handleTransportReject(request);
|
||||||
|
case session_terminate:
|
||||||
|
return handleSessionTerminate(request);
|
||||||
|
case transport_replace:
|
||||||
|
return handleTransportReplace(request);
|
||||||
|
default:
|
||||||
|
throw new AssertionError("Unknown Jingle Action enum! " + request.getAction());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleTransportReplace(JingleElement request) {
|
||||||
|
List<JingleContentElement> affectedContents = request.getContents();
|
||||||
|
List<JingleElement> responses = new ArrayList<>();
|
||||||
|
|
||||||
|
for (JingleContentElement affected : affectedContents) {
|
||||||
|
Content content = contents.get(affected.getName());
|
||||||
|
JingleContentTransportElement newTransport = affected.getTransport();
|
||||||
|
Set<String> blacklist = content.getTransportBlacklist();
|
||||||
|
|
||||||
|
// Proposed transport method might already be on the blacklist (eg. because of previous failures)
|
||||||
|
if (blacklist.contains(newTransport.getNamespace())) {
|
||||||
|
responses.add(JingleElement.createTransportReject(getInitiator(), getPeer(), getSessionId(),
|
||||||
|
content.getCreator(), content.getName(), newTransport));
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JingleTransportAdapter<?> transportAdapter = JingleExtensionManager.getJingleTransportAdapter(
|
||||||
|
newTransport.getNamespace());
|
||||||
|
// This might be an unknown transport.
|
||||||
|
if (transportAdapter == null) {
|
||||||
|
responses.add(JingleElement.createTransportReject(getInitiator(), getPeer(), getSessionId(),
|
||||||
|
content.getCreator(), content.getName(), newTransport));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Otherwise, when all went well so far, accept the transport-replace
|
||||||
|
content.setTransport(JingleExtensionManager.getJingleTransportAdapter(newTransport.getNamespace())
|
||||||
|
.transportFromElement(newTransport));
|
||||||
|
responses.add(JingleElement.createTransportAccept(getInitiator(), getPeer(), getSessionId(),
|
||||||
|
content.getCreator(), content.getName(), newTransport));
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Put in Thread?
|
||||||
|
for (JingleElement response : responses) {
|
||||||
|
try {
|
||||||
|
jingleManager.getConnection().createStanzaCollectorAndSend(response).nextResultOrThrow();
|
||||||
|
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException | SmackException.NotConnectedException e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not send response to transport-replace: " + e, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return IQ.createResultIQ(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleSessionTerminate(JingleElement request) {
|
||||||
|
JingleReasonElement reason = request.getReason();
|
||||||
|
if (reason == null) {
|
||||||
|
throw new AssertionError("Reason MUST not be null! (I guess)...");
|
||||||
|
}
|
||||||
|
switch (reason.asEnum()) {
|
||||||
|
case alternative_session:
|
||||||
|
case busy:
|
||||||
|
case cancel:
|
||||||
|
case connectivity_error:
|
||||||
|
case decline:
|
||||||
|
// :(
|
||||||
|
case expired:
|
||||||
|
case failed_application:
|
||||||
|
case failed_transport:
|
||||||
|
case general_error:
|
||||||
|
// well... shit.
|
||||||
|
case gone:
|
||||||
|
case incompatible_parameters:
|
||||||
|
case media_error:
|
||||||
|
case security_error:
|
||||||
|
case success:
|
||||||
|
// Weeeeeh
|
||||||
|
break;
|
||||||
|
case timeout:
|
||||||
|
case unsupported_applications:
|
||||||
|
case unsupported_transports:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new AssertionError("Unknown reson enum: " + reason.asEnum().toString());
|
||||||
|
}
|
||||||
|
return IQ.createResultIQ(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleTransportReject(JingleElement request) {
|
||||||
|
HashMap<JingleContentElement, Content> affectedContents = getAffectedContents(request);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleSessionInitiate(JingleElement request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleTransportInfo(JingleElement request) {
|
||||||
|
HashMap<JingleContentElement, Content> affectedContents = getAffectedContents(request);
|
||||||
|
List<JingleElement> responses = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map.Entry<JingleContentElement, Content> entry : affectedContents.entrySet()) {
|
||||||
|
responses.add(entry.getValue().getTransport().handleTransportInfo(entry.getKey().getTransport().getInfo()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (JingleElement response : responses) {
|
||||||
|
try {
|
||||||
|
getJingleManager().getConnection().createStanzaCollectorAndSend(response).nextResultOrThrow();
|
||||||
|
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException | SmackException.NotConnectedException e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not send response to transport-info: " + e, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return IQ.createResultIQ(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleTransportAccept(JingleElement request) {
|
||||||
|
HashMap<JingleContentElement, Content> affectedContents = getAffectedContents(request);
|
||||||
|
for (Map.Entry<JingleContentElement, Content> entry : affectedContents.entrySet()) {
|
||||||
|
|
||||||
|
PendingJingleAction pending = pendingJingleActions.get(entry.getValue());
|
||||||
|
if (pending == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pending.getAction() != JingleAction.transport_replace) {
|
||||||
|
//TODO: Are multiple contents even possible here?
|
||||||
|
//TODO: How to react to partially illegal requests?
|
||||||
|
return JingleElement.createJingleErrorOutOfOrder(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.getValue().setTransport(((PendingJingleAction.TransportReplace) pending).getNewTransport());
|
||||||
|
}
|
||||||
|
|
||||||
|
return IQ.createResultIQ(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleSessionAccept(JingleElement request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleSecurityInfo(JingleElement request) {
|
||||||
|
HashMap<JingleContentElement, Content> affectedContents = getAffectedContents(request);
|
||||||
|
List<JingleElement> responses = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map.Entry<JingleContentElement, Content> entry : affectedContents.entrySet()) {
|
||||||
|
responses.add(entry.getValue().getSecurity().handleSecurityInfo(entry.getKey().getSecurity().getSecurityInfo()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (JingleElement response : responses) {
|
||||||
|
try {
|
||||||
|
getJingleManager().getConnection().createStanzaCollectorAndSend(response).nextResultOrThrow();
|
||||||
|
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not send response to security-info: " + e, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return IQ.createResultIQ(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleSessionInfo(JingleElement request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleDescriptionInfo(JingleElement request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleContentRemove(JingleElement request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleContentReject(JingleElement request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleContentModify(JingleElement request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleContentAdd(JingleElement request) {
|
||||||
|
final List<JingleContentElement> proposedContents = request.getContents();
|
||||||
|
final List<JingleContentElement> acceptedContents = new ArrayList<>();
|
||||||
|
|
||||||
|
final HashMap<String, List<Content>> contentsByDescription = new HashMap<>();
|
||||||
|
|
||||||
|
for (JingleContentElement p : proposedContents) {
|
||||||
|
JingleContentDescriptionElement description = p.getDescription();
|
||||||
|
List<Content> list = contentsByDescription.get(description.getNamespace());
|
||||||
|
if (list == null) {
|
||||||
|
list = new ArrayList<>();
|
||||||
|
contentsByDescription.put(description.getNamespace(), list);
|
||||||
|
}
|
||||||
|
list.add(Content.fromElement(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, List<Content>> descriptionCategory : contentsByDescription.entrySet()) {
|
||||||
|
JingleDescriptionManager descriptionManager = JingleExtensionManager.getInstanceFor(getJingleManager().getConnection()).getDescriptionManager(descriptionCategory.getKey());
|
||||||
|
|
||||||
|
if (descriptionManager == null) {
|
||||||
|
//blabla
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final Content content : descriptionCategory.getValue()) {
|
||||||
|
ContentAddCallback callback = new ContentAddCallback() {
|
||||||
|
@Override
|
||||||
|
public void acceptContentAdd() {
|
||||||
|
contents.put(content.getName(), content);
|
||||||
|
acceptedContents.add(content.getElement());
|
||||||
|
// TODO: Send content-accept
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rejectContentAdd() {
|
||||||
|
// TODO: Send content-reject
|
||||||
|
}
|
||||||
|
};
|
||||||
|
descriptionManager.notifyContentListeners(content, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (acceptedContents.size() > 0) {
|
||||||
|
JingleElement accept = JingleElement.createContentAccept(getPeer(), getSessionId(), acceptedContents);
|
||||||
|
try {
|
||||||
|
getJingleManager().getConnection().createStanzaCollectorAndSend(accept).nextResultOrThrow();
|
||||||
|
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException | SmackException.NotConnectedException e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not send response to content-add: " + e, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: send content-reject for rejected contents!
|
||||||
|
|
||||||
|
return IQ.createResultIQ(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQ handleContentAccept(JingleElement request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FullJid getInitiator() {
|
||||||
|
return initiator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FullJid getResponder() {
|
||||||
|
return responder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FullJid getPeer() {
|
||||||
|
return role == Role.initiator ? responder : initiator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FullJid getOurJid() {
|
||||||
|
return role == Role.initiator ? initiator : responder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSessionId() {
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleManager getJingleManager() {
|
||||||
|
return jingleManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashMap<JingleContentElement, Content> getAffectedContents(JingleElement request) {
|
||||||
|
HashMap<JingleContentElement, Content> map = new HashMap<>();
|
||||||
|
for (JingleContentElement e : request.getContents()) {
|
||||||
|
Content c = contents.get(e.getName());
|
||||||
|
if (c == null) {
|
||||||
|
throw new AssertionError("Unknown content: " + e.getName());
|
||||||
|
}
|
||||||
|
map.put(e, c);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.internal;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportInfoElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.transport.BytestreamSessionEstablishedListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public abstract class Transport<D extends JingleContentTransportElement> {
|
||||||
|
|
||||||
|
public abstract D getElement();
|
||||||
|
|
||||||
|
public abstract String getNamespace();
|
||||||
|
|
||||||
|
public abstract BytestreamSession establishIncomingBytestreamSession(BytestreamSessionEstablishedListener listener);
|
||||||
|
|
||||||
|
public abstract BytestreamSession establishOutgoingBytestreamSession(BytestreamSessionEstablishedListener listener);
|
||||||
|
|
||||||
|
public abstract JingleElement handleTransportInfo(JingleContentTransportInfoElement info);
|
||||||
|
}
|
|
@ -14,18 +14,19 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.provider;
|
package org.jivesoftware.smackx.jingle3.provider;
|
||||||
|
|
||||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionElement;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
public abstract class JingleContentDescriptionProvider<D extends JingleContentDescription>
|
public abstract class JingleContentDescriptionProvider<D extends JingleContentDescriptionElement>
|
||||||
extends ExtensionElementProvider<D> {
|
extends ExtensionElementProvider<D> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract D parse(XmlPullParser parser, int initialDepth) throws Exception;
|
public abstract D parse(XmlPullParser parser, int initialDepth) throws Exception;
|
||||||
|
|
||||||
|
public abstract String getNamespace();
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.provider;
|
package org.jivesoftware.smackx.jingle3.provider;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.provider;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentSecurityElement;
|
||||||
|
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public abstract class JingleContentSecurityProvider<D extends JingleContentSecurityElement> extends ExtensionElementProvider<D> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract D parse(XmlPullParser parser, int initialDepth) throws Exception;
|
||||||
|
|
||||||
|
public abstract String getNamespace();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -14,18 +14,19 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.provider;
|
package org.jivesoftware.smackx.jingle3.provider;
|
||||||
|
|
||||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
public abstract class JingleContentTransportProvider<T extends JingleContentTransport>
|
public abstract class JingleContentTransportProvider<T extends JingleContentTransportElement>
|
||||||
extends ExtensionElementProvider<T> {
|
extends ExtensionElementProvider<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract T parse(XmlPullParser parser, int initialDepth) throws Exception;
|
public abstract T parse(XmlPullParser parser, int initialDepth) throws Exception;
|
||||||
|
|
||||||
|
public abstract String getNamespace();
|
||||||
}
|
}
|
|
@ -14,20 +14,20 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.provider;
|
package org.jivesoftware.smackx.jingle3.provider;
|
||||||
|
|
||||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleError;
|
import org.jivesoftware.smackx.jingle3.element.JingleErrorElement;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
public class JingleErrorProvider extends ExtensionElementProvider<JingleError> {
|
public class JingleErrorProvider extends ExtensionElementProvider<JingleErrorElement> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JingleError parse(XmlPullParser parser, int initialDepth) throws Exception {
|
public JingleErrorElement parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||||
String errorName = parser.getName();
|
String errorName = parser.getName();
|
||||||
return JingleError.fromString(errorName);
|
return JingleErrorElement.fromString(errorName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,45 +14,45 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.provider;
|
package org.jivesoftware.smackx.jingle3.provider;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.provider.IQProvider;
|
import org.jivesoftware.smack.provider.IQProvider;
|
||||||
import org.jivesoftware.smack.util.ParserUtils;
|
import org.jivesoftware.smack.util.ParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentDescriptionElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason.Reason;
|
import org.jivesoftware.smackx.jingle3.element.JingleReasonElement.Reason;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
public class JingleProvider extends IQProvider<Jingle> {
|
public class JingleProvider extends IQProvider<JingleElement> {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(JingleProvider.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(JingleProvider.class.getName());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Jingle parse(XmlPullParser parser, int initialDepth) throws Exception {
|
public JingleElement parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||||
Jingle.Builder builder = Jingle.getBuilder();
|
JingleElement.Builder builder = JingleElement.getBuilder();
|
||||||
|
|
||||||
String actionString = parser.getAttributeValue("", Jingle.ACTION_ATTRIBUTE_NAME);
|
String actionString = parser.getAttributeValue("", JingleElement.ACTION_ATTRIBUTE_NAME);
|
||||||
if (actionString != null) {
|
if (actionString != null) {
|
||||||
JingleAction action = JingleAction.fromString(actionString);
|
JingleAction action = JingleAction.fromString(actionString);
|
||||||
builder.setAction(action);
|
builder.setAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
FullJid initiator = ParserUtils.getFullJidAttribute(parser, Jingle.INITIATOR_ATTRIBUTE_NAME);
|
FullJid initiator = ParserUtils.getFullJidAttribute(parser, JingleElement.INITIATOR_ATTRIBUTE_NAME);
|
||||||
builder.setInitiator(initiator);
|
builder.setInitiator(initiator);
|
||||||
|
|
||||||
FullJid responder = ParserUtils.getFullJidAttribute(parser, Jingle.RESPONDER_ATTRIBUTE_NAME);
|
FullJid responder = ParserUtils.getFullJidAttribute(parser, JingleElement.RESPONDER_ATTRIBUTE_NAME);
|
||||||
builder.setResponder(responder);
|
builder.setResponder(responder);
|
||||||
|
|
||||||
String sessionId = parser.getAttributeValue("", Jingle.SESSION_ID_ATTRIBUTE_NAME);
|
String sessionId = parser.getAttributeValue("", JingleElement.SESSION_ID_ATTRIBUTE_NAME);
|
||||||
builder.setSessionId(sessionId);
|
builder.setSessionId(sessionId);
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,20 +62,20 @@ public class JingleProvider extends IQProvider<Jingle> {
|
||||||
case XmlPullParser.START_TAG:
|
case XmlPullParser.START_TAG:
|
||||||
String tagName = parser.getName();
|
String tagName = parser.getName();
|
||||||
switch (tagName) {
|
switch (tagName) {
|
||||||
case JingleContent.ELEMENT:
|
case JingleContentElement.ELEMENT:
|
||||||
JingleContent content = parseJingleContent(parser, parser.getDepth());
|
JingleContentElement content = parseJingleContent(parser, parser.getDepth());
|
||||||
builder.addJingleContent(content);
|
builder.addJingleContent(content);
|
||||||
break;
|
break;
|
||||||
case JingleReason.ELEMENT:
|
case JingleReasonElement.ELEMENT:
|
||||||
parser.next();
|
parser.next();
|
||||||
String reasonString = parser.getName();
|
String reasonString = parser.getName();
|
||||||
JingleReason reason;
|
JingleReasonElement reason;
|
||||||
if (reasonString.equals("alternative-session")) {
|
if (reasonString.equals("alternative-session")) {
|
||||||
parser.next();
|
parser.next();
|
||||||
String sid = parser.nextText();
|
String sid = parser.nextText();
|
||||||
reason = new JingleReason.AlternativeSession(sid);
|
reason = new JingleReasonElement.AlternativeSession(sid);
|
||||||
} else {
|
} else {
|
||||||
reason = new JingleReason(Reason.fromString(reasonString));
|
reason = new JingleReasonElement(Reason.fromString(reasonString));
|
||||||
}
|
}
|
||||||
builder.setReason(reason);
|
builder.setReason(reason);
|
||||||
break;
|
break;
|
||||||
|
@ -94,23 +94,23 @@ public class JingleProvider extends IQProvider<Jingle> {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JingleContent parseJingleContent(XmlPullParser parser, final int initialDepth)
|
public static JingleContentElement parseJingleContent(XmlPullParser parser, final int initialDepth)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
JingleContent.Builder builder = JingleContent.getBuilder();
|
JingleContentElement.Builder builder = JingleContentElement.getBuilder();
|
||||||
|
|
||||||
String creatorString = parser.getAttributeValue("", JingleContent.CREATOR_ATTRIBUTE_NAME);
|
String creatorString = parser.getAttributeValue("", JingleContentElement.CREATOR_ATTRIBUTE_NAME);
|
||||||
JingleContent.Creator creator = JingleContent.Creator.valueOf(creatorString);
|
JingleContentElement.Creator creator = JingleContentElement.Creator.valueOf(creatorString);
|
||||||
builder.setCreator(creator);
|
builder.setCreator(creator);
|
||||||
|
|
||||||
String disposition = parser.getAttributeValue("", JingleContent.DISPOSITION_ATTRIBUTE_NAME);
|
String disposition = parser.getAttributeValue("", JingleContentElement.DISPOSITION_ATTRIBUTE_NAME);
|
||||||
builder.setDisposition(disposition);
|
builder.setDisposition(disposition);
|
||||||
|
|
||||||
String name = parser.getAttributeValue("", JingleContent.NAME_ATTRIBUTE_NAME);
|
String name = parser.getAttributeValue("", JingleContentElement.NAME_ATTRIBUTE_NAME);
|
||||||
builder.setName(name);
|
builder.setName(name);
|
||||||
|
|
||||||
String sendersString = parser.getAttributeValue("", JingleContent.SENDERS_ATTRIBUTE_NAME);
|
String sendersString = parser.getAttributeValue("", JingleContentElement.SENDERS_ATTRIBUTE_NAME);
|
||||||
if (sendersString != null) {
|
if (sendersString != null) {
|
||||||
JingleContent.Senders senders = JingleContent.Senders.valueOf(sendersString);
|
JingleContentElement.Senders senders = JingleContentElement.Senders.valueOf(sendersString);
|
||||||
builder.setSenders(senders);
|
builder.setSenders(senders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,23 +121,23 @@ public class JingleProvider extends IQProvider<Jingle> {
|
||||||
String tagName = parser.getName();
|
String tagName = parser.getName();
|
||||||
String namespace = parser.getNamespace();
|
String namespace = parser.getNamespace();
|
||||||
switch (tagName) {
|
switch (tagName) {
|
||||||
case JingleContentDescription.ELEMENT: {
|
case JingleContentDescriptionElement.ELEMENT: {
|
||||||
JingleContentDescriptionProvider<?> provider = JingleContentProviderManager.getJingleContentDescriptionProvider(namespace);
|
JingleContentDescriptionProvider<?> provider = JingleContentProviderManager.getJingleContentDescriptionProvider(namespace);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
// TODO handle this case (DefaultExtensionElement wrapped in something?)
|
// TODO handle this case (DefaultExtensionElement wrapped in something?)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
JingleContentDescription description = provider.parse(parser);
|
JingleContentDescriptionElement description = provider.parse(parser);
|
||||||
builder.setDescription(description);
|
builder.setDescription(description);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JingleContentTransport.ELEMENT: {
|
case JingleContentTransportElement.ELEMENT: {
|
||||||
JingleContentTransportProvider<?> provider = JingleContentProviderManager.getJingleContentTransportProvider(namespace);
|
JingleContentTransportProvider<?> provider = JingleContentProviderManager.getJingleContentTransportProvider(namespace);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
// TODO handle this case (DefaultExtensionElement wrapped in something?)
|
// TODO handle this case (DefaultExtensionElement wrapped in something?)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
JingleContentTransport transport = provider.parse(parser);
|
JingleContentTransportElement transport = provider.parse(parser);
|
||||||
builder.setTransport(transport);
|
builder.setTransport(transport);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
|
@ -18,4 +18,4 @@
|
||||||
/**
|
/**
|
||||||
* Providers and parsers for <a href="https://xmpp.org/extensions/xep-0166.html">XEP-0166: Jingle</a>.
|
* Providers and parsers for <a href="https://xmpp.org/extensions/xep-0166.html">XEP-0166: Jingle</a>.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.provider;
|
package org.jivesoftware.smackx.jingle3.provider;
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.transport;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public interface BytestreamSessionEstablishedListener {
|
||||||
|
|
||||||
|
void onBytestreamSessionEstablished(BytestreamSession session);
|
||||||
|
|
||||||
|
void onBytestreamSessionFailed(Exception exception);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.transport.ibb;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.SmackException;
|
||||||
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
|
||||||
|
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
||||||
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
|
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
||||||
|
import org.jivesoftware.smackx.jingle3.internal.Session;
|
||||||
|
import org.jivesoftware.smackx.jingle3.internal.Transport;
|
||||||
|
import org.jivesoftware.smackx.jingle3.transport.BytestreamSessionEstablishedListener;
|
||||||
|
import org.jivesoftware.smackx.jingle3.transport.jingle_ibb.element.JingleIBBTransportElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public class JingleIBBTransport extends Transport<JingleIBBTransportElement> {
|
||||||
|
|
||||||
|
private final String streamId;
|
||||||
|
private final Short blockSize;
|
||||||
|
|
||||||
|
public JingleIBBTransport(String streamId, Short blockSize) {
|
||||||
|
this.streamId = streamId;
|
||||||
|
this.blockSize = blockSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JingleIBBTransport() {
|
||||||
|
this(StringUtils.randomString(10), JingleIBBTransportElement.DEFAULT_BLOCK_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JingleIBBTransportElement getElement() {
|
||||||
|
return new JingleIBBTransportElement(blockSize, streamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return JingleIBBTransportElement.NAMESPACE_V1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BytestreamSession establishIncomingBytestreamSession(final Session session) {
|
||||||
|
|
||||||
|
InBandBytestreamManager.getByteStreamManager(session.getJingleManager().getConnection())
|
||||||
|
.addIncomingBytestreamListener(new BytestreamListener() {
|
||||||
|
@Override
|
||||||
|
public void incomingBytestreamRequest(BytestreamRequest request) {
|
||||||
|
if (request.getFrom().asFullJidIfPossible().equals(session.getPeer())
|
||||||
|
&& request.getSessionID().equals(theirProposal.getSessionId())) {
|
||||||
|
BytestreamSession bytestreamSession;
|
||||||
|
|
||||||
|
try {
|
||||||
|
bytestreamSession = request.accept();
|
||||||
|
} catch (InterruptedException | SmackException | XMPPException.XMPPErrorException e) {
|
||||||
|
.onException(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback.onSessionInitiated(bytestreamSession);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BytestreamSession establishOutgoingBytestreamSession(BytestreamSessionEstablishedListener listener) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.jivesoftware.smackx.jingle3.transport.ibb;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle3.adapter.JingleTransportAdapter;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
|
import org.jivesoftware.smackx.jingle3.transport.jingle_ibb.element.JingleIBBTransportElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 18.07.17.
|
||||||
|
*/
|
||||||
|
public class JingleIBBTransportAdapter implements JingleTransportAdapter<JingleIBBTransport> {
|
||||||
|
@Override
|
||||||
|
public JingleIBBTransport transportFromElement(JingleContentTransportElement element) {
|
||||||
|
JingleIBBTransportElement transport = (JingleIBBTransportElement) element;
|
||||||
|
return new JingleIBBTransport(transport.getSessionId(), transport.getBlockSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return JingleIBBTransportElement.NAMESPACE_V1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,22 +14,22 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_ibb;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_ibb;
|
||||||
|
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentProviderManager;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_ibb.element.JingleIBBTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_ibb.provider.JingleIBBTransportProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager for Jingle InBandBytestream transports (XEP-0261).
|
* Manager for Jingle InBandBytestream transports (XEP-0261).
|
||||||
*/
|
*/
|
||||||
public final class JingleIBBTransportManager extends JingleTransportManager<JingleIBBTransport> {
|
public final class JingleIBBTransportManager extends JingleTransportManager<JingleIBBTransportElement> {
|
||||||
|
|
||||||
private static final WeakHashMap<XMPPConnection, JingleIBBTransportManager> INSTANCES = new WeakHashMap<>();
|
private static final WeakHashMap<XMPPConnection, JingleIBBTransportManager> INSTANCES = new WeakHashMap<>();
|
||||||
|
|
||||||
|
@ -49,11 +49,11 @@ public final class JingleIBBTransportManager extends JingleTransportManager<Jing
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
return JingleIBBTransport.NAMESPACE_V1;
|
return JingleIBBTransportElement.NAMESPACE_V1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JingleTransportSession<JingleIBBTransport> transportSession(JingleSession jingleSession) {
|
public JingleTransportSession<JingleIBBTransportElement> transportSession(JingleSession jingleSession) {
|
||||||
return new JingleIBBTransportSession(jingleSession);
|
return new JingleIBBTransportSession(jingleSession);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_ibb;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_ibb;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -27,14 +27,14 @@ import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_ibb.element.JingleIBBTransportElement;
|
||||||
|
|
||||||
public class JingleIBBTransportSession extends JingleTransportSession<JingleIBBTransport> {
|
public class JingleIBBTransportSession extends JingleTransportSession<JingleIBBTransportElement> {
|
||||||
private static final Logger LOGGER = Logger.getLogger(JingleIBBTransportSession.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(JingleIBBTransportSession.class.getName());
|
||||||
|
|
||||||
private final JingleIBBTransportManager transportManager;
|
private final JingleIBBTransportManager transportManager;
|
||||||
|
@ -45,19 +45,19 @@ public class JingleIBBTransportSession extends JingleTransportSession<JingleIBBT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JingleIBBTransport createTransport() {
|
public JingleIBBTransportElement createTransport() {
|
||||||
|
|
||||||
if (theirProposal == null) {
|
if (theirProposal == null) {
|
||||||
return new JingleIBBTransport();
|
return new JingleIBBTransportElement();
|
||||||
} else {
|
} else {
|
||||||
return new JingleIBBTransport(theirProposal.getBlockSize(), theirProposal.getSessionId());
|
return new JingleIBBTransportElement(theirProposal.getBlockSize(), theirProposal.getSessionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTheirProposal(JingleContentTransport transport) {
|
public void setTheirProposal(JingleContentTransportElement transport) {
|
||||||
theirProposal = (JingleIBBTransport) transport;
|
theirProposal = (JingleIBBTransportElement) transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,13 +103,13 @@ public class JingleIBBTransportSession extends JingleTransportSession<JingleIBBT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleTransportInfo(Jingle transportInfo) {
|
public IQ handleTransportInfo(JingleElement transportInfo) {
|
||||||
return IQ.createResultIQ(transportInfo);
|
return IQ.createResultIQ(transportInfo);
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JingleTransportManager<JingleIBBTransport> transportManager() {
|
public JingleTransportManager<JingleIBBTransportElement> transportManager() {
|
||||||
return JingleIBBTransportManager.getInstanceFor(jingleSession.getConnection());
|
return JingleIBBTransportManager.getInstanceFor(jingleSession.getConnection());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,17 +14,16 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_ibb.element;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_ibb.element;
|
||||||
|
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transport Element for JingleInBandBytestream transports.
|
* Transport Element for JingleInBandBytestream transports.
|
||||||
*/
|
*/
|
||||||
public class JingleIBBTransport extends JingleContentTransport {
|
public class JingleIBBTransportElement extends JingleContentTransportElement {
|
||||||
public static final String NAMESPACE_V1 = "urn:xmpp:jingle:transports:ibb:1";
|
public static final String NAMESPACE_V1 = "urn:xmpp:jingle:transports:ibb:1";
|
||||||
public static final String ATTR_BLOCK_SIZE = "block-size";
|
public static final String ATTR_BLOCK_SIZE = "block-size";
|
||||||
public static final String ATTR_SID = "sid";
|
public static final String ATTR_SID = "sid";
|
||||||
|
@ -34,25 +33,21 @@ public class JingleIBBTransport extends JingleContentTransport {
|
||||||
private final short blockSize;
|
private final short blockSize;
|
||||||
private final String sid;
|
private final String sid;
|
||||||
|
|
||||||
public JingleIBBTransport() {
|
public JingleIBBTransportElement() {
|
||||||
this(DEFAULT_BLOCK_SIZE);
|
this(DEFAULT_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleIBBTransport(String sid) {
|
public JingleIBBTransportElement(String sid) {
|
||||||
this(DEFAULT_BLOCK_SIZE, sid);
|
this(DEFAULT_BLOCK_SIZE, sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleIBBTransport(short blockSize) {
|
public JingleIBBTransportElement(Short blockSize) {
|
||||||
this(blockSize, StringUtils.randomString(24));
|
this(blockSize, StringUtils.randomString(24));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleIBBTransport(short blockSize, String sid) {
|
public JingleIBBTransportElement(Short blockSize, String sid) {
|
||||||
super(null);
|
super(null);
|
||||||
if (blockSize > 0) {
|
this.blockSize = blockSize != null ? blockSize : DEFAULT_BLOCK_SIZE;
|
||||||
this.blockSize = blockSize;
|
|
||||||
} else {
|
|
||||||
this.blockSize = DEFAULT_BLOCK_SIZE;
|
|
||||||
}
|
|
||||||
this.sid = sid;
|
this.sid = sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +72,7 @@ public class JingleIBBTransport extends JingleContentTransport {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other == null || !(other instanceof JingleIBBTransport)) {
|
if (other == null || !(other instanceof JingleIBBTransportElement)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,4 @@
|
||||||
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
|
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
|
||||||
* Element classes.
|
* Element classes.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_ibb.element;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_ibb.element;
|
|
@ -18,4 +18,4 @@
|
||||||
/**
|
/**
|
||||||
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
|
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_ibb;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_ibb;
|
|
@ -14,27 +14,27 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_ibb.provider;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
|
import org.jivesoftware.smack.util.ParserUtils;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentTransportProvider;
|
||||||
|
import org.jivesoftware.smackx.jingle3.transport.jingle_ibb.element.JingleIBBTransportElement;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse JingleByteStreamTransport elements.
|
* Parse JingleByteStreamTransport elements.
|
||||||
*/
|
*/
|
||||||
public class JingleIBBTransportProvider extends JingleContentTransportProvider<JingleIBBTransport> {
|
public class JingleIBBTransportProvider extends JingleContentTransportProvider <JingleIBBTransportElement> {
|
||||||
@Override
|
@Override
|
||||||
public JingleIBBTransport parse(XmlPullParser parser, int initialDepth) throws Exception {
|
public JingleIBBTransportElement parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||||
String blockSizeString = parser.getAttributeValue(null, JingleIBBTransport.ATTR_BLOCK_SIZE);
|
Short blockSize = ParserUtils.getShortAttribute(parser, JingleIBBTransportElement.ATTR_BLOCK_SIZE);
|
||||||
String sid = parser.getAttributeValue(null, JingleIBBTransport.ATTR_SID);
|
String sid = parser.getAttributeValue(null, JingleIBBTransportElement.ATTR_SID);
|
||||||
|
return new JingleIBBTransportElement(blockSize, sid);
|
||||||
short blockSize = -1;
|
|
||||||
if (blockSizeString != null) {
|
|
||||||
blockSize = Short.valueOf(blockSizeString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new JingleIBBTransport(blockSize, sid);
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return JingleIBBTransportElement.NAMESPACE_V1;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,4 +19,4 @@
|
||||||
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
|
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
|
||||||
* Provider classes.
|
* Provider classes.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_ibb.provider;
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_s5b;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -31,14 +31,14 @@ import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy;
|
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentProviderManager;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransport;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.provider.JingleS5BTransportProvider;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.provider.JingleS5BTransportProvider;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
|
@ -144,73 +144,73 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jingle createCandidateUsed(FullJid recipient, FullJid initiator, String sessionId, JingleContent.Senders contentSenders,
|
public JingleElement createCandidateUsed(FullJid recipient, FullJid initiator, String sessionId, JingleContentElement.Senders contentSenders,
|
||||||
JingleContent.Creator contentCreator, String contentName, String streamId,
|
JingleContentElement.Creator contentCreator, String contentName, String streamId,
|
||||||
String candidateId) {
|
String candidateId) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);
|
jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);
|
||||||
|
|
||||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
cb.setName(contentName).setCreator(contentCreator).setSenders(contentSenders);
|
cb.setName(contentName).setCreator(contentCreator).setSenders(contentSenders);
|
||||||
|
|
||||||
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
||||||
tb.setCandidateUsed(candidateId).setStreamId(streamId);
|
tb.setCandidateUsed(candidateId).setStreamId(streamId);
|
||||||
|
|
||||||
Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
|
JingleElement jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
|
||||||
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
||||||
jingle.setTo(recipient);
|
jingle.setTo(recipient);
|
||||||
|
|
||||||
return jingle;
|
return jingle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jingle createCandidateError(FullJid remote, FullJid initiator, String sessionId, JingleContent.Senders senders, JingleContent.Creator creator, String name, String streamId) {
|
public JingleElement createCandidateError(FullJid remote, FullJid initiator, String sessionId, JingleContentElement.Senders senders, JingleContentElement.Creator creator, String name, String streamId) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);
|
jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);
|
||||||
|
|
||||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
cb.setName(name).setCreator(creator).setSenders(senders);
|
cb.setName(name).setCreator(creator).setSenders(senders);
|
||||||
|
|
||||||
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
||||||
tb.setCandidateError().setStreamId(streamId);
|
tb.setCandidateError().setStreamId(streamId);
|
||||||
|
|
||||||
Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
|
JingleElement jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
|
||||||
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
||||||
jingle.setTo(remote);
|
jingle.setTo(remote);
|
||||||
|
|
||||||
return jingle;
|
return jingle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jingle createProxyError(FullJid remote, FullJid initiator, String sessionId,
|
public JingleElement createProxyError(FullJid remote, FullJid initiator, String sessionId,
|
||||||
JingleContent.Senders senders, JingleContent.Creator creator,
|
JingleContentElement.Senders senders, JingleContentElement.Creator creator,
|
||||||
String name, String streamId) {
|
String name, String streamId) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setSessionId(sessionId).setAction(JingleAction.transport_info).setInitiator(initiator);
|
jb.setSessionId(sessionId).setAction(JingleAction.transport_info).setInitiator(initiator);
|
||||||
|
|
||||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
cb.setSenders(senders).setCreator(creator).setName(name);
|
cb.setSenders(senders).setCreator(creator).setName(name);
|
||||||
|
|
||||||
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
||||||
tb.setStreamId(sessionId).setProxyError().setStreamId(streamId);
|
tb.setStreamId(sessionId).setProxyError().setStreamId(streamId);
|
||||||
|
|
||||||
Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
|
JingleElement jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
|
||||||
jingle.setTo(remote);
|
jingle.setTo(remote);
|
||||||
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
||||||
return jingle;
|
return jingle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jingle createCandidateActivated(FullJid remote, FullJid initiator, String sessionId,
|
public JingleElement createCandidateActivated(FullJid remote, FullJid initiator, String sessionId,
|
||||||
JingleContent.Senders senders, JingleContent.Creator creator,
|
JingleContentElement.Senders senders, JingleContentElement.Creator creator,
|
||||||
String name, String streamId, String candidateId) {
|
String name, String streamId, String candidateId) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
JingleElement.Builder jb = JingleElement.getBuilder();
|
||||||
jb.setInitiator(initiator).setSessionId(sessionId).setAction(JingleAction.transport_info);
|
jb.setInitiator(initiator).setSessionId(sessionId).setAction(JingleAction.transport_info);
|
||||||
|
|
||||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
JingleContentElement.Builder cb = JingleContentElement.getBuilder();
|
||||||
cb.setName(name).setCreator(creator).setSenders(senders);
|
cb.setName(name).setCreator(creator).setSenders(senders);
|
||||||
|
|
||||||
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
||||||
tb.setStreamId(streamId).setCandidateActivated(candidateId);
|
tb.setStreamId(streamId).setCandidateActivated(candidateId);
|
||||||
|
|
||||||
Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
|
JingleElement jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
|
||||||
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
||||||
jingle.setTo(remote);
|
jingle.setTo(remote);
|
||||||
return jingle;
|
return jingle;
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_s5b;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
@ -35,15 +35,15 @@ import org.jivesoftware.smackx.bytestreams.socks5.Socks5Utils;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidate;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportCandidateElement;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback;
|
||||||
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
import org.jivesoftware.smackx.jingle.transports.JingleTransportSession;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransport;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportCandidate;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportInfo;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler that handles Jingle Socks5Bytestream transports (XEP-0260).
|
* Handler that handles Jingle Socks5Bytestream transports (XEP-0260).
|
||||||
|
@ -68,7 +68,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTheirProposal(JingleContentTransport transport) {
|
public void setTheirProposal(JingleContentTransportElement transport) {
|
||||||
theirProposal = (JingleS5BTransport) transport;
|
theirProposal = (JingleS5BTransport) transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
return jb.build();
|
return jb.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTheirTransport(JingleContentTransport transport) {
|
public void setTheirTransport(JingleContentTransportElement transport) {
|
||||||
theirProposal = (JingleS5BTransport) transport;
|
theirProposal = (JingleS5BTransport) transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,11 +118,11 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
|
|
||||||
private void initiateSession() {
|
private void initiateSession() {
|
||||||
Socks5Proxy.getSocks5Proxy().addTransfer(createTransport().getDestinationAddress());
|
Socks5Proxy.getSocks5Proxy().addTransfer(createTransport().getDestinationAddress());
|
||||||
JingleContent content = jingleSession.getContents().get(0);
|
JingleContentElement content = jingleSession.getContents().get(0);
|
||||||
UsedCandidate usedCandidate = chooseFromProposedCandidates(theirProposal);
|
UsedCandidate usedCandidate = chooseFromProposedCandidates(theirProposal);
|
||||||
if (usedCandidate == null) {
|
if (usedCandidate == null) {
|
||||||
ourChoice = CANDIDATE_FAILURE;
|
ourChoice = CANDIDATE_FAILURE;
|
||||||
Jingle candidateError = transportManager().createCandidateError(
|
JingleElement candidateError = transportManager().createCandidateError(
|
||||||
jingleSession.getRemote(), jingleSession.getInitiator(), jingleSession.getSessionId(),
|
jingleSession.getRemote(), jingleSession.getInitiator(), jingleSession.getSessionId(),
|
||||||
content.getSenders(), content.getCreator(), content.getName(), theirProposal.getStreamId());
|
content.getSenders(), content.getCreator(), content.getName(), theirProposal.getStreamId());
|
||||||
try {
|
try {
|
||||||
|
@ -132,7 +132,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ourChoice = usedCandidate;
|
ourChoice = usedCandidate;
|
||||||
Jingle jingle = transportManager().createCandidateUsed(jingleSession.getRemote(), jingleSession.getInitiator(), jingleSession.getSessionId(),
|
JingleElement jingle = transportManager().createCandidateUsed(jingleSession.getRemote(), jingleSession.getInitiator(), jingleSession.getSessionId(),
|
||||||
content.getSenders(), content.getCreator(), content.getName(), theirProposal.getStreamId(), ourChoice.candidate.getCandidateId());
|
content.getSenders(), content.getCreator(), content.getName(), theirProposal.getStreamId(), ourChoice.candidate.getCandidateId());
|
||||||
try {
|
try {
|
||||||
jingleSession.getConnection().createStanzaCollectorAndSend(jingle)
|
jingleSession.getConnection().createStanzaCollectorAndSend(jingle)
|
||||||
|
@ -145,7 +145,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
}
|
}
|
||||||
|
|
||||||
private UsedCandidate chooseFromProposedCandidates(JingleS5BTransport proposal) {
|
private UsedCandidate chooseFromProposedCandidates(JingleS5BTransport proposal) {
|
||||||
for (JingleContentTransportCandidate c : proposal.getCandidates()) {
|
for (JingleContentTransportCandidateElement c : proposal.getCandidates()) {
|
||||||
JingleS5BTransportCandidate candidate = (JingleS5BTransportCandidate) c;
|
JingleS5BTransportCandidate candidate = (JingleS5BTransportCandidate) c;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -188,7 +188,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleTransportInfo(Jingle transportInfo) {
|
public IQ handleTransportInfo(JingleElement transportInfo) {
|
||||||
JingleS5BTransportInfo info = (JingleS5BTransportInfo) transportInfo.getContents().get(0).getTransport().getInfo();
|
JingleS5BTransportInfo info = (JingleS5BTransportInfo) transportInfo.getContents().get(0).getTransport().getInfo();
|
||||||
|
|
||||||
switch (info.getElementName()) {
|
switch (info.getElementName()) {
|
||||||
|
@ -208,7 +208,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
return IQ.createResultIQ(transportInfo);
|
return IQ.createResultIQ(transportInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQ handleCandidateUsed(Jingle jingle) {
|
public IQ handleCandidateUsed(JingleElement jingle) {
|
||||||
JingleS5BTransportInfo info = (JingleS5BTransportInfo) jingle.getContents().get(0).getTransport().getInfo();
|
JingleS5BTransportInfo info = (JingleS5BTransportInfo) jingle.getContents().get(0).getTransport().getInfo();
|
||||||
String candidateId = ((JingleS5BTransportInfo.CandidateUsed) info).getCandidateId();
|
String candidateId = ((JingleS5BTransportInfo.CandidateUsed) info).getCandidateId();
|
||||||
theirChoice = new UsedCandidate(ourProposal, ourProposal.getCandidate(candidateId), null);
|
theirChoice = new UsedCandidate(ourProposal, ourProposal.getCandidate(candidateId), null);
|
||||||
|
@ -224,7 +224,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
return IQ.createResultIQ(jingle);
|
return IQ.createResultIQ(jingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQ handleCandidateActivate(Jingle jingle) {
|
public IQ handleCandidateActivate(JingleElement jingle) {
|
||||||
LOGGER.log(Level.INFO, "handleCandidateActivate");
|
LOGGER.log(Level.INFO, "handleCandidateActivate");
|
||||||
Socks5BytestreamSession bs = new Socks5BytestreamSession(ourChoice.socket,
|
Socks5BytestreamSession bs = new Socks5BytestreamSession(ourChoice.socket,
|
||||||
ourChoice.candidate.getJid().asBareJid().equals(jingleSession.getRemote().asBareJid()));
|
ourChoice.candidate.getJid().asBareJid().equals(jingleSession.getRemote().asBareJid()));
|
||||||
|
@ -232,13 +232,13 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
return IQ.createResultIQ(jingle);
|
return IQ.createResultIQ(jingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQ handleCandidateError(Jingle jingle) {
|
public IQ handleCandidateError(JingleElement jingle) {
|
||||||
theirChoice = CANDIDATE_FAILURE;
|
theirChoice = CANDIDATE_FAILURE;
|
||||||
connectIfReady();
|
connectIfReady();
|
||||||
return IQ.createResultIQ(jingle);
|
return IQ.createResultIQ(jingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQ handleProxyError(Jingle jingle) {
|
public IQ handleProxyError(JingleElement jingle) {
|
||||||
//TODO
|
//TODO
|
||||||
return IQ.createResultIQ(jingle);
|
return IQ.createResultIQ(jingle);
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
* If it is not a proxy, just connect.
|
* If it is not a proxy, just connect.
|
||||||
*/
|
*/
|
||||||
private void connectIfReady() {
|
private void connectIfReady() {
|
||||||
JingleContent content = jingleSession.getContents().get(0);
|
JingleContentElement content = jingleSession.getContents().get(0);
|
||||||
if (ourChoice == null || theirChoice == null) {
|
if (ourChoice == null || theirChoice == null) {
|
||||||
// Not yet ready.
|
// Not yet ready.
|
||||||
LOGGER.log(Level.INFO, "Not ready.");
|
LOGGER.log(Level.INFO, "Not ready.");
|
||||||
|
@ -308,7 +308,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.log(Level.INFO, "Send candidate-activate.");
|
LOGGER.log(Level.INFO, "Send candidate-activate.");
|
||||||
Jingle candidateActivate = transportManager().createCandidateActivated(
|
JingleElement candidateActivate = transportManager().createCandidateActivated(
|
||||||
jingleSession.getRemote(), jingleSession.getInitiator(), jingleSession.getSessionId(),
|
jingleSession.getRemote(), jingleSession.getInitiator(), jingleSession.getSessionId(),
|
||||||
content.getSenders(), content.getCreator(), content.getName(), nominated.transport.getStreamId(),
|
content.getSenders(), content.getCreator(), content.getName(), nominated.transport.getStreamId(),
|
||||||
nominated.candidate.getCandidateId());
|
nominated.candidate.getCandidateId());
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -22,14 +22,14 @@ import java.util.List;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidate;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportCandidateElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfo;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportInfoElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Socks5Bytestream transport element.
|
* Socks5Bytestream transport element.
|
||||||
*/
|
*/
|
||||||
public class JingleS5BTransport extends JingleContentTransport {
|
public class JingleS5BTransport extends JingleContentTransportElement {
|
||||||
public static final String NAMESPACE_V1 = "urn:xmpp:jingle:transports:s5b:1";
|
public static final String NAMESPACE_V1 = "urn:xmpp:jingle:transports:s5b:1";
|
||||||
public static final String ATTR_DSTADDR = "dstaddr";
|
public static final String ATTR_DSTADDR = "dstaddr";
|
||||||
public static final String ATTR_MODE = "mode";
|
public static final String ATTR_MODE = "mode";
|
||||||
|
@ -39,7 +39,7 @@ public class JingleS5BTransport extends JingleContentTransport {
|
||||||
private final String dstAddr;
|
private final String dstAddr;
|
||||||
private final Bytestream.Mode mode;
|
private final Bytestream.Mode mode;
|
||||||
|
|
||||||
protected JingleS5BTransport(List<JingleContentTransportCandidate> candidates, JingleContentTransportInfo info, String streamId, String dstAddr, Bytestream.Mode mode) {
|
protected JingleS5BTransport(List<JingleContentTransportCandidateElement> candidates, JingleContentTransportInfoElement info, String streamId, String dstAddr, Bytestream.Mode mode) {
|
||||||
super(candidates, info);
|
super(candidates, info);
|
||||||
StringUtils.requireNotNullOrEmpty(streamId, "sid MUST be neither null, nor empty.");
|
StringUtils.requireNotNullOrEmpty(streamId, "sid MUST be neither null, nor empty.");
|
||||||
this.streamId = streamId;
|
this.streamId = streamId;
|
||||||
|
@ -76,7 +76,7 @@ public class JingleS5BTransport extends JingleContentTransport {
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleS5BTransportCandidate getCandidate(String candidateId) {
|
public JingleS5BTransportCandidate getCandidate(String candidateId) {
|
||||||
for (JingleContentTransportCandidate c : candidates) {
|
for (JingleContentTransportCandidateElement c : candidates) {
|
||||||
JingleS5BTransportCandidate candidate = (JingleS5BTransportCandidate) c;
|
JingleS5BTransportCandidate candidate = (JingleS5BTransportCandidate) c;
|
||||||
if (candidate.getCandidateId().equals(candidateId)) {
|
if (candidate.getCandidateId().equals(candidateId)) {
|
||||||
return candidate;
|
return candidate;
|
||||||
|
@ -93,8 +93,8 @@ public class JingleS5BTransport extends JingleContentTransport {
|
||||||
private String streamId;
|
private String streamId;
|
||||||
private String dstAddr;
|
private String dstAddr;
|
||||||
private Bytestream.Mode mode;
|
private Bytestream.Mode mode;
|
||||||
private final ArrayList<JingleContentTransportCandidate> candidates = new ArrayList<>();
|
private final ArrayList<JingleContentTransportCandidateElement> candidates = new ArrayList<>();
|
||||||
private JingleContentTransportInfo info;
|
private JingleContentTransportInfoElement info;
|
||||||
|
|
||||||
public Builder setStreamId(String sid) {
|
public Builder setStreamId(String sid) {
|
||||||
this.streamId = sid;
|
this.streamId = sid;
|
||||||
|
@ -120,7 +120,7 @@ public class JingleS5BTransport extends JingleContentTransport {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setTransportInfo(JingleContentTransportInfo info) {
|
public Builder setTransportInfo(JingleContentTransportInfoElement info) {
|
||||||
if (!candidates.isEmpty()) {
|
if (!candidates.isEmpty()) {
|
||||||
throw new IllegalStateException("Builder has already at least one candidate set. " +
|
throw new IllegalStateException("Builder has already at least one candidate set. " +
|
||||||
"The transport can only have either an info or transport candidates, not both.");
|
"The transport can only have either an info or transport candidates, not both.");
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import org.jivesoftware.smack.util.Objects;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidate;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportCandidateElement;
|
||||||
|
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
import org.jxmpp.jid.impl.JidCreate;
|
import org.jxmpp.jid.impl.JidCreate;
|
||||||
|
@ -31,7 +31,7 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
/**
|
/**
|
||||||
* TransportCandidate for Jingle Socks5Bytestream transports.
|
* TransportCandidate for Jingle Socks5Bytestream transports.
|
||||||
*/
|
*/
|
||||||
public final class JingleS5BTransportCandidate extends JingleContentTransportCandidate {
|
public final class JingleS5BTransportCandidate extends JingleContentTransportCandidateElement {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(JingleS5BTransportCandidate.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(JingleS5BTransportCandidate.class.getName());
|
||||||
|
|
|
@ -14,15 +14,15 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements;
|
||||||
|
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfo;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportInfoElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing possible SOCKS5 TransportInfo elements.
|
* Class representing possible SOCKS5 TransportInfo elements.
|
||||||
*/
|
*/
|
||||||
public abstract class JingleS5BTransportInfo extends JingleContentTransportInfo {
|
public abstract class JingleS5BTransportInfo extends JingleContentTransportInfoElement {
|
||||||
|
|
||||||
private static CandidateError CEI;
|
private static CandidateError CEI;
|
||||||
private static ProxyError PEI;
|
private static ProxyError PEI;
|
|
@ -19,4 +19,4 @@
|
||||||
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0260: Jingle SOCKS5 Bytestreams</a>.
|
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0260: Jingle SOCKS5 Bytestreams</a>.
|
||||||
* Element classes.
|
* Element classes.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements;
|
|
@ -18,4 +18,4 @@
|
||||||
/**
|
/**
|
||||||
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0260: Jingle SOCKS5 Bytestreams</a>.
|
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0260: Jingle SOCKS5 Bytestreams</a>.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_s5b;
|
|
@ -14,24 +14,24 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b.provider;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_s5b.provider;
|
||||||
|
|
||||||
import static org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.Mode.tcp;
|
import static org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.Mode.tcp;
|
||||||
import static org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.Mode.udp;
|
import static org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.Mode.udp;
|
||||||
import static org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_CID;
|
import static org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_CID;
|
||||||
import static org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_HOST;
|
import static org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_HOST;
|
||||||
import static org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_JID;
|
import static org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_JID;
|
||||||
import static org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_PORT;
|
import static org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_PORT;
|
||||||
import static org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_PRIORITY;
|
import static org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_PRIORITY;
|
||||||
import static org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_TYPE;
|
import static org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportCandidate.ATTR_TYPE;
|
||||||
import static org.xmlpull.v1.XmlPullParser.END_TAG;
|
import static org.xmlpull.v1.XmlPullParser.END_TAG;
|
||||||
import static org.xmlpull.v1.XmlPullParser.START_TAG;
|
import static org.xmlpull.v1.XmlPullParser.START_TAG;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentTransportProvider;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransport;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportCandidate;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportInfo;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransportInfo;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public class JingleS5BTransportProvider extends JingleContentTransportProvider<J
|
||||||
|
|
||||||
case END_TAG: {
|
case END_TAG: {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case JingleContentTransport.ELEMENT:
|
case JingleContentTransportElement.ELEMENT:
|
||||||
break outerloop;
|
break outerloop;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,4 +19,4 @@
|
||||||
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0260: Jingle SOCKS5 Bytestreams</a>.
|
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0260: Jingle SOCKS5 Bytestreams</a>.
|
||||||
* Provider classes.
|
* Provider classes.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b.provider;
|
package org.jivesoftware.smackx.jingle3.transport.jingle_s5b.provider;
|
|
@ -548,31 +548,31 @@
|
||||||
<iqProvider>
|
<iqProvider>
|
||||||
<elementName>jingle</elementName>
|
<elementName>jingle</elementName>
|
||||||
<namespace>urn:xmpp:jingle:1</namespace>
|
<namespace>urn:xmpp:jingle:1</namespace>
|
||||||
<className>org.jivesoftware.smackx.jingle.provider.JingleProvider</className>
|
<className>org.jivesoftware.smackx.jingle3.provider.JingleProvider</className>
|
||||||
</iqProvider>
|
</iqProvider>
|
||||||
|
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>out-of-order</elementName>
|
<elementName>out-of-order</elementName>
|
||||||
<namespace>urn:xmpp:jingle:errors:1</namespace>
|
<namespace>urn:xmpp:jingle:errors:1</namespace>
|
||||||
<className>org.jivesoftware.smackx.jingle.provider.JingleErrorProvider</className>
|
<className>org.jivesoftware.smackx.jingle3.provider.JingleErrorProvider</className>
|
||||||
</extensionProvider>
|
</extensionProvider>
|
||||||
|
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>unknown-session</elementName>
|
<elementName>unknown-session</elementName>
|
||||||
<namespace>urn:xmpp:jingle:errors:1</namespace>
|
<namespace>urn:xmpp:jingle:errors:1</namespace>
|
||||||
<className>org.jivesoftware.smackx.jingle.provider.JingleErrorProvider</className>
|
<className>org.jivesoftware.smackx.jingle3.provider.JingleErrorProvider</className>
|
||||||
</extensionProvider>
|
</extensionProvider>
|
||||||
|
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>unsupported-content</elementName>
|
<elementName>unsupported-content</elementName>
|
||||||
<namespace>urn:xmpp:jingle:errors:1</namespace>
|
<namespace>urn:xmpp:jingle:errors:1</namespace>
|
||||||
<className>org.jivesoftware.smackx.jingle.provider.JingleErrorProvider</className>
|
<className>org.jivesoftware.smackx.jingle3.provider.JingleErrorProvider</className>
|
||||||
</extensionProvider>
|
</extensionProvider>
|
||||||
|
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>unsupported-transports</elementName>
|
<elementName>unsupported-transports</elementName>
|
||||||
<namespace>urn:xmpp:jingle:errors:1</namespace>
|
<namespace>urn:xmpp:jingle:errors:1</namespace>
|
||||||
<className>org.jivesoftware.smackx.jingle.provider.JingleErrorProvider</className>
|
<className>org.jivesoftware.smackx.jingle3.provider.JingleErrorProvider</className>
|
||||||
</extensionProvider>
|
</extensionProvider>
|
||||||
|
|
||||||
</smackProviders>
|
</smackProviders>
|
||||||
|
|
|
@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -22,48 +22,48 @@ import static junit.framework.TestCase.assertNotSame;
|
||||||
import static junit.framework.TestCase.assertNull;
|
import static junit.framework.TestCase.assertNull;
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle3.element.JingleContentElement;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the JingleContent class.
|
* Test the JingleContent class.
|
||||||
*/
|
*/
|
||||||
public class JingleContentTest extends SmackTestSuite {
|
public class JingleContentElementTest extends SmackTestSuite {
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
public void emptyBuilderThrowsTest() {
|
public void emptyBuilderThrowsTest() {
|
||||||
JingleContent.Builder builder = JingleContent.getBuilder();
|
JingleContentElement.Builder builder = JingleContentElement.getBuilder();
|
||||||
builder.build();
|
builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void onlyCreatorBuilderThrowsTest() {
|
public void onlyCreatorBuilderThrowsTest() {
|
||||||
JingleContent.Builder builder = JingleContent.getBuilder();
|
JingleContentElement.Builder builder = JingleContentElement.getBuilder();
|
||||||
builder.setCreator(JingleContent.Creator.initiator);
|
builder.setCreator(JingleContentElement.Creator.initiator);
|
||||||
builder.build();
|
builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parserTest() throws Exception {
|
public void parserTest() throws Exception {
|
||||||
|
|
||||||
JingleContent.Builder builder = JingleContent.getBuilder();
|
JingleContentElement.Builder builder = JingleContentElement.getBuilder();
|
||||||
|
|
||||||
builder.setCreator(JingleContent.Creator.initiator);
|
builder.setCreator(JingleContentElement.Creator.initiator);
|
||||||
builder.setName("A name");
|
builder.setName("A name");
|
||||||
|
|
||||||
JingleContent content = builder.build();
|
JingleContentElement content = builder.build();
|
||||||
assertNotNull(content);
|
assertNotNull(content);
|
||||||
assertNull(content.getDescription());
|
assertNull(content.getDescription());
|
||||||
assertEquals(JingleContent.Creator.initiator, content.getCreator());
|
assertEquals(JingleContentElement.Creator.initiator, content.getCreator());
|
||||||
assertEquals("A name", content.getName());
|
assertEquals("A name", content.getName());
|
||||||
|
|
||||||
builder.setSenders(JingleContent.Senders.both);
|
builder.setSenders(JingleContentElement.Senders.both);
|
||||||
content = builder.build();
|
content = builder.build();
|
||||||
assertEquals(JingleContent.Senders.both, content.getSenders());
|
assertEquals(JingleContentElement.Senders.both, content.getSenders());
|
||||||
|
|
||||||
builder.setDisposition("session");
|
builder.setDisposition("session");
|
||||||
JingleContent content1 = builder.build();
|
JingleContentElement content1 = builder.build();
|
||||||
assertEquals("session", content1.getDisposition());
|
assertEquals("session", content1.getDisposition());
|
||||||
assertNotSame(content.toXML().toString(), content1.toXML().toString());
|
assertNotSame(content.toXML().toString(), content1.toXML().toString());
|
||||||
assertEquals(content1.toXML().toString(), builder.build().toXML().toString());
|
assertEquals(content1.toXML().toString(), builder.build().toXML().toString());
|
|
@ -20,11 +20,11 @@ import static junit.framework.TestCase.assertEquals;
|
||||||
import static junit.framework.TestCase.assertNull;
|
import static junit.framework.TestCase.assertNull;
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
import org.jivesoftware.smackx.jingle3.provider.JingleContentProviderManager;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider;
|
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.elements.JingleS5BTransport;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.provider.JingleS5BTransportProvider;
|
import org.jivesoftware.smackx.jingle3.transport.jingle_s5b.provider.JingleS5BTransportProvider;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ import static junit.framework.TestCase.assertTrue;
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle3.element.JingleAction;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
@ -33,11 +33,11 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
/**
|
/**
|
||||||
* Test the Jingle class.
|
* Test the Jingle class.
|
||||||
*/
|
*/
|
||||||
public class JingleTest extends SmackTestSuite {
|
public class JingleElementTest extends SmackTestSuite {
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void emptyBuilderTest() {
|
public void emptyBuilderTest() {
|
||||||
Jingle.Builder builder = Jingle.getBuilder();
|
JingleElement.Builder builder = JingleElement.getBuilder();
|
||||||
builder.build();
|
builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class JingleTest extends SmackTestSuite {
|
||||||
public void onlySessionIdBuilderTest() {
|
public void onlySessionIdBuilderTest() {
|
||||||
String sessionId = "testSessionId";
|
String sessionId = "testSessionId";
|
||||||
|
|
||||||
Jingle.Builder builder = Jingle.getBuilder();
|
JingleElement.Builder builder = JingleElement.getBuilder();
|
||||||
builder.setSessionId(sessionId);
|
builder.setSessionId(sessionId);
|
||||||
builder.build();
|
builder.build();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class JingleTest extends SmackTestSuite {
|
||||||
public void parserTest() throws XmppStringprepException {
|
public void parserTest() throws XmppStringprepException {
|
||||||
String sessionId = "testSessionId";
|
String sessionId = "testSessionId";
|
||||||
|
|
||||||
Jingle.Builder builder = Jingle.getBuilder();
|
JingleElement.Builder builder = JingleElement.getBuilder();
|
||||||
builder.setSessionId(sessionId);
|
builder.setSessionId(sessionId);
|
||||||
builder.setAction(JingleAction.session_initiate);
|
builder.setAction(JingleAction.session_initiate);
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class JingleTest extends SmackTestSuite {
|
||||||
builder.setInitiator(romeo);
|
builder.setInitiator(romeo);
|
||||||
builder.setResponder(juliet);
|
builder.setResponder(juliet);
|
||||||
|
|
||||||
Jingle jingle = builder.build();
|
JingleElement jingle = builder.build();
|
||||||
assertNotNull(jingle);
|
assertNotNull(jingle);
|
||||||
assertEquals(romeo, jingle.getInitiator());
|
assertEquals(romeo, jingle.getInitiator());
|
||||||
assertEquals(juliet, jingle.getResponder());
|
assertEquals(juliet, jingle.getResponder());
|
|
@ -20,47 +20,47 @@ import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
import org.jivesoftware.smack.test.util.TestUtils;
|
import org.jivesoftware.smack.test.util.TestUtils;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleError;
|
import org.jivesoftware.smackx.jingle3.element.JingleErrorElement;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleErrorProvider;
|
import org.jivesoftware.smackx.jingle3.provider.JingleErrorProvider;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the JingleError class.
|
* Test the JingleError class.
|
||||||
*/
|
*/
|
||||||
public class JingleErrorTest extends SmackTestSuite {
|
public class JingleErrorElementTest extends SmackTestSuite {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tieBreakTest() throws Exception {
|
public void tieBreakTest() throws Exception {
|
||||||
String xml = "<tie-break xmlns='urn:xmpp:jingle:errors:1'/>";
|
String xml = "<tie-break xmlns='urn:xmpp:jingle:errors:1'/>";
|
||||||
JingleError error = new JingleErrorProvider().parse(TestUtils.getParser(xml));
|
JingleErrorElement error = new JingleErrorProvider().parse(TestUtils.getParser(xml));
|
||||||
assertEquals(xml, error.toXML().toString());
|
assertEquals(xml, error.toXML().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unknownSessionTest() throws Exception {
|
public void unknownSessionTest() throws Exception {
|
||||||
String xml = "<unknown-session xmlns='urn:xmpp:jingle:errors:1'/>";
|
String xml = "<unknown-session xmlns='urn:xmpp:jingle:errors:1'/>";
|
||||||
JingleError error = new JingleErrorProvider().parse(TestUtils.getParser(xml));
|
JingleErrorElement error = new JingleErrorProvider().parse(TestUtils.getParser(xml));
|
||||||
assertEquals(xml, error.toXML().toString());
|
assertEquals(xml, error.toXML().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unsupportedInfoTest() throws Exception {
|
public void unsupportedInfoTest() throws Exception {
|
||||||
String xml = "<unsupported-info xmlns='urn:xmpp:jingle:errors:1'/>";
|
String xml = "<unsupported-info xmlns='urn:xmpp:jingle:errors:1'/>";
|
||||||
JingleError error = new JingleErrorProvider().parse(TestUtils.getParser(xml));
|
JingleErrorElement error = new JingleErrorProvider().parse(TestUtils.getParser(xml));
|
||||||
assertEquals(xml, error.toXML().toString());
|
assertEquals(xml, error.toXML().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void outOfOrderTest() throws Exception {
|
public void outOfOrderTest() throws Exception {
|
||||||
String xml = "<out-of-order xmlns='urn:xmpp:jingle:errors:1'/>";
|
String xml = "<out-of-order xmlns='urn:xmpp:jingle:errors:1'/>";
|
||||||
JingleError error = new JingleErrorProvider().parse(TestUtils.getParser(xml));
|
JingleErrorElement error = new JingleErrorProvider().parse(TestUtils.getParser(xml));
|
||||||
assertEquals(xml, error.toXML().toString());
|
assertEquals(xml, error.toXML().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void illegalArgumentTest() {
|
public void illegalArgumentTest() {
|
||||||
JingleError.fromString("inexistent-error");
|
JingleErrorElement.fromString("inexistent-error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.jivesoftware.smack.DummyConnection;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle3.element.JingleElement;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
@ -80,7 +80,7 @@ public class JingleManagerTest extends SmackTestSuite {
|
||||||
String stubNamespace = "urn:xmpp:jingle:application:stub:0";
|
String stubNamespace = "urn:xmpp:jingle:application:stub:0";
|
||||||
JingleHandler stub = new JingleHandler() {
|
JingleHandler stub = new JingleHandler() {
|
||||||
@Override
|
@Override
|
||||||
public IQ handleJingleRequest(Jingle jingle) {
|
public IQ handleJingleRequest(JingleElement jingle) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue