]> granicus.if.org Git - mutt/commitdiff
patch-1.3.3.tlr.change_charset.1
authorThomas Roessler <roessler@does-not-exist.org>
Fri, 16 Jun 2000 10:21:34 +0000 (10:21 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Fri, 16 Jun 2000 10:21:34 +0000 (10:21 +0000)
OPS
commands.c
compose.c
functions.h
mutt.h
sendlib.c

diff --git a/OPS b/OPS
index e4e6be1656253e636755c05bb78392efd08641b8..2e027983e3748c88b3fb2e66c3e496ab78486d5b 100644 (file)
--- 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"
index 1469a4fcd1ee60d728f8d042c3f4131976e35dff..1ab8586d08f5a5b83df0b980f8cb6c2401961641 100644 (file)
@@ -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);
index 18a5a824179be752fedbcc480d0e791667e90d38..62231d52e89a65f03885fc4fdff13ce798d9191f 100644 (file)
--- 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:
index 9f44e577f0ec134085208be1f19a8b3fa41c3537..60d2fc3e56f6ac83fe1a498ef9cc8a5f7e6d6dcb 100644 (file)
@@ -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 f214dcba3ae273a873dba8833187db503eda4f10..41c11b15138fbcebed80c643a0b29add36da4084 100644 (file)
--- 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
index 7af7204150d9f27fdab29699c6b83ae2bbdf2fbc..c91ed34ae45a2c2919bc84237deb3504bc7e78b2 100644 (file)
--- 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;