/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream.h"
#include "dsync-ibc.h"
#include "dsync-mail.h"
#include "dsync-mailbox-import.h"
#include "dsync-mailbox-export.h"
#include "dsync-brain-private.h"
"mailbox",
"changes",
"attributes",
"mail_requests",
"mails",
"recv_last_common",
"done"
};
{
const char *resync_reason;
bool resync;
return FALSE;
if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
i_error("Remote sent end-of-list instead of a mailbox");
return TRUE;
}
sizeof(dsync_box->mailbox_guid)) != 0) {
i_error("Remote sent mailbox with a wrong GUID");
return TRUE;
}
if (dsync_box->mailbox_ignore) {
/* ignore this box */
i_debug("brain %c: Ignoring missing remote box GUID %s",
return TRUE;
}
if (dsync_box->mailbox_lost) {
/* remote lost the mailbox. it's probably already deleted, but
verify it on next sync just to be sure */
"Remote lost mailbox GUID %s (maybe it was just deleted?)",
return TRUE;
}
/* no fields appear to have changed, skip this mailbox */
return TRUE;
}
return TRUE;
if (resync)
return TRUE;
}
return TRUE;
}
{
return FALSE;
if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
return TRUE;
}
return TRUE;
}
enum dsync_ibc_eol_type type)
{
}
{
const char *errstr;
i_error("Exporting mailbox %s failed: %s",
return -1;
}
return 0;
}
{
int ret;
return;
}
if (ret < 0) {
if (dsync_brain_export_deinit(brain) == 0)
i_unreached();
return;
}
}
{
return FALSE;
if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
else
return TRUE;
}
return TRUE;
}
{
int ret;
return;
}
if (ret < 0) {
if (dsync_brain_export_deinit(brain) == 0)
i_unreached();
return;
}
else
}
{
return FALSE;
if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
return TRUE;
}
return TRUE;
}
{
return TRUE;
}
return FALSE;
else {
}
return TRUE;
}
{
const char *changes_during_sync;
bool require_full_resync;
return;
/* finished with this mailbox */
sizeof(state.mailbox_guid));
/* this mailbox didn't exist on remote */
} else {
&brain->mail_error) < 0) {
if (require_full_resync) {
/* don't treat this as brain failure or the
state won't be sent to the other brain.
this also means we'll continue syncing the
following mailboxes. */
} else {
}
}
if (changes_during_sync != NULL) {
}
}
if (brain->require_full_resync) {
state.last_uidvalidity = 0;
}
}
{
return FALSE;
if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
if (dsync_brain_export_deinit(brain) < 0)
return TRUE;
}
return TRUE;
}
i_debug("brain %c: import mail uid %u guid %s",
}
return TRUE;
}
{
if (brain->mail_requests &&
/* wait for mail requests to finish. we could already start
exporting, but then we're going to do quite a lot of
separate searches. especially with pipe backend we'd do
a separate search for each mail. */
return FALSE;
}
return TRUE;
}
if (dsync_brain_export_deinit(brain) < 0)
return TRUE;
return TRUE;
}
{
return FALSE;
if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
i_error("Remote sent end-of-list instead of a mailbox state");
return TRUE;
}
sizeof(state.mailbox_guid)) == 0);
/* normally the last_common_* values should be the same in local and
remote, but during unexpected changes they may differ. use the
values that are lower as the final state. */
if (state.changes_during_sync)
return TRUE;
}
{
switch (brain->box_recv_state) {
case DSYNC_BOX_STATE_MAILBOX:
break;
break;
case DSYNC_BOX_STATE_CHANGES:
break;
break;
case DSYNC_BOX_STATE_MAILS:
break;
break;
case DSYNC_BOX_STATE_DONE:
break;
}
switch (brain->box_send_state) {
case DSYNC_BOX_STATE_MAILBOX:
/* wait for mailbox to be received first */
break;
break;
case DSYNC_BOX_STATE_CHANGES:
break;
break;
case DSYNC_BOX_STATE_MAILS:
if (dsync_brain_send_mail(brain))
break;
i_unreached();
case DSYNC_BOX_STATE_DONE:
break;
}
}
return changed;
}