talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 1207b105a41e9584406b7faab4cbe75cf9bf9534
parent 71b8625f5daf4ea32b4b1beff6fb044d48a7b31b
Author: Christian Hesse <mail@eworm.de>
Date:   Mon,  7 Sep 2015 20:24:01 +0200

Hidden preference to limit PGP autocompletion

Some keys have a lot of UIDs, resulting in a huge dropdown list. This
allows to limit PGP autocompletion to use the first n UID/address of a
key only.

Diffstat:
Msrc/plugins/pgpcore/autocompletion.c | 8++++++++
Msrc/plugins/pgpcore/prefs_gpg.c | 3+++
Msrc/plugins/pgpcore/prefs_gpg.h | 1+
3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/plugins/pgpcore/autocompletion.c b/src/plugins/pgpcore/autocompletion.c @@ -49,6 +49,7 @@ static gboolean pgp_autocompletion_hook(gpointer source, gpointer data) gpgme_user_id_t uid; address_entry *ae; GList *addr_list = NULL; + gint i; /* just return if autocompletion is disabled */ if (!prefs_gpg_get_config()->autocompletion) @@ -68,6 +69,7 @@ static gboolean pgp_autocompletion_hook(gpointer source, gpointer data) /* skip keys that are revoked, expired, ... */ if ((key->revoked || key->expired || key->disabled || key->invalid) == FALSE) { uid = key->uids; + i = 0; /* walk all user ids within a key */ while (uid != NULL) { @@ -89,7 +91,13 @@ static gboolean pgp_autocompletion_hook(gpointer source, gpointer data) debug_print("%s <%s>\n", uid->name, uid->email); } + + if (prefs_gpg_get_config()->autocompletion_limit > 0 && + prefs_gpg_get_config()->autocompletion_limit == i) + break; + uid = uid->next; + i++; } } gpgme_key_release(key); diff --git a/src/plugins/pgpcore/prefs_gpg.c b/src/plugins/pgpcore/prefs_gpg.c @@ -47,6 +47,9 @@ static PrefParam param[] = { {"autocompletion", "FALSE", &prefs_gpg.autocompletion, P_BOOL, NULL, NULL, NULL}, + {"autocompletion_limit", "0", + &prefs_gpg.autocompletion_limit, P_INT, + NULL, NULL, NULL}, {"use_gpg_agent", "TRUE", &prefs_gpg.use_gpg_agent, P_BOOL, NULL, NULL, NULL}, {"store_passphrase", "FALSE", &prefs_gpg.store_passphrase, P_BOOL, diff --git a/src/plugins/pgpcore/prefs_gpg.h b/src/plugins/pgpcore/prefs_gpg.h @@ -35,6 +35,7 @@ struct GPGConfig { gboolean auto_check_signatures; gboolean autocompletion; + gint autocompletion_limit; gboolean use_gpg_agent; gboolean store_passphrase; gint store_passphrase_timeout;