mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-27 14:32:06 +01:00
Transport Fallback works, but does not save file
This commit is contained in:
parent
f26f3bb503
commit
4a8251fbe5
3 changed files with 87 additions and 36 deletions
|
@ -44,6 +44,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
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 Jingle pendingSessionInitiate = null;
|
||||||
private ReceiveTask receivingThread;
|
private ReceiveTask receivingThread;
|
||||||
|
private File target;
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
fresh,
|
fresh,
|
||||||
|
@ -112,6 +113,55 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
return jutil.createAck(initiate);
|
return jutil.createAck(initiate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IQ handleTransportReplace(final Jingle transportReplace)
|
||||||
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
||||||
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||||
|
final JingleTransportManager<?> replacementManager = JingleTransportMethodManager.getInstanceFor(connection)
|
||||||
|
.getTransportManager(transportReplace);
|
||||||
|
|
||||||
|
queued.add(JingleManager.getThreadPool().submit(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
if (replacementManager != null) {
|
||||||
|
LOGGER.log(Level.INFO, "Accept transport-replace.");
|
||||||
|
IncomingJingleFileOffer.this.transportSession = replacementManager.transportSession(IncomingJingleFileOffer.this);
|
||||||
|
transportSession.processJingle(transportReplace);
|
||||||
|
transportSession.initiateIncomingSession(new JingleTransportInitiationCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSessionInitiated(BytestreamSession bytestreamSession) {
|
||||||
|
LOGGER.log(Level.INFO, "Bytestream initiated. Start receiving.");
|
||||||
|
receivingThread = new ReceiveTask(bytestreamSession, file, target);
|
||||||
|
queued.add(JingleManager.getThreadPool().submit(receivingThread));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onException(Exception e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "EXCEPTION IN INCOMING SESSION: ", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jutil.sendTransportAccept(transportReplace.getFrom().asFullJidOrThrow(),
|
||||||
|
transportReplace.getInitiator(), transportReplace.getSid(),
|
||||||
|
getContents().get(0).getCreator(), getContents().get(0).getName(),
|
||||||
|
transportSession.createTransport());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
LOGGER.log(Level.INFO, "Unsupported transport. Reject transport-replace.");
|
||||||
|
jutil.sendTransportReject(transportReplace.getFrom().asFullJidOrThrow(), transportReplace.getInitiator(),
|
||||||
|
transportReplace.getSid(), getContents().get(0).getCreator(),
|
||||||
|
getContents().get(0).getName(), transportReplace.getContents().get(0).getJingleTransport());
|
||||||
|
}
|
||||||
|
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Help me please!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
return jutil.createAck(transportReplace);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleTransportAccept(Jingle transportAccept) {
|
public IQ handleTransportAccept(Jingle transportAccept) {
|
||||||
LOGGER.log(Level.INFO, "Received transport-accept.");
|
LOGGER.log(Level.INFO, "Received transport-accept.");
|
||||||
|
@ -134,6 +184,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void acceptIncomingFileOffer(final Jingle request, final File target) {
|
public void acceptIncomingFileOffer(final Jingle request, final File 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) {
|
||||||
//Unsupported transport
|
//Unsupported transport
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
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.JingleUtil;
|
|
||||||
import org.jivesoftware.smackx.jingle.Role;
|
import org.jivesoftware.smackx.jingle.Role;
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
||||||
|
@ -175,6 +174,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
@Override
|
@Override
|
||||||
public IQ handleTransportAccept(Jingle transportAccept)
|
public IQ handleTransportAccept(Jingle transportAccept)
|
||||||
throws SmackException.NotConnectedException, InterruptedException {
|
throws SmackException.NotConnectedException, InterruptedException {
|
||||||
|
|
||||||
return handleSessionAccept(transportAccept);
|
return handleSessionAccept(transportAccept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
//Failure
|
//Failure
|
||||||
try {
|
try {
|
||||||
new JingleUtil(getConnection()).sendSessionTerminateUnsupportedTransports(getRemote(), getSessionId());
|
jutil.sendSessionTerminateUnsupportedTransports(getRemote(), getSessionId());
|
||||||
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) {
|
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) {
|
||||||
LOGGER.log(Level.WARNING, "Could not send session-terminate.", e);
|
LOGGER.log(Level.WARNING, "Could not send session-terminate.", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,40 +136,40 @@ public abstract class JingleSession implements JingleSessionHandler {
|
||||||
@Override
|
@Override
|
||||||
public IQ handleJingleSessionRequest(Jingle jingle) {
|
public IQ handleJingleSessionRequest(Jingle jingle) {
|
||||||
try {
|
try {
|
||||||
switch (jingle.getAction()) {
|
switch (jingle.getAction()) {
|
||||||
case content_accept:
|
case content_accept:
|
||||||
return handleContentAccept(jingle);
|
return handleContentAccept(jingle);
|
||||||
case content_add:
|
case content_add:
|
||||||
return handleContentAdd(jingle);
|
return handleContentAdd(jingle);
|
||||||
case content_modify:
|
case content_modify:
|
||||||
return handleContentModify(jingle);
|
return handleContentModify(jingle);
|
||||||
case content_reject:
|
case content_reject:
|
||||||
return handleContentReject(jingle);
|
return handleContentReject(jingle);
|
||||||
case content_remove:
|
case content_remove:
|
||||||
return handleContentRemove(jingle);
|
return handleContentRemove(jingle);
|
||||||
case description_info:
|
case description_info:
|
||||||
return handleDescriptionInfo(jingle);
|
return handleDescriptionInfo(jingle);
|
||||||
case session_info:
|
case session_info:
|
||||||
return handleSessionInfo(jingle);
|
return handleSessionInfo(jingle);
|
||||||
case security_info:
|
case security_info:
|
||||||
return handleSecurityInfo(jingle);
|
return handleSecurityInfo(jingle);
|
||||||
case session_accept:
|
case session_accept:
|
||||||
return handleSessionAccept(jingle);
|
return handleSessionAccept(jingle);
|
||||||
case transport_accept:
|
case transport_accept:
|
||||||
return handleTransportAccept(jingle);
|
return handleTransportAccept(jingle);
|
||||||
case transport_info:
|
case transport_info:
|
||||||
return transportSession.handleTransportInfo(jingle);
|
return transportSession.handleTransportInfo(jingle);
|
||||||
case session_initiate:
|
case session_initiate:
|
||||||
return handleSessionInitiate(jingle);
|
return handleSessionInitiate(jingle);
|
||||||
case transport_reject:
|
case transport_reject:
|
||||||
return handleTransportReject(jingle);
|
return handleTransportReject(jingle);
|
||||||
case session_terminate:
|
case session_terminate:
|
||||||
return handleSessionTerminate(jingle);
|
return handleSessionTerminate(jingle);
|
||||||
case transport_replace:
|
case transport_replace:
|
||||||
return handleTransportReplace(jingle);
|
return handleTransportReplace(jingle);
|
||||||
default:
|
default:
|
||||||
return IQ.createResultIQ(jingle);
|
return IQ.createResultIQ(jingle);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
|
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
|
||||||
return null; //TODO:
|
return null; //TODO:
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue