virtual-save.c revision bcb4e51a409d94ae670de96afb8483a4f7855294
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
697ff56bf3cdc9e7989ea2a70accf866b14b64d1Timo Sirainenvirtual_save_alloc(struct mailbox_transaction_context *_t)
d2e74f2af690b8e2d536400f02f397cbed1334b7Timo Sirainen struct virtual_mailbox *mbox = (struct virtual_mailbox *)_t->box;
13d98ffa534f2e7d04a832c9d0153fc9c568b878Timo Sirainen struct mailbox_transaction_context *backend_trans;
697ff56bf3cdc9e7989ea2a70accf866b14b64d1Timo Sirainen ctx = (struct virtual_save_context *)_t->save_ctx;
8e371a3ce32bd64288786855b8ce0cb63f19f7d1Timo Sirainen virtual_backend_box_open(mbox, mbox->save_bbox) < 0) {
220e21750948941dc6e33b8f11b552fa21d7f81eTimo Sirainen errstr = mailbox_get_last_error(mbox->save_bbox->box,
8a0ad174adb1eb5108511b90e97f4e5f9089b0eeTimo Sirainen virtual_transaction_get(_t, mbox->save_bbox->box);
8a0ad174adb1eb5108511b90e97f4e5f9089b0eeTimo Sirainen ctx->backend_save_ctx = mailbox_save_alloc(backend_trans);
8a0ad174adb1eb5108511b90e97f4e5f9089b0eeTimo Sirainen virtual_backend_box_accessed(mbox, mbox->save_bbox);
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen const char *const *kwp;
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen unsigned int i;
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen if (src_keywords == NULL || src_keywords->count == 0)
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen t_array_init(&kw_strings, src_keywords->count + 1);
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen mailbox_get_open_status(src_box, STATUS_KEYWORDS, &status);
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen kwp = array_idx(status.keywords, src_keywords->idx[i]);
8a0ad174adb1eb5108511b90e97f4e5f9089b0eeTimo Sirainen return mailbox_keywords_create_valid(dest_box,
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainenint virtual_save_begin(struct mail_save_context *_ctx, struct istream *input)
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen /* mailbox_open() failed */
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen mail_storage_set_error(_ctx->transaction->box->storage,
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen mail_storage_set_error(_ctx->transaction->box->storage,
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen "Can't save messages to this virtual mailbox");
a24519c36d5f8fa22f58b2c693ba547e8d175a54Timo Sirainen ctx->backend_box = ctx->backend_save_ctx->transaction->box;
a24519c36d5f8fa22f58b2c693ba547e8d175a54Timo Sirainen keywords = virtual_copy_keywords(_ctx->transaction->box, mdata->keywords,
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen mailbox_save_set_received_date(ctx->backend_save_ctx,
db8b0a3f74a20528d66a3c4be7df920e5c4554c2Timo Sirainen mailbox_save_set_from_envelope(ctx->backend_save_ctx,
ac2defed599a97c4a71a9e90ba185929dfe59226Josef 'Jeff' Sipek mailbox_save_set_guid(ctx->backend_save_ctx, mdata->guid);
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen mailbox_save_set_min_modseq(ctx->backend_save_ctx, mdata->min_modseq);
db8b0a3f74a20528d66a3c4be7df920e5c4554c2Timo Sirainen virtual_mail_set_unattached_backend_mail(_ctx->dest_mail,
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen return mailbox_save_begin(&ctx->backend_save_ctx, input);
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainenint virtual_save_continue(struct mail_save_context *_ctx)
2649b237dd4690575e75a30b2bf3b39ebd37b835Timo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen return mailbox_save_continue(ctx->backend_save_ctx);
63e207529879438e9f4412d97cdc34bdc82a3702Timo Sirainenint virtual_save_finish(struct mail_save_context *_ctx)
2649b237dd4690575e75a30b2bf3b39ebd37b835Timo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
ac2defed599a97c4a71a9e90ba185929dfe59226Josef 'Jeff' Sipek ret = mailbox_save_finish(&ctx->backend_save_ctx);
a24519c36d5f8fa22f58b2c693ba547e8d175a54Timo Sirainenvoid virtual_save_cancel(struct mail_save_context *_ctx)
a24519c36d5f8fa22f58b2c693ba547e8d175a54Timo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainenvoid virtual_save_free(struct mail_save_context *_ctx)
3fe67ec75ccae1230bb9eb9f16affc48377f6441Timo Sirainen struct virtual_save_context *ctx = (struct virtual_save_context *)_ctx;