7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#ifndef DSYNC_MAILBOX_TREE_H
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#define DSYNC_MAILBOX_TREE_H
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#include "guid.h"
ce0e25f26d6e67480ee39b5ca0ad634fa60c4605Timo Sirainen#include "mail-error.h"
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct mail_namespace;
be2bc5677a16a3547d5cbfd21c9deedc96a759adTimo Sirainenstruct dsync_brain;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
e83126866761632b437e532dfdc30be01d14039dTimo Sirainenenum dsync_mailbox_trees_sync_type {
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen /* two-way sync for both mailboxes */
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen DSYNC_MAILBOX_TREES_SYNC_TYPE_TWOWAY,
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen /* make remote tree look exactly like the local tree */
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_LOCAL,
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen /* make local tree look exactly like the remote tree */
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_REMOTE
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen};
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen
be2bc5677a16a3547d5cbfd21c9deedc96a759adTimo Sirainenenum dsync_mailbox_trees_sync_flags {
be2bc5677a16a3547d5cbfd21c9deedc96a759adTimo Sirainen /* Enable debugging */
be2bc5677a16a3547d5cbfd21c9deedc96a759adTimo Sirainen DSYNC_MAILBOX_TREES_SYNC_FLAG_DEBUG = 0x01,
be2bc5677a16a3547d5cbfd21c9deedc96a759adTimo Sirainen /* Show ourself as "master brain" in the debug output */
1a1d00fd04bfcf8436b00b58d527e46b23523c9dTimo Sirainen DSYNC_MAILBOX_TREES_SYNC_FLAG_MASTER_BRAIN = 0x02,
1a1d00fd04bfcf8436b00b58d527e46b23523c9dTimo Sirainen /* Disable mailbox renaming logic. This is just a kludge that should
1a1d00fd04bfcf8436b00b58d527e46b23523c9dTimo Sirainen be removed once the renaming logic has no more bugs.. */
1a1d00fd04bfcf8436b00b58d527e46b23523c9dTimo Sirainen DSYNC_MAILBOX_TREES_SYNC_FLAG_NO_RENAMES = 0x04
be2bc5677a16a3547d5cbfd21c9deedc96a759adTimo Sirainen};
be2bc5677a16a3547d5cbfd21c9deedc96a759adTimo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenenum dsync_mailbox_node_existence {
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* this is just a filler node for children or for
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen subscription deletion */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_NODE_NONEXISTENT = 0,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* if mailbox GUID is set, the mailbox exists.
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen otherwise the directory exists. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_NODE_EXISTS,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* if mailbox GUID is set, the mailbox has been deleted.
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen otherwise the directory has been deleted. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_NODE_DELETED
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen};
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox_node {
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen struct dsync_mailbox_node *parent, *next, *first_child;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* namespace where this node belongs to */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen struct mail_namespace *ns;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* this node's name (not including parents) */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen const char *name;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* mailbox GUID, or full of zeros if this is about a directory name */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen guid_128_t mailbox_guid;
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen /* mailbox's UIDVALIDITY/UIDNEXT (may be 0 if not assigned yet) */
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen uint32_t uid_validity, uid_next;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* existence of this mailbox/directory.
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen doesn't affect subscription state. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen enum dsync_mailbox_node_existence existence;
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen /* last time the mailbox/directory was created/renamed,
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen 0 if not known */
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen time_t last_renamed_or_created;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* last time the subscription state was changed, 0 if not known */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen time_t last_subscription_change;
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen /* is this mailbox or directory subscribed? */
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool subscribed:1;
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen /* Internal syncing flags: */
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool sync_delayed_guid_change:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool sync_temporary_name:1;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen};
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo SirainenARRAY_DEFINE_TYPE(dsync_mailbox_node, struct dsync_mailbox_node *);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen#define dsync_mailbox_node_guids_equal(node1, node2) \
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen (memcmp((node1)->mailbox_guid, (node2)->mailbox_guid, \
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen sizeof(guid_128_t)) == 0)
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen#define dsync_mailbox_node_is_dir(node) \
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen guid_128_is_empty((node)->mailbox_guid)
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainenenum dsync_mailbox_delete_type {
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainen /* Delete mailbox by given GUID */
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainen DSYNC_MAILBOX_DELETE_TYPE_MAILBOX = 1,
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainen /* Delete mailbox directory by given SHA1 name */
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainen DSYNC_MAILBOX_DELETE_TYPE_DIR,
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainen /* Unsubscribe mailbox by given SHA1 name */
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainen DSYNC_MAILBOX_DELETE_TYPE_UNSUBSCRIBE,
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainen};
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox_delete {
985acc0cfd9184b3f4f4cfd6b9e5686a65226147Timo Sirainen enum dsync_mailbox_delete_type type;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen guid_128_t guid;
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainen time_t timestamp;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen};
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenenum dsync_mailbox_tree_sync_type {
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_TREE_SYNC_TYPE_CREATE_BOX,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_TREE_SYNC_TYPE_CREATE_DIR,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_TREE_SYNC_TYPE_DELETE_BOX,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_TREE_SYNC_TYPE_DELETE_DIR,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* Rename given mailbox name and its children */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_TREE_SYNC_TYPE_RENAME,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_TREE_SYNC_TYPE_SUBSCRIBE,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_TREE_SYNC_TYPE_UNSUBSCRIBE
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen};
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox_tree_sync_change {
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen enum dsync_mailbox_tree_sync_type type;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* for all types: */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen struct mail_namespace *ns;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen const char *full_name;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* for create_box and delete_box: */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen guid_128_t mailbox_guid;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* for create_box: */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen uint32_t uid_validity;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen /* for rename: */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen const char *rename_dest_name;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen};
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
39ee82dad4d4fa61e3ed074d191afc6a9b82e249Timo Sirainenstruct dsync_mailbox_tree *dsync_mailbox_tree_init(char sep, char alt_char);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenvoid dsync_mailbox_tree_deinit(struct dsync_mailbox_tree **tree);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Lookup a mailbox node by name. Returns NULL if not known. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox_node *
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainendsync_mailbox_tree_lookup(struct dsync_mailbox_tree *tree,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen const char *full_name);
c307328f59c963eba21091ecd36c9435d42b47d8Timo Sirainen/* Lookup a mailbox node by GUID. Returns NULL if not known.
c307328f59c963eba21091ecd36c9435d42b47d8Timo Sirainen The mailbox GUID hash must have been build before calling this. */
c307328f59c963eba21091ecd36c9435d42b47d8Timo Sirainenstruct dsync_mailbox_node *
c307328f59c963eba21091ecd36c9435d42b47d8Timo Sirainendsync_mailbox_tree_lookup_guid(struct dsync_mailbox_tree *tree,
c307328f59c963eba21091ecd36c9435d42b47d8Timo Sirainen const guid_128_t guid);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Lookup or create a mailbox node by name. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox_node *
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainendsync_mailbox_tree_get(struct dsync_mailbox_tree *tree, const char *full_name);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Returns full name for the given mailbox node. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenconst char *dsync_mailbox_node_get_full_name(const struct dsync_mailbox_tree *tree,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen const struct dsync_mailbox_node *node);
414b2d3b63412c4bef6a4caa7a7222f3abbdbabaTimo Sirainenvoid dsync_mailbox_node_append_full_name(string_t *str,
414b2d3b63412c4bef6a4caa7a7222f3abbdbabaTimo Sirainen const struct dsync_mailbox_tree *tree,
414b2d3b63412c4bef6a4caa7a7222f3abbdbabaTimo Sirainen const struct dsync_mailbox_node *node);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Copy everything from src to dest, except name and hierarchy pointers */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenvoid dsync_mailbox_node_copy_data(struct dsync_mailbox_node *dest,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen const struct dsync_mailbox_node *src);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
9f99b5c3e607c41c16a6380203d401250d9e2603Timo Sirainen/* Add nodes to tree from the given namespace. If box_name or box_guid is
9f99b5c3e607c41c16a6380203d401250d9e2603Timo Sirainen non-NULL, add only that mailbox to the tree. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenint dsync_mailbox_tree_fill(struct dsync_mailbox_tree *tree,
9f99b5c3e607c41c16a6380203d401250d9e2603Timo Sirainen struct mail_namespace *ns, const char *box_name,
fd32c46c360e61de2c957c3d2241eaacab7b3eecTimo Sirainen const guid_128_t box_guid,
ce0e25f26d6e67480ee39b5ca0ad634fa60c4605Timo Sirainen const char *const *exclude_mailboxes,
ce0e25f26d6e67480ee39b5ca0ad634fa60c4605Timo Sirainen enum mail_error *error_r);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Return all known deleted mailboxes and directories. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenconst struct dsync_mailbox_delete *
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainendsync_mailbox_tree_get_deletes(struct dsync_mailbox_tree *tree,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen unsigned int *count_r);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Return mailbox node for a given delete record, or NULL if it doesn't exist.
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen The delete record is intended to come from another tree, possibly with
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen a different hierarchy separator. dsync_mailbox_tree_build_guid_hash() must
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen have been called before this. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox_node *
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainendsync_mailbox_tree_find_delete(struct dsync_mailbox_tree *tree,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen const struct dsync_mailbox_delete *del);
e3df4d9063a06e0cd228a1713677ec105b0a4aa2Timo Sirainen/* Build GUID lookup hash, if it's not already built. Returns 0 if ok, -1 if
e3df4d9063a06e0cd228a1713677ec105b0a4aa2Timo Sirainen there are duplicate GUIDs. The nodes with the duplicate GUIDs are
e3df4d9063a06e0cd228a1713677ec105b0a4aa2Timo Sirainen returned. */
e3df4d9063a06e0cd228a1713677ec105b0a4aa2Timo Sirainenint dsync_mailbox_tree_build_guid_hash(struct dsync_mailbox_tree *tree,
e3df4d9063a06e0cd228a1713677ec105b0a4aa2Timo Sirainen struct dsync_mailbox_node **dup_node1_r,
e3df4d9063a06e0cd228a1713677ec105b0a4aa2Timo Sirainen struct dsync_mailbox_node **dup_node2_r);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Manually add a new node to hash. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenint dsync_mailbox_tree_guid_hash_add(struct dsync_mailbox_tree *tree,
e3df4d9063a06e0cd228a1713677ec105b0a4aa2Timo Sirainen struct dsync_mailbox_node *node,
e3df4d9063a06e0cd228a1713677ec105b0a4aa2Timo Sirainen struct dsync_mailbox_node **old_node_r);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Set remote separator used for directory deletions in
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen dsync_mailbox_tree_find_delete() */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenvoid dsync_mailbox_tree_set_remote_sep(struct dsync_mailbox_tree *tree,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen char remote_sep);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Iterate through all nodes in a tree (depth-first) */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox_tree_iter *
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainendsync_mailbox_tree_iter_init(struct dsync_mailbox_tree *tree);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenbool dsync_mailbox_tree_iter_next(struct dsync_mailbox_tree_iter *iter,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen const char **full_name_r,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen struct dsync_mailbox_node **node_r);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenvoid dsync_mailbox_tree_iter_deinit(struct dsync_mailbox_tree_iter **iter);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Sync local and remote trees so at the end they're exactly the same.
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen Return changes done to local tree. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox_tree_sync_ctx *
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainendsync_mailbox_trees_sync_init(struct dsync_mailbox_tree *local_tree,
e83126866761632b437e532dfdc30be01d14039dTimo Sirainen struct dsync_mailbox_tree *remote_tree,
be2bc5677a16a3547d5cbfd21c9deedc96a759adTimo Sirainen enum dsync_mailbox_trees_sync_type sync_type,
be2bc5677a16a3547d5cbfd21c9deedc96a759adTimo Sirainen enum dsync_mailbox_trees_sync_flags sync_flags);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenconst struct dsync_mailbox_tree_sync_change *
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainendsync_mailbox_trees_sync_next(struct dsync_mailbox_tree_sync_ctx *ctx);
34b0579f1542471947564bf56cfcf51946f57313Timo Sirainenint dsync_mailbox_trees_sync_deinit(struct dsync_mailbox_tree_sync_ctx **ctx);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
299451d50b891c83f4f5d921bc22715f24094236Timo Sirainenconst char *dsync_mailbox_node_to_string(const struct dsync_mailbox_node *node);
299451d50b891c83f4f5d921bc22715f24094236Timo Sirainenconst char *
299451d50b891c83f4f5d921bc22715f24094236Timo Sirainendsync_mailbox_delete_type_to_string(enum dsync_mailbox_delete_type type);
299451d50b891c83f4f5d921bc22715f24094236Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#endif