]> granicus.if.org Git - mutt/commitdiff
Removing the Attach-Menu feature for the next release
authorThomas Roessler <roessler@does-not-exist.org>
Fri, 19 Jun 1998 12:52:04 +0000 (12:52 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Fri, 19 Jun 1998 12:52:04 +0000 (12:52 +0000)
version.

12 files changed:
OPS
compose.c
curs_main.c
functions.h
headers.c
main.c
menu.c
pattern.c
postpone.c
protos.h
send.c
sendlib.c

diff --git a/OPS b/OPS
index 4b6759bc9bf6139ff193e50e22f39579a1fe9ed6..049e89228ef947fe3b09dad1992e3313b74cb190 100644 (file)
--- a/OPS
+++ b/OPS
@@ -7,7 +7,6 @@ OP_BROWSER_NEW_FILE "select a new file in this directory"
 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 a message(s) to this message"
 OP_COMPOSE_EDIT_BCC "edit the BCC list"
 OP_COMPOSE_EDIT_CC "edit the CC list"
 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
index a256f454ab49255b264c9832e3aaf8ab04a631eb..5c2dfac5ce14d362fc0f784f86b228afedb660b5 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -23,7 +23,6 @@
 #include "mime.h"
 #include "attach.h"
 #include "mapping.h"
-#include "mailbox.h"
 
 #include <string.h>
 #include <sys/stat.h>
@@ -394,64 +393,6 @@ static int delete_attachment (MUTTMENU *menu, short *idxlen, int x)
   return (0);
 }
 
-static struct mapping_t AttachMsgHelp[] = {
-  { "Exit",  OP_EXIT },
-  { "Help",  OP_HELP },
-  { "Attach Message",  OP_GENERIC_SELECT_ENTRY },
-  { NULL }
-};
-
-
-static void attach_msg_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
-{
-  CONTEXT *tmp = Context;
-
-  Context = (CONTEXT *) menu->data;
-  index_make_entry (s, l, menu, num);
-  Context = tmp;
-}
-
-static HEADER *select_msg (CONTEXT *ctx)
-{
-  MUTTMENU *menu;
-  int i, done=0, r=-1;
-  char helpstr[SHORT_STRING];
-  char title[SHORT_STRING], from_folder[SHORT_STRING];
-
-  strfcpy(from_folder, ctx->path, sizeof (from_folder));
-  mutt_pretty_mailbox (from_folder);
-  snprintf(title, sizeof (title), "Attach messages from folder: %s", 
-                                   from_folder);
-
-  menu = mutt_new_menu ();
-  menu->make_entry = attach_msg_make_entry;
-  menu->menu = MENU_GENERIC;
-  menu->max = ctx->msgcount;
-  menu->title = title;
-  menu->data = ctx;
-  menu->search = (int (*)(MUTTMENU *, regex_t *, int)) -1;
-  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_GENERIC,
-                                 AttachMsgHelp);
-
-  while (!done)
-  {
-    switch (i = mutt_menuLoop (menu))
-    {
-      case OP_GENERIC_SELECT_ENTRY:
-       r = menu->current;
-       done = 1;
-       break;
-
-      case OP_EXIT:
-       done = 1;
-       break;
-    }
-  }
-
-  mutt_menuDestroy (&menu);
-  return (r > -1 ? ctx->hdrs[ctx->v2r[r]] : NULL);
-}
-
 /* return values:
  *
  * 1   message should be postponed
@@ -475,8 +416,6 @@ int mutt_send_menu (HEADER *msg,   /* structure for new message */
   int op = 0;
   int loop = 1;
   int fccSet = 0;      /* has the user edited the Fcc: field ? */
-  CONTEXT *ctx = NULL;
-  HEADER *hdr = NULL;
 
   idx = mutt_gen_attach_list (msg->content, idx, &idxlen, &idxmax, 0, 1);
 
