[libgdata/gxml] * port gdata-gd-{email-address, im-address, name, organization, postal-address}



commit 73571fc7bfc8fa541917b926c23e5a2250461fd7
Author: Richard Schwarting <aquarichy gmail com>
Date:   Fri Jul 22 17:45:02 2011 -0400

    * port gdata-gd-{email-address,im-address,name,organization,postal-address}

 gdata/gd/gdata-gd-email-address.c  |   27 ++++++++++++++-------------
 gdata/gd/gdata-gd-im-address.c     |   27 ++++++++++++++-------------
 gdata/gd/gdata-gd-name.c           |    6 +++---
 gdata/gd/gdata-gd-organization.c   |   21 +++++++++++----------
 gdata/gd/gdata-gd-postal-address.c |   32 +++++++++++++++++---------------
 5 files changed, 59 insertions(+), 54 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-email-address.c b/gdata/gd/gdata-gd-email-address.c
index d1ef2bf..b669115 100644
--- a/gdata/gd/gdata-gd-email-address.c
+++ b/gdata/gd/gdata-gd-email-address.c
@@ -30,7 +30,7 @@
  **/
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 
 #include "gdata-gd-email-address.h"
 #include "gdata-parsable.h"
@@ -41,7 +41,7 @@ static void gdata_gd_email_address_comparable_init (GDataComparableIface *iface)
 static void gdata_gd_email_address_finalize (GObject *object);
 static void gdata_gd_email_address_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 static void gdata_gd_email_address_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 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);
 
@@ -252,34 +252,35 @@ gdata_gd_email_address_set_property (GObject *object, guint property_id, const G
 }
 
 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 *address, *rel;
+	gchar *address, *rel;
 	gboolean primary_bool;
 	GDataGDEmailAddressPrivate *priv = GDATA_GD_EMAIL_ADDRESS (parsable)->priv;
+	GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
 
 	/* Is it the primary e-mail address? */
 	if (gdata_parser_boolean_from_property (root_node, "primary", &primary_bool, 0, error) == FALSE)
 		return FALSE;
 
-	address = xmlGetProp (root_node, (xmlChar*) "address");
+	address = gxml_dom_element_get_attribute (root_elem, "address");
 	if (address == NULL || *address == '\0') {
-		xmlFree (address);
+		g_free (address);
 		return gdata_parser_error_required_property_missing (root_node, "address", error);
 	}
 
-	rel = xmlGetProp (root_node, (xmlChar*) "rel");
+	rel = gxml_dom_element_get_attribute (root_elem, "rel");
 	if (rel != NULL && *rel == '\0') {
-		xmlFree (address);
-		xmlFree (rel);
+		g_free (address);
+		g_free (rel);
 		return gdata_parser_error_required_property_missing (root_node, "rel", error);
 	}
 
-	priv->address = (gchar*) address;
-	priv->relation_type = (gchar*) rel;
-	priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
+	priv->address = address;
+	priv->relation_type = rel;
+	priv->label = gxml_dom_element_get_attribute (root_elem, "label");
 	priv->is_primary = primary_bool;
-	priv->display_name = (gchar*) xmlGetProp (root_node, (xmlChar*) "displayName");
+	priv->display_name = gxml_dom_element_get_attribute (root_elem, "displayName");
 
 	return TRUE;
 }
diff --git a/gdata/gd/gdata-gd-im-address.c b/gdata/gd/gdata-gd-im-address.c
index 3ded135..21d4088 100644
--- a/gdata/gd/gdata-gd-im-address.c
+++ b/gdata/gd/gdata-gd-im-address.c
@@ -30,7 +30,7 @@
  **/
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 
 #include "gdata-gd-im-address.h"
 #include "gdata-parsable.h"
@@ -41,7 +41,7 @@ static void gdata_gd_im_address_comparable_init (GDataComparableIface *iface);
 static void gdata_gd_im_address_finalize (GObject *object);
 static void gdata_gd_im_address_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 static void gdata_gd_im_address_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 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);
 
@@ -256,33 +256,34 @@ gdata_gd_im_address_set_property (GObject *object, guint property_id, const GVal
 }
 
 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 *address, *rel;
