pop3c-sync.c revision 01435c38e7d671d5a892c4b802cfb204881cd454
/* Copyright (c) 2011 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"
{
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 */
(void)array_append_space(&uidls);
}
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_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) {
}
/* skip over existing messages with matching UIDLs */
str_truncate(str, 0);
cache_idx) > 0 &&
/* UIDL matched */
} else {
break;
}
}
/* remove the rest of the messages from index */
/* add the rest of the messages in POP3 mailbox to index */
}
/* mark the newly seen messages as recent */
}
{
}
{
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)
}