Skip to content
Snippets Groups Projects
Commit fa15a722 authored by Stephan Bosch's avatar Stephan Bosch Committed by Timo Sirainen
Browse files

lib-sieve: plugins: enotify: mailto: ntfy-mailto - Rename action context

parent fea4b8e3
No related branches found
No related tags found
No related merge requests found
...@@ -150,7 +150,7 @@ static const char *_unique_headers[] = { ...@@ -150,7 +150,7 @@ static const char *_unique_headers[] = {
* Method context data * Method context data
*/ */
struct ntfy_mailto_context { struct ntfy_mailto_action_context {
struct uri_mailto *uri; struct uri_mailto *uri;
const struct smtp_address *from_address; const struct smtp_address *from_address;
}; };
...@@ -319,14 +319,14 @@ ntfy_mailto_runtime_check_operands(const struct sieve_enotify_env *nenv, ...@@ -319,14 +319,14 @@ ntfy_mailto_runtime_check_operands(const struct sieve_enotify_env *nenv,
string_t *from, pool_t context_pool, string_t *from, pool_t context_pool,
void **method_context) void **method_context)
{ {
struct ntfy_mailto_context *mtctx; struct ntfy_mailto_action_context *mtactx;
struct uri_mailto *parsed_uri; struct uri_mailto *parsed_uri;
const struct smtp_address *address; const struct smtp_address *address;
struct ntfy_mailto_uri_env nmuenv; struct ntfy_mailto_uri_env nmuenv;
const char *error; const char *error;
/* Need to create context before validation to have arrays present */ /* Need to create context before validation to have arrays present */
mtctx = p_new(context_pool, struct ntfy_mailto_context, 1); mtactx = p_new(context_pool, struct ntfy_mailto_action_context, 1);
/* Validate :from */ /* Validate :from */
if (from != NULL) { if (from != NULL) {
...@@ -339,7 +339,7 @@ ntfy_mailto_runtime_check_operands(const struct sieve_enotify_env *nenv, ...@@ -339,7 +339,7 @@ ntfy_mailto_runtime_check_operands(const struct sieve_enotify_env *nenv,
"the mailto method: %s", "the mailto method: %s",
str_sanitize(str_c(from), 128), error); str_sanitize(str_c(from), 128), error);
} else { } else {
mtctx->from_address = mtactx->from_address =
smtp_address_clone(context_pool, address); smtp_address_clone(context_pool, address);
} }
} T_END; } T_END;
...@@ -359,8 +359,8 @@ ntfy_mailto_runtime_check_operands(const struct sieve_enotify_env *nenv, ...@@ -359,8 +359,8 @@ ntfy_mailto_runtime_check_operands(const struct sieve_enotify_env *nenv,
if (parsed_uri == NULL) if (parsed_uri == NULL)
return FALSE; return FALSE;
mtctx->uri = parsed_uri; mtactx->uri = parsed_uri;
*method_context = mtctx; *method_context = mtactx;
return TRUE; return TRUE;
} }
...@@ -374,16 +374,16 @@ ntfy_mailto_action_check_duplicates( ...@@ -374,16 +374,16 @@ ntfy_mailto_action_check_duplicates(
const struct sieve_enotify_action *nact, const struct sieve_enotify_action *nact,
const struct sieve_enotify_action *nact_other) const struct sieve_enotify_action *nact_other)
{ {
struct ntfy_mailto_context *mtctx = struct ntfy_mailto_action_context *mtactx =
(struct ntfy_mailto_context *)nact->method_context; nact->method_context;
struct ntfy_mailto_context *mtctx_other = struct ntfy_mailto_action_context *mtactx_other =
(struct ntfy_mailto_context *)nact_other->method_context; nact_other->method_context;
const struct uri_mailto_recipient *new_rcpts, *old_rcpts; const struct uri_mailto_recipient *new_rcpts, *old_rcpts;
unsigned int new_count, old_count, i, j; unsigned int new_count, old_count, i, j;
unsigned int del_start = 0, del_len = 0; unsigned int del_start = 0, del_len = 0;
new_rcpts = array_get(&mtctx->uri->recipients, &new_count); new_rcpts = array_get(&mtactx->uri->recipients, &new_count);
old_rcpts = array_get(&mtctx_other->uri->recipients, &old_count); old_rcpts = array_get(&mtactx_other->uri->recipients, &old_count);
for (i = 0; i < new_count; i++) { for (i = 0; i < new_count; i++) {
for (j = 0; j < old_count; j++) { for (j = 0; j < old_count; j++) {
...@@ -396,12 +396,12 @@ ntfy_mailto_action_check_duplicates( ...@@ -396,12 +396,12 @@ ntfy_mailto_action_check_duplicates(
/* Not duplicate */ /* Not duplicate */
if (del_len > 0) { if (del_len > 0) {
/* Perform pending deletion */ /* Perform pending deletion */
array_delete(&mtctx->uri->recipients, array_delete(&mtactx->uri->recipients,
del_start, del_len); del_start, del_len);
/* Make sure the loop integrity is maintained */ /* Make sure the loop integrity is maintained */
i -= del_len; i -= del_len;
new_rcpts = array_get(&mtctx->uri->recipients, new_rcpts = array_get(&mtactx->uri->recipients,
&new_count); &new_count);
} }
del_len = 0; del_len = 0;
...@@ -415,8 +415,8 @@ ntfy_mailto_action_check_duplicates( ...@@ -415,8 +415,8 @@ ntfy_mailto_action_check_duplicates(
/* Perform pending deletion */ /* Perform pending deletion */
if (del_len > 0) if (del_len > 0)
array_delete(&mtctx->uri->recipients, del_start, del_len); array_delete(&mtactx->uri->recipients, del_start, del_len);
return (array_count(&mtctx->uri->recipients) > 0 ? 0 : 1); return (array_count(&mtactx->uri->recipients) > 0 ? 0 : 1);
} }
/* /*
...@@ -430,8 +430,7 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv, ...@@ -430,8 +430,7 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv,
unsigned int count, i; unsigned int count, i;
const struct uri_mailto_recipient *recipients; const struct uri_mailto_recipient *recipients;
const struct uri_mailto_header_field *headers; const struct uri_mailto_header_field *headers;
struct ntfy_mailto_context *mtctx = struct ntfy_mailto_action_context *mtactx = nact->method_context;
(struct ntfy_mailto_context *)nact->method_context;
/* Print main method parameters */ /* Print main method parameters */
...@@ -442,10 +441,10 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv, ...@@ -442,10 +441,10 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv,
sieve_enotify_method_printf( sieve_enotify_method_printf(
penv, " => subject : %s\n", penv, " => subject : %s\n",
nact->message); nact->message);
} else if (mtctx->uri->subject != NULL) { } else if (mtactx->uri->subject != NULL) {
sieve_enotify_method_printf( sieve_enotify_method_printf(
penv, " => subject : %s\n", penv, " => subject : %s\n",
mtctx->uri->subject); mtactx->uri->subject);
} }
if (nact->from != NULL) { if (nact->from != NULL) {
...@@ -457,7 +456,7 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv, ...@@ -457,7 +456,7 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv,
sieve_enotify_method_printf(penv, " => recipients :\n"); sieve_enotify_method_printf(penv, " => recipients :\n");
recipients = array_get(&mtctx->uri->recipients, &count); recipients = array_get(&mtactx->uri->recipients, &count);
if (count == 0) { if (count == 0) {
sieve_enotify_method_printf( sieve_enotify_method_printf(
penv, " NONE, action has no effect\n"); penv, " NONE, action has no effect\n");
...@@ -477,7 +476,7 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv, ...@@ -477,7 +476,7 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv,
/* Print accepted headers for notification message */ /* Print accepted headers for notification message */
headers = array_get(&mtctx->uri->headers, &count); headers = array_get(&mtactx->uri->headers, &count);
if (count > 0) { if (count > 0) {
sieve_enotify_method_printf(penv, " => headers :\n"); sieve_enotify_method_printf(penv, " => headers :\n");
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
...@@ -489,10 +488,10 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv, ...@@ -489,10 +488,10 @@ ntfy_mailto_action_print(const struct sieve_enotify_print_env *penv,
/* Print body for notification message */ /* Print body for notification message */
if (mtctx->uri->body != NULL) { if (mtactx->uri->body != NULL) {
sieve_enotify_method_printf( sieve_enotify_method_printf(
penv, " => body : \n--\n%s\n--\n", penv, " => body : \n--\n%s\n--\n",
mtctx->uri->body); mtactx->uri->body);
} }
/* Finish output with an empty line */ /* Finish output with an empty line */
...@@ -523,16 +522,15 @@ ntfy_mailto_send(const struct sieve_enotify_exec_env *nenv, ...@@ -523,16 +522,15 @@ ntfy_mailto_send(const struct sieve_enotify_exec_env *nenv,
struct sieve_instance *svinst = nenv->svinst; struct sieve_instance *svinst = nenv->svinst;
const struct sieve_message_data *msgdata = nenv->msgdata; const struct sieve_message_data *msgdata = nenv->msgdata;
const struct sieve_script_env *senv = nenv->scriptenv; const struct sieve_script_env *senv = nenv->scriptenv;
struct ntfy_mailto_context *mtctx = struct ntfy_mailto_action_context *mtactx = nact->method_context;
(struct ntfy_mailto_context *)nact->method_context;
struct ntfy_mailto_config *mth_config = struct ntfy_mailto_config *mth_config =
(struct ntfy_mailto_config *)nenv->method->context; (struct ntfy_mailto_config *)nenv->method->context;
struct sieve_address_source env_from = struct sieve_address_source env_from =
mth_config->envelope_from; mth_config->envelope_from;
const char *from = NULL; const char *from = NULL;
const struct smtp_address *from_smtp = NULL; const struct smtp_address *from_smtp = NULL;
const char *subject = mtctx->uri->subject; const char *subject = mtactx->uri->subject;
const char *body = mtctx->uri->body; const char *body = mtactx->uri->body;
string_t *to, *cc, *all; string_t *to, *cc, *all;
const struct uri_mailto_recipient *recipients; const struct uri_mailto_recipient *recipients;
const struct uri_mailto_header_field *headers; const struct uri_mailto_header_field *headers;
...@@ -544,7 +542,7 @@ ntfy_mailto_send(const struct sieve_enotify_exec_env *nenv, ...@@ -544,7 +542,7 @@ ntfy_mailto_send(const struct sieve_enotify_exec_env *nenv,
int ret; int ret;
/* Get recipients */ /* Get recipients */
recipients = array_get(&mtctx->uri->recipients, &count); recipients = array_get(&mtactx->uri->recipients, &count);
if (count == 0) { if (count == 0) {
sieve_enotify_warning( sieve_enotify_warning(
nenv, "notify mailto uri specifies no recipients; " nenv, "notify mailto uri specifies no recipients; "
...@@ -585,8 +583,8 @@ ntfy_mailto_send(const struct sieve_enotify_exec_env *nenv, ...@@ -585,8 +583,8 @@ ntfy_mailto_send(const struct sieve_enotify_exec_env *nenv,
if (ret < 0) { if (ret < 0) {
from_smtp = NULL; from_smtp = NULL;
} else if (ret == 0) { } else if (ret == 0) {
if (mtctx->from_address != NULL) if (mtactx->from_address != NULL)
from_smtp = mtctx->from_address; from_smtp = mtactx->from_address;
else if (svinst->user_email != NULL) else if (svinst->user_email != NULL)
from_smtp = svinst->user_email; from_smtp = svinst->user_email;
else { else {
...@@ -696,7 +694,7 @@ ntfy_mailto_send(const struct sieve_enotify_exec_env *nenv, ...@@ -696,7 +694,7 @@ ntfy_mailto_send(const struct sieve_enotify_exec_env *nenv,
/* Add custom headers */ /* Add custom headers */
headers = array_get(&mtctx->uri->headers, &hcount); headers = array_get(&mtactx->uri->headers, &hcount);
for (h = 0; h < hcount; h++) { for (h = 0; h < hcount; h++) {
const char *name = const char *name =
rfc2822_header_field_name_sanitize(headers[h].name); rfc2822_header_field_name_sanitize(headers[h].name);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.