+	gchar *address, *rel;
 	gboolean primary_bool;
 	GDataGDIMAddressPrivate *priv = GDATA_GD_IM_ADDRESS (parsable)->priv;
+	GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node); // TODO:GXML: yah, perhaps change *parse_xml functions to take Element instead of XNode
 
 	/* Is it the primary IM address? */
 	if (gdata_parser_boolean_from_property (root_node, "primary", &primary_bool, 0, error) == FALSE)
 		return FALSE;
 
-	address = xmlGetProp (root_node, (xmlChar*) "address");
+	address = gxml_dom_element_get_attribute (root_elem, "address");
 	if (address == NULL || *address == '\0') {
-		xmlFree (address);
+		g_free (address);
 		return gdata_parser_error_required_property_missing (root_node, "address", error);
 	}
 
-	rel = xmlGetProp (root_node, (xmlChar*) "rel");
+	rel = gxml_dom_element_get_attribute (root_elem, "rel");
 	if (rel != NULL && *rel == '\0') {
-		xmlFree (address);
-		xmlFree (rel);
+		g_free (address);
+		g_free (rel);
 		return gdata_parser_error_required_property_missing (root_node, "rel", error);
 	}
 
-	priv->address = (gchar*) address;
-	priv->protocol = (gchar*) xmlGetProp (root_node, (xmlChar*) "protocol");
-	priv->relation_type = (gchar*) rel;
-	priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
+	priv->address = address;
+	priv->protocol = gxml_dom_element_get_attribute (root_elem, "protocol");
+	priv->relation_type = rel;
+	priv->label = gxml_dom_element_get_attribute (root_elem, "label");
 	priv->is_primary = primary_bool;
 
 	return TRUE;
diff --git a/gdata/gd/gdata-gd-name.c b/gdata/gd/gdata-gd-name.c
index 8300f01..3c86f90 100644
--- a/gdata/gd/gdata-gd-name.c
+++ b/gdata/gd/gdata-gd-name.c
@@ -40,7 +40,7 @@
  **/
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 
 #include "gdata-gd-name.h"
 #include "gdata-parsable.h"
@@ -51,7 +51,7 @@ static void gdata_gd_name_comparable_init (GDataComparableIface *iface);
 static void gdata_gd_name_finalize (GObject *object);
 static void gdata_gd_name_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 static void gdata_gd_name_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 void get_xml (GDataParsable *parsable, GString *xml_string);
 static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
 
@@ -294,7 +294,7 @@ gdata_gd_name_set_property (GObject *object, guint property_id, const GValue *va
 }
 
 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;
 	GDataGDNamePrivate *priv = GDATA_GD_NAME (parsable)->priv;
diff --git a/gdata/gd/gdata-gd-organization.c b/gdata/gd/gdata-gd-organization.c
index fe15d25..9634287 100644
--- a/gdata/gd/gdata-gd-organization.c
+++ b/gdata/gd/gdata-gd-organization.c
@@ -30,7 +30,7 @@
  **/
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 
 #include "gdata-gd-organization.h"
 #include "gdata-parsable.h"
@@ -44,8 +44,8 @@ static void gdata_gd_organization_dispose (GObject *object);
 static void gdata_gd_organization_finalize (GObject *object);
 static void gdata_gd_organization_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 static void gdata_gd_organization_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 *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 gboolean 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_xml (GDataParsable *parsable, GString *xml_string);
 static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
@@ -376,31 +376,32 @@ gdata_gd_organization_set_property (GObject *object, guint property_id, const GV
 }
 
 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 *rel;
+	gchar *rel;
 	gboolean primary_bool;
 	GDataGDOrganizationPrivate *priv = GDATA_GD_ORGANIZATION (parsable)->priv;
+	GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
 
 	/* Is it the primary organisation? */
 	if (gdata_parser_boolean_from_property (root_node, "primary", &primary_bool, 0, error) == FALSE)
 		return FALSE;
 
