version.
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"
#include "mime.h"
#include "attach.h"
#include "mapping.h"
-#include "mailbox.h"
#include <string.h>
#include <sys/stat.h>
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
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);
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));
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));
}
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;
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;
}
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;
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;
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" },
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) ;
{
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))
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);
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)
{
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];
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);
}
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))
}
else if (i < 0)
{
- i = ctx->vcount - 1;
+ i = Context->vcount - 1;
if (option (OPTWRAPSEARCH))
mutt_message ("Search wrapped to bottom.");
else
}
}
- 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 */
{
/* 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;
}
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 */
}
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);
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 *);
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];
if (cur)
{
- tmp = mutt_make_message_attach (ctx, cur);
+ tmp = make_forward (ctx, cur);
if (last)
last->next = tmp;
else
{
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;
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;