From 0042cda87ca1abd73f08b8f8129fbad3b92d23a2 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Fri, 3 Oct 2008 19:54:30 +0000 Subject: [PATCH] * main.h, mainproc.c (check_sig_and_print), keylist.c (list_keyblock_print), pkclist.c (do_edit_ownertrust), keyedit.c (menu_showphoto), photoid.c (generate_photo_id, show_photos), misc.c (pct_expando): Add %v and %V expandos so that displaying photo IDs can show the attribute validity tag (%v) and string (%V). Originally by Daniel Gillmor. --- g10/ChangeLog | 9 +++++++++ g10/keyedit.c | 6 +++--- g10/keylist.c | 6 +++--- g10/main.h | 6 ++++-- g10/mainproc.c | 7 ++++--- g10/misc.c | 52 +++++++++++++++++++++++++++++++++++--------------- g10/photoid.c | 13 +++++++++---- g10/photoid.h | 6 +++--- g10/pkclist.c | 3 ++- 9 files changed, 74 insertions(+), 34 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index c177c1717..439333294 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,12 @@ +2008-10-03 David Shaw + + * main.h, mainproc.c (check_sig_and_print), + keylist.c (list_keyblock_print), pkclist.c (do_edit_ownertrust), + keyedit.c (menu_showphoto), photoid.c (generate_photo_id, + show_photos), misc.c (pct_expando): Add %v and %V expandos so + that displaying photo IDs can show the attribute validity + tag (%v) and string (%V). Originally by Daniel Gillmor. + 2008-09-24 David Shaw * keyedit.c (keyedit_menu): Fix bug where a modified keyring loses diff --git a/g10/keyedit.c b/g10/keyedit.c index 4155b0706..ccb506361 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -1,6 +1,6 @@ /* keyedit.c - keyedit stuff - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * 2007 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + * 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -5094,7 +5094,7 @@ menu_showphoto( KBNODE keyblock ) "key %s (uid %d)\n"), image_type_to_string(type,1), (ulong)size,keystr_from_pk(pk),count); - show_photos(&uid->attribs[i],1,pk,NULL); + show_photos(&uid->attribs[i],1,pk,NULL,uid); } } } diff --git a/g10/keylist.c b/g10/keylist.c index 4198729ac..fa730bf95 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -1,6 +1,6 @@ /* keylist.c - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, - * 2004, 2005 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + * 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -839,7 +839,7 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque ) putchar('\n'); if((opt.list_options&LIST_SHOW_PHOTOS) && uid->attribs!=NULL) - show_photos(uid->attribs,uid->numattribs,pk,sk); + show_photos(uid->attribs,uid->numattribs,pk,sk,uid); } else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) { diff --git a/g10/main.h b/g10/main.h index 1c48ca6cd..9f53d0820 100644 --- a/g10/main.h +++ b/g10/main.h @@ -1,6 +1,6 @@ /* main.h - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * 2007 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + * 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -96,6 +96,8 @@ struct expando_args PKT_public_key *pk; PKT_secret_key *sk; byte imagetype; + int validity_info; + const char *validity_string; }; char *pct_expando(const char *string,struct expando_args *args); diff --git a/g10/mainproc.c b/g10/mainproc.c index 2a91f0f62..ec5952ebf 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -1,6 +1,6 @@ /* mainproc.c - handle packets - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * 2007 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + * 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -1800,7 +1800,8 @@ check_sig_and_print( CTX c, KBNODE node ) if(opt.verify_options&VERIFY_SHOW_PHOTOS) show_photos(un->pkt->pkt.user_id->attribs, - un->pkt->pkt.user_id->numattribs,pk,NULL); + un->pkt->pkt.user_id->numattribs, + pk,NULL,un->pkt->pkt.user_id); } p=utf8_to_native(un->pkt->pkt.user_id->name, diff --git a/g10/misc.c b/g10/misc.c index 004dd901e..11af251e1 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -1,6 +1,6 @@ /* misc.c - miscellaneous functions - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + * 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -503,8 +503,6 @@ pct_expando(const char *string,struct expando_args *args) while(*ch!='\0') { - char *str=NULL; - if(!done) { /* 8192 is way bigger than we'll need here */ @@ -613,22 +611,46 @@ pct_expando(const char *string,struct expando_args *args) } break; - case 't': /* e.g. "jpg" */ - str=image_type_to_string(args->imagetype,0); - /* fall through */ - - case 'T': /* e.g. "image/jpeg" */ - if(str==NULL) - str=image_type_to_string(args->imagetype,2); - - if(idx+strlen(str)validity_info && idx+1validity_info; + ret[idx]='\0'; done=1; } break; + /* The text string types */ + case 't': + case 'T': + case 'V': + { + const char *str=NULL; + + switch(*(ch+1)) + { + case 't': /* e.g. "jpg" */ + str=image_type_to_string(args->imagetype,0); + break; + + case 'T': /* e.g. "image/jpeg" */ + str=image_type_to_string(args->imagetype,2); + break; + + case 'V': /* e.g. "full", "expired", etc. */ + str=args->validity_string; + break; + } + + if(str && idx+strlen(str)attribs,uid->numattribs,pk,NULL); + show_photos(uid->attribs,uid->numattribs,pk,NULL,uid); switch(cpr_get_answer_yes_no_quit("photoid.jpeg.okay", _("Is this photo correct (y/N/q)? "))) { @@ -289,8 +290,10 @@ get_default_photo_command(void) } #endif -void show_photos(const struct user_attribute *attrs, - int count,PKT_public_key *pk,PKT_secret_key *sk) +void +show_photos(const struct user_attribute *attrs, + int count,PKT_public_key *pk,PKT_secret_key *sk, + PKT_user_id *uid) { #ifndef DISABLE_PHOTO_VIEWER int i; @@ -301,6 +304,8 @@ void show_photos(const struct user_attribute *attrs, memset(&args,0,sizeof(args)); args.pk=pk; args.sk=sk; + args.validity_info=get_validity_info(pk,uid); + args.validity_string=get_validity_string(pk,uid); if(pk) keyid_from_pk(pk,kid); diff --git a/g10/photoid.h b/g10/photoid.h index 88da4fb10..58728edac 100644 --- a/g10/photoid.h +++ b/g10/photoid.h @@ -1,5 +1,5 @@ /* photoid.h - * Copyright (C) 2001, 2002 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2005, 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -27,7 +27,7 @@ PKT_user_id *generate_photo_id(PKT_public_key *pk,const char *filename); int parse_image_header(const struct user_attribute *attr,byte *type,u32 *len); char *image_type_to_string(byte type,int style); -void show_photos(const struct user_attribute *attrs, - int count,PKT_public_key *pk,PKT_secret_key *sk); +void show_photos(const struct user_attribute *attrs,int count, + PKT_public_key *pk,PKT_secret_key *sk,PKT_user_id *uid); #endif /* !_PHOTOID_H_ */ diff --git a/g10/pkclist.c b/g10/pkclist.c index 7a809622c..534b59298 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -239,7 +239,8 @@ do_edit_ownertrust (PKT_public_key *pk, int mode, if((opt.verify_options&VERIFY_SHOW_PHOTOS) && un->pkt->pkt.user_id->attrib_data) show_photos(un->pkt->pkt.user_id->attribs, - un->pkt->pkt.user_id->numattribs,pk,NULL); + un->pkt->pkt.user_id->numattribs,pk,NULL, + un->pkt->pkt.user_id); p=utf8_to_native(un->pkt->pkt.user_id->name, un->pkt->pkt.user_id->len,0);