]> granicus.if.org Git - mutt/commitdiff
Fix inconsistencies between printing and displaying of
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 26 Sep 2001 10:33:09 +0000 (10:33 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 26 Sep 2001 10:33:09 +0000 (10:33 +0000)
message/rfc822 body parts.

attach.c
commands.c
copy.c
copy.h
handler.c
mutt.h
recvattach.c

index 2cccafbb2ad6122509aa33fc9a282e9f5c147bc1..d68e5220d68654f5f62275b3043ffa1e3b4ce613 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -543,7 +543,7 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
       /* Use built-in handler */
       set_option (OPTVIEWATTACH); /* disable the "use 'v' to view this part"
                                   * message in case of error */
-      if (mutt_decode_save_attachment (fp, a, pagerfile, 1, 0))
+      if (mutt_decode_save_attachment (fp, a, pagerfile, M_DISPLAY, 0))
       {
        unset_option (OPTVIEWATTACH);
        goto return_error;
@@ -801,7 +801,7 @@ int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path,
   HEADER *saved_hdr = NULL;
 
   memset (&s, 0, sizeof (s));
-  s.flags = (displaying ? M_DISPLAY : 0);
+  s.flags = displaying;
 
   if (flags == M_SAVE_APPEND)
     s.fpout = fopen (path, "a");
@@ -981,7 +981,7 @@ int mutt_print_attachment (FILE *fp, BODY *a)
     fpout = NULL;
     
     mutt_mktemp (newfile);
-    if (mutt_decode_save_attachment (fp, a, newfile, 0, 0) == 0)
+    if (mutt_decode_save_attachment (fp, a, newfile, M_PRINTING, 0) == 0)
     {
       
       dprint (2, (debugfile, "successfully decoded %s type attachment to %s\n",
index d11f81f80842f5ead4f321b78cceabe1ce94a230..0880cc4b6ed25b840440373b725d4971b644e1b4 100644 (file)
@@ -256,7 +256,7 @@ void ci_bounce_message (HEADER *h, int *redraw)
   mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
 }
 
-static void pipe_set_flags (int decode, int *cmflags, int *chflags)
+static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
 {
   if (decode)
   {
@@ -269,14 +269,18 @@ static void pipe_set_flags (int decode, int *cmflags, int *chflags)
       *cmflags |= M_CM_WEED;
     }
   }
+  
+  if (print)
+    *cmflags |= M_CM_PRINTING;
+  
 }
 
-void pipe_msg (HEADER *h, FILE *fp, int decode)
+void pipe_msg (HEADER *h, FILE *fp, int decode, int print)
 {
   int cmflags = 0;
   int chflags = CH_FROM;
   
-  pipe_set_flags (decode, &cmflags, &chflags);
+  pipe_set_flags (decode, print, &cmflags, &chflags);
 
 #ifdef HAVE_PGP
   
@@ -299,9 +303,10 @@ void pipe_msg (HEADER *h, FILE *fp, int decode)
 /* the following code is shared between printing and piping */
 
 static int _mutt_pipe_message (HEADER *h, char *cmd,
-                       int decode,
-                       int split,
-                       char *sep)
+                              int decode,
+                              int print,
+                              int split,
+                              char *sep)
 {
   
   int i, rc = 0;
@@ -330,7 +335,7 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
       return 1;
     }
       
-    pipe_msg (h, fpout, decode);
+    pipe_msg (h, fpout, decode, print);
     safe_fclose (&fpout);
     rc = mutt_wait_filter (thepid);
   }
@@ -368,7 +373,7 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
            mutt_perror _("Can't create filter process");
            return 1;
          }
-          pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode);
+          pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
           /* add the message separator */
           if (sep)  fputs (sep, fpout);
          safe_fclose (&fpout);
@@ -390,7 +395,7 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
         if (Context->hdrs[Context->v2r[i]]->tagged)
         {
          mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
-          pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode);
+          pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
           /* add the message separator */
           if (sep) fputs (sep, fpout);
         }
@@ -418,6 +423,7 @@ void mutt_pipe_message (HEADER *h)
   mutt_expand_path (buffer, sizeof (buffer));
   _mutt_pipe_message (h, buffer,
                      option (OPTPIPEDECODE),
+                     0, 
                      option (OPTPIPESPLIT),
                      PipeSep);
 }
@@ -438,6 +444,7 @@ void mutt_print_message (HEADER *h)
 
   if (_mutt_pipe_message (h, PrintCmd,
                          option (OPTPRINTDECODE),
+                         1,
                          option (OPTPRINTSPLIT),
                          "\f") == 0)
     mutt_message (h ? _("Message printed") : _("Messages printed"));
