Commit 45fa9970 authored by linuschien's avatar linuschien Committed by Guus der Kinderen
parent 64b3af11
...@@ -75,8 +75,12 @@ public class IQRetrieveHandler extends AbstractIQHandler { ...@@ -75,8 +75,12 @@ public class IQRetrieveHandler extends AbstractIQHandler {
final List<ArchivedMessage> messages = conversation.getMessages() final List<ArchivedMessage> messages = conversation.getMessages()
.subList(fromIndex, toIndex); .subList(fromIndex, toIndex);
for (ArchivedMessage message : messages) { for (int i = 0; i < messages.size(); i++) {
addMessageElement(chatElement, conversation, message); if (i == 0) {
addMessageElement(chatElement, conversation, messages.get(i), null);
} else {
addMessageElement(chatElement, conversation, messages.get(i), messages.get(i - 1));
}
} }
if (resultSet != null) { if (resultSet != null) {
...@@ -98,11 +102,16 @@ public class IQRetrieveHandler extends AbstractIQHandler { ...@@ -98,11 +102,16 @@ public class IQRetrieveHandler extends AbstractIQHandler {
} }
private Element addMessageElement(Element parentElement, private Element addMessageElement(Element parentElement,
Conversation conversation, ArchivedMessage message) { Conversation conversation, ArchivedMessage message, ArchivedMessage previousMessage) {
final Element messageElement; final Element messageElement;
final long secs; final long secs;
if (previousMessage == null) {
secs = (message.getTime().getTime() - conversation.getStart().getTime()) / 1000; secs = (message.getTime().getTime() - conversation.getStart().getTime()) / 1000;
} else {
secs = (message.getTime().getTime() - previousMessage.getTime().getTime()) / 1000;
}
messageElement = parentElement.addElement(message.getDirection() messageElement = parentElement.addElement(message.getDirection()
.toString()); .toString());
messageElement.addAttribute("secs", Long.toString(secs)); messageElement.addAttribute("secs", Long.toString(secs));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment