From 118225d7d2b6401006352897386a40131c6cd854 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 6 Jun 2014 17:28:36 +0200 Subject: [PATCH] import-log: add output to logcat (for debugging) --- .../keychain/pgp/OperationResultParcel.java | 5 ++++- .../keychain/pgp/PgpImportExport.java | 15 ++++++++------- .../keychain/provider/ProviderHelper.java | 7 +++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OperationResultParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OperationResultParcel.java index 8110590b1..ccb4b935c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OperationResultParcel.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OperationResultParcel.java @@ -126,10 +126,13 @@ public class OperationResultParcel implements Parcelable { MSG_IS_SUCCESS (R.string.msg_is_success), ; - private int mMsgId; + private final int mMsgId; LogType(int msgId) { mMsgId = msgId; } + public int getMsgId() { + return mMsgId; + } } /** Enumeration of possible log levels. */ 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 14ec67e64..5ce0b11dd 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -152,13 +152,14 @@ public class PgpImportExport { } } - mProviderHelper.savePublicKeyRing(key); - /*switch(status) { - case RETURN_UPDATED: oldKeys++; break; - case RETURN_OK: newKeys++; break; - case RETURN_BAD: badKeys++; break; - }*/ - // TODO proper import feedback + mProviderHelper.resetLog(); + OperationResultParcel result = mProviderHelper.savePublicKeyRing(key); + for(OperationResultParcel.LogEntryParcel loge : result.mLog) { + Log.d(Constants.TAG, + loge.mIndent + + new String(new char[loge.mIndent]).replace("\0", " ") + + mContext.getString(loge.mType.getMsgId(), (Object[]) loge.mParameters)); + } newKeys += 1; } catch (PgpGeneralException e) { 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 170fc4df2..b3a08a063 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -79,6 +79,13 @@ public class ProviderHelper { mIndent = indent; } + public void resetLog() { + if(mLog != null) { + mLog.clear(); + mIndent = 0; + } + } + public static class NotFoundException extends Exception { public NotFoundException() { }