dovecot-2.0: lib-storage: Added mail_parse().
dovecot at dovecot.org
dovecot at dovecot.org
Thu May 5 19:14:20 EEST 2011
details: http://hg.dovecot.org/dovecot-2.0/rev/e9918fd289f3
changeset: 12773:e9918fd289f3
user: Timo Sirainen <tss at iki.fi>
date: Thu May 05 17:49:45 2011 +0200
description:
lib-storage: Added mail_parse().
diffstat:
src/lib-storage/index/cydir/cydir-mail.c | 1 +
src/lib-storage/index/dbox-multi/mdbox-mail.c | 1 +
src/lib-storage/index/dbox-single/sdbox-mail.c | 1 +
src/lib-storage/index/index-mail.c | 13 +++++++++++++
src/lib-storage/index/index-mail.h | 1 +
src/lib-storage/index/maildir/maildir-mail.c | 1 +
src/lib-storage/index/mbox/mbox-mail.c | 1 +
src/lib-storage/index/raw/raw-mail.c | 1 +
src/lib-storage/mail-storage-private.h | 1 +
src/lib-storage/mail-storage.h | 3 +++
src/lib-storage/mail.c | 7 +++++++
src/lib-storage/test-mail.c | 6 ++++++
src/plugins/virtual/virtual-mail.c | 10 ++++++++++
13 files changed, 47 insertions(+), 0 deletions(-)
diffs (191 lines):
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/index/cydir/cydir-mail.c
--- a/src/lib-storage/index/cydir/cydir-mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/index/cydir/cydir-mail.c Thu May 05 17:49:45 2011 +0200
@@ -152,6 +152,7 @@
index_mail_update_modseq,
NULL,
index_mail_expunge,
+ index_mail_parse,
index_mail_set_cache_corrupted,
index_mail_opened
};
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/index/dbox-multi/mdbox-mail.c
--- a/src/lib-storage/index/dbox-multi/mdbox-mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c Thu May 05 17:49:45 2011 +0200
@@ -214,6 +214,7 @@
index_mail_update_modseq,
NULL,
index_mail_expunge,
+ index_mail_parse,
index_mail_set_cache_corrupted,
index_mail_opened
};
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/index/dbox-single/sdbox-mail.c
--- a/src/lib-storage/index/dbox-single/sdbox-mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/index/dbox-single/sdbox-mail.c Thu May 05 17:49:45 2011 +0200
@@ -110,6 +110,7 @@
index_mail_update_modseq,
NULL,
index_mail_expunge,
+ index_mail_parse,
index_mail_set_cache_corrupted,
index_mail_opened
};
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/index/index-mail.c Thu May 05 17:49:45 2011 +0200
@@ -1509,6 +1509,19 @@
}
}
+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)
{
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/index/index-mail.h Thu May 05 17:49:45 2011 +0200
@@ -202,6 +202,7 @@
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);
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/index/maildir/maildir-mail.c Thu May 05 17:49:45 2011 +0200
@@ -656,6 +656,7 @@
index_mail_update_modseq,
maildir_update_pop3_uidl,
index_mail_expunge,
+ index_mail_parse,
maildir_mail_set_cache_corrupted,
index_mail_opened
};
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/index/mbox/mbox-mail.c
--- a/src/lib-storage/index/mbox/mbox-mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/index/mbox/mbox-mail.c Thu May 05 17:49:45 2011 +0200
@@ -411,6 +411,7 @@
index_mail_update_modseq,
NULL,
index_mail_expunge,
+ index_mail_parse,
index_mail_set_cache_corrupted,
index_mail_opened
};
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/index/raw/raw-mail.c
--- a/src/lib-storage/index/raw/raw-mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/index/raw/raw-mail.c Thu May 05 17:49:45 2011 +0200
@@ -138,6 +138,7 @@
index_mail_update_modseq,
NULL,
index_mail_expunge,
+ index_mail_parse,
index_mail_set_cache_corrupted,
index_mail_opened
};
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/mail-storage-private.h Thu May 05 17:49:45 2011 +0200
@@ -336,6 +336,7 @@
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);
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/mail-storage.h Thu May 05 17:49:45 2011 +0200
@@ -704,6 +704,9 @@
/* 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);
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/mail.c
--- a/src/lib-storage/mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/mail.c Thu May 05 17:49:45 2011 +0200
@@ -246,6 +246,13 @@
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;
diff -r 55ff92050bd7 -r e9918fd289f3 src/lib-storage/test-mail.c
--- a/src/lib-storage/test-mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/lib-storage/test-mail.c Thu May 05 17:49:45 2011 +0200
@@ -195,6 +195,11 @@
{
}
+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 @@
test_mail_update_modseq,
NULL,
test_mail_expunge,
+ test_mail_parse,
test_mail_set_cache_corrupted,
NULL
};
diff -r 55ff92050bd7 -r e9918fd289f3 src/plugins/virtual/virtual-mail.c
--- a/src/plugins/virtual/virtual-mail.c Thu May 05 17:48:55 2011 +0200
+++ b/src/plugins/virtual/virtual-mail.c Thu May 05 17:49:45 2011 +0200
@@ -369,6 +369,15 @@
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 @@
index_mail_update_modseq,
virtual_mail_update_pop3_uidl,
virtual_mail_expunge,
+ virtual_mail_parse,
virtual_mail_set_cache_corrupted,
NULL
};
More information about the dovecot-cvs
mailing list