Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8084:f12f8c1da0bf HEAD
Forgot to add mail-user.* files in previous struct mail_user commit.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 12 Aug 2008 12:42:28 -0400 |
parents | bed6d0895dce |
children | bf83aa9c3f4a |
files | src/lib-storage/mail-user.c src/lib-storage/mail-user.h |
diffstat | 2 files changed, 82 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/mail-user.c Tue Aug 12 12:42:28 2008 -0400 @@ -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); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/mail-user.h Tue Aug 12 12:42:28 2008 -0400 @@ -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