quota-private.h revision 5be5d875996999585de785ac33f96ff1569f1a0e
#ifndef QUOTA_PRIVATE_H
#define QUOTA_PRIVATE_H
#include "mail-storage-private.h"
#include "mail-namespace.h"
#include "quota.h"
/* Modules should use do "my_id = quota_module_id++" and
use quota_module_contexts[id] for their own purposes. */
extern unsigned int quota_module_id;
struct quota {
struct quota_settings *set;
struct mail_namespace *unwanted_ns;
};
struct quota_settings {
const char *quota_exceeded_msg;
unsigned int debug:1;
unsigned int initialized:1;
};
struct quota_rule {
const char *mailbox_mask;
/* relative to default_rule */
int bytes_percent, count_percent;
/* Don't include this mailbox in quota */
unsigned int ignore:1;
};
struct quota_warning_rule {
struct quota_rule rule;
const char *command;
unsigned int reverse:1;
};
struct quota_backend_vfuncs {
struct quota_root *(*alloc)(void);
const char **error_r);
struct quota_rule *rule,
/* called once for each namespace */
struct mail_namespace *ns);
struct quota_transaction_context *ctx);
};
struct quota_backend {
/* quota backends equal if backend1.name == backend2.name */
const char *name;
struct quota_backend_vfuncs v;
};
struct quota_root_settings {
/* Unique quota root name. */
const char *name;
struct quota_settings *set;
const char *args;
const struct quota_backend *backend;
struct quota_rule default_rule;
const char *limit_set;
/* If user is under quota before saving a mail, allow the last mail to
bring the user over quota by this many bytes. */
struct quota_rule grace_rule;
/* Limits in default_rule override backend's quota limits */
unsigned int force_default_rule:1;
};
struct quota_root {
struct quota_root_settings *set;
struct quota_backend backend;
struct dict *limit_set_dict;
/* this quota root applies only to this namespace. it may also be
a public namespace without an owner. */
struct mail_namespace *ns;
/* this is set in quota init(), because namespaces aren't known yet.
when accessing shared users the ns_prefix may be non-NULL but
ns=NULL, so when checking if quota root applies only to a specific
namespace use the ns_prefix!=NULL check. */
const char *ns_prefix;
/* initially the same as set->default_rule.*_limit, but some backends
may change these by reading the limits elsewhere (e.g. Maildir++,
FS quota) */
/* 1 = quota root has resources and should be returned when iterating
quota roots, 0 = not, -1 = unknown. */
int resource_ret;
/* Module-specific contexts. See quota_module_id. */
ARRAY(void) quota_module_contexts;
/* don't enforce quota when saving */
unsigned int no_enforcing:1;
/* If user has unlimited quota, disable quota tracking */
unsigned int disable_unlimited_tracking:1;
/* Set while quota is being recalculated to avoid recursion. */
unsigned int recounting:1;
};
struct quota_transaction_context {
(set once, not updated by bytes_used/count_used).
if last_mail_max_extra_bytes>0, the bytes_ceil is initially
increased by that much, while bytes_ceil2 contains the real ceiling.
after the first allocation is done, bytes_ceil is set to
bytes_ceil2. */
only once and not updated by bytes_used/count_used. (Either *_ceil
or *_over is always zero.) */
unsigned int limits_set:1;
unsigned int failed:1;
unsigned int recalculate:1;
unsigned int sync_transaction:1;
};
/* Register storage to all user's quota roots. */
struct mail_namespace *ns);
struct quota_rule *
bool quota_warning_match(const struct quota_warning_rule *w,
#endif