Search in sources :

Example 21 with JinglePacket

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);
    }
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content) IbbTransportInfo(eu.siacs.conversations.xmpp.jingle.stanzas.IbbTransportInfo)

Example 22 with JinglePacket

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)");
        }
    });
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Element(eu.siacs.conversations.xml.Element)

Example 23 with JinglePacket

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);
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket)

Example 24 with JinglePacket

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);
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content) IbbTransportInfo(eu.siacs.conversations.xmpp.jingle.stanzas.IbbTransportInfo)

Example 25 with JinglePacket

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);
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content) Element(eu.siacs.conversations.xml.Element) S5BTransportInfo(eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo)

Aggregations

JinglePacket (eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket)30 Content (eu.siacs.conversations.xmpp.jingle.stanzas.Content)18 Element (eu.siacs.conversations.xml.Element)7 S5BTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo)6 IbbTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.IbbTransportInfo)4 IqPacket (eu.siacs.conversations.xmpp.stanzas.IqPacket)3 CryptoFailedException (eu.siacs.conversations.crypto.axolotl.CryptoFailedException)2 Account (eu.siacs.conversations.entities.Account)2 OnIqPacketReceived (eu.siacs.conversations.xmpp.OnIqPacketReceived)2 Reason (eu.siacs.conversations.xmpp.jingle.stanzas.Reason)2 FileNotFoundException (java.io.FileNotFoundException)2 ExecutionException (java.util.concurrent.ExecutionException)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Conversation (eu.siacs.conversations.entities.Conversation)1 Jid (eu.siacs.conversations.xmpp.Jid)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Map (java.util.Map)1