summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Schwarting <aquarichy@gmail.com>2011-07-23 16:21:27 -0400
committerRichard Schwarting <aquarichy@gmail.com>2011-09-24 02:07:10 -0400
commitb9b88ed72198a2dc9e7438c474ed71556c82f55f (patch)
treebd8706e0fb30706af90afb46c659b2c8a158ee6f
parent0fe1ac0634d72dd899055ae3a8dd78f89d8bc8e0 (diff)
downloadlibgdata-b9b88ed72198a2dc9e7438c474ed71556c82f55f.tar.gz
* youtube
-rw-r--r--gdata/services/calendar/gdata-calendar-event.c2
-rw-r--r--gdata/services/picasaweb/gdata-picasaweb-file.c2
-rw-r--r--gdata/services/youtube/gdata-youtube-category.c18
-rw-r--r--gdata/services/youtube/gdata-youtube-content.c10
-rw-r--r--gdata/services/youtube/gdata-youtube-control.c15
-rw-r--r--gdata/services/youtube/gdata-youtube-credit.c8
-rw-r--r--gdata/services/youtube/gdata-youtube-group.c16
-rw-r--r--gdata/services/youtube/gdata-youtube-service.c79
-rw-r--r--gdata/services/youtube/gdata-youtube-state.c23
-rw-r--r--gdata/services/youtube/gdata-youtube-video.c76
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 5152fa31..4d1a80ca 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 7346b89f..32bb487c 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 f405c8f6..e66a0913 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 94800924..b9df53e4 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 243c4bc6..19976562 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 69e5caa7..d2fa524a 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 e7f26718..6141c12b 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 90a48e3c..0607cb57 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 6df4da5c..9c66e7be 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 f347ddfe..e9db6b07 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);
}