~ubuntu-branches/ubuntu/maverick/mutt/maverick

« back to all changes in this revision

Viewing changes to debian/patches/upstream/573823-imap_internal_date

  • Committer: Package Import Robot
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy)
  • Date: 2010-06-22 17:48:54 UTC
  • mfrom: (2.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20100622174854-grpayfk2rgoyl2qk
Tags: 1.5.20-9ubuntu1
* Merge with Debian (LP: #588736). Remaining changes:
  + debian/control, debian/patches/debian-specific/build_doc_adjustments.diff:
    Use w3m (main) instead of elinks (universe) for generating documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
changeset:   5949:b2b97c7a2ae6
 
2
branch:      HEAD
 
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
 
6
 
 
7
--- a/imap/imap_private.h
 
8
+++ b/imap/imap_private.h
 
9
@@ -70,6 +70,9 @@
 
10
 #define IMAP_CMD_PASS    (1<<1)
 
11
 #define IMAP_CMD_QUEUE   (1<<2)
 
12
 
 
13
+/* length of "DD-MMM-YYYY HH:MM:SS +ZZzz" (null-terminated) */
 
14
+#define IMAP_DATELEN 27
 
15
+
 
16
 enum
 
17
 {
 
18
   IMAP_FATAL = 1,
 
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);
 
27
--- a/imap/message.c
 
28
+++ b/imap/message.c
 
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];
 
34
   size_t len;
 
35
   progress_t progressbar;
 
36
   size_t sent;
 
37
@@ -641,12 +642,14 @@ int imap_append_message (CONTEXT *ctx, M
 
38
                      M_PROGRESS_SIZE, NetInc, len);
 
39
 
 
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"  : "",
 
49
+           internaldate,
 
50
            (unsigned long) len);
 
51
 
 
52
   imap_cmd_start (idata, buf);
 
53
--- a/imap/util.c
 
54
+++ b/imap/util.c
 
55
@@ -577,6 +577,21 @@ time_t imap_parse_date (char *s)
 
56
   return (mutt_mktime (&t, 0) + tz);
 
57
 }
 
58
 
 
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)
 
62
+{
 
63
+  struct tm* tm = localtime (&timestamp);
 
64
+  time_t tz = mutt_local_tz (timestamp);
 
65
+
 
66
+  tz /= 60;
 
67
+
 
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);
 
72
+}
 
73
+
 
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)