}
}
-static void _mutt_save_message (HEADER *h, CONTEXT *ctx, int delete, int decode, int decrypt)
+void _mutt_save_message (HEADER *h, CONTEXT *ctx, int delete, int decode, int decrypt)
{
int cmflags, chflags;
int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
{
IMAP_DATA* idata;
+ CONTEXT* appendctx = NULL;
char buf[HUGE_STRING];
char flags[LONG_STRING];
char tmp[LONG_STRING];
{
if (ctx->hdrs[n]->changed)
{
- mutt_message (_("Saving message status flags... [%d/%d]"), n+1, ctx->msgcount);
-
+ mutt_message (_("Saving message status flags... [%d/%d]"), n+1,
+ ctx->msgcount);
+
+ /* if attachments have been deleted we delete the message and reupload
+ * it. This works better if we're expunging, of course. */
+ if (ctx->hdrs[n]->attach_del)
+ {
+ dprint (3, (debugfile, "imap_sync_mailbox: Attachments to be deleted, falling back to _mutt_save_message\n"));
+ appendctx = mx_open_mailbox (ctx->path, M_APPEND | M_QUIET, NULL);
+ _mutt_save_message (ctx->hdrs[n], appendctx, 1, 0, 0);
+ }
flags[0] = '\0';
imap_set_flag (idata, IMAP_ACL_SEEN, ctx->hdrs[n]->read, "\\Seen ",
err_continue = imap_continue ("imap_sync_mailbox: STORE failed",
idata->cmd.buf);
if (err_continue != M_YES)
- return -1;
+ {
+ rc = -1;
+ goto out;
+ }
}
ctx->hdrs[n]->changed = 0;
if (imap_exec (idata, "EXPUNGE", 0) != 0)
{
imap_error ("imap_sync_mailbox: EXPUNGE failed", idata->cmd.buf);
- return -1;
+ rc = -1;
+ goto out;
}
}
- return 0;
+ rc = 0;
+ out:
+ if (appendctx)
+ {
+ mx_fastclose_mailbox (appendctx);
+ FREE (&appendctx);
+ }
+ return rc;
}
/* imap_close_mailbox: issue close command if neccessary, reset IMAP_DATA */
if (imap_parse_path (dest, &mx))
{
- dprint (1, (debugfile, "imap_copy_message: bad destination %s\n", dest));
+ dprint (1, (debugfile, "imap_copy_messages: bad destination %s\n", dest));
return -1;
}
/* check that the save-to folder is in the same account */
if (!mutt_account_match (&(CTX_DATA->conn->account), &(mx.account)))
{
- dprint (3, (debugfile, "imap_copy_message: %s not same server as %s\n",
+ dprint (3, (debugfile, "imap_copy_messages: %s not same server as %s\n",
dest, ctx->path));
return 1;
}
+ if (h && h->attach_del)
+ {
+ dprint (3, (debugfile, "imap_copy_messages: Message contains attachments to be deleted\n"));
+ return 1;
+ }
+
imap_fix_path (idata, mx.mbox, cmd, sizeof (cmd));
/* Null HEADER* means copy tagged messages */
if (!h)
{
+ /* if any messages have attachments to delete, fall through to FETCH
+ * and APPEND. TODO: Copy what we can with COPY, fall through for the
+ * remainder. */
+ for (n = 0; n < ctx->msgcount; n++)
+ {
+ if (ctx->hdrs[n]->tagged && ctx->hdrs[n]->attach_del)
+ {
+ dprint (3, (debugfile, "imap_copy_messages: Message contains attachments to be deleted\n"));
+ return 1;
+ }
+ }
+
rc = imap_make_msg_set (idata, buf, sizeof (buf), M_TAG, 0);
if (!rc)
{
{
mx_fastclose_mailbox (ctx);
if (!pctx)
- safe_free ((void **) &ctx);
+ FREE (&ctx);
return NULL;
}
return ctx;
{
mx_fastclose_mailbox (ctx);
if (!pctx)
- safe_free ((void **) &ctx);
+ FREE (&ctx);
}
unset_option (OPTFORCEREFRESH);
int mutt_parse_unmono (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_push (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_rc_line (/* const */ char *, BUFFER *, BUFFER *);
-int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short user_hdrs, short weed,
- short do_2047, LIST **lastp);
+int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p,
+ short user_hdrs, short weed, short do_2047, LIST **lastp);
int mutt_parse_score (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_unscore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_unhook (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_print_attachment (FILE *, BODY *);
int mutt_query_complete (char *, size_t);
int mutt_save_attachment (FILE *, BODY *, char *, int, HEADER *);
+void _mutt_save_message (HEADER *, CONTEXT *, int, int, int);
int mutt_save_message (HEADER *, int, int, int, int *);
int mutt_search_command (int, int);
int mutt_compose_menu (HEADER *, char *, size_t, HEADER *);