use of eu.siacs.conversations.xmpp.stanzas.MessagePacket in project Conversations by siacs.
the class MessageGenerator method preparePacket.
private MessagePacket preparePacket(Message message) {
Conversation conversation = message.getConversation();
Account account = conversation.getAccount();
MessagePacket packet = new MessagePacket();
if (conversation.getMode() == Conversation.MODE_SINGLE) {
packet.setTo(message.getCounterpart());
packet.setType(MessagePacket.TYPE_CHAT);
packet.addChild("markable", "urn:xmpp:chat-markers:0");
if (this.mXmppConnectionService.indicateReceived()) {
packet.addChild("request", "urn:xmpp:receipts");
}
} else if (message.getType() == Message.TYPE_PRIVATE) {
packet.setTo(message.getCounterpart());
packet.setType(MessagePacket.TYPE_CHAT);
packet.addChild("x", "http://jabber.org/protocol/muc#user");
if (this.mXmppConnectionService.indicateReceived()) {
packet.addChild("request", "urn:xmpp:receipts");
}
} else {
packet.setTo(message.getCounterpart().toBareJid());
packet.setType(MessagePacket.TYPE_GROUPCHAT);
}
packet.setFrom(account.getJid());
packet.setId(message.getUuid());
packet.addChild("origin-id", Namespace.STANZA_IDS).setAttribute("id", message.getUuid());
if (message.edited()) {
packet.addChild("replace", "urn:xmpp:message-correct:0").setAttribute("id", message.getEditedId());
}
return packet;
}
use of eu.siacs.conversations.xmpp.stanzas.MessagePacket in project Conversations by siacs.
the class MessageGenerator method received.
public MessagePacket received(Account account, MessagePacket originalMessage, ArrayList<String> namespaces, int type) {
MessagePacket receivedPacket = new MessagePacket();
receivedPacket.setType(type);
receivedPacket.setTo(originalMessage.getFrom());
receivedPacket.setFrom(account.getJid());
for (String namespace : namespaces) {
receivedPacket.addChild("received", namespace).setAttribute("id", originalMessage.getId());
}
return receivedPacket;
}
use of eu.siacs.conversations.xmpp.stanzas.MessagePacket in project Conversations by siacs.
the class MessageGenerator method directInvite.
public MessagePacket directInvite(final Conversation conversation, final Jid contact) {
MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_NORMAL);
packet.setTo(contact);
packet.setFrom(conversation.getAccount().getJid());
Element x = packet.addChild("x", "jabber:x:conference");
x.setAttribute("jid", conversation.getJid().toBareJid().toString());
String password = conversation.getMucOptions().getPassword();
if (password != null) {
x.setAttribute("password", password);
}
return packet;
}
use of eu.siacs.conversations.xmpp.stanzas.MessagePacket in project Conversations by siacs.
the class XmppConnectionService method onOtrSessionEstablished.
public void onOtrSessionEstablished(Conversation conversation) {
final Account account = conversation.getAccount();
final Session otrSession = conversation.getOtrSession();
Log.d(Config.LOGTAG, account.getJid().toBareJid() + " otr session established with " + conversation.getJid() + "/" + otrSession.getSessionID().getUserID());
conversation.findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR, new Conversation.OnMessageFound() {
@Override
public void onMessageFound(Message message) {
SessionID id = otrSession.getSessionID();
try {
message.setCounterpart(Jid.fromString(id.getAccountID() + "/" + id.getUserID()));
} catch (InvalidJidException e) {
return;
}
if (message.needsUploading()) {
mJingleConnectionManager.createNewConnection(message);
} else {
MessagePacket outPacket = mMessageGenerator.generateOtrChat(message);
if (outPacket != null) {
mMessageGenerator.addDelay(outPacket, message.getTimeSent());
message.setStatus(Message.STATUS_SEND);
databaseBackend.updateMessage(message);
sendMessagePacket(account, outPacket);
}
}
updateConversationUi();
}
});
}
use of eu.siacs.conversations.xmpp.stanzas.MessagePacket in project Conversations by siacs.
the class XmppConnectionService method directInvite.
public void directInvite(Conversation conversation, Jid jid) {
MessagePacket packet = mMessageGenerator.directInvite(conversation, jid);
sendMessagePacket(conversation.getAccount(), packet);
}
Aggregations