-	rel = xmlGetProp (root_node, (xmlChar*) "rel");
+	rel = gxml_dom_element_get_attribute (root_elem, "rel");
 	if (rel != NULL && *rel == '\0') {
-		xmlFree (rel);
+		g_free (rel);
 		return gdata_parser_error_required_property_missing (root_node, "rel", error);
 	}
 
-	priv->relation_type = (gchar*) rel;
-	priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
+	priv->relation_type = rel;
+	priv->label = gxml_dom_element_get_attribute (root_elem, "label");
 	priv->is_primary = primary_bool;
 
 	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)
 {
 	gboolean success;
 	GDataGDOrganizationPrivate *priv = GDATA_GD_ORGANIZATION (parsable)->priv;
diff --git a/gdata/gd/gdata-gd-postal-address.c b/gdata/gd/gdata-gd-postal-address.c
index 3868976..e663df4 100644
--- a/gdata/gd/gdata-gd-postal-address.c
+++ b/gdata/gd/gdata-gd-postal-address.c
@@ -31,7 +31,7 @@
  **/
 
 #include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
 #include <string.h>
 
 #include "gdata-gd-postal-address.h"
@@ -43,8 +43,8 @@ static void gdata_gd_postal_address_comparable_init (GDataComparableIface *iface
 static void gdata_gd_postal_address_finalize (GObject *object);
 static void gdata_gd_postal_address_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 static void gdata_gd_postal_address_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);
@@ -563,36 +563,38 @@ gdata_gd_postal_address_set_property (GObject *object, guint property_id, const
 }
 
 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 *rel;
+	gchar *rel;
 	gboolean primary_bool;
 	GDataGDPostalAddressPrivate *priv = GDATA_GD_POSTAL_ADDRESS (parsable)->priv;
+	GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
 
 	/* Is it the primary postal address? */
 	if (gdata_parser_boolean_from_property (root_node, "primary", &primary_bool, 0, error) == FALSE)
 		return FALSE;
 
-	rel = xmlGetProp (root_node, (xmlChar*) "rel");
+	rel = gxml_dom_element_get_attribute (root_elem, "rel");
 	if (rel != NULL && *rel == '\0') {
-		xmlFree (rel);
+		g_free (rel);
 		return gdata_parser_error_required_property_missing (root_node, "rel", error);
 	}
 
-	priv->relation_type = (gchar*) rel;
-	priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
-	priv->mail_class = (gchar*) xmlGetProp (root_node, (xmlChar*) "mailClass");
-	priv->usage = (gchar*) xmlGetProp (root_node, (xmlChar*) "usage");
+	priv->relation_type = rel;
+	priv->label = gxml_dom_element_get_attribute (root_elem, "label");
+	priv->mail_class = gxml_dom_element_get_attribute (root_elem, "mailClass");
+	priv->usage = gxml_dom_element_get_attribute (root_elem, "usage");
 	priv->is_primary = primary_bool;
 
 	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)
 {
 	gboolean success;
 	GDataGDPostalAddressPrivate *priv = GDATA_GD_POSTAL_ADDRESS (parsable)->priv;
+	GXmlDomElement *elem = GXML_DOM_ELEMENT (node);
 
 	if (gdata_parser_is_namespace (node, "http://schemas.google.com/g/2005";) == TRUE) {
 		if (gdata_parser_string_from_element (node, "agent", P_NO_DUPES, &(priv->agent), &success, error) == TRUE ||
@@ -606,10 +608,10 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 		    gdata_parser_string_from_element (node, "postcode", P_NO_DUPES, &(priv->postcode), &success, error) == TRUE ||
 		    gdata_parser_string_from_element (node, "formattedAddress", P_NO_DUPES, &(priv->formatted_address), &success, error) == TRUE) {
 			return success;
-		} else if (xmlStrcmp (node->name, (xmlChar*) "country") == 0) {
+		} else if (g_strcmp0 (gxml_dom_xnode_get_node_name (node), "country") == 0) {
 			/* gd:country */
-			priv->country_code = (gchar*) xmlGetProp (node, (xmlChar*) "code");
-			priv->country = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
+			priv->country_code = gxml_dom_element_get_attribute (elem, "code");
+			priv->country = gxml_dom_element_content_to_string (elem);
 
 			return TRUE;
 		}



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