]> granicus.if.org Git - mutt/commitdiff
Make sure edit-type works without a segmentation fault from the
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 27 Nov 2000 13:14:28 +0000 (13:14 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 27 Nov 2000 13:14:28 +0000 (13:14 +0000)
receive-attach menu.

attach.h
commands.c
compose.c
curs_main.c
protos.h
recvattach.c

index 4743a278ebd847559e113eefee85525e0c54a505..c356130601cde018c3603daa3497c58ecff65fce 100644 (file)
--- a/attach.h
+++ b/attach.h
@@ -24,7 +24,7 @@ void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr);
 void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter);
 void mutt_print_attachment_list (FILE *fp, int tag, BODY *top);
 void mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
-                              ATTACHPTR **idx, short idxlen);
+                              BODY *cur, ATTACHPTR **idx, short *idxlen, short *idxmax);
 
 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
index cdf50da1e863c916dd30d592ab47855cd5cf7869..4ca832b508c9b35743c26b2671b62342a69ef1f7 100644 (file)
@@ -770,7 +770,7 @@ void mutt_version (void)
   mutt_message ("Mutt %s (%s)", MUTT_VERSION, ReleaseDate);
 }
 
-void mutt_edit_content_type (HEADER *h, BODY *b)
+void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
 {
   char buf[LONG_STRING];
   char obuf[LONG_STRING];
@@ -834,6 +834,9 @@ void mutt_edit_content_type (HEADER *h, BODY *b)
     mutt_free_header (&b->hdr);
   }
 
+  if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
+    mutt_parse_part (fp, b);
+  
 #ifdef HAVE_PGP
   if (h)
   {
index a82ddc5acab7ac51afe8c8c89da5e59692f3f89a..c43fa3219b1fe03ce3789f5bd24bdde621b59de1 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -906,7 +906,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
       case OP_EDIT_TYPE:
        CHECK_COUNT;
         {
-         mutt_edit_content_type (NULL, idx[menu->current]->content);
+         mutt_edit_content_type (NULL, idx[menu->current]->content, NULL);
 
          /* this may have been a change to text/something */
          mutt_update_encoding (idx[menu->current]->content);
@@ -1112,7 +1112,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
       case OP_VIEW_ATTACH:
       case OP_DISPLAY_HEADERS:
        CHECK_COUNT;
-       mutt_attach_display_loop (menu, op, NULL, NULL, idx, idxlen);
+       mutt_attach_display_loop (menu, op, NULL, NULL, NULL, idx, &idxlen, NULL);
        menu->redraw = REDRAW_FULL;
        break;
 
index 34e55b53ce1fa44598712a69a1463bb129524ef6..6e6816a5be43678aa6679d767a73a3d602cb778d 100644 (file)
@@ -1054,7 +1054,7 @@ int mutt_index_menu (void)
 
        CHECK_MSGCOUNT;
        CHECK_ATTACH;
-       mutt_edit_content_type (CURHDR, CURHDR->content);
+       mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
        /* if we were in the pager, redisplay the message */
        if (menu->menu == MENU_PAGER)
        {
index f254ecf669df5c42daf0c1e8ad634d988a46fee8..02d047b2e61a0dddce25206a1835c201469f5c6b 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -151,7 +151,7 @@ void mutt_decode_attachment (BODY *, STATE *);
 void mutt_default_save (char *, size_t, HEADER *);
 void mutt_display_address (ENVELOPE *);
 void mutt_display_sanitize (char *);
-void mutt_edit_content_type (HEADER *, BODY *);
+void mutt_edit_content_type (HEADER *, BODY *, FILE *);
 void mutt_edit_file (const char *, const char *);
 void mutt_edit_headers (const char *, const char *, HEADER *, char *, size_t);
 void mutt_curses_error (const char *, ...);
index 1c99d2c0bd7ebeda9136fbc401fb2cfc916cf0ac..27c04e4ca76fdaf8c41cb6e8ae8b14c2fd6781fc 100644 (file)
@@ -682,9 +682,28 @@ void mutt_print_attachment_list (FILE *fp, int tag, BODY *top)
     print_attachment_list (fp, tag, top, &state);
 }
 
+ATTACHPTR **mutt_update_attach_index (BODY *cur, ATTACHPTR **idx,
+                                     short *idxlen, short *idxmax,
+                                     MUTTMENU *menu)
+{
+  *idxlen = 0;
+  idx = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
+  
+  menu->max  = *idxlen;
+  menu->data = idx;
+
+  if (menu->current >= menu->max)
+    menu->current = menu->max - 1;
+  menu_check_recenter (menu);
+  menu->redraw |= REDRAW_INDEX;
+  
+  return idx;
+}
+
+
 void
-mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr, 
-                         ATTACHPTR **idx, short idxlen)
+mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
+                         BODY *cur, ATTACHPTR **idx, short *idxlen, short *idxmax)
 {
 #if 0
   int old_optweed = option (OPTWEED);
@@ -701,7 +720,7 @@ mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
 
       case OP_VIEW_ATTACH:
        op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
-                                  hdr, idx, idxlen);
+                                  hdr, idx, *idxlen);
        break;
 
       case OP_NEXT_ENTRY:
@@ -727,8 +746,10 @@ mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
       case OP_EDIT_TYPE:
        /* when we edit the content-type, we should redisplay the attachment
           immediately */
-       mutt_edit_content_type (hdr, idx[menu->current]->content);
-       op = OP_VIEW_ATTACH;
+       mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
+        if (idxmax) 
+         mutt_update_attach_index (cur, idx, idxlen, idxmax, menu);
+        op = OP_VIEW_ATTACH;
        break;
       default:
        op = OP_NULL;
@@ -752,6 +773,8 @@ static const char *Function_not_permitted = N_("Function not permitted in attach
                        break; \
                     }
 
+
+
 void mutt_view_attachments (HEADER *hdr)
 {
 
@@ -807,24 +830,23 @@ void mutt_view_attachments (HEADER *hdr)
     cur = hdr->content;
   }
 
-  idx = mutt_gen_attach_list (cur, -1, idx, &idxlen, &idxmax, 0, 0);
-
   menu = mutt_new_menu ();
-  menu->max = idxlen;
-  menu->make_entry = attach_entry;
-  menu->tag = mutt_tag_attach;
   menu->menu = MENU_ATTACH;
   menu->title = _("Attachments");
-  menu->data = idx;
+  menu->make_entry = attach_entry;
+  menu->tag = mutt_tag_attach;
   menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
 
+
+  idx  = mutt_update_attach_index (cur, idx, &idxlen, &idxmax, menu);
+
   FOREVER
   {
     switch (op = mutt_menuLoop (menu))
     {
       case OP_DISPLAY_HEADERS:
       case OP_VIEW_ATTACH:
-       mutt_attach_display_loop (menu, op, fp, hdr, idx, idxlen);
+       mutt_attach_display_loop (menu, op, fp, hdr, cur, idx, &idxlen, &idxmax);
        menu->redraw = REDRAW_FULL;
        break;
 
@@ -998,8 +1020,8 @@ void mutt_view_attachments (HEADER *hdr)
        break;
 
       case OP_EDIT_TYPE:
-       mutt_edit_content_type (hdr, idx[menu->current]->content);
-       menu->redraw = REDRAW_CURRENT;
+       mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
+        mutt_update_attach_index (cur, idx, &idxlen, &idxmax, menu);
        break;
 
       case OP_EXIT: