diff options
author | Daniel Gultsch <inputmice@siacs.eu> | 2015-03-01 14:15:40 +0100 |
---|---|---|
committer | Daniel Gultsch <inputmice@siacs.eu> | 2015-03-01 14:15:40 +0100 |
commit | ff86fa604903cd77fe26860be0cc256b5d1e04eb (patch) | |
tree | 43d85cfc20fa2e56f71a9a6ad99a4696127dae78 /src/main | |
parent | d318af098d28b6685219f852558087eee5c8c3ae (diff) |
mark all sent messages up to a marker as displayed
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/eu/siacs/conversations/parser/MessageParser.java | 13 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 19 |
2 files changed, 19 insertions, 13 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 3f3cf8cb..ced81520 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -402,14 +402,19 @@ public class MessageParser extends AbstractParser implements Element event = packet.findChild("event", "http://jabber.org/protocol/pubsub#event"); parseEvent(event, from, account); - } else if (from != null - && packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) { + } else if (from != null && packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) { String id = packet .findChild("displayed", "urn:xmpp:chat-markers:0") .getAttribute("id"); updateLastseen(packet, account, true); - mXmppConnectionService.markMessage(account, from.toBareJid(), - id, Message.STATUS_SEND_DISPLAYED); + final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), id, Message.STATUS_SEND_DISPLAYED); + Message message = displayedMessage.prev(); + while(message != null + && message.getStatus() == Message.STATUS_SEND_RECEIVED + && message.getTimeSent() < displayedMessage.getTimeSent()) { + mXmppConnectionService.markMessage(message,Message.STATUS_SEND_DISPLAYED); + message = message.prev(); + } } else if (from != null && packet.hasChild("received", "urn:xmpp:chat-markers:0")) { String id = packet.findChild("received", "urn:xmpp:chat-markers:0") diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 90f69338..a67378de 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2013,19 +2013,20 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } } - public boolean markMessage(final Account account, final Jid recipient, final String uuid, - final int status) { + public Message markMessage(final Account account, final Jid recipient, final String uuid, final int status) { if (uuid == null) { - return false; - } else { - for (Conversation conversation : getConversations()) { - if (conversation.getJid().equals(recipient) - && conversation.getAccount().equals(account)) { - return markMessage(conversation, uuid, status); + return null; + } + for (Conversation conversation : getConversations()) { + if (conversation.getJid().equals(recipient) && conversation.getAccount() == account) { + final Message message = conversation.findSentMessageWithUuid(uuid); + if (message != null) { + markMessage(message, status); } + return message; } - return false; } + return null; } public boolean markMessage(Conversation conversation, String uuid, |