X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=show-message.c;h=37252b22b2d05f8d4f01dc47fb9b9f2dabd8cf8d;hb=2e653db38fc38dee92b2ee0564e27921132e7232;hp=c90f310ca3c45b77b412b2ded67239e9e566b4c8;hpb=8b18efe171ef80cbb238a9446137c39908755d2d;p=obsolete%2Fnotmuch-old diff --git a/show-message.c b/show-message.c index c90f310c..37252b22 100644 --- a/show-message.c +++ b/show-message.c @@ -58,7 +58,34 @@ show_message_part (GMimeObject *part, GMimeMultipart *multipart = GMIME_MULTIPART (part); GError* err = NULL; - if (GMIME_IS_MULTIPART_SIGNED (part)) + if (GMIME_IS_MULTIPART_ENCRYPTED (part) && params->decrypt) + { + if ( g_mime_multipart_get_count (multipart) != 2 ) { + /* this violates RFC 3156 section 4, so we won't bother with it. */ + fprintf (stderr, + "Error: %d part(s) for a multipart/encrypted message (should be exactly 2)\n", + g_mime_multipart_get_count (multipart)); + } else { + GMimeMultipartEncrypted *encrypteddata = GMIME_MULTIPART_ENCRYPTED (part); + GMimeObject *decryptedpart = g_mime_multipart_encrypted_decrypt (encrypteddata, params->cryptoctx, &err); + if (decryptedpart) { + if ((selected || state->in_zone) && format->part_encstatus) + format->part_encstatus (1); + const GMimeSignatureValidity *sigvalidity = g_mime_multipart_encrypted_get_signature_validity (encrypteddata); + if (!sigvalidity) + fprintf (stderr, "Failed to verify signed part: %s\n", (err ? err->message : "no error explanation given")); + if ((selected || state->in_zone) && format->part_sigstatus) + format->part_sigstatus (sigvalidity); + /* swap the part with the decrypted part */ + part = decryptedpart; + } else { + fprintf (stderr, "Failed to decrypt part: %s\n", (err ? err->message : "no error explanation given")); + if ((selected || state->in_zone) && format->part_encstatus) + format->part_encstatus (0); + } + } + } + else if (GMIME_IS_MULTIPART_SIGNED (part)) { if ( g_mime_multipart_get_count (multipart) != 2 ) { /* this violates RFC 3156 section 5, so we won't bother with it. */