diff options
author | David Shaw <[email protected]> | 2005-09-01 20:51:13 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2005-09-01 20:51:13 +0000 |
commit | be8543812d67b47af668d3e72b7515e2f91b0dbe (patch) | |
tree | 9d1eac14802ca684b62d6d0b090ac9005187ab03 /g10/photoid.c | |
parent | * mpicoder.c (mpi_read): Fix minor bug in reading a zero-length MPI (diff) | |
download | gnupg-be8543812d67b47af668d3e72b7515e2f91b0dbe.tar.gz gnupg-be8543812d67b47af668d3e72b7515e2f91b0dbe.zip |
* photoid.h, photoid.c (generate_photo_id): Allow passing in a
suggested filename.
* keyedit.c (keyedit_menu, menu_adduid): Call it here so "addphoto
filename" works.
Diffstat (limited to '')
-rw-r--r-- | g10/photoid.c | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/g10/photoid.c b/g10/photoid.c index 5dd4e436a..885bbca01 100644 --- a/g10/photoid.c +++ b/g10/photoid.c @@ -44,12 +44,12 @@ /* Generate a new photo id packet, or return NULL if canceled */ PKT_user_id * -generate_photo_id(PKT_public_key *pk) +generate_photo_id(PKT_public_key *pk,const char *photo_name) { PKT_user_id *uid; int error=1,i; unsigned int len; - char *filename=NULL; + char *filename; byte *photo=NULL; byte header[16]; IOBUF file; @@ -65,34 +65,43 @@ generate_photo_id(PKT_public_key *pk) #define EXTRA_UID_NAME_SPACE 71 uid=xmalloc_clear(sizeof(*uid)+71); - tty_printf(_("\nPick an image to use for your photo ID. " - "The image must be a JPEG file.\n" - "Remember that the image is stored within your public key. " - "If you use a\n" - "very large picture, your key will become very large as well!\n" - "Keeping the image close to 240x288 is a good size to use.\n")); + if(photo_name && *photo_name) + filename=make_filename(photo_name,(void *)NULL); + else + { + tty_printf(_("\nPick an image to use for your photo ID." + " The image must be a JPEG file.\n" + "Remember that the image is stored within your public key." + " If you use a\n" + "very large picture, your key will become very large" + " as well!\n" + "Keeping the image close to 240x288 is a good size" + " to use.\n")); + filename=NULL; + } while(photo==NULL) { - char *tempname; - - tty_printf("\n"); + if(filename==NULL) + { + char *tempname; - xfree(filename); + tty_printf("\n"); - tty_enable_completion(NULL); + tty_enable_completion(NULL); - tempname=cpr_get("photoid.jpeg.add", - _("Enter JPEG filename for photo ID: ")); + tempname=cpr_get("photoid.jpeg.add", + _("Enter JPEG filename for photo ID: ")); - tty_disable_completion(); + tty_disable_completion(); - filename=make_filename(tempname,(void *)NULL); + filename=make_filename(tempname,(void *)NULL); - xfree(tempname); + xfree(tempname); - if(strlen(filename)==0) - goto scram; + if(strlen(filename)==0) + goto scram; + } file=iobuf_open(filename); if (file && is_secured_file (iobuf_get_fd (file))) @@ -105,6 +114,8 @@ generate_photo_id(PKT_public_key *pk) { log_error(_("unable to open JPEG file `%s': %s\n"), filename,strerror(errno)); + xfree(filename); + filename=NULL; continue; } @@ -116,6 +127,8 @@ generate_photo_id(PKT_public_key *pk) _("Are you sure you want to use it? (y/N) "))) { iobuf_close(file); + xfree(filename); + filename=NULL; continue; } } @@ -131,6 +144,8 @@ generate_photo_id(PKT_public_key *pk) log_error(_("`%s' is not a JPEG file\n"),filename); xfree(photo); photo=NULL; + xfree(filename); + filename=NULL; continue; } @@ -153,6 +168,8 @@ generate_photo_id(PKT_public_key *pk) free_attributes(uid); xfree(photo); photo=NULL; + xfree(filename); + filename=NULL; continue; } } |