changed lastMessageReceived into lastMessageTransmitted to account for sent messages as well. (will trigger on sm ack)
This commit is contained in:
parent
ccdb0fd971
commit
1dcdc79a71
|
@ -45,7 +45,7 @@ public class Conversation extends AbstractEntity {
|
||||||
public static final String ATTRIBUTE_NEXT_ENCRYPTION = "next_encryption";
|
public static final String ATTRIBUTE_NEXT_ENCRYPTION = "next_encryption";
|
||||||
public static final String ATTRIBUTE_MUC_PASSWORD = "muc_password";
|
public static final String ATTRIBUTE_MUC_PASSWORD = "muc_password";
|
||||||
public static final String ATTRIBUTE_MUTED_TILL = "muted_till";
|
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 name;
|
||||||
private String contactUuid;
|
private String contactUuid;
|
||||||
|
@ -473,14 +473,18 @@ public class Conversation extends AbstractEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setLastMessageReceived(long value) {
|
public boolean setLastMessageTransmitted(long value) {
|
||||||
long before = getLastMessageReceived();
|
long before = getLastMessageTransmitted();
|
||||||
this.setAttribute(ATTRIBUTE_LAST_MESSAGE_RECEIVED, String.valueOf(value));
|
if (value - before > 1000) {
|
||||||
return (value - before > 1000);
|
this.setAttribute(ATTRIBUTE_LAST_MESSAGE_TRANSMITTED, String.valueOf(value));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLastMessageReceived() {
|
public long getLastMessageTransmitted() {
|
||||||
long timestamp = getLongAttribute(ATTRIBUTE_LAST_MESSAGE_RECEIVED,0);
|
long timestamp = getLongAttribute(ATTRIBUTE_LAST_MESSAGE_TRANSMITTED,0);
|
||||||
if (timestamp == 0) {
|
if (timestamp == 0) {
|
||||||
synchronized (this.messages) {
|
synchronized (this.messages) {
|
||||||
for(int i = this.messages.size() - 1; i >= 0; --i) {
|
for(int i = this.messages.size() - 1; i >= 0; --i) {
|
||||||
|
|
|
@ -557,7 +557,7 @@ public class MessageParser extends AbstractParser implements
|
||||||
Conversation conversation = message.getConversation();
|
Conversation conversation = message.getConversation();
|
||||||
conversation.add(message);
|
conversation.add(message);
|
||||||
if (account.getXmppConnection() != null && account.getXmppConnection().getFeatures().advancedStreamFeaturesLoaded()) {
|
if (account.getXmppConnection() != null && account.getXmppConnection().getFeatures().advancedStreamFeaturesLoaded()) {
|
||||||
if (conversation.setLastMessageReceived(System.currentTimeMillis())) {
|
if (conversation.setLastMessageTransmitted(System.currentTimeMillis())) {
|
||||||
mXmppConnectionService.updateConversation(conversation);
|
mXmppConnectionService.updateConversation(conversation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
public void query(final Conversation conversation) {
|
public void query(final Conversation conversation) {
|
||||||
synchronized (this.queries) {
|
synchronized (this.queries) {
|
||||||
final Account account = conversation.getAccount();
|
final Account account = conversation.getAccount();
|
||||||
long start = conversation.getLastMessageReceived();
|
long start = conversation.getLastMessageTransmitted();
|
||||||
long end = account.getXmppConnection().getLastSessionEstablished();
|
long end = account.getXmppConnection().getLastSessionEstablished();
|
||||||
if (end - start >= Config.MAX_HISTORY_AGE) {
|
if (end - start >= Config.MAX_HISTORY_AGE) {
|
||||||
start = end - Config.MAX_HISTORY_AGE;
|
start = end - Config.MAX_HISTORY_AGE;
|
||||||
|
@ -51,7 +51,11 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
synchronized (this.queries) {
|
synchronized (this.queries) {
|
||||||
this.queries.remove(query);
|
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();
|
this.mXmppConnectionService.updateConversationUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,6 @@ import eu.siacs.conversations.utils.OnPhoneContactsLoadedListener;
|
||||||
import eu.siacs.conversations.utils.PRNGFixes;
|
import eu.siacs.conversations.utils.PRNGFixes;
|
||||||
import eu.siacs.conversations.utils.PhoneHelper;
|
import eu.siacs.conversations.utils.PhoneHelper;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xmpp.OnAdvancedStreamFeaturesLoaded;
|
|
||||||
import eu.siacs.conversations.xmpp.OnBindListener;
|
import eu.siacs.conversations.xmpp.OnBindListener;
|
||||||
import eu.siacs.conversations.xmpp.OnContactStatusChanged;
|
import eu.siacs.conversations.xmpp.OnContactStatusChanged;
|
||||||
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
||||||
|
@ -257,15 +256,17 @@ public class XmppConnectionService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageAcknowledged(Account account, String uuid) {
|
public void onMessageAcknowledged(Account account, String uuid) {
|
||||||
for (Conversation conversation : getConversations()) {
|
for (final Conversation conversation : getConversations()) {
|
||||||
if (conversation.getAccount() == account) {
|
if (conversation.getAccount() == account) {
|
||||||
for (Message message : conversation.getMessages()) {
|
for (final Message message : conversation.getMessages()) {
|
||||||
if ((message.getStatus() == Message.STATUS_UNSEND || message
|
final int s = message.getStatus();
|
||||||
.getStatus() == Message.STATUS_WAITING)
|
if ((s == Message.STATUS_UNSEND || s == Message.STATUS_WAITING) && message.getUuid().equals(uuid)) {
|
||||||
&& message.getUuid().equals(uuid)) {
|
|
||||||
markMessage(message, Message.STATUS_SEND);
|
markMessage(message, Message.STATUS_SEND);
|
||||||
|
if (conversation.setLastMessageTransmitted(System.currentTimeMillis())) {
|
||||||
|
databaseBackend.updateConversation(conversation);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -854,11 +855,11 @@ public class XmppConnectionService extends Service {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final Contact contact = account.getRoster()
|
final Contact contact = account.getRoster()
|
||||||
.getContact(jid);
|
.getContact(jid);
|
||||||
String systemAccount = phoneContact
|
String systemAccount = phoneContact
|
||||||
.getInt("phoneid")
|
.getInt("phoneid")
|
||||||
+ "#"
|
+ "#"
|
||||||
+ phoneContact.getString("lookup");
|
+ phoneContact.getString("lookup");
|
||||||
contact.setSystemAccount(systemAccount);
|
contact.setSystemAccount(systemAccount);
|
||||||
contact.setPhotoUri(phoneContact
|
contact.setPhotoUri(phoneContact
|
||||||
.getString("photouri"));
|
.getString("photouri"));
|
||||||
|
@ -1253,7 +1254,7 @@ public class XmppConnectionService extends Service {
|
||||||
if (conversation.getMucOptions().getPassword() != null) {
|
if (conversation.getMucOptions().getPassword() != null) {
|
||||||
x.addChild("password").setContent(conversation.getMucOptions().getPassword());
|
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();
|
String sig = account.getPgpSignature();
|
||||||
if (sig != null) {
|
if (sig != null) {
|
||||||
packet.addChild("status").setContent("online");
|
packet.addChild("status").setContent("online");
|
||||||
|
|
Loading…
Reference in a new issue