[libgdata/gxml] * youtube



commit b9b88ed72198a2dc9e7438c474ed71556c82f55f
Author: Richard Schwarting <aquarichy gmail com>
Date:   Sat Jul 23 16:21:27 2011 -0400

    * youtube

 gdata/services/calendar/gdata-calendar-event.c  |    2 +-
 gdata/services/picasaweb/gdata-picasaweb-file.c |    2 +-
 gdata/services/youtube/gdata-youtube-category.c |   18 +++--
 gdata/services/youtube/gdata-youtube-content.c  |   10 ++--
 gdata/services/youtube/gdata-youtube-control.c  |   15 ++--
 gdata/services/youtube/gdata-youtube-credit.c   |    8 +-
 gdata/services/youtube/gdata-youtube-group.c    |   16 +++--
 gdata/services/youtube/gdata-youtube-service.c  |   79 ++++++++++++----------
 gdata/services/youtube/gdata-youtube-state.c    |   23 ++++---
 gdata/services/youtube/gdata-youtube-video.c    |   76 +++++++++++-----------
 10 files changed, 132 insertions(+), 117 deletions(-)
---
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index 5152fa3..4d1a80c 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -84,7 +84,7 @@
 #include <config.h>
 #include <glib.h>
 #include <glib/gi18n-lib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 #include <string.h>
 
 #include "gdata-calendar-event.h"
diff --git a/gdata/services/picasaweb/gdata-picasaweb-file.c b/gdata/services/picasaweb/gdata-picasaweb-file.c
index 7346b89..32bb487 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-file.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-file.c
@@ -95,7 +95,7 @@
 #include <config.h>
 #include <glib.h>
 #include <glib/gi18n-lib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 #include <string.h>
 
 #include "gdata-picasaweb-file.h"
diff --git a/gdata/services/youtube/gdata-youtube-category.c b/gdata/services/youtube/gdata-youtube-category.c
index f405c8f..e66a091 100644
--- a/gdata/services/youtube/gdata-youtube-category.c
+++ b/gdata/services/youtube/gdata-youtube-category.c
@@ -31,7 +31,7 @@
  **/
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 #include <string.h>
 
 #include "gdata-youtube-category.h"
