quota-storage.c revision 4981827cb5e32cf767b7b0e3070137e6b36f42af
/* Copyright (C) 2005 Timo Sirainen */
#include "lib.h"
#include "array.h"
#include "istream.h"
#include "mail-storage-private.h"
#include "quota.h"
#include "quota-plugin.h"
#define QUOTA_CONTEXT(obj) \
struct quota_mail_storage {
struct mail_storage_vfuncs super;
};
struct quota_mailbox {
struct mailbox_vfuncs super;
unsigned int save_hack:1;
};
struct quota_mail {
struct mail_vfuncs super;
};
static unsigned int quota_storage_module_id = 0;
static bool quota_storage_module_id_set = FALSE;
{
struct quota_transaction_context *qt =
return -1;
return 0;
}
static struct mailbox_transaction_context *
{
struct mailbox_transaction_context *t;
struct quota_transaction_context *qt;
return t;
}
static int
enum mailbox_sync_flags flags)
{
return -1;
} else {
(void)quota_transaction_commit(qt);
return 0;
}
}
static void
{
}
static struct mail *
quota_mail_alloc(struct mailbox_transaction_context *t,
struct mailbox_header_lookup_ctx *wanted_headers)
{
struct quota_mail *qmail;
struct mail_private *mail;
return _mail;
}
{
int ret;
bool too_large;
if (ret > 0)
return 0;
else if (ret == 0) {
return -1;
} else {
return -1;
}
}
static int
{
struct mail *copy_dest_mail;
int ret;
else
return -1;
/* if copying used saving internally, we already checked the quota
and set qbox->save_hack = TRUE. */
if (copy_dest_mail != dest_mail)
return ret;
}
static int
quota_save_init(struct mailbox_transaction_context *t,
bool want_mail __attr_unused__,
struct mail_save_context **ctx_r)
{
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) {
"Quota exceeded");
return -1;
} else if (ret < 0) {
return -1;
}
}
/* note that we set want_mail = TRUE in here. */
}
{
struct mail *save_dest_mail;
int ret;
else {
}
return -1;
if (save_dest_mail != dest_mail)
return ret;
}
static struct mailbox *
{
struct quota_mailbox *qbox;
return NULL;
return box;
}
{
struct quota_mail_storage *qstorage;
if (!quota_storage_module_id_set) {
}
}