Revert "get rid of broken totalMessageCount for mam queries"

This reverts commit 58c6f9bfb2.
This commit is contained in:
Daniel Gultsch 2016-02-03 10:40:44 +01:00
parent f0798216d5
commit 1274b0ef39
2 changed files with 16 additions and 4 deletions

View File

@ -271,7 +271,7 @@ public class MessageParser extends AbstractParser implements
packet = f.first; packet = f.first;
isForwarded = true; isForwarded = true;
serverMsgId = result.getAttribute("id"); serverMsgId = result.getAttribute("id");
query.incrementMessageCount(); query.incrementTotalCount();
} else if (query != null) { } else if (query != null) {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received mam result from invalid sender"); Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received mam result from invalid sender");
return; return;
@ -411,7 +411,9 @@ public class MessageParser extends AbstractParser implements
} }
} }
if (query == null) { if (query != null) {
query.incrementMessageCount();
} else {
mXmppConnectionService.updateConversationUi(); mXmppConnectionService.updateConversationUi();
} }

View File

@ -201,10 +201,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
Element last = set == null ? null : set.findChild("last"); Element last = set == null ? null : set.findChild("last");
Element first = set == null ? null : set.findChild("first"); Element first = set == null ? null : set.findChild("first");
Element relevant = query.getPagingOrder() == PagingOrder.NORMAL ? last : first; Element relevant = query.getPagingOrder() == PagingOrder.NORMAL ? last : first;
boolean abort = (query.getStart() == 0 && query.getMessageCount() >= Config.PAGE_SIZE) || query.getMessageCount() >= Config.MAM_MAX_MESSAGES; boolean abort = (query.getStart() == 0 && query.getTotalCount() >= Config.PAGE_SIZE) || query.getTotalCount() >= Config.MAM_MAX_MESSAGES;
if (complete || relevant == null || abort) { if (complete || relevant == null || abort) {
this.finalizeQuery(query); this.finalizeQuery(query);
Log.d(Config.LOGTAG,query.getAccount().getJid().toBareJid().toString()+": finished mam after "+query.getMessageCount()+" messages"); Log.d(Config.LOGTAG,query.getAccount().getJid().toBareJid().toString()+": finished mam after "+query.getTotalCount()+" messages");
if (query.getWith() == null && query.getMessageCount() > 0) { if (query.getWith() == null && query.getMessageCount() > 0) {
mXmppConnectionService.getNotificationService().finishBacklog(true); mXmppConnectionService.getNotificationService().finishBacklog(true);
} }
@ -246,6 +246,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
} }
public class Query { public class Query {
private int totalCount = 0;
private int messageCount = 0; private int messageCount = 0;
private long start; private long start;
private long end; private long end;
@ -278,6 +279,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
Query query = new Query(this.account,this.start,this.end); Query query = new Query(this.account,this.start,this.end);
query.reference = reference; query.reference = reference;
query.conversation = conversation; query.conversation = conversation;
query.totalCount = totalCount;
query.callback = callback; query.callback = callback;
return query; return query;
} }
@ -343,10 +345,18 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
return this.account; return this.account;
} }
public void incrementTotalCount() {
this.totalCount++;
}
public void incrementMessageCount() { public void incrementMessageCount() {
this.messageCount++; this.messageCount++;
} }
public int getTotalCount() {
return this.totalCount;
}
public int getMessageCount() { public int getMessageCount() {
return this.messageCount; return this.messageCount;
} }