From: Timo Sirainen Date: Tue, 12 Aug 2008 16:42:28 +0000 (-0400) Subject: Forgot to add mail-user.* files in previous struct mail_user commit. X-Git-Tag: 1.2.alpha1~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d80f37f025593d959bdfa9c378915e4322f4f504;p=thirdparty%2Fdovecot%2Fcore.git Forgot to add mail-user.* files in previous struct mail_user commit. --HG-- branch : HEAD --- diff --git a/src/lib-storage/mail-user.c b/src/lib-storage/mail-user.c new file mode 100644 index 0000000000..d4eb16eec1 --- /dev/null +++ b/src/lib-storage/mail-user.c @@ -0,0 +1,43 @@ +/* Copyright (c) 2008 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "mail-namespace.h" +#include "mail-user.h" + +struct mail_user_module_register mail_user_module_register = { 0 }; +void (*hook_mail_user_created)(struct mail_user *user) = NULL; + +static void mail_user_deinit_base(struct mail_user *user) +{ + mail_namespaces_deinit(&user->namespaces); + pool_unref(&user->pool); +} + +struct mail_user *mail_user_init(const char *username, const char *home) +{ + struct mail_user *user; + pool_t pool; + + i_assert(username != NULL); + + pool = pool_alloconly_create("mail user", 512); + user = p_new(pool, struct mail_user, 1); + user->pool = pool; + user->username = p_strdup(pool, username); + user->home = p_strdup(pool, home); + user->v.deinit = mail_user_deinit_base; + p_array_init(&user->module_contexts, user->pool, 5); + + if (hook_mail_user_created != NULL) + hook_mail_user_created(user); + return user; +} + +void mail_user_deinit(struct mail_user **_user) +{ + struct mail_user *user = *_user; + + *_user = NULL; + user->v.deinit(user); +} diff --git a/src/lib-storage/mail-user.h b/src/lib-storage/mail-user.h new file mode 100644 index 0000000000..79fc05b22e --- /dev/null +++ b/src/lib-storage/mail-user.h @@ -0,0 +1,39 @@ +#ifndef MAIL_USER_H +#define MAIL_USER_H + +struct mail_user; + +struct mail_user_vfuncs { + void (*deinit)(struct mail_user *user); +}; + +struct mail_user { + pool_t pool; + struct mail_user_vfuncs v; + + const char *username; + const char *home; + + struct mail_namespace *namespaces; + + /* Module-specific contexts. See mail_storage_module_id. */ + ARRAY_DEFINE(module_contexts, union mail_user_module_context *); +}; + +struct mail_user_module_register { + unsigned int id; +}; + +union mail_user_module_context { + struct mail_user_vfuncs super; + struct mail_user_module_register *reg; +}; +extern struct mail_user_module_register mail_user_module_register; + +/* Called after user has been created */ +extern void (*hook_mail_user_created)(struct mail_user *user); + +struct mail_user *mail_user_init(const char *username, const char *home); +void mail_user_deinit(struct mail_user **user); + +#endif