virtual-save.c revision 3657abd8e4d63adb35a9242c47e0a53cfe010e78
89a126810703c666309310d0f3189e9834d70b5bTimo Sirainen/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenvirtual_save_alloc(struct mailbox_transaction_context *_t)
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct virtual_mailbox *mbox = (struct virtual_mailbox *)_t->box;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mailbox_transaction_context *backend_trans;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen ctx = t->save_ctx = i_new(struct virtual_save_context, 1);
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen virtual_transaction_get(_t, mbox->save_bbox->box);
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainen ctx->backend_save_ctx = mailbox_save_alloc(backend_trans);
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen const char *const *kwp;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen unsigned int i;
fc84f8af4794f4bb6caf6e5ec3fb1f8cebd0462aTimo Sirainen if (src_keywords == NULL || src_keywords->count == 0)
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen t_array_init(&kw_strings, src_keywords->count + 1);
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen mailbox_get_status(src_box, STATUS_KEYWORDS, &status);
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainen kwp = array_idx(status.keywords, src_keywords->idx[i]);
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen return mailbox_keywords_create_valid(dest_box,
8a1c866a4c429f26c8746525f82024bc387f1407Timo Sirainenint virtual_save_begin(struct mail_save_context *_ctx, struct istream *input)
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen (struct virtual_mailbox *)_ctx->transaction->box;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen mail_storage_set_error(_ctx->transaction->box->storage,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen "Can't save messages to this virtual mailbox");
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen ctx->backend_box = ctx->backend_save_ctx->transaction->box;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen virtual_copy_keywords(_ctx->transaction->box, _ctx->keywords,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen mailbox_save_set_flags(ctx->backend_save_ctx, _ctx->flags,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen mailbox_save_set_received_date(ctx->backend_save_ctx,
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen mailbox_save_set_from_envelope(ctx->backend_save_ctx,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen mailbox_save_set_guid(ctx->backend_save_ctx, _ctx->guid);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen mail = virtual_mail_set_backend_mail(_ctx->dest_mail,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen mailbox_save_set_dest_mail(ctx->backend_save_ctx, mail);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen return mailbox_save_begin(&ctx->backend_save_ctx, input);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenint virtual_save_continue(struct mail_save_context *_ctx)
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen return mailbox_save_continue(ctx->backend_save_ctx);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenint virtual_save_finish(struct mail_save_context *_ctx)
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen return mailbox_save_finish(&ctx->backend_save_ctx);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenvoid virtual_save_cancel(struct mail_save_context *_ctx)
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenvoid virtual_save_free(struct virtual_save_context *ctx)