a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen#ifndef DSYNC_IBC_PRIVATE_H
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen#define DSYNC_IBC_PRIVATE_H
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen#include "dsync-ibc.h"
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainenstruct dsync_ibc_vfuncs {
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void (*deinit)(struct dsync_ibc *ibc);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void (*send_handshake)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_ibc_settings *set);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen enum dsync_ibc_recv_ret
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen (*recv_handshake)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_ibc_settings **set_r);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
b8e6e314eb2f9f1fc8ce2999034321bfeb7a2269Timo Sirainen void (*send_end_of_list)(struct dsync_ibc *ibc,
b8e6e314eb2f9f1fc8ce2999034321bfeb7a2269Timo Sirainen enum dsync_ibc_eol_type type);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void (*send_mailbox_state)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mailbox_state *state);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen enum dsync_ibc_recv_ret
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen (*recv_mailbox_state)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen struct dsync_mailbox_state *state_r);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void (*send_mailbox_tree_node)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const char *const *name,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mailbox_node *node);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen enum dsync_ibc_recv_ret
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen (*recv_mailbox_tree_node)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const char *const **name_r,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mailbox_node **node_r);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void (*send_mailbox_deletes)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mailbox_delete *deletes,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen unsigned int count, char hierarchy_sep);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen enum dsync_ibc_recv_ret
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen (*recv_mailbox_deletes)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mailbox_delete **deletes_r,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen unsigned int *count_r,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen char *hierarchy_sep_r);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void (*send_mailbox)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mailbox *dsync_box);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen enum dsync_ibc_recv_ret
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen (*recv_mailbox)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mailbox **dsync_box_r);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen void (*send_mailbox_attribute)(struct dsync_ibc *ibc,
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen const struct dsync_mailbox_attribute *attr);
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen enum dsync_ibc_recv_ret
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen (*recv_mailbox_attribute)(struct dsync_ibc *ibc,
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen const struct dsync_mailbox_attribute **attr_r);
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void (*send_change)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mail_change *change);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen enum dsync_ibc_recv_ret
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen (*recv_change)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mail_change **change_r);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void (*send_mail_request)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mail_request *request);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen enum dsync_ibc_recv_ret
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen (*recv_mail_request)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mail_request **request_r);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void (*send_mail)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen const struct dsync_mail *mail);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen enum dsync_ibc_recv_ret
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen (*recv_mail)(struct dsync_ibc *ibc,
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen struct dsync_mail **mail_r);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
ce0e25f26d6e67480ee39b5ca0ad634fa60c4605Timo Sirainen void (*send_finish)(struct dsync_ibc *ibc, const char *error,
e229fe84553486b4ab37584f2a896a33384d0d70Timo Sirainen enum mail_error mail_error,
e229fe84553486b4ab37584f2a896a33384d0d70Timo Sirainen bool require_full_resync);
24bd831901b8fd59718e353b36eaef6a950f09a2Timo Sirainen enum dsync_ibc_recv_ret
ce0e25f26d6e67480ee39b5ca0ad634fa60c4605Timo Sirainen (*recv_finish)(struct dsync_ibc *ibc, const char **error_r,
e229fe84553486b4ab37584f2a896a33384d0d70Timo Sirainen enum mail_error *mail_error_r,
e229fe84553486b4ab37584f2a896a33384d0d70Timo Sirainen bool *require_full_resync_r);
24bd831901b8fd59718e353b36eaef6a950f09a2Timo Sirainen
f476a2abe41082176e65425358bf01bdcc86a41cTimo Sirainen void (*close_mail_streams)(struct dsync_ibc *ibc);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen bool (*is_send_queue_full)(struct dsync_ibc *ibc);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen bool (*has_pending_data)(struct dsync_ibc *ibc);
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen};
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainenstruct dsync_ibc {
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen struct dsync_ibc_vfuncs v;
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen io_callback_t *io_callback;
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen void *io_context;
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool failed:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool timeout:1;
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen};
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen
a85473f7c11c8734bdee9c2cbe4b767f144a18aaTimo Sirainen#endif