quota-storage.c revision 2e37d45867d081db150ab78dad303b9077aea24f
/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "istream.h"
#include "mail-search-build.h"
#include "mail-storage-private.h"
#include "mailbox-list-private.h"
#include "maildir-storage.h"
#include "quota-private.h"
#include "quota-plugin.h"
#define QUOTA_CONTEXT(obj) \
#define QUOTA_MAIL_CONTEXT(obj) \
#define QUOTA_LIST_CONTEXT(obj) \
struct quota_mailbox_list {
};
struct quota_mailbox {
union mailbox_module_context module_ctx;
struct mailbox_transaction_context *expunge_trans;
struct quota_transaction_context *expunge_qt;
unsigned int recalculate:1;
};
struct quota_user_module quota_user_module =
{
/* We need to handle the situation where multiple transactions expunged
the mail at the same time. In here we'll just save the message's
physical size and do the quota freeing later when the message was
known to be expunged. */
}
}
}
static struct mailbox_transaction_context *
{
struct mailbox_transaction_context *t;
struct quota_transaction_context *qt;
return t;
}
static int
struct mail_transaction_commit_changes *changes_r)
{
return -1;
} else {
(void)quota_transaction_commit(&qt);
return 0;
}
}
static void
{
}
{
union mail_module_context *qmail;
return;
v->expunge = quota_mail_expunge;
}
{
int ret;
bool too_large;
if (ret > 0)
return 0;
else if (ret == 0) {
return -1;
} else {
"Internal quota calculation error");
return -1;
}
}
static int
{
/* we always want to know the mail size */
NULL);
}
}
return -1;
/* if copying used saving internally, we already checked the quota */
}
static int
{
int ret;
/* Input size is known, check for quota immediately. This
check isn't perfect, especially because input stream's
linefeeds may contain CR+LFs while physical message would
only contain LFs. With mbox some headers might be skipped
entirely.
I think these don't really matter though compared to the
benefit of giving "out of quota" error before sending the
full mail. */
bool too_large;
if (ret == 0) {
return -1;
} else if (ret < 0) {
"Internal quota calculation error");
return -1;
}
}
/* we always want to know the mail size */
NULL);
}
}
}
{
return -1;
}
{
}
}
}
{
}
enum mailbox_sync_type sync_type)
{
unsigned int i, count;
if (uid == 0) {
/* free the transaction before view syncing begins,
otherwise it'll crash. */
}
return;
}
/* we're in the middle of syncing the mailbox, so it's a bad idea to
try and get the message sizes at this point. Rely on sizes that
we saved earlier, or recalculate the whole quota if we don't know
the size. */
i = count = 0;
} else {
for (i = 0; i < count; i++) {
break;
}
}
if (i != count) {
/* we already know the size */
return;
}
/* try to look up the size. this works only if it's cached. */
}
else {
/* there's no way to get the size. recalculate the quota. */
}
}
struct mailbox_sync_status *status_r)
{
int ret;
/* update quota only after syncing is finished. the quota commit may
recalculate the quota and cause all mailboxes to be synced,
including the one we're already syncing. */
return ret;
}
{
/* sync_notify() may be called outside sync_begin()..sync_deinit().
make sure we apply changes at close time at latest. */
}
static int
{
struct mail_search_context *ctx;
struct mailbox_transaction_context *t;
struct quota_transaction_context *qt;
struct mail_search_args *search_args;
return -1;
t = mailbox_transaction_begin(box, 0);
if (mailbox_search_deinit(&ctx) < 0) {
/* maybe we missed some mails. */
}
(void)quota_transaction_commit(&qt);
return 0;
}
{
if (quota_mailbox_delete_shrink_quota(box) < 0)
return -1;
}
}
{
}
}
{
struct quota_mailbox *qbox;
return;
return;
v->save_begin = quota_save_begin;
v->save_finish = quota_save_finish;
v->copy = quota_copy;
v->close = quota_mailbox_close;
v->delete = quota_mailbox_delete;
v->free = quota_mailbox_free;
}
{
}
{
}
{
}
{
struct quota_user *quser;
struct quota_settings *set;
const char *error;
int ret;
ret = -1;
}
}
if (ret < 0) {
"Failed to initialize quota: %s", error);
return;
}
if (ret > 0) {
v->deinit = quota_user_deinit;
} else if (user->mail_debug) {
i_debug("quota: No quota setting - plugin disabled");
}
}
static struct quota_root *
{
struct quota_root *const *roots;
unsigned int i, count;
for (i = 0; i < count; i++) {
return roots[i];
}
return NULL;
}
{
struct quota_mailbox_list *qlist;
struct quota_root *root;
bool add;
return;
/* see if we have a quota explicitly defined for this namespace */
/* public namespace - add quota only if namespace is
explicitly defined for it */
} else {
}
if (add) {
/* register to owner's quota roots */
}
}
struct mail_namespace *namespaces)
{
const struct quota_rule *rule;
const char *name;
i_error("quota: Unknown namespace: %s",
}
}
}
}
{
struct quota_root *const *roots;
unsigned int i, count;
return;
for (i = 0; i < count; i++)
}