Search in sources :

Example 26 with JinglePacket

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

the class JingleFileTransferConnection method sendAcceptSocks.

private void sendAcceptSocks() {
    gatherAndConnectDirectCandidates();
    this.jingleConnectionManager.getPrimaryCandidate(this.id.account, isInitiator(), (success, candidate) -> {
        final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_ACCEPT);
        final Content content = new Content(contentCreator, contentName);
        content.setSenders(this.contentSenders);
        content.setDescription(this.description);
        if (success && candidate != null && !equalCandidateExists(candidate)) {
            final JingleSocks5Transport socksConnection = new JingleSocks5Transport(this, candidate);
            connections.put(candidate.getCid(), socksConnection);
            socksConnection.connect(new OnTransportConnected() {

                @Override
                public void failed() {
                    Log.d(Config.LOGTAG, "connection to our own proxy65 candidate failed");
                    content.setTransport(new S5BTransportInfo(transportId, getOurCandidates()));
                    packet.addJingleContent(content);
                    sendJinglePacket(packet);
                    connectNextCandidate();
                }

                @Override
                public void established() {
                    Log.d(Config.LOGTAG, "connected to proxy65 candidate");
                    mergeCandidate(candidate);
                    content.setTransport(new S5BTransportInfo(transportId, getOurCandidates()));
                    packet.addJingleContent(content);
                    sendJinglePacket(packet);
                    connectNextCandidate();
                }
            });
        } else {
            Log.d(Config.LOGTAG, "did not find a proxy65 candidate for ourselves");
            content.setTransport(new S5BTransportInfo(transportId, getOurCandidates()));
            packet.addJingleContent(content);
            sendJinglePacket(packet);
            connectNextCandidate();
        }
    });
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content) S5BTransportInfo(eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo)

Example 27 with JinglePacket

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

the class JingleFileTransferConnection method sendCandidateError.

private void sendCandidateError() {
    Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending candidate error");
    JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO);
    Content content = new Content(this.contentCreator, this.contentName);
    content.setSenders(this.contentSenders);
    content.setTransport(new S5BTransportInfo(this.transportId, new Element("candidate-error")));
    packet.addJingleContent(content);
    this.sentCandidate = true;
    this.sendJinglePacket(packet);
    if (receivedCandidate && mJingleStatus == JINGLE_STATUS_ACCEPTED) {
        connect();
    }
}
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)

Example 28 with JinglePacket

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

the class JingleRtpConnection method sendSessionAccept.

private void sendSessionAccept(final RtpContentMap rtpContentMap) {
    if (isTerminated()) {
        Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": preparing session accept was too slow. already terminated. nothing to do.");
        return;
    }
    transitionOrThrow(State.SESSION_ACCEPTED);
    final JinglePacket sessionAccept = rtpContentMap.toJinglePacket(JinglePacket.Action.SESSION_ACCEPT, id.sessionId);
    send(sessionAccept);
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket)

Example 29 with JinglePacket

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

the class RtpContentMap method toJinglePacket.

JinglePacket toJinglePacket(final JinglePacket.Action action, final String sessionId) {
    final JinglePacket jinglePacket = new JinglePacket(action, sessionId);
    if (this.group != null) {
        jinglePacket.addGroup(this.group);
    }
    for (Map.Entry<String, DescriptionTransport> entry : this.contents.entrySet()) {
        final Content content = new Content(Content.Creator.INITIATOR, entry.getKey());
        if (entry.getValue().description != null) {
            content.addChild(entry.getValue().description);
        }
        content.addChild(entry.getValue().transport);
        jinglePacket.addJingleContent(content);
    }
    return jinglePacket;
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) Content(eu.siacs.conversations.xmpp.jingle.stanzas.Content) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 30 with JinglePacket

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

the class XmppConnection method processIq.

private void processIq(final Tag currentTag) throws IOException {
    final IqPacket packet = (IqPacket) processPacket(currentTag, PACKET_IQ);
    if (!packet.valid()) {
        Log.e(Config.LOGTAG, "encountered invalid iq from='" + packet.getFrom() + "' to='" + packet.getTo() + "'");
        return;
    }
    if (packet instanceof JinglePacket) {
        if (this.jingleListener != null) {
            this.jingleListener.onJinglePacketReceived(account, (JinglePacket) packet);
        }
    } else {
        OnIqPacketReceived callback = null;
        synchronized (this.packetCallbacks) {
            final Pair<IqPacket, OnIqPacketReceived> packetCallbackDuple = packetCallbacks.get(packet.getId());
            if (packetCallbackDuple != null) {
                // Packets to the server should have responses from the server
                if (packetCallbackDuple.first.toServer(account)) {
                    if (packet.fromServer(account)) {
                        callback = packetCallbackDuple.second;
                        packetCallbacks.remove(packet.getId());
                    } else {
                        Log.e(Config.LOGTAG, account.getJid().asBareJid().toString() + ": ignoring spoofed iq packet");
                    }
                } else {
                    if (packet.getFrom() != null && packet.getFrom().equals(packetCallbackDuple.first.getTo())) {
                        callback = packetCallbackDuple.second;
                        packetCallbacks.remove(packet.getId());
                    } else {
                        Log.e(Config.LOGTAG, account.getJid().asBareJid().toString() + ": ignoring spoofed iq packet");
                    }
                }
            } else if (packet.getType() == IqPacket.TYPE.GET || packet.getType() == IqPacket.TYPE.SET) {
                callback = this.unregisteredIqListener;
            }
        }
        if (callback != null) {
            try {
                callback.onIqPacketReceived(account, packet);
            } catch (StateChangingError error) {
                throw new StateChangingException(error.state);
            }
        }
    }
}
Also used : JinglePacket(eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

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