diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-06 23:39:26 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-06 23:40:22 +0200 |
commit | b779211f55a126d54c643fb9f13a0a17b46c37bf (patch) | |
tree | a526af2e5d385691c20393560443e17f9a61201a /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations | |
parent | fa614383065a22269c5ca249819c46b82e20a194 (diff) | |
parent | 7cfc0d80d0b4318ce1ae027536d70c2cda4c8605 (diff) | |
download | open-keychain-b779211f55a126d54c643fb9f13a0a17b46c37bf.tar.gz open-keychain-b779211f55a126d54c643fb9f13a0a17b46c37bf.tar.bz2 open-keychain-b779211f55a126d54c643fb9f13a0a17b46c37bf.zip |
Merge branch 'master' into v/multi-decrypt
this also fixes weird-bug
Conflicts:
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java
OpenKeychain/src/main/res/values/strings.xml
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations')
3 files changed, 25 insertions, 18 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java index a824e73d7..5a3321ac8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java @@ -40,7 +40,7 @@ public abstract class BaseOperation implements PassphraseCacheInterface { * of common methods for progress, cancellation and passphrase cache handling. * * An "operation" in this sense is a high level operation which is called - * by the KeychainIntentService or OpenPgpService services. Concrete + * by the KeychainService or OpenPgpService services. Concrete * subclasses of this class should implement either a single or a group of * related operations. An operation must rely solely on its input * parameters for operation specifics. It should also write a log of its @@ -49,7 +49,7 @@ public abstract class BaseOperation implements PassphraseCacheInterface { * * An operation must *not* throw exceptions of any kind, errors should be * handled as part of the OperationResult! Consequently, all handling of - * errors in KeychainIntentService and OpenPgpService should consist of + * errors in KeychainService and OpenPgpService should consist of * informational rather than operational means. * * Note that subclasses of this class should be either Android- or diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java index 86cfc21a3..ffce2f39c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java @@ -38,7 +38,6 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; -import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.Progressable; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; @@ -157,6 +156,15 @@ public class ImportExportOperation extends BaseOperation { } + /** + * Since the introduction of multithreaded import, we expect calling functions to handle the key sync i,e + * ContactSyncAdapterService.requestSync() + * + * @param entries keys to import + * @param num number of keys to import + * @param keyServerUri contains uri of keyserver to import from, if it is an import from cloud + * @return + */ public ImportKeyResult importKeyRings(Iterator<ParcelableKeyRing> entries, int num, String keyServerUri) { updateProgress(R.string.progress_importing, 0, 100); @@ -244,25 +252,25 @@ public class ImportExportOperation extends BaseOperation { try { log.add(LogType.MSG_IMPORT_FETCH_KEYBASE, 2, entry.mKeybaseName); byte[] data = keybaseServer.get(entry.mKeybaseName).getBytes(); - key = UncachedKeyRing.decodeFromData(data); + UncachedKeyRing keybaseKey = UncachedKeyRing.decodeFromData(data); - // If there already is a key (of keybase origin), merge the two - if (key != null) { + // If there already is a key, merge the two + if (key != null && keybaseKey != null) { log.add(LogType.MSG_IMPORT_MERGE, 3); - UncachedKeyRing merged = UncachedKeyRing.decodeFromData(data); - merged = key.merge(merged, log, 4); + keybaseKey = key.merge(keybaseKey, log, 4); // If the merge didn't fail, use the new merged key - if (merged != null) { - key = merged; + if (keybaseKey != null) { + key = keybaseKey; + } else { + log.add(LogType.MSG_IMPORT_MERGE_ERROR, 4); } - } else { - log.add(LogType.MSG_IMPORT_FETCH_ERROR_DECODE, 3); - key = UncachedKeyRing.decodeFromData(data); + } else if (keybaseKey != null) { + key = keybaseKey; } } catch (Keyserver.QueryFailedException e) { // download failed, too bad. just proceed Log.e(Constants.TAG, "query failed", e); - log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER_ERROR, 3); + log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER_ERROR, 3, e.getMessage()); } } } @@ -331,8 +339,8 @@ public class ImportExportOperation extends BaseOperation { // Special: make sure new data is synced into contacts // disabling sync right now since it reduces speed while multi-threading - // so, we expect calling functions to take care of it. KeychainIntentService handles this - //ContactSyncAdapterService.requestSync(); + // so, we expect calling functions to take care of it. KeychainService handles this + // ContactSyncAdapterService.requestSync(); // convert to long array long[] importedMasterKeyIdsArray = new long[importedMasterKeyIds.size()]; @@ -376,8 +384,6 @@ public class ImportExportOperation extends BaseOperation { log.add(LogType.MSG_IMPORT_ERROR, 1); } - ContactSyncAdapterService.requestSync(); - return new ImportKeyResult(resultType, log, newKeys, updatedKeys, badKeys, secret, importedMasterKeyIdsArray); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java index 2551c1802..707cf0af1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java @@ -696,6 +696,7 @@ public abstract class OperationResult implements Parcelable { MSG_IMPORT_FETCH_KEYBASE (LogLevel.INFO, R.string.msg_import_fetch_keybase), MSG_IMPORT_KEYSERVER (LogLevel.DEBUG, R.string.msg_import_keyserver), MSG_IMPORT_MERGE (LogLevel.DEBUG, R.string.msg_import_merge), + MSG_IMPORT_MERGE_ERROR (LogLevel.ERROR, R.string.msg_import_merge_error), MSG_IMPORT_FINGERPRINT_ERROR (LogLevel.ERROR, R.string.msg_import_fingerprint_error), MSG_IMPORT_FINGERPRINT_OK (LogLevel.DEBUG, R.string.msg_import_fingerprint_ok), MSG_IMPORT_ERROR (LogLevel.ERROR, R.string.msg_import_error), |