diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2010-03-24 23:35:49 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2010-03-25 00:35:02 +0000 |
commit | 469f55d88d624252641aeb76b6703a208b740c8b (patch) | |
tree | 4d1562471fe095b6612072d17db0ca7ab31a461f /gdata/gdata-access-rule.c | |
parent | 5c64f9db5a20fd4967a8e2190c9a719a1e04360e (diff) | |
download | libgdata-469f55d88d624252641aeb76b6703a208b740c8b.tar.gz |
[core] Add namespace checks to all parse_xml() functions
This should (theoretically, though untested) speed up parsing a little, since
whole chunks of unrelated elements can now be skipped at once in the search
for the right element.
Important: these changes accidentally fix the behaviour of
gdata_entry_get_id() for #GDataPicasaWebAlbum, which was returning incorrect
results before. Any applications which depend on the broken behaviour should
be updated to deal with the correct form IDs (i.e. URIs), or use a new
gdata_picasaweb_album_get_id() function which will be added shortly.
Diffstat (limited to 'gdata/gdata-access-rule.c')
-rw-r--r-- | gdata/gdata-access-rule.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/gdata/gdata-access-rule.c b/gdata/gdata-access-rule.c index 618b30a0..29f6ce35 100644 --- a/gdata/gdata-access-rule.c +++ b/gdata/gdata-access-rule.c @@ -206,40 +206,37 @@ gdata_access_rule_finalize (GObject *object) static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error) { - GDataAccessRule *self; - - g_return_val_if_fail (GDATA_IS_ACCESS_RULE (parsable), FALSE); - g_return_val_if_fail (doc != NULL, FALSE); - g_return_val_if_fail (node != NULL, FALSE); - - self = GDATA_ACCESS_RULE (parsable); - - if (xmlStrcmp (node->name, (xmlChar*) "role") == 0) { - /* gAcl:role */ - xmlChar *role = xmlGetProp (node, (xmlChar*) "value"); - if (role == NULL) - return gdata_parser_error_required_property_missing (node, "value", error); - self->priv->role = (gchar*) role; - } else if (xmlStrcmp (node->name, (xmlChar*) "scope") == 0) { - /* gAcl:scope */ - xmlChar *scope_type, *scope_value; - - scope_type = xmlGetProp (node, (xmlChar*) "type"); - if (scope_type == NULL) - return gdata_parser_error_required_property_missing (node, "type", error); - - scope_value = xmlGetProp (node, (xmlChar*) "value"); - - if (xmlStrcmp (scope_type, (xmlChar*) "default") == 0 && scope_value == NULL) { - xmlFree (scope_type); - return gdata_parser_error_required_property_missing (node, "value", error); + GDataAccessRule *self = GDATA_ACCESS_RULE (parsable); + + if (gdata_parser_is_namespace (node, "http://schemas.google.com/acl/2007") == TRUE) { + if (xmlStrcmp (node->name, (xmlChar*) "role") == 0) { + /* gAcl:role */ + xmlChar *role = xmlGetProp (node, (xmlChar*) "value"); + if (role == NULL) + return gdata_parser_error_required_property_missing (node, "value", error); + self->priv->role = (gchar*) role; + } else if (xmlStrcmp (node->name, (xmlChar*) "scope") == 0) { + /* gAcl:scope */ + xmlChar *scope_type, *scope_value; + + scope_type = xmlGetProp (node, (xmlChar*) "type"); + if (scope_type == NULL) + return gdata_parser_error_required_property_missing (node, "type", error); + + scope_value = xmlGetProp (node, (xmlChar*) "value"); + + if (xmlStrcmp (scope_type, (xmlChar*) "default") == 0 && scope_value == NULL) { + xmlFree (scope_type); + return gdata_parser_error_required_property_missing (node, "value", error); + } + + self->priv->scope_type = (gchar*) scope_type; + self->priv->scope_value = (gchar*) scope_value; + } else { + return GDATA_PARSABLE_CLASS (gdata_access_rule_parent_class)->parse_xml (parsable, doc, node, user_data, error); } - - self->priv->scope_type = (gchar*) scope_type; - self->priv->scope_value = (gchar*) scope_value; - } else if (GDATA_PARSABLE_CLASS (gdata_access_rule_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) { - /* Error! */ - return FALSE; + } else { + return GDATA_PARSABLE_CLASS (gdata_access_rule_parent_class)->parse_xml (parsable, doc, node, user_data, error); } return TRUE; |