From 7ee2ef5233b832fd419455ab78a26dff33a5da21 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Thu, 24 Jul 2014 01:04:25 +0200 Subject: answer correctly if both markers and receipts are requested --- .../conversations/generator/MessageGenerator.java | 10 ++++++++++ src/eu/siacs/conversations/parser/MessageParser.java | 20 +++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'src/eu') diff --git a/src/eu/siacs/conversations/generator/MessageGenerator.java b/src/eu/siacs/conversations/generator/MessageGenerator.java index 4885177c..4449a7ec 100644 --- a/src/eu/siacs/conversations/generator/MessageGenerator.java +++ b/src/eu/siacs/conversations/generator/MessageGenerator.java @@ -151,4 +151,14 @@ public class MessageGenerator { packet.addChild(x); 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; + } } diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java index f6cd47ee..a4fcc810 100644 --- a/src/eu/siacs/conversations/parser/MessageParser.java +++ b/src/eu/siacs/conversations/parser/MessageParser.java @@ -316,26 +316,20 @@ public class MessageParser extends AbstractParser implements return; } else if (packet.getType() == MessagePacket.TYPE_NORMAL) { this.parseNormal(packet, account); + return; } if ((message == null) || (message.getBody() == null)) { return; } if ((mXmppConnectionService.confirmMessages()) && ((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")) { - Element received = receivedPacket.addChild("received", - "urn:xmpp:chat-markers:0"); - received.setAttribute("id", packet.getId()); - account.getXmppConnection().sendMessagePacket(receivedPacket); - } else if (packet.hasChild("request", "urn:xmpp:receipts")) { - Element received = receivedPacket.addChild("received", - "urn:xmpp:receipts"); - received.setAttribute("id", packet.getId()); - account.getXmppConnection().sendMessagePacket(receivedPacket); + MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account, packet, "urn:xmpp:chat-markers:0"); + mXmppConnectionService.sendMessagePacket(account, receipt); + } + if (packet.hasChild("request", "urn:xmpp:receipts")) { + MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account, packet, "urn:xmpp:receipts"); + mXmppConnectionService.sendMessagePacket(account, receipt); } } Conversation conversation = message.getConversation(); -- cgit v1.2.3