mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-25 20:18:00 +01:00
Start implementing cancel abilities
This commit is contained in:
parent
f9086439a8
commit
ad529be705
3 changed files with 29 additions and 5 deletions
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.jingle_filetransfer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -50,8 +51,15 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
|||
|
||||
@Override
|
||||
public void cancel() {
|
||||
//TODO: Actually cancel
|
||||
notifyEndedListeners(JingleReason.Reason.cancel);
|
||||
if (state == State.active) {
|
||||
Future<?> task = queued.get(0);
|
||||
if (task != null) {
|
||||
task.cancel(true);
|
||||
queued.remove(task);
|
||||
}
|
||||
|
||||
notifyEndedListeners(JingleReason.Reason.cancel);
|
||||
}
|
||||
}
|
||||
|
||||
public enum State {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.jingle_filetransfer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -47,8 +48,21 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
|||
private static final Logger LOGGER = Logger.getLogger(OutgoingJingleFileOffer.class.getName());
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
//TODO: Actually cancel
|
||||
public void cancel() throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||
switch (state) {
|
||||
case terminated:
|
||||
return;
|
||||
|
||||
case active:
|
||||
Future<?> task = queued.get(0);
|
||||
if (task != null) {
|
||||
task.cancel(true);
|
||||
queued.remove(task);
|
||||
}
|
||||
|
||||
default:
|
||||
jutil.sendSessionTerminateCancel(getRemote(), getSessionId());
|
||||
}
|
||||
notifyEndedListeners(JingleReason.Reason.cancel);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle_filetransfer.handler;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +28,7 @@ public interface FileTransferHandler {
|
|||
/**
|
||||
* Cancels the current file transfer.
|
||||
*/
|
||||
void cancel();
|
||||
void cancel() throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException;
|
||||
|
||||
/**
|
||||
* Returns true, if the file transfer is ended.
|
||||
|
|
Loading…
Reference in a new issue