From 991910c8d3f70402713c4955fa4d11630cc6c995 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Fri, 16 Jun 2000 10:21:34 +0000 Subject: [PATCH] patch-1.3.3.tlr.change_charset.1 --- OPS | 1 - commands.c | 27 +++++++++++++++++++++++++-- compose.c | 32 -------------------------------- functions.h | 1 - mutt.h | 6 ++++++ sendlib.c | 3 ++- 6 files changed, 33 insertions(+), 37 deletions(-) diff --git a/OPS b/OPS index e4e6be16..2e027983 100644 --- a/OPS +++ b/OPS @@ -13,7 +13,6 @@ OP_CHANGE_DIRECTORY "change directories" 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" diff --git a/commands.c b/commands.c index 1469a4fc..1ab8586d 100644 --- a/commands.c +++ b/commands.c @@ -785,10 +785,21 @@ void mutt_version (void) 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; @@ -811,9 +822,21 @@ void mutt_edit_content_type (HEADER *h, BODY *b) 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); diff --git a/compose.c b/compose.c index 18a5a824..62231d52 100644 --- a/compose.c +++ b/compose.c @@ -386,33 +386,6 @@ static void update_idx (MUTTMENU *menu, ATTACHPTR **idx, short idxlen) 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 @@ -869,11 +842,6 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ 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: diff --git a/functions.h b/functions.h index 9f44e577..60d2fc3e 100644 --- a/functions.h +++ b/functions.h @@ -265,7 +265,6 @@ struct binding_t OpAttach[] = { 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" }, diff --git a/mutt.h b/mutt.h index f214dcba..41c11b15 100644 --- a/mutt.h +++ b/mutt.h @@ -544,12 +544,18 @@ typedef struct body */ 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 diff --git a/sendlib.c b/sendlib.c index 7af72041..c91ed34a 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1238,7 +1238,8 @@ void mutt_update_encoding (BODY *a) 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; -- 2.40.0