mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
S5B session-initiate and -accept
This commit is contained in:
parent
a8f172c66b
commit
eda7859aa7
3 changed files with 50 additions and 11 deletions
|
@ -41,11 +41,11 @@ import org.jivesoftware.smackx.jingle.exception.UnsupportedJingleTransportExcept
|
|||
import org.jivesoftware.smackx.jingle_filetransfer.callback.JingleFileTransferCallback;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferContentDescription;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.handler.ResponderIncomingFileTransferAccepted;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.handler.InitiatorOutgoingFileTransferInitiated;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.handler.ResponderIncomingFileTransferAccepted;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.listener.IncomingJingleFileTransferListener;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleFileTransferContentDescriptionProvider;
|
||||
import org.jivesoftware.smackx.jingle_ibb.JingleIBBTransportManager;
|
||||
import org.jivesoftware.smackx.jingle_s5b.JingleS5BTransportManager;
|
||||
import org.jxmpp.jid.FullJid;
|
||||
|
||||
/**
|
||||
|
@ -77,9 +77,8 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
|||
NAMESPACE_V5, this);
|
||||
JingleContentProviderManager.addJingleContentDescriptionProvider(
|
||||
NAMESPACE_V5, new JingleFileTransferContentDescriptionProvider());
|
||||
JingleIBBTransportManager.getInstanceFor(connection);
|
||||
//JingleInBandBytestreamTransportManager.getInstanceFor(connection);
|
||||
//JingleSocks5BytestreamTransportManager.getInstanceFor(connection);
|
||||
//JingleIBBTransportManager.getInstanceFor(connection);
|
||||
JingleS5BTransportManager.getInstanceFor(connection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,6 +34,8 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
|||
import org.jivesoftware.smackx.jingle.AbstractJingleTransportManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
||||
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.JingleContentDescription;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
|
||||
|
@ -112,13 +114,51 @@ public final class JingleS5BTransportManager extends AbstractJingleTransportMana
|
|||
}
|
||||
|
||||
@Override
|
||||
public Jingle createSessionInitiate(FullJid targetJID, JingleContentDescription application, String sessionId) throws XMPPException, IOException, InterruptedException, SmackException {
|
||||
return null;
|
||||
public Jingle createSessionInitiate(FullJid targetJID, JingleContentDescription application, String sessionId)
|
||||
throws XMPPException, IOException, InterruptedException, SmackException {
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
jb.setAction(JingleAction.session_initiate)
|
||||
.setInitiator(connection().getUser())
|
||||
.setSessionId(sessionId);
|
||||
|
||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||
cb.addTransport(createJingleContentTransport(targetJID, null))
|
||||
.setSenders(JingleContent.Senders.initiator)
|
||||
.setName(JingleTransportManager.generateRandomId())
|
||||
.setCreator(JingleContent.Creator.initiator)
|
||||
.setDescription(application);
|
||||
jb.addJingleContent(cb.build());
|
||||
|
||||
Jingle jingle = jb.build();
|
||||
jingle.setTo(targetJID);
|
||||
jingle.setFrom(connection().getUser());
|
||||
jingle.setType(IQ.Type.set);
|
||||
return jingle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Jingle createSessionAccept(Jingle request) {
|
||||
return null;
|
||||
public Jingle createSessionAccept(Jingle request)
|
||||
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
|
||||
JingleContent receivedContent = request.getContents().get(0);
|
||||
JingleS5BTransport receviedTransport = (JingleS5BTransport) receivedContent.getJingleTransports().get(0);
|
||||
Jingle.Builder jb = Jingle.getBuilder();
|
||||
jb.setResponder(connection().getUser())
|
||||
.setAction(JingleAction.session_accept)
|
||||
.setSessionId(request.getSid());
|
||||
|
||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||
cb.setSenders(receivedContent.getSenders())
|
||||
.setCreator(receivedContent.getCreator())
|
||||
.setName(receivedContent.getName())
|
||||
.setDescription(receivedContent.getDescription())
|
||||
.addTransport(createJingleContentTransport(request.getInitiator(), receviedTransport));
|
||||
jb.addJingleContent(cb.build());
|
||||
|
||||
Jingle jingle = jb.build();
|
||||
jingle.setTo(request.getFrom());
|
||||
jingle.setFrom(connection().getUser());
|
||||
jingle.setType(IQ.Type.set);
|
||||
return jingle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -128,7 +168,7 @@ public final class JingleS5BTransportManager extends AbstractJingleTransportMana
|
|||
|
||||
@Override
|
||||
public void setIncomingRespondedSessionListener(Jingle jingle, BytestreamListener listener) {
|
||||
|
||||
Socks5BytestreamManager.getBytestreamManager(connection()).addIncomingBytestreamListener(listener, jingle.getInitiator());
|
||||
}
|
||||
|
||||
public JingleS5BTransport createJingleContentTransport(Jid remote, JingleContentTransport received_) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
|
||||
|
|
|
@ -54,7 +54,7 @@ public abstract class AbstractJingleTransportManager<D extends JingleContentTran
|
|||
|
||||
public abstract Jingle createSessionInitiate(FullJid targetJID, JingleContentDescription application, String sessionId) throws XMPPException, IOException, InterruptedException, SmackException;
|
||||
|
||||
public abstract Jingle createSessionAccept(Jingle request);
|
||||
public abstract Jingle createSessionAccept(Jingle request) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException;
|
||||
|
||||
public abstract BytestreamSession outgoingInitiatedSession(Jingle jingle) throws Exception;
|
||||
|
||||
|
|
Loading…
Reference in a new issue