aboutsummaryrefslogtreecommitdiffstats
path: root/filter/filter-rule.c
diff options
context:
space:
mode:
Diffstat (limited to 'filter/filter-rule.c')
-rw-r--r--filter/filter-rule.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/filter/filter-rule.c b/filter/filter-rule.c
index c5d36d3496..f99c79e89b 100644
--- a/filter/filter-rule.c
+++ b/filter/filter-rule.c
@@ -144,6 +144,9 @@ filter_rule_clone(FilterRule *base, RuleContext *f)
xmlNodePtr xml;
FilterRule *rule;
+ g_assert(IS_FILTER_RULE(base));
+ g_assert(IS_RULE_CONTEXT(f));
+
/* TODO: do this more directly/efficiently */
xml = filter_rule_xml_encode(base);
rule = gtk_type_new(((GtkObject *)base)->klass->type);
@@ -156,6 +159,8 @@ filter_rule_clone(FilterRule *base, RuleContext *f)
void
filter_rule_set_name (FilterRule *fr, const char *name)
{
+ g_assert(IS_FILTER_RULE(fr));
+
g_free (fr->name);
fr->name = g_strdup (name);
}
@@ -163,6 +168,8 @@ filter_rule_set_name (FilterRule *fr, const char *name)
void
filter_rule_set_source (FilterRule *fr, const char *source)
{
+ g_assert(IS_FILTER_RULE(fr));
+
g_free (fr->source);
fr->source = g_strdup (source);
}
@@ -170,6 +177,8 @@ filter_rule_set_source (FilterRule *fr, const char *source)
xmlNodePtr
filter_rule_xml_encode (FilterRule *fr)
{
+ g_assert(IS_FILTER_RULE(fr));
+
return ((FilterRuleClass *) ((GtkObject *) fr)->klass)->xml_encode(fr);
}
@@ -188,7 +197,7 @@ xml_encode (FilterRule *fr)
xmlSetProp (node, "grouping", "any");
break;
}
-
+
if (fr->source) {
xmlSetProp (node, "source", fr->source);
} else {
@@ -197,12 +206,13 @@ xml_encode (FilterRule *fr)
}
if (fr->name) {
- gchar *encstr;
+ char *encstr;
+
work = xmlNewNode (NULL, "title");
- encstr = e_utf8_xml1_encode (fr->name);
- xmlNodeSetContent (work, encstr);
- g_free (encstr);
- xmlAddChild (node, work);
+ encstr = e_utf8_xml1_encode(fr->name);
+ xmlNodeSetContent(work, encstr);
+ g_free(encstr);
+ xmlAddChild(node, work);
}
set = xmlNewNode (NULL, "partset");
@@ -247,6 +257,10 @@ load_set (xmlNodePtr node, FilterRule *fr, RuleContext *f)
int
filter_rule_xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f)
{
+ g_assert(IS_FILTER_RULE(fr));
+ g_assert(IS_RULE_CONTEXT(f));
+ g_assert(node != NULL);
+
return ((FilterRuleClass *) ((GtkObject *) fr)->klass)->xml_decode(fr, node, f);
}
@@ -299,12 +313,18 @@ xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f)
void
filter_rule_add_part (FilterRule *fr, FilterPart *fp)
{
+ g_assert(IS_FILTER_RULE(fr));
+ g_assert(IS_FILTER_PART(fp));
+
fr->parts = g_list_append (fr->parts, fp);
}
void
filter_rule_remove_part (FilterRule *fr, FilterPart *fp)
{
+ g_assert(IS_FILTER_RULE(fr));
+ g_assert(IS_FILTER_PART(fp));
+
fr->parts = g_list_remove (fr->parts, fp);
}
@@ -312,6 +332,10 @@ void
filter_rule_replace_part (FilterRule *fr, FilterPart *fp, FilterPart *new)
{
GList *l;
+
+ g_assert(IS_FILTER_RULE(fr));
+ g_assert(IS_FILTER_PART(fp));
+ g_assert(IS_FILTER_PART(new));
l = g_list_find (fr->parts, fp);
if (l) {
@@ -324,6 +348,9 @@ filter_rule_replace_part (FilterRule *fr, FilterPart *fp, FilterPart *new)
void
filter_rule_build_code (FilterRule *fr, GString *out)
{
+ g_assert(IS_FILTER_RULE(fr));
+ g_assert(out != NULL);
+
return ((FilterRuleClass *) ((GtkObject *) fr)->klass)->build_code(fr, out);
}