mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-15 03:59:38 +02:00
progress
This commit is contained in:
parent
a395b11ee9
commit
59a600a0b6
10 changed files with 217 additions and 33 deletions
|
@ -126,6 +126,11 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
|||
return jutil.createAck(transportAccept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransportMethodFailed(String namespace) {
|
||||
//Nothing to do.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptIncomingFileOffer(final Jingle request, final File target) {
|
||||
LOGGER.log(Level.INFO, "Client accepted incoming file offer. Try to start receiving.");
|
||||
|
|
|
@ -41,4 +41,9 @@ public class JingleFileRequest extends JingleFileTransferSession {
|
|||
return new JingleFileRequest(connection, request.getInitiator(), connection.getUser().asFullJidOrThrow(), Role.responder,
|
||||
request.getSid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransportMethodFailed(String namespace) {
|
||||
//Not implemented
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,8 +118,8 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
|||
} //File Request
|
||||
else if (content.getSenders() == JingleContent.Senders.responder) {
|
||||
return JingleFileRequest.createIncomingFileRequest(connection(), request);
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// If senders is neither initiator, nor responder, consider session malformed.
|
||||
// See XEP-0166 §6.3 Example 16 and XEP-0234 §4.1
|
||||
LOGGER.log(Level.WARNING, "Jingle has invalid sender value. Only initiator and responder are allowed.");
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleTransportMethodManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleUtil;
|
||||
import org.jivesoftware.smackx.jingle.Role;
|
||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
||||
|
@ -161,4 +162,38 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
|||
|
||||
return jutil.createAck(transportReplace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IQ handleTransportAccept(Jingle transportAccept)
|
||||
throws SmackException.NotConnectedException, InterruptedException {
|
||||
return handleSessionAccept(transportAccept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransportMethodFailed(String namespace) {
|
||||
state = State.pending;
|
||||
JingleContent content = contents.get(0);
|
||||
failedTransportMethods.add(namespace);
|
||||
JingleTransportMethodManager tm = JingleTransportMethodManager.getInstanceFor(getConnection());
|
||||
JingleTransportManager<?> next = tm.getBestAvailableTransportManager(failedTransportMethods);
|
||||
|
||||
if (next == null) {
|
||||
//Failure
|
||||
try {
|
||||
new JingleUtil(getConnection()).sendSessionTerminateUnsupportedTransports(getRemote(), getSessionId());
|
||||
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) {
|
||||
LOGGER.log(Level.WARNING, "Could not send session-terminate.", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Replace transport
|
||||
this.transportSession = next.transportSession(this);
|
||||
try {
|
||||
jutil.sendTransportReplace(getRemote(), getInitiator(), getSessionId(), content.getCreator(), content.getName(),
|
||||
transportSession.createTransport());
|
||||
} catch (SmackException.NotConnectedException | SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException e) {
|
||||
LOGGER.log(Level.WARNING, "Could not send transport-replace.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ReceiveTask implements Runnable {
|
|||
byte[] filebuf = new byte[transfer.getSize()];
|
||||
int read = 0;
|
||||
byte[] bufbuf = new byte[2048];
|
||||
|
||||
LOGGER.log(Level.INFO, "Begin receiving.");
|
||||
while (read < filebuf.length) {
|
||||
int r = inputStream.read(bufbuf);
|
||||
if (r >= 0) {
|
||||
|
@ -68,6 +68,7 @@ public class ReceiveTask implements Runnable {
|
|||
}
|
||||
|
||||
outputStream.write(filebuf);
|
||||
LOGGER.log(Level.INFO, "File successfully received.");
|
||||
|
||||
} catch (IOException e) {
|
||||
LOGGER.log(Level.SEVERE, "Error while receiving data: ", e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue