aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java
diff options
context:
space:
mode:
authorfiaxh <github@lightrise.org>2015-10-15 23:21:47 +0100
committerfiaxh <github@lightrise.org>2015-10-28 19:57:11 +0000
commit29a849cb92c0dc902acd3aa54d0d2f07583bce72 (patch)
treef24dc3bfb5258c95a570d8ee54ca18b057d34602 /src/main/java/eu/siacs/conversations/crypto/PgpEngine.java
parentd65273ce39ab112ba95d0b852cda6717dbf33c8c (diff)
Decrypt PGP messages in background
Diffstat (limited to 'src/main/java/eu/siacs/conversations/crypto/PgpEngine.java')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/PgpEngine.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java
index 8f8122f0..257d0f7e 100644
--- a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java
+++ b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java
@@ -50,6 +50,7 @@ public class PgpEngine {
@Override
public void onReturn(Intent result) {
+ notifyPgpDecryptionService(message.getContact().getAccount(), OpenPgpApi.ACTION_DECRYPT_VERIFY, result);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
@@ -64,6 +65,7 @@ public class PgpEngine {
&& manager.getAutoAcceptFileSize() > 0) {
manager.createNewDownloadConnection(message);
}
+ mXmppConnectionService.updateMessage(message);
callback.success(message);
}
} catch (IOException e) {
@@ -158,6 +160,7 @@ public class PgpEngine {
@Override
public void onReturn(Intent result) {
+ notifyPgpDecryptionService(message.getContact().getAccount(), OpenPgpApi.ACTION_ENCRYPT, result);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
@@ -203,6 +206,7 @@ public class PgpEngine {
@Override
public void onReturn(Intent result) {
+ notifyPgpDecryptionService(message.getContact().getAccount(), OpenPgpApi.ACTION_ENCRYPT, result);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
@@ -252,6 +256,7 @@ public class PgpEngine {
InputStream is = new ByteArrayInputStream(pgpSig.toString().getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = api.executeApi(params, is, os);
+ notifyPgpDecryptionService(account, OpenPgpApi.ACTION_DECRYPT_VERIFY, result);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
@@ -282,6 +287,7 @@ public class PgpEngine {
@Override
public void onReturn(Intent result) {
+ notifyPgpDecryptionService(account, OpenPgpApi.ACTION_SIGN, result);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
StringBuilder signatureBuilder = new StringBuilder();
@@ -368,4 +374,17 @@ public class PgpEngine {
return (PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
}
+
+ private void notifyPgpDecryptionService(Account account, String action, final Intent result) {
+ switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
+ case OpenPgpApi.RESULT_CODE_SUCCESS:
+ if (OpenPgpApi.ACTION_SIGN.equals(action)) {
+ account.getPgpDecryptionService().onKeychainUnlocked();
+ }
+ break;
+ case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
+ account.getPgpDecryptionService().onKeychainLocked();
+ break;
+ }
+ }
}