@@ -40,7 +40,7 @@
 
 static void gdata_youtube_category_finalize (GObject *object);
 static void gdata_youtube_category_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-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 _GDataYouTubeCategoryPrivate {
@@ -135,24 +135,26 @@ gdata_youtube_category_get_property (GObject *object, guint property_id, GValue
 }
 
 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)
 {
 	GDataYouTubeCategory *self = GDATA_YOUTUBE_CATEGORY (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://gdata.youtube.com/schemas/2007";) == TRUE) {
-		if (xmlStrcmp (node->name, (xmlChar*) "assignable") == 0) {
+		if (g_strcmp0 (node_name, "assignable") == 0) {
 			/* yt:assignable */
 			self->priv->assignable = TRUE;
-		} else if (xmlStrcmp (node->name, (xmlChar*) "deprecated") == 0) {
+		} else if (g_strcmp0 (node_name, "deprecated") == 0) {
 			/* yt:deprecated */
 			self->priv->assignable = FALSE;
 			g_strfreev (self->priv->browsable_regions);
 			self->priv->browsable_regions = NULL;
-		} else if (xmlStrcmp (node->name, (xmlChar*) "browsable") == 0) {
+		} else if (g_strcmp0 (node_name, "browsable") == 0) {
 			/* yt:browsable */
-			xmlChar *regions;
+			gchar *regions;
 
-			regions = xmlGetProp (node, (xmlChar*) "regions");
+			regions = gxml_dom_element_get_attribute (elem, "regions");
 			if (regions == NULL)
 				return gdata_parser_error_required_property_missing (node, "regions", error);
 
diff --git a/gdata/services/youtube/gdata-youtube-content.c b/gdata/services/youtube/gdata-youtube-content.c
index 9480092..b9df53e 100644
--- a/gdata/services/youtube/gdata-youtube-content.c
+++ b/gdata/services/youtube/gdata-youtube-content.c
@@ -31,7 +31,7 @@
  **/
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 
 #include "gdata-youtube-content.h"
 #include "gdata-parsable.h"
@@ -39,7 +39,7 @@
 #include "gdata-youtube-enums.h"
 
 static void gdata_youtube_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 _GDataYouTubeContentPrivate {
@@ -106,14 +106,14 @@ gdata_youtube_content_get_property (GObject *object, guint property_id, GValue *
 }
 
 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)
 {
-	xmlChar *format;
+	gchar *format;
 
 	/* Chain up to the parent class */
 	GDATA_PARSABLE_CLASS (gdata_youtube_content_parent_class)->pre_parse_xml (parsable, doc, root_node, user_data, error);
 
-	format = xmlGetProp (root_node, (xmlChar*) "format");
+	format = gxml_dom_element_get_attribute (GXML_DOM_ELEMENT (root_node), "format");
 	GDATA_YOUTUBE_CONTENT (parsable)->priv->format = (format == NULL) ? GDATA_YOUTUBE_FORMAT_UNKNOWN : strtoul ((gchar*) format, NULL, 10);
 
 	return TRUE;
diff --git a/gdata/services/youtube/gdata-youtube-control.c b/gdata/services/youtube/gdata-youtube-control.c
index 243c4bc..1997656 100644
--- a/gdata/services/youtube/gdata-youtube-control.c
+++ b/gdata/services/youtube/gdata-youtube-control.c
@@ -36,7 +36,7 @@
  */
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 
 #include "gdata-youtube-control.h"
 #include "gdata-parsable.h"
@@ -45,7 +45,7 @@
 #include "gdata-youtube-state.h"
 
 static void gdata_youtube_control_dispose (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);
 
@@ -93,20 +93,21 @@ gdata_youtube_control_dispose (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;
 	GDataYouTubeControl *self = GDATA_YOUTUBE_CONTROL (parsable);
+	const gchar *node_name = gxml_dom_xnode_get_node_name (node);
 
 	if (gdata_parser_is_namespace (node, "http://www.w3.org/2007/app";) == TRUE &&
-	    xmlStrcmp (node->name, (xmlChar*) "draft") == 0) {
+	    g_strcmp0 (node_name, "draft") == 0) {
 		/* app:draft */
-		xmlChar *draft = xmlNodeListGetString (doc, node, TRUE);
-		if (xmlStrcmp (draft, (xmlChar*) "no") == 0)
+		gchar *draft = gxml_dom_element_get_content (GXML_DOM_ELEMENT (gxml_dom_xnode_get_parent_node (node)));
+		if (g_strcmp0 (draft, "no") == 0)
 			self->priv->is_draft = FALSE;
 		else
 			self->priv->is_draft = TRUE;
-		xmlFree (draft);
+		g_free (draft);
 	} else if (gdata_parser_is_namespace (node, "http://gdata.youtube.com/schemas/2007";) == TRUE &&
 	           gdata_parser_object_from_element (node, "state", P_REQUIRED | P_NO_DUPES, GDATA_TYPE_YOUTUBE_STATE,
 	                                             &(self->priv->state), &success, error) == TRUE) {
diff --git a/gdata/services/youtube/gdata-youtube-credit.c b/gdata/services/youtube/gdata-youtube-credit.c
index 69e5caa..d2fa524 100644
--- a/gdata/services/youtube/gdata-youtube-credit.c
+++ b/gdata/services/youtube/gdata-youtube-credit.c
@@ -31,7 +31,7 @@
  **/
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 
 #include "gdata-youtube-credit.h"
 #include "gdata-parsable.h"
@@ -39,7 +39,7 @@
 
 static void gdata_youtube_credit_finalize (GObject *object);
 static void gdata_youtube_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 pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
 static void pre_get_xml (GDataParsable *parsable, GString *xml_string);
 static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
 
@@ -120,12 +120,12 @@ gdata_youtube_credit_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)
 {
 	/* Chain up to the parent class */
 	GDATA_PARSABLE_CLASS (gdata_youtube_credit_parent_class)->pre_parse_xml (parsable, doc, root_node, user_data, error);
 
-	GDATA_YOUTUBE_CREDIT (parsable)->priv->entity_type = (gchar*) xmlGetProp (root_node, (xmlChar*) "type");
+	GDATA_YOUTUBE_CREDIT (parsable)->priv->entity_type = (gchar*) gxml_dom_element_get_attribute (GXML_DOM_ELEMENT (root_node), "type");
 
 	return TRUE;
 }
diff --git a/gdata/services/youtube/gdata-youtube-group.c b/gdata/services/youtube/gdata-youtube-group.c
index e7f2671..6141c12 100644
--- a/gdata/services/youtube/gdata-youtube-group.c
+++ b/gdata/services/youtube/gdata-youtube-group.c
@@ -29,7 +29,7 @@
  */
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 
 #include "gdata-youtube-group.h"
 #include "gdata-parsable.h"
@@ -40,7 +40,7 @@
 #include "gdata-youtube-credit.h"
 
 static void gdata_youtube_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);
 
@@ -88,10 +88,12 @@ gdata_youtube_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;
 	GDataYouTubeGroup *self = GDATA_YOUTUBE_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 &&
 	    (gdata_parser_object_from_element_setter (node, "content", P_REQUIRED, GDATA_TYPE_YOUTUBE_CONTENT,
@@ -106,15 +108,15 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 		    gdata_parser_int64_from_element (node, "uploaded", P_REQUIRED | P_NO_DUPES,
 		                                     &(self->priv->uploaded), &success, error) == TRUE) {
 			return success;
-		} else if (xmlStrcmp (node->name, (xmlChar*) "duration") == 0) {
+		} else if (g_strcmp0 (node_name, "duration") == 0) {
 			/* yt:duration */
-			xmlChar *duration = xmlGetProp (node, (xmlChar*) "seconds");
+			gchar *duration = gxml_dom_element_get_attribute (elem, "seconds");
 			if (duration == NULL)
 				return gdata_parser_error_required_property_missing (node, "seconds", error);
 
 			self->priv->duration = strtoul ((gchar*) duration, NULL, 10);
-			xmlFree (duration);
-		} else if (xmlStrcmp (node->name, (xmlChar*) "private") == 0) {
+			g_free (duration);
+		} else if (g_strcmp0 (node_name, "private") == 0) {
 			/* yt:private */
 			gdata_youtube_group_set_is_private (self, TRUE);
 		} else {
diff --git a/gdata/services/youtube/gdata-youtube-service.c b/gdata/services/youtube/gdata-youtube-service.c
index 90a48e3..0607cb5 100644
--- a/gdata/services/youtube/gdata-youtube-service.c
+++ b/gdata/services/youtube/gdata-youtube-service.c
@@ -340,8 +340,9 @@ static void
 parse_error_response (GDataService *self, GDataOperationType operation_type, guint status, const gchar *reason_phrase, const gchar *response_body,
                       gint length, GError **error)
 {
-	xmlDoc *doc;
-	xmlNode *node;
+	GXmlDomDocument *doc;
+	GXmlDomXNode *node;
+	const gchar *node_name; 
 
 	if (response_body == NULL)
 		goto parent;
@@ -350,81 +351,87 @@ parse_error_response (GDataService *self, GDataOperationType operation_type, gui
 		length = strlen (response_body);
 
 	/* Parse the XML */
-	doc = xmlReadMemory (response_body, length, "/dev/null", NULL, 0);
+	doc = gxml_dom_document_new_from_string (response_body, NULL); // TODO:GXML: consider passing error and then checking it
+
 	if (doc == NULL)
 		goto parent;
 
 	/* Get the root element */
-	node = xmlDocGetRootElement (doc);
+	node = GXML_DOM_XNODE (gxml_dom_document_get_document_element (doc));
 	if (node == NULL) {
 		/* XML document's empty; chain up to the parent class */
-		xmlFreeDoc (doc);
+		// xmlFreeDoc (doc);
 		goto parent;
 	}
 
-	if (xmlStrcmp (node->name, (xmlChar*) "errors") != 0) {
+	node_name = gxml_dom_xnode_get_node_name (node);
+
+	if (g_strcmp0 (node_name, "errors") != 0) {
 		/* No <errors> element (required); chain up to the parent class */
-		xmlFreeDoc (doc);
+		// xmlFreeDoc (doc); //TODO:GXML: figure out what to do with freeing these, g_object_unref?
 		goto parent;
 	}
 
 	/* Parse the actual errors */
-	node = node->children;
+	node = gxml_dom_xnode_get_first_child (node);
 	while (node != NULL) {
-		xmlChar *domain = NULL, *code = NULL, *location = NULL;
-		xmlNode *child_node = node->children;
+		gchar *domain = NULL, *code = NULL, *location = NULL;
+		GXmlDomXNode *child_node = gxml_dom_xnode_get_first_child (node);
 
-		if (node->type == XML_TEXT_NODE) {
+		if (gxml_dom_xnode_get_node_type (node) == GXML_DOM_NODE_TYPE_TEXT) {
 			/* Skip text nodes; they're all whitespace */
-			node = node->next;
+			node = gxml_dom_xnode_get_next_sibling (node);
 			continue;
 		}
 
 		/* Get the error data */
 		while (child_node != NULL) {
-			if (child_node->type == XML_TEXT_NODE) {
+			if (gxml_dom_xnode_get_node_type (child_node) == GXML_DOM_NODE_TYPE_TEXT) {
 				/* Skip text nodes; they're all whitespace */
-				child_node = child_node->next;
+				child_node = gxml_dom_xnode_get_next_sibling (child_node);
 				continue;
 			}
 
-			if (xmlStrcmp (child_node->name, (xmlChar*) "domain") == 0)
-				domain = xmlNodeListGetString (doc, child_node->children, TRUE);
-			else if (xmlStrcmp (child_node->name, (xmlChar*) "code") == 0)
-				code = xmlNodeListGetString (doc, child_node->children, TRUE);
-			else if (xmlStrcmp (child_node->name, (xmlChar*) "location") == 0)
-				location = xmlNodeListGetString (doc, child_node->children, TRUE);
-			else if (xmlStrcmp (child_node->name, (xmlChar*) "internalReason") != 0) {
+			const gchar *child_node_name = gxml_dom_xnode_get_node_name (child_node);
+			GXmlDomElement *child_elem = GXML_DOM_ELEMENT (child_node);
+
+			if (g_strcmp0 (child_node_name, "domain") == 0)
+				domain = gxml_dom_element_get_content (child_elem);
+			else if (g_strcmp0 (child_node_name, "code") == 0)
+				code = gxml_dom_element_get_content (child_elem);
+			else if (g_strcmp0 (child_node_name, "location") == 0)
+				location = gxml_dom_element_get_content (child_elem);
+			else if (g_strcmp0 (child_node_name, "internalReason") != 0) {
 				/* Unknown element (ignore internalReason) */
-				g_message ("Unhandled <error/%s> element.", child_node->name);
+				g_message ("Unhandled <error/%s> element.", child_node_name);
 
-				xmlFree (domain);
-				xmlFree (code);
-				xmlFree (location);
-				xmlFreeDoc (doc);
+				g_free (domain);
+				g_free (code);
+				g_free (location);
+				//xmlFreeDoc (doc);
 				goto check_error;
 			}
 
-			child_node = child_node->next;
+			child_node = gxml_dom_xnode_get_next_sibling (child_node);
 		}
 
 		/* Create an error message, but only for the first error */
 		if (error == NULL || *error == NULL) {
 			/* See http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Error_responses */
-			if (xmlStrcmp (domain, (xmlChar*) "yt:service") == 0 && xmlStrcmp (code, (xmlChar*) "disabled_in_maintenance_mode") == 0) {
+			if (g_strcmp0 (domain, "yt:service") == 0 && g_strcmp0 (code, "disabled_in_maintenance_mode") == 0) {
 				/* Service disabled */
 				g_set_error (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_UNAVAILABLE,
 				             _("This service is not available at the moment."));
-			} else if (xmlStrcmp (domain, (xmlChar*) "yt:authentication") == 0) {
+			} else if (g_strcmp0 (domain, "yt:authentication") == 0) {
 				/* Authentication problem */
 				g_set_error (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
 				             _("You must be authenticated to do this."));
-			} else if (xmlStrcmp (domain, (xmlChar*) "yt:quota") == 0) {
+			} else if (g_strcmp0 (domain, "yt:quota") == 0) {
 				/* Quota errors */
-				if (xmlStrcmp (code, (xmlChar*) "too_many_recent_calls") == 0) {
+				if (g_strcmp0 (code, "too_many_recent_calls") == 0) {
 					g_set_error (error, GDATA_YOUTUBE_SERVICE_ERROR, GDATA_YOUTUBE_SERVICE_ERROR_API_QUOTA_EXCEEDED,
 					             _("You have made too many API calls recently. Please wait a few minutes and try again."));
-				} else if (xmlStrcmp (code, (xmlChar*) "too_many_entries") == 0) {
+				} else if (g_strcmp0 (code, "too_many_entries") == 0) {
 					g_set_error (error, GDATA_YOUTUBE_SERVICE_ERROR, GDATA_YOUTUBE_SERVICE_ERROR_ENTRY_QUOTA_EXCEEDED,
 					             _("You have exceeded your entry quota. Please delete some entries and try again."));
 				} else {
@@ -447,11 +454,11 @@ parse_error_response (GDataService *self, GDataOperationType operation_type, gui
 			g_debug ("Error message received in response: code \"%s\", domain \"%s\", location \"%s\".", code, domain, location);
 		}
 
-		xmlFree (domain);
-		xmlFree (code);
-		xmlFree (location);
+		g_free (domain);
+		g_free (code);
+		g_free (location);
 
-		node = node->next;
+		node = gxml_dom_xnode_get_next_sibling (node);
 	}
 
 check_error:
diff --git a/gdata/services/youtube/gdata-youtube-state.c b/gdata/services/youtube/gdata-youtube-state.c
index 6df4da5..9c66e7b 100644
--- a/gdata/services/youtube/gdata-youtube-state.c
+++ b/gdata/services/youtube/gdata-youtube-state.c
@@ -30,7 +30,7 @@
  **/
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 
 #include "gdata-youtube-state.h"
 #include "gdata-parsable.h"
@@ -38,8 +38,8 @@
 
 static void gdata_youtube_state_finalize (GObject *object);
 static void gdata_youtube_state_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 _GDataYouTubeStatePrivate {
@@ -187,30 +187,31 @@ gdata_youtube_state_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)
 {
 	GDataYouTubeStatePrivate *priv = GDATA_YOUTUBE_STATE (parsable)->priv;
-	xmlChar *name;
+	gchar *name;
+	GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
 
-	name = xmlGetProp (root_node, (xmlChar*) "name");
+	name = gxml_dom_element_get_attribute (root_elem, "name");
 	if (name == NULL || *name == '\0') {
 		g_free (name);
 		return gdata_parser_error_required_property_missing (root_node, "name", error);
 	}
 
 	priv->name = (gchar*) name;
-	priv->reason_code = (gchar*) xmlGetProp (root_node, (xmlChar*) "reasonCode");
-	priv->help_uri = (gchar*) xmlGetProp (root_node, (xmlChar*) "helpUrl");
-	priv->message = (gchar*) xmlNodeListGetString (doc, root_node->children, TRUE);
+	priv->reason_code = (gchar*) gxml_dom_element_get_attribute (root_elem, "reasonCode");
+	priv->help_uri = (gchar*) gxml_dom_element_get_attribute (root_elem, "helpUrl");
+	priv->message = gxml_dom_element_get_content (root_elem);
 
 	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_youtube_state_parent_class)->parse_xml (parsable, doc, node, user_data, error);
diff --git a/gdata/services/youtube/gdata-youtube-video.c b/gdata/services/youtube/gdata-youtube-video.c
index f347ddf..e9db6b0 100644
--- a/gdata/services/youtube/gdata-youtube-video.c
+++ b/gdata/services/youtube/gdata-youtube-video.c
@@ -69,7 +69,7 @@
 #include <config.h>
 #include <glib.h>
 #include <glib/gi18n-lib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 #include <string.h>
 
 #include "gdata-youtube-video.h"
@@ -93,7 +93,7 @@ static void gdata_youtube_video_dispose (GObject *object);
 static void gdata_youtube_video_finalize (GObject *object);
 static void gdata_youtube_video_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 static void gdata_youtube_video_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-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 gboolean post_parse_xml (GDataParsable *parsable, gpointer user_data, GError **error);
 static void get_xml (GDataParsable *parsable, GString *xml_string);
 static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
@@ -716,10 +716,12 @@ gdata_youtube_video_set_property (GObject *object, guint property_id, const GVal
 }
 
 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;
 	GDataYouTubeVideo *self = GDATA_YOUTUBE_VIDEO (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 &&
 	    gdata_parser_object_from_element (node, "group", P_REQUIRED | P_NO_DUPES, GDATA_TYPE_YOUTUBE_GROUP,
@@ -736,113 +738,113 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	} else if (gdata_parser_is_namespace (node, "http://gdata.youtube.com/schemas/2007";) == TRUE) {
 		if (gdata_parser_string_from_element (node, "location", P_NONE, &(self->priv->location), &success, error) == TRUE) {
 			return success;
-		} else if (xmlStrcmp (node->name, (xmlChar*) "statistics") == 0) {
+		} else if (g_strcmp0 (node_name, "statistics") == 0) {
 			/* yt:statistics */
-			xmlChar *view_count, *favorite_count;
+			gchar *view_count, *favorite_count;
 
 			/* View count */
-			view_count = xmlGetProp (node, (xmlChar*) "viewCount");
+			view_count = gxml_dom_element_get_attribute (elem, "viewCount");
 			if (view_count == NULL)
 				return gdata_parser_error_required_property_missing (node, "viewCount", error);
 			self->priv->view_count = strtoul ((gchar*) view_count, NULL, 10);
-			xmlFree (view_count);
+			g_free (view_count);
 
 			/* Favourite count */
-			favorite_count = xmlGetProp (node, (xmlChar*) "favoriteCount");
+			favorite_count = gxml_dom_element_get_attribute (elem, "favoriteCount");
 			self->priv->favorite_count = (favorite_count != NULL) ? strtoul ((gchar*) favorite_count, NULL, 10) : 0;
-			xmlFree (favorite_count);
-		} else if (xmlStrcmp (node->name, (xmlChar*) "noembed") == 0) {
+			g_free (favorite_count);
+		} else if (g_strcmp0 (node_name, "noembed") == 0) {
 			/* yt:noembed */
 			/* Ignore this now; it's been superceded by yt:accessControl.
 			 * See http://apiblog.youtube.com/2010/02/extended-access-controls-available-via.html */
-		} else if (xmlStrcmp (node->name, (xmlChar*) "accessControl") == 0) {
+		} else if (g_strcmp0 (node_name, "accessControl") == 0) {
 			/* yt:accessControl */
-			xmlChar *action, *permission;
+			gchar *action, *permission;
 			GDataYouTubePermission permission_enum;
 
-			action = xmlGetProp (node, (xmlChar*) "action");
+			action = gxml_dom_element_get_attribute (elem, "action");
 			if (action == NULL)
 				return gdata_parser_error_required_property_missing (node, "action", error);
-			permission = xmlGetProp (node, (xmlChar*) "permission");
+			permission = gxml_dom_element_get_attribute (elem, "permission");
 			if (permission == NULL) {
-				xmlFree (action);
+				g_free (action);
 				return gdata_parser_error_required_property_missing (node, "permission", error);
 			}
 
 			/* Work out what the permission is */
-			if (xmlStrcmp (permission, (xmlChar*) "allowed") == 0) {
+			if (g_strcmp0 (permission, "allowed") == 0) {
 				permission_enum = GDATA_YOUTUBE_PERMISSION_ALLOWED;
-			} else if (xmlStrcmp (permission, (xmlChar*) "denied") == 0) {
+			} else if (g_strcmp0 (permission, "denied") == 0) {
 				permission_enum = GDATA_YOUTUBE_PERMISSION_DENIED;
-			} else if (xmlStrcmp (permission, (xmlChar*) "moderated") == 0) {
+			} else if (g_strcmp0 (permission, "moderated") == 0) {
 				permission_enum = GDATA_YOUTUBE_PERMISSION_MODERATED;
 			} else {
-				xmlFree (action);
-				xmlFree (permission);
+				g_free (action);
+				g_free (permission);
 				return gdata_parser_error_unknown_property_value (node, "permission", (gchar*) permission, error);
 			}
 
 			/* Store the access control */
 			g_hash_table_insert (self->priv->access_controls, (gchar*) action, GINT_TO_POINTER (permission_enum));
-		} else if (xmlStrcmp (node->name, (xmlChar*) "recorded") == 0) {
+		} else if (g_strcmp0 (node_name, "recorded") == 0) {
 			/* yt:recorded */
-			xmlChar *recorded;
+			gchar *recorded;
 			gint64 recorded_int64;
 
-			recorded = xmlNodeListGetString (doc, node->children, TRUE);
+			recorded = gxml_dom_element_get_content (elem);
 			if (gdata_parser_int64_from_date ((gchar*) recorded, &recorded_int64) == FALSE) {
 				/* Error */
 				gdata_parser_error_not_iso8601_format (node, (gchar*) recorded, error);
-				xmlFree (recorded);
+				g_free (recorded);
 				return FALSE;
 			}
-			xmlFree (recorded);
+			g_free (recorded);
 			gdata_youtube_video_set_recorded (self, recorded_int64);
 		} else {
 			return GDATA_PARSABLE_CLASS (gdata_youtube_video_parent_class)->parse_xml (parsable, doc, node, user_data, error);
 		}
 	} else if (gdata_parser_is_namespace (node, "http://schemas.google.com/g/2005";) == TRUE) {
-		if (xmlStrcmp (node->name, (xmlChar*) "rating") == 0) {
+		if (g_strcmp0 (node_name, "rating") == 0) {
 			/* gd:rating */
-			xmlChar *min, *max, *num_raters, *average;
+			gchar *min, *max, *num_raters, *average;
 			guint num_raters_uint;
 			gdouble average_double;
 
-			min = xmlGetProp (node, (xmlChar*) "min");
+			min = gxml_dom_element_get_attribute (elem, "min");
 			if (min == NULL)
 				return gdata_parser_error_required_property_missing (node, "min", error);
 
-			max = xmlGetProp (node, (xmlChar*) "max");
+			max = gxml_dom_element_get_attribute (elem, "max");
 			if (max == NULL) {
 				gdata_parser_error_required_property_missing (node, "max", error);
-				xmlFree (min);
+				g_free (min);
 				return FALSE;
 			}
 
-			num_raters = xmlGetProp (node, (xmlChar*) "numRaters");
+			num_raters = gxml_dom_element_get_attribute (elem, "numRaters");
 			if (num_raters == NULL)
 				num_raters_uint = 0;
 			else
 				num_raters_uint = strtoul ((gchar*) num_raters, NULL, 10);
-			xmlFree (num_raters);
+			g_free (num_raters);
 
-			average = xmlGetProp (node, (xmlChar*) "average");
+			average = gxml_dom_element_get_attribute (elem, "average");
 			if (average == NULL)
 				average_double = 0;
 			else
 				average_double = g_ascii_strtod ((gchar*) average, NULL);
-			xmlFree (average);
+			g_free (average);
 
 			self->priv->rating.min = strtoul ((gchar*) min, NULL, 10);
 			self->priv->rating.max = strtoul ((gchar*) max, NULL, 10);
 			self->priv->rating.count = num_raters_uint;
 			self->priv->rating.average = average_double;
-		} else if (xmlStrcmp (node->name, (xmlChar*) "comments") == 0) {
+		} else if (g_strcmp0 (node_name, "comments") == 0) {
 			/* gd:comments */
-			xmlNode *child_node;
+			GXmlDomXNode *child_node;
 
 			/* This is actually the child of the <comments> element */
-			child_node = node->children;
+			child_node = gxml_dom_xnode_get_first_child (node);
 			if (child_node == NULL) {
 				return gdata_parser_error_required_element_missing ("gd:feedLink", "gd:comments", error);
 			}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]