1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#ifndef DBOX_SAVE_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define DBOX_SAVE_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen#include "dbox-storage.h"
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct dbox_save_context {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mail_save_context ctx;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mail_index_transaction *trans;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* updated for each appended mail: */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen uint32_t seq;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct istream *input;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
e6440616c02bb1404dc35debf45d9741260c7831Timo Sirainen struct ostream *dbox_output;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
2b9dbb270ad82e58d5f3581436e6f143176d5819Timo Sirainen uint32_t highest_pop3_uidl_seq;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool failed:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool finished:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool have_pop3_uidls:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool have_pop3_orders:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
804fa3f03bd9170272168a5ad214053bbe3160c7Josef 'Jeff' Sipek#define DBOX_SAVECTX(s) container_of(s, struct dbox_save_context, ctx)
804fa3f03bd9170272168a5ad214053bbe3160c7Josef 'Jeff' Sipek
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid dbox_save_begin(struct dbox_save_context *ctx, struct istream *input);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint dbox_save_continue(struct mail_save_context *_ctx);
e6440616c02bb1404dc35debf45d9741260c7831Timo Sirainenvoid dbox_save_end(struct dbox_save_context *ctx);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid dbox_save_write_metadata(struct mail_save_context *ctx,
1f19649986397419d014febd1337c6eb7b530f26Timo Sirainen struct ostream *output, uoff_t output_msg_size,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const char *orig_mailbox_name,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen guid_128_t guid_128_r) ATTR_NULL(4);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid dbox_save_add_to_index(struct dbox_save_context *ctx);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
9865d9e7c5713e41db939222ed9c0225a11fb99eTimo Sirainenvoid dbox_save_update_header_flags(struct dbox_save_context *ctx,
9865d9e7c5713e41db939222ed9c0225a11fb99eTimo Sirainen struct mail_index_view *sync_view,
9865d9e7c5713e41db939222ed9c0225a11fb99eTimo Sirainen uint32_t ext_id,
9865d9e7c5713e41db939222ed9c0225a11fb99eTimo Sirainen unsigned int flags_offset);
9865d9e7c5713e41db939222ed9c0225a11fb99eTimo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#endif