old-style PGP messages and/or parts more easily.
OP_VIEW_ID "view the key's user id"
OP_DECRYPT_SAVE "make decrypted copy and delete"
OP_DECRYPT_COPY "make decrypted copy"
+OP_CHECK_TRADITIONAL "check for classic pgp"
#endif /* HAVE_PGP */
}
+
+
+#ifdef HAVE_PGP
+
+static int _mutt_check_traditional_pgp (HEADER *h, int *redraw)
+{
+ MESSAGE *msg;
+ int rv = 0;
+
+ mutt_parse_mime_message (Context, h);
+ if ((msg = mx_open_message (Context, h->msgno)) == NULL)
+ return 0;
+ if (pgp_check_traditional (msg->fp, h->content, 0))
+ {
+ h->pgp = pgp_query (h->content);
+ *redraw |= REDRAW_FULL;
+ rv = 1;
+ }
+
+ mx_close_message (&msg);
+ return rv;
+}
+
+int mutt_check_traditional_pgp (HEADER *h, int *redraw)
+{
+ int i;
+ int rv = 0;
+ if (h)
+ rv = _mutt_check_traditional_pgp (h, redraw);
+ else
+ {
+ for (i = 0; i < Context->vcount; i++)
+ if (Context->hdrs[Context->v2r[i]]->tagged)
+ rv = _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)
+ || rv;
+ }
+ return rv;
+}
+
+#endif
pgp_extract_keys_from_messages(tag ? NULL : CURHDR);
menu->redraw = REDRAW_FULL;
break;
+
+ case OP_CHECK_TRADITIONAL:
+
+ CHECK_MSGCOUNT;
+ mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
+ if (menu->menu == MENU_PAGER)
+ {
+ op = OP_DISPLAY_MESSAGE;
+ continue;
+ }
+ break;
#endif /* HAVE_PGP */
#ifdef HAVE_PGP
+ { "check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P" },
{ "extract-keys", OP_EXTRACT_KEYS, "\013" },
{ "forget-passphrase", OP_FORGET_PASSPHRASE, "\006" },
{ "mail-key", OP_MAIL_KEY, "\033k" },
#ifdef HAVE_PGP
+ { "check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P" },
{ "extract-keys", OP_EXTRACT_KEYS, "\013" },
{ "forget-passphrase",OP_FORGET_PASSPHRASE, "\006" },
{ "mail-key", OP_MAIL_KEY, "\033k" },
#ifdef HAVE_PGP
- { "extract-keys", OP_EXTRACT_KEYS, "\013" },
+ { "check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P" },
+ { "extract-keys", OP_EXTRACT_KEYS, "\013" },
+ { "forget-passphrase", OP_FORGET_PASSPHRASE, "\006" },
#endif
}
+static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
+{
+ char tempfile[_POSIX_PATH_MAX];
+ char buf[HUGE_STRING];
+ FILE *tfp;
+
+ short sgn = 0;
+ short enc = 0;
+
+ if (b->type != TYPETEXT)
+ return 0;
+
+ if (tagged_only && !b->tagged)
+ return 0;
+
+ mutt_mktemp (tempfile);
+ if (mutt_decode_save_attachment (fp, b, tempfile, 0, 0) != 0)
+ {
+ unlink (tempfile);
+ return 0;
+ }
+
+ if ((tfp = fopen (tempfile, "r")) == NULL)
+ {
+ unlink (tempfile);
+ return 0;
+ }
+
+ while (fgets (buf, sizeof (buf), tfp))
+ {
+ if (mutt_strncmp ("-----BEGIN PGP ", buf, 15) == 0)
+ {
+ if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0)
+ enc = 1;
+ else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0)
+ sgn = 1;
+ }
+ }
+
+ safe_fclose (&tfp);
+ unlink (tempfile);
+
+ if (!enc && !sgn)
+ return 0;
+
+ /* fix the content type */
+
+ b->type = TYPEAPPLICATION;
+ mutt_str_replace (&b->subtype, "pgp");
+
+ mutt_set_parameter ("format", "text", &b->parameter);
+ mutt_set_parameter ("x-action", enc ? "encrypt" : "sign", &b->parameter);
+
+ return 1;
+}
+
+int pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
+{
+ int rv = 0;
+ for (; b; b = b->next)
+ {
+ if (is_multipart (b))
+ rv = pgp_check_traditional (fp, b->parts, tagged_only) || rv;
+ else if (b->type == TYPETEXT)
+ rv = pgp_check_traditional_one_body (fp, b, tagged_only) || rv;
+ }
+
+ return rv;
+}
+
int mutt_is_multipart_signed (BODY *b)
{
char *p;
/* prototypes */
+int pgp_check_traditional (FILE *, BODY *, int);
BODY *pgp_decrypt_part (BODY *, STATE *, FILE *);
BODY *pgp_make_key_attachment (char *);
const char *pgp_micalg (const char *fname);
int mutt_check_mime_type (const char *);
int mutt_check_month (const char *);
int mutt_check_overwrite (const char *, const char *, char *, size_t, int *);
+int mutt_check_traditional_pgp (HEADER *, int *);
int mutt_command_complete (char *, size_t, int, int);
int mutt_var_value_complete (char *, size_t, int);
int mutt_complete (char *, size_t);
}
op = OP_VIEW_ATTACH;
break;
+ /* functions which are passed through from the pager */
case OP_ATTACH_COLLAPSE:
+ case OP_CHECK_TRADITIONAL:
if (recv)
return op;
default:
short idxlen = 0;
short idxmax = 0;
int flags = 0;
- int op;
+ int op = OP_NULL;
/* make sure we have parsed this message */
mutt_parse_mime_message (Context, hdr);
FOREVER
{
- switch (op = mutt_menuLoop (menu))
+ if (op == OP_NULL)
+ op = mutt_menuLoop (menu);
+ switch (op)
{
case OP_ATTACH_VIEW_MAILCAP:
mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
case OP_VIEW_ATTACH:
op = mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen, &idxmax, 1);
menu->redraw = REDRAW_FULL;
- if (op != OP_ATTACH_COLLAPSE)
- break;
- if (!idx[menu->current]->content->collapsed)
- break;
- /* else fall through - hack! */
+ continue;
+
case OP_ATTACH_COLLAPSE:
if (!idx[menu->current]->content->parts)
{
#ifdef HAVE_PGP
+ case OP_FORGET_PASSPHRASE:
+ mutt_forget_passphrase ();
+ break;
+
case OP_EXTRACT_KEYS:
pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
menu->tagprefix ? cur : idx[menu->current]->content);
menu->redraw = REDRAW_FULL;
break;
+
+ case OP_CHECK_TRADITIONAL:
+ if (pgp_check_traditional (fp, menu->tagprefix ? cur : idx[menu->current]->content,
+ menu->tagprefix))
+ {
+ hdr->pgp = pgp_query (cur);
+ menu->redraw = REDRAW_FULL;
+ }
+ break;
#endif
mutt_menuDestroy (&menu);
return;
}
+
+ op = OP_NULL;
}
/* not reached */