- case OP_COMPOSE_NEW_MIME:
- {
- char type[STRING];
- char *p;
- int itype;
- FILE *fp;
-
- CLEARLINE (LINES-1);
- fname[0] = 0;
- if (mutt_get_field (_("New file: "), fname, sizeof (fname), M_FILE)
- != 0 || !fname[0])
- continue;
- mutt_expand_path (fname, sizeof (fname));
-
- /* Call to lookup_mime_type () ? maybe later */
- type[0] = 0;
- if (mutt_get_field ("Content-Type: ", type, sizeof (type), 0) != 0
- || !type[0])
- continue;
-
- if (!(p = strchr (type, '/')))
- {
- mutt_error _("Content-Type is of the form base/sub");
- continue;
- }
- *p++ = 0;
- if ((itype = mutt_check_mime_type (type)) == TYPEOTHER)
- {
- mutt_error (_("Unknown Content-Type %s"), type);
- continue;
- }
- if (idxlen == idxmax)
- {
- safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5));
- menu->data = idx;
- }
-
- idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
- /* Touch the file */
- if (!(fp = safe_fopen (fname, "w")))
- {
- mutt_error (_("Can't create file %s"), fname);
- FREE (&idx[idxlen]);
- continue;
- }
- fclose (fp);
-
- if ((idx[idxlen]->content = mutt_make_file_attach (fname)) == NULL)
- {
- mutt_error _("What we have here is a failure to make an attachment");
- continue;
- }
- update_idx (menu, idx, idxlen++);
-
- idx[menu->current]->content->type = itype;
- mutt_str_replace (&idx[menu->current]->content->subtype, p);
- idx[menu->current]->content->unlink = 1;
- menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
-
- if (mutt_compose_attachment (idx[menu->current]->content))
- {
- mutt_update_encoding (idx[menu->current]->content);
- menu->redraw = REDRAW_FULL;
- }
- }
- mutt_message_hook (NULL, msg, M_SEND2HOOK);
+ str_replace (&idx[menu->current]->content->filename, fname);
+ menu->redraw = REDRAW_CURRENT;
+
+ if (idx[menu->current]->content->stamp >= st.st_mtime)
+ mutt_stamp_attachment (idx[menu->current]->content);
+
+ }
+ mutt_message_hook (NULL, msg, M_SEND2HOOK);
+ break;
+
+ case OP_COMPOSE_NEW_MIME:
+ {
+ char type[STRING];
+ char *p;
+ int itype;
+ FILE *fp;
+
+ CLEARLINE (LINES - 1);
+ fname[0] = 0;
+ if (mutt_get_field (_("New file: "), fname, sizeof (fname), M_FILE)
+ != 0 || !fname[0])
+ continue;
+ mutt_expand_path (fname, sizeof (fname));
+
+ /* Call to lookup_mime_type () ? maybe later */
+ type[0] = 0;
+ if (mutt_get_field ("Content-Type: ", type, sizeof (type), 0) != 0
+ || !type[0])
+ continue;
+
+ if (!(p = strchr (type, '/'))) {
+ mutt_error _("Content-Type is of the form base/sub");
+
+ continue;
+ }
+ *p++ = 0;
+ if ((itype = mutt_check_mime_type (type)) == TYPEOTHER) {
+ mutt_error (_("Unknown Content-Type %s"), type);
+ continue;
+ }
+ if (idxlen == idxmax) {
+ safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5));
+ menu->data = idx;
+ }
+
+ idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
+ /* Touch the file */
+ if (!(fp = safe_fopen (fname, "w"))) {
+ mutt_error (_("Can't create file %s"), fname);
+ FREE (&idx[idxlen]);
+ continue;
+ }
+ fclose (fp);
+
+ if ((idx[idxlen]->content = mutt_make_file_attach (fname)) == NULL) {
+ mutt_error
+ _("What we have here is a failure to make an attachment");
+ continue;
+ }
+ update_idx (menu, idx, idxlen++);
+
+ idx[menu->current]->content->type = itype;
+ str_replace (&idx[menu->current]->content->subtype, p);
+ idx[menu->current]->content->unlink = 1;
+ menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
+
+ if (mutt_compose_attachment (idx[menu->current]->content)) {
+ mutt_update_encoding (idx[menu->current]->content);
+ menu->redraw = REDRAW_FULL;
+ }
+ }
+ mutt_message_hook (NULL, msg, M_SEND2HOOK);
+ break;
+
+ case OP_COMPOSE_EDIT_MIME:
+ CHECK_COUNT;
+ if (mutt_edit_attachment (idx[menu->current]->content)) {
+ mutt_update_encoding (idx[menu->current]->content);
+ menu->redraw = REDRAW_FULL;
+ }
+ mutt_message_hook (NULL, msg, M_SEND2HOOK);
+ break;
+
+ case OP_VIEW_ATTACH:
+ case OP_DISPLAY_HEADERS:
+ CHECK_COUNT;
+ mutt_attach_display_loop (menu, op, NULL, NULL, NULL, &idx, &idxlen,
+ NULL, 0);
+ menu->redraw = REDRAW_FULL;
+ /* no send2hook, since this doesn't modify the message */
+ break;
+
+ case OP_SAVE:
+ CHECK_COUNT;
+ mutt_save_attachment_list (NULL, menu->tagprefix,
+ menu->tagprefix ? msg->content : idx[menu->
+ current]->
+ content, NULL, menu);
+ MAYBE_REDRAW (menu->redraw);
+ /* no send2hook, since this doesn't modify the message */
+ break;
+
+ case OP_PRINT:
+ CHECK_COUNT;
+ mutt_print_attachment_list (NULL, menu->tagprefix,
+ menu->tagprefix ? msg->content : idx[menu->
+ current]->
+ content);
+ /* no send2hook, since this doesn't modify the message */
+ break;
+
+ case OP_PIPE:
+ case OP_FILTER:
+ CHECK_COUNT;
+ mutt_pipe_attachment_list (NULL, menu->tagprefix,
+ menu->tagprefix ? msg->content : idx[menu->
+ current]->
+ content, op == OP_FILTER);
+ if (op == OP_FILTER) /* cte might have changed */
+ menu->redraw = menu->tagprefix ? REDRAW_FULL : REDRAW_CURRENT;
+ menu->redraw |= REDRAW_STATUS;
+ mutt_message_hook (NULL, msg, M_SEND2HOOK);
+ break;
+
+ case OP_EXIT:
+ if ((i =
+ query_quadoption (OPT_POSTPONE,
+ _("Postpone this message?"))) == M_NO) {
+ while (idxlen-- > 0) {
+ /* avoid freeing other attachments */
+ idx[idxlen]->content->next = NULL;
+ idx[idxlen]->content->parts = NULL;
+ if (idx[idxlen]->unowned)
+ idx[idxlen]->content->unlink = 0;
+ mutt_free_body (&idx[idxlen]->content);
+ FREE (&idx[idxlen]->tree);
+ FREE (&idx[idxlen]);
+ }
+ FREE (&idx);
+ idxlen = 0;
+ idxmax = 0;
+ r = -1;
+ loop = 0;