dovecot-1.2-sieve: Enotify extension: cleaned up notify method A...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sun Jan 10 03:39:29 EET 2010
details: http://hg.rename-it.nl/dovecot-1.2-sieve/rev/8e1c2bbb0b5c
changeset: 1195:8e1c2bbb0b5c
user: Stephan Bosch <stephan at rename-it.nl>
date: Sun Jan 10 02:39:19 2010 +0100
description:
Enotify extension: cleaned up notify method API (part is in previous change).
diffstat:
src/lib-sieve/plugins/enotify/cmd-notify.c | 15 ++--
src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c | 65 +++++++++++----------
src/lib-sieve/plugins/enotify/sieve-ext-enotify.h | 9 +-
3 files changed, 45 insertions(+), 44 deletions(-)
diffs (253 lines):
diff -r 9da9817a0e05 -r 8e1c2bbb0b5c src/lib-sieve/plugins/enotify/cmd-notify.c
--- a/src/lib-sieve/plugins/enotify/cmd-notify.c Sun Jan 10 02:11:11 2010 +0100
+++ b/src/lib-sieve/plugins/enotify/cmd-notify.c Sun Jan 10 02:39:19 2010 +0100
@@ -523,7 +523,7 @@
const struct sieve_action *act ATTR_UNUSED,
const struct sieve_action *act_other ATTR_UNUSED)
{
- const struct sieve_enotify_action *nact1, *nact2;
+ const struct sieve_enotify_action *nact, *nact_other;
const struct sieve_enotify_method_def *nmth_def;
struct sieve_enotify_env nenv;
bool result = TRUE;
@@ -531,23 +531,22 @@
if ( act->context == NULL || act_other->context == NULL )
return 0;
- nact1 = (const struct sieve_enotify_action *) act->context;
- nact2 = (const struct sieve_enotify_action *) act_other->context;
+ nact = (const struct sieve_enotify_action *) act->context;
+ nact_other = (const struct sieve_enotify_action *) act_other->context;
- if ( nact1->method == NULL || nact1->method->def == NULL )
+ if ( nact->method == NULL || nact->method->def == NULL )
return 0;
- nmth_def = nact1->method->def;
+ nmth_def = nact->method->def;
if ( nmth_def->action_check_duplicates == NULL )
return 0;
memset(&nenv, sizeof(nenv), 0);
- nenv.method = nact1->method;
+ nenv.method = nact->method;
nenv.ehandler = sieve_prefix_ehandler_create
(sieve_result_get_error_handler(renv->result), act->location, "notify");
- result = nmth_def->action_check_duplicates
- (&nenv, nact1->method_context, nact2->method_context, act_other->location);
+ result = nmth_def->action_check_duplicates(&nenv, nact, nact_other);
sieve_error_handler_unref(&nenv.ehandler);
diff -r 9da9817a0e05 -r 8e1c2bbb0b5c src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c
--- a/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c Sun Jan 10 02:11:11 2010 +0100
+++ b/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c Sun Jan 10 02:39:19 2010 +0100
@@ -63,16 +63,17 @@
void **method_context);
static int ntfy_mailto_action_check_duplicates
- (const struct sieve_enotify_env *nenv, void *method_ctx1, void *method_ctx2,
- const char *dupl_location);
+ (const struct sieve_enotify_env *nenv,
+ const struct sieve_enotify_action *nact,
+ const struct sieve_enotify_action *nact_other);
static void ntfy_mailto_action_print
(const struct sieve_enotify_print_env *penv,
- const struct sieve_enotify_action *act);
+ const struct sieve_enotify_action *nact);
static bool ntfy_mailto_action_execute
(const struct sieve_enotify_exec_env *nenv,
- const struct sieve_enotify_action *act);
+ const struct sieve_enotify_action *nact);
const struct sieve_enotify_method_def mailto_notify = {
"mailto",
@@ -236,19 +237,19 @@
static int ntfy_mailto_action_check_duplicates
(const struct sieve_enotify_env *nenv ATTR_UNUSED,
- void *method_ctx1, void *method_ctx2,
- const char *dupl_location ATTR_UNUSED)
+ const struct sieve_enotify_action *nact,
+ const struct sieve_enotify_action *nact_other)
{
- struct ntfy_mailto_context *mt_new =
- (struct ntfy_mailto_context *) method_ctx1;
- struct ntfy_mailto_context *mt_old =
- (struct ntfy_mailto_context *) method_ctx2;
+ struct ntfy_mailto_context *mtctx =
+ (struct ntfy_mailto_context *) nact->method_context;
+ struct ntfy_mailto_context *mtctx_other =
+ (struct ntfy_mailto_context *) nact_other->method_context;
const struct uri_mailto_recipient *new_rcpts, *old_rcpts;
unsigned int new_count, old_count, i, j;
unsigned int del_start = 0, del_len = 0;
- new_rcpts = array_get(&mt_new->uri->recipients, &new_count);
- old_rcpts = array_get(&mt_old->uri->recipients, &old_count);
+ new_rcpts = array_get(&mtctx->uri->recipients, &new_count);
+ old_rcpts = array_get(&mtctx_other->uri->recipients, &old_count);
for ( i = 0; i < new_count; i++ ) {
for ( j = 0; j < old_count; j++ ) {
@@ -261,11 +262,11 @@
/* Not duplicate */
if ( del_len > 0 ) {
/* Perform pending deletion */
- array_delete(&mt_new->uri->recipients, del_start, del_len);
+ array_delete(&mtctx->uri->recipients, del_start, del_len);
/* Make sure the loop integrity is maintained */
i -= del_len;
- new_rcpts = array_get(&mt_new->uri->recipients, &new_count);
+ new_rcpts = array_get(&mtctx->uri->recipients, &new_count);
}
del_len = 0;
} else {
@@ -278,10 +279,10 @@
/* Perform pending deletion */
if ( del_len > 0 ) {
- array_delete(&mt_new->uri->recipients, del_start, del_len);
+ array_delete(&mtctx->uri->recipients, del_start, del_len);
}
- return ( array_count(&mt_new->uri->recipients) > 0 ? 0 : 1 );
+ return ( array_count(&mtctx->uri->recipients) > 0 ? 0 : 1 );
}
/*
@@ -290,29 +291,29 @@
static void ntfy_mailto_action_print
(const struct sieve_enotify_print_env *penv,
- const struct sieve_enotify_action *act)
+ const struct sieve_enotify_action *nact)
{
unsigned int count, i;
const struct uri_mailto_recipient *recipients;
const struct uri_mailto_header_field *headers;
struct ntfy_mailto_context *mtctx =
- (struct ntfy_mailto_context *) act->method_context;
+ (struct ntfy_mailto_context *) nact->method_context;
/* Print main method parameters */
sieve_enotify_method_printf
- (penv, " => importance : %d\n", act->importance);
+ (penv, " => importance : %d\n", nact->importance);
- if ( act->message != NULL )
+ if ( nact->message != NULL )
sieve_enotify_method_printf
- (penv, " => subject : %s\n", act->message);
+ (penv, " => subject : %s\n", nact->message);
else if ( mtctx->uri->subject != NULL )
sieve_enotify_method_printf
(penv, " => subject : %s\n", mtctx->uri->subject);
- if ( act->from != NULL )
+ if ( nact->from != NULL )
sieve_enotify_method_printf
- (penv, " => from : %s\n", act->from);
+ (penv, " => from : %s\n", nact->from);
/* Print mailto: recipients */
@@ -372,12 +373,12 @@
static bool ntfy_mailto_send
(const struct sieve_enotify_exec_env *nenv,
- const struct sieve_enotify_action *act, const char *recipient)
+ const struct sieve_enotify_action *nact, const char *recipient)
{
const struct sieve_message_data *msgdata = nenv->msgdata;
const struct sieve_script_env *senv = nenv->scriptenv;
struct ntfy_mailto_context *mtctx =
- (struct ntfy_mailto_context *) act->method_context;
+ (struct ntfy_mailto_context *) nact->method_context;
const char *from = NULL, *from_smtp = NULL;
const char *subject = mtctx->uri->subject;
const char *body = mtctx->uri->body;
@@ -404,10 +405,10 @@
}
/* Determine message from address */
- if ( act->from == NULL ) {
+ if ( nact->from == NULL ) {
from = t_strdup_printf("Postmaster <%s>", senv->postmaster_address);
} else {
- from = act->from;
+ from = nact->from;
}
/* Determine SMTP from address */
@@ -420,9 +421,9 @@
}
/* Determine subject */
- if ( act->message != NULL ) {
+ if ( nact->message != NULL ) {
/* FIXME: handle UTF-8 */
- subject = str_sanitize(act->message, NTFY_MAILTO_MAX_SUBJECT);
+ subject = str_sanitize(nact->message, NTFY_MAILTO_MAX_SUBJECT);
} else if ( subject == NULL ) {
const char *const *hsubject;
@@ -484,7 +485,7 @@
rfc2822_header_field_write(f, "Precedence", "bulk");
/* Set importance */
- switch ( act->importance ) {
+ switch ( nact->importance ) {
case 1:
rfc2822_header_field_write(f, "X-Priority", "1 (Highest)");
rfc2822_header_field_write(f, "Importance", "High");
@@ -543,7 +544,7 @@
static bool ntfy_mailto_action_execute
(const struct sieve_enotify_exec_env *nenv,
- const struct sieve_enotify_action *act)
+ const struct sieve_enotify_action *nact)
{
const char *const *headers;
const char *sender = sieve_message_get_sender(nenv->msgctx);
@@ -574,7 +575,7 @@
}
}
- return ntfy_mailto_send(nenv, act, recipient);
+ return ntfy_mailto_send(nenv, nact, recipient);
}
diff -r 9da9817a0e05 -r 8e1c2bbb0b5c src/lib-sieve/plugins/enotify/sieve-ext-enotify.h
--- a/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h Sun Jan 10 02:11:11 2010 +0100
+++ b/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h Sun Jan 10 02:39:19 2010 +0100
@@ -63,18 +63,19 @@
/* Action duplicates */
int (*action_check_duplicates)
- (const struct sieve_enotify_env *nenv, void *method_ctx1,
- void *method_ctx2, const char *dupl_location);
+ (const struct sieve_enotify_env *nenv,
+ const struct sieve_enotify_action *nact,
+ const struct sieve_enotify_action *nact_other);
/* Action print */
void (*action_print)
(const struct sieve_enotify_print_env *penv,
- const struct sieve_enotify_action *act);
+ const struct sieve_enotify_action *nact);
/* Action execution */
bool (*action_execute)
(const struct sieve_enotify_exec_env *nenv,
- const struct sieve_enotify_action *act);
+ const struct sieve_enotify_action *nact);
};
/*
More information about the dovecot-cvs
mailing list