public final class FileTransferNegotiator extends Manager
Modifier and Type | Field and Description |
---|---|
static boolean |
IBB_ONLY
A static variable to use only offer IBB for file transfer.
|
static String |
SI_NAMESPACE |
static String |
SI_PROFILE_FILE_TRANSFER_NAMESPACE |
protected static String |
STREAM_DATA_FIELD_NAME |
Modifier and Type | Method and Description |
---|---|
static FileTransferNegotiator |
getInstanceFor(XMPPConnection connection)
Returns the file transfer negotiator related to a particular connection.
|
static String |
getNextStreamID()
Returns a new, unique, stream ID to identify a file transfer.
|
static Collection<String> |
getSupportedProtocols()
Returns a collection of the supported transfer protocols.
|
static boolean |
isServiceEnabled(XMPPConnection connection)
Checks to see if all file transfer related services are enabled on the
connection.
|
StreamNegotiator |
negotiateOutgoingTransfer(org.jxmpp.jid.Jid userID,
String streamID,
String fileName,
long size,
String desc,
int responseTimeout)
Send a request to another user to send them a file.
|
StreamNegotiator |
selectStreamNegotiator(FileTransferRequest request)
Selects an appropriate stream negotiator after examining the incoming file transfer request.
|
connection, getAuthenticatedConnectionOrThrow, schedule
public static final String SI_NAMESPACE
public static final String SI_PROFILE_FILE_TRANSFER_NAMESPACE
protected static final String STREAM_DATA_FIELD_NAME
public static boolean IBB_ONLY
public static FileTransferNegotiator getInstanceFor(XMPPConnection connection)
connection
- The connection for which the transfer manager is desiredpublic static boolean isServiceEnabled(XMPPConnection connection)
connection
- The connection to checkpublic static Collection<String> getSupportedProtocols()
public StreamNegotiator selectStreamNegotiator(FileTransferRequest request) throws SmackException.NotConnectedException, FileTransferException.NoStreamMethodsOfferedException, FileTransferException.NoAcceptableTransferMechanisms, InterruptedException
request
- The related file transfer request.FileTransferException.NoStreamMethodsOfferedException
- If there are either no stream methods contained in the packet, or
there is not an appropriate stream method.SmackException.NotConnectedException
FileTransferException.NoAcceptableTransferMechanisms
InterruptedException
public static String getNextStreamID()
public StreamNegotiator negotiateOutgoingTransfer(org.jxmpp.jid.Jid userID, String streamID, String fileName, long size, String desc, int responseTimeout) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, FileTransferException.NoAcceptableTransferMechanisms, InterruptedException
If they accept, the stanza will contain the other user's chosen stream type to send the file across. The two choices this implementation provides to the other user for file transfer are SOCKS5 Bytestreams, which is the preferred method of transfer, and In-Band Bytestreams, which is the fallback mechanism.
The other user may choose to decline the file request if they do not desire the file, their client does not support XEP-0096, or if there are no acceptable means to transfer the file.
Finally, if the other user does not respond this method will return null after the specified timeout.userID
- The userID of the user to whom the file will be sent.streamID
- The unique identifier for this file transfer.fileName
- The name of this file. Preferably it should include an
extension as it is used to determine what type of file it is.size
- The size, in bytes, of the file.desc
- A description of the file.responseTimeout
- The amount of time, in milliseconds, to wait for the remote
user to respond. If they do not respond in time, thisXMPPException.XMPPErrorException
- Thrown if there is an error negotiating the file transfer.SmackException.NotConnectedException
SmackException.NoResponseException
FileTransferException.NoAcceptableTransferMechanisms
InterruptedException