- case OP_COMPOSE_GET_ATTACHMENT:
- CHECK_COUNT;
- if(menu->tagprefix)
- {
- BODY *top;
- for(top = msg->content; top; top = top->next)
- {
- if(top->tagged)
- mutt_get_tmp_attachment(top);
- }
- menu->redraw = REDRAW_FULL;
- }
- else if (mutt_get_tmp_attachment(idx[menu->current]->content) == 0)
- menu->redraw = REDRAW_CURRENT;
-
- /* No send2hook since this doesn't change the message. */
- break;
-
- 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);
-
- }
- mutt_message_hook (NULL, msg, M_SEND2HOOK);
- break;
+ case OP_COMPOSE_GET_ATTACHMENT:
+ CHECK_COUNT;
+ if (menu->tagprefix) {
+ BODY *top;
+
+ for (top = msg->content; top; top = top->next) {
+ if (top->tagged)
+ mutt_get_tmp_attachment (top);
+ }
+ menu->redraw = REDRAW_FULL;
+ }
+ else if (mutt_get_tmp_attachment (idx[menu->current]->content) == 0)
+ menu->redraw = REDRAW_CURRENT;
+
+ /* No send2hook since this doesn't change the message. */
+ break;
+
+ case OP_COMPOSE_RENAME_FILE:
+ CHECK_COUNT;
+ m_strcpy(fname, sizeof(fname), idx[menu->current]->content->filename);
+ 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;
+
+ m_strreplace(&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) {
+ p_realloc(&idx, idxmax += 5);
+ menu->data = idx;
+ }
+
+ idx[idxlen] = p_new(ATTACHPTR, 1);
+ /* Touch the file */
+ if (!(fp = safe_fopen (fname, "w"))) {
+ mutt_error (_("Can't create file %s"), fname);
+ p_delete(&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;
+ m_strreplace(&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;