From 99274a95701e007c22cbfc3f7d42a123b0464ea4 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Mon, 15 Sep 2003 22:43:15 +0000 Subject: ** See Natzilla task #47524 2003-09-15 Not Zed ** See Natzilla task #47524 * filter-rule.h (FilterRule): add a system bit, for rules that shouldn't be edited/saved. * rule-context.c (load): check for ruleset maps in the system file, and if they exist, load in as system rules. (save): ignore system rules if they exist. * searchtypes.xml: Added a search-specific types folder. Also contains system searches that cannot be deleted. svn path=/trunk/; revision=22581 --- filter/ChangeLog | 14 ++++++++++++++ filter/Makefile.am | 5 +++-- filter/filter-rule.h | 1 + filter/rule-context.c | 26 +++++++++++++++++++++++--- 4 files changed, 41 insertions(+), 5 deletions(-) (limited to 'filter') diff --git a/filter/ChangeLog b/filter/ChangeLog index b5931a5726..d7b721a9ce 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,17 @@ +2003-09-15 Not Zed + + ** See Natzilla task #47524 + + * filter-rule.h (FilterRule): add a system bit, for rules that + shouldn't be edited/saved. + + * rule-context.c (load): check for ruleset maps in the system + file, and if they exist, load in as system rules. + (save): ignore system rules if they exist. + + * searchtypes.xml: Added a search-specific types folder. Also + contains system searches that cannot be deleted. + 2003-08-05 Not Zed ** See bug #42636. diff --git a/filter/Makefile.am b/filter/Makefile.am index 29fb45e32c..e3dbec3278 100644 --- a/filter/Makefile.am +++ b/filter/Makefile.am @@ -75,11 +75,12 @@ EXTRA_DIST = \ filter-marshal.list \ filtertypes.xml \ libfilter-i18n.h \ - vfoldertypes.xml + vfoldertypes.xml \ + searchtypes.xml # basic rules. filterdir = $(privdatadir) -filter_DATA = filtertypes.xml vfoldertypes.xml +filter_DATA = filtertypes.xml vfoldertypes.xml searchtypes.xml libfilter-i18n.h: filtertypes.xml vfoldertypes.xml echo "/* Automatically generated. Do not edit. */" > $@; \ diff --git a/filter/filter-rule.h b/filter/filter-rule.h index b75213d274..6f92fc01c4 100644 --- a/filter/filter-rule.h +++ b/filter/filter-rule.h @@ -59,6 +59,7 @@ struct _FilterRule { char *source; enum _filter_grouping_t grouping; + unsigned int system:1; /* this is a system rule, cannot be edited/deleted */ GList *parts; }; diff --git a/filter/rule-context.c b/filter/rule-context.c index f76d9fae89..c822993d36 100644 --- a/filter/rule-context.c +++ b/filter/rule-context.c @@ -337,6 +337,24 @@ load(RuleContext *rc, const char *system, const char *user) } rule = rule->next; } + } else if ((rule_map = g_hash_table_lookup(rc->rule_set_map, set->name))) { + d(printf("loading system rules ...\n")); + rule = set->children; + while (rule) { + d(printf("checking node: %s\n", rule->name)); + if (!strcmp(rule->name, "rule")) { + FilterRule *part = FILTER_RULE(g_object_new(rule_map->type, NULL, NULL)); + + if (filter_rule_xml_decode(part, rule, rc) == 0) { + part->system = TRUE; + rule_map->append(rc, part); + } else { + g_object_unref(part); + g_warning("Cannot load filter part"); + } + } + rule = rule->next; + } } set = set->next; } @@ -412,9 +430,11 @@ save(RuleContext *rc, const char *user) xmlAddChild(root, rules); rule = NULL; while ((rule = map->next(rc, rule, NULL))) { - d(printf("processing rule %s\n", rule->name)); - work = filter_rule_xml_encode(rule); - xmlAddChild(rules, work); + if (!rule->system) { + d(printf("processing rule %s\n", rule->name)); + work = filter_rule_xml_encode(rule); + xmlAddChild(rules, work); + } } l = g_list_next(l); } -- cgit v1.2.3