virtual-storage.c revision e345faa28311a949d01ed9088e64b231de0829de
/* Copyright (c) 2008-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "ioloop.h"
#include "str.h"
#include "mkdir-parents.h"
#include "unlink-directory.h"
#include "index-mail.h"
#include "mail-copy.h"
#include "mail-search.h"
#include "virtual-plugin.h"
#include "virtual-transaction.h"
#include "virtual-storage.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#define VIRTUAL_LIST_CONTEXT(obj) \
struct virtual_mailbox_list {
};
extern struct mail_storage virtual_storage;
extern struct mailbox virtual_mailbox;
{
const char *str;
enum mail_error error;
else {
}
}
static struct mail_storage *virtual_storage_alloc(void)
{
struct virtual_storage *storage;
}
static void
struct mailbox_list_settings *set)
{
}
struct virtual_backend_box *
{
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
for (i = 0; i < count; i++) {
return bboxes[i];
}
return NULL;
}
struct virtual_backend_box *
{
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
if (mailbox_id == 0)
return NULL;
for (i = 0; i < count; i++) {
return bboxes[i];
}
return NULL;
}
const char *name)
{
const char *const *names;
unsigned int i, count;
for (i = 0; i < count; i++) {
return TRUE;
}
return FALSE;
}
enum mailbox_flags flags)
{
struct virtual_backend_box *const *bboxes;
struct mail_storage *storage;
struct mail_namespace *ns;
unsigned int i, count;
enum mail_error error;
for (i = 0; i < count; ) {
(error == MAIL_ERROR_PERM ||
error == MAIL_ERROR_NOTFOUND)) {
/* this mailbox wasn't explicitly specified.
just skip it. */
continue;
}
/* copy the error */
break;
}
i++;
}
if (i == count)
return 0;
else {
/* failed */
for (; i > 0; i--) {
}
return -1;
}
}
static struct mailbox *
enum mailbox_flags flags)
{
struct virtual_mailbox *mbox;
sizeof(struct virtual_mail_index_record),
sizeof(uint32_t));
}
{
bool failed;
return -1;
}
"virtual doesn't support streamed mailboxes");
return -1;
}
/* exists, open it */
return -1;
return -1;
} else {
return -1;
}
return failed ? -1 : 0;
}
{
struct mail_storage *storage;
struct virtual_backend_box **bboxes;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}
static int
bool directory ATTR_UNUSED)
{
"Can't create virtual mailboxes");
return -1;
}
static int
{
"Can't update virtual mailboxes");
return -1;
}
static int
const char *name)
{
struct dirent *d;
unsigned int dir_len;
bool unlinked_something = FALSE;
if (!mailbox_list_set_error_from_errno(list)) {
"opendir(%s) failed: %m", path);
}
return -1;
}
errno = 0;
if (d->d_name[0] == '.') {
/* skip . and .. */
continue;
continue;
}
/* trying to unlink() a directory gives either EPERM or EISDIR
(non-POSIX). it doesn't really work anywhere in practise,
so don't bother stat()ing the file first */
"unlink(%s) failed: %m",
}
}
path);
}
return -1;
}
if (!unlinked_something) {
t_strdup_printf("Directory %s isn't empty, "
"can't delete it.", name));
return -1;
}
return 0;
}
static int
{
const char *src;
/* Make sure the indexes are closed before trying to delete the
directory that contains them. It can still fail with some NFS
implementations if indexes are opened by another session, but
that can't really be helped. */
/* delete the index and control directories */
return -1;
/* check if the mailbox actually exists */
return -1;
}
}
{
/* FIXME: maybe some day */
}
static int
const char *mailbox_name ATTR_UNUSED,
enum mailbox_list_file_type type,
enum mailbox_info_flags *flags)
{
const char *path, *maildir_path;
int ret = 1;
/* try to avoid stat() with these checks */
if (type != MAILBOX_LIST_FILE_TYPE_DIR &&
/* it's a file */
return 0;
}
/* need to stat() then */
/* non-directory */
ret = 0;
/* no subdirectories */
*flags |= MAILBOX_NOCHILDREN;
/* non-default configuration: we have one directory
containing the mailboxes. if there are 3 links,
either this is a selectable mailbox without children
or non-selectable mailbox with children */
*flags |= MAILBOX_CHILDREN;
} else {
/* default configuration: all subdirectories are
child mailboxes. */
*flags |= MAILBOX_CHILDREN;
}
} else {
/* non-selectable. probably either access denied, or symlink
destination not found. don't bother logging errors. */
*flags |= MAILBOX_NOSELECT;
}
if ((*flags & MAILBOX_NOSELECT) == 0) {
/* make sure it's a selectable mailbox */
*flags |= MAILBOX_NOSELECT;
}
return ret;
}
const struct virtual_backend_uidmap *map)
{
}
static bool
{
struct virtual_backend_box *bbox;
struct mailbox_status status;
const struct virtual_backend_uidmap *uids;
else {
}
return FALSE;
return FALSE;
return FALSE;
return TRUE;
}
static void
bool only_with_msgs)
{
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}
static void
{
}
static void virtual_class_init(void)
{
}
static void virtual_class_deinit(void)
{
}
struct mailbox_list *list)
{
struct virtual_mailbox_list *mlist;
}
struct mail_storage virtual_storage = {
MEMBER(class_flags) 0,
{
NULL,
NULL,
NULL,
}
};
struct mailbox virtual_mailbox = {
{
NULL,
NULL,
NULL,
}
};