[libgdata/gxml] * convert calendar-*.c
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/gxml] * convert calendar-*.c
- Date: Sat, 24 Sep 2011 06:22:49 +0000 (UTC)
commit 955c917872b553efad9122456e2e455c952ff599
Author: Richard Schwarting <aquarichy gmail com>
Date: Sat Jul 23 15:21:41 2011 -0400
* convert calendar-*.c
gdata/services/calendar/gdata-calendar-calendar.c | 42 ++++++++-------
gdata/services/calendar/gdata-calendar-event.c | 58 +++++++++++----------
gdata/services/calendar/gdata-calendar-feed.c | 22 ++++----
3 files changed, 64 insertions(+), 58 deletions(-)
---
diff --git a/gdata/services/calendar/gdata-calendar-calendar.c b/gdata/services/calendar/gdata-calendar-calendar.c
index 3b4d79a..9cb08cd 100644
--- a/gdata/services/calendar/gdata-calendar-calendar.c
+++ b/gdata/services/calendar/gdata-calendar-calendar.c
@@ -77,7 +77,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-calendar.h"
@@ -94,7 +94,7 @@ static void gdata_calendar_calendar_finalize (GObject *object);
static void gdata_calendar_calendar_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gdata_calendar_calendar_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void get_xml (GDataParsable *parsable, GString *xml_string);
-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 _GDataCalendarCalendarPrivate {
@@ -360,41 +360,43 @@ gdata_calendar_calendar_set_property (GObject *object, guint property_id, const
}
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;
GDataCalendarCalendar *self = GDATA_CALENDAR_CALENDAR (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://www.w3.org/2007/app") == TRUE &&
gdata_parser_int64_from_element (node, "edited", P_REQUIRED | P_NO_DUPES, &(self->priv->edited), &success, error) == TRUE) {
return success;
} else if (gdata_parser_is_namespace (node, "http://schemas.google.com/gCal/2005") == TRUE) {
- if (xmlStrcmp (node->name, (xmlChar*) "timezone") == 0) {
+ if (g_strcmp0 (node_name, "timezone") == 0) {
/* gCal:timezone */
- xmlChar *_timezone = xmlGetProp (node, (xmlChar*) "value");
+ gchar *_timezone = gxml_dom_element_get_attribute (elem, "value");
if (_timezone == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- self->priv->timezone = (gchar*) _timezone;
- } else if (xmlStrcmp (node->name, (xmlChar*) "timesCleaned") == 0) {
+ self->priv->timezone = _timezone;
+ } else if (g_strcmp0 (node_name, "timesCleaned") == 0) {
/* gCal:timesCleaned */
- xmlChar *times_cleaned = xmlGetProp (node, (xmlChar*) "value");
+ gchar *times_cleaned = gxml_dom_element_get_attribute (elem, "value");
if (times_cleaned == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- self->priv->times_cleaned = strtoul ((gchar*) times_cleaned, NULL, 10);
- xmlFree (times_cleaned);
- } else if (xmlStrcmp (node->name, (xmlChar*) "hidden") == 0) {
+ self->priv->times_cleaned = strtoul (times_cleaned, NULL, 10);
+ g_free (times_cleaned);
+ } else if (g_strcmp0 (node_name, "hidden") == 0) {
/* gCal:hidden */
if (gdata_parser_boolean_from_property (node, "value", &(self->priv->is_hidden), -1, error) == FALSE)
return FALSE;
- } else if (xmlStrcmp (node->name, (xmlChar*) "color") == 0) {
+ } else if (g_strcmp0 (node_name, "color") == 0) {
/* gCal:color */
- xmlChar *value;
+ gchar *value;
GDataColor colour;
- value = xmlGetProp (node, (xmlChar*) "value");
+ value = gxml_dom_element_get_attribute (elem, "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- if (gdata_color_from_hexadecimal ((gchar*) value, &colour) == FALSE) {
+ if (gdata_color_from_hexadecimal (value, &colour) == FALSE) {
/* Error */
g_set_error (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_PROTOCOL_ERROR,
/* Translators: the first parameter is the name of an XML element (including the angle brackets
@@ -405,20 +407,20 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
* The content of a <entry/gCal:color> element ("00FG56") was not in hexadecimal RGB format. */
_("The content of a %s element (\"%s\") was not in hexadecimal RGB format."),
"<entry/gCal:color>", value);
- xmlFree (value);
+ g_free (value);
return FALSE;
}
gdata_calendar_calendar_set_color (self, &colour);
- xmlFree (value);
- } else if (xmlStrcmp (node->name, (xmlChar*) "selected") == 0) {
+ g_free (value);
+ } else if (g_strcmp0 (node_name, "selected") == 0) {
/* gCal:selected */
if (gdata_parser_boolean_from_property (node, "value", &(self->priv->is_selected), -1, error) == FALSE)
return FALSE;
- } else if (xmlStrcmp (node->name, (xmlChar*) "accesslevel") == 0) {
+ } else if (g_strcmp0 (node_name, "accesslevel") == 0) {
/* gCal:accesslevel */
- self->priv->access_level = (gchar*) xmlGetProp (node, (xmlChar*) "value");
+ self->priv->access_level = gxml_dom_element_get_attribute (elem, "value");
if (self->priv->access_level == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
} else {
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index 5596913..5152fa3 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -100,7 +100,7 @@ static void gdata_calendar_event_finalize (GObject *object);
static void gdata_calendar_event_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gdata_calendar_event_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void get_xml (GDataParsable *parsable, GString *xml_string);
-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 _GDataCalendarEventPrivate {
@@ -510,10 +510,12 @@ gdata_calendar_event_set_property (GObject *object, guint property_id, const GVa
}
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;
GDataCalendarEvent *self = GDATA_CALENDAR_EVENT (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://www.w3.org/2007/app") == TRUE &&
gdata_parser_int64_from_element (node, "edited", P_REQUIRED | P_NO_DUPES, &(self->priv->edited), &success, error) == TRUE) {
@@ -526,73 +528,73 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
gdata_parser_object_from_element_setter (node, "where", P_REQUIRED, GDATA_TYPE_GD_WHERE,
gdata_calendar_event_add_place, self, &success, error) == TRUE) {
return success;
- } else if (xmlStrcmp (node->name, (xmlChar*) "eventStatus") == 0) {
+ } else if (g_strcmp0 (node_name, "eventStatus") == 0) {
/* gd:eventStatus */
- xmlChar *value = xmlGetProp (node, (xmlChar*) "value");
+ gchar *value = gxml_dom_element_get_attribute (elem, "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- self->priv->status = (gchar*) value;
- } else if (xmlStrcmp (node->name, (xmlChar*) "visibility") == 0) {
+ self->priv->status = value;
+ } else if (g_strcmp0 (node_name, "visibility") == 0) {
/* gd:visibility */
- xmlChar *value = xmlGetProp (node, (xmlChar*) "value");
+ gchar *value = gxml_dom_element_get_attribute (elem, "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- self->priv->visibility = (gchar*) value;
- } else if (xmlStrcmp (node->name, (xmlChar*) "transparency") == 0) {
+ self->priv->visibility = value;
+ } else if (g_strcmp0 (node_name, "transparency") == 0) {
/* gd:transparency */
- xmlChar *value = xmlGetProp (node, (xmlChar*) "value");
+ gchar *value = gxml_dom_element_get_attribute (elem, "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- self->priv->transparency = (gchar*) value;
- } else if (xmlStrcmp (node->name, (xmlChar*) "recurrence") == 0) {
+ self->priv->transparency = value;
+ } else if (g_strcmp0 (node_name, "recurrence") == 0) {
/* gd:recurrence */
- self->priv->recurrence = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
- } else if (xmlStrcmp (node->name, (xmlChar*) "originalEvent") == 0) {
+ self->priv->recurrence = gxml_dom_element_get_content (elem);
+ } else if (g_strcmp0 (node_name, "originalEvent") == 0) {
/* gd:originalEvent */
- self->priv->original_event_id = (gchar*) xmlGetProp (node, (xmlChar*) "id");
- self->priv->original_event_uri = (gchar*) xmlGetProp (node, (xmlChar*) "href");
+ self->priv->original_event_id = gxml_dom_element_get_attribute (elem, "id");
+ self->priv->original_event_uri = gxml_dom_element_get_attribute (elem, "href");
} else {
return GDATA_PARSABLE_CLASS (gdata_calendar_event_parent_class)->parse_xml (parsable, doc, node, user_data, error);
}
} else if (gdata_parser_is_namespace (node, "http://schemas.google.com/gCal/2005") == TRUE) {
- if (xmlStrcmp (node->name, (xmlChar*) "uid") == 0) {
+ if (g_strcmp0 (node_name, "uid") == 0) {
/* gCal:uid */
- xmlChar *value = xmlGetProp (node, (xmlChar*) "value");
+ gchar *value = gxml_dom_element_get_attribute (elem, "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- self->priv->uid = (gchar*) value;
- } else if (xmlStrcmp (node->name, (xmlChar*) "sequence") == 0) {
+ self->priv->uid = value;
+ } else if (g_strcmp0 (node_name, "sequence") == 0) {
/* gCal:sequence */
- xmlChar *value;
+ gchar *value;
guint value_uint;
- value = xmlGetProp (node, (xmlChar*) "value");
+ value = gxml_dom_element_get_attribute (elem, "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
else
- value_uint = strtoul ((gchar*) value, NULL, 10);
- xmlFree (value);
+ value_uint = strtoul (value, NULL, 10);
+ g_free (value);
gdata_calendar_event_set_sequence (self, value_uint);
- } else if (xmlStrcmp (node->name, (xmlChar*) "guestsCanModify") == 0) {
+ } else if (g_strcmp0 (node_name, "guestsCanModify") == 0) {
/* gCal:guestsCanModify */
gboolean guests_can_modify;
if (gdata_parser_boolean_from_property (node, "value", &guests_can_modify, -1, error) == FALSE)
return FALSE;
gdata_calendar_event_set_guests_can_modify (self, guests_can_modify);
- } else if (xmlStrcmp (node->name, (xmlChar*) "guestsCanInviteOthers") == 0) {
+ } else if (g_strcmp0 (node_name, "guestsCanInviteOthers") == 0) {
/* gCal:guestsCanInviteOthers */
gboolean guests_can_invite_others;
if (gdata_parser_boolean_from_property (node, "value", &guests_can_invite_others, -1, error) == FALSE)
return FALSE;
gdata_calendar_event_set_guests_can_invite_others (self, guests_can_invite_others);
- } else if (xmlStrcmp (node->name, (xmlChar*) "guestsCanSeeGuests") == 0) {
+ } else if (g_strcmp0 (node_name, "guestsCanSeeGuests") == 0) {
/* gCal:guestsCanSeeGuests */
gboolean guests_can_see_guests;
if (gdata_parser_boolean_from_property (node, "value", &guests_can_see_guests, -1, error) == FALSE)
return FALSE;
gdata_calendar_event_set_guests_can_see_guests (self, guests_can_see_guests);
- } else if (xmlStrcmp (node->name, (xmlChar*) "anyoneCanAddSelf") == 0) {
+ } else if (g_strcmp0 (node_name, "anyoneCanAddSelf") == 0) {
/* gCal:anyoneCanAddSelf */
gboolean anyone_can_add_self;
if (gdata_parser_boolean_from_property (node, "value", &anyone_can_add_self, -1, error) == FALSE)
diff --git a/gdata/services/calendar/gdata-calendar-feed.c b/gdata/services/calendar/gdata-calendar-feed.c
index a54cf0c..efaa02a 100644
--- a/gdata/services/calendar/gdata-calendar-feed.c
+++ b/gdata/services/calendar/gdata-calendar-feed.c
@@ -28,7 +28,7 @@
**/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include "gdata-calendar-feed.h"
#include "gdata-feed.h"
@@ -36,7 +36,7 @@
static void gdata_calendar_feed_finalize (GObject *object);
static void gdata_calendar_feed_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);
struct _GDataCalendarFeedPrivate {
gchar *timezone;
@@ -128,27 +128,29 @@ gdata_calendar_feed_get_property (GObject *object, guint property_id, 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)
{
GDataCalendarFeed *self = GDATA_CALENDAR_FEED (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://schemas.google.com/gCal/2005") == FALSE)
return GDATA_PARSABLE_CLASS (gdata_calendar_feed_parent_class)->parse_xml (parsable, doc, node, user_data, error);
- if (xmlStrcmp (node->name, (xmlChar*) "timezone") == 0) {
+ if (g_strcmp0 (node_name, "timezone") == 0) {
/* gCal:timezone */
- xmlChar *_timezone = xmlGetProp (node, (xmlChar*) "value");
+ gchar *_timezone = gxml_dom_element_get_attribute (elem, "value");
if (_timezone == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
g_free (self->priv->timezone);
- self->priv->timezone = (gchar*) _timezone;
- } else if (xmlStrcmp (node->name, (xmlChar*) "timesCleaned") == 0) {
+ self->priv->timezone = _timezone;
+ } else if (g_strcmp0 (node_name, "timesCleaned") == 0) {
/* gCal:timesCleaned */
- xmlChar *times_cleaned = xmlGetProp (node, (xmlChar*) "value");
+ gchar *times_cleaned = gxml_dom_element_get_attribute (elem, "value");
if (times_cleaned == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- self->priv->times_cleaned = strtoul ((gchar*) times_cleaned, NULL, 10);
- xmlFree (times_cleaned);
+ self->priv->times_cleaned = strtoul (times_cleaned, NULL, 10);
+ g_free (times_cleaned);
} else {
return GDATA_PARSABLE_CLASS (gdata_calendar_feed_parent_class)->parse_xml (parsable, doc, node, user_data, error);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]