aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-03-18 14:14:21 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2014-03-18 14:14:21 +0100
commit77b8b870ee8244cdf652ab5ff0d08c24474f93e7 (patch)
treed2638120393a590bc05c19931f2da755be18da3d /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service
parentefab1d27ac7ffb9e39fe5acd8064c708dc588452 (diff)
parente01c99a193528df717d5cf5bd9fe20c649297375 (diff)
downloadopen-keychain-77b8b870ee8244cdf652ab5ff0d08c24474f93e7.tar.gz
open-keychain-77b8b870ee8244cdf652ab5ff0d08c24474f93e7.tar.bz2
open-keychain-77b8b870ee8244cdf652ab5ff0d08c24474f93e7.zip
Merge pull request #421 from uberspot/master
Fix export for new unified key list #409 and lock drawer in tablets #255
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java50
1 files changed, 26 insertions, 24 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
index 4e5812202..a44b121ec 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
@@ -131,7 +131,6 @@ public class KeychainIntentService extends IntentService
public static final String EXPORT_KEY_TYPE = "export_key_type";
public static final String EXPORT_ALL = "export_all";
public static final String EXPORT_KEY_RING_MASTER_KEY_ID = "export_key_ring_id";
- public static final String EXPORT_KEY_RING_ROW_ID = "export_key_rind_row_id";
// upload key
public static final String UPLOAD_KEY_SERVER = "upload_key_server";
@@ -660,16 +659,11 @@ public class KeychainIntentService extends IntentService
if (data.containsKey(EXPORT_KEY_TYPE)) {
keyType = data.getInt(EXPORT_KEY_TYPE);
}
-
+ long[] masterKeyIds = data.getLongArray(EXPORT_KEY_RING_MASTER_KEY_ID);
String outputFile = data.getString(EXPORT_FILENAME);
- long[] rowIds = new long[0];
-
- // If not exporting all keys get the rowIds of the keys to export from the intent
+ // If not exporting all keys get the masterKeyIds of the keys to export from the intent
boolean exportAll = data.getBoolean(EXPORT_ALL);
- if (!exportAll) {
- rowIds = data.getLongArray(EXPORT_KEY_RING_ROW_ID);
- }
/* Operation */
@@ -678,30 +672,38 @@ public class KeychainIntentService extends IntentService
throw new PgpGeneralException(getString(R.string.error_external_storage_not_ready));
}
- // OutputStream
- FileOutputStream outStream = new FileOutputStream(outputFile);
+ ArrayList<Long> publicMasterKeyIds = new ArrayList<Long>();
+ ArrayList<Long> secretMasterKeyIds = new ArrayList<Long>();
+ ArrayList<Long> allPublicMasterKeyIds = ProviderHelper.getPublicKeyRingsMasterKeyIds(this);
+ ArrayList<Long> allSecretMasterKeyIds = ProviderHelper.getSecretKeyRingsMasterKeyIds(this);
- ArrayList<Long> keyRingRowIds = new ArrayList<Long>();
if (exportAll) {
-
- // get all key ring row ids based on export type
- if (keyType == Id.type.public_key) {
- keyRingRowIds = ProviderHelper.getPublicKeyRingsRowIds(this);
- } else {
- keyRingRowIds = ProviderHelper.getSecretKeyRingsRowIds(this);
+ // get all public key ring MasterKey ids
+ if (keyType == Id.type.public_key || keyType == Id.type.public_secret_key) {
+ publicMasterKeyIds = allPublicMasterKeyIds;
+ }
+ // get all secret key ring MasterKey ids
+ if (keyType == Id.type.secret_key || keyType == Id.type.public_secret_key) {
+ secretMasterKeyIds = allSecretMasterKeyIds;
}
} else {
- for (long rowId : rowIds) {
- keyRingRowIds.add(rowId);
+
+ for (long masterKeyId : masterKeyIds) {
+ if ((keyType == Id.type.public_key || keyType == Id.type.public_secret_key)
+ && allPublicMasterKeyIds.contains(masterKeyId)) {
+ publicMasterKeyIds.add(masterKeyId);
+ }
+ if ((keyType == Id.type.secret_key || keyType == Id.type.public_secret_key)
+ && allSecretMasterKeyIds.contains(masterKeyId)) {
+ secretMasterKeyIds.add(masterKeyId);
+ }
}
}
- Bundle resultData;
-
PgpImportExport pgpImportExport = new PgpImportExport(this, this, this);
-
- resultData = pgpImportExport
- .exportKeyRings(keyRingRowIds, keyType, outStream);
+ Bundle resultData = pgpImportExport
+ .exportKeyRings(publicMasterKeyIds, secretMasterKeyIds,
+ new FileOutputStream(outputFile));
if (mIsCanceled) {
boolean isDeleted = new File(outputFile).delete();