Search in sources :

Example 1 with JinglePacket

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

the class JingleConnection method sendSuccess.

private void sendSuccess() {
    JinglePacket packet = bootstrapPacket("session-terminate");
    Reason reason = new Reason();
    reason.addChild("success");
    packet.setReason(reason);
    this.sendJinglePacket(packet);
    this.disconnectSocks5Connections();
    this.mJingleStatus = JINGLE_STATUS_FINISHED;
    this.message.setStatus(Message.STATUS_RECEIVED);
    this.message.setTransferable(null);
    this.mXmppConnectionService.updateMessage(message);
    this.mJingleConnectionManager.finishConnection(this);
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Reason(eu.siacs.conversations.xmpp.jingle.stanzas.Reason)

Example 2 with JinglePacket

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

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

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

Example 5 with JinglePacket

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

the class JingleConnectionManager method deliverPacket.

public void deliverPacket(final Account account, final JinglePacket packet) {
    final String sessionId = packet.getSessionId();
    if (sessionId == null) {
        respondWithJingleError(account, packet, "unknown-session", "item-not-found", "cancel");
        return;
    }
    final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, packet);
    final AbstractJingleConnection existingJingleConnection = connections.get(id);
    if (existingJingleConnection != null) {
        existingJingleConnection.deliverPacket(packet);
    } else if (packet.getAction() == JinglePacket.Action.SESSION_INITIATE) {
        final Jid from = packet.getFrom();
        final Content content = packet.getJingleContent();
        final String descriptionNamespace = content == null ? null : content.getDescriptionNamespace();
        final AbstractJingleConnection connection;
        if (FileTransferDescription.NAMESPACES.contains(descriptionNamespace)) {
            connection = new JingleFileTransferConnection(this, id, from);
        } else if (Namespace.JINGLE_APPS_RTP.equals(descriptionNamespace) && isUsingClearNet(account)) {
            final boolean sessionEnded = this.terminatedSessions.asMap().containsKey(PersistableSessionId.of(id));
            final boolean stranger = isWithStrangerAndStrangerNotificationsAreOff(account, id.with);
            if (isBusy() || sessionEnded || stranger) {
                Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": rejected session with " + id.with + " because busy. sessionEnded=" + sessionEnded + ", stranger=" + stranger);
                mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null);
                final JinglePacket sessionTermination = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId);
                sessionTermination.setTo(id.with);
                sessionTermination.setReason(Reason.BUSY, null);
                mXmppConnectionService.sendIqPacket(account, sessionTermination, null);
                return;
            }
            connection = new JingleRtpConnection(this, id, from);
        } else {
            respondWithJingleError(account, packet, "unsupported-info", "feature-not-implemented", "cancel");
            return;
        }
        connections.put(id, connection);
        mXmppConnectionService.updateConversationUi();
        connection.deliverPacket(packet);
    } else {
        Log.d(Config.LOGTAG, "unable to route jingle packet: " + packet);
        respondWithJingleError(account, packet, "unknown-session", "item-not-found", "cancel");
    }
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Jid(eu.siacs.conversations.xmpp.Jid) Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content)

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