annotate src/plugins/quota/quota-private.h @ 9380:fe063e0d7109 HEAD

maildir quota: Limits weren't read early enough from maildirsize file.
author Timo Sirainen <tss@iki.fi>
date Sun, 13 Sep 2009 18:36:09 -0400
parents 16c286aee307
children a9b469e1c8de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6410
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 6032
diff changeset
1 #ifndef QUOTA_PRIVATE_H
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 6032
diff changeset
2 #define QUOTA_PRIVATE_H
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 #include "mail-storage-private.h"
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "quota.h"
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 /* Modules should use do "my_id = quota_module_id++" and
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 use quota_module_contexts[id] for their own purposes. */
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 extern unsigned int quota_module_id;
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 struct quota {
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
12 struct mail_user *user;
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
13 struct quota_settings *set;
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
14
4451
1a35d53c18fc Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents: 4330
diff changeset
15 ARRAY_DEFINE(roots, struct quota_root *);
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
16 ARRAY_DEFINE(storages, struct mail_storage *);
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
17 };
4514
511f1f5c76fa Changes to make trash plugin working again.
Timo Sirainen <tss@iki.fi>
parents: 4509
diff changeset
18
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
19 struct quota_settings {
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
20 pool_t pool;
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
21
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
22 ARRAY_DEFINE(root_sets, struct quota_root_settings *);
4514
511f1f5c76fa Changes to make trash plugin working again.
Timo Sirainen <tss@iki.fi>
parents: 4509
diff changeset
23 int (*test_alloc)(struct quota_transaction_context *ctx,
511f1f5c76fa Changes to make trash plugin working again.
Timo Sirainen <tss@iki.fi>
parents: 4509
diff changeset
24 uoff_t size, bool *too_large_r);
4870
e92b3eaab490 dict quota: If dictionary doesn't yet contain the quota, calculate it by
Timo Sirainen <tss@iki.fi>
parents: 4816
diff changeset
25
7147
740a17139b67 Added quota_exceeded_message setting.
Timo Sirainen <tss@iki.fi>
parents: 6874
diff changeset
26 const char *quota_exceeded_msg;
5078
16e09d2777af If mail_debug is enabled, log configured quota rules
Timo Sirainen <tss@iki.fi>
parents: 4870
diff changeset
27 unsigned int debug:1;
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
28 };
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
29
5704
4bf8438b497f Allow backend-specific quota rules with backend=<string>.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
30 struct quota_rule {
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
31 const char *mailbox_name;
5704
4bf8438b497f Allow backend-specific quota rules with backend=<string>.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
32
4bf8438b497f Allow backend-specific quota rules with backend=<string>.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
33 int64_t bytes_limit, count_limit;
7294
9e4c26471b19 Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents: 7147
diff changeset
34 /* relative to default_rule */
9e4c26471b19 Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents: 7147
diff changeset
35 unsigned int bytes_percent, count_percent;
7470
73368107aeda Added "ignore" option to quota rules which causes the mailbox to be ignored
Timo Sirainen <tss@iki.fi>
parents: 7295
diff changeset
36
73368107aeda Added "ignore" option to quota rules which causes the mailbox to be ignored
Timo Sirainen <tss@iki.fi>
parents: 7295
diff changeset
37 /* Don't include this mailbox in quota */
73368107aeda Added "ignore" option to quota rules which causes the mailbox to be ignored
Timo Sirainen <tss@iki.fi>
parents: 7295
diff changeset
38 unsigned int ignore:1;
5704
4bf8438b497f Allow backend-specific quota rules with backend=<string>.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
39 };
4bf8438b497f Allow backend-specific quota rules with backend=<string>.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
40
6032
6edca218d48a Added quota warning commands. Based lightly on a patch by Nicolas Boullis.
Timo Sirainen <tss@iki.fi>
parents: 6025
diff changeset
41 struct quota_warning_rule {
7294
9e4c26471b19 Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents: 7147
diff changeset
42 struct quota_rule rule;
6032
6edca218d48a Added quota warning commands. Based lightly on a patch by Nicolas Boullis.
Timo Sirainen <tss@iki.fi>
parents: 6025
diff changeset
43
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
44 const char *command;
6032
6edca218d48a Added quota warning commands. Based lightly on a patch by Nicolas Boullis.
Timo Sirainen <tss@iki.fi>
parents: 6025
diff changeset
45 };
6edca218d48a Added quota warning commands. Based lightly on a patch by Nicolas Boullis.
Timo Sirainen <tss@iki.fi>
parents: 6025
diff changeset
46
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
47 struct quota_backend_vfuncs {
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
48 struct quota_root *(*alloc)(void);
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
49 int (*init)(struct quota_root *root, const char *args);
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
50 void (*deinit)(struct quota_root *root);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
52 bool (*parse_rule)(struct quota_root_settings *root_set,
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
53 struct quota_rule *rule,
5704
4bf8438b497f Allow backend-specific quota rules with backend=<string>.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
54 const char *str, const char **error_r);
9380
fe063e0d7109 maildir quota: Limits weren't read early enough from maildirsize file.
Timo Sirainen <tss@iki.fi>
parents: 8958
diff changeset
55 int (*init_limits)(struct quota_root *root);
5704
4bf8438b497f Allow backend-specific quota rules with backend=<string>.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
56
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
57 /* called once for each backend */
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
58 void (*storage_added)(struct quota *quota,
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
59 struct mail_storage *storage);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
60
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
61 const char *const *(*get_resources)(struct quota_root *root);
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
62 int (*get_resource)(struct quota_root *root,
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
63 const char *name, uint64_t *value_r);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
64
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
65 int (*update)(struct quota_root *root,
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
66 struct quota_transaction_context *ctx);
8029
796307638449 FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents: 7470
diff changeset
67 bool (*match_box)(struct quota_root *root, struct mailbox *box);
796307638449 FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents: 7470
diff changeset
68
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
69 };
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
70
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
71 struct quota_backend {
4514
511f1f5c76fa Changes to make trash plugin working again.
Timo Sirainen <tss@iki.fi>
parents: 4509
diff changeset
72 /* quota backends equal if backend1.name == backend2.name */
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
73 const char *name;
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
74 struct quota_backend_vfuncs v;
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
75 };
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
76
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
77 struct quota_root_settings {
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
78 /* Unique quota root name. */
4816
8ac2a2d27364 Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents: 4615
diff changeset
79 const char *name;
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
80
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
81 struct quota_settings *set;
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
82 const char *args;
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
83
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
84 const struct quota_backend *backend;
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
85 struct quota_rule default_rule;
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
86 ARRAY_DEFINE(rules, struct quota_rule);
6032
6edca218d48a Added quota warning commands. Based lightly on a patch by Nicolas Boullis.
Timo Sirainen <tss@iki.fi>
parents: 6025
diff changeset
87 ARRAY_DEFINE(warning_rules, struct quota_warning_rule);
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
88
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
89 /* Limits in default_rule override backend's quota limits */
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
90 unsigned int force_default_rule:1;
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
91 };
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
92
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
93 struct quota_root {
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
94 pool_t pool;
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
95
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
96 struct quota_root_settings *set;
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
97 struct quota *quota;
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
98 struct quota_backend backend;
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
99
8958
16c286aee307 Implemented support for per-namespace quotas. Can be used with public namespaces.
Timo Sirainen <tss@iki.fi>
parents: 8645
diff changeset
100 /* this quota root applies only to this namespace. it may also be
16c286aee307 Implemented support for per-namespace quotas. Can be used with public namespaces.
Timo Sirainen <tss@iki.fi>
parents: 8645
diff changeset
101 a public namespace without an owner. */
16c286aee307 Implemented support for per-namespace quotas. Can be used with public namespaces.
Timo Sirainen <tss@iki.fi>
parents: 8645
diff changeset
102 struct mail_namespace *ns;
16c286aee307 Implemented support for per-namespace quotas. Can be used with public namespaces.
Timo Sirainen <tss@iki.fi>
parents: 8645
diff changeset
103 /* this is set in quota init(), because namespaces aren't known yet */
16c286aee307 Implemented support for per-namespace quotas. Can be used with public namespaces.
Timo Sirainen <tss@iki.fi>
parents: 8645
diff changeset
104 const char *ns_prefix;
16c286aee307 Implemented support for per-namespace quotas. Can be used with public namespaces.
Timo Sirainen <tss@iki.fi>
parents: 8645
diff changeset
105
8096
f35a8a3dc06d Fixed FS quota compiling and Maildir++ quota with multiple users.
Timo Sirainen <tss@iki.fi>
parents: 8082
diff changeset
106 /* initially the same as set->default_rule.*_limit, but some backends
f35a8a3dc06d Fixed FS quota compiling and Maildir++ quota with multiple users.
Timo Sirainen <tss@iki.fi>
parents: 8082
diff changeset
107 may change these by reading the limits elsewhere (e.g. Maildir++,
f35a8a3dc06d Fixed FS quota compiling and Maildir++ quota with multiple users.
Timo Sirainen <tss@iki.fi>
parents: 8082
diff changeset
108 FS quota) */
f35a8a3dc06d Fixed FS quota compiling and Maildir++ quota with multiple users.
Timo Sirainen <tss@iki.fi>
parents: 8082
diff changeset
109 int64_t bytes_limit, count_limit;
8645
a90d1488bacf quota plugin optimization: Don't look up quota values every time when iterating quota roots.
Timo Sirainen <tss@iki.fi>
parents: 8096
diff changeset
110 /* 1 = quota root has resources and should be returned when iterating
a90d1488bacf quota plugin optimization: Don't look up quota values every time when iterating quota roots.
Timo Sirainen <tss@iki.fi>
parents: 8096
diff changeset
111 quota roots, 0 = not, -1 = unknown. */
a90d1488bacf quota plugin optimization: Don't look up quota values every time when iterating quota roots.
Timo Sirainen <tss@iki.fi>
parents: 8096
diff changeset
112 int resource_ret;
8096
f35a8a3dc06d Fixed FS quota compiling and Maildir++ quota with multiple users.
Timo Sirainen <tss@iki.fi>
parents: 8082
diff changeset
113
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
114 /* Module-specific contexts. See quota_module_id. */
4451
1a35d53c18fc Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents: 4330
diff changeset
115 ARRAY_DEFINE(quota_module_contexts, void);
6874
1d0521b7151d Added noenforcing option to fs quota backend.
Timo Sirainen <tss@iki.fi>
parents: 6410
diff changeset
116
1d0521b7151d Added noenforcing option to fs quota backend.
Timo Sirainen <tss@iki.fi>
parents: 6410
diff changeset
117 /* don't enforce quota when saving */
1d0521b7151d Added noenforcing option to fs quota backend.
Timo Sirainen <tss@iki.fi>
parents: 6410
diff changeset
118 unsigned int no_enforcing:1;
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
119 };
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
120
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
121 struct quota_transaction_context {
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5078
diff changeset
122 union mailbox_transaction_module_context module_ctx;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5078
diff changeset
123
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124 struct quota *quota;
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
125 struct mailbox *box;
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
126
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
127 int64_t bytes_used, count_used;
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
128 uint64_t bytes_left, count_left;
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
129
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
130 struct mail *tmp_mail;
3767
c96f2e532b9d Make dirsize backend read the directory only once at the beginning of
Timo Sirainen <tss@iki.fi>
parents: 3738
diff changeset
131
6025
001d25a650df Don't set quota limits to transactions until they're needed.
Timo Sirainen <tss@iki.fi>
parents: 5704
diff changeset
132 unsigned int limits_set:1;
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
133 unsigned int failed:1;
5566
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
134 unsigned int recalculate:1;
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
135 };
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
136
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
137 /* Register storage to all user's quota roots. */
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
138 void quota_add_user_storage(struct quota *quota, struct mail_storage *storage);
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
139 void quota_remove_user_storage(struct mail_storage *storage);
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
140
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
141 struct quota *quota_get_mail_user_quota(struct mail_user *user);
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
142
8958
16c286aee307 Implemented support for per-namespace quotas. Can be used with public namespaces.
Timo Sirainen <tss@iki.fi>
parents: 8645
diff changeset
143 bool quota_root_is_storage_visible(struct quota_root *root,
16c286aee307 Implemented support for per-namespace quotas. Can be used with public namespaces.
Timo Sirainen <tss@iki.fi>
parents: 8645
diff changeset
144 struct mail_storage *storage);
7470
73368107aeda Added "ignore" option to quota rules which causes the mailbox to be ignored
Timo Sirainen <tss@iki.fi>
parents: 7295
diff changeset
145 struct quota_rule *
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
146 quota_root_rule_find(struct quota_root_settings *root_set, const char *name);
7470
73368107aeda Added "ignore" option to quota rules which causes the mailbox to be ignored
Timo Sirainen <tss@iki.fi>
parents: 7295
diff changeset
147
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 8029
diff changeset
148 void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set);
7470
73368107aeda Added "ignore" option to quota rules which causes the mailbox to be ignored
Timo Sirainen <tss@iki.fi>
parents: 7295
diff changeset
149 int quota_count(struct quota_root *root, uint64_t *bytes_r, uint64_t *count_r);
4870
e92b3eaab490 dict quota: If dictionary doesn't yet contain the quota, calculate it by
Timo Sirainen <tss@iki.fi>
parents: 4816
diff changeset
150
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
151 #endif