[libgdata/gxml] * gdata-{app-categories, exif-tags, media-{category, content, credit, group, thumbnail}}
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/gxml] * gdata-{app-categories, exif-tags, media-{category, content, credit, group, thumbnail}}
- Date: Sat, 24 Sep 2011 06:22:19 +0000 (UTC)
commit 8f526c927b47507b4a23de176e17f1b3726ac9c8
Author: Richard Schwarting <aquarichy gmail com>
Date: Fri Jul 22 19:47:56 2011 -0400
* gdata-{app-categories,exif-tags,media-{category,content,credit,group,thumbnail}}
gdata/app/gdata-app-categories.c | 21 ++++---
gdata/exif/gdata-exif-tags.c | 66 ++++++++++----------
gdata/media/gdata-media-category.c | 33 +++++-----
gdata/media/gdata-media-content.c | 71 +++++++++++-----------
gdata/media/gdata-media-credit.c | 27 ++++----
gdata/media/gdata-media-group.c | 114 ++++++++++++-----------------------
gdata/media/gdata-media-thumbnail.c | 37 ++++++------
7 files changed, 170 insertions(+), 199 deletions(-)
---
diff --git a/gdata/app/gdata-app-categories.c b/gdata/app/gdata-app-categories.c
index 44a2409..79b30ba 100644
--- a/gdata/app/gdata-app-categories.c
+++ b/gdata/app/gdata-app-categories.c
@@ -31,7 +31,7 @@
#include <config.h>
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include "gdata-app-categories.h"
#include "atom/gdata-category.h"
@@ -41,8 +41,8 @@
static void gdata_app_categories_dispose (GObject *object);
static void gdata_app_categories_finalize (GObject *object);
static void gdata_app_categories_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
-static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
+static gboolean pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
+static gboolean parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error);
static gboolean post_parse_xml (GDataParsable *parsable, gpointer user_data, GError **error);
struct _GDataAPPCategoriesPrivate {
@@ -140,18 +140,19 @@ gdata_app_categories_get_property (GObject *object, guint property_id, GValue *v
}
static gboolean
-pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
+pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error)
{
GDataAPPCategoriesPrivate *priv = GDATA_APP_CATEGORIES (parsable)->priv;
- xmlChar *fixed;
+ gchar *fixed;
+ GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
/* Extract fixed and scheme */
- priv->scheme = (gchar*) xmlGetProp (root_node, (xmlChar*) "scheme");
+ priv->scheme = gxml_dom_element_get_attribute (root_elem, "scheme");
- fixed = xmlGetProp (root_node, (xmlChar*) "fixed");
- if (xmlStrcmp (fixed, (xmlChar*) "yes") == 0)
+ fixed = gxml_dom_element_get_attribute (root_elem, "fixed");
+ if (g_strcmp0 (fixed, "yes") == 0)
priv->fixed = TRUE;
- xmlFree (fixed);
+ g_free (fixed);
return TRUE;
}
@@ -170,7 +171,7 @@ _gdata_app_categories_add_category (GDataAPPCategories *self, GDataCategory *cat
}
static gboolean
-parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
+parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error)
{
gboolean success;
diff --git a/gdata/exif/gdata-exif-tags.c b/gdata/exif/gdata-exif-tags.c
index cd7bf45..f4cd440 100644
--- a/gdata/exif/gdata-exif-tags.c
+++ b/gdata/exif/gdata-exif-tags.c
@@ -40,7 +40,7 @@
*/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include <string.h>
#include "gdata-exif-tags.h"
@@ -49,7 +49,7 @@
#include "gdata-private.h"
static void gdata_exif_tags_finalize (GObject *object);
-static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
+static gboolean parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error);
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
struct _GDataExifTagsPrivate {
@@ -104,58 +104,60 @@ gdata_exif_tags_finalize (GObject *object)
}
static gboolean
-parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
+parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error)
{
gboolean success;
GDataExifTags *self = GDATA_EXIF_TAGS (parsable);
+ GXmlDomElement *elem = GXML_DOM_ELEMENT (node);
+ const gchar *node_name = gxml_dom_xnode_get_node_name (node);
if (gdata_parser_is_namespace (node, "http://schemas.google.com/photos/exif/2007") == FALSE)
return GDATA_PARSABLE_CLASS (gdata_exif_tags_parent_class)->parse_xml (parsable, doc, node, user_data, error);
- if (xmlStrcmp (node->name, (xmlChar*) "distance") == 0 ) {
+ if (g_strcmp0 (node_name, "distance") == 0 ) {
/* exif:distance */
- xmlChar *distance = xmlNodeListGetString (doc, node->children, TRUE);
- self->priv->distance = g_ascii_strtod ((gchar*) distance, NULL);
- xmlFree (distance);
- } else if (xmlStrcmp (node->name, (xmlChar*) "fstop") == 0) {
+ gchar *distance = gxml_dom_element_content_to_string (elem);
+ self->priv->distance = g_ascii_strtod (distance, NULL);
+ g_free (distance);
+ } else if (g_strcmp0 (node_name, "fstop") == 0) {
/* exif:fstop */
- xmlChar *fstop = xmlNodeListGetString (doc, node->children, TRUE);
- self->priv->fstop = g_ascii_strtod ((gchar*) fstop, NULL);
- xmlFree (fstop);
+ gchar *fstop = gxml_dom_element_content_to_string (elem);
+ self->priv->fstop = g_ascii_strtod (fstop, NULL);
+ g_free (fstop);
} else if (gdata_parser_string_from_element (node, "make", P_NONE, &(self->priv->make), &success, error) == TRUE ||
gdata_parser_string_from_element (node, "model", P_NONE, &(self->priv->model), &success, error) == TRUE ||
gdata_parser_string_from_element (node, "imageUniqueID", P_NONE, &(self->priv->image_unique_id), &success, error) == TRUE) {
return success;
- } else if (xmlStrcmp (node->name, (xmlChar*) "exposure") == 0) {
+ } else if (g_strcmp0 (node_name, "exposure") == 0) {
/* exif:exposure */
- xmlChar *exposure = xmlNodeListGetString (doc, node->children, TRUE);
- self->priv->exposure = g_ascii_strtod ((gchar*) exposure, NULL);
- xmlFree (exposure);
- } else if (xmlStrcmp (node->name, (xmlChar*) "flash") == 0) {
+ gchar *exposure = gxml_dom_element_content_to_string (elem);
+ self->priv->exposure = g_ascii_strtod (exposure, NULL);
+ g_free (exposure);
+ } else if (g_strcmp0 (node_name, "flash") == 0) {
/* exif:flash */
- xmlChar *flash = xmlNodeListGetString (doc, node->children, TRUE);
+ gchar *flash = gxml_dom_element_content_to_string (elem);
if (flash == NULL)
return gdata_parser_error_required_content_missing (node, error);
- self->priv->flash = (xmlStrcmp (flash, (xmlChar*) "true") == 0 ? TRUE : FALSE);
- xmlFree (flash);
- } else if (xmlStrcmp (node->name, (xmlChar*) "focallength") == 0) {
+ self->priv->flash = (g_strcmp0 (flash, "true") == 0 ? TRUE : FALSE);
+ g_free (flash);
+ } else if (g_strcmp0 (node_name, "focallength") == 0) {
/* exif:focal-length */
- xmlChar *focal_length = xmlNodeListGetString (doc, node->children, TRUE);
- self->priv->focal_length = g_ascii_strtod ((gchar*) focal_length, NULL);
- xmlFree (focal_length);
- } else if (xmlStrcmp (node->name, (xmlChar*) "iso") == 0) {
+ gchar *focal_length = gxml_dom_element_content_to_string (elem);
+ self->priv->focal_length = g_ascii_strtod (focal_length, NULL);
+ g_free (focal_length);
+ } else if (g_strcmp0 (node_name, "iso") == 0) {
/* exif:iso */
- xmlChar *iso = xmlNodeListGetString (doc, node->children, TRUE);
- self->priv->iso = strtol ((gchar*) iso, NULL, 10);
- xmlFree (iso);
- } else if (xmlStrcmp (node->name, (xmlChar*) "time") == 0) {
+ gchar *iso = gxml_dom_element_content_to_string (elem);
+ self->priv->iso = strtol (iso, NULL, 10);
+ g_free (iso);
+ } else if (g_strcmp0 (node_name, "time") == 0) {
/* exif:time */
- xmlChar *time_str;
+ gchar *time_str;
guint64 milliseconds;
- time_str = xmlNodeListGetString (doc, node->children, TRUE);
- milliseconds = g_ascii_strtoull ((gchar*) time_str, NULL, 10);
- xmlFree (time_str);
+ time_str = gxml_dom_element_content_to_string (elem);
+ milliseconds = g_ascii_strtoull (time_str, NULL, 10);
+ g_free (time_str);
self->priv->_time = (gint64) milliseconds;
} else {
diff --git a/gdata/media/gdata-media-category.c b/gdata/media/gdata-media-category.c
index 8f7fa41..3e17f5c 100644
--- a/gdata/media/gdata-media-category.c
+++ b/gdata/media/gdata-media-category.c
@@ -30,7 +30,7 @@
**/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include "gdata-media-category.h"
#include "gdata-parsable.h"
@@ -40,8 +40,8 @@
static void gdata_media_category_finalize (GObject *object);
static void gdata_media_category_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gdata_media_category_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
-static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
+static gboolean pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
+static gboolean parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error);
static void pre_get_xml (GDataParsable *parsable, GString *xml_string);
static void get_xml (GDataParsable *parsable, GString *xml_string);
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
@@ -190,39 +190,40 @@ gdata_media_category_set_property (GObject *object, guint property_id, const GVa
}
static gboolean
-pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
+pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error)
{
GDataMediaCategoryPrivate *priv = GDATA_MEDIA_CATEGORY (parsable)->priv;
- xmlChar *category, *scheme;
+ gchar *category, *scheme;
+ GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
- category = xmlNodeListGetString (doc, root_node->children, TRUE);
+ category = gxml_dom_element_content_to_string (root_elem);
if (category == NULL || *category == '\0') {
- xmlFree (category);
+ g_free (category);
return gdata_parser_error_required_content_missing (root_node, error);
}
- scheme = xmlGetProp (root_node, (xmlChar*) "scheme");
+ scheme = gxml_dom_element_get_attribute (root_elem, "scheme");
if (scheme != NULL && *scheme == '\0') {
- xmlFree (scheme);
- xmlFree (category);
+ g_free (scheme);
+ g_free (category);
return gdata_parser_error_required_property_missing (root_node, "scheme", error);
} else if (scheme == NULL) {
/* Default */
- scheme = xmlStrdup ((xmlChar*) "http://video.search.yahoo.com/mrss/category_schema");
+ scheme = g_strdup ("http://video.search.yahoo.com/mrss/category_schema");
}
- priv->category = (gchar*) category;
- priv->scheme = (gchar*) scheme;
- priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
+ priv->category = category;
+ priv->scheme = scheme;
+ priv->label = gxml_dom_element_get_attribute (root_elem, "label");
return TRUE;
}
static gboolean
-parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
+parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error)
{
/* Textual content's handled in pre_parse_xml */
- if (node->type != XML_ELEMENT_NODE)
+ if (gxml_dom_xnode_get_node_type (node) != GXML_DOM_NODE_TYPE_ELEMENT)
return TRUE;
return GDATA_PARSABLE_CLASS (gdata_media_category_parent_class)->parse_xml (parsable, doc, node, user_data, error);
diff --git a/gdata/media/gdata-media-content.c b/gdata/media/gdata-media-content.c
index 4dd936c..719925b 100644
--- a/gdata/media/gdata-media-content.c
+++ b/gdata/media/gdata-media-content.c
@@ -32,7 +32,7 @@
**/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include "gdata-media-content.h"
#include "gdata-download-stream.h"
@@ -43,7 +43,7 @@
static void gdata_media_content_finalize (GObject *object);
static void gdata_media_content_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
+static gboolean pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
struct _GDataMediaContentPrivate {
@@ -285,86 +285,87 @@ gdata_media_content_get_property (GObject *object, guint property_id, GValue *va
}
static gboolean
-pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
+pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error)
{
GDataMediaContentPrivate *priv = GDATA_MEDIA_CONTENT (parsable)->priv;
- xmlChar *uri, *expression, *medium, *duration, *filesize, *height, *width;
+ gchar *uri, *expression, *medium, *duration, *filesize, *height, *width;
gboolean is_default_bool;
GDataMediaExpression expression_enum;
GDataMediaMedium medium_enum;
guint height_uint, width_uint;
gint64 duration_int64;
gulong filesize_ulong;
+ GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
/* Parse isDefault */
if (gdata_parser_boolean_from_property (root_node, "isDefault", &is_default_bool, 0, error) == FALSE)
return FALSE;
/* Parse expression */
- expression = xmlGetProp (root_node, (xmlChar*) "expression");
- if (expression == NULL || xmlStrcmp (expression, (xmlChar*) "full") == 0) {
+ expression = gxml_dom_element_get_attribute (root_elem, "expression");
+ if (expression == NULL || g_strcmp0 (expression, "full") == 0) {
expression_enum = GDATA_MEDIA_EXPRESSION_FULL;
- } else if (xmlStrcmp (expression, (xmlChar*) "sample") == 0) {
+ } else if (g_strcmp0 (expression, "sample") == 0) {
expression_enum = GDATA_MEDIA_EXPRESSION_SAMPLE;
- } else if (xmlStrcmp (expression, (xmlChar*) "nonstop") == 0) {
+ } else if (g_strcmp0 (expression, "nonstop") == 0) {
expression_enum = GDATA_MEDIA_EXPRESSION_NONSTOP;
} else {
gdata_parser_error_unknown_property_value (root_node, "expression", (gchar*) expression, error);
- xmlFree (expression);
+ g_free (expression);
return FALSE;
}
- xmlFree (expression);
+ g_free (expression);
/* Parse medium */
- medium = xmlGetProp (root_node, (xmlChar*) "medium");
+ medium = gxml_dom_element_get_attribute (root_elem, "medium");
if (medium == NULL) {
medium_enum = GDATA_MEDIA_UNKNOWN;
- } else if (xmlStrcmp (medium, (xmlChar*) "image") == 0) {
+ } else if (g_strcmp0 (medium, "image") == 0) {
medium_enum = GDATA_MEDIA_IMAGE;
- } else if (xmlStrcmp (medium, (xmlChar*) "audio") == 0) {
+ } else if (g_strcmp0 (medium, "audio") == 0) {
medium_enum = GDATA_MEDIA_AUDIO;
- } else if (xmlStrcmp (medium, (xmlChar*) "video") == 0) {
+ } else if (g_strcmp0 (medium, "video") == 0) {
medium_enum = GDATA_MEDIA_VIDEO;
- } else if (xmlStrcmp (medium, (xmlChar*) "document") == 0) {
+ } else if (g_strcmp0 (medium, "document") == 0) {
medium_enum = GDATA_MEDIA_DOCUMENT;
- } else if (xmlStrcmp (medium, (xmlChar*) "executable") == 0) {
+ } else if (g_strcmp0 (medium, "executable") == 0) {
medium_enum = GDATA_MEDIA_EXECUTABLE;
} else {
- gdata_parser_error_unknown_property_value (root_node, "medium", (gchar*) medium, error);
- xmlFree (medium);
+ gdata_parser_error_unknown_property_value (root_node, "medium", medium, error);
+ g_free (medium);
return FALSE;
}
- xmlFree (medium);
+ g_free (medium);
/* Parse duration */
- duration = xmlGetProp (root_node, (xmlChar*) "duration");
- duration_int64 = (duration == NULL) ? 0 : strtol ((gchar*) duration, NULL, 10);
- xmlFree (duration);
+ duration = gxml_dom_element_get_attribute (root_elem, "duration");
+ duration_int64 = (duration == NULL) ? 0 : strtol (duration, NULL, 10);
+ g_free (duration);
/* Parse filesize */
- filesize = xmlGetProp (root_node, (xmlChar*) "fileSize");
- filesize_ulong = (filesize == NULL) ? 0 : strtoul ((gchar*) filesize, NULL, 10);
- xmlFree (filesize);
+ filesize = gxml_dom_element_get_attribute (root_elem, "fileSize");
+ filesize_ulong = (filesize == NULL) ? 0 : strtoul (filesize, NULL, 10);
+ g_free (filesize);
/* Parse height and width */
- height = xmlGetProp (root_node, (xmlChar*) "height");
- height_uint = (height == NULL) ? 0 : strtoul ((gchar*) height, NULL, 10);
- xmlFree (height);
+ height = gxml_dom_element_get_attribute (root_elem, "height");
+ height_uint = (height == NULL) ? 0 : strtoul (height, NULL, 10);
+ g_free (height);
- width = xmlGetProp (root_node, (xmlChar*) "width");
- width_uint = (width == NULL) ? 0 : strtoul ((gchar*) width, NULL, 10);
- xmlFree (width);
+ width = gxml_dom_element_get_attribute (root_elem, "width");
+ width_uint = (width == NULL) ? 0 : strtoul (width, NULL, 10);
+ g_free (width);
/* Other properties */
- uri = xmlGetProp (root_node, (xmlChar*) "url");
+ uri = gxml_dom_element_get_attribute (root_elem, "url");
if (uri != NULL && *uri == '\0') {
- xmlFree (uri);
+ g_free (uri);
return gdata_parser_error_required_property_missing (root_node, "url", error);
}
- priv->uri = (gchar*) uri;
+ priv->uri = uri;
priv->filesize = filesize_ulong;
- priv->content_type = (gchar*) xmlGetProp (root_node, (xmlChar*) "type");
+ priv->content_type = gxml_dom_element_get_attribute (root_elem, "type");
priv->medium = medium_enum;
priv->is_default = is_default_bool;
priv->expression = expression_enum;
diff --git a/gdata/media/gdata-media-credit.c b/gdata/media/gdata-media-credit.c
index 92a9661..548d409 100644
--- a/gdata/media/gdata-media-credit.c
+++ b/gdata/media/gdata-media-credit.c
@@ -32,7 +32,7 @@
**/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include "gdata-media-credit.h"
#include "gdata-parsable.h"
@@ -41,8 +41,8 @@
static void gdata_media_credit_finalize (GObject *object);
static void gdata_media_credit_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
-static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
+static gboolean pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
+static gboolean parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error);
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
struct _GDataMediaCreditPrivate {
@@ -164,32 +164,33 @@ gdata_media_credit_get_property (GObject *object, guint property_id, GValue *val
}
static gboolean
-pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
+pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error)
{
GDataMediaCreditPrivate *priv = GDATA_MEDIA_CREDIT (parsable)->priv;
- xmlChar *credit;
+ gchar *credit;
gchar *scheme;
guint i;
+ GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
- credit = xmlNodeListGetString (doc, root_node->children, TRUE);
+ credit = gxml_dom_element_content_to_string (root_elem);
if (credit == NULL || *credit == '\0') {
- xmlFree (credit);
+ g_free (credit);
return gdata_parser_error_required_content_missing (root_node, error);
}
- scheme = (gchar*) xmlGetProp (root_node, (xmlChar*) "scheme");
+ scheme = gxml_dom_element_get_attribute (root_elem, "scheme");
if (scheme != NULL && *scheme == '\0') {
g_free (scheme);
- xmlFree (credit);
+ g_free (credit);
return gdata_parser_error_required_property_missing (root_node, "scheme", error);
} else if (scheme == NULL) {
/* Default */
scheme = g_strdup ("urn:ebu");
}
- priv->credit = (gchar*) credit;
+ priv->credit = credit;
priv->scheme = scheme;
- priv->role = (gchar*) xmlGetProp (root_node, (xmlChar*) "role");
+ priv->role = gxml_dom_element_get_attribute (root_elem, "role");
/* Convert the role to lower case */
if (priv->role != NULL) {
@@ -201,10 +202,10 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
}
static gboolean
-parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
+parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error)
{
/* Textual content's handled in pre_parse_xml */
- if (node->type != XML_ELEMENT_NODE)
+ if (gxml_dom_xnode_get_node_type (node) != GXML_DOM_NODE_TYPE_ELEMENT)
return TRUE;
return GDATA_PARSABLE_CLASS (gdata_media_credit_parent_class)->parse_xml (parsable, doc, node, user_data, error);
diff --git a/gdata/media/gdata-media-group.c b/gdata/media/gdata-media-group.c
index 21b9e33..ad77bc8 100644
--- a/gdata/media/gdata-media-group.c
+++ b/gdata/media/gdata-media-group.c
@@ -34,7 +34,7 @@
*/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include <string.h>
#include "gdata-media-group.h"
@@ -47,7 +47,7 @@
static void gdata_media_group_dispose (GObject *object);
static void gdata_media_group_finalize (GObject *object);
-static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
+static gboolean parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error);
static void get_xml (GDataParsable *parsable, GString *xml_string);
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
@@ -141,10 +141,12 @@ gdata_media_group_finalize (GObject *object)
}
static gboolean
-parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
+parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error)
{
gboolean success;
GDataMediaGroup *self = GDATA_MEDIA_GROUP (parsable);
+ const gchar *node_name = gxml_dom_xnode_get_node_name (node);
+ GXmlDomElement *elem = GXML_DOM_ELEMENT (node);
if (gdata_parser_is_namespace (node, "http://search.yahoo.com/mrss/") == TRUE) {
if (gdata_parser_string_from_element (node, "title", P_NONE, &(self->priv->title), &success, error) == TRUE ||
@@ -158,10 +160,10 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
gdata_parser_object_from_element (node, "credit", P_REQUIRED | P_NO_DUPES, GDATA_TYPE_MEDIA_CREDIT,
&(self->priv->credit), &success, error) == TRUE) {
return success;
- } else if (xmlStrcmp (node->name, (xmlChar*) "keywords") == 0) {
+ } else if (g_strcmp0 (node_name, "keywords") == 0) {
/* media:keywords */
guint i;
- xmlChar *text = xmlNodeListGetString (node->doc, node->children, TRUE);
+ gchar *text = gxml_dom_element_content_to_string (elem);
g_strfreev (self->priv->keywords);
if (text == NULL) {
@@ -169,8 +171,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
return TRUE;
}
- self->priv->keywords = g_strsplit ((gchar*) text, ",", -1);
- xmlFree (text);
+ self->priv->keywords = g_strsplit (text, ",", -1);
+ g_free (text);
for (i = 0; self->priv->keywords[i] != NULL; i++) {
gchar *comma, *start = self->priv->keywords[i];
@@ -193,57 +195,23 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
*end = '\0';
}
}
- } else if (xmlStrcmp (node->name, (xmlChar*) "player") == 0) {
+ } else if (g_strcmp0 (node_name, "player") == 0) {
/* media:player */
- xmlChar *player_uri = xmlGetProp (node, (xmlChar*) "url");
+ gchar *player_uri = gxml_dom_element_get_attribute (elem, "url");
g_free (self->priv->player_uri);
- self->priv->player_uri = (gchar*) player_uri;
- } else if (xmlStrcmp (node->name, (xmlChar*) "rating") == 0) {
+ self->priv->player_uri = player_uri;
+ } else if (g_strcmp0 (node_name, "rating") == 0) {
/* media:rating */
- xmlChar *scheme;
-
- /* The possible schemes are defined here:
- * â http://video.search.yahoo.com/mrss
- * â http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media:rating
- */
- scheme = xmlGetProp (node, (xmlChar*) "scheme");
-
- if (scheme == NULL || xmlStrcmp (scheme, (xmlChar*) "urn:simple") == 0) {
- /* Options: adult, nonadult */
- gdata_parser_string_from_element (node, "rating", P_REQUIRED | P_NON_EMPTY, &(self->priv->simple_rating),
- &success, error);
- } else if (xmlStrcmp (scheme, (xmlChar*) "urn:mpaa") == 0) {
- /* Options: g, pg, pg-13, r, nc-17 */
- gdata_parser_string_from_element (node, "rating", P_REQUIRED | P_NON_EMPTY, &(self->priv->mpaa_rating),
- &success, error);
- } else if (xmlStrcmp (scheme, (xmlChar*) "urn:v-chip") == 0) {
- /* Options: tv-y, tv-y7, tv-y7-fv, tv-g, tv-pg, tv-14, tv-ma */
- gdata_parser_string_from_element (node, "rating", P_REQUIRED | P_NON_EMPTY, &(self->priv->v_chip_rating),
- &success, error);
- } else if (xmlStrcmp (scheme, (xmlChar*) "http://gdata.youtube.com/schemas/2007#mediarating") == 0) {
- /* No content, but we do get a list of countries. There's nothing like overloading the semantics of XML elements
- * to brighten up one's day. */
- xmlChar *countries;
-
- countries = xmlGetProp (node, (xmlChar*) "country");
-
- if (countries != NULL) {
- gchar **country_list, **country;
-
- /* It's either a comma-separated list of countries, or the value "all" */
- country_list = g_strsplit ((const gchar*) countries, ",", -1);
- xmlFree (countries);
-
- /* Add all the listed countries to the restricted countries table */
- for (country = country_list; *country != NULL; country++) {
- g_hash_table_insert (self->priv->restricted_countries, *country, GUINT_TO_POINTER (TRUE));
- }
-
- g_free (country_list);
- } else {
- /* Assume it's restricted in all countries */
- g_hash_table_insert (self->priv->restricted_countries, g_strdup ("all"), GUINT_TO_POINTER (TRUE));
- }
+ gchar *countries;
+
+ countries = gxml_dom_element_get_attribute (elem, "country");
+
+ if (countries != NULL) {
+ gchar **country_list, **country;
+
+ /* It's either a comma-separated list of countries, or the value "all" */
+ country_list = g_strsplit (countries, ",", -1);
+ g_free (countries);
success = TRUE;
} else {
@@ -251,40 +219,36 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
gdata_parser_error_unknown_property_value (node, "scheme", (gchar*) scheme, error);
success = FALSE;
}
-
- xmlFree (scheme);
-
- return success;
- } else if (xmlStrcmp (node->name, (xmlChar*) "restriction") == 0) {
+ } else if (g_strcmp0 (node_name, "restriction") == 0) {
/* media:restriction */
- xmlChar *type, *countries, *relationship;
+ gchar *type, *countries, *relationship;
gchar **country_list, **country;
gboolean relationship_bool;
/* Check the type property is "country" */
- type = xmlGetProp (node, (xmlChar*) "type");
- if (xmlStrcmp (type, (xmlChar*) "country") != 0) {
- gdata_parser_error_unknown_property_value (node, "type", (gchar*) type, error);
- xmlFree (type);
+ type = gxml_dom_element_get_attribute (elem, "type");
+ if (g_strcmp0 (type, "country") != 0) {
+ gdata_parser_error_unknown_property_value (node, "type", type, error);
+ g_free (type);
return FALSE;
}
- xmlFree (type);
+ g_free (type);
- relationship = xmlGetProp (node, (xmlChar*) "relationship");
- if (xmlStrcmp (relationship, (xmlChar*) "allow") == 0) {
+ relationship = gxml_dom_element_get_attribute (elem, "relationship");
+ if (g_strcmp0 (relationship, "allow") == 0) {
relationship_bool = FALSE; /* it's *not* a restricted country */
- } else if (xmlStrcmp (relationship, (xmlChar*) "deny") == 0) {
+ } else if (g_strcmp0 (relationship, "deny") == 0) {
relationship_bool = TRUE; /* it *is* a restricted country */
} else {
- gdata_parser_error_unknown_property_value (node, "relationship", (gchar*) relationship, error);
- xmlFree (relationship);
+ gdata_parser_error_unknown_property_value (node, "relationship", relationship, error);
+ g_free (relationship);
return FALSE;
}
- xmlFree (relationship);
+ g_free (relationship);
- countries = xmlNodeListGetString (doc, node->children, TRUE);
- country_list = g_strsplit ((const gchar*) countries, " ", -1);
- xmlFree (countries);
+ countries = gxml_dom_element_content_to_string (elem);
+ country_list = g_strsplit (countries, " ", -1);
+ g_free (countries);
/* Add "all" to the table, since it's an exception table */
g_hash_table_insert (self->priv->restricted_countries, g_strdup ("all"), GUINT_TO_POINTER (!relationship_bool));
diff --git a/gdata/media/gdata-media-thumbnail.c b/gdata/media/gdata-media-thumbnail.c
index 4008d9e..0956432 100644
--- a/gdata/media/gdata-media-thumbnail.c
+++ b/gdata/media/gdata-media-thumbnail.c
@@ -30,7 +30,7 @@
**/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include <string.h>
#include "gdata-media-thumbnail.h"
@@ -41,7 +41,7 @@
static void gdata_media_thumbnail_finalize (GObject *object);
static void gdata_media_thumbnail_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
+static gboolean pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
struct _GDataMediaThumbnailPrivate {
@@ -242,44 +242,45 @@ build_time (gint64 _time)
}*/
static gboolean
-pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
+pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error)
{
GDataMediaThumbnailPrivate *priv = GDATA_MEDIA_THUMBNAIL (parsable)->priv;
- xmlChar *uri, *width, *height, *_time;
+ gchar *uri, *width, *height, *_time;
guint width_uint, height_uint;
gint64 time_int64;
+ GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
/* Get the width and height */
- width = xmlGetProp (root_node, (xmlChar*) "width");
- width_uint = (width == NULL) ? 0 : strtoul ((gchar*) width, NULL, 10);
- xmlFree (width);
+ width = gxml_dom_element_get_attribute (root_elem, "width");
+ width_uint = (width == NULL) ? 0 : strtoul (width, NULL, 10);
+ g_free (width);
- height = xmlGetProp (root_node, (xmlChar*) "height");
- height_uint = (height == NULL) ? 0 : strtoul ((gchar*) height, NULL, 10);
- xmlFree (height);
+ height = gxml_dom_element_get_attribute (root_elem, "height");
+ height_uint = (height == NULL) ? 0 : strtoul (height, NULL, 10);
+ g_free (height);
/* Get and parse the time */
- _time = xmlGetProp (root_node, (xmlChar*) "time");
+ _time = gxml_dom_element_get_attribute (root_elem, "time");
if (_time == NULL) {
time_int64 = -1;
} else {
- time_int64 = parse_time ((gchar*) _time);
+ time_int64 = parse_time (_time);
if (time_int64 == -1) {
- gdata_parser_error_unknown_property_value (root_node, "time", (gchar*) _time, error);
- xmlFree (_time);
+ gdata_parser_error_unknown_property_value (root_node, "time", _time, error);
+ g_free (_time);
return FALSE;
}
- xmlFree (_time);
+ g_free (_time);
}
/* Get the URI */
- uri = xmlGetProp (root_node, (xmlChar*) "url");
+ uri = gxml_dom_element_get_attribute (root_elem, "url");
if (uri == NULL || *uri == '\0') {
- xmlFree (uri);
+ g_free (uri);
return gdata_parser_error_required_property_missing (root_node, "url", error);
}
- priv->uri = (gchar*) uri;
+ priv->uri = uri;
priv->height = height_uint;
priv->width = width_uint;
priv->time = time_int64;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]