]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap-storage: Added imap_msgpart_contains_body()
authorTimo Sirainen <tss@iki.fi>
Fri, 15 May 2015 11:34:54 +0000 (14:34 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 15 May 2015 11:34:54 +0000 (14:34 +0300)
src/lib-imap-storage/imap-msgpart.c
src/lib-imap-storage/imap-msgpart.h

index 8b4044947c3cc4221a88214b7c491e6fe4b8c978..c4bb777ab37675f0db61ce704823e2a8a94cd1b8 100644 (file)
@@ -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;
index 21eb143d6c98b7f63167efb2ac28d470cdf1c5a1..4a016ba4815dfef67ecc932d9238af5ef7513696 100644 (file)
@@ -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. */