simplifications around mutt_is_message_type
[apps/madmutt.git] / recvattach.c
index d4ebd3d..b76c43a 100644 (file)
@@ -142,7 +142,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m,
       /* We don't support multipart messages in the compose menu yet */
       if (!compose && !m->collapsed
       &&  ((m->type == TYPEMULTIPART && !mutt_is_multipart_encrypted(m))
-      ||  mutt_is_message_type (m->type, m->subtype)))
+      ||  mutt_is_message_type(m)))
       {
         idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
                                     level + 1, compose);
@@ -217,8 +217,8 @@ const char *mutt_attach_fmt (char *dest,
         mutt_format_s (dest, destlen, prefix, aptr->content->description);
         break;
       }
-      if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
-          && MsgFmt && aptr->content->hdr) {
+      if (mutt_is_message_type(aptr->content) && MsgFmt && aptr->content->hdr)
+      {
         char s[SHORT_STRING];
 
         _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
@@ -235,8 +235,7 @@ const char *mutt_attach_fmt (char *dest,
       }
     }
     else if (aptr->content->description ||
-             (mutt_is_message_type
-              (aptr->content->type, aptr->content->subtype)
+             (mutt_is_message_type(aptr->content)
               && MsgFmt && aptr->content->hdr))
       break;
     /* FALLS THROUGH TO 'f' */
@@ -369,16 +368,6 @@ int mutt_tag_attach (MUTTMENU * menu, int n, int m)
   return cur->tagged - ot;
 }
 
-int mutt_is_message_type (int type, const char *subtype)
-{
-  if (type != TYPEMESSAGE)
-    return 0;
-
-  subtype = NONULL (subtype);
-  return (ascii_strcasecmp (subtype, "rfc822") == 0
-          || ascii_strcasecmp (subtype, "news") == 0);
-}
-
 static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
                                        char **directory)
 {
@@ -400,7 +389,7 @@ static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
   else if (body->hdr &&
            body->encoding != ENCBASE64 &&
            body->encoding != ENCQUOTEDPRINTABLE &&
-           mutt_is_message_type (body->type, body->subtype))
+           mutt_is_message_type(body))
     mutt_default_save (buf, sizeof (buf), body->hdr);
   else
     buf[0] = 0;
@@ -435,7 +424,7 @@ static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
                   body->hdr &&
                   body->encoding != ENCBASE64 &&
                   body->encoding != ENCQUOTEDPRINTABLE &&
-                  mutt_is_message_type (body->type, body->subtype));
+                  mutt_is_message_type(body));
 
     if (is_message) {
       struct stat st;
@@ -842,10 +831,9 @@ static void attach_collapse (BODY * b, short collapse, short init,
   for (; b; b = b->next) {
     i = init || b->collapsed;
     if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
-        && !ascii_strcasecmp (b->subtype, "digest"))
+        && mime_which_token(b->subtype, -1) == MIME_DIGEST)
       attach_collapse (b->parts, 1, 1, 0);
-    else if (b->type == TYPEMULTIPART
-             || mutt_is_message_type (b->type, b->subtype))
+    else if (b->type == TYPEMULTIPART || mutt_is_message_type(b))
       attach_collapse (b->parts, collapse, i, 0);
     b->collapsed = collapse;
     if (just_one)
@@ -863,19 +851,6 @@ void mutt_attach_init (BODY * b)
   }
 }
 
-static const char *Function_not_permitted =
-N_("Function not permitted in attach-message mode.");
-
-#define CHECK_ATTACH if(option(OPTATTACHMSG)) \
-                    {\
-                       mutt_flushinp (); \
-                       mutt_error _(Function_not_permitted); \
-                       break; \
-                    }
-
-
-
-
 void mutt_view_attachments (HEADER * hdr)
 {
   int secured = 0;
@@ -966,9 +941,16 @@ void mutt_view_attachments (HEADER * hdr)
   attach_collapse (cur, 0, 1, 0);
   mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
 
+#define CHECK_ATTACH \
+    if (option(OPTATTACHMSG)) {                                         \
+        mutt_flushinp ();                                               \
+        mutt_error _("Function not permitted in attach-message mode."); \
+        break;                                                          \
+    }
+
   for (;;) {
     if (op == OP_NULL)
-      op = mutt_menuLoop (menu);
+      op = mutt_menuLoop(menu);
     switch (op) {
     case OP_ATTACH_VIEW_MAILCAP:
       mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
@@ -1228,6 +1210,5 @@ void mutt_view_attachments (HEADER * hdr)
 
     op = OP_NULL;
   }
-
   /* not reached */
 }