/** * Returns the output stream connected to the peer to transfer the file. It * is only available after it has been successfully negotiated by the * {@link StreamNegotiator}. * * @return Returns the output stream connected to the peer to transfer the * file. */ protected OutputStream getOutputStream() { if (getStatus().equals(FileTransfer.Status.negotiated)) { return outputStream; } else { return null; } }
@Override protected void setStatus(Status status) { Status oldStatus = getStatus(); super.setStatus(status); if (callback != null) { callback.statusUpdated(oldStatus, status); } }
/** * Returns the current status of the negotiation process. * * @return Returns the current status of the negotiation process. */ public Status getStatus() { if (delegate == null) { throw new IllegalStateException("delegate not yet set"); } return delegate.getStatus(); }
/** * Returns the output stream connected to the peer to transfer the file. It * is only available after it has been succesfully negotiated by the * {@link StreamNegotiator}. * * @return Returns the output stream connected to the peer to transfer the * file. */ protected OutputStream getOutputStream() { if (getStatus().equals(FileTransfer.Status.NEGOTIATED)) { return outputStream; } else { return null; } }
/** * Returns the output stream connected to the peer to transfer the file. It * is only available after it has been successfully negotiated by the * {@link StreamNegotiator}. * * @return Returns the output stream connected to the peer to transfer the * file. */ protected OutputStream getOutputStream() { if (getStatus().equals(Status.negotiated)) { return outputStream; } else { return null; } }
/** * Returns the output stream connected to the peer to transfer the file. It * is only available after it has been successfully negotiated by the * {@link StreamNegotiator}. * * @return Returns the output stream connected to the peer to transfer the * file. */ protected OutputStream getOutputStream() { if (getStatus().equals(FileTransfer.Status.negotiated)) { return outputStream; } else { return null; } }
/** * Returns the output stream connected to the peer to transfer the file. It * is only available after it has been succesfully negotiated by the * {@link StreamNegotiator}. * * @return Returns the output stream connected to the peer to transfer the * file. */ protected OutputStream getOutputStream() { if (getStatus().equals(FileTransfer.Status.negotiated)) { return outputStream; } else { return null; } }
FileTransferManager manager = new FileTransferManager(connection); OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer("usre2@myHost/Smack"); File file = new File(filenameWithPath); try { transfer.sendFile(file, "test_file"); } catch (XMPPException e) { e.printStackTrace(); } while(!transfer.isDone()) { if(transfer.getStatus().equals(Status.error)) { System.out.println("ERROR!!! " + transfer.getError()); } else if (transfer.getStatus().equals(Status.cancelled) || transfer.getStatus().equals(Status.refused)) { System.out.println("Cancelled!!! " + transfer.getError()); } try { Thread.sleep(1000L); } catch (InterruptedException e) { e.printStackTrace(); } } if(transfer.getStatus().equals(Status.refused) || transfer.getStatus().equals(Status.error) || transfer.getStatus().equals(Status.cancelled)){ System.out.println("refused cancelled error " + transfer.getError()); } else { System.out.println("Success"); }
@Override protected void setStatus(Status status) { Status oldStatus = getStatus(); super.setStatus(status); if(callback != null) { callback.statusUpdated(oldStatus, status); } }
@Override protected void setStatus(Status status) { Status oldStatus = getStatus(); super.setStatus(status); if(callback != null) { callback.statusUpdated(oldStatus, status); } }
@Override protected void setStatus(Status status) { Status oldStatus = getStatus(); super.setStatus(status); if(callback != null) { callback.statusUpdated(oldStatus, status); } }
protected Void doInBackground(Void... params) { while (!transfer.isDone()) { if (transfer.getStatus().equals("Error")) { Log.d("file transfer", "ERROR!!! " + transfer.getError()); } else if (transfer.getStatus().equals("Cancelled") || transfer.getStatus().equals("Refused")) { Log.d("file transfer", "Cancelled!!! " + transfer.getError()); if (transfer.getStatus().equals("Refused") || transfer.getStatus().equals("Error") || transfer.getStatus().equals("Cancelled")) { Log.i("file transfer", "refused cancelled error " + transfer.getError());
oft.sendStream(new ByteArrayInputStream(dataToSend), "hello.txt", dataToSend.length, "A greeting"); outerloop: while (!oft.isDone()) { switch (oft.getStatus()) { case error: System.out.println("Filetransfer error: " + oft.getError()); break outerloop; default: System.out.println("Filetransfer status: " + oft.getStatus() + ". Progress: " + oft.getProgress()); break;
public Object construct() { while (true) { try { if(transfer.getBytesSent() >0 && _starttime==0){ _starttime = System.currentTimeMillis(); } long starttime = System.currentTimeMillis(); long startbyte = transfer.getBytesSent(); Thread.sleep(500); FileTransfer.Status status = transfer.getStatus(); if (status == Status.error || status == Status.complete || status == Status.cancelled || status == Status.refused) { break; } long endtime = System.currentTimeMillis(); long endbyte = transfer.getBytesSent(); long timediff = endtime-starttime; long bytediff = endbyte-startbyte; updateBar(transfer, nickname, TransferUtils.calculateSpeed(bytediff, timediff) ); } catch (InterruptedException e) { Log.error("Unable to sleep thread.", e); } } return ""; }
private OutputStream negotiateStream(String fileName, long fileSize, String description) throws XMPPException { // Negotiate the file transfer profile setStatus(Status.NEGOTIATING_TRANSFER); StreamNegotiator streamNegotiator = negotiator.negotiateOutgoingTransfer( getPeer(), streamID, fileName, fileSize, description, RESPONSE_TIMEOUT); if (streamNegotiator == null) { setStatus(Status.ERROR); setError(Error.NO_RESPONSE); return null; } if (!getStatus().equals(Status.NEGOTIATING_TRANSFER)) { return null; } // Negotiate the stream setStatus(Status.NEGOTIATING_STREAM); outputStream = streamNegotiator.createOutgoingStream(streamID, initiator, getPeer()); if (!getStatus().equals(Status.NEGOTIATING_STREAM)) { return null; } setStatus(Status.NEGOTIATED); return outputStream; }
oft.sendStream(new ByteArrayInputStream(dataToSend), "hello.txt", dataToSend.length, "A greeting"); outerloop: while (!oft.isDone()) { switch (oft.getStatus()) { case error: System.out.println("Filetransfer error: " + oft.getError()); break outerloop; default: System.out.println("Filetransfer status: " + oft.getStatus() + ". Progress: " + oft.getProgress()); break;
private void updateBar(final OutgoingFileTransfer transfer, String nickname, String kBperSecond) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.negotiating_stream) { titleLabel.setText(Res.getString("message.negotiation.file.transfer", nickname));