changeset 21543:eea5b9a884f8

lib-storage: Add mailbox_save_get_dest_mail() This marks mailbox_save_set_dest_mail deprecated. It's not efficient to use since it frees the already-created dest_mail.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 09 Feb 2017 18:46:14 +0200
parents ab3bec3c09a8
children 8851e74dd61f
files src/lib-storage/mail-storage.c src/lib-storage/mail-storage.h
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-storage.c	Mon Feb 13 20:23:49 2017 +0200
+++ b/src/lib-storage/mail-storage.c	Thu Feb 09 18:46:14 2017 +0200
@@ -2151,6 +2151,11 @@
 	ctx->dest_mail_external = TRUE;
 }
 
+struct mail *mailbox_save_get_dest_mail(struct mail_save_context *ctx)
+{
+	return ctx->dest_mail;
+}
+
 int mailbox_save_begin(struct mail_save_context **ctx, struct istream *input)
 {
 	struct mailbox *box = (*ctx)->transaction->box;
--- a/src/lib-storage/mail-storage.h	Mon Feb 13 20:23:49 2017 +0200
+++ b/src/lib-storage/mail-storage.h	Thu Feb 09 18:46:14 2017 +0200
@@ -756,12 +756,11 @@
    of the mailbox. Not all backends support this. */
 void mailbox_save_set_pop3_order(struct mail_save_context *ctx,
 				 unsigned int order);
-/* If dest_mail is set, the saved message can be accessed using it. Note that
-   setting it may require mailbox syncing, so don't set it unless you need
-   it. Also you shouldn't try to access it before mailbox_save_finish() is
-   called. */
+/* FIXME: Remove in v2.3. Obsolete - use mailbox_save_get_dest_mail() instead */
 void mailbox_save_set_dest_mail(struct mail_save_context *ctx,
 				struct mail *mail);
+/* Returns the destination mail */
+struct mail *mailbox_save_get_dest_mail(struct mail_save_context *ctx);
 /* Begin saving the message. All mail_save_set_*() calls must have been called
    before this function. If the save initialization fails, the context is freed
    and -1 is returned. After beginning the save you should keep calling