-
- case OP_COMPOSE_RENAME_FILE:
- CHECK_COUNT;
- strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname));
- mutt_pretty_mailbox (fname);
- if (mutt_get_field (_("Rename to: "), fname, sizeof (fname), M_FILE)
- == 0 && fname[0])
- {
- if (stat(idx[menu->current]->content->filename, &st) == -1)
- {
- mutt_error (_("Can't stat %s: %s"), fname, strerror (errno));
- break;
- }
-
- mutt_expand_path (fname, sizeof (fname));
- if(mutt_rename_file (idx[menu->current]->content->filename, fname))
- break;
-
- mutt_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);
-
- }
- 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;
- 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;
- }
- }
- 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;
- }
- 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;
- 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);
- break;
-
- case OP_PRINT:
- CHECK_COUNT;
- mutt_print_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content);
- 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;
- 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;
- mutt_free_body (&idx[idxlen]->content);
- FREE (&idx[idxlen]->tree);
- FREE (&idx[idxlen]);
- }
- FREE (&idx);
- idxlen = 0;
- idxmax = 0;
- r = -1;
- loop = 0;
- break;
- }
- else if (i == -1)
- break; /* abort */
-
- /* fall through to postpone! */
-
- case OP_COMPOSE_POSTPONE_MESSAGE:
-
- if(check_attachments(idx, idxlen) != 0)
- {
- menu->redraw = REDRAW_FULL;
- break;
- }
-
- loop = 0;
- r = 1;
- break;
-
- case OP_COMPOSE_ISPELL:
- endwin ();
- snprintf (buf, sizeof (buf), "%s -x %s", NONULL(Ispell), msg->content->filename);
- if (mutt_system (buf) == -1)
- mutt_error (_("Error running \"%s\"!"), buf);
- else
- {
- mutt_update_encoding (msg->content);
- menu->redraw |= REDRAW_STATUS;
- }
- break;
-
- case OP_COMPOSE_WRITE_MESSAGE:
-
- fname[0] = '\0';
- if (Context)
- {
- strfcpy (fname, NONULL (Context->path), sizeof (fname));
- mutt_pretty_mailbox (fname);
- }
- if (idxlen)
- msg->content = idx[0]->content;
- if (mutt_enter_fname (_("Write message to mailbox"), fname, sizeof (fname),
- &menu->redraw, 1) != -1 && fname[0])
- {
- mutt_message (_("Writing message to %s ..."), fname);
- mutt_expand_path (fname, sizeof (fname));
-
- if (msg->content->next)
- msg->content = mutt_make_multipart (msg->content);
-
- if (mutt_write_fcc (NONULL (fname), msg, NULL, 1, NULL) < 0)
- msg->content = mutt_remove_multipart (msg->content);
- else
- mutt_message _("Message written.");
- }
- break;
-
-
-
- case OP_COMPOSE_PGP_MENU:
- if (!(WithCrypto & APPLICATION_PGP))