aboutsummaryrefslogtreecommitdiffstats
path: root/filter/filter-rule.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-07-15 09:46:17 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-07-15 09:46:17 +0800
commit68ec840bca073bc8e8ea2f58ad36078df9c619c1 (patch)
tree64083ad8df8983d37c2658c51e1c961e4671f160 /filter/filter-rule.c
parente785008af08bdc913ce2711dcd7998efb51f694b (diff)
downloadgsoc2013-evolution-68ec840bca073bc8e8ea2f58ad36078df9c619c1.tar.gz
gsoc2013-evolution-68ec840bca073bc8e8ea2f58ad36078df9c619c1.tar.zst
gsoc2013-evolution-68ec840bca073bc8e8ea2f58ad36078df9c619c1.zip
** fixes for #10781
2002-07-10 Not Zed <NotZed@Ximian.com> ** fixes for #10781 * filter-int.c (xml_encode): (xml_decode): Handle encoding/decoding with a type name, in a manner compatible with the score/label elemtns. (filter_int_new_type): New constructor to create a generic 'int' type. * filter-score.c: Removed. Now relies on using a filter-int with appropriate settings. * filter-label.[ch]: Now inherits from filter-int. * rule-context.c (rule_context_revert): New method to revert a filter context back to a user-file's definition. (revert): implementation. * filter-rule.h: Added new virtual method _eq and wrapper, and fixed all subclasses to implement it. * filter-element.h: Added new virtual method _eq and wrapper. Fixed all subclasses to implement it. svn path=/trunk/; revision=17448
Diffstat (limited to 'filter/filter-rule.c')
-rw-r--r--filter/filter-rule.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/filter/filter-rule.c b/filter/filter-rule.c
index 89e0d76726..4adffeaf3c 100644
--- a/filter/filter-rule.c
+++ b/filter/filter-rule.c
@@ -41,6 +41,7 @@
#define d(x)
static int validate(FilterRule *);
+static int rule_eq(FilterRule *fr, FilterRule *cm);
static xmlNodePtr xml_encode (FilterRule *);
static int xml_decode (FilterRule *, xmlNodePtr, RuleContext *);
static void build_code (FilterRule *, GString * out);
@@ -100,6 +101,7 @@ filter_rule_class_init (FilterRuleClass * class)
/* override methods */
class->validate = validate;
+ class->eq = rule_eq;
class->xml_encode = xml_encode;
class->xml_decode = xml_decode;
class->build_code = build_code;
@@ -231,6 +233,43 @@ validate (FilterRule *fr)
return valid;
}
+int
+filter_rule_eq(FilterRule *fr, FilterRule *cm)
+{
+ g_assert(IS_FILTER_RULE(fr));
+ g_assert(IS_FILTER_RULE(cm));
+
+ return ((GtkObject *)fr)->klass == ((GtkObject *)cm)->klass
+ && ((FilterRuleClass *) ((GtkObject *) fr)->klass)->eq(fr, cm);
+}
+
+static int
+list_eq(GList *al, GList *bl)
+{
+ int truth = TRUE;
+
+ while (truth && al && bl) {
+ FilterPart *a = al->data, *b = bl->data;
+
+ truth = filter_part_eq(a, b);
+ al = al->next;
+ bl = bl->next;
+ }
+
+ return truth && al == NULL && bl == NULL;
+}
+
+static int
+rule_eq(FilterRule *fr, FilterRule *cm)
+{
+ return fr->grouping == cm->grouping
+ && ( (fr->name && cm->name && strcmp(fr->name, cm->name) == 0)
+ || (fr->name == NULL && cm->name == NULL))
+ && ( (fr->source && cm->source && strcmp(fr->source, cm->source) == 0)
+ || (fr->source == NULL && cm->source == NULL) )
+ && list_eq(fr->parts, cm->parts);
+}
+
xmlNodePtr
filter_rule_xml_encode (FilterRule *fr)
{