virtual-sync.c revision 24e5e4526d8f5cbc056ab97fd0d154d0936d7a5e
/* Copyright (c) 2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "ioloop.h"
#include "str.h"
#include "mail-search-build.h"
#include "virtual-storage.h"
#include <stdlib.h>
struct virtual_sync_mail {
struct virtual_mail_index_record vrec;
};
struct virtual_sync_context {
struct virtual_mailbox *mbox;
struct mail_index_sync_ctx *index_sync_ctx;
struct mail_index *index;
struct mail_index_view *sync_view;
struct mail_index_transaction *trans;
const char *const *kw_all;
enum mailbox_sync_flags flags;
unsigned int expunge_removed:1;
};
{
}
struct virtual_backend_box *bbox,
{
enum mail_flags flags;
const char *const *kw_names;
struct mail_keywords *keywords;
i_panic("UID lost unexpectedly");
/* copy flags */
/* copy keywords */
}
}
struct virtual_backend_box *bbox,
{
struct virtual_mail_index_record vrec;
}
}
static void
struct virtual_backend_box *bbox)
{
unsigned int seqs_count;
/* max(seq1,prev_uid+1)..seq2 contain newly seen UIDs */
if (first_ruid <= last_ruid) {
}
bbox->sync_iter_idx++;
}
}
static void
{
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}
{
return -1;
return 1;
return -1;
return 1;
/* broken */
return 0;
}
{
struct virtual_backend_box *bbox;
struct virtual_sync_mail *vmails;
const struct virtual_mail_index_record *vrec;
const void *data;
unsigned int i, seqs_count;
bool expunged;
/* sort the messages by their backend mailbox and real UID */
}
for (i = 0; i < messages; i++) {
vrec->mailbox_id);
/* the entire mailbox is lost */
continue;
}
}
/* max(seq1,prev_uid+1)..min(seq2,uid-1) contain
newly seen UIDs */
if (first_ruid <= last_ruid) {
}
break;
bbox->sync_iter_idx++;
}
if (ctx->expunge_removed) {
continue;
}
}
/* uid is within seq1..seq2 */
}
}
const struct mail_index_sync_rec *sync_rec)
{
struct virtual_backend_box *bbox;
const struct virtual_mail_index_record *vrec;
const void *data;
enum mail_flags flags;
struct mail_keywords *keywords;
enum modify_type modify_type;
const char *kw_names[2];
bool expunged;
/* don't care */
return;
break;
}
/* already expunged, nothing to do. */
return;
}
continue;
i_panic("UID lost unexpectedly");
break;
if (flags != 0) {
MODIFY_ADD, flags);
}
if (flags != 0) {
}
break;
kw_names);
break;
kw_names);
keywords);
break;
i_unreached();
}
}
}
{
const struct mail_index_header *hdr;
struct mail_index_sync_rec sync_rec;
if (hdr->uid_validity != 0)
else
/* mark the newly seen messages as recent */
}
}
struct virtual_backend_box *bbox)
{
struct mailbox_transaction_context *trans;
struct mail_search_context *search_ctx;
enum mailbox_sync_flags sync_flags;
int ret;
return -1;
(void)mailbox_transaction_commit(&trans);
return ret;
}
{
struct virtual_backend_box *const *bboxes;
struct mailbox_transaction_context *trans;
unsigned int i, count;
for (i = 0; i < count; i++) {
return -1;
bboxes[i]->sync_iter_idx = 0;
bboxes[i]->sync_iter_prev_real_uid = 0;
}
return 0;
}
{
struct virtual_backend_box *const *bboxes;
struct mailbox_transaction_context *trans;
unsigned int i, count;
for (i = 0; i < count; i++) {
(void)mailbox_transaction_commit(&trans);
}
}
}
{
if (success) {
ret = -1;
}
} else {
}
return 0;
}
enum mailbox_sync_flags flags)
{
struct virtual_sync_context *ctx;
int ret;
/* Removed messages are expunged when
a) EXPUNGE is used
b) Mailbox is being opened (FIX_INCONSISTENT is set) */
if (ret <= 0) {
if (ret < 0)
return ret;
}
/* update list of UIDs in mailboxes */
if (virtual_sync_backend_boxes(ctx) < 0)
}
struct mailbox_sync_context *
{
int ret = 0;
}