@Override public void cancel() { setStatus(Status.cancelled); }
private void handleXMPPException(XMPPErrorException e) { StanzaError error = e.getStanzaError(); if (error != null) { switch (error.getCondition()) { case forbidden: setStatus(Status.refused); return; case bad_request: setStatus(Status.error); setError(Error.not_acceptable); break; default: setStatus(FileTransfer.Status.error); } } setException(e); }
@Override public void run() { // Create packet filter. try { outputStream = negotiateStream(fileName, fileSize, description); } catch (XMPPErrorException e) { handleXMPPException(e); return; } catch (Exception e) { setException(e); } if (outputStream == null) { return; } if (!updateStatus(Status.negotiated, Status.in_progress)) { return; } try { writeToStream(in, outputStream); } catch (IOException e) { setStatus(FileTransfer.Status.error); setException(e); } finally { CloseableUtil.maybeClose(in, LOGGER); CloseableUtil.maybeClose(outputStream, LOGGER); } updateStatus(Status.in_progress, FileTransfer.Status.complete); }
public void cancel() { setStatus(Status.CANCLED); }
public void cancel() { setStatus(Status.cancelled); }
public void cancel() { setStatus(Status.cancelled); }
public void cancel() { setStatus(Status.cancelled); }
private void handleXMPPException(XMPPException e) { setStatus(FileTransfer.Status.ERROR); XMPPError error = e.getXMPPError(); if (error != null) { int code = error.getCode(); if (code == 403) { setStatus(Status.REFUSED); return; } else if (code == 400) { setStatus(Status.ERROR); setError(Error.NOT_ACCEPTABLE); } } setException(e); return; }
private void handleXMPPException(XMPPException e) { XMPPError error = e.getXMPPError(); if (error != null) { int code = error.getCode(); if (code == 403) { setStatus(Status.refused); return; } else if (code == 400) { setStatus(Status.error); setError(Error.not_acceptable); } else { setStatus(FileTransfer.Status.error); } } setException(e); }
private void handleXMPPException(XMPPException e) { XMPPError error = e.getXMPPError(); if (error != null) { int code = error.getCode(); if (code == 403) { setStatus(Status.refused); return; } else if (code == 400) { setStatus(Status.error); setError(Error.not_acceptable); } else { setStatus(FileTransfer.Status.error); } } setException(e); }
private void handleXMPPException(XMPPException e) { XMPPError error = e.getXMPPError(); if (error != null) { int code = error.getCode(); if (code == 403) { setStatus(Status.refused); return; } else if (code == 400) { setStatus(Status.error); setError(Error.not_acceptable); } else { setStatus(Status.error); } } setException(e); }
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; }
writeToStream(in, outputStream); } catch (XMPPException e) { setStatus(FileTransfer.Status.error); setException(e); } finally {
writeToStream(in, outputStream); } catch (XMPPException e) { setStatus(FileTransfer.Status.error); setException(e); } finally {
private OutputStream negotiateStream(String fileName, long fileSize, String description) throws XMPPException { // Negotiate the file transfer profile if (!updateStatus(Status.initial, Status.negotiating_transfer)) { throw new XMPPException("Illegal state change"); } StreamNegotiator streamNegotiator = negotiator.negotiateOutgoingTransfer( getPeer(), streamID, fileName, fileSize, description, RESPONSE_TIMEOUT); if (streamNegotiator == null) { setStatus(Status.error); setError(Error.no_response); return null; } // Negotiate the stream if (!updateStatus(Status.negotiating_transfer, Status.negotiating_stream)) { throw new XMPPException("Illegal state change"); } outputStream = streamNegotiator.createOutgoingStream(streamID, initiator, getPeer()); if (!updateStatus(Status.negotiating_stream, Status.negotiated)) { throw new XMPPException("Illegal state change"); } return outputStream; }
private OutputStream negotiateStream(String fileName, long fileSize, String description) throws XMPPException { // Negotiate the file transfer profile if (!updateStatus(Status.initial, Status.negotiating_transfer)) { throw new XMPPException("Illegal state change"); } StreamNegotiator streamNegotiator = negotiator.negotiateOutgoingTransfer( getPeer(), streamID, fileName, fileSize, description, RESPONSE_TIMEOUT); if (streamNegotiator == null) { setStatus(Status.error); setError(Error.no_response); return null; } // Negotiate the stream if (!updateStatus(Status.negotiating_transfer, Status.negotiating_stream)) { throw new XMPPException("Illegal state change"); } outputStream = streamNegotiator.createOutgoingStream(streamID, initiator, getPeer()); if (!updateStatus(Status.negotiating_stream, Status.negotiated)) { throw new XMPPException("Illegal state change"); } return outputStream; }
private OutputStream negotiateStream(String fileName, long fileSize, String description) throws XMPPException { // Negotiate the file transfer profile if (!updateStatus(Status.initial, Status.negotiating_transfer)) { throw new XMPPException("Illegal state change"); } StreamNegotiator streamNegotiator = negotiator.negotiateOutgoingTransfer( getPeer(), streamID, fileName, fileSize, description, RESPONSE_TIMEOUT); if (streamNegotiator == null) { setStatus(Status.error); setError(Error.no_response); return null; } // Negotiate the stream if (!updateStatus(Status.negotiating_transfer, Status.negotiating_stream)) { throw new XMPPException("Illegal state change"); } outputStream = streamNegotiator.createOutgoingStream(streamID, initiator, getPeer()); if (!updateStatus(Status.negotiating_stream, Status.negotiated)) { throw new XMPPException("Illegal state change"); } return outputStream; }