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;
}
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;
}
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;
}
}
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;
}
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;
}
Aggregations