fixed bug in ibb delivery introduced in earlier refactoring
This commit is contained in:
parent
34f42c73bc
commit
7538e387ec
|
@ -122,8 +122,8 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deliverIbbPacket(Account account, IqPacket packet) {
|
public void deliverIbbPacket(Account account, IqPacket packet) {
|
||||||
String sid = null;
|
final String sid;
|
||||||
Element payload = null;
|
final Element payload;
|
||||||
if (packet.hasChild("open", Namespace.IBB)) {
|
if (packet.hasChild("open", Namespace.IBB)) {
|
||||||
payload = packet.findChild("open", Namespace.IBB);
|
payload = packet.findChild("open", Namespace.IBB);
|
||||||
sid = payload.getAttribute("sid");
|
sid = payload.getAttribute("sid");
|
||||||
|
@ -133,6 +133,9 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
} else if (packet.hasChild("close", Namespace.IBB)) {
|
} else if (packet.hasChild("close", Namespace.IBB)) {
|
||||||
payload = packet.findChild("close", Namespace.IBB);
|
payload = packet.findChild("close", Namespace.IBB);
|
||||||
sid = payload.getAttribute("sid");
|
sid = payload.getAttribute("sid");
|
||||||
|
} else {
|
||||||
|
payload = null;
|
||||||
|
sid = null;
|
||||||
}
|
}
|
||||||
if (sid != null) {
|
if (sid != null) {
|
||||||
for (final AbstractJingleConnection connection : this.connections.values()) {
|
for (final AbstractJingleConnection connection : this.connections.values()) {
|
||||||
|
@ -140,7 +143,10 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
final JingleFileTransferConnection fileTransfer = (JingleFileTransferConnection) connection;
|
final JingleFileTransferConnection fileTransfer = (JingleFileTransferConnection) connection;
|
||||||
final JingleTransport transport = fileTransfer.getTransport();
|
final JingleTransport transport = fileTransfer.getTransport();
|
||||||
if (transport instanceof JingleInBandTransport) {
|
if (transport instanceof JingleInBandTransport) {
|
||||||
((JingleInBandTransport) transport).deliverPayload(packet, payload);
|
final JingleInBandTransport inBandTransport = (JingleInBandTransport) transport;
|
||||||
|
if (inBandTransport.matches(account, sid)) {
|
||||||
|
inBandTransport.deliverPayload(packet, payload);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package eu.siacs.conversations.xmpp.jingle;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -77,6 +79,10 @@ public class JingleInBandTransport extends JingleTransport {
|
||||||
this.account.getXmppConnection().sendIqPacket(iq, null);
|
this.account.getXmppConnection().sendIqPacket(iq, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean matches(final Account account, final String sessionId) {
|
||||||
|
return this.account == account && this.sessionId.equals(sessionId);
|
||||||
|
}
|
||||||
|
|
||||||
public void connect(final OnTransportConnected callback) {
|
public void connect(final OnTransportConnected callback) {
|
||||||
IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
|
IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
|
||||||
iq.setTo(this.counterpart);
|
iq.setTo(this.counterpart);
|
||||||
|
@ -96,7 +102,7 @@ public class JingleInBandTransport extends JingleTransport {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receive(DownloadableFile file, OnFileTransmissionStatusChanged callback) {
|
public void receive(DownloadableFile file, OnFileTransmissionStatusChanged callback) {
|
||||||
this.onFileTransmissionStatusChanged = callback;
|
this.onFileTransmissionStatusChanged = Preconditions.checkNotNull(callback);
|
||||||
this.file = file;
|
this.file = file;
|
||||||
try {
|
try {
|
||||||
this.digest = MessageDigest.getInstance("SHA-1");
|
this.digest = MessageDigest.getInstance("SHA-1");
|
||||||
|
@ -116,7 +122,7 @@ public class JingleInBandTransport extends JingleTransport {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(DownloadableFile file, OnFileTransmissionStatusChanged callback) {
|
public void send(DownloadableFile file, OnFileTransmissionStatusChanged callback) {
|
||||||
this.onFileTransmissionStatusChanged = callback;
|
this.onFileTransmissionStatusChanged = Preconditions.checkNotNull(callback);
|
||||||
this.file = file;
|
this.file = file;
|
||||||
try {
|
try {
|
||||||
this.remainingSize = this.file.getExpectedSize();
|
this.remainingSize = this.file.getExpectedSize();
|
||||||
|
@ -205,7 +211,7 @@ public class JingleInBandTransport extends JingleTransport {
|
||||||
connection.updateProgress((int) ((((double) (this.fileSize - this.remainingSize)) / this.fileSize) * 100));
|
connection.updateProgress((int) ((((double) (this.fileSize - this.remainingSize)) / this.fileSize) * 100));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + e.getMessage());
|
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + e.getMessage(), e);
|
||||||
FileBackend.close(fileOutputStream);
|
FileBackend.close(fileOutputStream);
|
||||||
this.onFileTransmissionStatusChanged.onFileTransferAborted();
|
this.onFileTransmissionStatusChanged.onFileTransferAborted();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue