dovecot-2.1: lib-storage: Preserve from_envelope in save context...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jan 18 16:52:37 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/7ee2cfbcae2e
changeset: 13947:7ee2cfbcae2e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jan 18 16:51:22 2012 +0200
description:
lib-storage: Preserve from_envelope in save context's dest_mail even if it's temporary.
This allows looking it up while the mail is being saved.

diffstat:

 src/lib-storage/index/index-mail.c    |  16 ++++++++++++++++
 src/lib-storage/index/index-mail.h    |   2 ++
 src/lib-storage/index/index-storage.c |   2 +-
 3 files changed, 19 insertions(+), 1 deletions(-)

diffs (64 lines):

diff -r a4e61c99c7eb -r 7ee2cfbcae2e src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Wed Jan 18 14:21:53 2012 +0200
+++ b/src/lib-storage/index/index-mail.c	Wed Jan 18 16:51:22 2012 +0200
@@ -1077,6 +1077,9 @@
 		*value_r = data->envelope;
 		return 0;
 	case MAIL_FETCH_FROM_ENVELOPE:
+		*value_r = data->from_envelope != NULL ?
+			data->from_envelope : "";
+		return 0;
 	case MAIL_FETCH_UIDL_FILE_NAME:
 	case MAIL_FETCH_UIDL_BACKEND:
 	case MAIL_FETCH_SEARCH_RELEVANCY:
@@ -1749,3 +1752,16 @@
 {
 	return 0;
 }
+
+void index_mail_save_finish(struct mail_save_context *ctx)
+{
+	struct index_mail *imail = (struct index_mail *)ctx->dest_mail;
+
+	if (imail == NULL)
+		return;
+
+	if (ctx->from_envelope != NULL && imail->data.from_envelope == NULL) {
+		imail->data.from_envelope =
+			p_strdup(imail->data_pool, ctx->from_envelope);
+	}
+}
diff -r a4e61c99c7eb -r 7ee2cfbcae2e src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h	Wed Jan 18 14:21:53 2012 +0200
+++ b/src/lib-storage/index/index-mail.h	Wed Jan 18 16:51:22 2012 +0200
@@ -78,6 +78,7 @@
 
 	struct message_part *parts;
 	const char *envelope, *body, *bodystructure, *uid_string, *guid;
+	const char *from_envelope;
 	struct message_part_envelope_data *envelope_data;
 
 	uint32_t seq;
@@ -235,5 +236,6 @@
 
 int index_mail_cache_lookup_field(struct index_mail *mail, buffer_t *buf,
 				  unsigned int field_idx);
+void index_mail_save_finish(struct mail_save_context *ctx);
 
 #endif
diff -r a4e61c99c7eb -r 7ee2cfbcae2e src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c	Wed Jan 18 14:21:53 2012 +0200
+++ b/src/lib-storage/index/index-storage.c	Wed Jan 18 16:51:22 2012 +0200
@@ -606,6 +606,7 @@
 
 void index_save_context_free(struct mail_save_context *ctx)
 {
+	index_mail_save_finish(ctx);
 	i_free_and_null(ctx->from_envelope);
 	i_free_and_null(ctx->guid);
 	i_free_and_null(ctx->pop3_uidl);
@@ -698,4 +699,3 @@
 	}
 	return 0;
 }
-


More information about the dovecot-cvs mailing list