bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenvirtual_save_alloc(struct mailbox_transaction_context *_t)
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen struct virtual_mailbox *mbox = (struct virtual_mailbox *)_t->box;
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen struct mailbox_transaction_context *backend_trans;
395682d473b161c86165e7b9323ce4e45afb94bdTimo Sirainen ctx = (struct virtual_save_context *)_t->save_ctx;
d979c1179d55ad86e40f869e48ef3e4db9c817b5Timo Sirainen virtual_backend_box_open(mbox, mbox->save_bbox) < 0) {
18a41cbd38f83429b790414c1159c097af4a59b8Timo Sirainen errstr = mailbox_get_last_error(mbox->save_bbox->box,
18a41cbd38f83429b790414c1159c097af4a59b8Timo Sirainen virtual_transaction_get(_t, mbox->save_bbox->box);
18a41cbd38f83429b790414c1159c097af4a59b8Timo Sirainen ctx->backend_save_ctx = mailbox_save_alloc(backend_trans);
0eef579fa2714c8b6b6bc2e54c545d291e657f8fTimo Sirainen virtual_backend_box_accessed(mbox, mbox->save_bbox);
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen unsigned int i;
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen if (src_keywords == NULL || src_keywords->count == 0)
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen t_array_init(&kw_strings, src_keywords->count + 1);
51327f2489a4e0e615eb9f7d921473cf8512bb79Timo Sirainen mailbox_get_open_status(src_box, STATUS_KEYWORDS, &status);
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen kwp = array_idx(status.keywords, src_keywords->idx[i]);
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen return mailbox_keywords_create_valid(dest_box,
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenint virtual_save_begin(struct mail_save_context *_ctx, struct istream *input)
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
18a41cbd38f83429b790414c1159c097af4a59b8Timo Sirainen /* mailbox_open() failed */
18a41cbd38f83429b790414c1159c097af4a59b8Timo Sirainen mail_storage_set_error(_ctx->transaction->box->storage,
18a41cbd38f83429b790414c1159c097af4a59b8Timo Sirainen mail_storage_set_error(_ctx->transaction->box->storage,
18a41cbd38f83429b790414c1159c097af4a59b8Timo Sirainen "Can't save messages to this virtual mailbox");
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen ctx->backend_box = ctx->backend_save_ctx->transaction->box;
c9c4494be2e6e8664ed2a37f74c2989c9b0ffe65Aki Tuomi keywords = virtual_copy_keywords(_ctx->transaction->box, mdata->keywords,
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen mailbox_save_set_received_date(ctx->backend_save_ctx,
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen mailbox_save_set_from_envelope(ctx->backend_save_ctx,
99695d99930b35c2bac85d52e976b44cf8485d83Timo Sirainen mailbox_save_set_guid(ctx->backend_save_ctx, mdata->guid);
99695d99930b35c2bac85d52e976b44cf8485d83Timo Sirainen mailbox_save_set_min_modseq(ctx->backend_save_ctx, mdata->min_modseq);
8eba883232f80178b60fa416f73292bf5f990fecTimo Sirainen virtual_mail_set_unattached_backend_mail(_ctx->dest_mail,
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen return mailbox_save_begin(&ctx->backend_save_ctx, input);
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenint virtual_save_continue(struct mail_save_context *_ctx)
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen return mailbox_save_continue(ctx->backend_save_ctx);
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenint virtual_save_finish(struct mail_save_context *_ctx)
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
c9c4494be2e6e8664ed2a37f74c2989c9b0ffe65Aki Tuomi ret = mailbox_save_finish(&ctx->backend_save_ctx);
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenvoid virtual_save_cancel(struct mail_save_context *_ctx)
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainenvoid virtual_save_free(struct mail_save_context *_ctx)
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;