dovecot-2.0-sieve: Enotify extension: cleaned up notify method A...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Tue Jan 12 01:24:45 EET 2010


details:   http://hg.rename-it.nl/dovecot-2.0-sieve/rev/4f2cb8c56d10
changeset: 1194:4f2cb8c56d10
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 72bf8c987ded -r 4f2cb8c56d10 src/lib-sieve/plugins/enotify/cmd-notify.c
--- a/src/lib-sieve/plugins/enotify/cmd-notify.c	Tue Jan 12 00:23:08 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 72bf8c987ded -r 4f2cb8c56d10 src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c
--- a/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c	Tue Jan 12 00:23:08 2010 +0100
+++ b/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c	Sun Jan 10 02:39:19 2010 +0100
@@ -65,16 +65,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",
@@ -238,19 +239,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++ ) {
@@ -263,11 +264,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 {
@@ -280,10 +281,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 );
 }
 
 /*
@@ -292,29 +293,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 */
 
@@ -374,12 +375,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;
@@ -406,10 +407,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 */
@@ -422,9 +423,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;
 		
@@ -487,7 +488,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");
@@ -546,7 +547,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);
@@ -577,7 +578,7 @@
 		}
 	}
 
-	return ntfy_mailto_send(nenv, act, recipient);
+	return ntfy_mailto_send(nenv, nact, recipient);
 }
 
 
diff -r 72bf8c987ded -r 4f2cb8c56d10 src/lib-sieve/plugins/enotify/sieve-ext-enotify.h
--- a/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h	Tue Jan 12 00:23:08 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