From 89ddd79d5f7cd12d05e837154e84210d7065d1ab Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan.bosch@open-xchange.com> Date: Mon, 8 Jun 2020 19:26:42 +0200 Subject: [PATCH] lib-sieve-tool: Add sieve_tool_get_mail_raw_user(). --- src/lib-sieve-tool/sieve-tool.c | 20 ++++++++++++++------ src/lib-sieve-tool/sieve-tool.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/lib-sieve-tool/sieve-tool.c b/src/lib-sieve-tool/sieve-tool.c index d546fed02..4b97e6186 100644 --- a/src/lib-sieve-tool/sieve-tool.c +++ b/src/lib-sieve-tool/sieve-tool.c @@ -375,13 +375,18 @@ void sieve_tool_init_mail_user(struct sieve_tool *tool, ns->flags |= NAMESPACE_FLAG_NOQUOTA | NAMESPACE_FLAG_NOACL; } -struct mail * -sieve_tool_open_file_as_mail(struct sieve_tool *tool, const char *path) +static void sieve_tool_init_mail_raw_user(struct sieve_tool *tool) { if (tool->mail_raw_user == NULL) { tool->mail_raw_user = mail_raw_user_create( master_service, tool->mail_user_dovecot); } +} + +struct mail * +sieve_tool_open_file_as_mail(struct sieve_tool *tool, const char *path) +{ + sieve_tool_init_mail_raw_user(tool); if (tool->mail_raw != NULL) mail_raw_close(&tool->mail_raw); @@ -394,10 +399,7 @@ sieve_tool_open_file_as_mail(struct sieve_tool *tool, const char *path) struct mail * sieve_tool_open_data_as_mail(struct sieve_tool *tool, string_t *mail_data) { - if (tool->mail_raw_user == NULL) { - tool->mail_raw_user = mail_raw_user_create( - master_service, tool->mail_user_dovecot); - } + sieve_tool_init_mail_raw_user(tool); if (tool->mail_raw != NULL) mail_raw_close(&tool->mail_raw); @@ -473,6 +475,12 @@ struct mail_user *sieve_tool_get_mail_user(struct sieve_tool *tool) tool->mail_user_dovecot : tool->mail_user); } +struct mail_user *sieve_tool_get_mail_raw_user(struct sieve_tool *tool) +{ + sieve_tool_init_mail_raw_user(tool); + return tool->mail_raw_user; +} + /* * Commonly needed functionality */ diff --git a/src/lib-sieve-tool/sieve-tool.h b/src/lib-sieve-tool/sieve-tool.h index b253e34ec..02f41984a 100644 --- a/src/lib-sieve-tool/sieve-tool.h +++ b/src/lib-sieve-tool/sieve-tool.h @@ -51,6 +51,7 @@ sieve_tool_open_data_as_mail(struct sieve_tool *tool, string_t *mail_data); const char *sieve_tool_get_username(struct sieve_tool *tool); const char *sieve_tool_get_homedir(struct sieve_tool *tool); struct mail_user *sieve_tool_get_mail_user(struct sieve_tool *tool); +struct mail_user *sieve_tool_get_mail_raw_user(struct sieve_tool *tool); /* * Configuration -- GitLab