index-mailbox-list-sync.c revision d3442384ca53d4b18a493db7dd0b000f470419cf
/* Copyright (C) 2006 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "index-storage.h"
#include "mailbox-list-index.h"
#include "index-mailbox-list.h"
#include "maildir/maildir-sync.h"
#define INDEX_LIST_STORAGE_CONTEXT(obj) \
#define CACHED_STATUS_ITEMS \
struct index_list_mailbox {
union mailbox_module_context module_ctx;
};
struct index_list_map {
const char *name;
unsigned int eid_offset;
unsigned int status_offset;
};
#define DEF(a, b, c) \
{ a, offsetof(struct index_mailbox_list, b), \
offsetof(struct mailbox_status, c) }
static struct index_list_map index_list_map[] = {
{ NULL, 0, 0 }
};
{
}
{
struct mail_index_sync_ctx *mail_sync_ctx;
struct mail_index_view *view;
struct mail_index_transaction *trans;
struct mail_index_sync_rec sync_rec;
int ret;
return 0;
if (ret <= 0)
return ret;
/* we should have only external transactions in here, for which we
don't need to do anything but write them to the index */
;
return mail_index_sync_commit(&mail_sync_ctx);
}
static int
struct mail_index_view **view_r,
{
struct mailbox_list *list;
struct index_mailbox_list *ilist;
struct mail_index_view *view;
int ret;
/* indexing disabled */
return 0;
}
if (ret <= 0)
return ret;
/* make sure we're synced */
return -1;
/* found from list index. lookup the mail index record for it */
return ret;
}
t_push();
t_pop();
if (ret != 0) {
/* error / mailbox has changed. we'll need to sync it. */
return ret < 0 ? -1 : 0;
}
return 1;
}
static int
{
struct mailbox_list *list;
struct index_mailbox_list *ilist;
struct mail_index_view *view;
const void *data;
unsigned int i;
int ret;
if (ret <= 0)
return ret;
break;
}
return 1;
}
static int
struct mailbox_status *status)
{
if ((items & ~CACHED_STATUS_ITEMS) == 0) {
return 0;
/* nonsynced / error, fallback to doing it the slow way */
}
}
{
struct mailbox_list_index_sync_ctx *sync_ctx;
int ret;
if (ret > 0) {
/* we'll need the mailbox synced since we're updating its
contents based on what it already contains */
return -1;
return 1;
} else if (ret < 0)
return -1;
/* create the mailbox by doing a partial sync with the mailbox name
as the sync root path */
&sync_ctx) < 0)
return -1;
if (mailbox_list_index_sync_commit(&sync_ctx) < 0)
return -1;
if (ret != 0)
return ret < 0 ? -1 : 0;
return -1;
}
static int
const struct mailbox_status *status)
{
struct mail_index_transaction *trans;
const void *data;
unsigned int i;
int ret = 1;
/* update counters */
if (ret <= 0)
break;
}
}
ret = -1;
if (ret <= 0) {
return -1;
}
&ibox->log_offset);
}
static struct mailbox_sync_context *
{
struct mailbox_sync_context *ctx;
ibox->log_offset = 0;
/* check using the mailbox list index if the mailbox has
changed. if not, we don't need to open the mailbox yet. */
struct mail_index_view *view;
int ret;
if (ret > 0) {
/* no changes, so don't bother checking again before
next sync */
return ctx;
}
}
}
struct mailbox_sync_rec *sync_rec_r)
{
return 0;
}
struct mailbox_status *status_r)
{
struct mailbox_list *list;
struct index_mailbox_list *ilist;
struct mail_index_view *view;
/* nothing synced. just return the status. */
return status_items == 0 ? 0 :
}
/* indexing disabled */
}
/* if status_items == 0, the status_r may be NULL. we really want to
know the status anyway, so save it elsewhere then */
return -1;
/* sync mailbox list index */
/* just ignore the error */
return 0;
}
seq > 0)
return 0;
}
{
struct index_mailbox_list *ilist =
struct index_list_mailbox *ibox;
return;
}
{
unsigned int i;
index_list_map[i].name, 0,
}
}
void index_mailbox_list_sync_init(void)
{
}