extract DatabaseReadWriteInteractor
This commit is contained in:
@@ -51,9 +51,9 @@ import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
|
||||
import org.sufficientlysecure.keychain.service.BackupKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
@@ -32,9 +35,7 @@ import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public abstract class BaseOperation <T extends Parcelable> implements PassphraseCacheInterface {
|
||||
public abstract class BaseOperation<T extends Parcelable> implements PassphraseCacheInterface {
|
||||
|
||||
final public Context mContext;
|
||||
final public Progressable mProgressable;
|
||||
@@ -72,7 +73,7 @@ public abstract class BaseOperation <T extends Parcelable> implements Passphrase
|
||||
}
|
||||
|
||||
public BaseOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
mContext = context;
|
||||
mProgressable = progressable;
|
||||
mDatabaseInteractor = databaseInteractor;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
|
||||
|
||||
abstract class BaseReadWriteOperation<T extends Parcelable> extends BaseOperation<T> {
|
||||
final DatabaseReadWriteInteractor mDatabaseReadWriteInteractor;
|
||||
|
||||
BaseReadWriteOperation(Context context,
|
||||
DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
|
||||
mDatabaseReadWriteInteractor = databaseInteractor;
|
||||
}
|
||||
|
||||
BaseReadWriteOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
|
||||
mDatabaseReadWriteInteractor = databaseInteractor;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants.OpenKeychainSymm
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptData;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.BenchmarkInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@@ -55,7 +55,7 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
|
||||
public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> {
|
||||
|
||||
public BenchmarkOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
|
||||
public BenchmarkOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable
|
||||
progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
@@ -60,9 +60,9 @@ import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
*
|
||||
* @see CertifyActionsParcel
|
||||
*/
|
||||
public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
|
||||
public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParcel> {
|
||||
|
||||
public CertifyOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable, AtomicBoolean
|
||||
public CertifyOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable, AtomicBoolean
|
||||
cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
|
||||
KeyFormattingUtils.convertKeyIdToHex(certifiedKey.getMasterKeyId()));
|
||||
// store the signed key in our local cache
|
||||
mDatabaseInteractor.clearLog();
|
||||
SaveKeyringResult result = mDatabaseInteractor.savePublicKeyRing(certifiedKey);
|
||||
SaveKeyringResult result = mDatabaseReadWriteInteractor.savePublicKeyRing(certifiedKey);
|
||||
|
||||
if (uploadOperation != null) {
|
||||
UploadKeyringParcel uploadInput =
|
||||
|
||||
@@ -29,16 +29,16 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
|
||||
|
||||
public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
|
||||
public class ChangeUnlockOperation extends BaseReadWriteOperation<ChangeUnlockParcel> {
|
||||
|
||||
public ChangeUnlockOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
|
||||
public ChangeUnlockOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
|
||||
log.add(modifyResult, 1);
|
||||
return new EditKeyResult(log, modifyResult);
|
||||
}
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
log.add(OperationResult.LogType.MSG_ED_ERROR_KEY_NOT_FOUND, 2);
|
||||
return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
|
||||
// It's a success, so this must be non-null now
|
||||
UncachedKeyRing ring = modifyResult.getRing();
|
||||
|
||||
SaveKeyringResult saveResult = mDatabaseInteractor
|
||||
SaveKeyringResult saveResult = mDatabaseReadWriteInteractor
|
||||
.saveSecretKeyRing(ring, new ProgressScaler(mProgressable, 70, 95, 100));
|
||||
log.add(saveResult, 1);
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ import android.support.annotation.NonNull;
|
||||
|
||||
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ConsolidateInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
|
||||
public class ConsolidateOperation extends BaseOperation<ConsolidateInputParcel> {
|
||||
public class ConsolidateOperation extends BaseReadWriteOperation<ConsolidateInputParcel> {
|
||||
|
||||
public ConsolidateOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
|
||||
public ConsolidateOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable
|
||||
progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
@@ -40,9 +40,9 @@ public class ConsolidateOperation extends BaseOperation<ConsolidateInputParcel>
|
||||
public ConsolidateResult execute(ConsolidateInputParcel consolidateInputParcel,
|
||||
CryptoInputParcel cryptoInputParcel) {
|
||||
if (consolidateInputParcel.mConsolidateRecovery) {
|
||||
return mDatabaseInteractor.consolidateDatabaseStep2(mProgressable);
|
||||
return mDatabaseReadWriteInteractor.consolidateDatabaseStep2(mProgressable);
|
||||
} else {
|
||||
return mDatabaseInteractor.consolidateDatabaseStep1(mProgressable);
|
||||
return mDatabaseReadWriteInteractor.consolidateDatabaseStep1(mProgressable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.service.DeleteKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -41,9 +41,9 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
* a list.
|
||||
*
|
||||
*/
|
||||
public class DeleteOperation extends BaseOperation<DeleteKeyringParcel> {
|
||||
public class DeleteOperation extends BaseReadWriteOperation<DeleteKeyringParcel> {
|
||||
|
||||
public DeleteOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
|
||||
public DeleteOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DeleteOperation extends BaseOperation<DeleteKeyringParcel> {
|
||||
|
||||
if (isSecret && success > 0) {
|
||||
log.add(LogType.MSG_DEL_CONSOLIDATE, 1);
|
||||
ConsolidateResult sub = mDatabaseInteractor.consolidateDatabaseStep1(mProgressable);
|
||||
ConsolidateResult sub = mDatabaseReadWriteInteractor.consolidateDatabaseStep1(mProgressable);
|
||||
log.add(sub, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
||||
@@ -55,9 +55,9 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
* @see SaveKeyringParcel
|
||||
*
|
||||
*/
|
||||
public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
|
||||
public class EditKeyOperation extends BaseReadWriteOperation<SaveKeyringParcel> {
|
||||
|
||||
public EditKeyOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
public EditKeyOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
|
||||
}
|
||||
|
||||
// Save the new keyring.
|
||||
SaveKeyringResult saveResult = mDatabaseInteractor
|
||||
SaveKeyringResult saveResult = mDatabaseReadWriteInteractor
|
||||
.saveSecretKeyRing(ring, new ProgressScaler(mProgressable, 60, 95, 100));
|
||||
log.add(saveResult, 1);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -80,18 +80,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* method here will generally import keyrings in the order given by the
|
||||
* iterator, so this should be ensured beforehand.
|
||||
*/
|
||||
public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
public class ImportOperation extends BaseReadWriteOperation<ImportKeyringParcel> {
|
||||
|
||||
private static final int MAX_THREADS = 10;
|
||||
|
||||
public static final String CACHE_FILE_NAME = "key_import.pcl";
|
||||
|
||||
public ImportOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
|
||||
public ImportOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable
|
||||
progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
public ImportOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
public ImportOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
@@ -319,10 +319,10 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
ProgressScaler progressScaler = new ProgressScaler(progressable, (int) (position * progSteps),
|
||||
(int) ((position + 1) * progSteps), 100);
|
||||
if (key.isSecret()) {
|
||||
result = mDatabaseInteractor.saveSecretKeyRing(key, progressScaler,
|
||||
result = mDatabaseReadWriteInteractor.saveSecretKeyRing(key, progressScaler,
|
||||
canKeyRings, skipSave);
|
||||
} else {
|
||||
result = mDatabaseInteractor.savePublicKeyRing(key, progressScaler,
|
||||
result = mDatabaseReadWriteInteractor.savePublicKeyRing(key, progressScaler,
|
||||
entry.mExpectedFingerprint, canKeyRings, skipSave);
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
// synonymous to isDownloadFromKeyserver.
|
||||
// If no byte data was supplied, import from keyserver took place
|
||||
// this prevents file imports being noted as keyserver imports
|
||||
mDatabaseInteractor.renewKeyLastUpdatedTime(key.getMasterKeyId(),
|
||||
mDatabaseReadWriteInteractor.renewKeyLastUpdatedTime(key.getMasterKeyId(),
|
||||
GregorianCalendar.getInstance().getTimeInMillis(),
|
||||
TimeUnit.MILLISECONDS);
|
||||
}
|
||||
@@ -366,7 +366,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
setPreventCancel();
|
||||
ConsolidateResult result;
|
||||
synchronized (mDatabaseInteractor) {
|
||||
result = mDatabaseInteractor.consolidateDatabaseStep1(progressable);
|
||||
result = mDatabaseReadWriteInteractor.consolidateDatabaseStep1(progressable);
|
||||
}
|
||||
log.add(result, 1);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.KeybaseVerificationParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
@@ -59,7 +59,7 @@ import de.measite.minidns.record.TXT;
|
||||
|
||||
public class KeybaseVerificationOperation extends BaseOperation<KeybaseVerificationParcel> {
|
||||
|
||||
public KeybaseVerificationOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
public KeybaseVerificationOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKey;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.PromoteKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -47,9 +47,8 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
* without secret key material, using a GNU_DUMMY s2k type.
|
||||
*
|
||||
*/
|
||||
public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
|
||||
|
||||
public PromoteKeyOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
public class PromoteKeyOperation extends BaseReadWriteOperation<PromoteKeyringParcel> {
|
||||
public PromoteKeyOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
@@ -114,7 +113,7 @@ public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
|
||||
setPreventCancel();
|
||||
|
||||
// Save the new keyring.
|
||||
SaveKeyringResult saveResult = mDatabaseInteractor
|
||||
SaveKeyringResult saveResult = mDatabaseReadWriteInteractor
|
||||
.saveSecretKeyRing(promotedRing, new ProgressScaler(mProgressable, 60, 95, 100));
|
||||
log.add(saveResult, 1);
|
||||
|
||||
|
||||
@@ -31,17 +31,17 @@ import org.sufficientlysecure.keychain.operations.results.RevokeResult;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.RevokeKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
|
||||
public class RevokeOperation extends BaseReadWriteOperation<RevokeKeyringParcel> {
|
||||
|
||||
public RevokeOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
|
||||
public RevokeOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
|
||||
saveKeyringParcel.mRevokeSubKeys.add(masterKeyId);
|
||||
|
||||
EditKeyResult revokeAndUploadResult = new EditKeyOperation(mContext,
|
||||
mDatabaseInteractor, mProgressable, mCancelled).execute(saveKeyringParcel, cryptoInputParcel);
|
||||
mDatabaseReadWriteInteractor, mProgressable, mCancelled).execute(saveKeyringParcel, cryptoInputParcel);
|
||||
|
||||
if (revokeAndUploadResult.isPending()) {
|
||||
return revokeAndUploadResult;
|
||||
@@ -97,7 +97,7 @@ public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
|
||||
return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId);
|
||||
}
|
||||
|
||||
} catch (PgpKeyNotFoundException | DatabaseInteractor.NotFoundException e) {
|
||||
} catch (PgpKeyNotFoundException | DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "could not find key to revoke", e);
|
||||
log.add(OperationResult.LogType.MSG_REVOKE_ERROR_KEY_FAIL, 1);
|
||||
return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId);
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
@@ -36,15 +40,11 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.SecurityTokenSignOperationsBuilder;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.RequiredInputType;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.SecurityTokenSignOperationsBuilder;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
||||
/**
|
||||
* This is a high-level operation, which encapsulates one or more sign/encrypt
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
@@ -59,7 +60,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
|
||||
|
||||
public UploadOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
|
||||
log.add(LogType.MSG_UPLOAD_KEY, 0, KeyFormattingUtils.convertKeyIdToHex(canonicalizedRing.getMasterKeyId()));
|
||||
return (CanonicalizedPublicKeyRing) canonicalizedRing;
|
||||
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
log.add(LogType.MSG_UPLOAD_ERROR_NOT_FOUND, 1);
|
||||
return null;
|
||||
} catch (IOException | PgpGeneralException e) {
|
||||
|
||||
Reference in New Issue
Block a user