Search in sources :

Example 6 with JinglePacket

use of de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket in project Pix-Art-Messenger by kriztan.

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(de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket) Reason(de.pixart.messenger.xmpp.jingle.stanzas.Reason)

Example 7 with JinglePacket

use of de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket in project Pix-Art-Messenger by kriztan.

the class JingleConnection method sendInitRequest.

private void sendInitRequest() {
    JinglePacket packet = this.bootstrapPacket("session-initiate");
    Content content = new Content(this.contentCreator, this.contentName);
    if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE) {
        content.setTransportId(this.transportId);
        this.file = this.mXmppConnectionService.getFileBackend().getFile(message, false);
        Pair<InputStream, Integer> pair;
        try {
            if (message.getEncryption() == Message.ENCRYPTION_OTR) {
                Conversation conversation = this.message.getConversation();
                if (!this.mXmppConnectionService.renewSymmetricKey(conversation)) {
                    Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not set symmetric key");
                    cancel();
                }
                this.file.setKeyAndIv(conversation.getSymmetricKey());
                pair = AbstractConnectionManager.createInputStream(this.file, false);
                this.file.setExpectedSize(pair.second);
                content.setFileOffer(this.file, true, this.ftVersion);
            } else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
                this.file.setKey(mXmppAxolotlMessage.getInnerKey());
                this.file.setIv(mXmppAxolotlMessage.getIV());
                pair = AbstractConnectionManager.createInputStream(this.file, true);
                this.file.setExpectedSize(pair.second);
                content.setFileOffer(this.file, false, this.ftVersion).addChild(mXmppAxolotlMessage.toElement());
            } else {
                pair = AbstractConnectionManager.createInputStream(this.file, false);
                this.file.setExpectedSize(pair.second);
                content.setFileOffer(this.file, false, this.ftVersion);
            }
        } catch (FileNotFoundException e) {
            cancel();
            return;
        }
        message.resetFileParams();
        this.mFileInputStream = pair.first;
        content.setTransportId(this.transportId);
        content.socks5transport().setChildren(getCandidatesAsElements());
        packet.setContent(content);
        this.sendJinglePacket(packet, new OnIqPacketReceived() {

            @Override
            public void onIqPacketReceived(Account account, IqPacket packet) {
                if (packet.getType() == IqPacket.TYPE.RESULT) {
                    Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": other party received offer");
                    if (mJingleStatus == JINGLE_STATUS_OFFERED) {
                        mJingleStatus = JINGLE_STATUS_INITIATED;
                        mXmppConnectionService.markMessage(message, Message.STATUS_OFFERED);
                    } else {
                        Log.d(Config.LOGTAG, "received ack for offer when status was " + mJingleStatus);
                    }
                } else {
                    fail(IqParser.extractErrorMessage(packet));
                }
            }
        });
    }
}
Also used : Account(de.pixart.messenger.entities.Account) JinglePacket(de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket) OnIqPacketReceived(de.pixart.messenger.xmpp.OnIqPacketReceived) Content(de.pixart.messenger.xmpp.jingle.stanzas.Content) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) Conversation(de.pixart.messenger.entities.Conversation) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 8 with JinglePacket

use of de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket in project Pix-Art-Messenger by kriztan.

the class JingleConnection method bootstrapPacket.

private JinglePacket bootstrapPacket(String action) {
    JinglePacket packet = new JinglePacket();
    packet.setAction(action);
    packet.setFrom(account.getJid());
    packet.setTo(this.message.getCounterpart());
    packet.setSessionId(this.sessionId);
    packet.setInitiator(this.initiator);
    return packet;
}
Also used : JinglePacket(de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket)

Example 9 with JinglePacket

use of de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket in project Pix-Art-Messenger by kriztan.

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(de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket) Content(de.pixart.messenger.xmpp.jingle.stanzas.Content)

Example 10 with JinglePacket

use of de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket in project Pix-Art-Messenger by kriztan.

the class JingleConnection method sendCandidateUsed.

private void sendCandidateUsed(final String cid) {
    JinglePacket packet = bootstrapPacket("transport-info");
    Content content = new Content(this.contentCreator, this.contentName);
    content.setTransportId(this.transportId);
    content.socks5transport().addChild("candidate-used").setAttribute("cid", cid);
    packet.setContent(content);
    this.sentCandidate = true;
    if ((receivedCandidate) && (mJingleStatus == JINGLE_STATUS_ACCEPTED)) {
        connect();
    }
    this.sendJinglePacket(packet);
}
Also used : JinglePacket(de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket) Content(de.pixart.messenger.xmpp.jingle.stanzas.Content)

Aggregations

JinglePacket (de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket)13 Content (de.pixart.messenger.xmpp.jingle.stanzas.Content)7 IqPacket (de.pixart.messenger.xmpp.stanzas.IqPacket)4 Account (de.pixart.messenger.entities.Account)2 OnIqPacketReceived (de.pixart.messenger.xmpp.OnIqPacketReceived)2 Reason (de.pixart.messenger.xmpp.jingle.stanzas.Reason)2 Conversation (de.pixart.messenger.entities.Conversation)1 Element (de.pixart.messenger.xml.Element)1 Tag (de.pixart.messenger.xml.Tag)1 MessagePacket (de.pixart.messenger.xmpp.stanzas.MessagePacket)1 PresencePacket (de.pixart.messenger.xmpp.stanzas.PresencePacket)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1