@@ -632,31 +571,10 @@ int mutt_send_menu (HEADER *msg,   /* structure for new message */
 
 
       case OP_COMPOSE_ATTACH_FILE:
-      case OP_COMPOSE_ATTACH_MESSAGE:
-
        fname[0] = 0;
-       {
-         char* prompt;
-         int flag;
-
-         if (op == OP_COMPOSE_ATTACH_FILE)
-         {
-           prompt = "Attach file";
-           flag = 0;
-         }
-         else
-         {
-           prompt = "Open mailbox to attach message from";
-           flag = 1;
-         }
-
-         if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw,
-                               flag) == -1)
-         {
-           break;
-         }
-       }
-
+       if (mutt_enter_fname ("Attach file", fname, sizeof (fname),
+                             &menu->redraw, 0) == -1)
+         break;
        if (!fname[0])
          continue;
        mutt_expand_path (fname, sizeof (fname));
@@ -668,34 +586,6 @@ int mutt_send_menu (HEADER *msg,   /* structure for new message */
          break;
        }
 
-       if (op == OP_COMPOSE_ATTACH_MESSAGE)
-       {
-         menu->redraw = REDRAW_FULL;
-
-         ctx = mx_open_mailbox (fname, 0, NULL);
-         if (ctx == NULL)
-         {
-           mutt_perror (fname);
-           break;
-         }
-
-         if (!ctx->msgcount)
-         {
-           mx_close_mailbox (ctx);
-           safe_free ((void **) &ctx);
-           mutt_error ("No messages in that folder.");
-           break;
-         }
-         
-         hdr = select_msg (ctx);
-         if (hdr == NULL)
-         {
-           mx_close_mailbox (ctx);
-           safe_free ((void **) &ctx);
-           break;
-         }
-       }
-
        if (idxlen == idxmax)
        {
          safe_realloc ((void **) &idx, sizeof (ATTACHPTR *) * (idxmax += 5));
@@ -703,13 +593,7 @@ int mutt_send_menu (HEADER *msg,   /* structure for new message */
        }
 
        idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
-
-       if (op == OP_COMPOSE_ATTACH_FILE)
-         idx[idxlen]->content = mutt_make_file_attach (fname);
-       else
-         idx[idxlen]->content = mutt_make_message_attach (ctx, hdr);
-
-       if (idx[idxlen]->content != NULL)
+       if ((idx[idxlen]->content = mutt_make_attach (fname)) != NULL)
        {
          idx[idxlen]->level = (idxlen > 0) ? idx[idxlen-1]->level : 0;
 
@@ -719,12 +603,11 @@ int mutt_send_menu (HEADER *msg,   /* structure for new message */
          menu->current = idxlen++;
          mutt_update_tree (idx, idxlen);
          menu->max = idxlen;
-         if (op == OP_COMPOSE_ATTACH_FILE)
-           menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
+         menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
        }
        else
        {
-         mutt_error ("Unable to attach!");
+         mutt_error ("Unable to attach file!");
          safe_free ((void **) &idx[idxlen]);
        }
        break;
@@ -892,7 +775,7 @@ int mutt_send_menu (HEADER *msg,   /* structure for new message */
          }
          fclose (fp);
 
-         if ((idx[idxlen]->content = mutt_make_file_attach (fname)) == NULL)
+         if ((idx[idxlen]->content = mutt_make_attach (fname)) == NULL)
          {
            mutt_error ("What we have here is a failure to make an attachment");
            continue;
index 2782c3342b6f2387d0242790b5cf49d817610518..cf06bcf909aedf0353dddadd94e59a9dbff19ae0 100644 (file)
@@ -655,7 +655,7 @@ void mutt_index_menu (void)
       case OP_SEARCH_OPPOSITE:
 
        CHECK_MSGCOUNT;
-       if ((menu->current = mutt_search_command (Context, menu->current, op)) == -1)
+       if ((menu->current = mutt_search_command (menu->current, op)) == -1)
          menu->current = menu->oldcurrent;
        else
          menu->redraw = REDRAW_MOTION;
index d694ad117e22f9b931c294362ba19d4d163c4c9d..f8a1af178687e86cc6eafde0b2c4fbb8782e9e0d 100644 (file)
@@ -307,7 +307,6 @@ struct binding_t OpAttach[] = {
 
 struct binding_t OpCompose[] = {
   { "attach-file",     OP_COMPOSE_ATTACH_FILE,         "a" },
-  { "attach-message",  OP_COMPOSE_ATTACH_MESSAGE,      "A" },
   { "edit-bcc",                OP_COMPOSE_EDIT_BCC,            "b" },
   { "edit-cc",         OP_COMPOSE_EDIT_CC,             "c" },
   { "copy-file",       OP_SAVE,                        "C" },
index c9bc49b2c466f7d8aae4f36be608dfdc92eb81b4..b718eaf17c79f55b65ccb3161fe304997d081504 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -189,7 +189,7 @@ void mutt_edit_headers (const char *editor,
        else
          strfcpy (path, p, sizeof (path));
        mutt_expand_path (path, sizeof (path));
-       if ((body = mutt_make_file_attach (path)))
+       if ((body = mutt_make_attach (path)))
        {
          body->description = safe_strdup (q);
          for (parts = msg->content; parts->next; parts = parts->next) ;
diff --git a/main.c b/main.c
index 8002e25f477c61446753752d867c8b605a9c5d40..c0e2177a61eb30ca9e4c77c573205b5f6ac6d9e0 100644 (file)
--- a/main.c
+++ b/main.c
@@ -573,11 +573,11 @@ int main (int argc, char **argv)
       {
        if (a)
        {
-         a->next = mutt_make_file_attach (t->data);
+         a->next = mutt_make_attach (t->data);
          a = a->next;
        }
        else
-         msg->content = a = mutt_make_file_attach (t->data);
+         msg->content = a = mutt_make_attach (t->data);
        if (!a)
        {
          if (!option (OPTNOCURSES))
diff --git a/menu.c b/menu.c
index 474d4382ef9ae23e6b67155ad147d0fcc8ef34d2..f582a1eba157da53672ae7dbcc05005fc33232d4 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -574,21 +574,14 @@ void mutt_menuDestroy (MUTTMENU **p)
 static int menu_search (MUTTMENU *menu, int op)
 {
   int r;
-  int searchDir;
+  int searchDir = (menu->searchDir == M_SEARCH_UP) ? -1 : 1;
   regex_t re;
   char buf[SHORT_STRING];
 
-  /* Need to search the folder using the pattern matching language,
-   * not plain regexps. mutt_search_command() does just this */
-  if (menu->search == (int (*)(MUTTMENU *, regex_t *, int)) -1 )
-    return mutt_search_command (menu->data, menu->current, op);
-
   if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)
   {
     strfcpy (buf, menu->searchBuf ? menu->searchBuf : "", sizeof (buf));
-    if (mutt_get_field ((op == OP_SEARCH) ? "Search for: " : 
-                                            "Reverse search for: ",
-                        buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
+    if (mutt_get_field ("Search for: ", buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
       return (-1);
     safe_free ((void **) &menu->searchBuf);
     menu->searchBuf = safe_strdup (buf);
@@ -601,11 +594,10 @@ static int menu_search (MUTTMENU *menu, int op)
       mutt_error ("No search pattern.");
       return (-1);
     }
-  }
 
-  searchDir = (menu->searchDir == M_SEARCH_UP) ? -1 : 1;
-  if (op == OP_SEARCH_OPPOSITE)
-    searchDir = -searchDir;
+    if (op == OP_SEARCH_OPPOSITE)
+      searchDir = -searchDir;
+  }
 
   if ((r = REGCOMP (&re, menu->searchBuf, REG_NOSUB | mutt_which_case (menu->searchBuf))) != 0)
   {
index a720c8aa302756dcd965cd3810a2613d9a2c6b77..0435ac76f64664ee8b5c682292532de353518f69 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -960,7 +960,7 @@ int mutt_pattern_func (int op, char *prompt, HEADER *hdr)
   return 0;
 }
 
-int mutt_search_command (CONTEXT *ctx, int cur, int op)
+int mutt_search_command (int cur, int op)
 {
   int i, j;
   char buf[STRING];
@@ -1011,8 +1011,8 @@ int mutt_search_command (CONTEXT *ctx, int cur, int op)
 
   if (option (OPTSEARCHINVALID))
   {
-    for (i = 0; i < ctx->msgcount; i++)
-      ctx->hdrs[i]->searched = 0;
+    for (i = 0; i < Context->msgcount; i++)
+      Context->hdrs[i]->searched = 0;
     unset_option (OPTSEARCHINVALID);
   }
 
@@ -1020,9 +1020,9 @@ int mutt_search_command (CONTEXT *ctx, int cur, int op)
   if (op == OP_SEARCH_OPPOSITE)
     incr = -incr;
 
-  for (i = cur + incr, j = 0 ; j != ctx->vcount; j++)
+  for (i = cur + incr, j = 0 ; j != Context->vcount; j++)
   {
-    if (i > ctx->vcount - 1)
+    if (i > Context->vcount - 1)
     {
       i = 0;
       if (option (OPTWRAPSEARCH))
@@ -1035,7 +1035,7 @@ int mutt_search_command (CONTEXT *ctx, int cur, int op)
     }
     else if (i < 0)
     {
-      i = ctx->vcount - 1;
+      i = Context->vcount - 1;
       if (option (OPTWRAPSEARCH))
         mutt_message ("Search wrapped to bottom.");
       else 
@@ -1045,7 +1045,7 @@ int mutt_search_command (CONTEXT *ctx, int cur, int op)
       }
     }
 
-    h = ctx->hdrs[ctx->v2r[i]];
+    h = Context->hdrs[Context->v2r[i]];
     if (h->searched)
     {
       /* if we've already evaulated this message, use the cached value */
@@ -1056,7 +1056,7 @@ int mutt_search_command (CONTEXT *ctx, int cur, int op)
     {
       /* remember that we've already searched this message */
       h->searched = 1;
-      if ((h->matched = (mutt_pattern_exec (SearchPattern, M_MATCH_FULL_ADDRESS, ctx, h) > 0)))
+      if ((h->matched = (mutt_pattern_exec (SearchPattern, M_MATCH_FULL_ADDRESS, Context, h) > 0)))
        return i;
     }
 
index 185ccbaf83537db80b312a8865e492502fec7b35..b8bf6cf862dd1efc5d65bdd920254ceb8fb2b6da 100644 (file)
@@ -270,7 +270,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur)
       safe_free ((void **) &PostContext);
       return (-1);
     }
-    hdr->content = mutt_make_file_attach (file);
+    hdr->content = mutt_make_attach (file);
     hdr->content->use_disp = 0;        /* no content-disposition */
     hdr->content->unlink = 1;  /* delete when we are done */
   }
index b577b7de5a898fe94c44267966ff14a90f2594f9..38a1ad29aa14f60fc0f4418d44f47fcc4793c094 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -70,8 +70,7 @@ ADDRESS *mutt_expand_aliases (ADDRESS *);
 ADDRESS *mutt_parse_adrlist (ADDRESS *, const char *);
 
 BODY *mutt_dup_body (BODY *);
-BODY *mutt_make_file_attach (const char *);
-BODY *mutt_make_message_attach (CONTEXT *, HEADER *);
+BODY *mutt_make_attach (const char *);
 BODY *mutt_make_multipart (BODY *);
 BODY *mutt_new_body (void);
 BODY *mutt_parse_multipart (FILE *, const char *, long, int);
@@ -220,7 +219,7 @@ int mutt_print_attachment (FILE *, BODY *);
 int mutt_query_complete (char *, size_t);
 int mutt_save_attachment (FILE *, BODY *, char *, int);
 int mutt_save_message (HEADER *, int, int, int *);
-int mutt_search_command (CONTEXT *, int, int);
+int mutt_search_command (int, int);
 int mutt_send_menu (HEADER *, char *, size_t, HEADER *);
 int mutt_send_message (HEADER *, const char *);
 int mutt_strcmp (const char *, const char *);
diff --git a/send.c b/send.c
index 30b97ce7a46443ca4099adc7d9f75ea5a14ab6a1..44e80eed661d65a8116c7b8e3738ef4446efdc6f 100644 (file)
--- a/send.c
+++ b/send.c
@@ -392,6 +392,38 @@ static int include_reply (CONTEXT *ctx, HEADER *cur, FILE *out)
   return 0;
 }
 
+static BODY *make_forward (CONTEXT *ctx, HEADER *hdr)
+{
+  char buffer[LONG_STRING];
+  BODY *body;
+  FILE *fpout;
+
+  mutt_mktemp (buffer);
+  if ((fpout = safe_fopen (buffer, "w")) == NULL)
+    return NULL;
+
+  body = mutt_new_body ();
+  body->type = TYPEMESSAGE;
+  body->subtype = safe_strdup ("rfc822");
+  body->filename = safe_strdup (buffer);
+  body->unlink = 1;
+  body->use_disp = 0;
+
+  /* this MUST come after setting ->filename because we reuse buffer[] */
+  strfcpy (buffer, "Forwarded message from ", sizeof (buffer));
+  rfc822_write_address (buffer + 23, sizeof (buffer) - 23, hdr->env->from);
+  body->description = safe_strdup (buffer);
+
+  mutt_parse_mime_message (ctx, hdr);
+  mutt_copy_message (fpout, ctx, hdr,
+                    option (OPTMIMEFORWDECODE) ? M_CM_DECODE : 0,
+                    CH_XMIT | (option (OPTMIMEFORWDECODE) ? (CH_MIME | CH_TXTPLAIN ) : 0));
+  
+  fclose (fpout);
+  mutt_update_encoding (body);
+  return (body);
+}
+
 static int default_to (ADDRESS **to, ENVELOPE *env, int group)
 {
   char prompt[STRING];
@@ -637,7 +669,7 @@ generate_body (FILE *tempfp,        /* stream for outgoing message */
 
       if (cur)
       {
-       tmp = mutt_make_message_attach (ctx, cur);
+       tmp = make_forward (ctx, cur);
        if (last)
          last->next = tmp;
        else
@@ -649,7 +681,7 @@ generate_body (FILE *tempfp,        /* stream for outgoing message */
        {
          if (ctx->hdrs[ctx->v2r[i]]->tagged)
          {
-           tmp = mutt_make_message_attach (ctx, ctx->hdrs[ctx->v2r[i]]);
+           tmp = make_forward (ctx, ctx->hdrs[ctx->v2r[i]]);
            if (last)
            {
              last->next = tmp;
index a9bbeff4a1d1a922db2943e12485a3e44a15ced9..b6eaac648462df51d1367afa1d7b706e22b139cb 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -849,39 +849,7 @@ void mutt_update_encoding (BODY *a)
   safe_free ((void **) &info);
 }
 
-BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr)
-{
-  char buffer[LONG_STRING];
-  BODY *body;
-  FILE *fpout;
-
-  mutt_mktemp (buffer);
-  if ((fpout = safe_fopen (buffer, "w")) == NULL)
-    return NULL;
-
-  body = mutt_new_body ();
-  body->type = TYPEMESSAGE;
-  body->subtype = safe_strdup ("rfc822");
-  body->filename = safe_strdup (buffer);
-  body->unlink = 1;
-  body->use_disp = 0;
-
-  /* this MUST come after setting ->filename because we reuse buffer[] */
-  strfcpy (buffer, "Forwarded message from ", sizeof (buffer));
-  rfc822_write_address (buffer + 23, sizeof (buffer) - 23, hdr->env->from);
-  body->description = safe_strdup (buffer);
-
-  mutt_parse_mime_message (ctx, hdr);
-  mutt_copy_message (fpout, ctx, hdr,
-                    option (OPTMIMEFORWDECODE) ? M_CM_DECODE : 0,
-                    CH_XMIT | (option (OPTMIMEFORWDECODE) ? (CH_MIME | CH_TXTPLAIN ) : 0));
-  
-  fclose (fpout);
-  mutt_update_encoding (body);
-  return (body);
-}
-
-BODY *mutt_make_file_attach (const char *path)
+BODY *mutt_make_attach (const char *path)
 {
   BODY *att;
   CONTENT *info;