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

This commit is contained in:
Vincent Breitmoser 2014-10-05 02:25:36 +02:00
commit 84c624517c
4 changed files with 67 additions and 60 deletions

View File

@ -73,7 +73,10 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
}
dest.writeString(mFingerprintHex);
dest.writeString(mKeyIdHex);
dest.writeInt(mBitStrength);
dest.writeInt(mBitStrength == null ? 0 : 1);
if (mBitStrength != null) {
dest.writeInt(mBitStrength);
}
dest.writeString(mAlgorithm);
dest.writeByte((byte) (mSecretKey ? 1 : 0));
dest.writeByte((byte) (mSelected ? 1 : 0));
@ -94,7 +97,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
vr.mDate = source.readInt() != 0 ? new Date(source.readLong()) : null;
vr.mFingerprintHex = source.readString();
vr.mKeyIdHex = source.readString();
vr.mBitStrength = source.readInt();
vr.mBitStrength = source.readInt() != 0 ? source.readInt() : null;
vr.mAlgorithm = source.readString();
vr.mSecretKey = source.readByte() == 1;
vr.mSelected = source.readByte() == 1;

View File

@ -81,7 +81,9 @@ public class AddKeysActivity extends ActionBarActivity implements
byte[] mImportBytes;
private static final int REQUEST_CODE_SAFE_SLINGER = 1;
private static final int REQUEST_CODE_RESULT = 0;
private static final int REQUEST_CODE_RESULT_TO_LIST = 1;
private static final int REQUEST_CODE_SAFE_SLINGER = 2;
private static final int LOADER_ID_BYTES = 0;
@ -130,7 +132,7 @@ public class AddKeysActivity extends ActionBarActivity implements
// show nfc help
Intent intent = new Intent(AddKeysActivity.this, HelpActivity.class);
intent.putExtra(HelpActivity.EXTRA_SELECTED_TAB, HelpActivity.TAB_NFC);
startActivityForResult(intent, 0);
startActivityForResult(intent, REQUEST_CODE_RESULT);
}
});
@ -177,55 +179,62 @@ public class AddKeysActivity extends ActionBarActivity implements
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if a result has been returned, display a notify
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
result.createNotify(this).show();
} else {
switch (requestCode) {
case REQUEST_CODE_SAFE_SLINGER: {
switch (resultCode) {
case ExchangeActivity.RESULT_EXCHANGE_OK:
// import exchanged keys
mImportBytes = getSlingedKeys(data);
getSupportLoaderManager().restartLoader(LOADER_ID_BYTES, null, this);
break;
case ExchangeActivity.RESULT_EXCHANGE_CANCELED:
// do nothing
break;
}
break;
}
case IntentIntegratorSupportV4.REQUEST_CODE: {
IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode,
resultCode, data);
if (scanResult != null && scanResult.getFormatName() != null) {
String scannedContent = scanResult.getContents();
Log.d(Constants.TAG, "scannedContent: " + scannedContent);
// look if it's fingerprint only
if (scannedContent.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
importKeys(null, getFingerprintFromUri(Uri.parse(scanResult.getContents())));
return;
}
// is this a full key encoded as qr code?
if (scannedContent.startsWith("-----BEGIN PGP")) {
// TODO
// mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(scannedContent.getBytes(), null));
return;
}
// fail...
Notify.showNotify(this, R.string.import_qr_code_wrong, Notify.Style.ERROR);
}
break;
switch (requestCode) {
case REQUEST_CODE_RESULT: {
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
result.createNotify(this).show();
}
break;
}
case REQUEST_CODE_RESULT_TO_LIST: {
// give it down...
setResult(0, data);
finish();
break;
}
case REQUEST_CODE_SAFE_SLINGER: {
switch (resultCode) {
case ExchangeActivity.RESULT_EXCHANGE_OK:
// import exchanged keys
mImportBytes = getSlingedKeys(data);
getSupportLoaderManager().restartLoader(LOADER_ID_BYTES, null, this);
break;
case ExchangeActivity.RESULT_EXCHANGE_CANCELED:
// do nothing
break;
}
break;
}
case IntentIntegratorSupportV4.REQUEST_CODE: {
IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode,
resultCode, data);
if (scanResult != null && scanResult.getFormatName() != null) {
String scannedContent = scanResult.getContents();
Log.d(Constants.TAG, "scannedContent: " + scannedContent);
// look if it's fingerprint only
if (scannedContent.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
importKeys(null, getFingerprintFromUri(Uri.parse(scanResult.getContents())));
return;
}
// is this a full key encoded as qr code?
if (scannedContent.startsWith("-----BEGIN PGP")) {
// TODO
// mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(scannedContent.getBytes(), null));
return;
}
// fail...
Notify.showNotify(this, R.string.import_qr_code_wrong, Notify.Style.ERROR);
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
super.onActivityResult(requestCode, resultCode, data);
}
private String getFingerprintFromUri(Uri dataUri) {
@ -383,14 +392,11 @@ public class AddKeysActivity extends ActionBarActivity implements
return;
}
finish();
Intent certifyIntent = new Intent(AddKeysActivity.this, MultiCertifyKeyActivity.class);
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_RESULT, result);
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_KEY_IDS, result.getImportedMasterKeyIds());
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, mExchangeMasterKeyId);
startActivity(certifyIntent);
result.createNotify(AddKeysActivity.this).show();
startActivityForResult(certifyIntent, REQUEST_CODE_RESULT_TO_LIST);
}
}
};
@ -449,7 +455,6 @@ public class AddKeysActivity extends ActionBarActivity implements
final ImportKeysListEntry keyEntry = new ImportKeysListEntry();
keyEntry.setFingerprintHex(fingerprint);
keyEntry.setBitStrength(1337); // TODO: make optional!
keyEntry.addOrigin(cloudPrefs.keyserver);
ArrayList<ImportKeysListEntry> selectedEntries = new ArrayList<ImportKeysListEntry>();
selectedEntries.add(keyEntry);

View File

@ -28,16 +28,16 @@ import android.view.MenuItem;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.util.ExportHelper;
import org.sufficientlysecure.keychain.util.Preferences;
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.results.OperationResult;
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.service.results.OperationResult;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.ExportHelper;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Preferences;
import java.io.IOException;

View File

@ -59,7 +59,6 @@ public class KeyUpdateHelper {
for (String fprint : providerHelper.getAllFingerprints(KeychainContract.KeyRings.buildUnifiedKeyRingsUri())) {
ImportKeysListEntry key = new ImportKeysListEntry();
key.setFingerprintHex(fprint);
key.setBitStrength(1337);
key.addOrigin(servers[0]);
keys.add(key);
}