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/rule-context.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'filter/rule-context.c') 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