mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
use sub results in import
This commit is contained in:
parent
6699917279
commit
34345cf237
@ -117,10 +117,12 @@ public class PgpImportExport {
|
||||
public ImportKeyResult importKeyRings(Iterator<ParcelableKeyRing> entries, int num) {
|
||||
updateProgress(R.string.progress_importing, 0, 100);
|
||||
|
||||
OperationLog log = new OperationLog();
|
||||
|
||||
// If there aren't even any keys, do nothing here.
|
||||
if (entries == null || !entries.hasNext()) {
|
||||
return new ImportKeyResult(
|
||||
ImportKeyResult.RESULT_FAIL_NOTHING, mProviderHelper.getLog(), 0, 0, 0, 0,
|
||||
ImportKeyResult.RESULT_FAIL_NOTHING, log, 0, 0, 0, 0,
|
||||
new long[]{});
|
||||
}
|
||||
|
||||
@ -156,6 +158,7 @@ public class PgpImportExport {
|
||||
}
|
||||
|
||||
SaveKeyringResult result;
|
||||
mProviderHelper.clearLog();
|
||||
if (key.isSecret()) {
|
||||
result = mProviderHelper.saveSecretKeyRing(key,
|
||||
new ProgressScaler(mProgressable, (int)(position*progSteps), (int)((position+1)*progSteps), 100));
|
||||
@ -176,6 +179,8 @@ public class PgpImportExport {
|
||||
importedMasterKeyIds.add(key.getMasterKeyId());
|
||||
}
|
||||
|
||||
log.add(result, 1);
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.e(Constants.TAG, "Encountered bad key on import!", e);
|
||||
++badKeys;
|
||||
@ -187,7 +192,6 @@ public class PgpImportExport {
|
||||
position++;
|
||||
}
|
||||
|
||||
OperationLog log = mProviderHelper.getLog();
|
||||
int resultType = 0;
|
||||
// special return case: no new keys at all
|
||||
if (badKeys == 0 && newKeys == 0 && oldKeys == 0) {
|
||||
|
@ -641,7 +641,7 @@ public abstract class OperationResult implements Parcelable {
|
||||
|
||||
public void add(OperationResult subResult, int indent) {
|
||||
OperationLog subLog = subResult.getLog();
|
||||
mParcels.add(new SubLogEntryParcel(subResult, subLog.getLast().mType, indent, subLog.getLast().mParameters));
|
||||
mParcels.add(new SubLogEntryParcel(subResult, subLog.getFirst().mType, indent, subLog.getFirst().mParameters));
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
@ -678,6 +678,13 @@ public abstract class OperationResult implements Parcelable {
|
||||
return mParcels.isEmpty();
|
||||
}
|
||||
|
||||
public LogEntryParcel getFirst() {
|
||||
if (mParcels.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return mParcels.get(0);
|
||||
}
|
||||
|
||||
public LogEntryParcel getLast() {
|
||||
if (mParcels.isEmpty()) {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user