]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Forgot to add mail-user.* files in previous struct mail_user commit.
authorTimo Sirainen <tss@iki.fi>
Tue, 12 Aug 2008 16:42:28 +0000 (12:42 -0400)
committerTimo Sirainen <tss@iki.fi>
Tue, 12 Aug 2008 16:42:28 +0000 (12:42 -0400)
--HG--
branch : HEAD

src/lib-storage/mail-user.c [new file with mode: 0644]
src/lib-storage/mail-user.h [new file with mode: 0644]

diff --git a/src/lib-storage/mail-user.c b/src/lib-storage/mail-user.c
new file mode 100644 (file)
index 0000000..d4eb16e
--- /dev/null
@@ -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 (file)
index 0000000..79fc05b
--- /dev/null
@@ -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