summaryrefslogtreecommitdiff
path: root/src/key.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2016-08-23 06:48:50 +0200
committerWerner Koch <wk@gnupg.org>2016-08-23 06:48:50 +0200
commit3955dce06e9d056599e5ec7d40301e66b9305195 (patch)
tree1336879434595922fb272d220a9584bd27828fe1 /src/key.c
parent26c5ba528ce1411d96655952ec48359105695c0f (diff)
downloadgpgme-3955dce06e9d056599e5ec7d40301e66b9305195.tar.gz
core: Extend gpgme_user_id_t with 'address'.
* src/mbox-util.c, src/mbox-util.h: Adjust for use in gpgme. * src/Makefile.am (main_sources): Add mbox-util. * src/key.c (_gpgme_key_append_name): Set 'address' field of uid. (gpgme_key_unref): Free it. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'src/key.c')
-rw-r--r--src/key.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/key.c b/src/key.c
index de971023..f642501b 100644
--- a/src/key.c
+++ b/src/key.c
@@ -31,6 +31,8 @@
#include "ops.h"
#include "sema.h"
#include "debug.h"
+#include "mbox-util.h"
+
/* Protects all reference counters in keys. All other accesses to a
@@ -233,6 +235,14 @@ _gpgme_key_append_name (gpgme_key_t key, const char *src, int convert)
parse_user_id (uid->uid, &uid->name, &uid->email,
&uid->comment, dst);
+ uid->address = _gpgme_mailbox_from_userid (uid->uid);
+ if (uid->address && uid->email && !strcmp (uid->address, uid->email))
+ {
+ /* The ADDRESS is the same as EMAIL: Save some space. */
+ free (uid->address);
+ uid->address = uid->email;
+ }
+
if (!key->uids)
key->uids = uid;
if (key->_last_uid)
@@ -363,6 +373,8 @@ gpgme_key_unref (gpgme_key_t key)
free (keysig);
keysig = next_keysig;
}
+ if (uid->address && uid->address != uid->email)
+ free (uid->address);
free (uid);
uid = next_uid;
}