aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-04-28 20:20:23 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-04-28 20:20:23 +0200
commit1bd357cf55cf5a40134407495487de5e56487d12 (patch)
tree9ab5ac5dd9d3ffb1b31b3ef222cf4932567fdcc5 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain
parent0963efc78b7d46b2c92a5e13e0fffb8f67255242 (diff)
downloadopen-keychain-1bd357cf55cf5a40134407495487de5e56487d12.tar.gz
open-keychain-1bd357cf55cf5a40134407495487de5e56487d12.tar.bz2
open-keychain-1bd357cf55cf5a40134407495487de5e56487d12.zip
API: Fix GET_KEY, closes #599
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
index 9f093ada0..6e0179aaa 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -408,16 +408,26 @@ public class OpenPgpService extends RemoteService {
private Intent getKeyImpl(Intent data) {
try {
- long keyId = data.getLongExtra(OpenPgpApi.EXTRA_KEY_ID, 0);
+ long masterKeyId = data.getLongExtra(OpenPgpApi.EXTRA_KEY_ID, 0);
- if (mProviderHelper.getPGPPublicKeyRingWithKeyId(keyId) == null) {
+ try {
+ // try to find key, throws NotFoundException if not in db!
+ mProviderHelper.getPGPPublicKeyRing(masterKeyId);
+
+ Intent result = new Intent();
+ result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
+
+ // TODO: also return PendingIntent that opens the key view activity
+
+ return result;
+ } catch (ProviderHelper.NotFoundException e) {
Intent result = new Intent();
// If keys are not in db we return an additional PendingIntent
// to retrieve the missing key
Intent intent = new Intent(getBaseContext(), ImportKeysActivity.class);
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN);
- intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, keyId);
+ intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, masterKeyId);
intent.putExtra(ImportKeysActivity.EXTRA_PENDING_INTENT_DATA, data);
PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0,
@@ -427,13 +437,6 @@ public class OpenPgpService extends RemoteService {
result.putExtra(OpenPgpApi.RESULT_INTENT, pi);
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED);
return result;
- } else {
- Intent result = new Intent();
- result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
-
- // TODO: also return PendingIntent that opens the key view activity
-
- return result;
}
} catch (Exception e) {
Intent result = new Intent();