]> granicus.if.org Git - neomutt/commitdiff
Disable recursive invocations of the attach-message function.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 23 Sep 1998 10:35:41 +0000 (10:35 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 23 Sep 1998 10:35:41 +0000 (10:35 +0000)
13 files changed:
commands.c
compose.c
curs_lib.c
curs_main.c
init.h
main.c
mutt.h
pager.c
pager.h
protos.h
recvattach.c
sendlib.c
status.c

index 715d2902d65ed109f6d8c2320e25ba9151874926..5293c2d7a544868107f9b139bdc4846ec17014f4 100644 (file)
@@ -103,7 +103,7 @@ static int is_mmnoask (const char *buf)
   return (0);
 }
 
-int mutt_display_message (HEADER *cur, const char *attach_msg_status)
+int mutt_display_message (HEADER *cur)
 {
   char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
   int rc = 0, builtin = 0;
@@ -208,7 +208,7 @@ int mutt_display_message (HEADER *cur, const char *attach_msg_status)
     memset (&info, 0, sizeof (pager_t));
     info.hdr = cur;
     info.ctx = Context;
-    rc = mutt_pager (NULL, tempfile, 1, &info, attach_msg_status);
+    rc = mutt_pager (NULL, tempfile, 1, &info);
   }
   else
   {
index 43f1bfaaadd3cc434646760080b236969204a941..de23890df111764aeac111d79cb437560572d3b7 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -650,7 +650,10 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
          
          this = Context; /* remember current folder */
          Context = ctx;
-         close = mutt_index_menu (1);
+         set_option(OPTATTACHMSG);
+         close = mutt_index_menu ();
+         unset_option(OPTATTACHMSG);
+
          if (!Context)
          {
            /* go back to the folder we started from */
index 14c9afcf2338a1e5c2d8e47e65e6b503438ce3d6..700fd73f7cc02bd069912c19c580942739c4e592 100644 (file)
@@ -277,7 +277,7 @@ int mutt_do_pager (const char *banner,
   int rc;
   
   if (!Pager || strcmp (Pager, "builtin") == 0)
-    rc = mutt_pager (banner, tempfile, do_color, info, "");
+    rc = mutt_pager (banner, tempfile, do_color, info);
   else
   {
     char cmd[STRING];
index 1179f4b874b8596d8f776b7c7ed03ba2e43711c3..429a285795f6a32cb63c4e389e19f4172ba53879 100644 (file)
                                break; \
                        }
 
+#define CHECK_ATTACH if(option(OPTATTACHMSG)) \
+                    {\
+                       mutt_flushinp (); \
+                       mutt_error ("Function not permitted in attach-message mode."); \
+                       break; \
+                    }
+
 #define CURHDR Context->hdrs[Context->v2r[menu->current]]
 #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
@@ -231,9 +238,9 @@ struct mapping_t IndexHelp[] = {
 /* This function handles the message index window as well as commands returned
  * from the pager (MENU_PAGER).
  */
-int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
+int mutt_index_menu (void)
 {
-  char buf[LONG_STRING], attach_msg_status[LONG_STRING] = "", helpstr[SHORT_STRING];
+  char buf[LONG_STRING], helpstr[SHORT_STRING];
   int op = OP_NULL;                 /* function to execute */
   int done = 0;                /* controls when to exit the "event" loop */
   int i = 0, j;
@@ -246,6 +253,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
   int index_hint;   /* used to restore cursor position */
   int do_buffy_notify = 1;
   int close = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
+  int attach_msg = option(OPTATTACHMSG);
 
   menu = mutt_new_menu ();
   menu->menu = MENU_MAIN;
@@ -446,19 +454,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
 
       if (menu->redraw & REDRAW_STATUS) 
       {
-       if (attach_msg)
-       {
-        char from_folder [STRING];
-        strfcpy(from_folder, Context->path, sizeof (from_folder));
-        mutt_pretty_mailbox (from_folder);
-        snprintf (attach_msg_status, sizeof (attach_msg_status), 
-                  "Folder: %s Tagged messages will be attached upon exiting", 
-                  from_folder);
-        snprintf (buf, sizeof (buf), M_MODEFMT, attach_msg_status);
-       }
-       else
-        menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
-
+       menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
        CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
        SETCOLOR (MT_COLOR_STATUS);
        printw ("%-*.*s", COLS, COLS, buf);
@@ -651,6 +647,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
 
        CHECK_MSGCOUNT;
        CHECK_READONLY;
+       CHECK_ATTACH;
        mutt_pattern_func (M_DELETE, "Delete messages matching: ");
        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
        break;
@@ -658,6 +655,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
 #ifdef USE_POP
       case OP_MAIN_FETCH_MAIL:
 
+       CHECK_ATTACH;
        mutt_fetchPopMail ();
        menu->redraw = REDRAW_FULL;
        break;
@@ -938,7 +936,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
            menu->current = mutt_thread_next_unread (Context, CURHDR);
        }
  
-       if ((op = mutt_display_message (CURHDR, attach_msg_status)) == -1)
+       if ((op = mutt_display_message (CURHDR)) == -1)
        {
          unset_option (OPTNEEDRESORT);
          break;
@@ -1386,6 +1384,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
 
       case OP_BOUNCE_MESSAGE:
 
+       CHECK_ATTACH;
        CHECK_MSGCOUNT;
        ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
        break;
@@ -1397,6 +1396,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
        break;
 
       case OP_QUERY:
+       CHECK_ATTACH;
        mutt_query_menu (NULL, 0);
        MAYBE_REDRAW (menu->redraw);
        break;
@@ -1485,6 +1485,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
 
        CHECK_MSGCOUNT;
        CHECK_READONLY;
+       CHECK_ATTACH;
         
         set_option(OPTUSEHEADERDATE);
        ci_send_message (SENDEDITMSG, NULL, NULL, Context, CURHDR);
@@ -1495,6 +1496,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
       case OP_FORWARD_MESSAGE:
 
        CHECK_MSGCOUNT;
+       CHECK_ATTACH;
        ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
        menu->redraw = REDRAW_FULL;
        break;
@@ -1513,12 +1515,14 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
       case OP_GROUP_REPLY:
 
        CHECK_MSGCOUNT;
+       CHECK_ATTACH;
        ci_send_message (SENDREPLY|SENDGROUPREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
        menu->redraw = REDRAW_FULL;
        break;
 
       case OP_LIST_REPLY:
 
+       CHECK_ATTACH;
        CHECK_MSGCOUNT;
        ci_send_message (SENDREPLY|SENDLISTREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
        menu->redraw = REDRAW_FULL;
@@ -1526,6 +1530,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
 
       case OP_MAIL:
 
+       CHECK_ATTACH;
        ci_send_message (0, NULL, NULL, NULL, NULL);
        menu->redraw = REDRAW_FULL;
        break;
@@ -1539,6 +1544,7 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
 #ifdef _PGPPATH
       case OP_MAIL_KEY:
        
+       CHECK_ATTACH;
        ci_send_message (SENDKEY, NULL, NULL, NULL, NULL);
        menu->redraw = REDRAW_FULL;
        break;
@@ -1592,12 +1598,14 @@ int mutt_index_menu (int attach_msg /* invoked while attaching a message */)
 
       case OP_RECALL_MESSAGE:
 
+       CHECK_ATTACH;
        ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
        menu->redraw = REDRAW_FULL;
        break;
 
       case OP_REPLY:
 
+       CHECK_ATTACH;
        CHECK_MSGCOUNT;
        ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
        menu->redraw = REDRAW_FULL;
diff --git a/init.h b/init.h
index 02c7acf9c20681ddb88f886e7b966624646f66d7..4f360f5dcf1ec729dae355c97ceccc9b699e39c1 100644 (file)
--- a/init.h
+++ b/init.h
@@ -251,7 +251,7 @@ struct option_t MuttVars[] = {
   { "sort_browser",    DT_SORT|DT_SORT_BROWSER, R_NONE, UL &BrowserSort, SORT_SUBJECT },
   { "sort_re",         DT_BOOL, R_INDEX|R_RESORT_BOTH, OPTSORTRE, 1 },
   { "spoolfile",       DT_PATH, R_NONE, UL &Spoolfile, 0 },
-  { "status_chars",    DT_STR,  R_BOTH, UL &StChars, UL "-*%" },
+  { "status_chars",    DT_STR,  R_BOTH, UL &StChars, UL "-*%A" },
   { "status_format",   DT_STR,  R_BOTH, UL &Status, UL "-%r-Mutt: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---" },
   { "status_on_top",   DT_BOOL, R_BOTH, OPTSTATUSONTOP, 0 },
   { "strict_threads",  DT_BOOL, R_RESORT|R_INDEX, OPTSTRICTTHREADS, 0 },
diff --git a/main.c b/main.c
index b6b45aaa9cfd5c4fd6ea93f0c1f0f2c4801885b1..2c85da3d0a711d0454b0d30f18ec3212a3c0e857 100644 (file)
--- a/main.c
+++ b/main.c
@@ -627,7 +627,7 @@ int main (int argc, char **argv)
 
     if ((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL)) != NULL)
     {
-      int close = mutt_index_menu (0);
+      int close = mutt_index_menu ();
 
       if (Context)
       {
diff --git a/mutt.h b/mutt.h
index 86f7af8a476a4833f32d4c774c256ee1a5f25c59..511878553e9c9db70cad0b7edd58c803cc795cfb 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -333,6 +333,7 @@ enum
   OPTNEEDRESCORE,      /* (pseudo) set when the `score' command is used */
   OPTSORTCOLLAPSE,     /* (pseudo) used by mutt_sort_headers() */
   OPTUSEHEADERDATE,    /* (pseudo) used by edit-message */
+  OPTATTACHMSG,                /* (pseudo) used by attach-message */
   
 #ifdef _PGPPATH
   OPTPGPCHECKTRUST,    /* (pseudo) used by pgp_select_key () */
diff --git a/pager.c b/pager.c
index 6d0e723caa25a35220fad4f6f0491ce14478ca89..f0fd4b3b36a8a90ee1754562cf0262487dd0a8e0 100644 (file)
--- a/pager.c
+++ b/pager.c
                                break; \
                        }
 
+#define CHECK_ATTACH if(option(OPTATTACHMSG)) \
+                    {\
+                       mutt_flushinp (); \
+                       mutt_error ("Function not permitted in attach-message mode."); \
+                       break; \
+                    }
+
 struct q_class_t
 {
   int length;
@@ -1305,8 +1312,7 @@ upNLines (int nlines, struct line_t *info, int cur, int hiding)
    is there so that we can do operations on the current message without the
    need to pop back out to the main-menu.  */
 int 
-mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra,
-            const char *attach_msg_status /* invoked while attaching a message */)
+mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra)
 {
   static char searchbuf[STRING];
   char buffer[LONG_STRING];
@@ -1541,10 +1547,7 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra,
       menu_redraw_current (index);
 
       /* print out the index status bar */
-      if (*attach_msg_status)
-        snprintf (buffer, sizeof (buffer), M_MODEFMT, attach_msg_status);
-      else
-       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
+      menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
  
       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
       SETCOLOR (MT_COLOR_STATUS);
@@ -1921,7 +1924,8 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra,
 
       case OP_BOUNCE_MESSAGE:
        CHECK_MODE(IsHeader (extra));
-       ci_bounce_message (extra->hdr, &redraw);
+        CHECK_ATTACH;
+        ci_bounce_message (extra->hdr, &redraw);
        break;
 
       case OP_CREATE_ALIAS:
@@ -2076,36 +2080,42 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra,
 
       case OP_MAIL:
        CHECK_MODE(IsHeader (extra));
+        CHECK_ATTACH;      
        ci_send_message (0, NULL, NULL, NULL, NULL);
        redraw = REDRAW_FULL;
        break;
 
       case OP_REPLY:
        CHECK_MODE(IsHeader (extra));
+        CHECK_ATTACH;      
        ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr);
        redraw = REDRAW_FULL;
        break;
 
       case OP_RECALL_MESSAGE:
        CHECK_MODE(IsHeader (extra));
+        CHECK_ATTACH;
        ci_send_message (SENDPOSTPONED, NULL, NULL, extra->ctx, extra->hdr);
        redraw = REDRAW_FULL;
        break;
 
       case OP_GROUP_REPLY:
        CHECK_MODE(IsHeader (extra));
+        CHECK_ATTACH;
        ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx, extra->hdr);
        redraw = REDRAW_FULL;
        break;
 
       case OP_LIST_REPLY:
        CHECK_MODE(IsHeader (extra));
+        CHECK_ATTACH;
        ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx, extra->hdr);
        redraw = REDRAW_FULL;
        break;
 
       case OP_FORWARD_MESSAGE:
        CHECK_MODE(IsHeader (extra));
+        CHECK_ATTACH;
        ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
        redraw = REDRAW_FULL;
        break;
@@ -2245,6 +2255,7 @@ mutt_pager (const char *banner, const char *fname, int do_color, pager_t *extra,
 
       case OP_MAIL_KEY:
        CHECK_MODE(IsHeader(extra));
+        CHECK_ATTACH;
        ci_send_message (SENDKEY, NULL, NULL, extra->ctx, extra->hdr);
        redraw = REDRAW_FULL;
        break;
diff --git a/pager.h b/pager.h
index b218addcb2853f7010894d9c6c0e1e8db04113cd..bc3fab23caf2227815063a2ea934c46ea955655f 100644 (file)
--- a/pager.h
+++ b/pager.h
@@ -25,4 +25,4 @@ typedef struct
 } pager_t;
 
 int mutt_do_pager (const char *, const char *, int, pager_t *);
-int mutt_pager (const char *, const char *, int, pager_t *, const char *);
+int mutt_pager (const char *, const char *, int, pager_t *);
index 41eb9a6591457f52e984d9e983ec4940798212af..b6af9be3f2fc41ec1768e3274b7f5cfbc52804f8 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -218,7 +218,7 @@ int mutt_compose_attachment (BODY *a);
 int mutt_copy_bytes (FILE *, FILE *, size_t);
 int mutt_copy_stream (FILE *, FILE *);
 int mutt_decode_save_attachment (FILE *, BODY *, char *, int, int);
-int mutt_display_message (HEADER *h, const char *);
+int mutt_display_message (HEADER *h);
 int mutt_edit_attachment(BODY *);
 int mutt_edit_message(CONTEXT *, HEADER *, HEADER *);
 int mutt_enter_fname (const char *, char *, size_t, int *, int);
@@ -227,7 +227,7 @@ int mutt_get_field (char *, char *, size_t, int);
 int mutt_get_password (char *, char *, size_t);
 int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **);
 int mutt_get_tmp_attachment (BODY *);
-int mutt_index_menu (int);
+int mutt_index_menu (void);
 int mutt_invoke_sendmail (ADDRESS *, ADDRESS *, ADDRESS *, const char *, int);
 int mutt_is_autoview (char *);
 int mutt_is_mail_list (ADDRESS *);
index ef464769fc08f12316623d0fa4b9732868670ec5..1ac98c568dc2bc118180298caadcb1c461a866e6 100644 (file)
@@ -778,6 +778,14 @@ mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, ATTACHPTR **idx)
     toggle_option (OPTWEED);
 }
 
+
+#define CHECK_ATTACH if(option(OPTATTACHMSG)) \
+                    {\
+                       mutt_flushinp (); \
+                       mutt_error ("Function not permitted in attach-message mode."); \
+                       break; \
+                    }
+
 void mutt_view_attachments (HEADER *hdr)
 {
 
@@ -962,6 +970,7 @@ void mutt_view_attachments (HEADER *hdr)
        break;
 
       case OP_BOUNCE_MESSAGE:
+        CHECK_ATTACH;
        query_bounce_attachment (menu->tagprefix, menu->tagprefix ? cur : idx[menu->current]->content, hdr);
        break;
 
@@ -970,7 +979,7 @@ void mutt_view_attachments (HEADER *hdr)
       case OP_LIST_REPLY:
       case OP_FORWARD_MESSAGE:
 
-
+        CHECK_ATTACH;
 
 #ifdef _PGPPATH
        if ((hdr->pgp & PGPENCRYPT) && hdr->content->type == TYPEMULTIPART)
index dee5f0b0c261df8e23b7f9cdca296c5d6d341ac4..66d299d6e0e131bb8ddc491dc37e81d93df6bde4 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -923,7 +923,7 @@ BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
 #ifdef _PGPPATH
   int pgp = hdr->pgp;
 #endif
-  
+
 #ifdef _PGPPATH
   if ((option(OPTMIMEFORWDECODE) || option(OPTFORWDECRYPT)) &&
       (hdr->pgp & PGPENCRYPT) && !pgp_valid_passphrase())
index 7cf8680747eb81b0d85cb07bf8e16bd12fc02822..a2ca6a1033fe5f516792c1bbbbfebb87a59ce638 100644 (file)
--- a/status.c
+++ b/status.c
@@ -199,9 +199,9 @@ status_format_str (char *buf, size_t buflen, char op, const char *src,
       break;
 
     case 'r':
-      if (Context)
-       buf[0] = (Context->readonly || Context->dontwrite) ? StChars[2] :
-         (Context->changed || Context->deleted) ? StChars[1] : StChars[0];
+      if (Context && StChars)  /* XXX */
+        buf[0] = option(OPTATTACHMSG) ? StChars[3] : ((Context->readonly || Context->dontwrite) ? StChars[2] :
+         (Context->changed || Context->deleted) ? StChars[1] : StChars[0]);
       else
        buf[0] = StChars[0];
       buf[1] = 0;