report not-acceptable on jingle errors

This commit is contained in:
Daniel Gultsch 2019-10-01 11:31:15 +02:00
parent d2d9bbe3da
commit f8bd4284a5
2 changed files with 210 additions and 209 deletions

View File

@ -270,9 +270,10 @@ public class JingleConnection implements Transferable {
IqPacket response; IqPacket response;
if (returnResult) { if (returnResult) {
response = packet.generateResponse(IqPacket.TYPE.RESULT); response = packet.generateResponse(IqPacket.TYPE.RESULT);
} else { } else {
response = packet.generateResponse(IqPacket.TYPE.ERROR); response = packet.generateResponse(IqPacket.TYPE.ERROR);
final Element error = response.addChild("error").setAttribute("type", "cancel");
error.addChild("not-acceptable", "urn:ietf:params:xml:ns:xmpp-stanzas");
} }
mXmppConnectionService.sendIqPacket(account, response, null); mXmppConnectionService.sendIqPacket(account, response, null);
} }
@ -933,8 +934,9 @@ public class JingleConnection implements Transferable {
private boolean receiveTransportAccept(JinglePacket packet) { private boolean receiveTransportAccept(JinglePacket packet) {
if (packet.getJingleContent().hasIbbTransport()) { if (packet.getJingleContent().hasIbbTransport()) {
String receivedBlockSize = packet.getJingleContent().ibbTransport() final Element ibbTransport = packet.getJingleContent().ibbTransport();
.getAttribute("block-size"); final String receivedBlockSize = ibbTransport.getAttribute("block-size");
final String sid = ibbTransport.getAttribute("sid");
if (receivedBlockSize != null) { if (receivedBlockSize != null) {
try { try {
int bs = Integer.parseInt(receivedBlockSize); int bs = Integer.parseInt(receivedBlockSize);
@ -947,6 +949,10 @@ public class JingleConnection implements Transferable {
} }
this.transport = new JingleInbandTransport(this, this.transportId, this.ibbBlockSize); this.transport = new JingleInbandTransport(this, this.transportId, this.ibbBlockSize);
if (sid == null || !sid.equals(this.transportId)) {
Log.w(Config.LOGTAG,String.format("%s: sid in transport-accept (%s) did not match our sid (%s) ", account.getJid().asBareJid(), sid, transportId));
}
//might be receive instead if we are not initiating //might be receive instead if we are not initiating
if (initiating()) { if (initiating()) {
this.transport.connect(onIbbTransportConnected); this.transport.connect(onIbbTransportConnected);
@ -955,6 +961,7 @@ public class JingleConnection implements Transferable {
} }
return true; return true;
} else { } else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received invalid transport-accept");
return false; return false;
} }
} }

View File

@ -80,18 +80,12 @@ public class JingleInbandTransport extends JingleTransport {
open.setAttribute("stanza", "iq"); open.setAttribute("stanza", "iq");
open.setAttribute("block-size", Integer.toString(this.blockSize)); open.setAttribute("block-size", Integer.toString(this.blockSize));
this.connected = true; this.connected = true;
this.account.getXmppConnection().sendIqPacket(iq, this.account.getXmppConnection().sendIqPacket(iq, (account, packet) -> {
new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account,
IqPacket packet) {
if (packet.getType() != IqPacket.TYPE.RESULT) { if (packet.getType() != IqPacket.TYPE.RESULT) {
callback.failed(); callback.failed();
} else { } else {
callback.established(); callback.established();
} }
}
}); });
} }