1 changeset: 5949:b2b97c7a2ae6
3 user: Brendan Cully <brendan@kublai.com>
4 date: Fri Jun 26 21:47:34 2009 -0700
5 summary: Set internaldate of messages appended to IMAP mailboxes
7 --- a/imap/imap_private.h
8 +++ b/imap/imap_private.h
10 #define IMAP_CMD_PASS (1<<1)
11 #define IMAP_CMD_QUEUE (1<<2)
13 +/* length of "DD-MMM-YYYY HH:MM:SS +ZZzz" (null-terminated) */
14 +#define IMAP_DATELEN 27
19 @@ -281,6 +284,7 @@ char* imap_get_qualifier (char* buf);
20 int imap_mxcmp (const char* mx1, const char* mx2);
21 char* imap_next_word (char* s);
22 time_t imap_parse_date (char* s);
23 +void imap_make_date (char* buf, time_t timestamp);
24 void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path);
25 void imap_quote_string (char* dest, size_t slen, const char* src);
26 void imap_unquote_string (char* s);
29 @@ -600,6 +600,7 @@ int imap_append_message (CONTEXT *ctx, M
30 char buf[LONG_STRING];
31 char mbox[LONG_STRING];
32 char mailbox[LONG_STRING];
33 + char internaldate[IMAP_DATELEN];
35 progress_t progressbar;
37 @@ -641,12 +642,14 @@ int imap_append_message (CONTEXT *ctx, M
38 M_PROGRESS_SIZE, NetInc, len);
40 imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
41 - snprintf (buf, sizeof (buf), "APPEND %s (%s%s%s%s%s) {%lu}", mbox,
42 + imap_make_date (internaldate, msg->received);
43 + snprintf (buf, sizeof (buf), "APPEND %s (%s%s%s%s%s) \"%s\" {%lu}", mbox,
44 msg->flags.read ? "\\Seen" : "",
45 msg->flags.read && (msg->flags.replied || msg->flags.flagged) ? " " : "",
46 msg->flags.replied ? "\\Answered" : "",
47 msg->flags.replied && msg->flags.flagged ? " " : "",
48 msg->flags.flagged ? "\\Flagged" : "",
52 imap_cmd_start (idata, buf);
55 @@ -577,6 +577,21 @@ time_t imap_parse_date (char *s)
56 return (mutt_mktime (&t, 0) + tz);
59 +/* format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz.
60 + * Caller should provide a buffer of IMAP_DATELEN bytes */
61 +void imap_make_date (char *buf, time_t timestamp)
63 + struct tm* tm = localtime (×tamp);
64 + time_t tz = mutt_local_tz (timestamp);
68 + snprintf (buf, IMAP_DATELEN, "%02d-%s-%d %02d:%02d:%02d %+03d%02d",
69 + tm->tm_mday, Months[tm->tm_mon], tm->tm_year + 1900,
70 + tm->tm_hour, tm->tm_min, tm->tm_sec,
71 + (int) tz / 60, (int) abs (tz) % 60);
74 /* imap_qualify_path: make an absolute IMAP folder target, given IMAP_MBOX
75 * and relative path. */
76 void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path)