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;
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);
*/
/* 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
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;
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;
}
int r, need_buffy_cleanup = 0;
struct stat st;
char buf[SHORT_STRING];
+ int onm_flags;
if (post)
set_noconv_flags (hdr->content, 1);
}
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);