public void getFile(){ manager.addFileTransferListener(new FileTransferListener() { @Override public void fileTransferRequest(FileTransferRequest request) { IncomingFileTransfer fileTransfer = request.accept(); try { fileTransfer.recieveFile(new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "�����ļ�")); } catch (XMPPException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); }
@Override public void fileTransferRequest(final FileTransferRequest request) { log.fine("Received file transfer request " + request); final String uniqueFileIdentifier = request.getDescription(); final MD5Hash hash = new MD5Hash(uniqueFileIdentifier); final File temporaryIncomingFile = getTemporaryFileToStoreIncomingTransfer(); log.fine("File " + request.getFileName() + " being saved as " + temporaryIncomingFile.getAbsolutePath()); final IncomingFileTransfer transfer = request.accept(); try { transfer.recieveFile(temporaryIncomingFile); FileTransferWorker fileTransferWorker = new FileTransferWorker(new FileTransferWorker.FileTransferWorkerDelegate() { @Override public void transferComplete() { fileTransferDidComplete(request.getFileName(), temporaryIncomingFile, hash, transfer); } }, transfer); fileTransferWorker.start(); } catch (XMPPException ex) { log.log(Level.SEVERE, null, ex); } }
public IncomingTransfer(Module module, DeploymentID listenerID, File file, IncomingFileTransfer transfer, TransferHandle handle, long inactivityTimeout, long fileSize, boolean notifyProgress) { super(module, listenerID, inactivityTimeout, handle, file, fileSize, notifyProgress); this.transfer = transfer; this.listenerID = listenerID; }
public void accept(IncomingTransferHandle handle, DeploymentID listenerID) { File destination = handle.getLocalFile(); long inactivityTimeout = handle.getInactivityTimeout(); boolean receiveProgressUpdates = handle.isReceiveProgressUpdate(); LOG.debug( "Accepting transfer. Handle: " + handle + ", dest: " + destination.getAbsolutePath() ); createSubFolders(destination); FileTransferRequest fileTransferRequest = handlersRequestMap.get( handle ); final IncomingFileTransfer transfer = fileTransferRequest.accept(); IncomingTransfer fileTransfer = new IncomingTransfer(module, listenerID, destination, transfer, handle, inactivityTimeout, fileTransferRequest.getFileSize(), receiveProgressUpdates); if ( receiveProgressUpdates ) { TransferProgress transferProgress = new TransferProgress( handle, destination.getName(), fileTransferRequest.getFileSize(), transfer.getStatus(), 0L, 0D, 0, false ); Message message = AbstractTransfer.createUpdateTransferProgressMessage(module.getContainerID(), listenerID, transferProgress); module.sendMessage(message); } try { fileTransfer.start(); } catch (IllegalArgumentException e) { LOG.error("Destination is not writable. Handle: " + handle + ", dest: " + destination.getAbsolutePath()); reject(handle); } addTransfer(handle, fileTransfer); }
public void putFileTransfer(String path, IncomingFileTransfer fileTransfer) { fileTransfers.put(path, fileTransfer); }
public IncomingFileTransfer getFileTransfer(String path) { return fileTransfers.get(path); }
/** * Instantiates a new file transfer worker. * * @param delegate * the delegate * @param transfer * the transfer */ public FileTransferWorker(FileTransferWorkerDelegate delegate, IncomingFileTransfer transfer) { this.delegate = delegate; this.transfer = transfer; }