diff options
author | Vitaly Takmazov | 2017-08-15 17:12:17 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-08-15 17:26:52 +0300 |
commit | 62960df0089be25bc58aadcb99fd0f8cbbb4cda2 (patch) | |
tree | 9e3e9740722b622578a55961c616de7e5abed66a /juick-xmpp | |
parent | d98cbc9267033d65779b01384d633d780ec58e05 (diff) |
xmpp: handle file transfer errors
Diffstat (limited to 'juick-xmpp')
-rw-r--r-- | juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java b/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java index 8317c600..ff879bee 100644 --- a/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java +++ b/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java @@ -176,7 +176,7 @@ public class XMPPConnection implements AutoCloseable { FileTransfer ft = e.accept(filePath).get(); ft.addFileTransferStatusListener(st -> { logger.debug("{}: received {} of {}", e.getName(), st.getBytesTransferred(), e.getSize()); - if (ft.isDone()) { + if (st.getStatus().equals(FileTransfer.Status.COMPLETED)) { logger.info("transfer completed"); Message msg = new Message(); msg.setType(Message.Type.CHAT); @@ -190,6 +190,16 @@ public class XMPPConnection implements AutoCloseable { } catch (URISyntaxException e1) { logger.warn("attachment error", e1); } + } else if (st.getStatus().equals(FileTransfer.Status.FAILED)) { + logger.info("transfer failed", ft.getException()); + Message msg = new Message(); + msg.setType(Message.Type.CHAT); + msg.setFrom(xmpp.getJid()); + msg.setTo(e.getInitiator()); + msg.setBody("File transfer failed, please report to us"); + router.sendMessage(msg); + } else if (st.getStatus().equals(FileTransfer.Status.CANCELED)) { + logger.info("transfer cancelled"); } }); ft.transfer(); |