Search in sources :

Example 1 with XMPPFileID

use of org.eclipse.ecf.provider.xmpp.identity.XMPPFileID in project ecf by eclipse.

the class XMPPOutgoingFileTransferHelper method sendOutgoingRequest.

public void sendOutgoingRequest(IFileID targetReceiver, IFileTransferInfo localFileToSend, IFileTransferListener progressListener, Map options) throws SendFileTransferException {
    if (manager == null)
        throw new SendFileTransferException("not connected");
    if (!(targetReceiver instanceof XMPPFileID))
        throw new SendFileTransferException("target receiver not XMPPFileID type.");
    final XMPPFileID fileID = (XMPPFileID) targetReceiver;
    int requestTimeout = -1;
    if (options != null) {
        final Object option = options.get(OUTGOING_REQUEST_TIMEOUT);
        if (option != null) {
            if (option instanceof String) {
                try {
                    requestTimeout = Integer.valueOf((String) option).intValue();
                } catch (final NumberFormatException e) {
                // Ignore
                }
            } else if (option instanceof Integer) {
                requestTimeout = ((Integer) option).intValue();
            }
        }
    }
    final XMPPOutgoingFileTransfer fileTransfer = new XMPPOutgoingFileTransfer(manager, fileID.getXMPPID(), localFileToSend, progressListener, requestTimeout);
    try {
        fileTransfer.startSend(localFileToSend.getFile(), localFileToSend.getDescription());
    } catch (final XMPPException e) {
        throw new SendFileTransferException("Exception sending outgoing file transfer request", e);
    }
}
Also used : SendFileTransferException(org.eclipse.ecf.filetransfer.SendFileTransferException) XMPPException(org.jivesoftware.smack.XMPPException) XMPPFileID(org.eclipse.ecf.provider.xmpp.identity.XMPPFileID)

Aggregations

SendFileTransferException (org.eclipse.ecf.filetransfer.SendFileTransferException)1 XMPPFileID (org.eclipse.ecf.provider.xmpp.identity.XMPPFileID)1 XMPPException (org.jivesoftware.smack.XMPPException)1