mutt_message ("Mutt %s (%s)", MUTT_VERSION, ReleaseDate);
}
-void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
+/*
+ * Returns:
+ * 1 when a structural change is made.
+ * recvattach requires this to know when to regenerate the actx.
+ * 0 otherwise.
+ */
+int mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
{
char buf[LONG_STRING];
char obuf[LONG_STRING];
short charset_changed = 0;
short type_changed = 0;
+ short structure_changed = 0;
cp = mutt_get_parameter ("charset", b->parameter);
strfcpy (charset, NONULL (cp), sizeof (charset));
if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
buf[0] == 0)
- return;
+ return 0;
/* clean up previous junk */
mutt_free_parameter (&b->parameter);
b->force_charset |= charset_changed ? 1 : 0;
if (!is_multipart (b) && b->parts)
+ {
+ structure_changed = 1;
mutt_free_body (&b->parts);
+ }
if (!mutt_is_message_type (b->type, b->subtype) && b->hdr)
{
+ structure_changed = 1;
b->hdr->content = NULL;
mutt_free_header (&b->hdr);
}
- if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
+ if (fp && !b->parts && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
+ {
+ structure_changed = 1;
mutt_parse_part (fp, b);
+ }
if (WithCrypto && h)
{
h->security |= crypt_query (b);
}
+
+ return structure_changed;
}
void mutt_default_save (char *, size_t, HEADER *);
void mutt_display_address (ENVELOPE *);
void mutt_display_sanitize (char *);
-void mutt_edit_content_type (HEADER *, BODY *, FILE *);
+int mutt_edit_content_type (HEADER *, BODY *, FILE *);
void mutt_edit_file (const char *, const char *);
void mutt_edit_headers (const char *, const char *, HEADER *, char *, size_t);
char **mutt_envlist (void);
return rv;
}
+static void recvattach_edit_content_type (ATTACH_CONTEXT *actx, MUTTMENU *menu, HEADER *hdr)
+{
+ int i;
+
+ if (mutt_edit_content_type (hdr, CURATTACH->content, CURATTACH->fp) == 1)
+ {
+ /* The mutt_update_recvattach_menu() will overwrite any changes
+ * made to a decrypted CURATTACH->content, so warn the user. */
+ if (CURATTACH->decrypted)
+ {
+ mutt_message _("Structural changes to decrypted attachments are not supported");
+ mutt_sleep (1);
+ }
+ /* Editing the content type can rewrite the body structure. */
+ for (i = 0; i < actx->idxlen; i++)
+ actx->idx[i]->content = NULL;
+ mutt_actx_free_entries (actx);
+ mutt_update_recvattach_menu (actx, menu, 1);
+ }
+}
+
int
mutt_attach_display_loop (MUTTMENU *menu, int op, HEADER *hdr,
ATTACH_CONTEXT *actx, int recv)
{
- int i;
-
do
{
switch (op)
case OP_EDIT_TYPE:
/* when we edit the content-type, we should redisplay the attachment
immediately */
- mutt_edit_content_type (hdr, CURATTACH->content, CURATTACH->fp);
if (recv)
- {
- /* Editing the content type can rewrite the body structure. */
- for (i = 0; i < actx->idxlen; i++)
- actx->idx[i]->content = NULL;
- mutt_actx_free_entries (actx);
- mutt_update_recvattach_menu (actx, menu, 1);
- }
+ recvattach_edit_content_type (actx, menu, hdr);
+ else
+ mutt_edit_content_type (hdr, CURATTACH->content, CURATTACH->fp);
+
+ menu->redraw |= REDRAW_INDEX;
op = OP_VIEW_ATTACH;
break;
/* functions which are passed through from the pager */
MUTTMENU *menu;
BODY *cur = NULL;
MESSAGE *msg;
- FILE *fp;
ATTACH_CONTEXT *actx;
int flags = 0;
int op = OP_NULL;
break;
case OP_EDIT_TYPE:
- mutt_edit_content_type (hdr, CURATTACH->content, fp);
- /* Editing the content type can rewrite the body structure. */
- for (i = 0; i < actx->idxlen; i++)
- actx->idx[i]->content = NULL;
- mutt_actx_free_entries (actx);
- mutt_update_recvattach_menu (actx, menu, 1);
+ recvattach_edit_content_type (actx, menu, hdr);
+ menu->redraw |= REDRAW_INDEX;
break;
case OP_EXIT: