Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-storage/mail-user.h @ 9415:2a48aa6e2bce HEAD
Added signature for changeset 609fe4268f40
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 05 Oct 2009 19:52:13 -0400 |
parents | db9811ec1f47 |
children |
rev | line source |
---|---|
8084
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
1 #ifndef MAIL_USER_H |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 #define MAIL_USER_H |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 struct mail_user; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 struct mail_user_vfuncs { |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 void (*deinit)(struct mail_user *user); |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 }; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 struct mail_user { |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 pool_t pool; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 struct mail_user_vfuncs v; |
8467
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
13 int refcount; |
8084
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 const char *username; |
8467
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
16 /* don't access the home directly. It may be set lazily. */ |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
17 const char *_home; |
8084
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 struct mail_namespace *namespaces; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 /* Module-specific contexts. See mail_storage_module_id. */ |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 ARRAY_DEFINE(module_contexts, union mail_user_module_context *); |
8467
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
23 |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
24 /* Either home is set or there is no home for the user. */ |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
25 unsigned int home_looked_up:1; |
8470
e4f319453cb2
Quota works now properly with shared mailboxes.
Timo Sirainen <tss@iki.fi>
parents:
8467
diff
changeset
|
26 /* User is an administrator. Allow operations not normally allowed |
e4f319453cb2
Quota works now properly with shared mailboxes.
Timo Sirainen <tss@iki.fi>
parents:
8467
diff
changeset
|
27 for other people. */ |
e4f319453cb2
Quota works now properly with shared mailboxes.
Timo Sirainen <tss@iki.fi>
parents:
8467
diff
changeset
|
28 unsigned int admin:1; |
8084
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 }; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 struct mail_user_module_register { |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 unsigned int id; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 }; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
35 union mail_user_module_context { |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 struct mail_user_vfuncs super; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 struct mail_user_module_register *reg; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 }; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 extern struct mail_user_module_register mail_user_module_register; |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 /* Called after user has been created */ |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 extern void (*hook_mail_user_created)(struct mail_user *user); |
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 |
8467
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
44 void mail_users_init(const char *auth_socket_path, bool debug); |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
45 void mail_users_deinit(void); |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
46 |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
47 struct mail_user *mail_user_init(const char *username); |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
48 void mail_user_ref(struct mail_user *user); |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
49 void mail_user_unref(struct mail_user **user); |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
50 |
8470
e4f319453cb2
Quota works now properly with shared mailboxes.
Timo Sirainen <tss@iki.fi>
parents:
8467
diff
changeset
|
51 /* Find another user from the given user's namespaces. */ |
e4f319453cb2
Quota works now properly with shared mailboxes.
Timo Sirainen <tss@iki.fi>
parents:
8467
diff
changeset
|
52 struct mail_user *mail_user_find(struct mail_user *user, const char *name); |
e4f319453cb2
Quota works now properly with shared mailboxes.
Timo Sirainen <tss@iki.fi>
parents:
8467
diff
changeset
|
53 |
8467
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
54 /* Specify the user's home directory. This should be called also when it's |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
55 known that the user doesn't have a home directory to avoid the internal |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
56 lookup. */ |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
57 void mail_user_set_home(struct mail_user *user, const char *home); |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
58 /* Get the home directory for the user. Returns 1 if home directory looked up |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
59 successfully, 0 if there is no home directory (either user doesn't exist or |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
60 has no home directory) or -1 if lookup failed. */ |
03c418eadc8b
mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents:
8457
diff
changeset
|
61 int mail_user_get_home(struct mail_user *user, const char **home_r); |
8786
db9811ec1f47
Added mail_user_get_temp_prefix() and mail_storage_get_temp_prefix().
Timo Sirainen <tss@iki.fi>
parents:
8652
diff
changeset
|
62 /* Returns path + file prefix for creating a temporary file. Uses home |
db9811ec1f47
Added mail_user_get_temp_prefix() and mail_storage_get_temp_prefix().
Timo Sirainen <tss@iki.fi>
parents:
8652
diff
changeset
|
63 directory if possible, fallbacks to mail directory. */ |
db9811ec1f47
Added mail_user_get_temp_prefix() and mail_storage_get_temp_prefix().
Timo Sirainen <tss@iki.fi>
parents:
8652
diff
changeset
|
64 const char *mail_user_get_temp_prefix(struct mail_user *user); |
8084
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
65 |
8652
8b3af54b4dc3
hook_mail_namespaces_created() wasn't always called with all namespaces as parameter.
Timo Sirainen <tss@iki.fi>
parents:
8470
diff
changeset
|
66 /* Add more namespaces to user's namespaces. The ->next pointers may be |
8b3af54b4dc3
hook_mail_namespaces_created() wasn't always called with all namespaces as parameter.
Timo Sirainen <tss@iki.fi>
parents:
8470
diff
changeset
|
67 changed, so the namespaces pointer will be updated to user->namespaces. */ |
8b3af54b4dc3
hook_mail_namespaces_created() wasn't always called with all namespaces as parameter.
Timo Sirainen <tss@iki.fi>
parents:
8470
diff
changeset
|
68 void mail_user_add_namespace(struct mail_user *user, |
8b3af54b4dc3
hook_mail_namespaces_created() wasn't always called with all namespaces as parameter.
Timo Sirainen <tss@iki.fi>
parents:
8470
diff
changeset
|
69 struct mail_namespace **namespaces); |
8457
f5554ae61732
Don't drop useless namespaces automatically while creating a new one.
Timo Sirainen <tss@iki.fi>
parents:
8173
diff
changeset
|
70 /* Drop autocreated shared namespaces that don't have any "usable" mailboxes. */ |
f5554ae61732
Don't drop useless namespaces automatically while creating a new one.
Timo Sirainen <tss@iki.fi>
parents:
8173
diff
changeset
|
71 void mail_user_drop_useless_namespaces(struct mail_user *user); |
8173
6dd0c6755afe
Added initial support for shared mailboxes. Listing isn't supported yet.
Timo Sirainen <tss@iki.fi>
parents:
8137
diff
changeset
|
72 |
8137
b2a258213ee0
Created mail_user_[try_]home_expand(). Used them for expanding mail directories.
Timo Sirainen <tss@iki.fi>
parents:
8084
diff
changeset
|
73 /* Replace ~/ at the beginning of the path with the user's home directory. */ |
b2a258213ee0
Created mail_user_[try_]home_expand(). Used them for expanding mail directories.
Timo Sirainen <tss@iki.fi>
parents:
8084
diff
changeset
|
74 const char *mail_user_home_expand(struct mail_user *user, const char *path); |
b2a258213ee0
Created mail_user_[try_]home_expand(). Used them for expanding mail directories.
Timo Sirainen <tss@iki.fi>
parents:
8084
diff
changeset
|
75 /* Returns 0 if ok, -1 if home directory isn't set. */ |
b2a258213ee0
Created mail_user_[try_]home_expand(). Used them for expanding mail directories.
Timo Sirainen <tss@iki.fi>
parents:
8084
diff
changeset
|
76 int mail_user_try_home_expand(struct mail_user *user, const char **path); |
b2a258213ee0
Created mail_user_[try_]home_expand(). Used them for expanding mail directories.
Timo Sirainen <tss@iki.fi>
parents:
8084
diff
changeset
|
77 |
8084
f12f8c1da0bf
Forgot to add mail-user.* files in previous struct mail_user commit.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
78 #endif |