]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added mail_parse().
authorTimo Sirainen <tss@iki.fi>
Thu, 5 May 2011 15:49:45 +0000 (17:49 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 5 May 2011 15:49:45 +0000 (17:49 +0200)
13 files changed:
src/lib-storage/index/cydir/cydir-mail.c
src/lib-storage/index/dbox-multi/mdbox-mail.c
src/lib-storage/index/dbox-single/sdbox-mail.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-mail.h
src/lib-storage/index/maildir/maildir-mail.c
src/lib-storage/index/mbox/mbox-mail.c
src/lib-storage/index/raw/raw-mail.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.h
src/lib-storage/mail.c
src/lib-storage/test-mail.c
src/plugins/virtual/virtual-mail.c

index 244d888a515e3eea06231c9af1766f349d48d7c5..5fa0f9c50dedffc14f39dd8377864a0c3d41cbeb 100644 (file)
@@ -152,6 +152,7 @@ struct mail_vfuncs cydir_mail_vfuncs = {
        index_mail_update_modseq,
        NULL,
        index_mail_expunge,
+       index_mail_parse,
        index_mail_set_cache_corrupted,
        index_mail_opened
 };
index 50b39e4569006439abb5d5ac527a3ceb67ca8e61..296e9566b8045e4e176ce4d8edb2cdc81b7ea564 100644 (file)
@@ -214,6 +214,7 @@ struct mail_vfuncs mdbox_mail_vfuncs = {
        index_mail_update_modseq,
        NULL,
        index_mail_expunge,
+       index_mail_parse,
        index_mail_set_cache_corrupted,
        index_mail_opened
 };
index 76586a714193be4b4ad9aba32816c4f9498b9828..175ef4ad502b8ea1085f9dc4683aa50bc1bb943b 100644 (file)
@@ -110,6 +110,7 @@ struct mail_vfuncs sdbox_mail_vfuncs = {
        index_mail_update_modseq,
        NULL,
        index_mail_expunge,
+       index_mail_parse,
        index_mail_set_cache_corrupted,
        index_mail_opened
 };
index 5bb1ef2d9aa49768b040c51671dd58efb6924455..a0f03171897a7e90e036b8e4784a547b46b0eb83 100644 (file)
@@ -1509,6 +1509,19 @@ void index_mail_expunge(struct mail *mail)
        }
 }
 
