dovecot-2.0-pigeonhole: Vacation extension: added default period...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Tue Jan 25 02:28:55 EET 2011


details:   http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/b6aa4ac74175
changeset: 1466:b6aa4ac74175
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Tue Jan 25 01:27:01 2011 +0100
description:
Vacation extension: added default period configuration setting and fixed a limit bug.

diffstat:

 doc/vacation.txt                                     |  12 ++++++++++--
 src/lib-sieve/plugins/vacation/cmd-vacation.c        |  10 +++++++---
 src/lib-sieve/plugins/vacation/ext-vacation-common.c |  18 ++++++++++++++----
 src/lib-sieve/plugins/vacation/ext-vacation-common.h |   5 ++++-
 4 files changed, 35 insertions(+), 10 deletions(-)

diffs (133 lines):

diff -r 129adff0c81b -r b6aa4ac74175 doc/vacation.txt
--- a/doc/vacation.txt	Tue Jan 25 01:05:28 2011 +0100
+++ b/doc/vacation.txt	Tue Jan 25 01:27:01 2011 +0100
@@ -8,15 +8,20 @@
 sieve_vacation_min_period = 1d
   This specifies the minimum period that can be specified for the :days tag
   of the vacation command. Values are specified in s(econds), unless followed
-  by a d(ay), h(our), m(inute) specifier character. 
+  by a d(ay), h(our) or m(inute) specifier character. 
 
 sieve_vacation_max_period = 0
   This specifies the minimum period that can be specified for the :days tag
   of the vacation command. Values are specified in s(econds), unless followed
-  by a d(ay), h(our), m(inute) specifier character. The configured value
+  by a d(ay), h(our) or m(inute) specifier character. The configured value
   must be larger than the sieve_vacation_min_period setting. A value of 0
   has a special meaning: it indicates that there is no upper limit. 
 
+sieve_vacation_default_period = 7d
+	This specifies the default period that can be specified for the :days tag
+  of the vacation command. Values are specified in s(econds), unless followed
+  by a d(ay), h(our) or m(inute) specifier character.
+
 Example
 =======
 
@@ -26,6 +31,9 @@
   # One minute at minimum
   sieve_vacation_min_period = 1m
 
+  # Ten days default
+  sieve_vacation_min_period = 10d
+
   # Thirty days at maximum
   sieve_vacation_max_period = 30d
 }
diff -r 129adff0c81b -r b6aa4ac74175 src/lib-sieve/plugins/vacation/cmd-vacation.c
--- a/src/lib-sieve/plugins/vacation/cmd-vacation.c	Tue Jan 25 01:05:28 2011 +0100
+++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c	Tue Jan 25 01:27:01 2011 +0100
@@ -554,11 +554,13 @@
 (const struct sieve_runtime_env *renv, sieve_size_t *address)
 {	
 	const struct sieve_extension *this_ext = renv->oprtn->ext;
+	const struct ext_vacation_config *config =
+		(const struct ext_vacation_config *) this_ext->context;
 	struct sieve_side_effects_list *slist = NULL;
 	struct act_vacation_context *act;
 	pool_t pool;
 	int opt_code = 0;
-	sieve_number_t seconds = EXT_VACATION_DEFAULT_PERIOD;
+	sieve_number_t seconds = config->default_period;
 	bool mime = FALSE;
 	struct sieve_stringlist *addresses = NULL;
 	string_t *reason, *subject = NULL, *from = NULL, *handle = NULL; 
@@ -1132,8 +1134,10 @@
 
 		/* Check period limits once more */
 		seconds = ctx->seconds;
-		if ( seconds < config->min_period ) seconds = config->min_period;
-		if ( seconds > config->max_period ) seconds = config->max_period;
+		if ( seconds < config->min_period ) 
+			seconds = config->min_period;
+		else if ( config->max_period > 0 && seconds > config->max_period )
+			seconds = config->max_period;
 
 		/* Mark as replied */
 		sieve_action_duplicate_mark
diff -r 129adff0c81b -r b6aa4ac74175 src/lib-sieve/plugins/vacation/ext-vacation-common.c
--- a/src/lib-sieve/plugins/vacation/ext-vacation-common.c	Tue Jan 25 01:05:28 2011 +0100
+++ b/src/lib-sieve/plugins/vacation/ext-vacation-common.c	Tue Jan 25 01:27:01 2011 +0100
@@ -10,7 +10,7 @@
 {
 	struct sieve_instance *svinst = ext->svinst;
 	struct ext_vacation_config *config;
-	sieve_number_t min_period, max_period;
+	sieve_number_t min_period, max_period, default_period;
 
 	if ( *context != NULL ) {
 		ext_vacation_unload(ext);
@@ -26,18 +26,28 @@
 		max_period = EXT_VACATION_DEFAULT_MAX_PERIOD;
 	}
 
-	if ( max_period > 0 && max_period < min_period ) {
+	if ( !sieve_setting_get_duration_value
+		(svinst, "sieve_vacation_default_period", &default_period) ) {
+		default_period = EXT_VACATION_DEFAULT_PERIOD;
+	}
+
+	if ( max_period > 0 
+		&& (min_period > max_period || default_period < min_period
+			|| default_period > max_period) ) {
 		min_period = EXT_VACATION_DEFAULT_MIN_PERIOD;
 		max_period = EXT_VACATION_DEFAULT_MAX_PERIOD;
+		default_period = EXT_VACATION_DEFAULT_PERIOD;
 
 		sieve_sys_warning(svinst,
-			"vacation extension: invalid settings: "
-			"sieve_vacation_min_period > sieve_vacation_max_period");
+			"vacation extension: invalid settings: violated "
+			"sieve_vacation_min_period < sieve_vacation_default_period < "
+			"sieve_vacation_max_period");
 	}
 	
 	config = i_new(struct ext_vacation_config, 1);
 	config->min_period = min_period;
 	config->max_period = max_period;
+	config->default_period = default_period;
 
 	*context = (void *) config;
 
diff -r 129adff0c81b -r b6aa4ac74175 src/lib-sieve/plugins/vacation/ext-vacation-common.h
--- a/src/lib-sieve/plugins/vacation/ext-vacation-common.h	Tue Jan 25 01:05:28 2011 +0100
+++ b/src/lib-sieve/plugins/vacation/ext-vacation-common.h	Tue Jan 25 01:27:01 2011 +0100
@@ -17,6 +17,7 @@
 struct ext_vacation_config {
 	unsigned int min_period;
 	unsigned int max_period;
+	unsigned int default_period;
 };
 
 /* 
@@ -31,7 +32,9 @@
 
 extern const struct sieve_operation_def vacation_operation;
 
-/* Extension */
+/* 
+ * Extension 
+ */
 
 extern const struct sieve_extension_def vacation_extension;
 


More information about the dovecot-cvs mailing list