OP_CHECK_NEW "check mailboxes for new mail"
OP_COMPOSE_ATTACH_FILE "attach a file(s) to this message"
OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
-OP_COMPOSE_CHANGE_CHARSET "change an attachment's character set"
OP_COMPOSE_EDIT_BCC "edit the BCC list"
OP_COMPOSE_EDIT_CC "edit the CC list"
OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
void mutt_edit_content_type (HEADER *h, BODY *b)
{
char buf[LONG_STRING];
+ char obuf[LONG_STRING];
char tmp[STRING];
PARAMETER *p;
+
+ char charset[STRING];
+ char *cp;
+
+ short charset_changed = 0;
+ short type_changed = 0;
+ cp = mutt_get_parameter ("charset", b->parameter);
+ strfcpy (charset, NONULL (cp), sizeof (charset));
+
snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
+ strfcpy (obuf, buf, sizeof (obuf));
if (b->parameter)
{
size_t l;
FREE (&b->subtype);
mutt_parse_content_type (buf, b);
+
+ /* inform the user */
+
- mutt_message ("Content-Type changed to %s/%s.", TYPE (b),
- NONULL (b->subtype));
+ snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
+ type_changed = mutt_strcmp (tmp, obuf);
+ charset_changed = mutt_strcmp (charset, mutt_get_parameter ("charset", b->parameter));
+
+ if (type_changed)
+ mutt_message (_("Content-Type changed to %s."), tmp);
+ else if (b->type == TYPETEXT && charset_changed)
+ mutt_message (_("Character set changed to %s."),
+ mutt_get_parameter ("charset", b->parameter));
+
+ b->force_charset |= charset_changed;
if (!is_multipart (b) && b->parts)
mutt_free_body (&b->parts);
return;
}
-static int change_attachment_charset (BODY *b)
-{
- char buff[SHORT_STRING];
- iconv_t cd;
-
- if (!mutt_is_text_type (b->type, b->subtype))
- {
- mutt_error _("Can't change character set for non-text attachments!");
- return 0;
- }
-
- mutt_get_send_charset (buff, sizeof(buff), b, 0);
-
- if (mutt_get_field (_("Enter character set: "), buff, sizeof(buff), 0) == -1)
- return 0;
-
- if ((cd = mutt_iconv_open (buff, "us-ascii")) == (iconv_t)-1)
- {
- mutt_error (_("Character set %s is unknown."), buff);
- return 0;
- }
- else
- iconv_close (cd);
-
- mutt_set_body_charset (b, buff);
- return REDRAW_CURRENT;
-}
/*
* cum_attachs_size: Cumulative Attachments Size
menu->redraw |= REDRAW_STATUS;
break;
- case OP_COMPOSE_CHANGE_CHARSET:
- CHECK_COUNT;
- menu->redraw = change_attachment_charset(idx[menu->current]->content);
- break;
-
#define CURRENT idx[menu->current]->content
case OP_COMPOSE_TOGGLE_RECODE:
struct binding_t OpCompose[] = {
{ "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
{ "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
- { "change-charset", OP_COMPOSE_CHANGE_CHARSET, NULL },
{ "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
{ "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
{ "copy-file", OP_SAVE, "C" },
*/
unsigned int tagged : 1;
unsigned int deleted : 1; /* attachment marked for deletion */
+
unsigned int noconv : 1; /* don't do character set conversion */
+ unsigned int force_charset : 1;
+ /* send mode: don't adjust the character
+ * set when in send-mode.
+ */
#ifdef HAVE_PGP
unsigned int goodsig : 1; /* good PGP signature */
#endif
+
} BODY;
typedef struct header
CONTENT *info;
/* Previous value is usually wrong, apparently. */
- mutt_set_parameter ("charset", 0, &a->parameter);
+ if (!a->force_charset)
+ mutt_set_parameter ("charset", 0, &a->parameter);
if ((info = mutt_get_content_info (a->filename, a)) == NULL)
return;