aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java21
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java5
2 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java b/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java
index bcdc7bbed..ff039e907 100644
--- a/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java
+++ b/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java
@@ -69,6 +69,27 @@ public class PgpDecryptionService {
this.pendingNotifications.remove(message);
}
+ public void giveUpCurrentDecryption() {
+ Message message;
+ synchronized (this) {
+ if (currentMessage != null) {
+ return;
+ }
+ message = messages.peekFirst();
+ if (message == null) {
+ return;
+ }
+ discard(message);
+ }
+ synchronized (message) {
+ if (message.getEncryption() == Message.ENCRYPTION_PGP) {
+ message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED);
+ }
+ }
+ mXmppConnectionService.updateMessage(message);
+ continueDecryption(true);
+ }
+
protected synchronized void decryptNext() {
if (pendingIntent == null
&& getOpenPgpApi() != null
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index a243688d7..30d0f19ff 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -1640,6 +1640,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
int choice = data.getIntExtra("choice", ConversationActivity.ATTACHMENT_CHOICE_INVALID);
activity.selectPresenceToAttachFile(choice, conversation.getNextEncryption());
}
+ } else if (resultCode == Activity.RESULT_CANCELED) {
+ if (requestCode == ConversationActivity.REQUEST_DECRYPT_PGP) {
+ // discard the message to prevent decryption being blocked
+ conversation.getAccount().getPgpDecryptionService().giveUpCurrentDecryption();
+ }
}
}