From d5e87e939388111c6125251d75bbc8998b9446e2 Mon Sep 17 00:00:00 2001 From: Pablo Ovelleiro Corral Date: Mon, 3 Dec 2018 17:52:04 +0100 Subject: [PATCH] add $crypto_chars to customise the index Fixes #1469 --- hdrline.c | 33 +++++++++++++++++++++++---------- hdrline.h | 1 + init.h | 13 +++++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/hdrline.c b/hdrline.c index 8699c8fda..c7bb18cbc 100644 --- a/hdrline.c +++ b/hdrline.c @@ -49,6 +49,7 @@ #include "sort.h" /* These Config Variables are only used in hdrline.c */ +struct MbTable *CryptoChars; ///< Config: User-configurable crypto flags: signed, encrypted etc. struct MbTable *FlagChars; ///< Config: User-configurable index flags: tagged, new, etc struct MbTable *FromChars; ///< Config: User-configurable index flags: to address, cc address, etc struct MbTable *ToChars; ///< Config: Indicator characters for the 'To' field in the index @@ -71,6 +72,18 @@ enum FlagChars FLAG_CHAR_ZEMPTY, ///< Character denoting a read email, $index_format %Z expando }; +/** + * enum CryptoChars - Index into the CryptoChars variable ($crypto_chars) + */ +enum CryptoChars +{ + FLAG_CHAR_CRYPTO_GOOD_SIGN, ///< Character denoting a message signed with a verified key + FLAG_CHAR_CRYPTO_ENCRYPTED, ///< Character denoting a message is PGP-encrypted + FLAG_CHAR_CRYPTO_SIGNED, ///< Character denoting a message is signed + FLAG_CHAR_CRYPTO_CONTAINS_KEY, ///< Character denoting a message contains a PGP key + FLAG_CHAR_CRYPTO_NO_CRYPTO, ///< Character denoting a message has no cryptography information +}; + /** * mutt_is_mail_list - Is this the email address of a mailing list? * @param addr Address to test @@ -1311,17 +1324,17 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co { const char *ch = NULL; if ((WithCrypto != 0) && (e->security & GOODSIGN)) - ch = "S"; + ch = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_GOOD_SIGN); else if ((WithCrypto != 0) && (e->security & ENCRYPT)) - ch = "P"; + ch = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_ENCRYPTED); else if ((WithCrypto != 0) && (e->security & SIGN)) - ch = "s"; + ch = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_SIGNED); else if (((WithCrypto & APPLICATION_PGP) != 0) && ((e->security & PGP_KEY) == PGP_KEY)) { - ch = "K"; + ch = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_CONTAINS_KEY); } else - ch = " "; + ch = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_NO_CRYPTO); snprintf(tmp, sizeof(tmp), "%s", ch); src++; @@ -1377,15 +1390,15 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co else if (e->attach_del) second = get_nth_wchar(FlagChars, FLAG_CHAR_DELETED_ATTACH); else if ((WithCrypto != 0) && (e->security & GOODSIGN)) - second = "S"; + second = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_GOOD_SIGN); else if ((WithCrypto != 0) && (e->security & ENCRYPT)) - second = "P"; + second = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_ENCRYPTED); else if ((WithCrypto != 0) && (e->security & SIGN)) - second = "s"; + second = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_SIGNED); else if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & PGP_KEY)) - second = "K"; + second = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_CONTAINS_KEY); else - second = " "; + second = get_nth_wchar(CryptoChars, FLAG_CHAR_CRYPTO_NO_CRYPTO); /* Tagged, flagged and recipient flag */ const char *third = NULL; diff --git a/hdrline.h b/hdrline.h index 4bf4c8f71..00b40d6cf 100644 --- a/hdrline.h +++ b/hdrline.h @@ -32,6 +32,7 @@ struct Context; struct Email; /* These Config Variables are only used in hdrline.c */ +extern struct MbTable *CryptoChars; extern struct MbTable *FlagChars; extern struct MbTable *FromChars; extern struct MbTable *ToChars; diff --git a/init.h b/init.h index 643b2ab28..de94a0b8c 100644 --- a/init.h +++ b/init.h @@ -971,6 +971,19 @@ struct ConfigDef MuttVars[] = { ** .dt 11 .dd .dd The mail is read - %Z expando. ** .de */ + { "crypto_chars", DT_MBTABLE, R_BOTH, &CryptoChars, IP "SPsK " }, + /* + ** .pp + ** Controls the characters used in cryptography flags. + ** .dl + ** .dt \fBCharacter\fP .dd \fBDefault\fP .dd \fBDescription\fP + ** .dt 1 .dd S .dd The mail is signed, and the signature is successfully verified. + ** .dt 2 .dd P .dd The mail is PGP encrypted. + ** .dt 3 .dd s .dd The mail is signed. + ** .dt 4 .dd K .dd The mail contains a PGP public key. + ** .dt 5 .dd .dd The mail has no crypto info. + ** .de + */ { "flag_safe", DT_BOOL, R_NONE, &FlagSafe, false }, /* ** .pp -- 2.40.0