From 30871da932e684894f88483bf4934bf989a5242d Mon Sep 17 00:00:00 2001 From: Michael Zucci Date: Tue, 16 May 2000 23:08:32 +0000 Subject: Initial filter rules. * filtertypes.xml: Initial filter rules. * filter-xml.c (filter_write_optionset): Save the description also. (write_description): Routine to save description - only saves 1 node of description. * filter-arg.c (filter_arg_edit_clicked): Dont free edata here, let the destroy do it(?) svn path=/trunk/; revision=3098 --- filter/ChangeLog | 10 ++++++ filter/Makefile.am | 4 +++ filter/filter-arg.c | 1 - filter/filter-editor.c | 3 ++ filter/filter-xml.c | 20 +++++++++++ filter/filtertypes.xml | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 filter/filtertypes.xml diff --git a/filter/ChangeLog b/filter/ChangeLog index 78b6a0823d..b483b6ba84 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,5 +1,15 @@ 2000-05-16 NotZed + * filtertypes.xml: Initial filter rules. + + * filter-xml.c (filter_write_optionset): Save the description + also. + (write_description): Routine to save description - only saves 1 + node of description. + + * filter-arg.c (filter_arg_edit_clicked): Dont free edata here, + let the destroy do it(?) + * filter-editor.c (main): Simple driver program for testing, so i can fix all this really broken code *sigh* diff --git a/filter/Makefile.am b/filter/Makefile.am index 17cac3ccf0..32ef89f638 100644 --- a/filter/Makefile.am +++ b/filter/Makefile.am @@ -29,3 +29,7 @@ libfilter_la_SOURCES = \ filter-driver.h EXTRA_DIST = blank.xpm check.xpm + +# basic rules. +filterdir = $(prefix)/share/evolution +filter_DATA = filtertypes.xml diff --git a/filter/filter-arg.c b/filter/filter-arg.c index 867afdc94e..77dffe284b 100644 --- a/filter/filter-arg.c +++ b/filter/filter-arg.c @@ -452,7 +452,6 @@ filter_arg_edit_clicked(GnomeDialog *d, int button, struct filter_arg_edit *edat } xmlFreeNodeList(p->oldargs); p->oldargs = NULL; - g_free(edata); p->dialogue = NULL; gnome_dialog_close(d); } diff --git a/filter/filter-editor.c b/filter/filter-editor.c index af064b32eb..ec6320b649 100644 --- a/filter/filter-editor.c +++ b/filter/filter-editor.c @@ -350,6 +350,9 @@ filter_editor_set_rule_files(FilterEditor *e, const char *systemrules, const cha out = xmlParseFile(userrules); if (out) options = filter_load_optionset(out, rules); + + printf("Loading system rules: %s = %p = %p\n", systemrules, doc, rules); + printf("Loading user rules: %s = %p = %p\n", userrules, out, options); filter_editor_set_rules(e, rules, options2, options); } diff --git a/filter/filter-xml.c b/filter/filter-xml.c index 0df8f49ad5..ada718778e 100644 --- a/filter/filter-xml.c +++ b/filter/filter-xml.c @@ -334,6 +334,19 @@ filter_load_optionset(xmlDocPtr doc, GList *rules) return l; } +static xmlNodePtr +write_description(xmlDocPtr doc, GList *descl) +{ + xmlNodePtr d; + struct filter_desc *desc; + + desc = descl->data; + d = xmlNewDocNode(doc, NULL, "description", NULL); + if (desc->type == FILTER_XML_TEXT) + xmlNodeSetContent(d, desc->data); + return d; +} + xmlNodePtr filter_write_optionset(xmlDocPtr doc, GList *optionl) { @@ -350,6 +363,13 @@ filter_write_optionset(xmlDocPtr doc, GList *optionl) option = xmlNewDocNode(doc, NULL, "option", NULL); xmlSetProp(option, "type", detokenise(op->type)); + if (op->description) { + xmlNodePtr desc; + + desc = write_description(doc, op->description); + xmlAddChild(option, desc); + } + optionrulel = op->options; while (optionrulel) { or = optionrulel->data; diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml new file mode 100644 index 0000000000..f93a7b9c35 --- /dev/null +++ b/filter/filtertypes.xml @@ -0,0 +1,94 @@ + + + + + + (match-all (header-contains "From" ${sender})) + + The From address matches sender(s). + + + + + (match-all (header-contains "To" ${receipient})) + + The To address matches receipients. + + + + + (match-all (header-contains "Subject" ${words})) + + The Subject contains words. + + + + + (match-all (header-contains "CC" ${self-email})) + + I am in the cc list. + + + + + (& (> message-size (size-lower size-range)) + (< message-size (size-uppwer size-range))) + + The message is a certain size. + + + + + + + (copy-to ${folder}) + + Send a copy to folder. + + + + (forward-to ${address}) + + Forward the message to people. + + + + (delete) + + Delete message. + + + + (stop) + + Stop processing further rules for this message. + + + + + + + (match-all (not (header-contains "To" ${self-email}))) + + When I am the receipient. + + + + + + + + + + -- cgit v1.2.3