mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-27 14:32:06 +01:00
Temp
This commit is contained in:
parent
a4454aa8b5
commit
4d11422335
9 changed files with 84 additions and 42 deletions
|
@ -141,16 +141,16 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
Jingle initiate = sessionInitiate(recipient, description, transport);
|
Jingle initiate = sessionInitiate(recipient, description, transport);
|
||||||
|
|
||||||
JingleManager.FullJidAndSessionId fullJidAndSessionId =
|
JingleManager.FullJidAndSessionId fullJidAndSessionId =
|
||||||
new JingleManager.FullJidAndSessionId(recipient, initiate.getSid());
|
new JingleManager.FullJidAndSessionId(recipient, initiate.getSessionId());
|
||||||
|
|
||||||
InitiatorOutgoingFileTransferInitiated sessionHandler =
|
InitiatorOutgoingFileTransferInitiated sessionHandler =
|
||||||
new InitiatorOutgoingFileTransferInitiated(this, fullJidAndSessionId, file);
|
new InitiatorOutgoingFileTransferInitiated(this, fullJidAndSessionId, file);
|
||||||
|
|
||||||
jingleManager.registerJingleSessionHandler(recipient, initiate.getSid(), sessionHandler);
|
jingleManager.registerJingleSessionHandler(recipient, initiate.getSessionId(), sessionHandler);
|
||||||
|
|
||||||
JingleTransportHandler<?> transportHandler = tm.createJingleTransportHandler(sessionHandler);
|
JingleTransportHandler<?> transportHandler = tm.createJingleTransportHandler(sessionHandler);
|
||||||
connection().sendStanza(initiate);
|
connection().sendStanza(initiate);
|
||||||
transportHandler.establishOutgoingSession(fullJidAndSessionId, transport, new JingleTransportEstablishedCallback() {
|
transportHandler.establishOutgoingSession(initiate, new JingleTransportEstablishedCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSessionEstablished(BytestreamSession bytestreamSession) {
|
public void onSessionEstablished(BytestreamSession bytestreamSession) {
|
||||||
try {
|
try {
|
||||||
|
@ -192,7 +192,7 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
connection().sendStanza(sessionAccept(jingle));
|
connection().sendStanza(sessionAccept(jingle));
|
||||||
ResponderIncomingFileTransferAccepted responded = new ResponderIncomingFileTransferAccepted(
|
ResponderIncomingFileTransferAccepted responded = new ResponderIncomingFileTransferAccepted(
|
||||||
JingleFileTransferManager.this, jingle, target);
|
JingleFileTransferManager.this, jingle, target);
|
||||||
jingleManager.registerJingleSessionHandler(jingle.getFrom().asFullJidIfPossible(), jingle.getSid(),
|
jingleManager.registerJingleSessionHandler(jingle.getFrom().asFullJidIfPossible(), jingle.getSessionId(),
|
||||||
responded);
|
responded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
JingleContent content = request.getContents().get(0);
|
JingleContent content = request.getContents().get(0);
|
||||||
|
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
Jingle.Builder jb = Jingle.getBuilder();
|
||||||
jb.setSessionId(request.getSid())
|
jb.setSessionId(request.getSessionId())
|
||||||
.setAction(JingleAction.session_accept)
|
.setAction(JingleAction.session_accept)
|
||||||
.setResponder(connection().getUser());
|
.setResponder(connection().getUser());
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
jb.setResponder(connection().getUser())
|
jb.setResponder(connection().getUser())
|
||||||
.setAction(JingleAction.session_terminate)
|
.setAction(JingleAction.session_terminate)
|
||||||
.setReason(JingleReason.Reason.decline)
|
.setReason(JingleReason.Reason.decline)
|
||||||
.setSessionId(request.getSid());
|
.setSessionId(request.getSessionId());
|
||||||
Jingle jingle = jb.build();
|
Jingle jingle = jb.build();
|
||||||
jingle.setTo(request.getFrom());
|
jingle.setTo(request.getFrom());
|
||||||
jingle.setFrom(connection().getUser());
|
jingle.setFrom(connection().getUser());
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.jivesoftware.smackx.jingle.AbstractJingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleSessionHandler;
|
import org.jivesoftware.smackx.jingle.JingleSessionHandler;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportEstablishedCallback;
|
import org.jivesoftware.smackx.jingle.JingleTransportEstablishedCallback;
|
||||||
|
import org.jivesoftware.smackx.jingle.JingleTransportHandler;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||||
|
@ -67,7 +68,7 @@ public class InitiatorOutgoingFileTransferInitiated implements JingleSessionHand
|
||||||
|
|
||||||
switch (jingle.getAction()) {
|
switch (jingle.getAction()) {
|
||||||
case session_accept:
|
case session_accept:
|
||||||
bm.createJingleTransportHandler(this).establishOutgoingSession(fullJidAndSessionId, transport, new JingleTransportEstablishedCallback() {
|
bm.createJingleTransportHandler(this).establishOutgoingSession(jingle, new JingleTransportEstablishedCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSessionEstablished(final BytestreamSession bytestreamSession) {
|
public void onSessionEstablished(final BytestreamSession bytestreamSession) {
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
import org.jivesoftware.smackx.jingle.AbstractJingleTransportManager;
|
import org.jivesoftware.smackx.jingle.AbstractJingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
|
||||||
import org.jivesoftware.smackx.jingle.JingleSessionHandler;
|
import org.jivesoftware.smackx.jingle.JingleSessionHandler;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportEstablishedCallback;
|
import org.jivesoftware.smackx.jingle.JingleTransportEstablishedCallback;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
||||||
|
@ -60,12 +59,10 @@ public class ResponderIncomingFileTransferAccepted implements JingleSessionHandl
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
this.initiator = initiate.getInitiator();
|
this.initiator = initiate.getInitiator();
|
||||||
this.sessionId = initiate.getSid();
|
this.sessionId = initiate.getSessionId();
|
||||||
|
|
||||||
transportManager.createJingleTransportHandler(this).establishIncomingSession(
|
transportManager.createJingleTransportHandler(this).establishIncomingSession(
|
||||||
new JingleManager.FullJidAndSessionId(initiate.getFrom().asFullJidIfPossible(), initiate.getSid()),
|
initiate, new JingleTransportEstablishedCallback() {
|
||||||
initiate.getContents().get(0).getJingleTransports().get(0),
|
|
||||||
new JingleTransportEstablishedCallback() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onSessionEstablished(BytestreamSession bytestreamSession) {
|
public void onSessionEstablished(BytestreamSession bytestreamSession) {
|
||||||
manager.receiveFile(initiate, bytestreamSession, target);
|
manager.receiveFile(initiate, bytestreamSession, target);
|
||||||
|
|
|
@ -10,11 +10,10 @@ 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.bytestreams.ibb.InBandBytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
|
||||||
import org.jivesoftware.smackx.jingle.JingleSessionHandler;
|
import org.jivesoftware.smackx.jingle.JingleSessionHandler;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportEstablishedCallback;
|
import org.jivesoftware.smackx.jingle.JingleTransportEstablishedCallback;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportHandler;
|
import org.jivesoftware.smackx.jingle.JingleTransportHandler;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||||
import org.jivesoftware.smackx.jingle.exception.JingleTransportFailureException;
|
import org.jivesoftware.smackx.jingle.exception.JingleTransportFailureException;
|
||||||
import org.jivesoftware.smackx.jingle_ibb.element.JingleIBBTransport;
|
import org.jivesoftware.smackx.jingle_ibb.element.JingleIBBTransport;
|
||||||
|
|
||||||
|
@ -30,12 +29,12 @@ public class JingleIBBTransportHandler implements JingleTransportHandler<JingleI
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void establishOutgoingSession(JingleManager.FullJidAndSessionId target, JingleContentTransport transport, JingleTransportEstablishedCallback callback) {
|
public void establishOutgoingSession(Jingle request, JingleTransportEstablishedCallback callback) {
|
||||||
InBandBytestreamSession session;
|
InBandBytestreamSession session;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
session = InBandBytestreamManager.getByteStreamManager(getConnection())
|
session = InBandBytestreamManager.getByteStreamManager(getConnection())
|
||||||
.establishSession(target.getFullJid(), target.getSessionId());
|
.establishSession(request.getResponder(), request.getSessionId());
|
||||||
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
|
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
|
||||||
callback.onSessionFailure(new JingleTransportFailureException(e));
|
callback.onSessionFailure(new JingleTransportFailureException(e));
|
||||||
return;
|
return;
|
||||||
|
@ -45,12 +44,12 @@ public class JingleIBBTransportHandler implements JingleTransportHandler<JingleI
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void establishIncomingSession(final JingleManager.FullJidAndSessionId target, JingleContentTransport transport, final JingleTransportEstablishedCallback callback) {
|
public void establishIncomingSession(final Jingle initiate, final JingleTransportEstablishedCallback callback) {
|
||||||
InBandBytestreamManager.getByteStreamManager(getConnection()).addIncomingBytestreamListener(new BytestreamListener() {
|
InBandBytestreamManager.getByteStreamManager(getConnection()).addIncomingBytestreamListener(new BytestreamListener() {
|
||||||
@Override
|
@Override
|
||||||
public void incomingBytestreamRequest(BytestreamRequest request) {
|
public void incomingBytestreamRequest(BytestreamRequest request) {
|
||||||
if (request.getFrom().asFullJidIfPossible().equals(target.getFullJid())
|
if (request.getFrom().asFullJidIfPossible().equals(initiate.getInitiator())
|
||||||
&& request.getSessionID().equals(target.getSessionId())) {
|
&& request.getSessionID().equals(initiate.getSessionId())) {
|
||||||
BytestreamSession session;
|
BytestreamSession session;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -12,15 +12,20 @@ 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.smackx.bytestreams.socks5.Socks5Client;
|
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Client;
|
||||||
|
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy;
|
||||||
|
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.JingleSessionHandler;
|
import org.jivesoftware.smackx.jingle.JingleSessionHandler;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportEstablishedCallback;
|
import org.jivesoftware.smackx.jingle.JingleTransportEstablishedCallback;
|
||||||
import org.jivesoftware.smackx.jingle.JingleTransportHandler;
|
import org.jivesoftware.smackx.jingle.JingleTransportHandler;
|
||||||
|
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||||
|
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
||||||
|
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidate;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidate;
|
||||||
import org.jivesoftware.smackx.jingle_s5b.elements.JingleS5BTransport;
|
import org.jivesoftware.smackx.jingle_s5b.elements.JingleS5BTransport;
|
||||||
import org.jivesoftware.smackx.jingle_s5b.elements.JingleS5BTransportCandidate;
|
import org.jivesoftware.smackx.jingle_s5b.elements.JingleS5BTransportCandidate;
|
||||||
|
import org.jivesoftware.smackx.jingle_s5b.elements.JingleS5BTransportInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JingleTransportHandler for Socks5Bytestreams.
|
* JingleTransportHandler for Socks5Bytestreams.
|
||||||
|
@ -30,25 +35,33 @@ public class JingleS5BTransportHandler implements JingleTransportHandler<JingleS
|
||||||
|
|
||||||
private final WeakReference<JingleSessionHandler> sessionHandler;
|
private final WeakReference<JingleSessionHandler> sessionHandler;
|
||||||
|
|
||||||
|
private JingleS5BTransportCandidate receivedCandidateUsed = null;
|
||||||
|
|
||||||
|
private Socket connectedSocket = null;
|
||||||
|
|
||||||
public JingleS5BTransportHandler(JingleSessionHandler sessionHandler) {
|
public JingleS5BTransportHandler(JingleSessionHandler sessionHandler) {
|
||||||
this.sessionHandler = new WeakReference<>(sessionHandler);
|
this.sessionHandler = new WeakReference<>(sessionHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void establishOutgoingSession(JingleManager.FullJidAndSessionId target, JingleContentTransport hopefullyS5BTransport, JingleTransportEstablishedCallback callback) {
|
public void establishOutgoingSession(Jingle request, JingleTransportEstablishedCallback callback) {
|
||||||
|
JingleContent content = request.getContents().get(0);
|
||||||
|
JingleContentTransport hopefullyS5BTransport = content.getJingleTransports().get(0);
|
||||||
|
|
||||||
if (!hopefullyS5BTransport.getNamespace().equals(JingleS5BTransport.NAMESPACE_V1)) {
|
if (!hopefullyS5BTransport.getNamespace().equals(JingleS5BTransport.NAMESPACE_V1)) {
|
||||||
throw new IllegalArgumentException("Transport must be a JingleS5BTransport.");
|
throw new IllegalArgumentException("Transport must be a JingleS5BTransport.");
|
||||||
}
|
}
|
||||||
|
|
||||||
JingleS5BTransport transport = (JingleS5BTransport) hopefullyS5BTransport;
|
JingleS5BTransport transport = (JingleS5BTransport) hopefullyS5BTransport;
|
||||||
|
|
||||||
|
Socks5Proxy.getSocks5Proxy().addLocalAddress(Socks5Utils.createDigest(
|
||||||
|
request.getSessionId(), getConnection().getUser().asFullJidIfPossible(), request.getResponder()));
|
||||||
|
|
||||||
|
|
||||||
ArrayList<Bytestream.StreamHost> streamHosts = new ArrayList<>();
|
JingleS5BTransportCandidate usedCandidate = null;
|
||||||
for (JingleContentTransportCandidate c : transport.getCandidates()) {
|
for (JingleContentTransportCandidate c : transport.getCandidates()) {
|
||||||
streamHosts.add(((JingleS5BTransportCandidate) c).getStreamHost());
|
usedCandidate = (JingleS5BTransportCandidate) c;
|
||||||
}
|
Bytestream.StreamHost streamHost = usedCandidate.getStreamHost();
|
||||||
|
|
||||||
for (Bytestream.StreamHost streamHost : streamHosts) {
|
|
||||||
String address = streamHost.getAddress() + ":" + streamHost.getPort();
|
String address = streamHost.getAddress() + ":" + streamHost.getPort();
|
||||||
|
|
||||||
LOGGER.log(Level.INFO, "Connect outwards to " + address);
|
LOGGER.log(Level.INFO, "Connect outwards to " + address);
|
||||||
|
@ -59,23 +72,52 @@ public class JingleS5BTransportHandler implements JingleTransportHandler<JingleS
|
||||||
final Socks5Client socks5Client = new Socks5Client(streamHost, transport.getDestinationAddress());
|
final Socks5Client socks5Client = new Socks5Client(streamHost, transport.getDestinationAddress());
|
||||||
|
|
||||||
// connect to SOCKS5 proxy with a timeout
|
// connect to SOCKS5 proxy with a timeout
|
||||||
Socket socket = socks5Client.getSocket(10 * 1000);
|
connectedSocket = socks5Client.getSocket(10 * 1000);
|
||||||
|
|
||||||
|
|
||||||
// set selected host
|
// set selected host
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (TimeoutException | IOException | SmackException | XMPPException e) {
|
catch (TimeoutException | IOException | SmackException | XMPPException | InterruptedException e) {
|
||||||
|
LOGGER.log(Level.WARNING, "Could not connect outwards to " + address + ": " + e, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connectedSocket != null) {
|
||||||
|
Jingle.Builder jb = Jingle.getBuilder();
|
||||||
|
jb.setSessionId(request.getSessionId())
|
||||||
|
.setAction(JingleAction.transport_info)
|
||||||
|
.setInitiator(getConnection().getUser());
|
||||||
|
|
||||||
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||||
|
cb.setName(content.getName())
|
||||||
|
.setCreator(content.getCreator())
|
||||||
|
.setSenders(content.getSenders());
|
||||||
|
|
||||||
|
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
||||||
|
tb.addTransportInfo(JingleS5BTransportInfo.CandidateUsed(usedCandidate.getCandidateId()));
|
||||||
|
cb.addTransport(tb.build());
|
||||||
|
|
||||||
|
jb.addJingleContent(cb.build());
|
||||||
|
|
||||||
|
Jingle jingle = jb.build();
|
||||||
|
jingle.setFrom(getConnection().getUser());
|
||||||
|
jingle.setTo(request.getFrom());
|
||||||
|
try {
|
||||||
|
getConnection().sendStanza(jingle);
|
||||||
|
} catch (SmackException.NotConnectedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void establishIncomingSession(JingleManager.FullJidAndSessionId target, JingleContentTransport hopefullyS5BTransport, JingleTransportEstablishedCallback callback) {
|
public void establishIncomingSession(Jingle request, JingleTransportEstablishedCallback callback) {
|
||||||
|
JingleContent content = request.getContents().get(0);
|
||||||
|
JingleContentTransport hopefullyS5BTransport = content.getJingleTransports().get(0);
|
||||||
if (!hopefullyS5BTransport.getNamespace().equals(JingleS5BTransport.NAMESPACE_V1)) {
|
if (!hopefullyS5BTransport.getNamespace().equals(JingleS5BTransport.NAMESPACE_V1)) {
|
||||||
throw new IllegalArgumentException("Transport must be a JingleS5BTransport.");
|
throw new IllegalArgumentException("Transport must be a JingleS5BTransport.");
|
||||||
}
|
}
|
||||||
|
@ -105,10 +147,8 @@ public class JingleS5BTransportHandler implements JingleTransportHandler<JingleS
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (TimeoutException | IOException | SmackException | XMPPException e) {
|
catch (TimeoutException | IOException | SmackException | XMPPException | InterruptedException e) {
|
||||||
|
LOGGER.log(Level.WARNING, "Could not connect inwards to " + address + ": " + e, e);
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -119,4 +159,8 @@ public class JingleS5BTransportHandler implements JingleTransportHandler<JingleS
|
||||||
JingleSessionHandler handler = sessionHandler.get();
|
JingleSessionHandler handler = sessionHandler.get();
|
||||||
return handler != null ? handler.getConnection() : null;
|
return handler != null ? handler.getConnection() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setReceivedCandidateUsed(JingleS5BTransportCandidate used) {
|
||||||
|
this.receivedCandidateUsed = used;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public final class JingleManager extends Manager {
|
||||||
Jid from = jingle.getFrom();
|
Jid from = jingle.getFrom();
|
||||||
assert (from != null);
|
assert (from != null);
|
||||||
FullJid fullFrom = from.asFullJidOrThrow();
|
FullJid fullFrom = from.asFullJidOrThrow();
|
||||||
FullJidAndSessionId fullJidAndSessionId = new FullJidAndSessionId(fullFrom, jingle.getSid());
|
FullJidAndSessionId fullJidAndSessionId = new FullJidAndSessionId(fullFrom, jingle.getSessionId());
|
||||||
JingleSessionHandler jingleSessionHandler = jingleSessionHandlers.get(fullJidAndSessionId);
|
JingleSessionHandler jingleSessionHandler = jingleSessionHandlers.get(fullJidAndSessionId);
|
||||||
|
|
||||||
if (jingleSessionHandler == null) {
|
if (jingleSessionHandler == null) {
|
||||||
|
@ -79,7 +79,7 @@ public final class JingleManager extends Manager {
|
||||||
.addExtension(JingleError.UNKNOWN_SESSION);
|
.addExtension(JingleError.UNKNOWN_SESSION);
|
||||||
return IQ.createErrorResponse(jingle, errorBuilder);
|
return IQ.createErrorResponse(jingle, errorBuilder);
|
||||||
}
|
}
|
||||||
return jingleSessionHandler.handleJingleSessionRequest(jingle, jingle.getSid());
|
return jingleSessionHandler.handleJingleSessionRequest(jingle, jingle.getSessionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jingle.getContents().size() > 1) {
|
if (jingle.getContents().size() > 1) {
|
||||||
|
@ -95,7 +95,7 @@ public final class JingleManager extends Manager {
|
||||||
//Unsupported Application
|
//Unsupported Application
|
||||||
Jingle.Builder builder = Jingle.getBuilder();
|
Jingle.Builder builder = Jingle.getBuilder();
|
||||||
builder.setAction(JingleAction.session_terminate)
|
builder.setAction(JingleAction.session_terminate)
|
||||||
.setSessionId(jingle.getSid())
|
.setSessionId(jingle.getSessionId())
|
||||||
.setReason(JingleReason.Reason.unsupported_applications);
|
.setReason(JingleReason.Reason.unsupported_applications);
|
||||||
Jingle response = builder.build();
|
Jingle response = builder.build();
|
||||||
response.setTo(jingle.getFrom());
|
response.setTo(jingle.getFrom());
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle;
|
||||||
|
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,9 +9,9 @@ import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||||
*/
|
*/
|
||||||
public interface JingleTransportHandler<D extends JingleContentTransport> {
|
public interface JingleTransportHandler<D extends JingleContentTransport> {
|
||||||
|
|
||||||
void establishOutgoingSession(JingleManager.FullJidAndSessionId target, JingleContentTransport transport, JingleTransportEstablishedCallback callback);
|
void establishOutgoingSession(Jingle request, JingleTransportEstablishedCallback callback);
|
||||||
|
|
||||||
void establishIncomingSession(JingleManager.FullJidAndSessionId target, JingleContentTransport transport, JingleTransportEstablishedCallback callback);
|
void establishIncomingSession(Jingle request, JingleTransportEstablishedCallback callback);
|
||||||
|
|
||||||
XMPPConnection getConnection();
|
XMPPConnection getConnection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ public final class Jingle extends IQ {
|
||||||
*
|
*
|
||||||
* @return Returns the session ID related to the session.
|
* @return Returns the session ID related to the session.
|
||||||
*/
|
*/
|
||||||
public String getSid() {
|
public String getSessionId() {
|
||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ public final class Jingle extends IQ {
|
||||||
xml.optAttribute(INITIATOR_ATTRIBUTE_NAME, getInitiator());
|
xml.optAttribute(INITIATOR_ATTRIBUTE_NAME, getInitiator());
|
||||||
xml.optAttribute(RESPONDER_ATTRIBUTE_NAME, getResponder());
|
xml.optAttribute(RESPONDER_ATTRIBUTE_NAME, getResponder());
|
||||||
xml.optAttribute(ACTION_ATTRIBUTE_NAME, getAction());
|
xml.optAttribute(ACTION_ATTRIBUTE_NAME, getAction());
|
||||||
xml.optAttribute(SESSION_ID_ATTRIBUTE_NAME, getSid());
|
xml.optAttribute(SESSION_ID_ATTRIBUTE_NAME, getSessionId());
|
||||||
xml.rightAngleBracket();
|
xml.rightAngleBracket();
|
||||||
|
|
||||||
xml.optElement(reason);
|
xml.optElement(reason);
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class JingleTest extends SmackTestSuite {
|
||||||
assertEquals(romeo, jingle.getInitiator());
|
assertEquals(romeo, jingle.getInitiator());
|
||||||
assertEquals(juliet, jingle.getResponder());
|
assertEquals(juliet, jingle.getResponder());
|
||||||
assertEquals(jingle.getAction(), JingleAction.session_initiate);
|
assertEquals(jingle.getAction(), JingleAction.session_initiate);
|
||||||
assertEquals(sessionId, jingle.getSid());
|
assertEquals(sessionId, jingle.getSessionId());
|
||||||
|
|
||||||
String xml = "<jingle xmlns='urn:xmpp:jingle:1' " +
|
String xml = "<jingle xmlns='urn:xmpp:jingle:1' " +
|
||||||
"initiator='romeo@montague.lit/orchard' " +
|
"initiator='romeo@montague.lit/orchard' " +
|
||||||
|
|
Loading…
Reference in a new issue