2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen/* Returns 1 = ok, 0 = client output buffer full, call again, -1 = error.
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen mail = NULL for deinit. */
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainentypedef int imap_fetch_handler_t(struct imap_fetch_context *ctx,
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainen /* Returns FALSE and sets ctx->error if arg is invalid */
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainen bool (*init)(struct imap_fetch_init_context *ctx);
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen const ARRAY_TYPE(uint32_t) *qresync_sample_seqset;
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen const ARRAY_TYPE(uint32_t) *qresync_sample_uidset;
d10a370b2614712d9cb6a1dd8625f62a071b6377Timo Sirainen int (*cont_handler)(struct imap_fetch_context *ctx);
905627a760ce8bf4141b361f72858a99975ded3cTimo Sirainen /* TRUE if the first FETCH parameter result hasn't yet been sent to
905627a760ce8bf4141b361f72858a99975ded3cTimo Sirainen the IMAP client. Note that this doesn't affect buffered content in
905627a760ce8bf4141b361f72858a99975ded3cTimo Sirainen cur_str until it gets flushed out. */
905627a760ce8bf4141b361f72858a99975ded3cTimo Sirainen /* TRUE if the cur_str prefix has been flushed. More data may still
905627a760ce8bf4141b361f72858a99975ded3cTimo Sirainen be added to it. */
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen ARRAY(struct imap_fetch_context_handler) handlers;
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainenvoid imap_fetch_handlers_register(const struct imap_fetch_handler *handlers,
67c25cb4af273aff7384d5028d459cc9afdf8712Timo Sirainenvoid imap_fetch_handler_unregister(const char *name);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenvoid imap_fetch_add_handler(struct imap_fetch_init_context *ctx,
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen#define imap_fetch_add_handler(ctx, flags, nil_reply, handler, context) \
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen imap_fetch_add_handler(ctx, flags, nil_reply + \
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenint imap_fetch_att_list_parse(struct client *client, pool_t pool,
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen const char **error_r);
cddfd1355db6b60c71d7ee3c0b4f23b3efcc9ad1Timo Sirainenimap_fetch_alloc(struct client *client, pool_t pool, const char *reason);
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainenvoid imap_fetch_free(struct imap_fetch_context **ctx);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenbool imap_fetch_init_handler(struct imap_fetch_init_context *init_ctx);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenvoid imap_fetch_init_nofail_handler(struct imap_fetch_context *ctx,
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainen bool (*init)(struct imap_fetch_init_context *));
67c25cb4af273aff7384d5028d459cc9afdf8712Timo Sirainenconst struct imap_fetch_handler *imap_fetch_handler_lookup(const char *name);
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenvoid imap_fetch_begin(struct imap_fetch_context *ctx, struct mailbox *box,
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainenint imap_fetch_send_vanished(struct client *client, struct mailbox *box,
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen const struct imap_fetch_qresync_args *qresync_args);
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen/* Returns 1 if finished, 0 if more data is needed, -1 if error.
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen When 0 is returned, line_partial=TRUE if literal is open and must be
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen finished before anything else to client. */
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainenint imap_fetch_more(struct imap_fetch_context *ctx,
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen/* Like imap_fetch_more(), but don't check/update output_lock.
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen The caller must handle this itself. */
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainenint imap_fetch_more_no_lock_update(struct imap_fetch_context *ctx);
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainenint imap_fetch_end(struct imap_fetch_context *ctx);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenint imap_fetch_more(struct imap_fetch_context *ctx,
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenbool imap_fetch_flags_init(struct imap_fetch_init_context *ctx);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenbool imap_fetch_modseq_init(struct imap_fetch_init_context *ctx);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenbool imap_fetch_uid_init(struct imap_fetch_init_context *ctx);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenbool imap_fetch_body_section_init(struct imap_fetch_init_context *ctx);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenbool imap_fetch_rfc822_init(struct imap_fetch_init_context *ctx);
306b3f41b05da642d87e7ca7a1496efce9f5902fTimo Sirainenbool imap_fetch_binary_init(struct imap_fetch_init_context *ctx);