pop3c-sync.c revision 2676c973a61edf2a9dd5d0196e0993ecb04bb2a2
/* Copyright (c) 2011-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "istream.h"
#include "bsearch-insert-pos.h"
#include "str.h"
#include "strnum.h"
#include "index-mail.h"
#include "pop3c-client.h"
#include "pop3c-storage.h"
#include "pop3c-sync.h"
struct pop3c_sync_msg {
const char *uidl;
};
{
char *line, *p;
return 0;
POP3C_CAPABILITY_UIDL) == 0) {
"UIDLs not supported by server");
return -1;
}
"UIDL failed: %s", error);
return -1;
}
seq++;
if (p == NULL) {
"Invalid UIDL line: %s", line);
break;
}
*p++ = '\0';
break;
}
}
return -1;
}
if (seq == 0) {
/* make msg_uidls non-NULL */
}
return 0;
}
{
const char *error;
char *line, *p;
if (pop3c_sync_get_uidls(mbox) < 0)
return -1;
}
return 0;
}
"LIST failed: %s", error);
return -1;
}
"Too much data in LIST: %s", line);
break;
}
if (p == NULL) {
"Invalid LIST line: %s", line);
break;
}
*p++ = '\0';
break;
}
"Invalid LIST size: %s", p);
break;
}
}
return -1;
}
return 0;
}
static void
struct mail_cache_view *cache_view,
unsigned int cache_idx)
{
struct pop3c_sync_msg msg;
str_truncate(str, 0);
cache_idx) > 0) {
}
}
}
static void
struct pop3c_mailbox *mbox)
{
struct pop3c_sync_msg *msg;
}
}
const struct pop3c_sync_msg *msg2)
{
}
static void
struct mail_index_view *sync_view,
struct mail_index_transaction *sync_trans,
struct mail_cache_view *cache_view)
{
struct index_mailbox_context *ibox =
const struct mail_index_header *hdr;
struct mail_cache_transaction_ctx *cache_trans;
/* set our uidvalidity */
if (hdr->uid_validity == 0) {
}
/* sort the messages by UIDLs, because some servers reorder messages */
/* skip over existing messages with matching UIDLs and expunge the ones
that no longer exist in remote. (+1 to avoid malloc(0) assert) */
int ret;
ret = 1;
ret = -1;
else
if (ret < 0) {
/* message expunged in remote */
lidx++;
} else if (ret > 0) {
/* new message in remote */
ridx++;
} else {
/* UIDL matched */
lidx++;
ridx++;
}
}
/* mark the newly seen messages as recent */
pool_unref(&pool);
}
{
struct mail_index_sync_ctx *index_sync_ctx;
struct mail_index_transaction *sync_trans;
struct mail_index_sync_rec sync_rec;
unsigned int idx;
const char *reply;
int ret;
if (pop3c_sync_get_uidls(mbox) < 0)
return -1;
if (ret <= 0) {
if (ret < 0)
return ret;
}
}
/* mark expunges messages as deleted in this pop3 session,
if those exist */
continue;
uint32_cmp, &idx)) {
/* no such messages in this session */
continue;
}
break;
str_truncate(str, 0);
}
}
if (mail_index_sync_commit(&index_sync_ctx) < 0) {
return -1;
}
if (cache_view != NULL) {
}
if (deletions) {
&reply) < 0) {
return -1;
}
}
return 0;
}
struct mailbox_sync_context *
{
int ret = 0;
if (mailbox_open(box) < 0)
ret = -1;
} else {
if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 &&
/* FIXME: reconnect */
}
}
if (ret == 0)
}