From 506b09282104d1272295a662b9af7f5db8ab9bc4 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 31 Aug 2019 15:47:29 +0200 Subject: more ibb fixes (include sid in transport-accept) --- .../messenger/xmpp/jingle/JingleConnection.java | 34 +++++++++++++++------- .../xmpp/jingle/JingleInbandTransport.java | 6 ++-- 2 files changed, 25 insertions(+), 15 deletions(-) (limited to 'src/main/java/de/pixart/messenger/xmpp/jingle') diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java index 7982cfeea..30ca27391 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java @@ -658,9 +658,13 @@ public class JingleConnection implements Transferable { } else if (content.hasIbbTransport()) { String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size"); if (receivedBlockSize != null) { - int bs = Integer.parseInt(receivedBlockSize); - if (bs > this.ibbBlockSize) { - this.ibbBlockSize = bs; + try { + int bs = Integer.parseInt(receivedBlockSize); + if (bs > this.ibbBlockSize) { + this.ibbBlockSize = bs; + } + } catch (Exception e) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to parse block size in session-accept"); } } this.transport = new JingleInbandTransport(this, this.transportId, this.ibbBlockSize); @@ -847,12 +851,16 @@ public class JingleConnection implements Transferable { private boolean receiveFallbackToIbb(JinglePacket packet) { - Log.d(Config.LOGTAG, "receiving fallack to ibb"); + Log.d(Config.LOGTAG, "receiving fallback to ibb"); final String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size"); if (receivedBlockSize != null) { - final int bs = Integer.parseInt(receivedBlockSize); - if (bs < this.ibbBlockSize) { - this.ibbBlockSize = bs; + try { + final int bs = Integer.parseInt(receivedBlockSize); + if (bs < this.ibbBlockSize) { + this.ibbBlockSize = bs; + } + } catch (NumberFormatException e) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to parse block size in transport-replace"); } } this.transportId = packet.getJingleContent().getTransportId(); @@ -861,8 +869,8 @@ public class JingleConnection implements Transferable { final JinglePacket answer = bootstrapPacket("transport-accept"); final Content content = new Content(contentCreator, contentName); - content.setFileOffer(fileOffer, ftVersion); content.ibbTransport().setAttribute("block-size", this.ibbBlockSize); + content.ibbTransport().setAttribute("sid", this.transportId); answer.setContent(content); @@ -885,9 +893,13 @@ public class JingleConnection implements Transferable { String receivedBlockSize = packet.getJingleContent().ibbTransport() .getAttribute("block-size"); if (receivedBlockSize != null) { - int bs = Integer.parseInt(receivedBlockSize); - if (bs > this.ibbBlockSize) { - this.ibbBlockSize = bs; + try { + int bs = Integer.parseInt(receivedBlockSize); + if (bs < this.ibbBlockSize) { + this.ibbBlockSize = bs; + } + } catch (NumberFormatException e) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to parse block size in transport-accept"); } } this.transport = new JingleInbandTransport(this, this.transportId, this.ibbBlockSize); 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 f3e7cc814..72a9142ec 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java @@ -176,12 +176,10 @@ public class JingleInbandTransport extends JingleTransport { this.account.getXmppConnection().sendIqPacket(iq, this.onAckReceived); this.account.getXmppConnection().r(); //don't fill up stanza queue too much this.seq++; - if (this.remainingSize > 0) { - connection.updateProgress((int) ((((double) (this.fileSize - this.remainingSize)) / this.fileSize) * 100)); - } else { + connection.updateProgress((int) ((((double) (this.fileSize - this.remainingSize)) / this.fileSize) * 100)); + if (this.remainingSize <= 0) { sendClose(); file.setSha1Sum(digest.digest()); - Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": sendNextBlock() remaining size"); this.onFileTransmissionStatusChanged.onFileTransmitted(file); fileInputStream.close(); } -- cgit v1.2.3