aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-06-13 19:06:09 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-06-13 19:06:09 +0200
commit39ad426ca9afdf0a3c2fbc49cdde5ec7fd157f42 (patch)
tree6d9f12bb652eaf9b1a45e3a2004555d323eb01a4
parent40f81f19dfbfd806a604012fc1aa2eafb4e10cfe (diff)
remove messages from decryption queue when trimming a conversation
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java4
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java19
2 files changed, 19 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java b/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java
index 2bc270c1..0a34ba17 100644
--- a/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java
+++ b/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java
@@ -50,6 +50,10 @@ public class PgpDecryptionService {
continueDecryption();
}
+ public synchronized void discard(List<Message> discards) {
+ this.messages.removeAll(discards);
+ }
+
protected synchronized void decryptNext() {
if (pendingIntent == null
&& getOpenPgpApi() != null
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index 182e86dd..94502d24 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -22,6 +22,7 @@ import java.util.Iterator;
import java.util.List;
import eu.siacs.conversations.Config;
+import eu.siacs.conversations.crypto.PgpDecryptionService;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
@@ -206,7 +207,13 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
final int size = messages.size();
final int maxsize = Config.PAGE_SIZE * Config.MAX_NUM_PAGES;
if (size > maxsize) {
- this.messages.subList(0, size - maxsize).clear();
+ List<Message> discards = this.messages.subList(0, size - maxsize);
+ final PgpDecryptionService pgpDecryptionService = account.getPgpDecryptionService();
+ if (pgpDecryptionService != null) {
+ pgpDecryptionService.discard(discards);
+ }
+ discards.clear();
+ untieMessages();
}
}
}
@@ -949,9 +956,13 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
}
});
- for(Message message : this.messages) {
- message.untie();
- }
+ untieMessages();
+ }
+ }
+
+ private void untieMessages() {
+ for(Message message : this.messages) {
+ message.untie();
}
}