From 69e86df05170b95fcead87b335ab0713909fc5cf Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 10 May 2002 10:42:45 +0000 Subject: [PATCH] * key.h (gpgme_key_s): Add OTRUST. * keylist.c (set_ownertrust): New. (keylist_colon_handler): Get the ownertrust value * key.c (gpgme_key_get_string_attr,gpgme_key_get_ulong_attr): Return that value. --- trunk/gpgme/ChangeLog | 8 ++++++++ trunk/gpgme/key.c | 14 ++++++++++++-- trunk/gpgme/key.h | 1 + trunk/gpgme/keylist.c | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 0696272..fc03015 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,11 @@ +2002-05-10 Werner Koch + + * key.h (gpgme_key_s): Add OTRUST. + * keylist.c (set_ownertrust): New. + (keylist_colon_handler): Get the ownertrust value + * key.c (gpgme_key_get_string_attr,gpgme_key_get_ulong_attr): + Return that value. + 2002-05-08 Marcus Brinkmann * w32-util.c: New static variable GET_PATH_LOCK. diff --git a/trunk/gpgme/key.c b/trunk/gpgme/key.c index 0b3b787..43472dc 100644 --- a/trunk/gpgme/key.c +++ b/trunk/gpgme/key.c @@ -887,8 +887,15 @@ gpgme_key_get_string_attr (GpgmeKey key, GpgmeAttr what, case GPGME_ATTR_EXPIRE: /* Use another get function. */ break; - case GPGME_ATTR_OTRUST: - val = "[fixme]"; + case GPGME_ATTR_OTRUST: + switch (key->otrust) + { + case GPGME_VALIDITY_NEVER: val = "n"; break; + case GPGME_VALIDITY_MARGINAL: val = "m"; break; + case GPGME_VALIDITY_FULL: val = "f"; break; + case GPGME_VALIDITY_ULTIMATE: val = "u"; break; + default: val = "?"; break; + } break; case GPGME_ATTR_USERID: for (u = key->uids; u && idx; u = u->next, idx--) @@ -1041,6 +1048,9 @@ gpgme_key_get_ulong_attr (GpgmeKey key, GpgmeAttr what, if (u) val = u->validity; break; + case GPGME_ATTR_OTRUST: + val = key->otrust; + break; case GPGME_ATTR_IS_SECRET: val = !!key->secret; break; diff --git a/trunk/gpgme/key.h b/trunk/gpgme/key.h index bc00f5f..39a1316 100644 --- a/trunk/gpgme/key.h +++ b/trunk/gpgme/key.h @@ -62,6 +62,7 @@ struct gpgme_key_s { char *issuer_serial; /* malloced string used only with X.509 */ char *issuer_name; /* ditto */ char *chain_id; /* ditto */ + GpgmeValidity otrust; /* only used with OpenPGP */ struct subkey_s keys; struct user_id_s *uids; }; diff --git a/trunk/gpgme/keylist.c b/trunk/gpgme/keylist.c index 57a8980..a04300a 100644 --- a/trunk/gpgme/keylist.c +++ b/trunk/gpgme/keylist.c @@ -151,6 +151,23 @@ set_subkey_capability ( struct subkey_s *k, const char *s) } } +static void +set_ownertrust (GpgmeKey key, const char *s) +{ + /* Look at letters and stop at the first digit. */ + for (; *s && !my_isdigit (*s); s++) + { + switch (*s) + { + case 'n': key->otrust = GPGME_VALIDITY_NEVER; break; + case 'm': key->otrust = GPGME_VALIDITY_MARGINAL; break; + case 'f': key->otrust = GPGME_VALIDITY_FULL; break; + case 'u': key->otrust = GPGME_VALIDITY_ULTIMATE; break; + default : key->otrust = GPGME_VALIDITY_UNKNOWN; break; + } + } +} + /* Note: We are allowed to modify LINE. */ static void @@ -312,6 +329,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) } break; case 9: /* ownertrust */ + set_ownertrust (key, p); break; case 10: /* not used for gpg due to --fixed-list-mode option but gpgsm stores the issuer name */ -- 2.26.2