Someone trying to use mutt with FastMail was having a problem where a postponed message was not editable in the web ui. It turns out it was because the message, when saved, did not include the IMAP \Draft flag.
I'm not too familiar with the mx and imap code in mutt, so the attached patch may be a bit clumsy. It does seem to fix the problem, though. -Kevin
# HG changeset patch # User Kevin McCarthy <[email protected]> # Date 1392350861 28800 # Thu Feb 13 20:07:41 2014 -0800 # Node ID ef8daedf5bf4ba08f470c292e10f27ddf7283302 # Parent 8f62001989cc9f564236e54b318ecca05f551af2 Send the IMAP \Draft flag when postponing a message. This patch adds a mx_open_new_message flag, M_SET_DRAFT, and a MESSAGE->flags.draft flag. mutt_write_fcc passes the M_SET_DRAFT flag to mx_open_new_message, which sets MESSAGE->flags.draft. The imap_append_message can just barely tolerate one more flag check using the existing logic of assembling IMAP flags. It possibly should be rewritten. diff --git a/imap/message.c b/imap/message.c --- a/imap/message.c +++ b/imap/message.c @@ -638,22 +638,24 @@ } rewind (fp); mutt_progress_init (&progressbar, _("Uploading message..."), M_PROGRESS_SIZE, NetInc, len); imap_munge_mbox_name (mbox, sizeof (mbox), mailbox); imap_make_date (internaldate, msg->received); - snprintf (buf, sizeof (buf), "APPEND %s (%s%s%s%s%s) \"%s\" {%lu}", mbox, + snprintf (buf, sizeof (buf), "APPEND %s (%s%s%s%s%s%s%s) \"%s\" {%lu}", mbox, msg->flags.read ? "\\Seen" : "", - msg->flags.read && (msg->flags.replied || msg->flags.flagged) ? " " : "", + msg->flags.read && (msg->flags.replied || msg->flags.flagged || msg->flags.draft) ? " " : "", msg->flags.replied ? "\\Answered" : "", - msg->flags.replied && msg->flags.flagged ? " " : "", + msg->flags.replied && (msg->flags.flagged || msg->flags.draft) ? " " : "", msg->flags.flagged ? "\\Flagged" : "", + msg->flags.flagged && msg->flags.draft ? " " : "", + msg->flags.draft ? "\\Draft" : "", internaldate, (unsigned long) len); imap_cmd_start (idata, buf); do rc = imap_cmd_step (idata); while (rc == IMAP_CMD_CONTINUE); diff --git a/mailbox.h b/mailbox.h --- a/mailbox.h +++ b/mailbox.h @@ -24,17 +24,18 @@ #define M_APPEND (1<<1) /* open mailbox for appending messages */ #define M_READONLY (1<<2) /* open in read-only mode */ #define M_QUIET (1<<3) /* do not print any messages */ #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses * safe_fopen() for mbox-style folders. */ /* mx_open_new_message() */ -#define M_ADD_FROM 1 /* add a From_ line */ +#define M_ADD_FROM (1<<0) /* add a From_ line */ +#define M_SET_DRAFT (1<<1) /* set the message draft flag */ /* return values from mx_check_mailbox() */ enum { M_NEW_MAIL = 1, /* new mail received in mailbox */ M_LOCKED, /* couldn't lock the mailbox */ M_REOPENED, /* mailbox was reopened */ M_FLAGS /* nondestructive flags change (IMAP) */ @@ -45,16 +46,17 @@ FILE *fp; /* pointer to the message data */ char *path; /* path to temp file */ short magic; /* type of mailbox this message belongs to */ short write; /* nonzero if message is open for writing */ struct { unsigned read : 1; unsigned flagged : 1; unsigned replied : 1; + unsigned draft : 1; } flags; time_t received; /* the time at which this message was received */ } MESSAGE; CONTEXT *mx_open_mailbox (const char *, int, CONTEXT *); MESSAGE *mx_open_message (CONTEXT *, int); MESSAGE *mx_open_new_message (CONTEXT *, HEADER *, int); diff --git a/mx.c b/mx.c --- a/mx.c +++ b/mx.c @@ -1250,16 +1250,17 @@ msg->magic = dest->magic; msg->write = 1; if (hdr) { msg->flags.flagged = hdr->flagged; msg->flags.replied = hdr->replied; msg->flags.read = hdr->read; + msg->flags.draft = (flags & M_SET_DRAFT) ? 1 : 0; msg->received = hdr->received; } if(msg->received == 0) time(&msg->received); if (func (msg, dest, hdr) == 0) { diff --git a/sendlib.c b/sendlib.c --- a/sendlib.c +++ b/sendlib.c @@ -2713,17 +2713,17 @@ return (-1); } /* remember new mail status before appending message */ need_buffy_cleanup = 1; stat (path, &st); } hdr->read = !post; /* make sure to put it in the `cur' directory (maildir) */ - if ((msg = mx_open_new_message (&f, hdr, M_ADD_FROM)) == NULL) + if ((msg = mx_open_new_message (&f, hdr, M_ADD_FROM | (post ? M_SET_DRAFT : 0))) == NULL) { mx_close_mailbox (&f, NULL); return (-1); } /* post == 1 => postpone message. Set mode = -1 in mutt_write_rfc822_header() * post == 0 => Normal mode. Set mode = 0 in mutt_write_rfc822_header() * */
signature.asc
Description: PGP signature
