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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-12-13 15:10:51 +01:00
parent 7e7eaf4342
commit 5eeae535ee
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
6 changed files with 19 additions and 0 deletions

1
NEWS
View File

@ -13,6 +13,7 @@ Noteworthy changes in version 1.14.0 (unreleased)
* Interface changes relative to the 1.13.1 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_user_id_t EXTENDED: New field 'uidhash'.
cpp: UserID::remark NEW.
cpp: UserID::remarks NEW.
cpp: GpgSignKeyEditInteractor::setDupeOk NEW.

View File

@ -3581,6 +3581,12 @@ Reserved for the origin of this user ID.
Reserved for the time of the last update of this user ID.
@item char *uidhash;
A string used by gpg to identify a user ID. This string can be used
at certain prompts of @code{gpgme_op_edit} to select a user ID. Users
must be prepared to see a @code{NULL} value here. The format of the
value is not specified and may depend on the GPGME or GnuPG version.
@end table
@end deftp

View File

@ -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;

View File

@ -385,6 +385,7 @@ gpgme_key_unref (gpgme_key_t key)
}
free (uid->address);
free (uid->uidhash);
free (uid);
uid = next_uid;
}

View File

@ -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)
{

View File

@ -330,6 +330,8 @@ main (int argc, char **argv)
printf (" name: %s\n", uid->name);
if (uid->comment)
printf (" cmmnt: %s\n", uid->comment);
if (uid->uidhash)
printf (" uidhash: %s\n", uid->uidhash);
printf (" upd: %lu (%u)\n", uid->last_update, uid->origin);
printf (" valid: %s\n",
uid->validity == GPGME_VALIDITY_UNKNOWN? "unknown":