11
11
/* defined by imap, pop3, lda */
12
12
extern void (*hook_mail_storage_created)(struct mail_storage *storage);
14
void (*quota_next_hook_mail_user_created)(struct mail_user *user);
14
15
void (*quota_next_hook_mail_storage_created)(struct mail_storage *storage);
15
16
void (*quota_next_hook_mailbox_list_created)(struct mailbox_list *list);
17
void (*quota_next_hook_mail_namespaces_created)(struct mail_namespace *namespaces);
17
19
const char *quota_plugin_version = PACKAGE_VERSION;
18
struct quota *quota_set;
20
struct quota_settings *quota_set;
20
22
static void quota_root_add_rules(const char *root_name,
21
struct quota_root *root)
23
struct quota_root_settings *root_set)
23
25
const char *rule_name, *rule, *error;
33
if (quota_root_add_rule(root, rule, &error) < 0) {
35
if (quota_root_add_rule(root_set, rule, &error) < 0) {
34
36
i_fatal("Quota root %s: Invalid rule %s: %s",
35
37
root_name, rule, error);
41
43
static void quota_root_add_warning_rules(const char *root_name,
42
struct quota_root *root)
44
struct quota_root_settings *root_set)
44
46
const char *rule_name, *rule, *error;
54
if (quota_root_add_warning_rule(root, rule, &error) < 0) {
56
if (quota_root_add_warning_rule(root_set, rule, &error) < 0) {
55
57
i_fatal("Quota root %s: Invalid warning rule: %s",
75
quota_set = quota_init();
77
quota_set = quota_settings_init();
77
root = quota_root_init(quota_set, env);
79
root_set = quota_root_settings_init(quota_set, env);
79
81
i_fatal("Couldn't create quota root: %s", env);
80
quota_root_add_rules("QUOTA", root);
81
quota_root_add_warning_rules("QUOTA", root);
82
quota_root_add_rules("QUOTA", root_set);
83
quota_root_add_warning_rules("QUOTA", root_set);
83
85
for (i = 2;; i++) {
84
86
const char *root_name;
92
root = quota_root_init(quota_set, env);
94
root_set = quota_root_settings_init(quota_set, env);
94
96
i_fatal("Couldn't create quota root: %s", env);
95
quota_root_add_rules(root_name, root);
96
quota_root_add_warning_rules(root_name, root);
97
quota_root_add_rules(root_name, root_set);
98
quota_root_add_warning_rules(root_name, root_set);
101
quota_next_hook_mail_user_created = hook_mail_user_created;
102
hook_mail_user_created = quota_mail_user_created;
99
104
quota_next_hook_mail_storage_created = hook_mail_storage_created;
100
105
hook_mail_storage_created = quota_mail_storage_created;
102
107
quota_next_hook_mailbox_list_created = hook_mailbox_list_created;
103
108
hook_mailbox_list_created = quota_mailbox_list_created;
110
quota_next_hook_mail_namespaces_created = hook_mail_namespaces_created;
111
hook_mail_namespaces_created = quota_mail_namespaces_created;
106
114
void quota_plugin_deinit(void)
108
116
if (quota_set != NULL) {
117
hook_mail_user_created = quota_next_hook_mail_user_created;
109
118
hook_mail_storage_created =
110
119
quota_next_hook_mail_storage_created;
111
120
hook_mailbox_list_created =
112
121
quota_next_hook_mailbox_list_created;
113
quota_deinit("a_set);
122
hook_mail_namespaces_created =
123
quota_next_hook_mail_namespaces_created;
124
quota_settings_deinit("a_set);