Search in sources :

Example 6 with MessagePacket

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

the class MessageGenerator method confirm.

public MessagePacket confirm(final Account account, final Jid to, final String id) {
    MessagePacket packet = new MessagePacket();
    packet.setType(MessagePacket.TYPE_CHAT);
    packet.setTo(to);
    packet.setFrom(account.getJid());
    Element received = packet.addChild("displayed", "urn:xmpp:chat-markers:0");
    received.setAttribute("id", id);
    packet.addChild("store", "urn:xmpp:hints");
    return packet;
}
Also used : MessagePacket(eu.siacs.conversations.xmpp.stanzas.MessagePacket) Element(eu.siacs.conversations.xml.Element)

Example 7 with MessagePacket

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

the class MessageGenerator method generateOtrError.

public MessagePacket generateOtrError(Jid to, String id, String errorText) {
    MessagePacket packet = new MessagePacket();
    packet.setType(MessagePacket.TYPE_ERROR);
    packet.setAttribute("id", id);
    packet.setTo(to);
    Element error = packet.addChild("error");
    error.setAttribute("code", "406");
    error.setAttribute("type", "modify");
    error.addChild("not-acceptable", "urn:ietf:params:xml:ns:xmpp-stanzas");
    error.addChild("text").setContent("?OTR Error:" + errorText);
    return packet;
}
Also used : MessagePacket(eu.siacs.conversations.xmpp.stanzas.MessagePacket) Element(eu.siacs.conversations.xml.Element)

Example 8 with MessagePacket

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

the class MessageGenerator method generateOtrChat.

public MessagePacket generateOtrChat(Message message) {
    Session otrSession = message.getConversation().getOtrSession();
    if (otrSession == null) {
        return null;
    }
    MessagePacket packet = preparePacket(message);
    addMessageHints(packet);
    try {
        String content;
        if (message.hasFileOnRemoteHost()) {
            content = message.getFileParams().url.toString();
        } else {
            content = message.getBody();
        }
        packet.setBody(otrSession.transformSending(content)[0]);
        packet.addChild("encryption", "urn:xmpp:eme:0").setAttribute("namespace", "urn:xmpp:otr:0");
        return packet;
    } catch (OtrException e) {
        return null;
    }
}
Also used : MessagePacket(eu.siacs.conversations.xmpp.stanzas.MessagePacket) OtrException(net.java.otr4j.OtrException) Session(net.java.otr4j.session.Session)

Example 9 with MessagePacket

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

the class MessageGenerator method generateChat.

public MessagePacket generateChat(Message message) {
    MessagePacket packet = preparePacket(message);
    String content;
    if (message.hasFileOnRemoteHost()) {
        Message.FileParams fileParams = message.getFileParams();
        content = fileParams.url.toString();
        packet.addChild("x", "jabber:x:oob").addChild("url").setContent(content);
    } else {
        content = message.getBody();
    }
    packet.setBody(content);
    return packet;
}
Also used : MessagePacket(eu.siacs.conversations.xmpp.stanzas.MessagePacket) Message(eu.siacs.conversations.entities.Message) XmppAxolotlMessage(eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)

Example 10 with MessagePacket

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

the class MessageGenerator method invite.

public MessagePacket invite(Conversation conversation, Jid contact) {
    MessagePacket packet = new MessagePacket();
    packet.setTo(conversation.getJid().toBareJid());
    packet.setFrom(conversation.getAccount().getJid());
    Element x = new Element("x");
    x.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
    Element invite = new Element("invite");
    invite.setAttribute("to", contact.toBareJid().toString());
    x.addChild(invite);
    packet.addChild(x);
    return packet;
}
Also used : MessagePacket(eu.siacs.conversations.xmpp.stanzas.MessagePacket) Element(eu.siacs.conversations.xml.Element)

Aggregations

MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)29 Element (eu.siacs.conversations.xml.Element)8 Account (eu.siacs.conversations.entities.Account)6 Conversation (eu.siacs.conversations.entities.Conversation)6 XmppAxolotlMessage (eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)5 Message (eu.siacs.conversations.entities.Message)5 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)4 Jid (eu.siacs.conversations.xmpp.jid.Jid)4 AbstractAcknowledgeableStanza (eu.siacs.conversations.xmpp.stanzas.AbstractAcknowledgeableStanza)3 Session (net.java.otr4j.session.Session)3 MucOptions (eu.siacs.conversations.entities.MucOptions)2 Tag (eu.siacs.conversations.xml.Tag)2 RequestPacket (eu.siacs.conversations.xmpp.stanzas.streammgmt.RequestPacket)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 OtrException (net.java.otr4j.OtrException)2 Bundle (android.os.Bundle)1 Bookmark (eu.siacs.conversations.entities.Bookmark)1 Contact (eu.siacs.conversations.entities.Contact)1 HttpConnectionManager (eu.siacs.conversations.http.HttpConnectionManager)1