Merge branch 'development' of github.com:open-keychain/open-keychain into development

This commit is contained in:
Dominik Schürmann 2014-10-26 22:38:35 +01:00
commit be31815ee8
8 changed files with 31 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
import org.sufficientlysecure.keychain.keyimport.Keyserver.AddKeyException;
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
@ -57,6 +58,10 @@ public class CertifyOperation extends BaseOperation {
mProviderHelper.getCanonicalizedSecretKeyRing(parcel.mMasterKeyId);
log.add(LogType.MSG_CRT_UNLOCK, 1);
certificationKey = secretKeyRing.getSecretKey();
if (certificationKey.getSecretKeyType() == SecretKeyType.DIVERT_TO_CARD) {
log.add(LogType.MSG_CRT_ERROR_DIVERT, 2);
return new CertifyResult(CertifyResult.RESULT_ERROR, log);
}
if (!certificationKey.unlock(passphrase)) {
log.add(LogType.MSG_CRT_ERROR_UNLOCK, 2);
return new CertifyResult(CertifyResult.RESULT_ERROR, log);

View File

@ -575,6 +575,7 @@ public abstract class OperationResult implements Parcelable {
MSG_CRT_ERROR_MASTER_NOT_FOUND (LogLevel.ERROR, R.string.msg_crt_error_master_not_found),
MSG_CRT_ERROR_NOTHING (LogLevel.ERROR, R.string.msg_crt_error_nothing),
MSG_CRT_ERROR_UNLOCK (LogLevel.ERROR, R.string.msg_crt_error_unlock),
MSG_CRT_ERROR_DIVERT (LogLevel.ERROR, R.string.msg_crt_error_divert),
MSG_CRT (LogLevel.START, R.string.msg_crt),
MSG_CRT_MASTER_FETCH (LogLevel.DEBUG, R.string.msg_crt_master_fetch),
MSG_CRT_SAVE (LogLevel.DEBUG, R.string.msg_crt_save),

View File

@ -23,4 +23,6 @@ public interface Progressable {
void setProgress(int resourceId, int current, int total);
void setProgress(int current, int total);
void setPreventCancel();
}

View File

@ -938,6 +938,9 @@ public class ProviderHelper {
progress.setProgress(R.string.progress_con_saving, 0, 100);
// The consolidate operation can never be cancelled!
progress.setPreventCancel();
try {
log.add(LogType.MSG_CON_SAVE_SECRET, indent);
@ -947,11 +950,13 @@ public class ProviderHelper {
KeyRings.PRIVKEY_DATA, KeyRings.FINGERPRINT, KeyRings.HAS_ANY_SECRET
}, KeyRings.HAS_ANY_SECRET + " = 1", null, null);
if (cursor == null || !cursor.moveToFirst()) {
if (cursor == null) {
log.add(LogType.MSG_CON_ERROR_DB, indent);
return new ConsolidateResult(ConsolidateResult.RESULT_ERROR, log);
}
// No keys existing might be a legitimate option, we write an empty file in that case
cursor.moveToFirst();
ParcelableFileCache<ParcelableKeyRing> cache =
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_secret.pcl");
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {
@ -1007,11 +1012,13 @@ public class ProviderHelper {
KeyRings.PUBKEY_DATA, KeyRings.FINGERPRINT
}, null, null, null);
if (cursor == null || !cursor.moveToFirst()) {
if (cursor == null) {
log.add(LogType.MSG_CON_ERROR_DB, indent);
return new ConsolidateResult(ConsolidateResult.RESULT_ERROR, log);
}
// No keys existing might be a legitimate option, we write an empty file in that case
cursor.moveToFirst();
ParcelableFileCache<ParcelableKeyRing> cache =
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_public.pcl");
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {

View File

@ -472,8 +472,7 @@ public class KeychainIntentService extends IntentService implements Progressable
// Special: consolidate on secret key import (cannot be cancelled!)
if (result.mSecret > 0) {
// cannot cancel from here on out!
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_PREVENT_CANCEL);
// TODO move this into the import operation
providerHelper.consolidateDatabaseStep1(this);
}
@ -676,6 +675,11 @@ public class KeychainIntentService extends IntentService implements Progressable
setProgress(null, progress, max);
}
@Override
public void setPreventCancel() {
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_PREVENT_CANCEL);
}
private InputData createDecryptInputData(Bundle data) throws IOException, PgpGeneralException {
return createCryptInputData(data, DECRYPT_CIPHERTEXT_BYTES);
}

View File

@ -145,7 +145,7 @@ public class ProgressDialogFragment extends DialogFragment {
mPreventCancel = preventCancel;
final Button negative = ((ProgressDialog) getDialog()).getButton(DialogInterface.BUTTON_NEGATIVE);
negative.setVisibility(preventCancel ? View.GONE : View.VISIBLE);
negative.setEnabled(mIsCancelled && !preventCancel);
}
@Override

View File

@ -60,4 +60,10 @@ public class ProgressScaler implements Progressable {
}
}
@Override
public void setPreventCancel() {
if (mWrapped != null) {
mWrapped.setPreventCancel();
}
}
}

View File

@ -928,6 +928,7 @@
<string name="msg_crt_error_master_not_found">"Master key not found!"</string>
<string name="msg_crt_error_nothing">"No keys certified!"</string>
<string name="msg_crt_error_unlock">"Error unlocking master key!"</string>
<string name="msg_crt_error_divert">"Certification with NFC is not (yet) supported!"</string>
<string name="msg_crt">"Certifying keyrings"</string>
<string name="msg_crt_master_fetch">"Fetching certifying master key"</string>
<string name="msg_crt_save">"Saving certified key %s"</string>