send fallback to ibb after proxy activation failed

This commit is contained in:
Daniel Gultsch 2019-09-01 21:41:28 +02:00
parent 10b1365264
commit 90e669313e

View file

@ -172,7 +172,9 @@ public class JingleConnection implements Transferable {
@Override @Override
public void failed() { public void failed() {
Log.d(Config.LOGTAG, account.getJid().asBareJid()+": proxy activation failed"); Log.d(Config.LOGTAG, account.getJid().asBareJid()+": proxy activation failed");
//TODO: when initiating send fallback to ibb if (initiating()) {
sendFallbackToIbb();
}
} }
}; };
@ -774,11 +776,11 @@ public class JingleConnection implements Transferable {
mXmppConnectionService.sendIqPacket(account, activation, (account, response) -> { mXmppConnectionService.sendIqPacket(account, activation, (account, response) -> {
if (response.getType() != IqPacket.TYPE.RESULT) { if (response.getType() != IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + response.toString()); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + response.toString());
sendProxyError();
onProxyActivated.failed(); onProxyActivated.failed();
//TODO send proxy-error
} else { } else {
onProxyActivated.success();
sendProxyActivated(connection.getCandidate().getCid()); sendProxyActivated(connection.getCandidate().getCid());
onProxyActivated.success();
} }
}); });
} else { } else {
@ -862,7 +864,7 @@ public class JingleConnection implements Transferable {
private boolean receiveFallbackToIbb(JinglePacket packet) { private boolean receiveFallbackToIbb(JinglePacket packet) {
Log.d(Config.LOGTAG, "receiving fallback to ibb"); Log.d(Config.LOGTAG, account.getJid().asBareJid()+": receiving fallback to ibb");
final String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size"); final String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size");
if (receivedBlockSize != null) { if (receivedBlockSize != null) {
try { try {
@ -1050,14 +1052,23 @@ public class JingleConnection implements Transferable {
} }
private void sendProxyActivated(String cid) { private void sendProxyActivated(String cid) {
JinglePacket packet = bootstrapPacket("transport-info"); final JinglePacket packet = bootstrapPacket("transport-info");
Content content = new Content(this.contentCreator, this.contentName); final Content content = new Content(this.contentCreator, this.contentName);
content.setTransportId(this.transportId); content.setTransportId(this.transportId);
content.socks5transport().addChild("activated").setAttribute("cid", cid); content.socks5transport().addChild("activated").setAttribute("cid", cid);
packet.setContent(content); packet.setContent(content);
this.sendJinglePacket(packet); this.sendJinglePacket(packet);
} }
private void sendProxyError() {
final JinglePacket packet = bootstrapPacket("transport-info");
final Content content = new Content(this.contentCreator, this.contentName);
content.setTransportId(this.transportId);
content.socks5transport().addChild("proxy-error");
packet.setContent(content);
this.sendJinglePacket(packet);
}
private void sendCandidateUsed(final String cid) { private void sendCandidateUsed(final String cid) {
JinglePacket packet = bootstrapPacket("transport-info"); JinglePacket packet = bootstrapPacket("transport-info");
Content content = new Content(this.contentCreator, this.contentName); Content content = new Content(this.contentCreator, this.contentName);