Search in sources :

Example 1 with Content

use of eu.siacs.conversations.xmpp.jingle.stanzas.Content in project Conversations by siacs.

the class JingleConnection method receiveFallbackToIbb.

private boolean receiveFallbackToIbb(JinglePacket packet) {
    Log.d(Config.LOGTAG, "receiving fallack to ibb");
    String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size");
    if (receivedBlockSize != null) {
        int bs = Integer.parseInt(receivedBlockSize);
        if (bs > this.ibbBlockSize) {
            this.ibbBlockSize = bs;
        }
    }
    this.transportId = packet.getJingleContent().getTransportId();
    this.transport = new JingleInbandTransport(this, this.transportId, this.ibbBlockSize);
    JinglePacket answer = bootstrapPacket("transport-accept");
    Content content = new Content("initiator", "a-file-offer");
    content.setTransportId(this.transportId);
    content.ibbTransport().setAttribute("block-size", this.ibbBlockSize);
    answer.setContent(content);
    if (initiator.equals(account.getJid())) {
        this.sendJinglePacket(answer, new OnIqPacketReceived() {

            @Override
            public void onIqPacketReceived(Account account, IqPacket packet) {
                if (packet.getType() == IqPacket.TYPE.RESULT) {
                    Log.d(Config.LOGTAG, account.getJid().toBareJid() + " recipient ACKed our transport-accept. creating ibb");
                    transport.connect(onIbbTransportConnected);
                }
            }
        });
    } else {
        this.transport.receive(file, onFileTransmissionSatusChanged);
        this.sendJinglePacket(answer);
    }
    return true;
}
Also used : Account(eu.siacs.conversations.entities.Account) JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) OnIqPacketReceived(eu.siacs.conversations.xmpp.OnIqPacketReceived) Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 2 with Content

use of eu.siacs.conversations.xmpp.jingle.stanzas.Content in project Conversations by siacs.

the class JingleConnection method receiveAccept.

private boolean receiveAccept(JinglePacket packet) {
    Content content = packet.getJingleContent();
    mergeCandidates(JingleCandidate.parse(content.socks5transport().getChildren()));
    this.mJingleStatus = JINGLE_STATUS_ACCEPTED;
    mXmppConnectionService.markMessage(message, Message.STATUS_UNSEND);
    this.connectNextCandidate();
    return true;
}
Also used : Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content)

Example 3 with Content

use of eu.siacs.conversations.xmpp.jingle.stanzas.Content in project Conversations by siacs.

the class JingleConnection method receiveTransportInfo.

private boolean receiveTransportInfo(JinglePacket packet) {
    Content content = packet.getJingleContent();
    if (content.hasSocks5Transport()) {
        if (content.socks5transport().hasChild("activated")) {
            if ((this.transport != null) && (this.transport instanceof JingleSocks5Transport)) {
                onProxyActivated.success();
            } else {
                String cid = content.socks5transport().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");
                    this.sendCancel();
                    this.fail();
                }
            }
            return true;
        } else if (content.socks5transport().hasChild("proxy-error")) {
            onProxyActivated.failed();
            return true;
        } else if (content.socks5transport().hasChild("candidate-error")) {
            Log.d(Config.LOGTAG, "received candidate error");
            this.receivedCandidate = true;
            if ((mJingleStatus == JINGLE_STATUS_ACCEPTED) && (this.sentCandidate)) {
                this.connect();
            }
            return true;
        } else if (content.socks5transport().hasChild("candidate-used")) {
            String cid = content.socks5transport().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);
                    return false;
                }
                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");
                }
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else {
        return true;
    }
}
Also used : Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content)

Example 4 with Content

use of eu.siacs.conversations.xmpp.jingle.stanzas.Content in project Conversations by siacs.

the class JingleConnection method sendProxyActivated.

private void sendProxyActivated(String cid) {
    JinglePacket packet = bootstrapPacket("transport-info");
    Content content = new Content(this.contentCreator, this.contentName);
    content.setTransportId(this.transportId);
    content.socks5transport().addChild("activated").setAttribute("cid", cid);
    packet.setContent(content);
    this.sendJinglePacket(packet);
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content)

Example 5 with Content

use of eu.siacs.conversations.xmpp.jingle.stanzas.Content in project Conversations by siacs.

the class JingleConnection method sendAccept.

private void sendAccept() {
    mJingleStatus = JINGLE_STATUS_ACCEPTED;
    this.mStatus = Transferable.STATUS_DOWNLOADING;
    this.mJingleConnectionManager.updateConversationUi(true);
    this.mJingleConnectionManager.getPrimaryCandidate(this.account, new OnPrimaryCandidateFound() {

        @Override
        public void onPrimaryCandidateFound(boolean success, final JingleCandidate candidate) {
            final JinglePacket packet = bootstrapPacket("session-accept");
            final Content content = new Content(contentCreator, contentName);
            content.setFileOffer(fileOffer, ftVersion);
            content.setTransportId(transportId);
            if (success && candidate != null && !equalCandidateExists(candidate)) {
                final JingleSocks5Transport socksConnection = new JingleSocks5Transport(JingleConnection.this, candidate);
                connections.put(candidate.getCid(), socksConnection);
                socksConnection.connect(new OnTransportConnected() {

                    @Override
                    public void failed() {
                        Log.d(Config.LOGTAG, "connection to our own primary candidate failed");
                        content.socks5transport().setChildren(getCandidatesAsElements());
                        packet.setContent(content);
                        sendJinglePacket(packet);
                        connectNextCandidate();
                    }

                    @Override
                    public void established() {
                        Log.d(Config.LOGTAG, "connected to primary candidate");
                        mergeCandidate(candidate);
                        content.socks5transport().setChildren(getCandidatesAsElements());
                        packet.setContent(content);
                        sendJinglePacket(packet);
                        connectNextCandidate();
                    }
                });
            } else {
                Log.d(Config.LOGTAG, "did not find a primary candidate for ourself");
                content.socks5transport().setChildren(getCandidatesAsElements());
                packet.setContent(content);
                sendJinglePacket(packet);
                connectNextCandidate();
            }
        }
    });
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content)

Aggregations

Content (eu.siacs.conversations.xmpp.jingle.stanzas.Content)25 JinglePacket (eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket)18 S5BTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo)9 Element (eu.siacs.conversations.xml.Element)7 IbbTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.IbbTransportInfo)7 GenericTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.GenericTransportInfo)4 Conversation (eu.siacs.conversations.entities.Conversation)3 FileNotFoundException (java.io.FileNotFoundException)3 XmppAxolotlMessage (eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)2 Account (eu.siacs.conversations.entities.Account)2 Message (eu.siacs.conversations.entities.Message)2 OnIqPacketReceived (eu.siacs.conversations.xmpp.OnIqPacketReceived)2 IqPacket (eu.siacs.conversations.xmpp.stanzas.IqPacket)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 AbstractConnectionManager (eu.siacs.conversations.services.AbstractConnectionManager)1 Jid (eu.siacs.conversations.xmpp.Jid)1 Jid (eu.siacs.conversations.xmpp.jid.Jid)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1