answer correctly if both markers and receipts are requested

This commit is contained in:
iNPUTmice 2014-07-24 01:04:25 +02:00
parent 23e5fb5d56
commit 7ee2ef5233
2 changed files with 17 additions and 13 deletions

View File

@ -151,4 +151,14 @@ public class MessageGenerator {
packet.addChild(x); packet.addChild(x);
return packet; return packet;
} }
public MessagePacket received(Account account, MessagePacket originalMessage, String namespace) {
MessagePacket receivedPacket = new MessagePacket();
receivedPacket.setType(MessagePacket.TYPE_NORMAL);
receivedPacket.setTo(originalMessage.getFrom());
receivedPacket.setFrom(account.getFullJid());
Element received = receivedPacket.addChild("received",namespace);
received.setAttribute("id", originalMessage.getId());
return receivedPacket;
}
} }

View File

@ -316,26 +316,20 @@ public class MessageParser extends AbstractParser implements
return; return;
} else if (packet.getType() == MessagePacket.TYPE_NORMAL) { } else if (packet.getType() == MessagePacket.TYPE_NORMAL) {
this.parseNormal(packet, account); this.parseNormal(packet, account);
return;
} }
if ((message == null) || (message.getBody() == null)) { if ((message == null) || (message.getBody() == null)) {
return; return;
} }
if ((mXmppConnectionService.confirmMessages()) if ((mXmppConnectionService.confirmMessages())
&& ((packet.getId() != null))) { && ((packet.getId() != null))) {
MessagePacket receivedPacket = new MessagePacket();
receivedPacket.setType(MessagePacket.TYPE_NORMAL);
receivedPacket.setTo(message.getCounterpart());
receivedPacket.setFrom(account.getFullJid());
if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) { if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {
Element received = receivedPacket.addChild("received", MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account, packet, "urn:xmpp:chat-markers:0");
"urn:xmpp:chat-markers:0"); mXmppConnectionService.sendMessagePacket(account, receipt);
received.setAttribute("id", packet.getId()); }
account.getXmppConnection().sendMessagePacket(receivedPacket); if (packet.hasChild("request", "urn:xmpp:receipts")) {
} else if (packet.hasChild("request", "urn:xmpp:receipts")) { MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account, packet, "urn:xmpp:receipts");
Element received = receivedPacket.addChild("received", mXmppConnectionService.sendMessagePacket(account, receipt);
"urn:xmpp:receipts");
received.setAttribute("id", packet.getId());
account.getXmppConnection().sendMessagePacket(receivedPacket);
} }
} }
Conversation conversation = message.getConversation(); Conversation conversation = message.getConversation();