aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java1
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java254
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java68
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSignature.java12
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java22
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java15
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java348
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ConsolidateResult.java27
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/EditKeyResult.java63
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java192
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResultParcel.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java)3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SaveKeyringResult.java68
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SingletonResult.java83
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java6
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java2
26 files changed, 681 insertions, 548 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java
index 0d3e5676a..554899843 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java
@@ -59,6 +59,10 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
return getPublicKey().getPrimaryUserIdWithFallback();
}
+ public ArrayList<byte[]> getUnorderedRawUserIds() {
+ return getPublicKey().getUnorderedRawUserIds();
+ }
+
public ArrayList<String> getUnorderedUserIds() {
return getPublicKey().getUnorderedUserIds();
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
index aa85b1082..b2b633ed7 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
@@ -60,7 +60,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLConnection;
import java.security.SignatureException;
-import java.util.Date;
import java.util.Iterator;
import java.util.Set;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
index 511086489..06415cf8a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
@@ -33,11 +33,11 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogType;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.OperationLog;
-import org.sufficientlysecure.keychain.service.OperationResults.ImportKeyResult;
-import org.sufficientlysecure.keychain.service.OperationResults.SaveKeyringResult;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
+import org.sufficientlysecure.keychain.service.results.ImportKeyResult;
+import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.ProgressScaler;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
index 9bfea2414..ad592a3e9 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
@@ -46,11 +46,11 @@ import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogType;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.OperationLog;
-import org.sufficientlysecure.keychain.service.OperationResults.EditKeyResult;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
+import org.sufficientlysecure.keychain.service.results.EditKeyResult;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Curve;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
index e26fa4446..768065f1c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
@@ -33,11 +33,12 @@ import org.spongycastle.openpgp.PGPSignature;
import org.spongycastle.openpgp.PGPSignatureList;
import org.spongycastle.openpgp.PGPUtil;
import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
+import org.spongycastle.util.Strings;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogType;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.OperationLog;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.util.Log;
@@ -361,156 +362,159 @@ public class UncachedKeyRing {
}
}
- ArrayList<String> processedUserIds = new ArrayList<String>();
- for (String userId : new IterableIterator<String>(masterKey.getUserIDs())) {
+ ArrayList<byte[]> processedUserIds = new ArrayList<byte[]>();
+ for (byte[] rawUserId : new IterableIterator<byte[]>(masterKey.getRawUserIDs())) {
+ String userId = Strings.fromUTF8ByteArray(rawUserId);
+
// check for duplicate user ids
- if (processedUserIds.contains(userId)) {
+ if (processedUserIds.contains(rawUserId)) {
log.add(LogLevel.WARN, LogType.MSG_KC_UID_DUP,
indent, userId);
// strip out the first found user id with this name
- modified = PGPPublicKey.removeCertification(modified, userId);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId);
}
- processedUserIds.add(userId);
+ processedUserIds.add(rawUserId);
PGPSignature selfCert = null;
revocation = null;
- // look through signatures for this specific key
- for (PGPSignature zert : new IterableIterator<PGPSignature>(
- masterKey.getSignaturesForID(userId))) {
- WrappedSignature cert = new WrappedSignature(zert);
- long certId = cert.getKeyId();
-
- int type = zert.getSignatureType();
- if (type != PGPSignature.DEFAULT_CERTIFICATION
- && type != PGPSignature.NO_CERTIFICATION
- && type != PGPSignature.CASUAL_CERTIFICATION
- && type != PGPSignature.POSITIVE_CERTIFICATION
- && type != PGPSignature.CERTIFICATION_REVOCATION) {
- log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_TYPE,
- indent, "0x" + Integer.toString(zert.getSignatureType(), 16));
- modified = PGPPublicKey.removeCertification(modified, userId, zert);
- badCerts += 1;
- continue;
- }
-
- if (cert.getCreationTime().after(now)) {
- // Creation date in the future? No way!
- log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_TIME, indent);
- modified = PGPPublicKey.removeCertification(modified, userId, zert);
- badCerts += 1;
- continue;
- }
-
- if (cert.isLocal()) {
- // Creation date in the future? No way!
- log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_LOCAL, indent);
- modified = PGPPublicKey.removeCertification(modified, userId, zert);
- badCerts += 1;
- continue;
- }
+ // look through signatures for this specific user id
+ @SuppressWarnings("unchecked")
+ Iterator<PGPSignature> signaturesIt = masterKey.getSignaturesForID(rawUserId);
+ if (signaturesIt != null) {
+ for (PGPSignature zert : new IterableIterator<PGPSignature>(signaturesIt)) {
+ WrappedSignature cert = new WrappedSignature(zert);
+ long certId = cert.getKeyId();
+
+ int type = zert.getSignatureType();
+ if (type != PGPSignature.DEFAULT_CERTIFICATION
+ && type != PGPSignature.NO_CERTIFICATION
+ && type != PGPSignature.CASUAL_CERTIFICATION
+ && type != PGPSignature.POSITIVE_CERTIFICATION
+ && type != PGPSignature.CERTIFICATION_REVOCATION) {
+ log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_TYPE,
+ indent, "0x" + Integer.toString(zert.getSignatureType(), 16));
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, zert);
+ badCerts += 1;
+ continue;
+ }
- // If this is a foreign signature, ...
- if (certId != masterKeyId) {
- // never mind any further for public keys, but remove them from secret ones
- if (isSecret()) {
- log.add(LogLevel.WARN, LogType.MSG_KC_UID_FOREIGN,
- indent, PgpKeyHelper.convertKeyIdToHex(certId));
- modified = PGPPublicKey.removeCertification(modified, userId, zert);
+ if (cert.getCreationTime().after(now)) {
+ // Creation date in the future? No way!
+ log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_TIME, indent);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, zert);
badCerts += 1;
+ continue;
}
- continue;
- }
- // Otherwise, first make sure it checks out
- try {
- cert.init(masterKey);
- if (!cert.verifySignature(masterKey, userId)) {
- log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD,
- indent, userId);
- modified = PGPPublicKey.removeCertification(modified, userId, zert);
+ if (cert.isLocal()) {
+ // Creation date in the future? No way!
+ log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_LOCAL, indent);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, zert);
badCerts += 1;
continue;
}
- } catch (PgpGeneralException e) {
- log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_ERR,
- indent, userId);
- modified = PGPPublicKey.removeCertification(modified, userId, zert);
- badCerts += 1;
- continue;
- }
- switch (type) {
- case PGPSignature.DEFAULT_CERTIFICATION:
- case PGPSignature.NO_CERTIFICATION:
- case PGPSignature.CASUAL_CERTIFICATION:
- case PGPSignature.POSITIVE_CERTIFICATION:
- if (selfCert == null) {
- selfCert = zert;
- } else if (selfCert.getCreationTime().before(cert.getCreationTime())) {
- log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_CERT_DUP,
- indent, userId);
- modified = PGPPublicKey.removeCertification(modified, userId, selfCert);
- redundantCerts += 1;
- selfCert = zert;
- } else {
- log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_CERT_DUP,
- indent, userId);
- modified = PGPPublicKey.removeCertification(modified, userId, zert);
- redundantCerts += 1;
- }
- // If there is a revocation certificate, and it's older than this, drop it
- if (revocation != null
- && revocation.getCreationTime().before(selfCert.getCreationTime())) {
- log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_OLD,
- indent, userId);
- modified = PGPPublicKey.removeCertification(modified, userId, revocation);
- revocation = null;
- redundantCerts += 1;
+ // If this is a foreign signature, ...
+ if (certId != masterKeyId) {
+ // never mind any further for public keys, but remove them from secret ones
+ if (isSecret()) {
+ log.add(LogLevel.WARN, LogType.MSG_KC_UID_FOREIGN,
+ indent, PgpKeyHelper.convertKeyIdToHex(certId));
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, zert);
+ badCerts += 1;
}
- break;
+ continue;
+ }
- case PGPSignature.CERTIFICATION_REVOCATION:
- // If this is older than the (latest) self cert, drop it
- if (selfCert != null && selfCert.getCreationTime().after(zert.getCreationTime())) {
- log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_OLD,
+ // Otherwise, first make sure it checks out
+ try {
+ cert.init(masterKey);
+ if (!cert.verifySignature(masterKey, rawUserId)) {
+ log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD,
indent, userId);
- modified = PGPPublicKey.removeCertification(modified, userId, zert);
- redundantCerts += 1;
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, zert);
+ badCerts += 1;
continue;
}
- // first revocation? remember it.
- if (revocation == null) {
- revocation = zert;
- // more revocations? at least one is superfluous, then.
- } else if (revocation.getCreationTime().before(cert.getCreationTime())) {
- log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_DUP,
- indent, userId);
- modified = PGPPublicKey.removeCertification(modified, userId, revocation);
- redundantCerts += 1;
- revocation = zert;
- } else {
- log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_DUP,
- indent, userId);
- modified = PGPPublicKey.removeCertification(modified, userId, zert);
- redundantCerts += 1;
- }
- break;
+ } catch (PgpGeneralException e) {
+ log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_ERR,
+ indent, userId);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, zert);
+ badCerts += 1;
+ continue;
+ }
+ switch (type) {
+ case PGPSignature.DEFAULT_CERTIFICATION:
+ case PGPSignature.NO_CERTIFICATION:
+ case PGPSignature.CASUAL_CERTIFICATION:
+ case PGPSignature.POSITIVE_CERTIFICATION:
+ if (selfCert == null) {
+ selfCert = zert;
+ } else if (selfCert.getCreationTime().before(cert.getCreationTime())) {
+ log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_CERT_DUP,
+ indent, userId);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, selfCert);
+ redundantCerts += 1;
+ selfCert = zert;
+ } else {
+ log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_CERT_DUP,
+ indent, userId);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, zert);
+ redundantCerts += 1;
+ }
+ // If there is a revocation certificate, and it's older than this, drop it
+ if (revocation != null
+ && revocation.getCreationTime().before(selfCert.getCreationTime())) {
+ log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_OLD,
+ indent, userId);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, revocation);
+ revocation = null;
+ redundantCerts += 1;
+ }
+ break;
+
+ case PGPSignature.CERTIFICATION_REVOCATION:
+ // If this is older than the (latest) self cert, drop it
+ if (selfCert != null && selfCert.getCreationTime().after(zert.getCreationTime())) {
+ log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_OLD,
+ indent, userId);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, zert);
+ redundantCerts += 1;
+ continue;
+ }
+ // first revocation? remember it.
+ if (revocation == null) {
+ revocation = zert;
+ // more revocations? at least one is superfluous, then.
+ } else if (revocation.getCreationTime().before(cert.getCreationTime())) {
+ log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_DUP,
+ indent, userId);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, revocation);
+ redundantCerts += 1;
+ revocation = zert;
+ } else {
+ log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_DUP,
+ indent, userId);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId, zert);
+ redundantCerts += 1;
+ }
+ break;
+ }
}
-
}
// If no valid certificate (if only a revocation) remains, drop it
if (selfCert == null && revocation == null) {
log.add(LogLevel.ERROR, LogType.MSG_KC_UID_REMOVE,
indent, userId);
- modified = PGPPublicKey.removeCertification(modified, userId);
+ modified = PGPPublicKey.removeCertification(modified, rawUserId);
}
}
// If NO user ids remain, error out!
- if (!modified.getUserIDs().hasNext()) {
+ if (modified == null || !modified.getUserIDs().hasNext()) {
log.add(LogLevel.ERROR, LogType.MSG_KC_ERROR_NO_UID, indent);
return null;
}
@@ -816,8 +820,14 @@ public class UncachedKeyRing {
}
// Copy over all user id certificates
- for (String userId : new IterableIterator<String>(key.getUserIDs())) {
- for (PGPSignature cert : new IterableIterator<PGPSignature>(key.getSignaturesForID(userId))) {
+ for (byte[] rawUserId : new IterableIterator<byte[]>(key.getRawUserIDs())) {
+ @SuppressWarnings("unchecked")
+ Iterator<PGPSignature> signaturesIt = key.getSignaturesForID(rawUserId);
+ // no signatures for this User ID, skip it
+ if (signaturesIt == null) {
+ continue;
+ }
+ for (PGPSignature cert : new IterableIterator<PGPSignature>(signaturesIt)) {
// Don't merge foreign stuff into secret keys
if (cert.getKeyID() != masterKeyId && isSecret()) {
continue;
@@ -829,7 +839,7 @@ public class UncachedKeyRing {
}
newCerts += 1;
certs.add(encoded);
- modified = PGPPublicKey.addCertification(modified, userId, cert);
+ modified = PGPPublicKey.addCertification(modified, rawUserId, cert);
}
}
// If anything changed, save the updated (sub)key
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java
index 2224d7391..e27190bc7 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java
@@ -28,11 +28,13 @@ import org.spongycastle.openpgp.PGPPublicKey;
import org.spongycastle.openpgp.PGPSignature;
import org.spongycastle.openpgp.PGPSignatureSubpacketVector;
import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
+import org.spongycastle.util.Strings;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.util.Log;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -126,12 +128,20 @@ public class UncachedPublicKey {
*
*/
public String getPrimaryUserId() {
- String found = null;
+ byte[] found = null;
PGPSignature foundSig = null;
- for (String userId : new IterableIterator<String>(mPublicKey.getUserIDs())) {
+ // noinspection unchecked
+ for (byte[] rawUserId : new IterableIterator<byte[]>(mPublicKey.getRawUserIDs())) {
PGPSignature revocation = null;
- for (PGPSignature sig : new IterableIterator<PGPSignature>(mPublicKey.getSignaturesForID(userId))) {
+ @SuppressWarnings("unchecked")
+ Iterator<PGPSignature> signaturesIt = mPublicKey.getSignaturesForID(rawUserId);
+ // no signatures for this User ID
+ if (signaturesIt == null) {
+ continue;
+ }
+
+ for (PGPSignature sig : new IterableIterator<PGPSignature>(signaturesIt)) {
try {
// if this is a revocation, this is not the user id
@@ -139,10 +149,10 @@ public class UncachedPublicKey {
// make sure it's actually valid
sig.init(new JcaPGPContentVerifierBuilderProvider().setProvider(
Constants.BOUNCY_CASTLE_PROVIDER_NAME), mPublicKey);
- if (!sig.verifyCertification(userId, mPublicKey)) {
+ if (!sig.verifyCertification(rawUserId, mPublicKey)) {
continue;
}
- if (found != null && found.equals(userId)) {
+ if (found != null && Arrays.equals(found, rawUserId)) {
found = null;
}
revocation = sig;
@@ -161,8 +171,8 @@ public class UncachedPublicKey {
// make sure it's actually valid
sig.init(new JcaPGPContentVerifierBuilderProvider().setProvider(
Constants.BOUNCY_CASTLE_PROVIDER_NAME), mPublicKey);
- if (sig.verifyCertification(userId, mPublicKey)) {
- found = userId;
+ if (sig.verifyCertification(rawUserId, mPublicKey)) {
+ found = rawUserId;
foundSig = sig;
// this one can't be relevant anymore at this point
revocation = null;
@@ -174,7 +184,11 @@ public class UncachedPublicKey {
}
}
}
- return found;
+ if (found != null) {
+ return Strings.fromUTF8ByteArray(found);
+ } else {
+ return null;
+ }
}
/**
@@ -196,6 +210,14 @@ public class UncachedPublicKey {
return userIds;
}
+ public ArrayList<byte[]> getUnorderedRawUserIds() {
+ ArrayList<byte[]> userIds = new ArrayList<byte[]>();
+ for (byte[] userId : new IterableIterator<byte[]>(mPublicKey.getRawUserIDs())) {
+ userIds.add(userId);
+ }
+ return userIds;
+ }
+
public boolean isElGamalEncrypt() {
return getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT;
}
@@ -312,19 +334,23 @@ public class UncachedPublicKey {
};
}
- public Iterator<WrappedSignature> getSignaturesForId(String userId) {
- final Iterator<PGPSignature> it = mPublicKey.getSignaturesForID(userId);
- return new Iterator<WrappedSignature>() {
- public void remove() {
- it.remove();
- }
- public WrappedSignature next() {
- return new WrappedSignature(it.next());
- }
- public boolean hasNext() {
- return it.hasNext();
- }
- };
+ public Iterator<WrappedSignature> getSignaturesForRawId(byte[] rawUserId) {
+ final Iterator<PGPSignature> it = mPublicKey.getSignaturesForID(rawUserId);
+ if (it != null) {
+ return new Iterator<WrappedSignature>() {
+ public void remove() {
+ it.remove();
+ }
+ public WrappedSignature next() {
+ return new WrappedSignature(it.next());
+ }
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+ };
+ } else {
+ return null;
+ }
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSignature.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSignature.java
index f24259ba7..4d4c0e5d1 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSignature.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSignature.java
@@ -187,8 +187,16 @@ public class WrappedSignature {
}
}
- public boolean verifySignature(UncachedPublicKey key, String uid) throws PgpGeneralException {
- return verifySignature(key.getPublicKey(), uid);
+ boolean verifySignature(PGPPublicKey key, byte[] rawUserId) throws PgpGeneralException {
+ try {
+ return mSig.verifyCertification(rawUserId, key);
+ } catch (PGPException e) {
+ throw new PgpGeneralException("Error!", e);
+ }
+ }
+
+ public boolean verifySignature(UncachedPublicKey key, byte[] rawUserId) throws PgpGeneralException {
+ return verifySignature(key.getPublicKey(), rawUserId);
}
public boolean verifySignature(CanonicalizedPublicKey key, String uid) throws PgpGeneralException {
return verifySignature(key.getPublicKey(), uid);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
index 684c08066..fdf8c1f38 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
@@ -28,6 +28,7 @@ import android.net.Uri;
import android.os.RemoteException;
import android.support.v4.util.LongSparseArray;
+import org.spongycastle.util.Strings;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.Preferences;
@@ -54,11 +55,11 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
import org.sufficientlysecure.keychain.remote.AccountSettings;
import org.sufficientlysecure.keychain.remote.AppSettings;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogType;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.OperationLog;
-import org.sufficientlysecure.keychain.service.OperationResults.ConsolidateResult;
-import org.sufficientlysecure.keychain.service.OperationResults.SaveKeyringResult;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
+import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
+import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.util.Log;
@@ -434,8 +435,11 @@ public class ProviderHelper {
}
mIndent += 1;
List<UserIdItem> uids = new ArrayList<UserIdItem>();
- for (String userId : new IterableIterator<String>(
- masterKey.getUnorderedUserIds().iterator())) {
+ for (byte[] rawUserId : new IterableIterator<byte[]>(
+ masterKey.getUnorderedRawUserIds().iterator())) {
+ String userId = Strings.fromUTF8ByteArray(rawUserId);
+ Log.d(Constants.TAG, "userId: "+userId);
+
UserIdItem item = new UserIdItem();
uids.add(item);
item.userId = userId;
@@ -446,7 +450,7 @@ public class ProviderHelper {
mIndent += 1;
// look through signatures for this specific key
for (WrappedSignature cert : new IterableIterator<WrappedSignature>(
- masterKey.getSignaturesForId(userId))) {
+ masterKey.getSignaturesForRawId(rawUserId))) {
long certId = cert.getKeyId();
try {
// self signature
@@ -469,7 +473,7 @@ public class ProviderHelper {
if (trustedKeys.indexOfKey(certId) >= 0) {
CanonicalizedPublicKey trustedKey = trustedKeys.get(certId);
cert.init(trustedKey);
- if (cert.verifySignature(masterKey, userId)) {
+ if (cert.verifySignature(masterKey, rawUserId)) {
item.trustedCerts.add(cert);
log(LogLevel.INFO, LogType.MSG_IP_UID_CERT_GOOD,
PgpKeyHelper.convertKeyIdToHexShort(trustedKey.getKeyId())
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java
index 46a557da3..4bf750121 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java
@@ -30,8 +30,7 @@ import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.remote.AccountSettings;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
-import org.sufficientlysecure.keychain.ui.CertifyKeyActivity;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
import org.sufficientlysecure.keychain.util.Log;
public class AccountSettingsActivity extends ActionBarActivity {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java
index 04c202019..d21d83574 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java
@@ -26,19 +26,15 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
-import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
-import android.widget.Toast;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.KeyRing;
-import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
-import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.remote.AccountSettings;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
-import org.sufficientlysecure.keychain.service.OperationResults;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter;
import org.sufficientlysecure.keychain.ui.widget.KeySpinner;
@@ -176,7 +172,7 @@ public class AccountSettingsFragment extends Fragment {
case REQUEST_CODE_CREATE_KEY: {
if (resultCode == Activity.RESULT_OK) {
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
- OperationResults.SaveKeyringResult result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
+ SaveKeyringResult result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
mSelectKeySpinner.setSelectedKeyId(result.mRingMasterKeyId);
} else {
Log.e(Constants.TAG, "missing result!");
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java
index 885d06857..8cc05231e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java
@@ -32,7 +32,7 @@ import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.remote.AppSettings;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
import org.sufficientlysecure.keychain.util.Log;
public class AppSettingsActivity extends ActionBarActivity {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
index e664570ac..92917fa51 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
@@ -55,13 +55,14 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogType;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.OperationLog;
-import org.sufficientlysecure.keychain.service.OperationResults.ConsolidateResult;
-import org.sufficientlysecure.keychain.service.OperationResults.EditKeyResult;
-import org.sufficientlysecure.keychain.service.OperationResults.ImportKeyResult;
-import org.sufficientlysecure.keychain.service.OperationResults.SaveKeyringResult;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
+import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
+import org.sufficientlysecure.keychain.service.results.EditKeyResult;
+import org.sufficientlysecure.keychain.service.results.ImportKeyResult;
+import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
import org.sufficientlysecure.keychain.util.InputData;
import org.sufficientlysecure.keychain.util.Log;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java
deleted file mode 100644
index ad8fb2f7a..000000000
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
- * Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.sufficientlysecure.keychain.service;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.view.View;
-
-import com.github.johnpersano.supertoasts.SuperCardToast;
-import com.github.johnpersano.supertoasts.SuperToast;
-import com.github.johnpersano.supertoasts.SuperToast.Duration;
-import com.github.johnpersano.supertoasts.util.OnClickWrapper;
-import com.github.johnpersano.supertoasts.util.Style;
-
-import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
-import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
-import org.sufficientlysecure.keychain.ui.LogDisplayActivity;
-import org.sufficientlysecure.keychain.ui.LogDisplayFragment;
-
-public abstract class OperationResults {
-
- /** This is a simple subclass meant to contain only a single log message. This log
- * message is also shown without a log button in the createNotify SuperToast. */
- public static class SingletonResult extends OperationResultParcel {
-
- /** Construct from a parcel - trivial because we have no extra data. */
- public SingletonResult(Parcel source) {
- super(source);
- }
-
- public SingletonResult(int result, LogLevel level, LogType reason) {
- super(result, new OperationLog());
- // Prepare the log
- mLog.add(level, reason, 0);
- }
-
- @Override
- public SuperCardToast createNotify(final Activity activity) {
-
- // there is exactly one error msg - use that one
- String str = activity.getString(mLog.iterator().next().mType.getMsgId());
- int color;
-
- // Determine color by result type
- if (cancelled()) {
- color = Style.RED;
- } else if (success()) {
- if (getLog().containsWarnings()) {
- color = Style.ORANGE;
- } else {
- color = Style.GREEN;
- }
- } else {
- color = Style.RED;
- }
-
- SuperCardToast toast = new SuperCardToast(activity, SuperToast.Type.STANDARD,
- Style.getStyle(color, SuperToast.Animations.POPUP));
- toast.setText(str);
- toast.setDuration(SuperToast.Duration.EXTRA_LONG);
- toast.setIndeterminate(false);
- toast.setSwipeToDismiss(true);
- return toast;
-
- }
-
- public static Creator<SingletonResult> CREATOR = new Creator<SingletonResult>() {
- public SingletonResult createFromParcel(final Parcel source) {
- return new SingletonResult(source);
- }
-
- public SingletonResult[] newArray(final int size) {
- return new SingletonResult[size];
- }
- };
-
- }
-
- public static class ImportKeyResult extends OperationResultParcel {
-
- public final int mNewKeys, mUpdatedKeys, mBadKeys, mSecret;
-
- // At least one new key
- public static final int RESULT_OK_NEWKEYS = 8;
- // At least one updated key
- public static final int RESULT_OK_UPDATED = 16;
- // At least one key failed (might still be an overall success)
- public static final int RESULT_WITH_ERRORS = 32;
-
- // No keys to import...
- public static final int RESULT_FAIL_NOTHING = 64 + 1;
-
- public boolean isOkBoth() {
- return (mResult & (RESULT_OK_NEWKEYS | RESULT_OK_UPDATED))
- == (RESULT_OK_NEWKEYS | RESULT_OK_UPDATED);
- }
-
- public boolean isOkNew() {
- return (mResult & RESULT_OK_NEWKEYS) == RESULT_OK_NEWKEYS;
- }
-
- public boolean isOkUpdated() {
- return (mResult & RESULT_OK_UPDATED) == RESULT_OK_UPDATED;
- }
-
- public boolean isFailNothing() {
- return (mResult & RESULT_FAIL_NOTHING) == RESULT_FAIL_NOTHING;
- }
-
- public ImportKeyResult(Parcel source) {
- super(source);
- mNewKeys = source.readInt();
- mUpdatedKeys = source.readInt();
- mBadKeys = source.readInt();
- mSecret = source.readInt();
- }
-
- public ImportKeyResult(int result, OperationLog log,
- int newKeys, int updatedKeys, int badKeys, int secret) {
- super(result, log);
- mNewKeys = newKeys;
- mUpdatedKeys = updatedKeys;
- mBadKeys = badKeys;
- mSecret = secret;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mNewKeys);
- dest.writeInt(mUpdatedKeys);
- dest.writeInt(mBadKeys);
- dest.writeInt(mSecret);
- }
-
- public static Creator<ImportKeyResult> CREATOR = new Creator<ImportKeyResult>() {
- public ImportKeyResult createFromParcel(final Parcel source) {
- return new ImportKeyResult(source);
- }
-
- public ImportKeyResult[] newArray(final int size) {
- return new ImportKeyResult[size];
- }
- };
-
- public SuperCardToast createNotify(final Activity activity) {
-
- int resultType = getResult();
-
- String str;
- int duration, color;
-
- // Not an overall failure
- if ((resultType & OperationResultParcel.RESULT_ERROR) == 0) {
- String withWarnings;
-
- duration = Duration.EXTRA_LONG;
- color = Style.GREEN;
- withWarnings = "";
-
- // Any warnings?
- if ((resultType & ImportKeyResult.RESULT_WARNINGS) > 0) {
- duration = 0;
- color = Style.ORANGE;
- withWarnings += activity.getString(R.string.import_with_warnings);
- }
- if ((resultType & ImportKeyResult.RESULT_CANCELLED) > 0) {
- duration = 0;
- color = Style.ORANGE;
- withWarnings += activity.getString(R.string.import_with_cancelled);
- }
-
- // New and updated keys
- if (this.isOkBoth()) {
- str = activity.getResources().getQuantityString(
- R.plurals.import_keys_added_and_updated_1, mNewKeys, mNewKeys);
- str += " " + activity.getResources().getQuantityString(
- R.plurals.import_keys_added_and_updated_2, mUpdatedKeys, mUpdatedKeys, withWarnings);
- } else if (isOkUpdated()) {
- str = activity.getResources().getQuantityString(
- R.plurals.import_keys_updated, mUpdatedKeys, mUpdatedKeys, withWarnings);
- } else if (isOkNew()) {
- str = activity.getResources().getQuantityString(
- R.plurals.import_keys_added, mNewKeys, mNewKeys, withWarnings);
- } else {
- duration = 0;
- color = Style.RED;
- str = "internal error";
- }
-
- } else {
- duration = 0;
- color = Style.RED;
- if (isFailNothing()) {
- str = activity.getString((resultType & ImportKeyResult.RESULT_CANCELLED) > 0
- ? R.string.import_error_nothing_cancelled
- : R.string.import_error_nothing);
- } else {
- str = activity.getString(R.string.import_error);
- }
- }
-
- boolean button = getLog() != null && !getLog().isEmpty();
- SuperCardToast toast = new SuperCardToast(activity,
- button ? SuperToast.Type.BUTTON : SuperToast.Type.STANDARD,
- Style.getStyle(color, SuperToast.Animations.POPUP));
- toast.setText(str);
- toast.setDuration(duration);
- toast.setIndeterminate(duration == 0);
- toast.setSwipeToDismiss(true);
- // If we have a log and it's non-empty, show a View Log button
- if (button) {
- toast.setButtonIcon(R.drawable.ic_action_view_as_list,
- activity.getResources().getString(R.string.view_log));
- toast.setButtonTextColor(activity.getResources().getColor(R.color.black));
- toast.setTextColor(activity.getResources().getColor(R.color.black));
- toast.setOnClickWrapper(new OnClickWrapper("supercardtoast",
- new SuperToast.OnClickListener() {
- @Override
- public void onClick(View view, Parcelable token) {
- Intent intent = new Intent(
- activity, LogDisplayActivity.class);
- intent.putExtra(LogDisplayFragment.EXTRA_RESULT, ImportKeyResult.this);
- activity.startActivity(intent);
- }
- }
- ));
- }
-
- return toast;
-
- }
-
- }
-
- public static class EditKeyResult extends OperationResultParcel {
-
- private transient UncachedKeyRing mRing;
- public final long mRingMasterKeyId;
-
- public EditKeyResult(int result, OperationLog log,
- UncachedKeyRing ring) {
- super(result, log);
- mRing = ring;
- mRingMasterKeyId = ring != null ? ring.getMasterKeyId() : Constants.key.none;
- }
-
- public UncachedKeyRing getRing() {
- return mRing;
- }
-
- public EditKeyResult(Parcel source) {
- super(source);
- mRingMasterKeyId = source.readLong();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeLong(mRingMasterKeyId);
- }
-
- public static Creator<EditKeyResult> CREATOR = new Creator<EditKeyResult>() {
- public EditKeyResult createFromParcel(final Parcel source) {
- return new EditKeyResult(source);
- }
-
- public EditKeyResult[] newArray(final int size) {
- return new EditKeyResult[size];
- }
- };
-
- }
-
-
- public static class SaveKeyringResult extends OperationResultParcel {
-
- public final long mRingMasterKeyId;
-
- public SaveKeyringResult(int result, OperationLog log,
- CanonicalizedKeyRing ring) {
- super(result, log);
- mRingMasterKeyId = ring != null ? ring.getMasterKeyId() : Constants.key.none;
- }
-
- // Some old key was updated
- public static final int UPDATED = 4;
-
- // Public key was saved
- public static final int SAVED_PUBLIC = 8;
- // Secret key was saved (not exclusive with public!)
- public static final int SAVED_SECRET = 16;
-
- public boolean updated() {
- return (mResult & UPDATED) == UPDATED;
- }
-
- public SaveKeyringResult(Parcel source) {
- super(source);
- mRingMasterKeyId = source.readLong();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeLong(mRingMasterKeyId);
- }
-
- public static Creator<SaveKeyringResult> CREATOR = new Creator<SaveKeyringResult>() {
- public SaveKeyringResult createFromParcel(final Parcel source) {
- return new SaveKeyringResult(source);
- }
-
- public SaveKeyringResult[] newArray(final int size) {
- return new SaveKeyringResult[size];
- }
- };
- }
-
- public static class ConsolidateResult extends OperationResultParcel {
-
- public ConsolidateResult(int result, OperationLog log) {
- super(result, log);
- }
-
- }
-
-}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ConsolidateResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ConsolidateResult.java
new file mode 100644
index 000000000..31f4cabc3
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ConsolidateResult.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.sufficientlysecure.keychain.service.results;
+
+public class ConsolidateResult extends OperationResultParcel {
+
+ public ConsolidateResult(int result, OperationLog log) {
+ super(result, log);
+ }
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/EditKeyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/EditKeyResult.java
new file mode 100644
index 000000000..169ed9f36
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/EditKeyResult.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.sufficientlysecure.keychain.service.results;
+
+import android.os.Parcel;
+
+import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
+
+public class EditKeyResult extends OperationResultParcel {
+
+ private transient UncachedKeyRing mRing;
+ public final long mRingMasterKeyId;
+
+ public EditKeyResult(int result, OperationLog log,
+ UncachedKeyRing ring) {
+ super(result, log);
+ mRing = ring;
+ mRingMasterKeyId = ring != null ? ring.getMasterKeyId() : Constants.key.none;
+ }
+
+ public UncachedKeyRing getRing() {
+ return mRing;
+ }
+
+ public EditKeyResult(Parcel source) {
+ super(source);
+ mRingMasterKeyId = source.readLong();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeLong(mRingMasterKeyId);
+ }
+
+ public static Creator<EditKeyResult> CREATOR = new Creator<EditKeyResult>() {
+ public EditKeyResult createFromParcel(final Parcel source) {
+ return new EditKeyResult(source);
+ }
+
+ public EditKeyResult[] newArray(final int size) {
+ return new EditKeyResult[size];
+ }
+ };
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java
new file mode 100644
index 000000000..62b5b1b52
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.sufficientlysecure.keychain.service.results;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.view.View;
+
+import com.github.johnpersano.supertoasts.SuperCardToast;
+import com.github.johnpersano.supertoasts.SuperToast;
+import com.github.johnpersano.supertoasts.SuperToast.Duration;
+import com.github.johnpersano.supertoasts.util.OnClickWrapper;
+import com.github.johnpersano.supertoasts.util.Style;
+
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.ui.LogDisplayActivity;
+import org.sufficientlysecure.keychain.ui.LogDisplayFragment;
+
+public class ImportKeyResult extends OperationResultParcel {
+
+ public final int mNewKeys, mUpdatedKeys, mBadKeys, mSecret;
+
+ // At least one new key
+ public static final int RESULT_OK_NEWKEYS = 8;
+ // At least one updated key
+ public static final int RESULT_OK_UPDATED = 16;
+ // At least one key failed (might still be an overall success)
+ public static final int RESULT_WITH_ERRORS = 32;
+
+ // No keys to import...
+ public static final int RESULT_FAIL_NOTHING = 64 + 1;
+
+ public boolean isOkBoth() {
+ return (mResult & (RESULT_OK_NEWKEYS | RESULT_OK_UPDATED))
+ == (RESULT_OK_NEWKEYS | RESULT_OK_UPDATED);
+ }
+
+ public boolean isOkNew() {
+ return (mResult & RESULT_OK_NEWKEYS) == RESULT_OK_NEWKEYS;
+ }
+
+ public boolean isOkUpdated() {
+ return (mResult & RESULT_OK_UPDATED) == RESULT_OK_UPDATED;
+ }
+
+ public boolean isFailNothing() {
+ return (mResult & RESULT_FAIL_NOTHING) == RESULT_FAIL_NOTHING;
+ }
+
+ public ImportKeyResult(Parcel source) {
+ super(source);
+ mNewKeys = source.readInt();
+ mUpdatedKeys = source.readInt();
+ mBadKeys = source.readInt();
+ mSecret = source.readInt();
+ }
+
+ public ImportKeyResult(int result, OperationLog log,
+ int newKeys, int updatedKeys, int badKeys, int secret) {
+ super(result, log);
+ mNewKeys = newKeys;
+ mUpdatedKeys = updatedKeys;
+ mBadKeys = badKeys;
+ mSecret = secret;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeInt(mNewKeys);
+ dest.writeInt(mUpdatedKeys);
+ dest.writeInt(mBadKeys);
+ dest.writeInt(mSecret);
+ }
+
+ public static Creator<ImportKeyResult> CREATOR = new Creator<ImportKeyResult>() {
+ public ImportKeyResult createFromParcel(final Parcel source) {
+ return new ImportKeyResult(source);
+ }
+
+ public ImportKeyResult[] newArray(final int size) {
+ return new ImportKeyResult[size];
+ }
+ };
+
+ public SuperCardToast createNotify(final Activity activity) {
+
+ int resultType = getResult();
+
+ String str;
+ int duration, color;
+
+ // Not an overall failure
+ if ((resultType & OperationResultParcel.RESULT_ERROR) == 0) {
+ String withWarnings;
+
+ duration = Duration.EXTRA_LONG;
+ color = Style.GREEN;
+ withWarnings = "";
+
+ // Any warnings?
+ if ((resultType & ImportKeyResult.RESULT_WARNINGS) > 0) {
+ duration = 0;
+ color = Style.ORANGE;
+ withWarnings += activity.getString(R.string.import_with_warnings);
+ }
+ if ((resultType & ImportKeyResult.RESULT_CANCELLED) > 0) {
+ duration = 0;
+ color = Style.ORANGE;
+ withWarnings += activity.getString(R.string.import_with_cancelled);
+ }
+
+ // New and updated keys
+ if (this.isOkBoth()) {
+ str = activity.getResources().getQuantityString(
+ R.plurals.import_keys_added_and_updated_1, mNewKeys, mNewKeys);
+ str += " " + activity.getResources().getQuantityString(
+ R.plurals.import_keys_added_and_updated_2, mUpdatedKeys, mUpdatedKeys, withWarnings);
+ } else if (isOkUpdated()) {
+ str = activity.getResources().getQuantityString(
+ R.plurals.import_keys_updated, mUpdatedKeys, mUpdatedKeys, withWarnings);
+ } else if (isOkNew()) {
+ str = activity.getResources().getQuantityString(
+ R.plurals.import_keys_added, mNewKeys, mNewKeys, withWarnings);
+ } else {
+ duration = 0;
+ color = Style.RED;
+ str = "internal error";
+ }
+
+ } else {
+ duration = 0;
+ color = Style.RED;
+ if (isFailNothing()) {
+ str = activity.getString((resultType & ImportKeyResult.RESULT_CANCELLED) > 0
+ ? R.string.import_error_nothing_cancelled
+ : R.string.import_error_nothing);
+ } else {
+ str = activity.getString(R.string.import_error);
+ }
+ }
+
+ boolean button = getLog() != null && !getLog().isEmpty();
+ SuperCardToast toast = new SuperCardToast(activity,
+ button ? SuperToast.Type.BUTTON : SuperToast.Type.STANDARD,
+ Style.getStyle(color, SuperToast.Animations.POPUP));
+ toast.setText(str);
+ toast.setDuration(duration);
+ toast.setIndeterminate(duration == 0);
+ toast.setSwipeToDismiss(true);
+ // If we have a log and it's non-empty, show a View Log button
+ if (button) {
+ toast.setButtonIcon(R.drawable.ic_action_view_as_list,
+ activity.getResources().getString(R.string.view_log));
+ toast.setButtonTextColor(activity.getResources().getColor(R.color.black));
+ toast.setTextColor(activity.getResources().getColor(R.color.black));
+ toast.setOnClickWrapper(new OnClickWrapper("supercardtoast",
+ new SuperToast.OnClickListener() {
+ @Override
+ public void onClick(View view, Parcelable token) {
+ Intent intent = new Intent(
+ activity, LogDisplayActivity.class);
+ intent.putExtra(LogDisplayFragment.EXTRA_RESULT, ImportKeyResult.this);
+ activity.startActivity(intent);
+ }
+ }
+ ));
+ }
+
+ return toast;
+
+ }
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResultParcel.java
index 02caca145..580072957 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResultParcel.java
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package org.sufficientlysecure.keychain.service;
+package org.sufficientlysecure.keychain.service.results;
import android.app.Activity;
import android.content.Intent;
@@ -49,6 +49,7 @@ import java.util.List;
* list (ie, enum) of all possible log types, which should in all cases be tied
* to string resource ids.
*
+ * TODO ideally, this class should be abstract, and all actual results of a specific subclass
*
*/
public class OperationResultParcel implements Parcelable {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SaveKeyringResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SaveKeyringResult.java
new file mode 100644
index 000000000..0edb9c617
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SaveKeyringResult.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.sufficientlysecure.keychain.service.results;
+
+import android.os.Parcel;
+
+import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
+
+public class SaveKeyringResult extends OperationResultParcel {
+
+ public final long mRingMasterKeyId;
+
+ public SaveKeyringResult(int result, OperationLog log,
+ CanonicalizedKeyRing ring) {
+ super(result, log);
+ mRingMasterKeyId = ring != null ? ring.getMasterKeyId() : Constants.key.none;
+ }
+
+ // Some old key was updated
+ public static final int UPDATED = 4;
+
+ // Public key was saved
+ public static final int SAVED_PUBLIC = 8;
+ // Secret key was saved (not exclusive with public!)
+ public static final int SAVED_SECRET = 16;
+
+ public boolean updated() {
+ return (mResult & UPDATED) == UPDATED;
+ }
+
+ public SaveKeyringResult(Parcel source) {
+ super(source);
+ mRingMasterKeyId = source.readLong();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeLong(mRingMasterKeyId);
+ }
+
+ public static Creator<SaveKeyringResult> CREATOR = new Creator<SaveKeyringResult>() {
+ public SaveKeyringResult createFromParcel(final Parcel source) {
+ return new SaveKeyringResult(source);
+ }
+
+ public SaveKeyringResult[] newArray(final int size) {
+ return new SaveKeyringResult[size];
+ }
+ };
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SingletonResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SingletonResult.java
new file mode 100644
index 000000000..5022c46a7
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SingletonResult.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.sufficientlysecure.keychain.service.results;
+
+import android.app.Activity;
+import android.os.Parcel;
+
+import com.github.johnpersano.supertoasts.SuperCardToast;
+import com.github.johnpersano.supertoasts.SuperToast;
+import com.github.johnpersano.supertoasts.util.Style;
+
+/** This is a simple subclass meant to contain only a single log message. This log
+ * message is also shown without a log button in the createNotify SuperToast. */
+public class SingletonResult extends OperationResultParcel {
+
+ /** Construct from a parcel - trivial because we have no extra data. */
+ public SingletonResult(Parcel source) {
+ super(source);
+ }
+
+ public SingletonResult(int result, LogLevel level, LogType reason) {
+ super(result, new OperationLog());
+ // Prepare the log
+ mLog.add(level, reason, 0);
+ }
+
+ @Override
+ public SuperCardToast createNotify(final Activity activity) {
+
+ // there is exactly one error msg - use that one
+ String str = activity.getString(mLog.iterator().next().mType.getMsgId());
+ int color;
+
+ // Determine color by result type
+ if (cancelled()) {
+ color = Style.RED;
+ } else if (success()) {
+ if (getLog().containsWarnings()) {
+ color = Style.ORANGE;
+ } else {
+ color = Style.GREEN;
+ }
+ } else {
+ color = Style.RED;
+ }
+
+ SuperCardToast toast = new SuperCardToast(activity, SuperToast.Type.STANDARD,
+ Style.getStyle(color, SuperToast.Animations.POPUP));
+ toast.setText(str);
+ toast.setDuration(SuperToast.Duration.EXTRA_LONG);
+ toast.setIndeterminate(false);
+ toast.setSwipeToDismiss(true);
+ return toast;
+
+ }
+
+ public static Creator<SingletonResult> CREATOR = new Creator<SingletonResult>() {
+ public SingletonResult createFromParcel(final Parcel source) {
+ return new SingletonResult(source);
+ }
+
+ public SingletonResult[] newArray(final int size) {
+ return new SingletonResult[size];
+ }
+ };
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java
index d921f3cc0..fb2184362 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java
@@ -54,7 +54,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java
index ec4f2e337..a645f18a9 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java
@@ -39,10 +39,10 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
-import org.sufficientlysecure.keychain.service.OperationResults;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
+import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
import org.sufficientlysecure.keychain.util.Log;
public class CreateKeyFinalFragment extends Fragment {
@@ -140,7 +140,7 @@ public class CreateKeyFinalFragment extends Fragment {
if (returnData == null) {
return;
}
- final OperationResults.SaveKeyringResult result =
+ final SaveKeyringResult result =
returnData.getParcelable(OperationResultParcel.EXTRA_RESULT);
if (result == null) {
Log.e(Constants.TAG, "result == null");
@@ -189,7 +189,7 @@ public class CreateKeyFinalFragment extends Fragment {
getActivity().startService(intent);
}
- private void uploadKey(final OperationResults.SaveKeyringResult saveKeyResult) {
+ private void uploadKey(final SaveKeyringResult saveKeyResult) {
// Send all information needed to service to upload key in other thread
final Intent intent = new Intent(getActivity(), KeychainIntentService.class);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java
index 8feef5e46..8bde3f295 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java
@@ -48,10 +48,10 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogType;
-import org.sufficientlysecure.keychain.service.OperationResults.SingletonResult;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
+import org.sufficientlysecure.keychain.service.results.SingletonResult;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
index 3e949cfae..732e59e32 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
@@ -46,8 +46,8 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
-import org.sufficientlysecure.keychain.service.OperationResults.ImportKeyResult;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.ImportKeyResult;
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
index 65c4b8605..1b3bb06c3 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
@@ -34,8 +34,8 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
-import org.sufficientlysecure.keychain.service.OperationResults.ConsolidateResult;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Notify;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java
index 1202de1b7..ddc57b8aa 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java
@@ -37,9 +37,9 @@ import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogEntryParcel;
-import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogEntryParcel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
import org.sufficientlysecure.keychain.util.Log;
import java.util.HashMap;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
index 5d8e13349..ef0b95bcc 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
@@ -56,7 +56,7 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
-import org.sufficientlysecure.keychain.service.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout.TabColorizer;