+void index_mail_parse(struct mail *mail, bool parse_body)
+{
+       struct index_mail *imail = (struct index_mail *)mail;
+
+       imail->data.access_part |= PARSE_HDR;
+       if (index_mail_parse_headers(imail, NULL) == 0) {
+               if (parse_body) {
+                       imail->data.access_part |= PARSE_BODY;
+                       (void)index_mail_parse_body(imail, 0);
+               }
+       }
+}
+
 void index_mail_set_cache_corrupted(struct mail *mail,
                                    enum mail_fetch_field field)
 {
index 651d7d438085a97c94ebe860591bfd2fa1b39ec9..4ebf43f58cfc582976b1cd6a5197092211bea1df 100644 (file)
@@ -202,6 +202,7 @@ void index_mail_update_keywords(struct mail *mail, enum modify_type modify_type,
                                struct mail_keywords *keywords);
 void index_mail_update_modseq(struct mail *mail, uint64_t min_modseq);
 void index_mail_expunge(struct mail *mail);
+void index_mail_parse(struct mail *mail, bool parse_body);
 void index_mail_set_cache_corrupted(struct mail *mail,
                                    enum mail_fetch_field field);
 int index_mail_opened(struct mail *mail, struct istream **stream);
index 8837cea675d453b0725e92e4fd41728c6d6910cf..e3f2dae8a4bc81db89c3d036dc4646d97ed7b577 100644 (file)
@@ -656,6 +656,7 @@ struct mail_vfuncs maildir_mail_vfuncs = {
        index_mail_update_modseq,
        maildir_update_pop3_uidl,
        index_mail_expunge,
+       index_mail_parse,
        maildir_mail_set_cache_corrupted,
        index_mail_opened
 };
index 0bb212063f216cf01b53a0f9e3570b8fd34f3fa3..47566a0500e64631ff77e9d291f126cb5b3dcd2c 100644 (file)
@@ -411,6 +411,7 @@ struct mail_vfuncs mbox_mail_vfuncs = {
        index_mail_update_modseq,
        NULL,
        index_mail_expunge,
+       index_mail_parse,
        index_mail_set_cache_corrupted,
        index_mail_opened
 };
index 6a3aac3addaad4f179f4cc27504e5d95b245135f..2e754d54bebbe923c1a96b694c716b5968af8d0c 100644 (file)
@@ -138,6 +138,7 @@ struct mail_vfuncs raw_mail_vfuncs = {
        index_mail_update_modseq,
        NULL,
        index_mail_expunge,
+       index_mail_parse,
        index_mail_set_cache_corrupted,
        index_mail_opened
 };
index e1c7da52cfaa1fceb5847dae916d19fd5e1d5059..8ca43ed8e32fd371d12f4bf94a5c9abadbbdde5b 100644 (file)
@@ -336,6 +336,7 @@ struct mail_vfuncs {
        void (*update_modseq)(struct mail *mail, uint64_t min_modseq);
        void (*update_pop3_uidl)(struct mail *mail, const char *uidl);
        void (*expunge)(struct mail *mail);
+       void (*parse)(struct mail *mail, bool parse_body);
        void (*set_cache_corrupted)(struct mail *mail,
                                    enum mail_fetch_field field);
        int (*istream_opened)(struct mail *mail, struct istream **input);
index 0c88dfb256d5228a5b0517dc3f8c39eb392faa24..7feaaffd0fa0d125ad2baecda974136814d25d1d 100644 (file)
@@ -704,6 +704,9 @@ void mail_expunge(struct mail *mail);
 
 /* Returns TRUE if anything is cached for the mail, FALSE if not. */
 bool mail_is_cached(struct mail *mail);
+/* Parse mail's header and optionally body so that fields using them get
+   cached. */
+void mail_parse(struct mail *mail, bool parse_body);
 /* Mark a cached field corrupted and have it recalculated. */
 void mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field);
 
index 50faf5a7d3ed92c541629f8722f8fa89bfe79a58..2ba727083f94bdbbea741a325fbdb8addf3c9a7d 100644 (file)
@@ -246,6 +246,13 @@ bool mail_is_cached(struct mail *mail)
                                           mail->seq);
 }
 
+void mail_parse(struct mail *mail, bool parse_body)
+{
+       struct mail_private *p = (struct mail_private *)mail;
+
+       p->v.parse(mail, parse_body);
+}
+
 void mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field)
 {
        struct mail_private *p = (struct mail_private *)mail;
index a8eb0f272424d3e67b402dcab551716542ebf896..e804e11d20f088d092bbe5b5ca94194afdfc05cb 100644 (file)
@@ -195,6 +195,11 @@ static void test_mail_expunge(struct mail *mail ATTR_UNUSED)
 {
 }
 
+static void test_mail_parse(struct mail *mail ATTR_UNUSED,
+                           bool parse_body ATTR_UNUSED)
+{
+}
+
 static void
 test_mail_set_cache_corrupted(struct mail *mail ATTR_UNUSED,
                              enum mail_fetch_field field ATTR_UNUSED)
@@ -229,6 +234,7 @@ struct mail_vfuncs test_mail_vfuncs = {
        test_mail_update_modseq,
        NULL,
        test_mail_expunge,
+       test_mail_parse,
        test_mail_set_cache_corrupted,
        NULL
 };
index 1c43675cf41e61cf47388435ae5fb11af7efdc2b..5a33b3f61ed8b30b1f35a65bab03ee212373f7c3 100644 (file)
@@ -369,6 +369,15 @@ static void virtual_mail_expunge(struct mail *mail)
        mail_expunge(vmail->backend_mail);
 }
 
+static void virtual_mail_parse(struct mail *mail, bool parse_body)
+{
+       struct virtual_mail *vmail = (struct virtual_mail *)mail;
+
+       if (virtual_mail_handle_lost(vmail) < 0)
+               return;
+       mail_parse(vmail->backend_mail, parse_body);
+}
+
 static void
 virtual_mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field)
 {
@@ -407,6 +416,7 @@ struct mail_vfuncs virtual_mail_vfuncs = {
        index_mail_update_modseq,
        virtual_mail_update_pop3_uidl,
        virtual_mail_expunge,
+       virtual_mail_parse,
        virtual_mail_set_cache_corrupted,
        NULL
 };