use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleFileTransferConnection method receiveFallbackToIbb.
private void receiveFallbackToIbb(final JinglePacket packet, final IbbTransportInfo transportInfo) {
if (isInitiator()) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received out of order transport-replace (we were initiating)");
respondToIqWithOutOfOrder(packet);
return;
}
final boolean validState = mJingleStatus == JINGLE_STATUS_ACCEPTED || (proxyActivationFailed && mJingleStatus == JINGLE_STATUS_TRANSMITTING);
if (!validState) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received out of order transport-replace");
respondToIqWithOutOfOrder(packet);
return;
}
// fallback received; now we no longer need to accept another one;
this.proxyActivationFailed = false;
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": receiving fallback to ibb");
final int remoteBlockSize = transportInfo.getBlockSize();
if (remoteBlockSize > 0) {
this.ibbBlockSize = Math.min(MAX_IBB_BLOCK_SIZE, remoteBlockSize);
} else {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to parse block size in transport-replace");
}
// TODO: handle the case where this is null by the remote party
this.transportId = transportInfo.getTransportId();
this.transport = new JingleInBandTransport(this, this.transportId, this.ibbBlockSize);
final JinglePacket answer = bootstrapPacket(JinglePacket.Action.TRANSPORT_ACCEPT);
final Content content = new Content(contentCreator, contentName);
content.setSenders(this.contentSenders);
content.setTransport(new IbbTransportInfo(this.transportId, this.ibbBlockSize));
answer.addJingleContent(content);
respondToIq(packet, true);
if (isInitiator()) {
this.sendJinglePacket(answer, (account, response) -> {
if (response.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + " recipient ACKed our transport-accept. creating ibb");
transport.connect(onIbbTransportConnected);
}
});
} else {
this.transport.receive(file, onFileTransmissionStatusChanged);
this.sendJinglePacket(answer);
}
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleFileTransferConnection method sendHash.
private void sendHash() {
final Element checksum = new Element("checksum", description.getVersion().getNamespace());
checksum.setAttribute("creator", "initiator");
checksum.setAttribute("name", "a-file-offer");
Element hash = checksum.addChild("file").addChild("hash", "urn:xmpp:hashes:2");
hash.setAttribute("algo", "sha-1").setContent(Base64.encodeToString(file.getSha1Sum(), Base64.NO_WRAP));
final JinglePacket packet = this.bootstrapPacket(JinglePacket.Action.SESSION_INFO);
packet.addJingleChild(checksum);
xmppConnectionService.sendIqPacket(id.account, packet, (account, response) -> {
if (response.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring error response to our session-info (hash transmission)");
}
});
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleFileTransferConnection method sendSessionTerminate.
private void sendSessionTerminate(Reason reason) {
final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_TERMINATE);
packet.setReason(reason, null);
this.sendJinglePacket(packet);
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleFileTransferConnection method sendFallbackToIbb.
private void sendFallbackToIbb() {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending fallback to ibb");
final JinglePacket packet = this.bootstrapPacket(JinglePacket.Action.TRANSPORT_REPLACE);
final Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
this.transportId = JingleConnectionManager.nextRandomId();
content.setTransport(new IbbTransportInfo(this.transportId, this.ibbBlockSize));
packet.addJingleContent(content);
this.sendJinglePacket(packet);
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleFileTransferConnection method sendCandidateUsed.
private void sendCandidateUsed(final String cid) {
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("candidate-used").setAttribute("cid", cid)));
packet.addJingleContent(content);
this.sentCandidate = true;
if ((receivedCandidate) && (mJingleStatus == JINGLE_STATUS_ACCEPTED)) {
connect();
}
this.sendJinglePacket(packet);
}
Aggregations