aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-12-09 22:50:53 +0100
committeriNPUTmice <daniel@gultsch.de>2014-12-10 14:08:06 +0100
commit1dcdc79a71ae36aadba4c8a82aded46cca9dcf61 (patch)
tree94d52894095da9d2781d98010cf9107962879213 /src/main/java/eu
parentccdb0fd9717fcc79374b55e741bc03eb02fe526d (diff)
changed lastMessageReceived into lastMessageTransmitted to account for sent messages as well. (will trigger on sm ack)
Diffstat (limited to 'src/main/java/eu')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java18
-rw-r--r--src/main/java/eu/siacs/conversations/parser/MessageParser.java2
-rw-r--r--src/main/java/eu/siacs/conversations/services/MessageArchiveService.java8
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java25
4 files changed, 31 insertions, 22 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index 63f341e72..e254cfc28 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -45,7 +45,7 @@ public class Conversation extends AbstractEntity {
public static final String ATTRIBUTE_NEXT_ENCRYPTION = "next_encryption";
public static final String ATTRIBUTE_MUC_PASSWORD = "muc_password";
public static final String ATTRIBUTE_MUTED_TILL = "muted_till";
- public static final String ATTRIBUTE_LAST_MESSAGE_RECEIVED = "last_message_received";
+ public static final String ATTRIBUTE_LAST_MESSAGE_TRANSMITTED = "last_message_transmitted";
private String name;
private String contactUuid;
@@ -473,14 +473,18 @@ public class Conversation extends AbstractEntity {
}
}
- public boolean setLastMessageReceived(long value) {
- long before = getLastMessageReceived();
- this.setAttribute(ATTRIBUTE_LAST_MESSAGE_RECEIVED, String.valueOf(value));
- return (value - before > 1000);
+ public boolean setLastMessageTransmitted(long value) {
+ long before = getLastMessageTransmitted();
+ if (value - before > 1000) {
+ this.setAttribute(ATTRIBUTE_LAST_MESSAGE_TRANSMITTED, String.valueOf(value));
+ return true;
+ } else {
+ return false;
+ }
}
- public long getLastMessageReceived() {
- long timestamp = getLongAttribute(ATTRIBUTE_LAST_MESSAGE_RECEIVED,0);
+ public long getLastMessageTransmitted() {
+ long timestamp = getLongAttribute(ATTRIBUTE_LAST_MESSAGE_TRANSMITTED,0);
if (timestamp == 0) {
synchronized (this.messages) {
for(int i = this.messages.size() - 1; i >= 0; --i) {
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
index 9944f364f..74d38ce44 100644
--- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
@@ -557,7 +557,7 @@ public class MessageParser extends AbstractParser implements
Conversation conversation = message.getConversation();
conversation.add(message);
if (account.getXmppConnection() != null && account.getXmppConnection().getFeatures().advancedStreamFeaturesLoaded()) {
- if (conversation.setLastMessageReceived(System.currentTimeMillis())) {
+ if (conversation.setLastMessageTransmitted(System.currentTimeMillis())) {
mXmppConnectionService.updateConversation(conversation);
}
}
diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
index c77262cb4..c93a6e759 100644
--- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
+++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
@@ -28,7 +28,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
public void query(final Conversation conversation) {
synchronized (this.queries) {
final Account account = conversation.getAccount();
- long start = conversation.getLastMessageReceived();
+ long start = conversation.getLastMessageTransmitted();
long end = account.getXmppConnection().getLastSessionEstablished();
if (end - start >= Config.MAX_HISTORY_AGE) {
start = end - Config.MAX_HISTORY_AGE;
@@ -51,7 +51,11 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
synchronized (this.queries) {
this.queries.remove(query);
}
- query.getConversation().sort();
+ final Conversation conversation = query.getConversation();
+ conversation.sort();
+ if (conversation.setLastMessageTransmitted(query.getEnd())) {
+ this.mXmppConnectionService.databaseBackend.updateConversation(conversation);
+ }
this.mXmppConnectionService.updateConversationUi();
}
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 3e2c1b8b5..86b6be568 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -73,7 +73,6 @@ import eu.siacs.conversations.utils.OnPhoneContactsLoadedListener;
import eu.siacs.conversations.utils.PRNGFixes;
import eu.siacs.conversations.utils.PhoneHelper;
import eu.siacs.conversations.xml.Element;
-import eu.siacs.conversations.xmpp.OnAdvancedStreamFeaturesLoaded;
import eu.siacs.conversations.xmpp.OnBindListener;
import eu.siacs.conversations.xmpp.OnContactStatusChanged;
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
@@ -257,15 +256,17 @@ public class XmppConnectionService extends Service {
@Override
public void onMessageAcknowledged(Account account, String uuid) {
- for (Conversation conversation : getConversations()) {
+ for (final Conversation conversation : getConversations()) {
if (conversation.getAccount() == account) {
- for (Message message : conversation.getMessages()) {
- if ((message.getStatus() == Message.STATUS_UNSEND || message
- .getStatus() == Message.STATUS_WAITING)
- && message.getUuid().equals(uuid)) {
+ for (final Message message : conversation.getMessages()) {
+ final int s = message.getStatus();
+ if ((s == Message.STATUS_UNSEND || s == Message.STATUS_WAITING) && message.getUuid().equals(uuid)) {
markMessage(message, Message.STATUS_SEND);
+ if (conversation.setLastMessageTransmitted(System.currentTimeMillis())) {
+ databaseBackend.updateConversation(conversation);
+ }
return;
- }
+ }
}
}
}
@@ -854,11 +855,11 @@ public class XmppConnectionService extends Service {
break;
}
final Contact contact = account.getRoster()
- .getContact(jid);
+ .getContact(jid);
String systemAccount = phoneContact
- .getInt("phoneid")
- + "#"
- + phoneContact.getString("lookup");
+ .getInt("phoneid")
+ + "#"
+ + phoneContact.getString("lookup");
contact.setSystemAccount(systemAccount);
contact.setPhotoUri(phoneContact
.getString("photouri"));
@@ -1253,7 +1254,7 @@ public class XmppConnectionService extends Service {
if (conversation.getMucOptions().getPassword() != null) {
x.addChild("password").setContent(conversation.getMucOptions().getPassword());
}
- x.addChild("history").setAttribute("since",PresenceGenerator.getTimestamp(conversation.getLastMessageReceived()));
+ x.addChild("history").setAttribute("since",PresenceGenerator.getTimestamp(conversation.getLastMessageTransmitted()));
String sig = account.getPgpSignature();
if (sig != null) {
packet.addChild("status").setContent("online");