aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-02-03 10:40:44 +0100
committerDaniel Gultsch <daniel@gultsch.de>2016-02-03 10:40:44 +0100
commit1274b0ef3998fdd3753ae9f930029c657e905ddf (patch)
tree3da9742ac2ca6af642058220b2faca7cd96dd91e
parentf0798216d568bca30051ba5392263da31e78eb98 (diff)
Revert "get rid of broken totalMessageCount for mam queries"
This reverts commit 58c6f9bfb283f5c54695b9662b5b4b08e5d4357f.
-rw-r--r--src/main/java/eu/siacs/conversations/parser/MessageParser.java6
-rw-r--r--src/main/java/eu/siacs/conversations/services/MessageArchiveService.java14
2 files changed, 16 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
index 60948918..d8eae969 100644
--- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
@@ -271,7 +271,7 @@ public class MessageParser extends AbstractParser implements
packet = f.first;
isForwarded = true;
serverMsgId = result.getAttribute("id");
- query.incrementMessageCount();
+ query.incrementTotalCount();
} else if (query != null) {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received mam result from invalid sender");
return;
@@ -411,7 +411,9 @@ public class MessageParser extends AbstractParser implements
}
}
- if (query == null) {
+ if (query != null) {
+ query.incrementMessageCount();
+ } else {
mXmppConnectionService.updateConversationUi();
}
diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
index 6fcb4612..4403f99c 100644
--- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
+++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
@@ -201,10 +201,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
Element last = set == null ? null : set.findChild("last");
Element first = set == null ? null : set.findChild("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) {
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) {
mXmppConnectionService.getNotificationService().finishBacklog(true);
}
@@ -246,6 +246,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
}
public class Query {
+ private int totalCount = 0;
private int messageCount = 0;
private long start;
private long end;
@@ -278,6 +279,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
Query query = new Query(this.account,this.start,this.end);
query.reference = reference;
query.conversation = conversation;
+ query.totalCount = totalCount;
query.callback = callback;
return query;
}
@@ -343,10 +345,18 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
return this.account;
}
+ public void incrementTotalCount() {
+ this.totalCount++;
+ }
+
public void incrementMessageCount() {
this.messageCount++;
}
+ public int getTotalCount() {
+ return this.totalCount;
+ }
+
public int getMessageCount() {
return this.messageCount;
}