From 5eeae535ee0df981d8ae8b758b5bb0d190c7fd89 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 13 Dec 2019 15:10:51 +0100 Subject: core: Extend gpgme_user_id_t with uidhash member. * src/gpgme.h.in (struct _gpgme_user_id): Add field 'uidhash'. * src/key.c (gpgme_key_unref): Free it. * src/keylist.c (keylist_colon_handler): Set it. * tests/run-keylist.c (main): Print it. -- The uidhash value is part of gpg's output since the year 2005. This now adds support to gpgme. The application for uidhash is to select a user id in an edit interactor: Instead of giving the number of the user id, the uidhash value can be be used to avoid tracking the user id numbers. Signed-off-by: Werner Koch --- src/gpgme.h.in | 3 +++ src/key.c | 1 + src/keylist.c | 6 ++++++ 3 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/gpgme.h.in b/src/gpgme.h.in index 722ce68b..a52901bb 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -728,6 +728,9 @@ struct _gpgme_user_id /* Time of the last refresh of this user id. 0 if unknown. */ unsigned long last_update; + + /* The string to exactly identify a userid. Might be NULL. */ + char *uidhash; }; typedef struct _gpgme_user_id *gpgme_user_id_t; diff --git a/src/key.c b/src/key.c index e5dbdcb9..e4b85774 100644 --- a/src/key.c +++ b/src/key.c @@ -385,6 +385,7 @@ gpgme_key_unref (gpgme_key_t key) } free (uid->address); + free (uid->uidhash); free (uid); uid = next_uid; } diff --git a/src/keylist.c b/src/keylist.c index a0de7666..a4de3ad5 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -831,6 +831,12 @@ keylist_colon_handler (void *priv, char *line) if (field[1]) set_userid_flags (key, field[1]); + if (field[7] && *field[7]) + { + gpgme_user_id_t uid = key->_last_uid; + assert (uid); + uid->uidhash = strdup (field[7]); + } opd->tmp_uid = key->_last_uid; if (fields >= 20) { -- cgit v1.2.3