From b73774260ab692f0c801ec09ec7f7e1d397a820e Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 14 Nov 2019 20:48:47 +0100 Subject: make jingle state transitions less error prone --- .../messenger/xmpp/jingle/JingleConnection.java | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/main/java') 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 9adb6f62e..9ac39ed5c 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java @@ -73,6 +73,8 @@ public class JingleConnection implements Transferable { private Element fileOffer; private DownloadableFile file = null; + private boolean proxyActivationFailed = false; + private String contentName; private String contentCreator; private Transport initialTransport; @@ -177,6 +179,7 @@ public class JingleConnection implements Transferable { @Override public void failed() { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": proxy activation failed"); + proxyActivationFailed = true; if (initiating()) { sendFallbackToIbb(); } @@ -718,6 +721,11 @@ public class JingleConnection implements Transferable { } private void receiveAccept(JinglePacket packet) { + if (responding()) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order session-accept (we were responding)"); + respondToIqWithOutOfOrder(packet); + return; + } if (this.mJingleStatus != JINGLE_STATUS_INITIATED) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order session-accept"); respondToIqWithOutOfOrder(packet); @@ -927,6 +935,16 @@ public class JingleConnection implements Transferable { private void receiveFallbackToIbb(JinglePacket packet) { + if (initiating()) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order transport-replace (we were initiating)"); + respondToIqWithOutOfOrder(packet); + return; + } + if (mJingleStatus != JINGLE_STATUS_ACCEPTED && !proxyActivationFailed) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order transport-replace"); + respondToIqWithOutOfOrder(packet); + return; + } Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": receiving fallback to ibb"); final String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size"); if (receivedBlockSize != null) { @@ -965,6 +983,16 @@ public class JingleConnection implements Transferable { } private void receiveTransportAccept(JinglePacket packet) { + if (responding()) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order transport-accept (we were responding)"); + respondToIqWithOutOfOrder(packet); + return; + } + if (this.mJingleStatus != JINGLE_STATUS_ACCEPTED) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order transport-accept"); + respondToIqWithOutOfOrder(packet); + return; + } if (packet.getJingleContent().hasIbbTransport()) { final Element ibbTransport = packet.getJingleContent().ibbTransport(); final String receivedBlockSize = ibbTransport.getAttribute("block-size"); @@ -988,8 +1016,6 @@ public class JingleConnection implements Transferable { //might be receive instead if we are not initiating if (initiating()) { this.transport.connect(onIbbTransportConnected); - } else { - this.transport.receive(file, onFileTransmissionStatusChanged); } } else { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received invalid transport-accept"); -- cgit v1.2.3