From 06793ee314e8039e068050a3207423ec87342b7a Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan.bosch@open-xchange.com> Date: Wed, 23 Oct 2019 22:11:47 +0200 Subject: [PATCH] managesieve: managesieve-quota - Use command context rather than client as parameter. --- src/managesieve/cmd-havespace.c | 2 +- src/managesieve/cmd-putscript.c | 9 +++++---- src/managesieve/managesieve-quota.c | 7 +++++-- src/managesieve/managesieve-quota.h | 5 +++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/managesieve/cmd-havespace.c b/src/managesieve/cmd-havespace.c index e4c344fbd..50146f2d1 100644 --- a/src/managesieve/cmd-havespace.c +++ b/src/managesieve/cmd-havespace.c @@ -44,7 +44,7 @@ bool cmd_havespace(struct client_command_context *cmd) return TRUE; } - if (!managesieve_quota_check_all(client, scriptname, size)) + if (!managesieve_quota_check_all(cmd, scriptname, size)) return TRUE; client_send_ok(client, "Putscript would succeed."); diff --git a/src/managesieve/cmd-putscript.c b/src/managesieve/cmd-putscript.c index dbe507640..330b0ad4c 100644 --- a/src/managesieve/cmd-putscript.c +++ b/src/managesieve/cmd-putscript.c @@ -231,6 +231,7 @@ cmd_putscript_finish_script(struct cmd_putscript_context *ctx, static void cmd_putscript_handle_script(struct cmd_putscript_context *ctx) { struct client *client = ctx->client; + struct client_command_context *cmd = ctx->cmd; struct sieve_script *script; /* Obtain script object for uploaded script */ @@ -254,7 +255,7 @@ static void cmd_putscript_handle_script(struct cmd_putscript_context *ctx) /* Check quota; max size is already checked */ if (ctx->scriptname != NULL && - !managesieve_quota_check_all(client, ctx->scriptname, + !managesieve_quota_check_all(cmd, ctx->scriptname, ctx->script_size)) { cmd_putscript_finish(ctx); return; @@ -346,11 +347,11 @@ static bool cmd_putscript_continue_parsing(struct client_command_context *cmd) /* Check quota */ if (ctx->scriptname == NULL) { if (!managesieve_quota_check_validsize( - client, ctx->script_size)) + cmd, ctx->script_size)) return cmd_putscript_cancel(ctx, TRUE); } else { if (!managesieve_quota_check_all( - client, ctx->scriptname, ctx->script_size)) + cmd, ctx->scriptname, ctx->script_size)) return cmd_putscript_cancel(ctx, TRUE); } @@ -391,7 +392,7 @@ static bool cmd_putscript_continue_script(struct client_command_context *cmd) if (ctx->max_script_size > 0 && ctx->input->v_offset > ctx->max_script_size) { (void)managesieve_quota_check_validsize( - client, ctx->input->v_offset); + cmd, ctx->input->v_offset); cmd_putscript_finish(ctx); return TRUE; } diff --git a/src/managesieve/managesieve-quota.c b/src/managesieve/managesieve-quota.c index cc0c7be83..aeede4662 100644 --- a/src/managesieve/managesieve-quota.c +++ b/src/managesieve/managesieve-quota.c @@ -15,8 +15,10 @@ uint64_t managesieve_quota_max_script_size(struct client *client) return sieve_storage_quota_max_script_size(client->storage); } -bool managesieve_quota_check_validsize(struct client *client, size_t size) +bool managesieve_quota_check_validsize(struct client_command_context *cmd, + size_t size) { + struct client *client = cmd->client; uint64_t limit; if (!sieve_storage_quota_validsize(client->storage, size, &limit)) { @@ -29,9 +31,10 @@ bool managesieve_quota_check_validsize(struct client *client, size_t size) return TRUE; } -bool managesieve_quota_check_all(struct client *client, +bool managesieve_quota_check_all(struct client_command_context *cmd, const char *scriptname, size_t size) { + struct client *client = cmd->client; enum sieve_storage_quota quota; uint64_t limit; int ret; diff --git a/src/managesieve/managesieve-quota.h b/src/managesieve/managesieve-quota.h index 39a34debe..f6b37bf63 100644 --- a/src/managesieve/managesieve-quota.h +++ b/src/managesieve/managesieve-quota.h @@ -3,8 +3,9 @@ uint64_t managesieve_quota_max_script_size(struct client *client); -bool managesieve_quota_check_validsize(struct client *client, size_t size); -bool managesieve_quota_check_all(struct client *client, +bool managesieve_quota_check_validsize(struct client_command_context *cmd, + size_t size); +bool managesieve_quota_check_all(struct client_command_context *cmd, const char *scriptname, size_t size); #endif -- GitLab