receive-attachment menus. Mostly by Michael Elkins.
OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
OP_COMPOSE_EDIT_TO "edit the TO list"
-OP_COMPOSE_EDIT_TYPE "edit attachment type"
+OP_EDIT_TYPE "edit attachment content type"
OP_COMPOSE_GET_ATTACHMENT "get a temporary copy of an attachment"
OP_COMPOSE_ISPELL "run ispell on the message"
OP_COMPOSE_NEW_MIME "compose new attachment using mailcap entry"
{
mutt_message ("Mutt %s (%s)", MUTT_VERSION, ReleaseDate);
}
+
+void mutt_edit_content_type (HEADER *h, BODY *b)
+{
+ char buf[LONG_STRING];
+ char tmp[STRING];
+ PARAMETER *p;
+
+ snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
+ if (b->parameter)
+ {
+ size_t l;
+
+ for (p = b->parameter; p; p = p->next)
+ {
+ l = strlen (buf);
+
+ rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
+ snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
+ }
+ }
+
+ if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
+ buf[0] == 0)
+ return;
+
+ /* clean up previous junk */
+ mutt_free_parameter (&b->parameter);
+ FREE (&b->subtype);
+
+ mutt_parse_content_type (buf, b);
+
+ mutt_message ("Content-Type changed to %s/%s.", TYPE (b),
+ NONULL (b->subtype));
+
+ if (!is_multipart (b) && b->parts)
+ mutt_free_body (&b->parts);
+ if (!mutt_is_message_type (b->type, b->subtype) && b->hdr)
+ {
+ b->hdr->content = NULL;
+ mutt_free_header (&b->hdr);
+ }
+
+#ifdef _PGPPATH
+ if (h)
+ {
+ if (h->content == b)
+ h->pgp = 0;
+ h->pgp |= pgp_query (b);
+ }
+#endif /* _PGPPATH */
+
+}
}
break;
- case OP_COMPOSE_EDIT_TYPE:
+ case OP_EDIT_TYPE:
CHECK_COUNT;
- snprintf (buf, sizeof (buf), "%s/%s",
- TYPE (idx[menu->current]->content),
- idx[menu->current]->content->subtype);
- if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) == 0 && buf[0])
- {
- char *s;
- PARAMETER *par;
- BODY *b;
-
- b = idx[menu->current]->content;
-
- s = b->filename; par = b->parameter;
- b->filename = NULL; b->parameter = NULL;
-
- mutt_parse_content_type (buf, b);
-
- safe_free ((void **) &b->filename);
- b->filename = s;
-
- if ((s = mutt_get_parameter("charset", b->parameter)))
- mutt_set_parameter("charset", s, &par);
-
- /* These are needed for "traditional" PGP.
- * Should we switch to a "negative list" instead?
- */
-
- if ((s = mutt_get_parameter("x-action", b->parameter)))
- mutt_set_parameter("x-action", s, &par);
- if ((s = mutt_get_parameter("format", b->parameter)))
- mutt_set_parameter("format", s, &par);
-
- /* ignore the other parameters for now */
- mutt_free_parameter(&b->parameter);
- b->parameter = par;
-
- /* this may have been a "structured" message */
- if (b->parts)
- mutt_free_body (&b->parts);
- if (b->hdr)
- {
- b->hdr->content = NULL;
- mutt_free_header (&b->hdr);
- }
+ {
+ mutt_edit_content_type (NULL, idx[menu->current]->content);
/* this may have been a change to text/something */
- mutt_update_encoding (b);
+ mutt_update_encoding (idx[menu->current]->content);
menu->redraw = REDRAW_CURRENT;
}
}
break;
+ case OP_EDIT_TYPE:
+
+ CHECK_MSGCOUNT;
+ CHECK_ATTACH;
+ mutt_edit_content_type (CURHDR, CURHDR->content);
+ /* if we were in the pager, redisplay the message */
+ if (menu->menu == MENU_PAGER)
+ {
+ op = OP_DISPLAY_MESSAGE;
+ continue;
+ }
+ else
+ menu->redraw = REDRAW_CURRENT;
+ break;
+
case OP_MAIN_NEXT_UNDELETED:
CHECK_MSGCOUNT;
{ "delete-thread", OP_DELETE_THREAD, "\004" },
{ "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
{ "edit", OP_EDIT_MESSAGE, "e" },
+ { "edit-type", OP_EDIT_TYPE, "\005" },
{ "forward-message", OP_FORWARD_MESSAGE, "f" },
{ "flag-message", OP_FLAG_MESSAGE, "F" },
{ "group-reply", OP_GROUP_REPLY, "g" },
{ "delete-thread", OP_DELETE_THREAD, "\004" },
{ "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
{ "edit", OP_EDIT_MESSAGE, "e" },
+ { "edit-type", OP_EDIT_TYPE, "\005" },
{ "forward-message", OP_FORWARD_MESSAGE, "f" },
{ "flag-message", OP_FLAG_MESSAGE, "F" },
{ "group-reply", OP_GROUP_REPLY, "g" },
struct binding_t OpAttach[] = {
{ "bounce-message", OP_BOUNCE_MESSAGE, "b" },
{ "display-headers", OP_DISPLAY_HEADERS, "h" },
+ { "edit-type", OP_EDIT_TYPE, "\005" },
{ "print-entry", OP_PRINT, "p" },
{ "save-entry", OP_SAVE, "s" },
{ "pipe-entry", OP_PIPE, "|" },
{ "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
{ "edit-subject", OP_COMPOSE_EDIT_SUBJECT, "s" },
{ "edit-to", OP_COMPOSE_EDIT_TO, "t" },
- { "edit-type", OP_COMPOSE_EDIT_TYPE, "\024" },
+ { "edit-type", OP_EDIT_TYPE, "\024" },
{ "write-fcc", OP_COMPOSE_WRITE_MESSAGE, "w" },
{ "recode-attachment",OP_COMPOSE_RECODE, NULL },
{ "toggle-unlink", OP_COMPOSE_TOGGLE_UNLINK, "u" },
void mutt_decode_attachment (BODY *, STATE *);
void mutt_default_save (char *, size_t, HEADER *);
void mutt_display_address (ENVELOPE *);
+void mutt_edit_content_type (HEADER *, BODY *);
void mutt_edit_file (const char *, const char *);
void mutt_edit_headers (const char *, const char *, HEADER *, char *, size_t);
void mutt_curses_error (const char *, ...);
else
op = OP_NULL;
break;
+ case OP_EDIT_TYPE:
+ /* when we edit the content-type, we should redisplay the attachment
+ immediately */
+ mutt_edit_content_type (hdr, idx[menu->current]->content);
+ op = OP_VIEW_ATTACH;
+ break;
default:
op = OP_NULL;
}
menu->redraw = REDRAW_FULL;
break;
+ case OP_EDIT_TYPE:
+ mutt_edit_content_type (hdr, idx[menu->current]->content);
+ menu->redraw = REDRAW_CURRENT;
+ break;
+
case OP_EXIT:
mx_close_message (&msg);
hdr->attach_del = 0;
-
-
-
-
-
-
-
-
#ifdef _PGPPATH
if (pgp)
{