diff --git a/source/org/jivesoftware/smackx/filetransfer/FileTransfer.java b/source/org/jivesoftware/smackx/filetransfer/FileTransfer.java index 18686b82e..9954adf4e 100644 --- a/source/org/jivesoftware/smackx/filetransfer/FileTransfer.java +++ b/source/org/jivesoftware/smackx/filetransfer/FileTransfer.java @@ -184,13 +184,13 @@ public abstract class FileTransfer { this.exception = exception; } - protected final void setStatus(Status status) { + protected void setStatus(Status status) { synchronized (statusMonitor) { this.status = status; } } - protected final boolean updateStatus(Status oldStatus, Status newStatus) { + protected boolean updateStatus(Status oldStatus, Status newStatus) { synchronized (statusMonitor) { if (oldStatus != status) { return false; diff --git a/source/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java b/source/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java index 430e4c755..f5ef15293 100644 --- a/source/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java +++ b/source/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java @@ -35,18 +35,19 @@ import java.io.*; public class OutgoingFileTransfer extends FileTransfer { private static int RESPONSE_TIMEOUT = 60 * 1000; + private NegotiationProgress callback; - /** - * Returns the time in milliseconds after which the file transfer - * negotiation process will timeout if the other user has not responded. - * - * @return Returns the time in milliseconds after which the file transfer - * negotiation process will timeout if the remote user has not - * responded. - */ - public static int getResponseTimeout() { - return RESPONSE_TIMEOUT; - } + /** + * Returns the time in milliseconds after which the file transfer + * negotiation process will timeout if the other user has not responded. + * + * @return Returns the time in milliseconds after which the file transfer + * negotiation process will timeout if the remote user has not + * responded. + */ + public static int getResponseTimeout() { + return RESPONSE_TIMEOUT; + } /** * Sets the time in milliseconds after which the file transfer negotiation @@ -129,10 +130,8 @@ public class OutgoingFileTransfer extends FileTransfer { /** * This methods handles the transfer and stream negotiation process. It - * returns immediately and its progress can be monitored through the - * {@link NegotiationProgress} callback. When the negotiation process is - * complete the OutputStream can be retrieved from the callback via the - * {@link NegotiationProgress#getOutputStream()} method. + * returns immediately and its progress will be updated through the + * {@link NegotiationProgress} callback. * * @param fileName * The name of the file that will be transmitted. It is @@ -149,20 +148,26 @@ public class OutgoingFileTransfer extends FileTransfer { */ public synchronized void sendFile(final String fileName, final long fileSize, final String description, - NegotiationProgress progress) { - checkTransferThread(); + final NegotiationProgress progress) + { + if(progress == null) { + throw new IllegalArgumentException("Callback progress cannot be null."); + } + checkTransferThread(); if (isDone() || outputStream != null) { throw new IllegalStateException( "The negotation process has already" + " been attempted for this file transfer"); } - progress.delegate = this; - transferThread = new Thread(new Runnable() { + this.callback = progress; + transferThread = new Thread(new Runnable() { public void run() { try { OutgoingFileTransfer.this.outputStream = negotiateStream( fileName, fileSize, description); - } catch (XMPPException e) { + progress.outputStreamEstablished(OutgoingFileTransfer.this.outputStream); + } + catch (XMPPException e) { handleXMPPException(e); } } @@ -177,7 +182,7 @@ public class OutgoingFileTransfer extends FileTransfer { } } - /** + /** * This method handles the stream negotiation process and transmits the file * to the remote user. It returns immediatly and the progress of the file * transfer can be monitored through several methods: @@ -188,6 +193,8 @@ public class OutgoingFileTransfer extends FileTransfer { *