Search in sources :

Example 6 with IbbTransportInfo

use of eu.siacs.conversations.xmpp.jingle.stanzas.IbbTransportInfo 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 7 with IbbTransportInfo

use of eu.siacs.conversations.xmpp.jingle.stanzas.IbbTransportInfo 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)

Aggregations

Content (eu.siacs.conversations.xmpp.jingle.stanzas.Content)7 IbbTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.IbbTransportInfo)7 JinglePacket (eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket)4 GenericTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.GenericTransportInfo)3 S5BTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo)3 Element (eu.siacs.conversations.xml.Element)2 FileNotFoundException (java.io.FileNotFoundException)2 XmppAxolotlMessage (eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)1 Conversation (eu.siacs.conversations.entities.Conversation)1 Message (eu.siacs.conversations.entities.Message)1 AbstractConnectionManager (eu.siacs.conversations.services.AbstractConnectionManager)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1