use of eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo in project Conversations by siacs.
the class JingleFileTransferConnection method receiveAccept.
private void receiveAccept(JinglePacket packet) {
if (responding()) {
Log.d(Config.LOGTAG, id.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, id.account.getJid().asBareJid() + ": received out of order session-accept");
respondToIqWithOutOfOrder(packet);
return;
}
this.mJingleStatus = JINGLE_STATUS_ACCEPTED;
xmppConnectionService.markMessage(message, Message.STATUS_UNSEND);
final Content content = packet.getJingleContent();
final GenericTransportInfo transportInfo = content.getTransport();
// TODO we want to fail if transportInfo doesn’t match our intialTransport and/or our id
if (transportInfo instanceof S5BTransportInfo) {
final S5BTransportInfo s5BTransportInfo = (S5BTransportInfo) transportInfo;
respondToIq(packet, true);
// TODO calling merge is probably a bug because that might eliminate candidates of the other party and lead to us not sending accept/deny
// TODO: we probably just want to call add
mergeCandidates(s5BTransportInfo.getCandidates());
this.connectNextCandidate();
} else if (transportInfo instanceof IbbTransportInfo) {
final IbbTransportInfo ibbTransportInfo = (IbbTransportInfo) transportInfo;
final int remoteBlockSize = ibbTransportInfo.getBlockSize();
if (remoteBlockSize > 0) {
this.ibbBlockSize = Math.min(ibbBlockSize, remoteBlockSize);
}
respondToIq(packet, true);
this.transport = new JingleInBandTransport(this, this.transportId, this.ibbBlockSize);
this.transport.connect(onIbbTransportConnected);
} else {
respondToIq(packet, false);
}
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo in project Conversations by siacs.
the class JingleFileTransferConnection method sendInitRequest.
private void sendInitRequest() {
final JinglePacket packet = this.bootstrapPacket(JinglePacket.Action.SESSION_INITIATE);
final Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL && remoteSupportsOmemoJet) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": remote announced support for JET");
final Element security = new Element("security", Namespace.JINGLE_ENCRYPTED_TRANSPORT);
security.setAttribute("name", this.contentName);
security.setAttribute("cipher", JET_OMEMO_CIPHER);
security.setAttribute("type", AxolotlService.PEP_PREFIX);
security.addChild(mXmppAxolotlMessage.toElement());
content.addChild(security);
}
content.setDescription(this.description);
message.resetFileParams();
try {
this.mFileInputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
fail(e.getMessage());
return;
}
if (this.initialTransport == IbbTransportInfo.class) {
content.setTransport(new IbbTransportInfo(this.transportId, this.ibbBlockSize));
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending IBB offer");
} else {
final Collection<JingleCandidate> candidates = getOurCandidates();
content.setTransport(new S5BTransportInfo(this.transportId, candidates));
Log.d(Config.LOGTAG, String.format("%s: sending S5B offer with %d candidates", id.account.getJid().asBareJid(), candidates.size()));
}
packet.addJingleContent(content);
this.sendJinglePacket(packet, (account, response) -> {
if (response.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": other party received offer");
if (mJingleStatus == JINGLE_STATUS_OFFERED) {
mJingleStatus = JINGLE_STATUS_INITIATED;
xmppConnectionService.markMessage(message, Message.STATUS_OFFERED);
} else {
Log.d(Config.LOGTAG, "received ack for offer when status was " + mJingleStatus);
}
} else {
fail(IqParser.extractErrorMessage(response));
}
});
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo in project Conversations by siacs.
the class JingleFileTransferConnection method sendProxyError.
private void sendProxyError() {
final JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO);
final Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
content.setTransport(new S5BTransportInfo(this.transportId, new Element("proxy-error")));
packet.addJingleContent(content);
this.sendJinglePacket(packet);
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo in project Conversations by siacs.
the class JingleFileTransferConnection method receiveTransportInfo.
private void receiveTransportInfo(JinglePacket packet) {
final Content content = packet.getJingleContent();
final GenericTransportInfo transportInfo = content.getTransport();
if (transportInfo instanceof S5BTransportInfo) {
final S5BTransportInfo s5BTransportInfo = (S5BTransportInfo) transportInfo;
if (s5BTransportInfo.hasChild("activated")) {
respondToIq(packet, true);
if ((this.transport != null) && (this.transport instanceof JingleSocks5Transport)) {
onProxyActivated.success();
} else {
String cid = s5BTransportInfo.findChild("activated").getAttribute("cid");
Log.d(Config.LOGTAG, "received proxy activated (" + cid + ")prior to choosing our own transport");
JingleSocks5Transport connection = this.connections.get(cid);
if (connection != null) {
connection.setActivated(true);
} else {
Log.d(Config.LOGTAG, "activated connection not found");
sendSessionTerminate(Reason.FAILED_TRANSPORT);
this.fail();
}
}
} else if (s5BTransportInfo.hasChild("proxy-error")) {
respondToIq(packet, true);
onProxyActivated.failed();
} else if (s5BTransportInfo.hasChild("candidate-error")) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received candidate error");
respondToIq(packet, true);
this.receivedCandidate = true;
if (mJingleStatus == JINGLE_STATUS_ACCEPTED && this.sentCandidate) {
this.connect();
}
} else if (s5BTransportInfo.hasChild("candidate-used")) {
String cid = s5BTransportInfo.findChild("candidate-used").getAttribute("cid");
if (cid != null) {
Log.d(Config.LOGTAG, "candidate used by counterpart:" + cid);
JingleCandidate candidate = getCandidate(cid);
if (candidate == null) {
Log.d(Config.LOGTAG, "could not find candidate with cid=" + cid);
respondToIq(packet, false);
return;
}
respondToIq(packet, true);
candidate.flagAsUsedByCounterpart();
this.receivedCandidate = true;
if (mJingleStatus == JINGLE_STATUS_ACCEPTED && this.sentCandidate) {
this.connect();
} else {
Log.d(Config.LOGTAG, "ignoring because file is already in transmission or we haven't sent our candidate yet status=" + mJingleStatus + " sentCandidate=" + sentCandidate);
}
} else {
respondToIq(packet, false);
}
} else {
respondToIq(packet, false);
}
} else {
respondToIq(packet, true);
}
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo in project Conversations by siacs.
the class JingleFileTransferConnection method sendProxyActivated.
private void sendProxyActivated(String cid) {
final JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO);
final Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
content.setTransport(new S5BTransportInfo(this.transportId, new Element("activated").setAttribute("cid", cid)));
packet.addJingleContent(content);
this.sendJinglePacket(packet);
}
Aggregations