summaryrefslogtreecommitdiff
path: root/gdata/services/calendar/gdata-calendar-calendar.c
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2009-04-16 13:20:01 +0100
committerPhilip Withnall <philip@tecnocode.co.uk>2009-04-16 13:20:01 +0100
commit290b92c174680472ca75eb07f7fb84902b3248fd (patch)
tree8951202ca90ca3a88677e861a889e961399fb8ce /gdata/services/calendar/gdata-calendar-calendar.c
parentefaa27526a42956ece7a43132f41640bbbcf073c (diff)
downloadlibgdata-290b92c174680472ca75eb07f7fb84902b3248fd.tar.gz
Refactored entry creation a little
The code to create entries from XML strings was duplicated in several places and has now been refactored out into _gdata_entry_new_from_xml.
Diffstat (limited to 'gdata/services/calendar/gdata-calendar-calendar.c')
-rw-r--r--gdata/services/calendar/gdata-calendar-calendar.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/gdata/services/calendar/gdata-calendar-calendar.c b/gdata/services/calendar/gdata-calendar-calendar.c
index 6933b382..1503fa4f 100644
--- a/gdata/services/calendar/gdata-calendar-calendar.c
+++ b/gdata/services/calendar/gdata-calendar-calendar.c
@@ -209,43 +209,7 @@ gdata_calendar_calendar_new (const gchar *id)
GDataCalendarCalendar *
gdata_calendar_calendar_new_from_xml (const gchar *xml, gint length, GError **error)
{
- xmlDoc *doc;
- xmlNode *node;
-
- g_return_val_if_fail (xml != NULL, NULL);
-
- if (length == -1)
- length = strlen (xml);
-
- /* Parse the XML */
- doc = xmlReadMemory (xml, length, "entry.xml", NULL, 0);
- if (doc == NULL) {
- xmlError *xml_error = xmlGetLastError ();
- g_set_error (error, GDATA_PARSER_ERROR, GDATA_PARSER_ERROR_PARSING_STRING,
- _("Error parsing XML: %s"),
- xml_error->message);
- return NULL;
- }
-
- /* Get the root element */
- node = xmlDocGetRootElement (doc);
- if (node == NULL) {
- /* XML document's empty */
- xmlFreeDoc (doc);
- g_set_error (error, GDATA_PARSER_ERROR, GDATA_PARSER_ERROR_EMPTY_DOCUMENT,
- _("Error parsing XML: %s"),
- _("Empty document."));
- return NULL;
- }
-
- if (xmlStrcmp (node->name, (xmlChar*) "entry") != 0) {
- /* No <entry> element (required) */
- xmlFreeDoc (doc);
- gdata_parser_error_required_element_missing ("entry", "root", error);
- return NULL;
- }
-
- return GDATA_CALENDAR_CALENDAR (_gdata_entry_new_from_xml_node (GDATA_TYPE_CALENDAR_CALENDAR, doc, node, error));
+ return GDATA_CALENDAR_CALENDAR (_gdata_entry_new_from_xml (GDATA_TYPE_CALENDAR_CALENDAR, xml, length, error));
}
static gboolean