#ifndef DSYNC_BRAIN_H
#define DSYNC_BRAIN_H
#include "guid.h"
#include "mail-error.h"
struct mail_namespace;
struct mail_user;
struct dsync_ibc;
enum dsync_brain_flags {
/* Sync everything but the actual mails (e.g. mailbox creates,
deletes) */
/* Used with BACKUP_SEND/RECV: Don't force the
Use the two-way syncing algorithm, but don't actually modify
anything locally. (Useful during migration.) */
/* Run storage purge on the remote after syncing.
Useful with e.g. a nightly doveadm backup. */
/* Don't prefetch mail bodies until they're actually needed. This works
only with pipe ibc. It's useful if most of the mails can be copied
directly within filesystem without having to read them. */
/* Disable mailbox renaming logic. This is just a kludge that should
be removed once the renaming logic has no more bugs.. */
/* Add MAILBOX_TRANSACTION_FLAG_NO_NOTIFY to transactions. */
/* Workaround missing Date/Message-ID headers */
};
enum dsync_brain_sync_type {
/* Go through all mailboxes to make sure everything is synced */
/* Go through all mailboxes that have changed (based on UIDVALIDITY,
UIDNEXT, HIGHESTMODSEQ). If both sides have had equal amount of
changes in some mailbox, it may get incorrectly skipped. */
/* Use saved state to find out what has changed. */
};
struct dsync_brain_settings {
const char *process_title_prefix;
/* Sync only these namespaces */
/* Sync only this mailbox name */
const char *sync_box;
/* Use this virtual \All mailbox to be able to copy mails with the same
GUID instead of saving them twice. With most storages this results
in less disk space usage. */
const char *virtual_all_box;
/* Sync only this mailbox GUID */
/* Exclude these mailboxes from the sync. They can contain '*'
wildcards and be \special-use flags. */
const char *const *exclude_mailboxes;
/* Alternative character to use in mailbox names where the original
character cannot be used. */
char mailbox_alt_char;
/* Sync only mails with received timestamp at least this high. */
/* Sync only mails with received timestamp less or equal than this */
/* Don't sync mails larger than this. */
/* Sync only mails which contains / doesn't contain this flag.
'-' at the beginning means this flag must not exist. */
const char *sync_flag;
/* Headers to hash (defaults to Date, Message-ID) */
const char *const *hashed_headers;
/* If non-zero, use dsync lock file for this user */
unsigned int lock_timeout_secs;
/* If non-zero, importing will attempt to commit transaction after
saving this many messages. */
unsigned int import_commit_msgs_interval;
/* Input state for DSYNC_BRAIN_SYNC_TYPE_STATE */
const char *state;
};
struct dsync_brain *
enum dsync_brain_flags flags,
const struct dsync_brain_settings *set);
struct dsync_brain *
bool local, const char *process_title_prefix);
/* Returns 0 if everything was successful, -1 if syncing failed in some way */
/* Returns TRUE if brain needs to run more, FALSE if it's finished.
changed_r is TRUE if anything happened during this run. */
/* Returns TRUE if brain has failed, and there's no point in continuing. */
/* Returns the current sync state string, which can be given as parameter to
dsync_brain_master_init() to quickly sync only the new changes. */
/* Returns the sync type that was used. Mainly useful with slave brain. */
/* If there were any unexpected changes during the sync, return the reason
for them. Otherwise return NULL. If remote_only_r=TRUE, this brain itself
didn't see any changes, but the remote brain did. */
bool *remote_only_r);
/* Returns TRUE if we want to sync this namespace. */
struct mail_namespace *ns);
#endif