imap-fetch.h revision be48f0e5693530f97f60c6f9dce8c8c08a38b584
#ifndef IMAP_FETCH_H
#define IMAP_FETCH_H
struct imap_fetch_context;
enum imap_fetch_handler_flags {
IMAP_FETCH_HANDLER_FLAG_BUFFERED = 0x01,
};
/* Returns 1 = ok, 0 = client output buffer full, call again, -1 = error.
mail = NULL for deinit. */
struct imap_fetch_init_context {
struct imap_fetch_context *fetch_ctx;
const char *name;
const char *error;
};
struct imap_fetch_handler {
const char *name;
/* Returns FALSE and sets ctx->error if arg is invalid */
};
struct imap_fetch_context_handler {
void *context;
const char *name;
const char *nil_reply;
unsigned int buffered:1;
unsigned int want_deinit:1;
};
struct imap_fetch_qresync_args {
};
struct imap_fetch_state {
struct mailbox_transaction_context *trans;
struct mail_search_context *search_ctx;
unsigned int cur_handler;
const char *cur_human_name;
bool skip_cr;
unsigned int fetching:1;
unsigned int seen_flags_changed:1;
unsigned int cur_first:1;
unsigned int cur_flushed:1;
unsigned int line_partial:1;
unsigned int line_finished:1;
unsigned int skipped_expunged_msgs:1;
unsigned int failed:1;
};
struct imap_fetch_context {
enum mail_fetch_field fetch_data;
unsigned int buffered_handlers_count;
struct imap_fetch_state state;
unsigned int initialized:1;
unsigned int flags_have_handler:1;
unsigned int flags_update_seen:1;
unsigned int flags_show_only_seen_changes:1;
};
const char *nil_reply,
CALLBACK_TYPECHECK(handler, int (*)( \
struct imap_fetch_context *, struct mail *, \
struct imap_fetch_context **fetch_ctx_r,
const char **error_r);
struct imap_fetch_context *
bool (*init)(struct imap_fetch_init_context *));
struct mail_search_args *search_args);
const struct mail_search_args *search_args,
const struct imap_fetch_qresync_args *qresync_args);
/* Returns 1 if finished, 0 if more data is needed, -1 if error.
When 0 is returned, line_partial=TRUE if literal is open and must be
finished before anything else to client. */
struct client_command_context *cmd);
The caller must handle this itself. */
struct client_command_context *cmd);
void imap_fetch_handlers_init(void);
void imap_fetch_handlers_deinit(void);
#endif