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) {
|
||||
String sid = null;
|
||||
Element payload = null;
|
||||
final String sid;
|
||||
final Element payload;
|
||||
if (packet.hasChild("open", Namespace.IBB)) {
|
||||
payload = packet.findChild("open", Namespace.IBB);
|
||||
sid = payload.getAttribute("sid");
|
||||
|
@ -133,6 +133,9 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
|||
} else if (packet.hasChild("close", Namespace.IBB)) {
|
||||
payload = packet.findChild("close", Namespace.IBB);
|
||||
sid = payload.getAttribute("sid");
|
||||
} else {
|
||||
payload = null;
|
||||
sid = null;
|
||||
}
|
||||
if (sid != null) {
|
||||
for (final AbstractJingleConnection connection : this.connections.values()) {
|
||||
|
@ -140,7 +143,10 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
|||
final JingleFileTransferConnection fileTransfer = (JingleFileTransferConnection) connection;
|
||||
final JingleTransport transport = fileTransfer.getTransport();
|
||||
if (transport instanceof JingleInBandTransport) {
|
||||
((JingleInBandTransport) transport).deliverPayload(packet, payload);
|
||||
final JingleInBandTransport inBandTransport = (JingleInBandTransport) transport;
|
||||
if (inBandTransport.matches(account, sid)) {
|
||||
inBandTransport.deliverPayload(packet, payload);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package eu.siacs.conversations.xmpp.jingle;
|
|||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -77,6 +79,10 @@ public class JingleInBandTransport extends JingleTransport {
|
|||
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) {
|
||||
IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
|
||||
iq.setTo(this.counterpart);
|
||||
|
@ -96,7 +102,7 @@ public class JingleInBandTransport extends JingleTransport {
|
|||
|
||||
@Override
|
||||
public void receive(DownloadableFile file, OnFileTransmissionStatusChanged callback) {
|
||||
this.onFileTransmissionStatusChanged = callback;
|
||||
this.onFileTransmissionStatusChanged = Preconditions.checkNotNull(callback);
|
||||
this.file = file;
|
||||
try {
|
||||
this.digest = MessageDigest.getInstance("SHA-1");
|
||||
|
@ -116,7 +122,7 @@ public class JingleInBandTransport extends JingleTransport {
|
|||
|
||||
@Override
|
||||
public void send(DownloadableFile file, OnFileTransmissionStatusChanged callback) {
|
||||
this.onFileTransmissionStatusChanged = callback;
|
||||
this.onFileTransmissionStatusChanged = Preconditions.checkNotNull(callback);
|
||||
this.file = file;
|
||||
try {
|
||||
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));
|
||||
}
|
||||
} 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);
|
||||
this.onFileTransmissionStatusChanged.onFileTransferAborted();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue