From: Timo Sirainen Date: Fri, 15 May 2015 11:34:54 +0000 (+0300) Subject: lib-imap-storage: Added imap_msgpart_contains_body() X-Git-Tag: 2.2.19.rc1~489 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbb5807edb9c8e71b94102ea91319f11ef63fb6e;p=thirdparty%2Fdovecot%2Fcore.git lib-imap-storage: Added imap_msgpart_contains_body() --- diff --git a/src/lib-imap-storage/imap-msgpart.c b/src/lib-imap-storage/imap-msgpart.c index 8b4044947c..c4bb777ab3 100644 --- a/src/lib-imap-storage/imap-msgpart.c +++ b/src/lib-imap-storage/imap-msgpart.c @@ -306,6 +306,22 @@ void imap_msgpart_free(struct imap_msgpart **_msgpart) pool_unref(&msgpart->pool); } +bool imap_msgpart_contains_body(const struct imap_msgpart *msgpart) +{ + switch (msgpart->fetch_type) { + case FETCH_HEADER: + case FETCH_HEADER_FIELDS: + case FETCH_HEADER_FIELDS_NOT: + return FALSE; + case FETCH_FULL: + case FETCH_MIME: + case FETCH_MIME_BODY: + case FETCH_BODY: + break; + } + return TRUE; +} + void imap_msgpart_set_decode_to_binary(struct imap_msgpart *msgpart) { msgpart->decode_cte_to_binary = TRUE; diff --git a/src/lib-imap-storage/imap-msgpart.h b/src/lib-imap-storage/imap-msgpart.h index 21eb143d6c..4a016ba481 100644 --- a/src/lib-imap-storage/imap-msgpart.h +++ b/src/lib-imap-storage/imap-msgpart.h @@ -24,6 +24,11 @@ struct imap_msgpart *imap_msgpart_body(void); int imap_msgpart_parse(const char *section, struct imap_msgpart **msgpart_r); void imap_msgpart_free(struct imap_msgpart **msgpart); +/* Returns TRUE if the msgpart might return at least part of the message body. + Or alternatively: If FALSE is returned, the msgpart will never return + anything except (part of) the message header. MIME headers are counted + as part of the message body. */ +bool imap_msgpart_contains_body(const struct imap_msgpart *msgpart); /* Decode MIME parts with Content-Transfer-Encoding: base64/quoted-printable to binary data (IMAP BINARY extension). If something can't be decoded, fails with storage error set to MAIL_ERROR_CONVERSION. */