aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/main')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java44
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java26
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java36
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java1
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml33
7 files changed, 94 insertions, 50 deletions
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 ebc5a7868..4cb41708d 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
@@ -171,8 +171,6 @@ public class PgpImportExport {
if (newKeys > 0 || oldKeys > 0) {
if (badKeys > 0) {
resultType = ImportResult.RESULT_PARTIAL_WITH_ERRORS;
- } else if (log.containsWarnings()) {
- resultType = ImportResult.RESULT_OK_WITH_WARNINGS;
} else if (newKeys > 0 && oldKeys > 0) {
resultType = ImportResult.RESULT_OK_BOTHKEYS;
} else if (newKeys > 0) {
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 ab4672a98..cbaf72270 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
@@ -49,7 +49,6 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
import org.sufficientlysecure.keychain.remote.AccountSettings;
import org.sufficientlysecure.keychain.remote.AppSettings;
-import org.sufficientlysecure.keychain.service.OperationResults;
import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.util.Log;
@@ -252,7 +251,7 @@ public class ProviderHelper {
throw new NotFoundException("Secret key not available!");
}
return secret
- ? new WrappedSecretKeyRing(blob, hasAnySecret, verified)
+ ? new WrappedSecretKeyRing(blob, true, verified)
: new WrappedPublicKeyRing(blob, hasAnySecret, verified);
} else {
throw new NotFoundException("Key not found!");
@@ -274,14 +273,15 @@ public class ProviderHelper {
return new OperationResultParcel(1, mLog);
}
- // Canonicalize this key, to assert a number of assumptions made about the key.
+ long masterKeyId = keyRing.getMasterKeyId();
+ log(LogLevel.START, LogType.MSG_IP,
+ new String[]{ PgpKeyHelper.convertKeyIdToHex(masterKeyId) });
+ mIndent += 1;
+
+ // Canonicalize this key, to assert a number of assumptions made about it.
keyRing = keyRing.canonicalize(mLog);
UncachedPublicKey masterKey = keyRing.getPublicKey();
- long masterKeyId = masterKey.getKeyId();
- log(LogLevel.INFO, LogType.MSG_IP_IMPORTING,
- new String[]{Long.toString(masterKeyId)});
- mIndent += 1;
// IF there is a secret key, preserve it!
UncachedKeyRing secretRing;
@@ -342,12 +342,28 @@ public class ProviderHelper {
values.put(Keys.ALGORITHM, key.getAlgorithm());
values.put(Keys.FINGERPRINT, key.getFingerprint());
- boolean c = key.canCertify(), s = key.canSign(), e = key.canEncrypt();
+ boolean c = key.canCertify(), e = key.canEncrypt(), s = key.canSign();
values.put(Keys.CAN_CERTIFY, c);
- values.put(Keys.CAN_SIGN, s);
values.put(Keys.CAN_ENCRYPT, e);
+ values.put(Keys.CAN_SIGN, s);
values.put(Keys.IS_REVOKED, key.isRevoked());
- log(LogLevel.DEBUG, LogType.MSG_IP_SUBKEY_FLAGS, new String[] { "X" });
+ if (c) {
+ if (e) {
+ log(LogLevel.DEBUG,s ? LogType.MSG_IP_SUBKEY_FLAGS_CES
+ : LogType.MSG_IP_SUBKEY_FLAGS_CEX, null);
+ } else {
+ log(LogLevel.DEBUG, s ? LogType.MSG_IP_SUBKEY_FLAGS_CXS
+ : LogType.MSG_IP_SUBKEY_FLAGS_CXX, null);
+ }
+ } else {
+ if (e) {
+ log(LogLevel.DEBUG, s ? LogType.MSG_IP_SUBKEY_FLAGS_XES
+ : LogType.MSG_IP_SUBKEY_FLAGS_XEX, null);
+ } else {
+ log(LogLevel.DEBUG, s ? LogType.MSG_IP_SUBKEY_FLAGS_XXS
+ : LogType.MSG_IP_SUBKEY_FLAGS_XXX, null);
+ }
+ }
Date creation = key.getCreationTime();
values.put(Keys.CREATION, creation.getTime() / 1000);
@@ -531,7 +547,7 @@ public class ProviderHelper {
mIndent -= 1;
}
- log(LogLevel.INFO, LogType.MSG_IP_SUCCESS);
+ log(LogLevel.OK, LogType.MSG_IP_SUCCESS);
mIndent -= 1;
return new OperationResultParcel(0, mLog);
@@ -569,8 +585,8 @@ public class ProviderHelper {
}
long masterKeyId = keyRing.getMasterKeyId();
- log(LogLevel.INFO, LogType.MSG_IS_IMPORTING,
- new String[]{Long.toString(masterKeyId)});
+ log(LogLevel.START, LogType.MSG_IS,
+ new String[]{PgpKeyHelper.convertKeyIdToHex(masterKeyId)});
// save secret keyring
try {
@@ -626,7 +642,7 @@ public class ProviderHelper {
// with has_secret = 0
}
- log(LogLevel.INFO, LogType.MSG_IS_SUCCESS);
+ log(LogLevel.OK, LogType.MSG_IS_SUCCESS);
return new OperationResultParcel(0, mLog);
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java
index a1a1d0067..85b7c456f 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java
@@ -101,6 +101,9 @@ public class OperationResultParcel implements Parcelable {
}
public static enum LogType {
+
+ // import public
+ MSG_IP(R.string.msg_ip),
MSG_IP_APPLY_BATCH (R.string.msg_ip_apply_batch),
MSG_IP_BAD_TYPE_SECRET (R.string.msg_ip_bad_type_secret),
MSG_IP_DELETE_OLD_FAIL (R.string.msg_ip_delete_old_fail),
@@ -109,7 +112,6 @@ public class OperationResultParcel implements Parcelable {
MSG_IP_FAIL_IO_EXC (R.string.msg_ip_fail_io_exc),
MSG_IP_FAIL_OP_EX (R.string.msg_ip_fail_op_ex),
MSG_IP_FAIL_REMOTE_EX (R.string.msg_ip_fail_remote_ex),
- MSG_IP_IMPORTING (R.string.msg_ip_importing),
MSG_IP_INSERT_KEYRING (R.string.msg_ip_insert_keyring),
MSG_IP_INSERT_SUBKEYS (R.string.msg_ip_insert_subkeys),
MSG_IP_PRESERVING_SECRET (R.string.msg_ip_preserving_secret),
@@ -118,6 +120,14 @@ public class OperationResultParcel implements Parcelable {
MSG_IP_SUBKEY_EXPIRED (R.string.msg_ip_subkey_expired),
MSG_IP_SUBKEY_EXPIRES (R.string.msg_ip_subkey_expires),
MSG_IP_SUBKEY_FLAGS (R.string.msg_ip_subkey_flags),
+ MSG_IP_SUBKEY_FLAGS_CES (R.string.msg_ip_subkey_flags_ces),
+ MSG_IP_SUBKEY_FLAGS_CEX (R.string.msg_ip_subkey_flags_cex),
+ MSG_IP_SUBKEY_FLAGS_CXS (R.string.msg_ip_subkey_flags_cxs),
+ MSG_IP_SUBKEY_FLAGS_XES (R.string.msg_ip_subkey_flags_xes),
+ MSG_IP_SUBKEY_FLAGS_CXX (R.string.msg_ip_subkey_flags_cxx),
+ MSG_IP_SUBKEY_FLAGS_XEX (R.string.msg_ip_subkey_flags_xex),
+ MSG_IP_SUBKEY_FLAGS_XXS (R.string.msg_ip_subkey_flags_xxs),
+ MSG_IP_SUBKEY_FLAGS_XXX (R.string.msg_ip_subkey_flags_xxx),
MSG_IP_SUBKEY_FUTURE (R.string.msg_ip_subkey_future),
MSG_IP_SUCCESS (R.string.msg_ip_success),
MSG_IP_TRUST_RETRIEVE (R.string.msg_ip_trust_retrieve),
@@ -135,14 +145,20 @@ public class OperationResultParcel implements Parcelable {
MSG_IP_UID_SELF_GOOD (R.string.msg_ip_uid_self_good),
MSG_IP_UID_SELF_IGNORING_OLD (R.string.msg_ip_uid_self_ignoring_old),
MSG_IP_UID_SELF_NEWER (R.string.msg_ip_uid_self_newer),
+
+ // import secret
+ MSG_IS(R.string.msg_is),
MSG_IS_BAD_TYPE_PUBLIC (R.string.msg_is_bad_type_public),
- MSG_IS_IMPORTING (R.string.msg_is_importing),
MSG_IS_IMPORTING_SUBKEYS (R.string.msg_is_importing_subkeys),
MSG_IS_IO_EXCPTION (R.string.msg_is_io_excption),
MSG_IS_SUBKEY_NONEXISTENT (R.string.msg_is_subkey_nonexistent),
MSG_IS_SUBKEY_OK (R.string.msg_is_subkey_ok),
MSG_IS_SUBKEY_STRIPPED (R.string.msg_is_subkey_stripped),
MSG_IS_SUCCESS (R.string.msg_is_success),
+
+ // keyring canonicalization
+ MSG_KC(R.string.msg_kc),
+ MSG_KC_SUCCESS(R.string.msg_kc_success),
;
private final int mMsgId;
@@ -156,12 +172,12 @@ public class OperationResultParcel implements Parcelable {
/** Enumeration of possible log levels. */
public static enum LogLevel {
- OK,
+ START, // should occur once at the start of each independent operation
+ OK, // should occur once at the end of a successful operation
+ ERROR, // should occur once at the end of a failed operation
DEBUG,
INFO,
WARN,
- /** If any ERROR log entry is included in the result, the overall operation should have failed. */
- ERROR,
}
@Override
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java
index e08b50500..bee6917be 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java
@@ -14,8 +14,6 @@ public abstract class OperationResults {
public static final int RESULT_OK_BOTHKEYS = 2;
// Operation ok, no new keys but upated ones (no warnings)
public static final int RESULT_OK_UPDATED = 3;
- // Operation ok, but with warnings
- public static final int RESULT_OK_WITH_WARNINGS = 4;
// Operation partially ok, but at least one key failed!
public static final int RESULT_PARTIAL_WITH_ERRORS = 50;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
index 9932e3e18..61d7e7949 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
@@ -378,37 +378,37 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
final ImportResult result =
returnData.<ImportResult>getParcelable(KeychainIntentService.RESULT);
- // , make pessimistic assumptions
- String str = Integer.toString(result.getResult());
- int duration = 0, color = Style.RED;
+ String str = "";
+ boolean hasWarnings = result.getLog().containsWarnings();
+ int duration = 0, color = hasWarnings ? Style.ORANGE : Style.GREEN;
+ String withWarnings = hasWarnings
+ ? getResources().getString(R.string.with_warnings) : "";
switch(result.getResult()) {
case ImportResult.RESULT_OK_NEWKEYS:
- color = Style.GREEN;
- duration = SuperToast.Duration.LONG;
+ if (!hasWarnings) {
+ duration = SuperToast.Duration.LONG;
+ }
str = getResources().getQuantityString(
- R.plurals.keys_added, result.mNewKeys, result.mNewKeys);
+ R.plurals.keys_added, result.mNewKeys, result.mNewKeys, withWarnings);
break;
case ImportResult.RESULT_OK_UPDATED:
- color = Style.GREEN;
- duration = SuperToast.Duration.LONG;
+ if (!hasWarnings) {
+ duration = SuperToast.Duration.LONG;
+ }
str = getResources().getQuantityString(
- R.plurals.keys_updated, result.mNewKeys, result.mNewKeys);
+ R.plurals.keys_updated, result.mNewKeys, result.mNewKeys, withWarnings);
break;
case ImportResult.RESULT_OK_BOTHKEYS:
- color = Style.GREEN;
- duration = SuperToast.Duration.LONG;
+ if (!hasWarnings) {
+ duration = SuperToast.Duration.LONG;
+ }
str = getResources().getQuantityString(
R.plurals.keys_added_and_updated_1, result.mNewKeys, result.mNewKeys);
str += getResources().getQuantityString(
- R.plurals.keys_added_and_updated_2, result.mUpdatedKeys, result.mUpdatedKeys);
- break;
-
- case ImportResult.RESULT_OK_WITH_WARNINGS:
- str = "ok with warnings";
- color = Style.ORANGE;
+ R.plurals.keys_added_and_updated_2, result.mUpdatedKeys, result.mUpdatedKeys, withWarnings);
break;
case ImportResult.RESULT_PARTIAL_WITH_ERRORS:
@@ -435,6 +435,8 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
toast.setSwipeToDismiss(true);
toast.setButtonIcon(R.drawable.ic_action_view_as_list,
getResources().getString(R.string.view_log));
+ toast.setButtonTextColor(R.color.emphasis_dark);
+ toast.setTextColor(R.color.emphasis_dark);
toast.setOnClickWrapper(new OnClickWrapper("supercardtoast",
new SuperToast.OnClickListener() {
@Override
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java
index 5e038d3f6..275c9ac18 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java
@@ -73,6 +73,7 @@ public class LogDisplayFragment extends ListFragment {
text.setPadding(entry.mIndent*dipFactor, 0, 0, 0);
text.setText(getResources().getString(entry.mType.getMsgId(), (Object[]) entry.mParameters));
switch (entry.mLevel) {
+ case OK: text.setTextColor(Color.GREEN); break;
case DEBUG: text.setTextColor(Color.GRAY); break;
case INFO: text.setTextColor(Color.BLACK); break;
case WARN: text.setTextColor(Color.YELLOW); break;
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index e1ff77c63..b60e281ee 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -222,23 +222,24 @@
<string name="also_export_secret_keys">Also export secret keys?</string>
<plurals name="keys_added_and_updated_1">
- <item quantity="one">Successfully added %d key</item>
- <item quantity="other">Successfully added %d keys</item>
+ <item quantity="one">Successfully added %1$d key</item>
+ <item quantity="other">Successfully added %1$d keys</item>
</plurals>
<plurals name="keys_added_and_updated_2">
- <item quantity="one"> and updated %d key.</item>
- <item quantity="other"> and updated %d keys.</item>
+ <item quantity="one"> and updated %1$d key%2$s.</item>
+ <item quantity="other"> and updated %1$d keys%2$s.</item>
</plurals>
<plurals name="keys_added">
- <item quantity="one">Successfully added %d key.</item>
- <item quantity="other">Successfully added %d keys.</item>
+ <item quantity="one">Successfully added %1$d key%2$s.</item>
+ <item quantity="other">Successfully added %1$d keys%2$s.</item>
</plurals>
<plurals name="keys_updated">
- <item quantity="one">Successfully updated %d key.</item>
- <item quantity="other">Successfully updated %d keys.</item>
+ <item quantity="one">Successfully updated %1$d key%2$s.</item>
+ <item quantity="other">Successfully updated %1$d keys%2$s.</item>
</plurals>
<string name="no_keys_added_or_updated">No keys added or updated.</string>
+ <string name="with_warnings">, with warnings</string>
<string name="key_exported">Successfully exported 1 key.</string>
<string name="keys_exported">Successfully exported %d keys.</string>
<string name="no_keys_exported">No keys exported.</string>
@@ -509,7 +510,7 @@
<string name="msg_ip_fail_io_exc">Operation failed due to i/o error</string>
<string name="msg_ip_fail_op_ex">Operation failed due to database error</string>
<string name="msg_ip_fail_remote_ex">Operation failed due to internal error</string>
- <string name="msg_ip_importing">Importing public keyring %s</string>
+ <string name="msg_ip">Importing public keyring %s</string>
<string name="msg_ip_insert_keyring">Inserting keyring data</string>
<string name="msg_ip_insert_subkeys">Inserting subkeys</string>
<string name="msg_ip_preserving_secret">Preserving available secret key</string>
@@ -517,6 +518,14 @@
<string name="msg_ip_subkey_expired">Subkey expired on %s</string>
<string name="msg_ip_subkey_expires">Subkey expires on %s</string>
<string name="msg_ip_subkey_flags">Subkey flags: %s</string>
+ <string name="msg_ip_subkey_flags_ces">Subkey flags: certify, encrypt, sign</string>
+ <string name="msg_ip_subkey_flags_cex">Subkey flags: certify, encrypt</string>
+ <string name="msg_ip_subkey_flags_cxs">Subkey flags: certify, sign</string>
+ <string name="msg_ip_subkey_flags_xes">Subkey flags: encrypt, sign</string>
+ <string name="msg_ip_subkey_flags_cxx">Subkey flags: certify</string>
+ <string name="msg_ip_subkey_flags_xex">Subkey flags: encrypt</string>
+ <string name="msg_ip_subkey_flags_xxs">Subkey flags: sign</string>
+ <string name="msg_ip_subkey_flags_xxx">Subkey flags: none</string>
<string name="msg_ip_subkey_future">Subkey creation date lies in the future! (%s)</string>
<string name="msg_ip_success">Successfully inserted public keyring</string>
<string name="msg_ip_reinsert_secret">Re-inserting secret key</string>
@@ -538,7 +547,7 @@
<string name="msg_is_bad_type_public">Tried to import public keyring as secret. This is a bug, please file a report!</string>
<!-- Import Secret log entries -->
- <string name="msg_is_importing">Importing secret key %s</string>
+ <string name="msg_is">Importing secret key %s</string>
<string name="msg_is_importing_subkeys">Processing secret subkeys</string>
<string name="msg_is_io_excption">Error encoding keyring</string>
<string name="msg_is_subkey_nonexistent">Subkey %s unavailable in public key</string>
@@ -546,6 +555,10 @@
<string name="msg_is_subkey_stripped">Marked %s as stripped</string>
<string name="msg_is_success">Successfully inserted secret keyring</string>
+ <!-- Keyring Canonicalization log entries -->
+ <string name="msg_kc">Canonicalizing keyring %s</string>
+ <string name="msg_kc_success">Successfully canonicalized keyring</string>
+
<!-- unsorted -->
<string name="section_certifier_id">Certifier</string>
<string name="section_cert">Certificate Details</string>