autocreate-plugin.c revision e4c43c353f8da8af60d372c13709df5b5db6552e
/* Copyright (c) 2007-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "unichar.h"
#include "imap-match.h"
#include "mailbox-list-private.h"
#include "mail-storage-private.h"
#include "mail-storage-hooks.h"
#include "autocreate-plugin.h"
#include <stdlib.h>
#define AUTOCREATE_USER_CONTEXT(obj) \
#define AUTOCREATE_LIST_CONTEXT(obj) \
#define AUTOCREATE_CONTEXT(obj) \
enum match_result {
/* list contains the mailbox */
MATCH_RESULT_YES = 0x01,
/* list contains children of the mailbox */
MATCH_RESULT_CHILDREN = 0x02,
/* list contains parents of the mailbox */
MATCH_RESULT_PARENT = 0x04
};
struct autocreate_box {
const char *name;
unsigned int name_len;
enum mailbox_info_flags flags;
bool child_listed;
struct mail_namespace *ns;
};
struct autocreate_user {
};
unsigned int idx;
struct mailbox_info new_info;
};
struct autocreate_mailbox_list {
};
const char *autocreate_plugin_version = DOVECOT_VERSION;
static enum match_result
unsigned int *idx_r)
{
const struct autocreate_box *autoboxes;
enum match_result result = 0;
char sep;
*idx_r = -1U;
for (i = 0; i < count; i++) {
continue;
*idx_r = i;
}
return result;
}
static bool
{
unsigned int idx;
}
static bool
{
unsigned int idx;
}
{
int ret;
/* autocreate the mailbox */
i_error("autocreate: Failed to create mailbox %s: %s",
}
}
return ret;
}
enum mailbox_existence *existence_r)
{
return 0;
}
}
static int
const struct mailbox_update *update,
bool directory)
{
return -1;
i_error("autocreate: Failed to subscribe to mailbox %s: %s",
}
}
return 0;
}
{
union mailbox_module_context *abox;
v->open = autocreate_mailbox_open;
}
static struct mailbox_list_iterate_context *
const char *const *patterns,
enum mailbox_list_iter_flags flags)
{
union mailbox_list_module_context *alist =
struct mailbox_list_iterate_context *ctx;
const struct autocreate_box *autobox;
if ((flags & MAILBOX_LIST_ITER_NO_AUTO_BOXES) == 0) {
if ((flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0)
else
}
}
return ctx;
}
{
union mailbox_list_module_context *alist =
struct autocreate_mailbox_list_iterate_context *actx =
}
static const struct mailbox_info *
{
struct autocreate_mailbox_list_iterate_context *actx =
struct autocreate_user *auser =
unsigned int idx;
if ((match & MATCH_RESULT_YES) != 0) {
/* we have an exact match in the list.
don't list it at the end. */
}
if ((match & MATCH_RESULT_CHILDREN) != 0) {
else {
}
}
/* make sure the mailbox existence flags are correct. */
else {
}
if ((match2 & MATCH_RESULT_YES) != 0)
if ((match2 & MATCH_RESULT_CHILDREN) != 0) {
}
/* we're listing all mailboxes and want \Subscribed flag */
if ((match2 & MATCH_RESULT_YES) != 0) {
/* mailbox is also marked as autosubscribe */
}
if ((match2 & MATCH_RESULT_CHILDREN) != 0) {
/* mailbox also has a children marked as
autosubscribe */
}
}
if ((match & MATCH_RESULT_PARENT) != 0) {
/* there are autocreate parent boxes.
set their children flag states. */
struct autocreate_box *autobox;
char sep;
continue;
}
}
return info;
}
const struct autocreate_box *autobox)
{
struct autocreate_mailbox_list_iterate_context *actx =
enum imap_match_result match;
if (match == IMAP_MATCH_YES)
return TRUE;
const char *p;
(old_flags & (MAILBOX_CHILDREN |
if ((old_flags & MAILBOX_NONEXISTENT) == 0) {
}
if ((old_flags & MAILBOX_SUBSCRIBED) != 0)
do {
} while (match != IMAP_MATCH_YES);
return TRUE;
}
return FALSE;
}
static const struct mailbox_info *
{
union mailbox_list_module_context *alist =
struct autocreate_mailbox_list_iterate_context *actx =
const struct mailbox_info *info;
const struct autocreate_box *autoboxes;
unsigned int count;
return autocreate_iter_existing(ctx);
}
}
/* list missing mailboxes */
}
return NULL;
}
{
union mailbox_list_module_context *alist;
}
static void
const char *value)
{
struct autocreate_box *autobox;
struct mail_namespace *ns;
if (!uni_utf8_str_is_valid(value)) {
i_error("autocreate: Mailbox name isn't valid UTF-8: %s",
value);
return;
}
if (user->mail_debug) {
i_debug("autocreate: Namespace not found for mailbox: %s",
value);
}
return;
}
}
const char *env_name_base)
{
const char *value;
char env_name[20];
unsigned int i = 1;
env_name_base, ++i);
}
}
static void
{
struct autocreate_user *auser;
"autosubscribe");
}
static struct mail_storage_hooks autocreate_mail_storage_hooks = {
};
{
}
void autocreate_plugin_deinit(void)
{
}