From: Thomas Roessler Date: Fri, 19 Jun 1998 12:52:04 +0000 (+0000) Subject: Removing the Attach-Menu feature for the next release X-Git-Tag: mutt-0-92-12i-rel~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9044dd4d58af4b4d64a6e68b7b76c42d317e7ce5;p=mutt Removing the Attach-Menu feature for the next release version. --- diff --git a/OPS b/OPS index 4b6759bc..049e8922 100644 --- 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" diff --git a/compose.c b/compose.c index a256f454..5c2dfac5 100644 --- a/compose.c +++ b/compose.c @@ -23,7 +23,6 @@ #include "mime.h" #include "attach.h" #include "mapping.h" -#include "mailbox.h" #include #include @@ -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; diff --git a/curs_main.c b/curs_main.c index 2782c334..cf06bcf9 100644 --- a/curs_main.c +++ b/curs_main.c @@ -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; diff --git a/functions.h b/functions.h index d694ad11..f8a1af17 100644 --- a/functions.h +++ b/functions.h @@ -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" }, diff --git a/headers.c b/headers.c index c9bc49b2..b718eaf1 100644 --- 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 8002e25f..c0e2177a 100644 --- 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 474d4382..f582a1eb 100644 --- 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) { diff --git a/pattern.c b/pattern.c index a720c8aa..0435ac76 100644 --- 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; } diff --git a/postpone.c b/postpone.c index 185ccbaf..b8bf6cf8 100644 --- a/postpone.c +++ b/postpone.c @@ -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 */ } diff --git a/protos.h b/protos.h index b577b7de..38a1ad29 100644 --- 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 30b97ce7..44e80eed 100644 --- 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; diff --git a/sendlib.c b/sendlib.c index a9bbeff4..b6eaac64 100644 --- 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;