changeset: 6412:688d66ae6014
user: Kevin McCarthy <[email protected]>
date: Thu Jan 15 14:18:53 2015 -0800
link: http://dev.mutt.org/hg/mutt/rev/688d66ae6014
Send the IMAP \Draft flag when postponing a message.
This patch adds a mx_open_new_message() flag, M_SET_DRAFT. It also adds
a MESSAGE->flags.draft flag.
mutt_write_fcc() passes the M_SET_DRAFT flag to mx_open_new_message(),
which then sets MESSAGE->flags.draft. Then, imap_append_message() is
able to see this flag and so adds the \Draft flag.
The imap_append_message() function started to have a bit too many flags,
so this version of the patch separates out the flag generating code into
a simpler version.
diffs (92 lines):
diff -r 200185ed86bc -r 688d66ae6014 imap/message.c
--- a/imap/message.c Sat Jan 31 11:53:47 2015 -0800
+++ b/imap/message.c Thu Jan 15 14:18:53 2015 -0800
@@ -601,6 +601,7 @@
char mbox[LONG_STRING];
char mailbox[LONG_STRING];
char internaldate[IMAP_DATELEN];
+ char imap_flags[SHORT_STRING];
size_t len;
progress_t progressbar;
size_t sent;
@@ -643,12 +644,19 @@
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,
- msg->flags.read ? "\\Seen" : "",
- msg->flags.read && (msg->flags.replied || msg->flags.flagged) ? " "
: "",
- msg->flags.replied ? "\\Answered" : "",
- msg->flags.replied && msg->flags.flagged ? " " : "",
- msg->flags.flagged ? "\\Flagged" : "",
+
+ imap_flags[0] = imap_flags[1] = 0;
+ if (msg->flags.read)
+ safe_strcat (imap_flags, sizeof (imap_flags), " \\Seen");
+ if (msg->flags.replied)
+ safe_strcat (imap_flags, sizeof (imap_flags), " \\Answered");
+ if (msg->flags.flagged)
+ safe_strcat (imap_flags, sizeof (imap_flags), " \\Flagged");
+ if (msg->flags.draft)
+ safe_strcat (imap_flags, sizeof (imap_flags), " \\Draft");
+
+ snprintf (buf, sizeof (buf), "APPEND %s (%s) \"%s\" {%lu}", mbox,
+ imap_flags + 1,
internaldate,
(unsigned long) len);
diff -r 200185ed86bc -r 688d66ae6014 mailbox.h
--- a/mailbox.h Sat Jan 31 11:53:47 2015 -0800
+++ b/mailbox.h Thu Jan 15 14:18:53 2015 -0800
@@ -29,7 +29,8 @@
*/
/* 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
@@ -50,6 +51,7 @@
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;
diff -r 200185ed86bc -r 688d66ae6014 mx.c
--- a/mx.c Sat Jan 31 11:53:47 2015 -0800
+++ b/mx.c Thu Jan 15 14:18:53 2015 -0800
@@ -1255,6 +1255,7 @@
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;
}
diff -r 200185ed86bc -r 688d66ae6014 sendlib.c
--- a/sendlib.c Sat Jan 31 11:53:47 2015 -0800
+++ b/sendlib.c Thu Jan 15 14:18:53 2015 -0800
@@ -2696,6 +2696,7 @@
int r, need_buffy_cleanup = 0;
struct stat st;
char buf[SHORT_STRING];
+ int onm_flags;
if (post)
set_noconv_flags (hdr->content, 1);
@@ -2725,7 +2726,10 @@
}
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)
+ onm_flags = M_ADD_FROM;
+ if (post)
+ onm_flags |= M_SET_DRAFT;
+ if ((msg = mx_open_new_message (&f, hdr, onm_flags)) == NULL)
{
mx_close_mailbox (&f, NULL);
return (-1);