* 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.
This commit is contained in:
David Shaw 2008-10-03 20:00:46 +00:00
parent af7c1fa134
commit 1b86ee9806
9 changed files with 74 additions and 34 deletions

View File

@ -1,3 +1,12 @@
2008-10-03 David Shaw <dshaw@jabberwocky.com>
* 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-29 Werner Koch <wk@g10code.com>
* gpg.c (main): Remove -sat kludge. Note that we printed a

View File

@ -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.
*
@ -5103,7 +5103,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);
}
}
}

View File

@ -1,6 +1,6 @@
/* keylist.c - print keys
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
* 2004, 2005, 2008 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.
*
@ -882,7 +882,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 )
{

View File

@ -1,6 +1,6 @@
/* main.h
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
* 2006 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.
*
@ -101,6 +101,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);

View File

@ -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.
*
@ -1826,7 +1826,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,

View File

@ -1,6 +1,6 @@
/* misc.c - miscellaneous functions
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
* 2005, 2006, 2007, 2008 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.
*
@ -550,8 +550,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 */
@ -660,22 +658,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)<maxlen)
case 'v': /* validity letters */
if(args->validity_info && idx+1<maxlen)
{
strcpy(&ret[idx],str);
idx+=strlen(str);
ret[idx++]=args->validity_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)<maxlen)
{
strcpy(&ret[idx],str);
idx+=strlen(str);
done=1;
}
}
break;
case '%':
if(idx+1<maxlen)
{

View File

@ -1,5 +1,5 @@
/* photoid.c - photo ID handling code
* Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
* Copyright (C) 2001, 2002, 2005, 2006, 2008 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -40,6 +40,7 @@
#include "main.h"
#include "photoid.h"
#include "ttyio.h"
#include "trustdb.h"
/* Generate a new photo id packet, or return NULL if canceled */
PKT_user_id *
@ -159,7 +160,7 @@ generate_photo_id(PKT_public_key *pk,const char *photo_name)
"user" may not be able to dismiss a viewer window! */
if(opt.command_fd==-1)
{
show_photos(uid->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)? ")))
{
@ -282,8 +283,10 @@ static const char *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;
@ -294,6 +297,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);

View File

@ -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_ */

View File

@ -236,7 +236,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);