From 46462e1b9f0a10023bbb9170800b59132bb1df30 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 23 Nov 2017 19:43:47 +0100 Subject: PgpService: feed result intent back into decryption --- .../pixart/messenger/crypto/PgpDecryptionService.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java') diff --git a/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java b/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java index ff039e907..f96e45082 100644 --- a/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java +++ b/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java @@ -25,13 +25,13 @@ import de.pixart.messenger.services.XmppConnectionService; public class PgpDecryptionService { - private final XmppConnectionService mXmppConnectionService; - private OpenPgpApi openPgpApi = null; - protected final ArrayDeque messages = new ArrayDeque(); protected final HashSet pendingNotifications = new HashSet<>(); - Message currentMessage; + private final XmppConnectionService mXmppConnectionService; + private OpenPgpApi openPgpApi = null; + private Message currentMessage; private PendingIntent pendingIntent; + private Intent userInteractionResult; public PgpDecryptionService(XmppConnectionService service) { @@ -111,6 +111,12 @@ public class PgpDecryptionService { continueDecryption(); } + public synchronized void continueDecryption(Intent userInteractionResult) { + this.pendingIntent = null; + this.userInteractionResult = userInteractionResult; + continueDecryption(); + } + public synchronized void continueDecryption() { if (currentMessage == null) { decryptNext(); @@ -126,7 +132,7 @@ public class PgpDecryptionService { private void executeApi(Message message) { synchronized (message) { - Intent params = new Intent(); + Intent params = userInteractionResult != null ? userInteractionResult : new Intent(); params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); if (message.getType() == Message.TYPE_TEXT) { InputStream is = new ByteArrayInputStream(message.getBody().getBytes()); @@ -237,4 +243,4 @@ public class PgpDecryptionService { public boolean isConnected() { return getOpenPgpApi() != null; } -} +} \ No newline at end of file -- cgit v1.2.3