X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=imap%2Fmessage.c;h=3c5011c10e018cb10e1d56da9247358f459c88f5;hb=643be053e447a35cccc37550ac0087bb5bb5c5ad;hp=1221e7a55b3a12777a82fd708811281d3459e0e4;hpb=ce2c6b74b93777c66708ef0cfb7cc14ff1bf6a94;p=apps%2Fmadmutt.git diff --git a/imap/message.c b/imap/message.c index 1221e7a..3c5011c 100644 --- a/imap/message.c +++ b/imap/message.c @@ -19,6 +19,10 @@ /* message parsing/updating functions */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include #include @@ -32,6 +36,12 @@ #include "pgp.h" #endif +#if HAVE_STDINT_H +#include +#elif HAVE_INTTYPES_H +#include +#endif + static void flush_buffer(char* buf, size_t* len, CONNECTION* conn); static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp); @@ -61,11 +71,11 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend) IMAP_HEADER h; int rc, mfhrc, oldmsgcount; int fetchlast = 0; - const char *want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE IN-REPLY-TO REPLY-TO LINES X-LABEL"; + const char *want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL"; #if USE_HCACHE void *hc = NULL; - unsigned long long *uid_validity = NULL; + uint64_t *uid_validity = NULL; char uid_buf[64]; #endif /* USE_HCACHE */ @@ -77,13 +87,13 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend) if (mutt_bit_isset (idata->capabilities,IMAP4REV1)) { - snprintf (hdrreq, sizeof (hdrreq), "BODY.PEEK[HEADER.FIELDS (%s)]", - want_headers); + snprintf (hdrreq, sizeof (hdrreq), "BODY.PEEK[HEADER.FIELDS (%s%s%s)]", + want_headers, ImapHeaders ? " " : "", ImapHeaders ? ImapHeaders : ""); } else if (mutt_bit_isset (idata->capabilities,IMAP4)) { - snprintf (hdrreq, sizeof (hdrreq), "RFC822.HEADER.LINES (%s)", - want_headers); + snprintf (hdrreq, sizeof (hdrreq), "RFC822.HEADER.LINES (%s%s%s)", + want_headers, ImapHeaders ? " " : "", ImapHeaders ? ImapHeaders : ""); } else { /* Unable to fetch headers for lower versions */ @@ -150,7 +160,7 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend) fputs ("\n\n", fp); sprintf(uid_buf, "/%u", h.data->uid); /* XXX --tg 21:41 04-07-11 */ - uid_validity = (unsigned long long *) mutt_hcache_fetch (hc, uid_buf, &imap_hcache_keylen); + uid_validity = (uint64_t *) mutt_hcache_fetch (hc, uid_buf, &imap_hcache_keylen); if (uid_validity != NULL && *uid_validity == idata->uid_validity) { @@ -376,7 +386,7 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) * command handler */ h->active = 0; - snprintf (buf, sizeof (buf), "UID FETCH %d %s", HEADER_DATA(h)->uid, + snprintf (buf, sizeof (buf), "UID FETCH %u %s", HEADER_DATA(h)->uid, (mutt_bit_isset (idata->capabilities, IMAP4REV1) ? (option (OPTIMAPPEEK) ? "BODY.PEEK[]" : "BODY[]") : "RFC822")); @@ -552,7 +562,13 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg) rewind (fp); imap_munge_mbox_name (mbox, sizeof (mbox), mailbox); - snprintf (buf, sizeof (buf), "APPEND %s (\\Seen) {%d}", mbox, len); + snprintf (buf, sizeof (buf), "APPEND %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" : "", + (unsigned long) len); imap_cmd_start (idata, buf); @@ -778,8 +794,8 @@ void imap_add_keywords (char* s, HEADER* h, LIST* mailbox_flags, size_t slen) { if (msg_has_flag (mailbox_flags, keywords->data)) { - strncat (s, keywords->data, slen); - strncat (s, " ", slen); + safe_strcat (s, slen, keywords->data); + safe_strcat (s, slen, " "); } keywords = keywords->next; } @@ -876,19 +892,20 @@ static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp) if (msg_parse_fetch (h, buf) != -2) return rc; - if (imap_get_literal_count (buf, &bytes) < 0) - return rc; - imap_read_literal (fp, idata, bytes); - - /* we may have other fields of the FETCH _after_ the literal - * (eg Domino puts FLAGS here). Nothing wrong with that, either. - * This all has to go - we should accept literals and nonliterals - * interchangeably at any time. */ - if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE) - return -2; + if (imap_get_literal_count (buf, &bytes) == 0) + { + imap_read_literal (fp, idata, bytes); + + /* we may have other fields of the FETCH _after_ the literal + * (eg Domino puts FLAGS here). Nothing wrong with that, either. + * This all has to go - we should accept literals and nonliterals + * interchangeably at any time. */ + if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE) + return rc; - if (msg_parse_fetch (h, idata->cmd.buf) == -1) - return rc; + if (msg_parse_fetch (h, idata->cmd.buf) == -1) + return rc; + } rc = 0; /* success */