public class OutgoingFileTransfer extends FileTransfer
Modifier and Type | Class and Description |
---|---|
static interface |
OutgoingFileTransfer.NegotiationProgress
A callback class to retrieve the status of an outgoing transfer
negotiation process.
|
FileTransfer.Error, FileTransfer.Status
amountWritten, negotiator, streamID
Modifier | Constructor and Description |
---|---|
protected |
OutgoingFileTransfer(org.jxmpp.jid.Jid initiator,
org.jxmpp.jid.Jid target,
String streamID,
FileTransferNegotiator transferNegotiator) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the file transfer.
|
long |
getBytesSent()
Returns the amount of bytes that have been sent for the file transfer.
|
protected OutputStream |
getOutputStream()
Returns the output stream connected to the peer to transfer the file.
|
static int |
getResponseTimeout()
Returns the time in milliseconds after which the file transfer
negotiation process will timeout if the other user has not responded.
|
void |
sendFile(File file,
String description)
This method handles the stream negotiation process and transmits the file
to the remote user.
|
OutputStream |
sendFile(String fileName,
long fileSize,
String description)
This method handles the negotiation of the file transfer and the stream,
it only returns the created stream after the negotiation has been completed.
|
void |
sendFile(String fileName,
long fileSize,
String description,
OutgoingFileTransfer.NegotiationProgress progress)
This methods handles the transfer and stream negotiation process.
|
void |
sendStream(InputStream in,
String fileName,
long fileSize,
String description)
This method handles the stream negotiation process and transmits the file
to the remote user.
|
protected void |
setException(Exception exception) |
protected void |
setOutputStream(OutputStream stream) |
static void |
setResponseTimeout(int responseTimeout)
Sets the time in milliseconds after which the file transfer negotiation
process will timeout if the other user has not responded.
|
protected void |
setStatus(FileTransfer.Status status) |
protected boolean |
updateStatus(FileTransfer.Status oldStatus,
FileTransfer.Status newStatus) |
getAmountWritten, getError, getException, getFileName, getFilePath, getFileSize, getPeer, getProgress, getStatus, getStreamID, isDone, setError, setFileInfo, setFileInfo, writeToStream
protected OutgoingFileTransfer(org.jxmpp.jid.Jid initiator, org.jxmpp.jid.Jid target, String streamID, FileTransferNegotiator transferNegotiator)
public static int getResponseTimeout()
public static void setResponseTimeout(int responseTimeout)
responseTimeout
- The timeout time in milliseconds.protected void setOutputStream(OutputStream stream)
protected OutputStream getOutputStream()
StreamNegotiator
.public OutputStream sendFile(String fileName, long fileSize, String description) throws XMPPException, SmackException, InterruptedException
fileName
- The name of the file that will be transmitted. It is
preferable for this name to have an extension as it will be
used to determine the type of file it is.fileSize
- The size in bytes of the file that will be transmitted.description
- A description of the file that will be transmitted.XMPPException
- Thrown if an error occurs during the file transfer
negotiation process.SmackException
- if there was no response from the server.InterruptedException
public void sendFile(String fileName, long fileSize, String description, OutgoingFileTransfer.NegotiationProgress progress)
OutgoingFileTransfer.NegotiationProgress
callback.fileName
- The name of the file that will be transmitted. It is
preferable for this name to have an extension as it will be
used to determine the type of file it is.fileSize
- The size in bytes of the file that will be transmitted.description
- A description of the file that will be transmitted.progress
- A callback to monitor the progress of the file transfer
negotiation process and to retrieve the OutputStream when it
is complete.public void sendFile(File file, String description) throws SmackException
file
- the file to transfer to the remote entity.description
- a description for the file to transfer.SmackException
- If there is an error during the negotiation process or the
sending of the file.public void sendStream(InputStream in, String fileName, long fileSize, String description)
in
- the stream to transfer to the remote entity.fileName
- the name of the file that is transferredfileSize
- the size of the file that is transferreddescription
- a description for the file to transfer.public long getBytesSent()
Note: This method is only useful when the sendFile(File, String)
method is called, as it is the only method that actually transmits the
file.
public void cancel()
FileTransfer
cancel
in class FileTransfer
protected boolean updateStatus(FileTransfer.Status oldStatus, FileTransfer.Status newStatus)
updateStatus
in class FileTransfer
protected void setStatus(FileTransfer.Status status)
setStatus
in class FileTransfer
protected void setException(Exception exception)
setException
in class FileTransfer