X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=crypt-gpgme.c;h=23604e85caf350cc9d4b46b0e16a9c1f562b196e;hp=ed847138eb811eba0f038138bc217beb4e67a6bd;hb=48197ec45abcad3e3e07c18e06b2df4bc5098a3f;hpb=ba5e3af4ea19e1d20c80941c077039871ec84258 diff --git a/crypt-gpgme.c b/crypt-gpgme.c index ed84713..23604e8 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -22,9 +22,13 @@ #include "mutt_crypt.h" #include "mutt_menu.h" #include "mutt_curses.h" +#include "ascii.h" +#include "handler.h" +#include "enter.h" #include "mime.h" #include "copy.h" #include "pager.h" +#include "recvattach.h" #include "sort.h" #include "lib/mem.h" @@ -1762,7 +1766,7 @@ static void copy_clearsigned (gpgme_data_t data, STATE * s, char *charset) /* Support for classic_application/pgp */ -void pgp_gpgme_application_handler (BODY * m, STATE * s) +int pgp_gpgme_application_handler (BODY * m, STATE * s) { int needpass = -1, pgp_keyblock = 0; int clearsign = 0; @@ -1771,7 +1775,7 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) char buf[HUGE_STRING]; FILE *pgpout = NULL; - gpgme_error_t err; + gpgme_error_t err = 0; gpgme_data_t armored_data = NULL; short maybe_goodsig = 1; @@ -1982,9 +1986,10 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) if (needpass == -1) { state_attach_puts (_("[-- Error: could not find beginning" " of PGP message! --]\n\n"), s); - return; + return (-1); } debug_print (2, ("Leaving pgp_application_pgp handler\n")); + return (err); } /* @@ -1992,13 +1997,14 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) */ /* MIME handler for pgp/mime encrypted messages. */ -void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) +int pgp_gpgme_encrypted_handler (BODY * a, STATE * s) { char tempfile[_POSIX_PATH_MAX]; FILE *fpout; BODY *tattach; BODY *orig_body = a; int is_signed; + int rc = 0; debug_print (2, ("Entering pgp_encrypted handler\n")); a = a->parts; @@ -2009,7 +2015,7 @@ void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"), s); - return; + return (-1); } /* Move forward to the application/pgp-encrypted body. */ @@ -2020,7 +2026,7 @@ void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (_("[-- Error: could not create temporary file! " "--]\n"), s); - return; + return (-1); } tattach = decrypt_part (a, s, fpout, 0, &is_signed); @@ -2030,17 +2036,14 @@ void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (is_signed ? _ - ("[-- The following data is PGP/MIME signed and encrypted --]\n\n") - : - _ - ("[-- The following data is PGP/MIME encrypted --]\n\n"), - s); + ("[-- The following data is PGP/MIME signed and encrypted --]\n\n") : + _("[-- The following data is PGP/MIME encrypted --]\n\n"), s); { FILE *savefp = s->fpin; s->fpin = fpout; - mutt_body_handler (tattach, s); + rc = mutt_body_handler (tattach, s); s->fpin = savefp; } @@ -2066,16 +2069,17 @@ void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) fclose (fpout); mutt_unlink (tempfile); debug_print (2, ("Leaving pgp_encrypted handler\n")); + return (rc); } /* Support for application/smime */ -void smime_gpgme_application_handler (BODY * a, STATE * s) +int smime_gpgme_application_handler (BODY * a, STATE * s) { char tempfile[_POSIX_PATH_MAX]; FILE *fpout; BODY *tattach; int is_signed; - + int rc = 0; debug_print (2, ("Entering smime_encrypted handler\n")); @@ -2085,7 +2089,7 @@ void smime_gpgme_application_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (_("[-- Error: could not create temporary file! " "--]\n"), s); - return; + return (-1); } tattach = decrypt_part (a, s, fpout, 1, &is_signed); @@ -2094,17 +2098,14 @@ void smime_gpgme_application_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (is_signed ? - _("[-- The following data is S/MIME signed --]\n\n") - : - _ - ("[-- The following data is S/MIME encrypted --]\n\n"), - s); + _("[-- The following data is S/MIME signed --]\n\n") : + _("[-- The following data is S/MIME encrypted --]\n\n"), s); { FILE *savefp = s->fpin; s->fpin = fpout; - mutt_body_handler (tattach, s); + rc = mutt_body_handler (tattach, s); s->fpin = savefp; } @@ -2135,6 +2136,7 @@ void smime_gpgme_application_handler (BODY * a, STATE * s) fclose (fpout); mutt_unlink (tempfile); debug_print (2, ("Leaving smime_encrypted handler\n")); + return (rc); } @@ -2753,7 +2755,8 @@ static void print_key_info (gpgme_key_t key, FILE * fp) continue; s = uid->uid; - fprintf (fp, "%s ......: ", idx ? _(" aka") : _("Name")); + fputs (idx ? _(" aka ......: ") :_("Name ......: "), fp); + if (uid->invalid) { fputs (_("[Invalid]"), fp); putc (' ', fp); @@ -2774,7 +2777,7 @@ static void print_key_info (gpgme_key_t key, FILE * fp) #else strftime (shortbuf, sizeof shortbuf, "%c", tm); #endif - fprintf (fp, "Valid From : %s\n", shortbuf); + fprintf (fp, _("Valid From : %s\n"), shortbuf); } if (key->subkeys && (key->subkeys->expires > 0)) { @@ -2786,7 +2789,7 @@ static void print_key_info (gpgme_key_t key, FILE * fp) #else strftime (shortbuf, sizeof shortbuf, "%c", tm); #endif - fprintf (fp, "Valid To ..: %s\n", shortbuf); + fprintf (fp, _("Valid To ..: %s\n"), shortbuf); } if (key->subkeys) @@ -2799,22 +2802,22 @@ static void print_key_info (gpgme_key_t key, FILE * fp) if (key->subkeys) aval = key->subkeys->length; - fprintf (fp, "Key Type ..: %s, %lu bit %s\n", s2, aval, s); + fprintf (fp, _("Key Type ..: %s, %lu bit %s\n"), s2, aval, s); - fprintf (fp, "Key Usage .: "); + fprintf (fp, _("Key Usage .: ")); delim = ""; if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT)) { fprintf (fp, "%s%s", delim, _("encryption")); - delim = ", "; + delim = _(", "); } if (key_check_cap (key, KEY_CAP_CAN_SIGN)) { fprintf (fp, "%s%s", delim, _("signing")); - delim = ", "; + delim = _(", "); } if (key_check_cap (key, KEY_CAP_CAN_CERTIFY)) { fprintf (fp, "%s%s", delim, _("certification")); - delim = ", "; + delim = _(", "); } putc ('\n', fp); @@ -2847,13 +2850,13 @@ static void print_key_info (gpgme_key_t key, FILE * fp) if (key->issuer_serial) { s = key->issuer_serial; if (s) - fprintf (fp, "Serial-No .: 0x%s\n", s); + fprintf (fp, _("Serial-No .: 0x%s\n"), s); } if (key->issuer_name) { s = key->issuer_name; if (s) { - fprintf (fp, "Issued By .: "); + fprintf (fp, _("Issued By .: ")); parse_and_print_user_id (fp, s); putc ('\n', fp); } @@ -2869,7 +2872,7 @@ static void print_key_info (gpgme_key_t key, FILE * fp) putc ('\n', fp); if (str_len (s) == 16) s += 8; /* display only the short keyID */ - fprintf (fp, "Subkey ....: 0x%s", s); + fprintf (fp, _("Subkey ....: 0x%s"), s); if (subkey->revoked) { putc (' ', fp); fputs (_("[Revoked]"), fp); @@ -2897,7 +2900,7 @@ static void print_key_info (gpgme_key_t key, FILE * fp) #else strftime (shortbuf, sizeof shortbuf, "%c", tm); #endif - fprintf (fp, "Valid From : %s\n", shortbuf); + fprintf (fp, _("Valid From : %s\n"), shortbuf); } if (subkey->expires > 0) { @@ -2909,7 +2912,7 @@ static void print_key_info (gpgme_key_t key, FILE * fp) #else strftime (shortbuf, sizeof shortbuf, "%c", tm); #endif - fprintf (fp, "Valid To ..: %s\n", shortbuf); + fprintf (fp, _("Valid To ..: %s\n"), shortbuf); } if (subkey) @@ -2922,22 +2925,22 @@ static void print_key_info (gpgme_key_t key, FILE * fp) else aval = 0; - fprintf (fp, "Key Type ..: %s, %lu bit %s\n", "PGP", aval, s); + fprintf (fp, _("Key Type ..: %s, %lu bit %s\n"), "PGP", aval, s); - fprintf (fp, "Key Usage .: "); + fprintf (fp, _("Key Usage .: ")); delim = ""; if (subkey->can_encrypt) { fprintf (fp, "%s%s", delim, _("encryption")); - delim = ", "; + delim = _(", "); } if (subkey->can_sign) { fprintf (fp, "%s%s", delim, _("signing")); - delim = ", "; + delim = _(", "); } if (subkey->can_certify) { fprintf (fp, "%s%s", delim, _("certification")); - delim = ", "; + delim = _(", "); } putc ('\n', fp); }