Get the root node properly.

2002-11-13  Not Zed  <NotZed@Ximian.com>

	* rule-context.c (load): Get the root node properly.

	* rule-editor.c (rule_add): cast g_object_weak_ref
	(rule_edit): "

	* all: xml2 node change - childs->children.  Also, ignore 'text'
	nodes while scanning tree.

	* rule-context.h: gnome-xml->libxml.

	* filter-element.h: gnome-xml->libxml

svn path=/trunk/; revision=18732
This commit is contained in:
Not Zed
2002-11-13 09:31:06 +00:00
committed by Michael Zucci
parent 9e4f25d532
commit ac1de7eaf9
16 changed files with 49 additions and 33 deletions

View File

@ -1,5 +1,17 @@
2002-11-13 Not Zed <NotZed@Ximian.com>
* rule-context.c (load): Get the root node properly.
* rule-editor.c (rule_add): cast g_object_weak_ref
(rule_edit): "
* all: xml2 node change - childs->children. Also, ignore 'text'
nodes while scanning tree.
* rule-context.h: gnome-xml->libxml.
* filter-element.h: gnome-xml->libxml
* vfolder-rule.c (source_add): comment out gtk_destroyed check.
* filter-label.c: Added back some of the guts. Might not work but

View File

@ -233,7 +233,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
xmlFree (fe->name);
fe->name = xmlGetProp (node, "name");
n = node->childs;
n = node->children;
while (n) {
if (!strcmp (n->name, "datespec")) {
val = xmlGetProp (n, "type");

View File

@ -26,8 +26,8 @@
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtkwidget.h>
#include <gnome-xml/parser.h>
#include <gnome-xml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
#define FILTER_TYPE_ELEMENT (filter_element_get_type ())
#define FILTER_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_ELEMENT, FilterElement))

View File

@ -256,7 +256,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
xmlFree (file->type);
file->type = type;
n = node->childs;
n = node->children;
if (!strcmp (n->name, type)) {
str = xmlNodeGetContent (n);
if (str)
@ -265,7 +265,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
file->path = g_strdup ("");
d(printf (" '%s'\n", file->path));
} else {
} else if (n->type == XML_ELEMENT_NODE) {
g_warning ("Unknown node type '%s' encountered decoding a %s\n", n->name, type);
}

View File

@ -244,7 +244,7 @@ load_set (xmlNodePtr node, FilterFilter *ff, RuleContext *rc)
char *rulename;
FilterPart *part;
work = node->childs;
work = node->children;
while (work) {
if (!strcmp (work->name, "part")) {
rulename = xmlGetProp (work, "name");
@ -257,7 +257,7 @@ load_set (xmlNodePtr node, FilterFilter *ff, RuleContext *rc)
g_warning ("cannot find rule part '%s'\n", rulename);
}
xmlFree (rulename);
} else {
} else if (work->type == XML_ELEMENT_NODE) {
g_warning ("Unknown xml node in part: %s", work->name);
}
work = work->next;
@ -275,7 +275,7 @@ xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *rc)
if (result != 0)
return result;
work = node->childs;
work = node->children;
while (work) {
if (!strcmp (work->name, "actionset")) {
load_set (work, ff, rc);

View File

@ -202,7 +202,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
xmlFree (fe->name);
fe->name = xmlGetProp (node, "name");
n = node->childs;
n = node->children;
while (n) {
if (!strcmp (n->name, "folder")) {
char *uri;

View File

@ -279,7 +279,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
fe->name = name;
xmlFree (fi->type);
fi->type = type;
n = node->childs;
n = node->children;
while (n) {
if (!strcmp (n->name, type)) {
if (!(str = xmlNodeGetContent (n)))
@ -288,7 +288,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
d(printf (" '%s'\n", str));
fi->values = g_list_append (fi->values, g_strdup (str));
xmlFree (str);
} else {
} else if (n->type == XML_ELEMENT_NODE) {
g_warning ("Unknown node type '%s' encountered decoding a %s\n", n->name, type);
}
n = n->next;

View File

@ -200,13 +200,13 @@ xml_create (FilterElement *fe, xmlNodePtr node)
/* parent implementation */
FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node);
n = node->childs;
n = node->children;
while (n) {
if (!strcmp (n->name, "option")) {
char *tmp, *value, *title = NULL, *code = NULL;
value = xmlGetProp (n, "value");
work = n->childs;
work = n->children;
while (work) {
if (!strcmp (work->name, "title")) {
if (!title) {
@ -232,7 +232,7 @@ xml_create (FilterElement *fe, xmlNodePtr node)
xmlFree (value);
g_free (title);
g_free (code);
} else {
} else if (n->type == XML_ELEMENT_NODE) {
g_warning ("Unknown xml node within optionlist: %s\n", n->name);
}
n = n->next;

View File

@ -175,7 +175,7 @@ filter_part_xml_create (FilterPart *ff, xmlNodePtr node)
if (str)
xmlFree (str);
n = node->childs;
n = node->children;
while (n) {
if (!strcmp (n->name, "input")) {
type = xmlGetProp (n, "type");
@ -203,7 +203,7 @@ filter_part_xml_create (FilterPart *ff, xmlNodePtr node)
if (str)
xmlFree (str);
}
} else {
} else if (n->type == XML_ELEMENT_NODE) {
g_warning ("Unknown part element in xml: %s\n", n->name);
}
n = n->next;
@ -245,7 +245,7 @@ filter_part_xml_decode (FilterPart *fp, xmlNodePtr node)
g_return_val_if_fail (fp != NULL, -1);
g_return_val_if_fail (node != NULL, -1);
n = node->childs;
n = node->children;
while (n) {
if (!strcmp (n->name, "value")) {
name = xmlGetProp (n, "name");

View File

@ -326,7 +326,7 @@ load_set (xmlNodePtr node, FilterRule *fr, RuleContext *f)
char *rulename;
FilterPart *part;
work = node->childs;
work = node->children;
while (work) {
if (!strcmp (work->name, "part")) {
rulename = xmlGetProp (work, "name");
@ -339,7 +339,7 @@ load_set (xmlNodePtr node, FilterRule *fr, RuleContext *f)
g_warning ("cannot find rule part '%s'\n", rulename);
}
xmlFree (rulename);
} else {
} else if (work->type == XML_ELEMENT_NODE) {
g_warning ("Unknown xml node in part: %s", work->name);
}
work = work->next;
@ -393,7 +393,7 @@ xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f)
fr->source = g_strdup ("incoming");
}
work = node->childs;
work = node->children;
while (work) {
if (!strcmp (work->name, "partset")) {
load_set (work, fr, f);

View File

@ -191,7 +191,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
CamelURL *url;
char *uri;
node = node->childs;
node = node->children;
if (node && node->name && !strcmp (node->name, "uri")) {
uri = xmlNodeGetContent (node);
url = camel_url_new (uri, NULL);

View File

@ -286,7 +286,7 @@ rule_context_load (RuleContext *rc, const char *system, const char *user)
static int
load (RuleContext *rc, const char *system, const char *user)
{
xmlNodePtr set, rule;
xmlNodePtr set, rule, root;
struct _part_set_map *part_map;
struct _rule_set_map *rule_map;
@ -300,8 +300,9 @@ load (RuleContext *rc, const char *system, const char *user)
system, g_strerror (errno)));
return -1;
}
if (strcmp (rc->system->name, "filterdescription")) {
root = xmlDocGetRootElement(rc->system);
if (root == NULL || strcmp (root->name, "filterdescription")) {
rule_context_set_error (rc, g_strdup_printf ("Unable to load system rules '%s': Invalid format", system));
xmlFreeDoc (rc->system);
rc->system = NULL;
@ -312,7 +313,7 @@ load (RuleContext *rc, const char *system, const char *user)
/* now parse structure */
/* get rule parts */
set = rc->system->children;
set = root->children;
while (set) {
d(printf("set name = %s\n", set->name));
part_map = g_hash_table_lookup (rc->part_set_map, set->name);
@ -338,7 +339,8 @@ load (RuleContext *rc, const char *system, const char *user)
/* now load actual rules */
if (rc->user) {
set = rc->user->children;
root = xmlDocGetRootElement(rc->user);
set = root?root->children:NULL;
while (set) {
d(printf("set name = %s\n", set->name));
rule_map = g_hash_table_lookup (rc->rule_set_map, set->name);
@ -413,7 +415,9 @@ save (RuleContext *rc, const char *user)
l = g_list_next (l);
}
ret = e_xml_save_file (user, doc);
#warning "xmlSaveFile used here"
ret = xmlSaveFile (user, doc);
/*ret = e_xml_save_file (user, doc);*/
xmlFreeDoc (doc);

View File

@ -26,7 +26,7 @@
#include <glib.h>
#include <glib-object.h>
#include <gnome-xml/parser.h>
#include <libxml/parser.h>
#include "filter-part.h"
#include "filter-rule.h"

View File

@ -291,7 +291,7 @@ rule_add (GtkWidget *widget, RuleEditor *re)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (re->dialog)->vbox), rules, TRUE, TRUE, 0);
g_signal_connect (re->dialog, "response", GTK_SIGNAL_FUNC (add_editor_response), re);
g_object_weak_ref (re->dialog, (GWeakNotify) editor_destroy, re);
g_object_weak_ref ((GObject *)re->dialog, (GWeakNotify) editor_destroy, re);
gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE);
@ -363,7 +363,7 @@ rule_edit (GtkWidget *widget, RuleEditor *re)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (re->dialog)->vbox), rules, TRUE, TRUE, 0);
g_signal_connect (re->dialog, "clicked", GTK_SIGNAL_FUNC (edit_editor_response), re);
g_object_weak_ref (re->dialog, (GWeakNotify) editor_destroy, re);
g_object_weak_ref ((GObject *)re->dialog, (GWeakNotify) editor_destroy, re);
gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE);

View File

@ -139,7 +139,7 @@ xml_decode (FilterRule *fr, xmlNodePtr node, struct _RuleContext *f)
if (result != 0)
return result;
value = node->childs;
value = node->children;
while (value) {
if (!strcmp (value->name, "score")) {
str = xmlGetProp (value, "value");

View File

@ -285,10 +285,10 @@ xml_decode (FilterRule *fr, xmlNodePtr node, struct _RuleContext *f)
if (result != 0)
return result;
set = node->childs;
set = node->children;
while (set) {
if (!strcmp (set->name, "sources")) {
work = set->childs;
work = set->children;
while (work) {
if (!strcmp (work->name, "folder")) {
uri = xmlGetProp (work, "uri");