diff --git a/copy.c b/copy.c
index a650add97fa1328cf385a3d8947a644f7ec98a0e..4b880df05d0329306220c3004abbcaa88f29dadc 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -417,6 +417,7 @@ static int count_delete_lines (FILE *fp, BODY *b, long *length, size_t datelen)
  *     M_CM_PREFIX     quote header and body
  *     M_CM_DECODE     decode message body to text/plain
  *     M_CM_DISPLAY    displaying output to the user
+ *      M_CM_PRINTING   printing the message
  *     M_CM_UPDATE     update structures in memory after syncing
  *     M_CM_DECODE_PGP used for decoding PGP messages
  *     M_CM_CHARCONV   perform character set conversion 
@@ -519,6 +520,8 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
       s.prefix = prefix;
     if (flags & M_CM_DISPLAY)
       s.flags |= M_DISPLAY;
+    if (flags & M_CM_PRINTING)
+      s.flags |= M_PRINTING;
     if (flags & M_CM_WEED)
       s.flags |= M_WEED;
     if (flags & M_CM_CHARCONV)
diff --git a/copy.h b/copy.h
index 8350a21af6df16610b457481badac3a4f032cf01..ccbe550d33bc8ec56696c88988f24607decf6ce0 100644 (file)
--- a/copy.h
+++ b/copy.h
 #define M_CM_UPDATE    (1<<4)  /* update structs on sync */
 #define M_CM_WEED      (1<<5)  /* weed message/rfc822 attachment headers */
 #define M_CM_CHARCONV  (1<<6)  /* perform character set conversions */
+#define M_CM_PRINTING  (1<<7)  /* printing the message - display light */
 
 
 #ifdef HAVE_PGP
-#define M_CM_DECODE_PGP        (1<<7)  /* used for decoding PGP messages */
-#define M_CM_VERIFY    (1<<8)  /* do signature verification */
+#define M_CM_DECODE_PGP        (1<<8)  /* used for decoding PGP messages */
+#define M_CM_VERIFY    (1<<9)  /* do signature verification */
 #endif
 
 
index bfaa867be6a22910620bf98e795353ac20ec7c86..35fa5cc803796eba586d213fced1ea386ba17072 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1325,7 +1325,7 @@ void message_handler (BODY *a, STATE *s)
   if (b->parts)
   {
     mutt_copy_hdr (s->fpin, s->fpout, off_start, b->parts->offset,
-       (((s->flags & M_WEED) || ((s->flags & M_DISPLAY) && option (OPTWEED))) ? (CH_WEED | CH_REORDER) : 0) |
+       (((s->flags & M_WEED) || ((s->flags & (M_DISPLAY|M_PRINTING)) && option (OPTWEED))) ? (CH_WEED | CH_REORDER) : 0) |
        (s->prefix ? CH_PREFIX : 0) | CH_DECODE | CH_FROM, s->prefix);
 
     if (s->prefix)
@@ -1596,7 +1596,7 @@ static void external_body_handler (BODY *b, STATE *s)
 
   if (!ascii_strcasecmp (access_type, "x-mutt-deleted"))
   {
-    if (s->flags & M_DISPLAY)
+    if (s->flags & (M_DISPLAY|M_PRINTING))
     {
       char *length;
       char pretty_size[10];
diff --git a/mutt.h b/mutt.h
index 1fceba1455a0eb41b117bbe1e42a1c4192d86c4f..40d36520905dbef5f83ccd1609af44233f9e08b2 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -777,6 +777,7 @@ typedef struct
 #define M_PENDINGPREFIX (1<<2) /* prefix to write, but character must follow */
 #define M_WEED          (1<<3) /* weed headers even when not in display mode */
 #define M_CHARCONV     (1<<4) /* Do character set conversions */
+#define M_PRINTING     (1<<5) /* are we printing? - M_DISPLAY "light" */
 
 #define state_set_prefix(s) ((s)->flags |= M_PENDINGPREFIX)
 #define state_reset_prefix(s) ((s)->flags &= ~M_PENDINGPREFIX)
index 6039f48f5f889e0b5390f1e82e13d356d93cfd45..b1c0ccd19cdef051b2cbac4d38c4e2a68ab05dd8 100644 (file)
@@ -645,7 +645,7 @@ static void print_attachment_list (FILE *fp, int tag, BODY *top, STATE *state)
          FILE *ifp;
 
          mutt_mktemp (newfile);
-         if (mutt_decode_save_attachment (fp, top, newfile, 0, 0) == 0)
+         if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) == 0)
          {
            if ((ifp = fopen (newfile, "r")) != NULL)
            {