summaryrefslogtreecommitdiffstats
path: root/imap/message.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2019-07-27 13:44:36 -0700
committerKevin McCarthy <kevin@8t8.us>2019-08-03 14:08:09 -0700
commitec6953f510fe5cd4b931304fe626be1650a1fa1a (patch)
tree27cdae24b9e8aa8453bc23d82b0916f00cccfe1d /imap/message.c
parent0d94a3dc611064dd87a3488f9db60c8d580075e4 (diff)
Add AUTOCRYPT header to imap fetch list.
If $autocrypt is set, add the header to make IMAP behave the same as other formats (parsing on initial mailbox opening). This will also be useful if we perform an initial scan during account creation, to make that work for IMAP too.
Diffstat (limited to 'imap/message.c')
-rw-r--r--imap/message.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/imap/message.c b/imap/message.c
index be6e4a7e..d1f0d6c1 100644
--- a/imap/message.c
+++ b/imap/message.c
@@ -708,21 +708,36 @@ static int read_headers_fetch_new (IMAP_DATA *idata, unsigned int msn_begin,
char tempfile[_POSIX_PATH_MAX];
FILE *fp = NULL;
IMAP_HEADER h;
- BUFFER *b = NULL;
+ BUFFER *b = NULL, *hdr_list = NULL;
static const char * const want_headers = "DATE FROM SENDER SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL";
ctx = idata->ctx;
idx = ctx->msgcount;
+ hdr_list = mutt_buffer_pool_get ();
+ mutt_buffer_strcpy (hdr_list, want_headers);
+ if (ImapHeaders)
+ {
+ mutt_buffer_addch (hdr_list, ' ');
+ mutt_buffer_addstr (hdr_list, ImapHeaders);
+ }
+#ifdef USE_AUTOCRYPT
+ if (option (OPTAUTOCRYPT))
+ {
+ mutt_buffer_addch (hdr_list, ' ');
+ mutt_buffer_addstr (hdr_list, "AUTOCRYPT");
+ }
+#endif
+
if (mutt_bit_isset (idata->capabilities,IMAP4REV1))
{
- safe_asprintf (&hdrreq, "BODY.PEEK[HEADER.FIELDS (%s%s%s)]",
- want_headers, ImapHeaders ? " " : "", NONULL (ImapHeaders));
+ safe_asprintf (&hdrreq, "BODY.PEEK[HEADER.FIELDS (%s)]",
+ mutt_b2s (hdr_list));
}
else if (mutt_bit_isset (idata->capabilities,IMAP4))
{
- safe_asprintf (&hdrreq, "RFC822.HEADER.LINES (%s%s%s)",
- want_headers, ImapHeaders ? " " : "", NONULL (ImapHeaders));
+ safe_asprintf (&hdrreq, "RFC822.HEADER.LINES (%s)",
+ mutt_b2s (hdr_list));
}
else
{ /* Unable to fetch headers for lower versions */
@@ -731,6 +746,8 @@ static int read_headers_fetch_new (IMAP_DATA *idata, unsigned int msn_begin,
goto bail;
}
+ mutt_buffer_pool_release (&hdr_list);
+
/* instead of downloading all headers and then parsing them, we parse them
* as they come in. */
mutt_mktemp (tempfile, sizeof (tempfile));
@@ -891,6 +908,7 @@ static int read_headers_fetch_new (IMAP_DATA *idata, unsigned int msn_begin,
retval = 0;
bail:
+ mutt_buffer_pool_release (&hdr_list);
mutt_buffer_pool_release (&b);
safe_fclose (&fp);
FREE (&hdrreq);