dovecot-2.2-pigeonhole: Merged changes from Pigeonhole v0.3.
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sat Oct 13 11:36:21 EEST 2012
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/9f9459bd038f
changeset: 1696:9f9459bd038f
user: Stephan Bosch <stephan at rename-it.nl>
date: Sat Oct 13 10:35:19 2012 +0200
description:
Merged changes from Pigeonhole v0.3.
diffstat:
src/lib-sieve/plugins/date/ext-date-common.c | 23 +++++---
src/lib-sieve/plugins/date/ext-date-common.h | 6 +-
src/lib-sieve/plugins/date/tst-date.c | 30 ++++++++--
src/lib-sieve/sieve-actions.c | 13 ++-
src/lib-sieve/sieve-error-private.h | 3 +-
src/lib-sieve/sieve-error.c | 76 +++++++++++++++++++++++++--
src/lib-sieve/sieve-error.h | 17 ++++++
src/lib-sieve/sieve-result.c | 21 +++++++-
src/lib-sieve/sieve-result.h | 6 ++
src/lib-sieve/sieve-script-dict.c | 1 -
src/managesieve-login/client.c | 2 +
src/plugins/lda-sieve/lda-sieve-plugin.c | 18 +++++-
tests/extensions/date/basic.svtest | 33 ++++++++++++
13 files changed, 213 insertions(+), 36 deletions(-)
diffs (truncated from 540 to 300 lines):
diff -r cf079ce8368b -r 9f9459bd038f src/lib-sieve/plugins/date/ext-date-common.c
--- a/src/lib-sieve/plugins/date/ext-date-common.c Fri Oct 12 19:25:10 2012 +0200
+++ b/src/lib-sieve/plugins/date/ext-date-common.c Sat Oct 13 10:35:19 2012 +0200
@@ -283,23 +283,28 @@
unsigned int date_parts_count = N_ELEMENTS(date_parts);
-const char *ext_date_part_extract
-(const char *part, struct tm *tm, int zone_offset)
+const struct ext_date_part *ext_date_part_find(const char *part)
{
unsigned int i;
for ( i = 0; i < date_parts_count; i++ ) {
if ( strcasecmp(date_parts[i]->identifier, part) == 0 ) {
- if ( date_parts[i]->get_string != NULL )
- return date_parts[i]->get_string(tm, zone_offset);
-
- return NULL;
+ return date_parts[i];
}
}
return NULL;
}
+const char *ext_date_part_extract
+(const struct ext_date_part *dpart, struct tm *tm, int zone_offset)
+{
+ if ( dpart == NULL || dpart->get_string == NULL )
+ return NULL;
+
+ return dpart->get_string(tm, zone_offset);
+}
+
/*
* Date part implementations
*/
@@ -455,7 +460,7 @@
struct sieve_stringlist *field_values;
int time_zone;
- const char *date_part;
+ const struct ext_date_part *date_part;
time_t local_time;
int local_zone;
@@ -465,7 +470,7 @@
struct sieve_stringlist *ext_date_stringlist_create
(const struct sieve_runtime_env *renv, struct sieve_stringlist *field_values,
- int time_zone, const char *date_part)
+ int time_zone, const struct ext_date_part *dpart)
{
struct ext_date_stringlist *strlist;
@@ -476,7 +481,7 @@
strlist->strlist.reset = ext_date_stringlist_reset;
strlist->field_values = field_values;
strlist->time_zone = time_zone;
- strlist->date_part = date_part;
+ strlist->date_part = dpart;
strlist->local_time = ext_date_get_current_date(renv, &strlist->local_zone);
diff -r cf079ce8368b -r 9f9459bd038f src/lib-sieve/plugins/date/ext-date-common.h
--- a/src/lib-sieve/plugins/date/ext-date-common.h Fri Oct 12 19:25:10 2012 +0200
+++ b/src/lib-sieve/plugins/date/ext-date-common.h Sat Oct 13 10:35:19 2012 +0200
@@ -60,8 +60,10 @@
const char *(*get_string)(struct tm *tm, int zone_offset);
};
+const struct ext_date_part *ext_date_part_find(const char *part);
+
const char *ext_date_part_extract
- (const char *part, struct tm *tm, int zone_offset);
+ (const struct ext_date_part *dpart, struct tm *tm, int zone_offset);
/*
* Date stringlist
@@ -74,7 +76,7 @@
struct sieve_stringlist *ext_date_stringlist_create
(const struct sieve_runtime_env *renv, struct sieve_stringlist *field_values,
- int time_zone, const char *date_part);
+ int time_zone, const struct ext_date_part *dpart);
diff -r cf079ce8368b -r 9f9459bd038f src/lib-sieve/plugins/date/tst-date.c
--- a/src/lib-sieve/plugins/date/tst-date.c Fri Oct 12 19:25:10 2012 +0200
+++ b/src/lib-sieve/plugins/date/tst-date.c Sat Oct 13 10:35:19 2012 +0200
@@ -260,7 +260,7 @@
return FALSE;
if ( !sieve_command_verify_headers_argument(valdtr, arg) )
- return FALSE;
+ return FALSE;
arg = sieve_ast_argument_next(arg);
}
@@ -275,6 +275,16 @@
if ( !sieve_validator_argument_activate(valdtr, tst, arg, FALSE) )
return FALSE;
+ if ( sieve_argument_is_string_literal(arg) ) {
+ const char * part = sieve_ast_argument_strc(arg);
+
+ if ( ext_date_part_find(part) == NULL ) {
+ sieve_argument_validate_warning
+ (valdtr, arg, "specified date part `%s' is not known",
+ str_sanitize(part, 80));
+ }
+ }
+
arg = sieve_ast_argument_next(arg);
/* Check key list */
@@ -349,7 +359,7 @@
if ( !sieve_opr_string_dump_ex(denv, address, "zone", "ORIGINAL") )
return FALSE;
break;
- default:
+ default:
return FALSE;
}
}
@@ -381,6 +391,7 @@
struct sieve_stringlist *hdr_list = NULL, *hdr_value_list;
struct sieve_stringlist *value_list, *key_list;
bool zone_specified = FALSE, zone_literal = TRUE;
+ const struct ext_date_part *dpart;
int time_zone;
int match, ret;
@@ -433,11 +444,19 @@
} else if ( !ext_date_parse_timezone(str_c(zone), &time_zone) ) {
if ( !zone_literal )
sieve_runtime_warning(renv, NULL,
- "specified :zone argument '%s' is not a valid timezone "
+ "specified :zone argument `%s' is not a valid timezone "
"(using local zone)", str_sanitize(str_c(zone), 40));
time_zone = EXT_DATE_TIMEZONE_LOCAL;
}
+ if ( (dpart=ext_date_part_find(str_c(date_part))) == NULL ) {
+ sieve_runtime_warning(renv, NULL,
+ "specified date part argument `%s' is not known",
+ str_sanitize(str_c(date_part), 40));
+ sieve_interpreter_set_test_result(renv->interp, FALSE);
+ return SIEVE_EXEC_OK;
+ }
+
/*
* Perform test
*/
@@ -449,7 +468,7 @@
/* Create value stringlist */
hdr_value_list = sieve_message_header_stringlist_create(renv, hdr_list, FALSE);
value_list = ext_date_stringlist_create
- (renv, hdr_value_list, time_zone, str_c(date_part));
+ (renv, hdr_value_list, time_zone, dpart);
} else if ( sieve_operation_is(op, currentdate_operation) ) {
/* Use time stamp recorded at the time the script first started */
@@ -457,8 +476,7 @@
sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, "currentdatedate test");
/* Create value stringlist */
- value_list = ext_date_stringlist_create
- (renv, NULL, time_zone, str_c(date_part));
+ value_list = ext_date_stringlist_create(renv, NULL, time_zone, dpart);
} else {
i_unreached();
}
diff -r cf079ce8368b -r 9f9459bd038f src/lib-sieve/sieve-actions.c
--- a/src/lib-sieve/sieve-actions.c Fri Oct 12 19:25:10 2012 +0200
+++ b/src/lib-sieve/sieve-actions.c Sat Oct 13 10:35:19 2012 +0200
@@ -605,13 +605,16 @@
(mailbox_get_storage(trans->box), &error_code);
}
- if ( error_code != MAIL_ERROR_NOTFOUND && error_code != MAIL_ERROR_PARAMS )
- {
+ if ( error_code == MAIL_ERROR_NOTFOUND ||
+ error_code == MAIL_ERROR_PARAMS ) {
+ sieve_result_error(aenv, "failed to store into mailbox %s: %s",
+ mailbox_name, errstr);
+ } else if ( error_code == MAIL_ERROR_NOSPACE ) {
+ sieve_result_global_log_error
+ (aenv, "failed to store into mailbox %s: %s", mailbox_name, errstr);
+ } else {
sieve_result_global_error(aenv, "failed to store into mailbox %s: %s",
mailbox_name, errstr);
- } else {
- sieve_result_error(aenv, "failed to store into mailbox %s: %s",
- mailbox_name, errstr);
}
/* Store aborted? */
diff -r cf079ce8368b -r 9f9459bd038f src/lib-sieve/sieve-error-private.h
--- a/src/lib-sieve/sieve-error-private.h Fri Oct 12 19:25:10 2012 +0200
+++ b/src/lib-sieve/sieve-error-private.h Sat Oct 13 10:35:19 2012 +0200
@@ -11,7 +11,8 @@
*/
enum sieve_error_flags {
- SIEVE_ERROR_FLAG_GLOBAL = (1 << 0)
+ SIEVE_ERROR_FLAG_GLOBAL = (1 << 0),
+ SIEVE_ERROR_FLAG_GLOBAL_MAX_INFO = (1 << 1),
};
/*
diff -r cf079ce8368b -r 9f9459bd038f src/lib-sieve/sieve-error.c
--- a/src/lib-sieve/sieve-error.c Fri Oct 12 19:25:10 2012 +0200
+++ b/src/lib-sieve/sieve-error.c Sat Oct 13 10:35:19 2012 +0200
@@ -84,11 +84,17 @@
VA_COPY(args_copy, args);
- svinst->system_ehandler->verror
- (svinst->system_ehandler, 0, location, fmt, args_copy);
+ if ( (flags & SIEVE_ERROR_FLAG_GLOBAL_MAX_INFO) != 0 ) {
+ svinst->system_ehandler->vinfo
+ (svinst->system_ehandler, 0, location, fmt, args_copy);
+ } else {
+ svinst->system_ehandler->verror
+ (svinst->system_ehandler, 0, location, fmt, args_copy);
+ }
}
- if ( ehandler == NULL ) return;
+ if ( ehandler == NULL )
+ return;
if ( ehandler->parent != NULL || sieve_errors_more_allowed(ehandler) ) {
if ( ehandler->verror != NULL )
@@ -111,11 +117,17 @@
VA_COPY(args_copy, args);
- svinst->system_ehandler->vwarning
- (svinst->system_ehandler, 0, location, fmt, args_copy);
+ if ( (flags & SIEVE_ERROR_FLAG_GLOBAL_MAX_INFO) != 0 ) {
+ svinst->system_ehandler->vinfo
+ (svinst->system_ehandler, 0, location, fmt, args_copy);
+ } else {
+ svinst->system_ehandler->vwarning
+ (svinst->system_ehandler, 0, location, fmt, args_copy);
+ }
}
- if ( ehandler == NULL ) return;
+ if ( ehandler == NULL )
+ return;
if ( ehandler->vwarning != NULL )
ehandler->vwarning(ehandler, flags, location, fmt, args);
@@ -140,7 +152,8 @@
(svinst->system_ehandler, 0, location, fmt, args_copy);
}
- if ( ehandler == NULL ) return;
+ if ( ehandler == NULL )
+ return;
if ( ehandler->parent != NULL || ehandler->log_info ) {
if ( ehandler->vinfo != NULL )
@@ -164,7 +177,8 @@
(svinst->system_ehandler, 0, location, fmt, args_copy);
}
- if ( ehandler == NULL ) return;
+ if ( ehandler == NULL )
+ return;
if ( ehandler->parent != NULL || ehandler->log_debug ) {
if ( ehandler->vdebug != NULL )
@@ -300,6 +314,24 @@
(svinst, ehandler, SIEVE_ERROR_FLAG_GLOBAL, location, fmt, args);
}
+void sieve_global_info_verror
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+ const char *location, const char *fmt, va_list args)
+{
+ sieve_direct_verror(svinst, ehandler,
+ (SIEVE_ERROR_FLAG_GLOBAL | SIEVE_ERROR_FLAG_GLOBAL_MAX_INFO),
+ location, fmt, args);
+}
+
+void sieve_global_info_vwarning
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+ const char *location, const char *fmt, va_list args)
+{
+ sieve_direct_vwarning(svinst, ehandler,
+ (SIEVE_ERROR_FLAG_GLOBAL | SIEVE_ERROR_FLAG_GLOBAL_MAX_INFO),
+ location, fmt, args);
+}
+
More information about the dovecot-cvs
mailing list