From d11f78c349719e66a6eb569f6f1a65d268a6dec4 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Sun, 28 May 2000 06:14:53 +0000 Subject: New file - lists rules appropriate for vfolders (no actions, etc). 2000-05-27 Not Zed * vfoldertypes.xml: New file - lists rules appropriate for vfolders (no actions, etc). * Makefile.am (EXTRA_DIST): Add vfoldertypes.xml * filter-driver.c (filter_driver_expand_option): Made public from expand_filter_option. (filter_driver_rule_count): find out how many user rules are defined. (filter_driver_rule_get): Get a user rule by index. svn path=/trunk/; revision=3240 --- filter/filter-driver.c | 76 +++++++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 28 deletions(-) (limited to 'filter/filter-driver.c') diff --git a/filter/filter-driver.c b/filter/filter-driver.c index 17ced7412d..e43f543611 100644 --- a/filter/filter-driver.c +++ b/filter/filter-driver.c @@ -301,46 +301,52 @@ expand_variables(GString *out, char *source, GList *args, GHashTable *globals) /* build an expression for the filter */ -static void -expand_filter_option(FilterDriver *d, GString *s, GString *action, struct filter_option *op) +void +filter_driver_expand_option(FilterDriver *d, GString *s, GString *action, struct filter_option *op) { GList *optionl; FilterArg *arg; struct _FilterDriverPrivate *p = _PRIVATE(d); - g_string_append(s, "(and "); - optionl = op->options; - while (optionl) { - struct filter_optionrule *or = optionl->data; - if (or->rule->type == FILTER_XML_MATCH - || or->rule->type == FILTER_XML_EXCEPT) { - if (or->args) { - arg = or->args->data; - if (arg) { - printf("arg = %s\n", arg->name); + if (s) { + g_string_append(s, "(and "); + optionl = op->options; + while (optionl) { + struct filter_optionrule *or = optionl->data; + if (or->rule->type == FILTER_XML_MATCH + || or->rule->type == FILTER_XML_EXCEPT) { + if (or->args) { + arg = or->args->data; + if (arg) { + printf("arg = %s\n", arg->name); + } } + expand_variables(s, or->rule->code, or->args, p->globals); } - expand_variables(s, or->rule->code, or->args, p->globals); + optionl = g_list_next(optionl); } - optionl = g_list_next(optionl); - } - g_string_append(s, ")"); + g_string_append(s, ")"); + } - g_string_append(action, "(begin "); - optionl = op->options; - while (optionl) { - struct filter_optionrule *or = optionl->data; - if (or->rule->type == FILTER_XML_ACTION) { - expand_variables(action, or->rule->code, or->args, p->globals); - g_string_append(action, " "); + if (action) { + g_string_append(action, "(begin "); + optionl = op->options; + while (optionl) { + struct filter_optionrule *or = optionl->data; + if (or->rule->type == FILTER_XML_ACTION) { + expand_variables(action, or->rule->code, or->args, p->globals); + g_string_append(action, " "); + } + optionl = g_list_next(optionl); } - optionl = g_list_next(optionl); + g_string_append(action, ")"); } - g_string_append(action, ")"); - printf("combined rule '%s'\n", s->str); - printf("combined action '%s'\n", action->str); + if (s) + printf("combined rule '%s'\n", s->str); + if (action) + printf("combined action '%s'\n", action->str); } static ESExpResult * @@ -522,6 +528,20 @@ close_folders(FilterDriver *d) return 0; } +int +filter_driver_rule_count(FilterDriver *d) +{ + struct _FilterDriverPrivate *p = _PRIVATE(d); + return g_list_length(p->options); +} + +struct filter_option * +filter_driver_rule_get(FilterDriver *d, int n) +{ + struct _FilterDriverPrivate *p = _PRIVATE(d); + return g_list_nth_data(p->options, n); +} + int filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox) { @@ -549,7 +569,7 @@ filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox) s = g_string_new(""); a = g_string_new(""); - expand_filter_option(d, s, a, fo); + filter_driver_expand_option(d, s, a, fo); printf("searching expression %s\n", s->str); p->matches = camel_folder_search_by_expression (p->source, s->str, p->ex); -- cgit v1.2.3