-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-1.11.1.bk.gmail-labels.1
134 lines (126 loc) · 4.43 KB
/
patch-1.11.1.bk.gmail-labels.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
diff -Naur mutt-1.11.1/PATCHES mutt-1.11.1-gmail-labels/PATCHES
--- mutt-1.11.1/PATCHES 2017-12-02 19:10:17.000000000 -0800
+++ mutt-1.11.1-gmail-labels/PATCHES 2018-12-27 11:00:55.000000000 -0800
@@ -0,0 +1 @@
+patch-1.11.1.bk.gmail-labels.1
diff -Naur mutt-1.11.1/imap/command.c mutt-1.11.1-gmail-labels/imap/command.c
--- mutt-1.11.1/imap/command.c 2018-11-25 10:00:40.000000000 -0800
+++ mutt-1.11.1-gmail-labels/imap/command.c 2018-12-27 10:57:52.000000000 -0800
@@ -73,6 +73,7 @@
"ENABLE",
"CONDSTORE",
"QRESYNC",
+ "X-GM-EXT-1",
NULL
};
diff -Naur mutt-1.11.1/imap/imap_private.h mutt-1.11.1-gmail-labels/imap/imap_private.h
--- mutt-1.11.1/imap/imap_private.h 2018-11-25 10:00:40.000000000 -0800
+++ mutt-1.11.1-gmail-labels/imap/imap_private.h 2018-12-27 10:58:55.000000000 -0800
@@ -120,6 +120,7 @@
ENABLE, /* RFC 5161 */
CONDSTORE, /* RFC 7162 */
QRESYNC, /* RFC 7162 */
+ X_GM_EXT_1, /* Gmail IMAP Extensions */
CAPMAX
};
diff -Naur mutt-1.11.1/imap/message.c mutt-1.11.1-gmail-labels/imap/message.c
--- mutt-1.11.1/imap/message.c 2018-11-30 15:01:52.000000000 -0800
+++ mutt-1.11.1-gmail-labels/imap/message.c 2018-12-27 10:52:52.000000000 -0800
@@ -736,8 +736,10 @@
mutt_buffer_add_printf (b, "%u:%u", msn_begin, msn_end);
fetch_msn_end = msn_end;
- safe_asprintf (&cmd, "FETCH %s (UID FLAGS INTERNALDATE RFC822.SIZE %s)",
- b->data, hdrreq);
+ safe_asprintf (&cmd, "FETCH %s (%sUID FLAGS INTERNALDATE RFC822.SIZE X-GM-LABELS %s)",
+ b->data,
+ mutt_bit_isset (idata->capabilities, X_GM_EXT_1) ? "X-GM-MSGID " : "",
+ hdrreq);
imap_cmd_start (idata, cmd);
FREE (&cmd);
mutt_buffer_free (&b);
@@ -821,6 +823,7 @@
0, 0);
/* content built as a side-effect of mutt_read_rfc822_header */
ctx->hdrs[idx]->content->length = h.content_length;
+ ctx->hdrs[idx]->env->x_label = h.data->labels;
ctx->size += h.content_length;
#if USE_HCACHE
@@ -936,6 +939,12 @@
}
}
+ if (mutt_bit_isset (idata->capabilities, X_GM_EXT_1))
+ {
+ fprintf (msg->fp, "X-Gm-Msgid:%llu\n", HEADER_DATA(h)->msgid);
+ fprintf (msg->fp, "X-Gm-Permalink: https://mail.google.com/mail/#all/%llx\n", HEADER_DATA(h)->msgid);
+ }
+
/* mark this header as currently inactive so the command handler won't
* also try to update it. HACK until all this code can be moved into the
* command handler */
@@ -1702,11 +1711,57 @@
{
SKIPWS (s);
+ if (ascii_strncasecmp ("X-GM-LABELS", s, 11) == 0)
+ {
+ s += 11;
+ SKIPWS (s);
+ ptmp = tmp;
+ s++; /* skip ( */
+ while (*s && *s != ')')
+ {
+ if (ptmp-tmp == sizeof(tmp)/sizeof(char))
+ s++;
+ else if (ascii_strncasecmp ("\"\\\\Important\"", s, 13) == 0)
+ {
+ s += 13;
+ SKIPWS (s);
+ }
+ else if (ascii_strncasecmp ("\"\\\\Starred\"", s, 11) == 0)
+ {
+ s += 11;
+ SKIPWS (s);
+ }
+ else if (ascii_strncasecmp ("\"\\\\", s, 3) == 0)
+ s += 3;
+ else if (ascii_strncasecmp ("\"", s, 1) == 0)
+ s++;
+ else
+ *ptmp++ = *s++;
+
+ if (*s == ')' && *(ptmp-1) == ' ')
+ ptmp--;
+ }
+ if (*s != ')')
+ return -1;
+ s++; /* skip ) */
+ *ptmp = 0;
+ h->data->labels = safe_strdup(tmp);
+ SKIPWS (s);
+ }
+
if (ascii_strncasecmp ("FLAGS", s, 5) == 0)
{
if ((s = msg_parse_flags (h, s)) == NULL)
return -1;
}
+ else if (ascii_strncasecmp ("X-GM-MSGID", s, 10) == 0)
+ {
+ s += 10;
+ SKIPWS (s);
+ h->data->msgid = strtoull (s, NULL, 10);
+
+ s = imap_next_word (s);
+ }
else if (ascii_strncasecmp ("UID", s, 3) == 0)
{
s += 3;
diff -Naur mutt-1.11.1/imap/message.h mutt-1.11.1-gmail-labels/imap/message.h
--- mutt-1.11.1/imap/message.h 2018-11-25 10:00:40.000000000 -0800
+++ mutt-1.11.1-gmail-labels/imap/message.h 2018-12-27 10:52:52.000000000 -0800
@@ -37,6 +37,8 @@
unsigned int uid; /* 32-bit Message UID */
unsigned int msn; /* Message Sequence Number */
+ unsigned long long msgid;
+ char *labels;
LIST *keywords;
} IMAP_HEADER_DATA;