index-mailbox-list.c revision d9fdacd5fb3e07997e5c389739d2054f0c8441d8
/* Copyright (C) 2006 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "file-lock.h"
#include "imap-match.h"
#include "mail-index.h"
#include "mail-storage.h"
#include "mailbox-list-index.h"
#include "index-mailbox-list.h"
#include <time.h>
/* min 2 seconds */
#define MAILBOX_LIST_SYNC_SECS 2
unsigned int index_mailbox_list_module_id = 0;
static bool index_mailbox_list_module_id_set = FALSE;
static int
{
const struct mail_index_header *hdr;
/* FIXME: single sync_stamp works only with maildir++ */
"stat(%s) failed: %m", path);
return -1;
}
/*
if mtime is older than 2 secs, we set the first bit on
if mtime is 0-2 secs old, we set the first bit off.
this way we'll always do a resync later when syncing a recently
changed directory. if the directory changes while we're syncing it
we'll resync it again later.
this would work with 1 second difference if we didn't store the
dirtyness flag in the stamp's first bit.
*/
else
}
const char **prefix_r, int *recurse_level_r)
{
const char *prefix_start, *prefix_end;
bool seen_wildcards = FALSE;
int recurse_level = 0;
if (*mask == '%')
else if (*mask == '*') {
recurse_level = -1;
break;
}
if (!seen_wildcards)
prefix_end = mask;
}
}
}
static struct mailbox_list_iterate_context *
enum mailbox_list_iter_flags flags)
{
struct index_mailbox_list_iterate_context *ctx;
const char *prefix;
int recurse_level;
if (index_mailbox_list_is_synced(ctx) > 0) {
/* synced, list from index */
} else {
/* FIXME: this works nicely with maildir++, but not others */
mask = "*";
prefix = "";
}
}
}
static enum mailbox_info_flags
{
enum mailbox_info_flags info_flags = 0;
if ((flags & MAILBOX_LIST_INDEX_FLAG_CHILDREN) != 0)
if ((flags & MAILBOX_LIST_INDEX_FLAG_NOCHILDREN) != 0)
if ((flags & MAILBOX_LIST_INDEX_FLAG_NONEXISTENT) != 0)
if ((flags & MAILBOX_LIST_INDEX_FLAG_NOSELECT) != 0)
return info_flags;
}
static enum mailbox_list_index_flags
{
enum mailbox_list_index_flags flags = 0;
if ((info_flags & MAILBOX_CHILDREN) != 0)
if ((info_flags & MAILBOX_NOCHILDREN) != 0)
if ((info_flags & MAILBOX_NONEXISTENT) != 0)
if ((info_flags & MAILBOX_NOSELECT) != 0)
return flags;
}
/* skip nonexistent mailboxes when finding with "*" */
(ctx)->recurse_level >= 0)
struct mailbox_info **info_r)
{
struct mailbox_list_index_info iinfo;
const struct mail_index_record *rec;
int ret;
/* find the next matching mailbox */
do {
if (ret <= 0) {
return ret;
}
/* get the mailbox's flags */
return -1;
if (seq == 0) {
"Desynced: Record expunged from mail index");
return -1;
}
return -1;
/* do some sanity checks to the flags */
"Mail index has both children and nochildren flags");
return -1;
}
"Desynced: Children flags wrong in mail index");
}
return 0;
}
static struct mailbox_info *
{
struct index_mailbox_list_iterate_context *ctx =
(struct index_mailbox_list_iterate_context *)_ctx;
struct mailbox_info *info;
return NULL;
}
return info;
}
do {
return info;
/* if the sync fails, just ignore it. we don't require synced
indexes to return valid output. */
&seq) < 0)
return info;
return info;
}
static int
{
struct index_mailbox_list_iterate_context *ctx =
(struct index_mailbox_list_iterate_context *)_ctx;
}
/* FIXME: single sync_stamp works only with maildir++ */
else {
/* index updates aren't that important. if the commit
fails, we've still returned full output. */
}
}
return ret;
}
{
}
{
struct index_mailbox_list *ilist;
struct mail_index *mail_index;
struct mailbox_list_index *list_index;
int ret;
/* FIXME: for now we only work with maildir++ */
return;
/* FIXME: a bit ugly way to get the flags, but this will do for now.. */
if ((storage_flags & MAIL_STORAGE_FLAG_MMAP_DISABLE) != 0) {
return; /* FIXME: we currently don't support mmap_disable */
}
#ifndef MMAP_CONFLICTS_WRITE
if ((storage_flags & MAIL_STORAGE_FLAG_MMAP_NO_WRITE) != 0)
#endif
if (mail_index_move_to_memory(mail_index) < 0) {
/* try opening once more. it should be created
directly into memory now. */
if (ret <= 0) {
/* everything failed. there's a bug in the
code, but just work around it by disabling
the index completely */
return;
}
}
}
if (mailbox_list_index_open_or_create(list_index) < 0) {
/* skip indexing */
return;
}
if (!index_mailbox_list_module_id_set) {
}
}
void index_mailbox_list_init(void); /* called in mailbox-list-register.c */
void index_mailbox_list_init(void)
{
}