/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "hash.h"
#include "str.h"
#include "sort.h"
#include "imap-util.h"
#include "mail-cache.h"
#include "mail-index-modseq.h"
#include "index-sync-private.h"
#include "imapc-msgmap.h"
#include "imapc-list.h"
#include "imapc-storage.h"
#include "imapc-sync.h"
struct imapc_sync_command {
char *cmd_str;
bool ignore_no;
};
void *context)
{
;
/* maybe the message was expunged already.
some servers fail STOREs with NO in such situation. */
/* the disconnection is already logged, don't flood
the logs unnecessarily */
} else {
"imapc: Sync command '%s' failed: %s",
}
if (--ctx->sync_command_count == 0)
}
static struct imapc_command *
bool ignore_no)
{
return cmd;
}
static struct imapc_command *
{
}
{
}
const struct imapc_sync_store *store2)
{
return 1;
}
{
return flags;
}
static void
{
const char *sorted_flags;
return;
.flags = sorted_flags,
};
}
}
static void
const char *flags)
{
}
}
}
static void
{
return;
str_truncate(cmd, 0);
}
}
static void
{
/* if any of them has a missing \Deleted flag,
just add it to all of them. */
break;
}
}
}
const struct mail_index_sync_rec *sync_rec)
{
}
if (sync_rec->remove_flags != 0) {
str_truncate(str, 0);
}
}
static void
const struct mail_index_sync_rec *sync_rec)
{
const char *const *kw_p;
break;
break;
default:
i_unreached();
}
}
{
return;
/* just expunge everything */
return;
}
/* build a list of UIDs to expunge */
}
{
}
}
{
}
static void
{
else
else
/* message exists in index and in remote server */
/* message exists in index but not in remote server */
/* the message was added to index by another
imapc session, and it's not visible yet
in this session */
break;
}
/* it's already expunged and we should have marked it */
lseq++;
} else {
/* message doesn't exist in index, but exists in
remote server */
/* the message hasn't been yet added to index */
break;
}
/* another imapc session expunged it =>
NOOP should send us an EXPUNGE event */
if (!nooped) {
return;
}
/* already nooped => index is corrupted */
"Expunged message uid=%u reappeared", ruid);
return;
}
}
}
static void
{
/* empty mailbox - no point in fetching anything */
return;
}
}
}
{
/* already expunged, nothing to do. */
break;
break;
break;
}
} T_END;
if (!mbox->initial_sync_done)
while (ctx->sync_command_count > 0)
/* add uidnext & highestmodseq after all appends */
/* reset only after a successful sync */
mbox->sync_fetch_first_uid = 0;
}
}
}
static int
{
int ret;
if (!force)
if (ret <= 0) {
if (ret < 0)
return ret;
}
return 0;
}
{
bool changes;
if (ret == 0) {
ret = -1;
}
} else {
}
"gmail-pop3 search not successful");
ret = -1;
}
/* this is done simply to commit delayed expunges if there are any
(has to be done after sync is committed) */
return ret;
}
{
/* we're only saving mails here - no syncing actually wanted */
return 0;
}
return -1;
return 0;
if (imapc_sync_finish(&sync_ctx) < 0)
return -1;
return 0;
}
static void
{
if (!mbox->initial_sync_done) {
NOOP. */
} else if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 &&
(flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0)) {
/* do NOOP to make sure we have the latest changes before
starting sync. this is necessary either because se don't
support IDLE at all, or because we want to be sure that we
have the latest changes (IDLE is started with a small delay,
so we might not actually even be in IDLE right not) */
}
}
struct mailbox_sync_context *
{
bool changes;
int ret = 0;
if (!list->refreshed_mailboxes &&
}
ret = -1;
/* initial FETCH failed already */
ret = -1;
}
ret = -1;
ret == 0)
}
struct mailbox_sync_status *status_r)
{
int ret;
return ret;
return ret;
}