diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java index 151e9409f..df8b962c4 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java @@ -14,6 +14,7 @@ import de.pixart.messenger.Config; import de.pixart.messenger.entities.Account; import de.pixart.messenger.entities.DownloadableFile; import de.pixart.messenger.persistance.FileBackend; +import de.pixart.messenger.services.AbstractConnectionManager; import de.pixart.messenger.xml.Element; import de.pixart.messenger.xmpp.OnIqPacketReceived; import de.pixart.messenger.xmpp.stanzas.IqPacket; @@ -35,6 +36,7 @@ public class JingleInbandTransport extends JingleTransport { private JingleConnection connection; private InputStream fileInputStream = null; + private InputStream innerInputStream = null; private OutputStream fileOutputStream = null; private long remainingSize = 0; private long fileSize = 0; @@ -129,10 +131,11 @@ public class JingleInbandTransport extends JingleTransport { callback.onFileTransferAborted(); return; } + innerInputStream = AbstractConnectionManager.upgrade(file, fileInputStream, false); if (this.connected) { this.sendNextBlock(); } - } catch (NoSuchAlgorithmException e) { + } catch (Exception e) { callback.onFileTransferAborted(); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + e.getMessage()); } @@ -141,26 +144,14 @@ public class JingleInbandTransport extends JingleTransport { @Override public void disconnect() { this.connected = false; - if (this.fileOutputStream != null) { - try { - this.fileOutputStream.close(); - } catch (IOException e) { - - } - } - if (this.fileInputStream != null) { - try { - this.fileInputStream.close(); - } catch (IOException e) { - - } - } + FileBackend.close(fileOutputStream); + FileBackend.close(fileInputStream); } private void sendNextBlock() { byte[] buffer = new byte[this.blockSize]; try { - int count = fileInputStream.read(buffer); + int count = innerInputStream.read(buffer); if (count == -1) { sendClose(); file.setSha1Sum(digest.digest()); @@ -168,7 +159,7 @@ public class JingleInbandTransport extends JingleTransport { fileInputStream.close(); return; } else if (count != buffer.length) { - int rem = fileInputStream.read(buffer, count, buffer.length - count); + int rem = innerInputStream.read(buffer, count, buffer.length - count); if (rem > 0) { count += rem; } |