summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdata/atom/gdata-author.c21
-rw-r--r--gdata/atom/gdata-category.c20
-rw-r--r--gdata/atom/gdata-generator.c17
-rw-r--r--gdata/atom/gdata-link.c21
-rw-r--r--gdata/exif/gdata-exif-tags.c12
-rw-r--r--gdata/gd/gdata-gd-email-address.c21
-rw-r--r--gdata/gd/gdata-gd-im-address.c20
-rw-r--r--gdata/gd/gdata-gd-name.c18
-rw-r--r--gdata/gd/gdata-gd-organization.c49
-rw-r--r--gdata/gd/gdata-gd-phone-number.c19
-rw-r--r--gdata/gd/gdata-gd-postal-address.c29
-rw-r--r--gdata/gd/gdata-gd-reminder.c9
-rw-r--r--gdata/gd/gdata-gd-when.c10
-rw-r--r--gdata/gd/gdata-gd-where.c17
-rw-r--r--gdata/gd/gdata-gd-who.c15
-rw-r--r--gdata/gdata-access-rule.c24
-rw-r--r--gdata/gdata-entry.c30
-rw-r--r--gdata/gdata-feed.c15
-rw-r--r--gdata/gdata-parsable.c12
-rw-r--r--gdata/gdata-service.h3
-rw-r--r--gdata/media/gdata-media-category.c16
-rw-r--r--gdata/media/gdata-media-content.c13
-rw-r--r--gdata/media/gdata-media-credit.c23
-rw-r--r--gdata/media/gdata-media-group.c18
-rw-r--r--gdata/media/gdata-media-thumbnail.c19
-rw-r--r--gdata/services/calendar/gdata-calendar-calendar.c7
-rw-r--r--gdata/services/calendar/gdata-calendar-event.c22
-rw-r--r--gdata/services/calendar/gdata-calendar-feed.c6
-rw-r--r--gdata/services/contacts/gdata-contacts-contact.c21
-rw-r--r--gdata/services/documents/gdata-documents-feed.c15
-rw-r--r--gdata/services/picasaweb/gdata-picasaweb-album.c40
-rw-r--r--gdata/services/picasaweb/gdata-picasaweb-file.c20
-rw-r--r--gdata/services/picasaweb/gdata-picasaweb-user.c29
-rw-r--r--gdata/services/youtube/gdata-youtube-credit.c4
-rw-r--r--gdata/services/youtube/gdata-youtube-group.c4
-rw-r--r--gdata/services/youtube/gdata-youtube-state.c24
-rw-r--r--gdata/services/youtube/gdata-youtube-video.c7
-rw-r--r--gdata/tests/general.c6
38 files changed, 276 insertions, 400 deletions
diff --git a/gdata/atom/gdata-author.c b/gdata/atom/gdata-author.c
index 10be75a0..933ea5af 100644
--- a/gdata/atom/gdata-author.c
+++ b/gdata/atom/gdata-author.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -198,30 +198,23 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
return gdata_parser_error_duplicate_element (node, error);
name = xmlNodeListGetString (doc, node->children, TRUE);
- if (name == NULL || *name == '\0')
+ if (name == NULL || *name == '\0') {
+ xmlFree (name);
return gdata_parser_error_required_content_missing (node, error);
- priv->name = g_strdup ((gchar*) name);
- xmlFree (name);
+ }
+ priv->name = (gchar*) name;
} else if (xmlStrcmp (node->name, (xmlChar*) "uri") == 0) {
/* atom:uri */
- xmlChar *uri;
-
if (priv->uri != NULL)
return gdata_parser_error_duplicate_element (node, error);
- uri = xmlNodeListGetString (doc, node->children, TRUE);
- priv->uri = g_strdup ((gchar*) uri);
- xmlFree (uri);
+ priv->uri = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "email") == 0) {
/* atom:email */
- xmlChar *email_address;
-
if (priv->email_address != NULL)
return gdata_parser_error_duplicate_element (node, error);
- email_address = xmlNodeListGetString (doc, node->children, TRUE);
- priv->email_address = g_strdup ((gchar*) email_address);
- xmlFree (email_address);
+ priv->email_address = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (GDATA_PARSABLE_CLASS (gdata_author_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
return FALSE;
diff --git a/gdata/atom/gdata-category.c b/gdata/atom/gdata-category.c
index 0f0ca7b0..2adcb1f1 100644
--- a/gdata/atom/gdata-category.c
+++ b/gdata/atom/gdata-category.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -186,22 +186,18 @@ gdata_category_set_property (GObject *object, guint property_id, const GValue *v
static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
- xmlChar *term, *scheme, *label;
+ xmlChar *term;
GDataCategory *self = GDATA_CATEGORY (parsable);
term = xmlGetProp (root_node, (xmlChar*) "term");
- if (term == NULL || *term == '\0')
+ if (term == NULL || *term == '\0') {
+ xmlFree (term);
return gdata_parser_error_required_property_missing (root_node, "term", error);
- self->priv->term = g_strdup ((gchar*) term);
- xmlFree (term);
-
- scheme = xmlGetProp (root_node, (xmlChar*) "scheme");
- self->priv->scheme = g_strdup ((gchar*) scheme);
- xmlFree (scheme);
+ }
+ self->priv->term = (gchar*) term;
- label = xmlGetProp (root_node, (xmlChar*) "label");
- self->priv->label = g_strdup ((gchar*) label);
- xmlFree (label);
+ self->priv->scheme = (gchar*) xmlGetProp (root_node, (xmlChar*) "scheme");
+ self->priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
return TRUE;
}
diff --git a/gdata/atom/gdata-generator.c b/gdata/atom/gdata-generator.c
index 6a8f2277..f9086ff4 100644
--- a/gdata/atom/gdata-generator.c
+++ b/gdata/atom/gdata-generator.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -129,9 +129,9 @@ gdata_generator_finalize (GObject *object)
{
GDataGeneratorPrivate *priv = GDATA_GENERATOR (object)->priv;
- xmlFree (priv->name);
- xmlFree (priv->uri);
- xmlFree (priv->version);
+ g_free (priv->name);
+ g_free (priv->uri);
+ g_free (priv->version);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_generator_parent_class)->finalize (object);
@@ -162,12 +162,15 @@ gdata_generator_get_property (GObject *object, guint property_id, GValue *value,
static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
+ xmlChar *uri;
GDataGeneratorPrivate *priv = GDATA_GENERATOR (parsable)->priv;
- priv->uri = (gchar*) xmlGetProp (root_node, (xmlChar*) "uri");
- if (priv->uri != NULL && *(priv->uri) == '\0')
- /* priv->uri will be freed when the object is destroyed */
+ uri = xmlGetProp (root_node, (xmlChar*) "uri");
+ if (uri != NULL && *uri == '\0') {
+ xmlFree (uri);
return gdata_parser_error_required_property_missing (root_node, "uri", error);
+ }
+ priv->uri = (gchar*) uri;
priv->name = (gchar*) xmlNodeListGetString (doc, root_node->children, TRUE);
priv->version = (gchar*) xmlGetProp (root_node, (xmlChar*) "version");
diff --git a/gdata/atom/gdata-link.c b/gdata/atom/gdata-link.c
index 2cf91652..00a9c7e7 100644
--- a/gdata/atom/gdata-link.c
+++ b/gdata/atom/gdata-link.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -264,15 +264,16 @@ gdata_link_set_property (GObject *object, guint property_id, const GValue *value
static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
- xmlChar *uri, *relation_type, *content_type, *language, *title, *length;
+ xmlChar *uri, *relation_type, *content_type, *language, *length;
GDataLink *self = GDATA_LINK (parsable);
/* href */
uri = xmlGetProp (root_node, (xmlChar*) "href");
- if (uri == NULL || *uri == '\0')
+ if (uri == NULL || *uri == '\0') {
+ xmlFree (uri);
return gdata_parser_error_required_property_missing (root_node, "href", error);
- self->priv->uri = g_strdup ((gchar*) uri);
- xmlFree (uri);
+ }
+ self->priv->uri = (gchar*) uri;
/* rel */
relation_type = xmlGetProp (root_node, (xmlChar*) "rel");
@@ -290,8 +291,7 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
xmlFree (content_type);
return gdata_parser_error_required_property_missing (root_node, "type", error);
}
- self->priv->content_type = g_strdup ((gchar*) content_type);
- xmlFree (content_type);
+ self->priv->content_type = (gchar*) content_type;
/* hreflang */
language = xmlGetProp (root_node, (xmlChar*) "hreflang");
@@ -299,13 +299,10 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
xmlFree (language);
return gdata_parser_error_required_property_missing (root_node, "hreflang", error);
}
- self->priv->language = g_strdup ((gchar*) language);
- xmlFree (language);
+ self->priv->language = (gchar*) language;
/* title */
- title = xmlGetProp (root_node, (xmlChar*) "title");
- self->priv->title = g_strdup ((gchar*) title);
- xmlFree (title);
+ self->priv->title = (gchar*) xmlGetProp (root_node, (xmlChar*) "title");
/* length */
length = xmlGetProp (root_node, (xmlChar*) "length");
diff --git a/gdata/exif/gdata-exif-tags.c b/gdata/exif/gdata-exif-tags.c
index b87e34ca..6db0d589 100644
--- a/gdata/exif/gdata-exif-tags.c
+++ b/gdata/exif/gdata-exif-tags.c
@@ -95,9 +95,9 @@ gdata_exif_tags_finalize (GObject *object)
{
GDataExifTagsPrivate *priv = GDATA_EXIF_TAGS (object)->priv;
- xmlFree ((xmlChar*) priv->make);
- xmlFree ((xmlChar*) priv->model);
- xmlFree ((xmlChar*) priv->image_unique_id);
+ g_free (priv->make);
+ g_free (priv->model);
+ g_free (priv->image_unique_id);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_exif_tags_parent_class)->finalize (object);
@@ -120,11 +120,11 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlFree (fstop);
} else if (xmlStrcmp (node->name, (xmlChar*) "make") == 0) {
/* exif:make */
- xmlFree ((xmlChar*) self->priv->make);
+ g_free (self->priv->make);
self->priv->make = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "model") == 0) {
/* exif:model */
- xmlFree ((xmlChar*) self->priv->model);
+ g_free (self->priv->model);
self->priv->model = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "exposure") == 0) {
/* exif:exposure */
@@ -161,7 +161,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
self->priv->_time.tv_usec = (glong) ((milliseconds % 1000) * 1000);
} else if (xmlStrcmp (node->name, (xmlChar*) "imageUniqueID") == 0) {
/* exif:imageUniqueID */
- xmlFree ((xmlChar*) self->priv->image_unique_id);
+ g_free (self->priv->image_unique_id);
self->priv->image_unique_id = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (GDATA_PARSABLE_CLASS (gdata_exif_tags_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
diff --git a/gdata/gd/gdata-gd-email-address.c b/gdata/gd/gdata-gd-email-address.c
index 022d0528..8a9da95a 100644
--- a/gdata/gd/gdata-gd-email-address.c
+++ b/gdata/gd/gdata-gd-email-address.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -238,7 +238,7 @@ 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)
{
- xmlChar *address, *rel, *label, *primary, *display_name;
+ xmlChar *address, *rel, *primary;
gboolean primary_bool;
GDataGDEmailAddressPrivate *priv = GDATA_GD_EMAIL_ADDRESS (parsable)->priv;
@@ -267,20 +267,11 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
}
xmlFree (primary);
- /* Other properties */
- label = xmlGetProp (root_node, (xmlChar*) "label");
- display_name = xmlGetProp (root_node, (xmlChar*) "displayName");
-
- priv->address = g_strdup ((gchar*) address);
- priv->relation_type = g_strdup ((gchar*) rel);
- priv->label = g_strdup ((gchar*) label);
+ priv->address = (gchar*) address;
+ priv->relation_type = (gchar*) rel;
+ priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
priv->is_primary = primary_bool;
- priv->display_name = g_strdup ((gchar*) display_name);
-
- xmlFree (address);
- xmlFree (rel);
- xmlFree (label);
- xmlFree (display_name);
+ priv->display_name = (gchar*) xmlGetProp (root_node, (xmlChar*) "displayName");
return TRUE;
}
diff --git a/gdata/gd/gdata-gd-im-address.c b/gdata/gd/gdata-gd-im-address.c
index 7e202a17..a074cfc3 100644
--- a/gdata/gd/gdata-gd-im-address.c
+++ b/gdata/gd/gdata-gd-im-address.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -238,7 +238,7 @@ 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)
{
- xmlChar *address, *protocol, *rel, *label, *primary;
+ xmlChar *address, *protocol, *rel, *primary;
gboolean primary_bool;
GDataGDIMAddressPrivate *priv = GDATA_GD_IM_ADDRESS (parsable)->priv;
@@ -269,20 +269,12 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
}
xmlFree (primary);
- /* Other properties */
- label = xmlGetProp (root_node, (xmlChar*) "label");
-
- priv->address = g_strdup ((gchar*) address);
- priv->protocol = g_strdup ((gchar*) protocol);
- priv->relation_type = g_strdup ((gchar*) rel);
- priv->label = g_strdup ((gchar*) label);
+ priv->address = (gchar*) address;
+ priv->protocol = (gchar*) protocol;
+ priv->relation_type = (gchar*) rel;
+ priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
priv->is_primary = primary_bool;
- xmlFree (address);
- xmlFree (protocol);
- xmlFree (rel);
- xmlFree (label);
-
return TRUE;
}
diff --git a/gdata/gd/gdata-gd-name.c b/gdata/gd/gdata-gd-name.c
index bc5d8409..d61ccc11 100644
--- a/gdata/gd/gdata-gd-name.c
+++ b/gdata/gd/gdata-gd-name.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -275,14 +275,9 @@ gdata_gd_name_set_property (GObject *object, guint property_id, const GValue *va
#define PARSE_STRING_ELEMENT(E,F) \
if (xmlStrcmp (node->name, (xmlChar*) (E)) == 0) { \
/* gd:##E */ \
- xmlChar *name; \
- \
if (priv->F != NULL) \
return gdata_parser_error_duplicate_element (node, error); \
- \
- name = xmlNodeListGetString (doc, node->children, TRUE); \
- priv->F = g_strdup ((gchar*) name); \
- xmlFree (name); \
+ priv->F = (gchar*) xmlNodeListGetString (doc, node->children, TRUE); \
}
static gboolean
@@ -295,8 +290,13 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
else PARSE_STRING_ELEMENT ("familyName", family_name)
else PARSE_STRING_ELEMENT ("namePrefix", prefix)
else PARSE_STRING_ELEMENT ("nameSuffix", suffix)
- else PARSE_STRING_ELEMENT ("fullName", full_name)
- else if (GDATA_PARSABLE_CLASS (gdata_gd_name_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
+ else if (xmlStrcmp (node->name, (xmlChar*) "fullName") == 0) {
+ /* gd:fullName */
+ if (priv->full_name != NULL)
+ return gdata_parser_error_duplicate_element (node, error);
+ priv->full_name = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
+ g_object_notify (G_OBJECT (parsable), "full-name"); /* various classes listen to this */
+ } else if (GDATA_PARSABLE_CLASS (gdata_gd_name_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
return FALSE;
}
diff --git a/gdata/gd/gdata-gd-organization.c b/gdata/gd/gdata-gd-organization.c
index 033cee76..3db6fd60 100644
--- a/gdata/gd/gdata-gd-organization.c
+++ b/gdata/gd/gdata-gd-organization.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -358,7 +358,7 @@ 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)
{
- xmlChar *rel, *label, *primary;
+ xmlChar *rel, *primary;
gboolean primary_bool;
GDataGDOrganizationPrivate *priv = GDATA_GD_ORGANIZATION (parsable)->priv;
@@ -382,16 +382,10 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
}
xmlFree (primary);
- /* Other properties */
- label = xmlGetProp (root_node, (xmlChar*) "label");
-
- priv->relation_type = g_strdup ((gchar*) rel);
- priv->label = g_strdup ((gchar*) label);
+ priv->relation_type = (gchar*) rel;
+ priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
priv->is_primary = primary_bool;
- xmlFree (rel);
- xmlFree (label);
-
return TRUE;
}
@@ -402,54 +396,29 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
if (xmlStrcmp (node->name, (xmlChar*) "orgName") == 0) {
/* gd:orgName */
- xmlChar *name;
-
if (priv->name != NULL)
return gdata_parser_error_duplicate_element (node, error);
-
- name = xmlNodeListGetString (doc, node->children, TRUE);
- priv->name = g_strdup ((gchar*) name);
- xmlFree (name);
+ priv->name = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "orgTitle") == 0) {
/* gd:orgTitle */
- xmlChar *title;
-
if (priv->title != NULL)
return gdata_parser_error_duplicate_element (node, error);
-
- title = xmlNodeListGetString (doc, node->children, TRUE);
- priv->title = g_strdup ((gchar*) title);
- xmlFree (title);
+ priv->title = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "orgDepartment") == 0) {
/* gd:orgDepartment */
- xmlChar *department;
-
if (priv->department != NULL)
return gdata_parser_error_duplicate_element (node, error);
-
- department = xmlNodeListGetString (doc, node->children, TRUE);
- priv->department = g_strdup ((gchar*) department);
- xmlFree (department);
+ priv->department = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "orgJobDescription") == 0) {
/* gd:orgJobDescription */
- xmlChar *job_description;
-
if (priv->job_description != NULL)
return gdata_parser_error_duplicate_element (node, error);
-
- job_description = xmlNodeListGetString (doc, node->children, TRUE);
- priv->job_description = g_strdup ((gchar*) job_description);
- xmlFree (job_description);
+ priv->job_description = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "orgSymbol") == 0) {
/* gd:orgSymbol */
- xmlChar *symbol;
-
if (priv->symbol != NULL)
return gdata_parser_error_duplicate_element (node, error);
-
- symbol = xmlNodeListGetString (doc, node->children, TRUE);
- priv->symbol = g_strdup ((gchar*) symbol);
- xmlFree (symbol);
+ priv->symbol = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "where") == 0) {
/* gd:where */
GDataGDWhere *location = GDATA_GD_WHERE (_gdata_parsable_new_from_xml_node (GDATA_TYPE_GD_WHERE, doc, node, NULL, error));
diff --git a/gdata/gd/gdata-gd-phone-number.c b/gdata/gd/gdata-gd-phone-number.c
index 72934ded..4921d349 100644
--- a/gdata/gd/gdata-gd-phone-number.c
+++ b/gdata/gd/gdata-gd-phone-number.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -243,7 +243,7 @@ gdata_gd_phone_number_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)
{
- xmlChar *number, *uri, *rel, *label, *primary;
+ xmlChar *number, *rel, *primary;
gboolean primary_bool;
GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (parsable)->priv;
@@ -275,21 +275,12 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
}
xmlFree (primary);
- /* Other properties */
- label = xmlGetProp (root_node, (xmlChar*) "label");
- uri = xmlGetProp (root_node, (xmlChar*) "uri");
-
gdata_gd_phone_number_set_number (GDATA_GD_PHONE_NUMBER (parsable), (gchar*) number);
- priv->uri = g_strdup ((gchar*) uri);
- priv->relation_type = g_strdup ((gchar*) rel);
- priv->label = g_strdup ((gchar*) label);
+ priv->uri = (gchar*) xmlGetProp (root_node, (xmlChar*) "uri");
+ priv->relation_type = (gchar*) rel;
+ priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
priv->is_primary = primary_bool;
- xmlFree (number);
- xmlFree (uri);
- xmlFree (rel);
- xmlFree (label);
-
return TRUE;
}
diff --git a/gdata/gd/gdata-gd-postal-address.c b/gdata/gd/gdata-gd-postal-address.c
index 786c5fff..6ec22dd3 100644
--- a/gdata/gd/gdata-gd-postal-address.c
+++ b/gdata/gd/gdata-gd-postal-address.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -543,7 +543,7 @@ 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)
{
- xmlChar *rel, *label, *primary, *mail_class, *usage;
+ xmlChar *rel, *primary;
gboolean primary_bool;
GDataGDPostalAddressPrivate *priv = GDATA_GD_POSTAL_ADDRESS (parsable)->priv;
@@ -565,36 +565,21 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
}
xmlFree (primary);
- /* Other properties */
- label = xmlGetProp (root_node, (xmlChar*) "label");
- mail_class = xmlGetProp (root_node, (xmlChar*) "mailClass");
- usage = xmlGetProp (root_node, (xmlChar*) "usage");
-
- priv->relation_type = g_strdup ((gchar*) rel);
- priv->label = g_strdup ((gchar*) label);
- priv->mail_class = g_strdup ((gchar*) mail_class);
- priv->usage = g_strdup ((gchar*) usage);
+ 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->is_primary = primary_bool;
- xmlFree (rel);
- xmlFree (label);
- xmlFree (mail_class);
- xmlFree (usage);
-
return TRUE;
}
#define PARSE_STRING_ELEMENT(E,F) \
if (xmlStrcmp (node->name, (xmlChar*) (E)) == 0) { \
/* gd:##E */ \
- xmlChar *name; \
- \
if (priv->F != NULL) \
return gdata_parser_error_duplicate_element (node, error); \
- \
- name = xmlNodeListGetString (doc, node->children, TRUE); \
- priv->F = g_strdup ((gchar*) name); \
- xmlFree (name); \
+ priv->F = (gchar*) xmlNodeListGetString (doc, node->children, TRUE); \
}
static gboolean
diff --git a/gdata/gd/gdata-gd-reminder.c b/gdata/gd/gdata-gd-reminder.c
index 18ec24c8..2f0e5a58 100644
--- a/gdata/gd/gdata-gd-reminder.c
+++ b/gdata/gd/gdata-gd-reminder.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -209,7 +209,7 @@ static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
GDataGDReminderPrivate *priv = GDATA_GD_REMINDER (parsable)->priv;
- xmlChar *absolute_time, *relative_time, *method;
+ xmlChar *absolute_time, *relative_time;
GTimeVal absolute_time_timeval;
gint relative_time_int = -1;
gboolean is_absolute_time = FALSE;
@@ -243,8 +243,6 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
}
xmlFree (relative_time);
- method = xmlGetProp (root_node, (xmlChar*) "method");
-
if (is_absolute_time == TRUE) {
priv->absolute_time = absolute_time_timeval;
priv->relative_time = -1;
@@ -253,8 +251,7 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
priv->relative_time = relative_time_int;
}
- priv->method = g_strdup ((gchar*) method);
- xmlFree (method);
+ priv->method = (gchar*) xmlGetProp (root_node, (xmlChar*) "method");
return TRUE;
}
diff --git a/gdata/gd/gdata-gd-when.c b/gdata/gd/gdata-gd-when.c
index 724be772..f5fd9979 100644
--- a/gdata/gd/gdata-gd-when.c
+++ b/gdata/gd/gdata-gd-when.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -240,7 +240,7 @@ static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
GDataGDWhenPrivate *priv = GDATA_GD_WHEN (parsable)->priv;
- xmlChar *start_time, *end_time, *value_string;
+ xmlChar *start_time, *end_time;
GTimeVal start_time_timeval, end_time_timeval;
gboolean is_date = FALSE;
@@ -278,14 +278,10 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
end_time_timeval.tv_sec = end_time_timeval.tv_usec = 0;
}
- value_string = xmlGetProp (root_node, (xmlChar*) "valueString");
-
priv->start_time = start_time_timeval;
priv->end_time = end_time_timeval;
priv->is_date = is_date;
- priv->value_string = g_strdup ((gchar*) value_string);
-
- xmlFree (value_string);
+ priv->value_string = (gchar*) xmlGetProp (root_node, (xmlChar*) "valueString");
return TRUE;
}
diff --git a/gdata/gd/gdata-gd-where.c b/gdata/gd/gdata-gd-where.c
index 7d4b2051..c23f85e9 100644
--- a/gdata/gd/gdata-gd-where.c
+++ b/gdata/gd/gdata-gd-where.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -193,7 +193,7 @@ gdata_gd_where_set_property (GObject *object, guint property_id, const GValue *v
static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
- xmlChar *rel, *value_string, *label;
+ xmlChar *rel;
GDataGDWherePrivate *priv = GDATA_GD_WHERE (parsable)->priv;
rel = xmlGetProp (root_node, (xmlChar*) "rel");
@@ -202,16 +202,9 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
return gdata_parser_error_required_property_missing (root_node, "rel", error);
}
- label = xmlGetProp (root_node, (xmlChar*) "label");
- value_string = xmlGetProp (root_node, (xmlChar*) "valueString");
-
- priv->relation_type = g_strdup ((gchar*) rel);
- priv->value_string = g_strdup ((gchar*) value_string);
- priv->label = g_strdup ((gchar*) label);
-
- xmlFree (rel);
- xmlFree (value_string);
- xmlFree (label);
+ priv->relation_type = (gchar*) rel;
+ priv->value_string = (gchar*) xmlGetProp (root_node, (xmlChar*) "valueString");
+ priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
return TRUE;
}
diff --git a/gdata/gd/gdata-gd-who.c b/gdata/gd/gdata-gd-who.c
index 8238378c..7084e64d 100644
--- a/gdata/gd/gdata-gd-who.c
+++ b/gdata/gd/gdata-gd-who.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -193,7 +193,7 @@ gdata_gd_who_set_property (GObject *object, guint property_id, const GValue *val
static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
- xmlChar *rel, *value_string, *email;
+ xmlChar *rel, *email;
GDataGDWhoPrivate *priv = GDATA_GD_WHO (parsable)->priv;
rel = xmlGetProp (root_node, (xmlChar*) "rel");
@@ -208,15 +208,10 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
xmlFree (email);
return gdata_parser_error_required_property_missing (root_node, "email", error);
}
- value_string = xmlGetProp (root_node, (xmlChar*) "valueString");
- priv->relation_type = g_strdup ((gchar*) rel);
- priv->value_string = g_strdup ((gchar*) value_string);
- priv->email_address = g_strdup ((gchar*) email);
-
- xmlFree (rel);
- xmlFree (value_string);
- xmlFree (email);
+ priv->relation_type = (gchar*) rel;
+ priv->value_string = (gchar*) xmlGetProp (root_node, (xmlChar*) "valueString");
+ priv->email_address = (gchar*) email;
return TRUE;
}
diff --git a/gdata/gdata-access-rule.c b/gdata/gdata-access-rule.c
index 0df59049..28004c8c 100644
--- a/gdata/gdata-access-rule.c
+++ b/gdata/gdata-access-rule.c
@@ -2,7 +2,7 @@
/*
* GData Client
* Copyright (C) Thibault Saunier 2009 <saunierthibault@gmail.com>
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -217,8 +217,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlChar *role = xmlGetProp (node, (xmlChar*) "value");
if (role == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- gdata_access_rule_set_role (self, (gchar*) role);
- xmlFree (role);
+ self->priv->role = (gchar*) role;
} else if (xmlStrcmp (node->name, (xmlChar*) "scope") == 0) {
/* gAcl:scope */
xmlChar *scope_type, *scope_value;
@@ -228,9 +227,14 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
return gdata_parser_error_required_property_missing (node, "type", error);
scope_value = xmlGetProp (node, (xmlChar*) "value");
- gdata_access_rule_set_scope (self, (gchar*) scope_type, (gchar*) scope_value);
- xmlFree (scope_type);
- xmlFree (scope_value);
+
+ if (xmlStrcmp (scope_type, (xmlChar*) "default") == 0 && scope_value == NULL) {
+ xmlFree (scope_type);
+ return gdata_parser_error_required_property_missing (node, "value", error);
+ }
+
+ self->priv->scope_type = (gchar*) scope_type;
+ self->priv->scope_value = (gchar*) scope_value;
} else if (GDATA_PARSABLE_CLASS (gdata_access_rule_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
return FALSE;
@@ -293,6 +297,7 @@ void
gdata_access_rule_set_role (GDataAccessRule *self, const gchar *role)
{
g_return_if_fail (GDATA_IS_ACCESS_RULE (self));
+
g_free (self->priv->role);
self->priv->role = g_strdup (role);
g_object_notify (G_OBJECT (self), "role");
@@ -337,12 +342,7 @@ gdata_access_rule_set_scope (GDataAccessRule *self, const gchar *type, const gch
{
g_return_if_fail (GDATA_IS_ACCESS_RULE (self));
g_return_if_fail (type != NULL);
-
- /* Validate stuff first */
- if (strcmp (type, "default") == 0)
- g_return_if_fail (value == NULL);
- else
- g_return_if_fail (value != NULL);
+ g_return_if_fail ((strcmp (type, "default") == 0 && value == NULL) || value != NULL);
g_free (self->priv->scope_type);
self->priv->scope_type = g_strdup (type);
diff --git a/gdata/gdata-entry.c b/gdata/gdata-entry.c
index a22cab4a..fe606688 100644
--- a/gdata/gdata-entry.c
+++ b/gdata/gdata-entry.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2008-2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2008–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -213,8 +213,8 @@ gdata_entry_finalize (GObject *object)
g_free (priv->title);
g_free (priv->summary);
- xmlFree (priv->id);
- xmlFree (priv->etag);
+ g_free (priv->id);
+ g_free (priv->etag);
g_free (priv->rights);
g_free (priv->content);
@@ -324,14 +324,11 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlChar *title = xmlNodeListGetString (doc, node->children, TRUE);
/* Title can be empty */
- if (title == NULL)
- gdata_entry_set_title (self, "");
- else
- gdata_entry_set_title (self, (gchar*) title);
- xmlFree (title);
+ self->priv->title = (title == NULL) ? g_strdup ("") : (gchar*) title;
+ g_object_notify (G_OBJECT (self), "title"); /* various classes depend on updates to our title */
} else if (xmlStrcmp (node->name, (xmlChar*) "id") == 0) {
/* atom:id */
- xmlFree (self->priv->id);
+ g_free (self->priv->id);
self->priv->id = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "updated") == 0) {
/* atom:updated */
@@ -369,8 +366,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlChar *content = xmlNodeListGetString (doc, node->children, TRUE);
if (content == NULL)
content = xmlGetProp (node, (xmlChar*) "src");
- gdata_entry_set_content (self, (gchar*) content);
- xmlFree (content);
+ self->priv->content = (gchar*) content;
} else if (xmlStrcmp (node->name, (xmlChar*) "link") == 0) {
/* atom:link */
GDataLink *link = GDATA_LINK (_gdata_parsable_new_from_xml_node (GDATA_TYPE_LINK, doc, node, NULL, error));
@@ -387,14 +383,12 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
self->priv->authors = g_list_prepend (self->priv->authors, author);
} else if (xmlStrcmp (node->name, (xmlChar*) "summary") == 0) {
/* atom:summary */
- xmlChar *summary = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_entry_set_summary (self, (gchar*) summary);
- xmlFree (summary);
+ self->priv->summary = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
+ g_object_notify (G_OBJECT (self), "summary"); /* various classes depend on updates to our title */
} else if (xmlStrcmp (node->name, (xmlChar*) "rights") == 0) {
/* atom:rights */
- xmlChar *rights = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_entry_set_rights (self, (gchar*) rights);
- xmlFree (rights);
+ self->priv->rights = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
+ g_object_notify (G_OBJECT (self), "rights"); /* various classes depend on updates to our title */
} else if (GDATA_PARSABLE_CLASS (gdata_entry_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
return FALSE;
@@ -558,6 +552,7 @@ void
gdata_entry_set_summary (GDataEntry *self, const gchar *summary)
{
g_return_if_fail (GDATA_IS_ENTRY (self));
+
g_free (self->priv->summary);
self->priv->summary = g_strdup (summary);
g_object_notify (G_OBJECT (self), "summary");
@@ -849,6 +844,7 @@ void
gdata_entry_set_rights (GDataEntry *self, const gchar *rights)
{
g_return_if_fail (GDATA_IS_ENTRY (self));
+
g_free (self->priv->rights);
self->priv->rights = g_strdup (rights);
g_object_notify (G_OBJECT (self), "rights");
diff --git a/gdata/gdata-feed.c b/gdata/gdata-feed.c
index 21683643..2cbae6f1 100644
--- a/gdata/gdata-feed.c
+++ b/gdata/gdata-feed.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2008-2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2008–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -310,12 +310,12 @@ gdata_feed_finalize (GObject *object)
{
GDataFeedPrivate *priv = GDATA_FEED (object)->priv;
- xmlFree (priv->title);
- xmlFree (priv->subtitle);
- xmlFree (priv->id);
- xmlFree (priv->etag);
- xmlFree (priv->logo);
- xmlFree (priv->icon);
+ g_free (priv->title);
+ g_free (priv->subtitle);
+ g_free (priv->id);
+ g_free (priv->etag);
+ g_free (priv->logo);
+ g_free (priv->icon);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_feed_parent_class)->finalize (object);
@@ -457,7 +457,6 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlFree (updated_string);
return FALSE;
}
-
xmlFree (updated_string);
} else if (xmlStrcmp (node->name, (xmlChar*) "category") == 0) {
/* atom:category */
diff --git a/gdata/gdata-parsable.c b/gdata/gdata-parsable.c
index f0d86e93..5ae51825 100644
--- a/gdata/gdata-parsable.c
+++ b/gdata/gdata-parsable.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -147,11 +147,21 @@ _gdata_parsable_new_from_xml (GType parsable_type, const gchar *xml, gint length
{
xmlDoc *doc;
xmlNode *node;
+ static gboolean libxml_initialised = FALSE;
g_return_val_if_fail (g_type_is_a (parsable_type, GDATA_TYPE_PARSABLE), NULL);
g_return_val_if_fail (xml != NULL && *xml != '\0', NULL);
g_return_val_if_fail (length >= -1, NULL);
+ /* Set up libxml. We do this here to avoid introducing a libgdata setup function, which would be unnecessary hassle. This is the only place
+ * that libxml can be initialised in the library. */
+ if (libxml_initialised == FALSE) {
+ /* Change the libxml memory allocation functions to be GLib's. This means we don't have to re-allocate all the strings we get from
+ * libxml, which cuts down on strdup() calls dramatically. */
+ xmlMemSetup ((xmlFreeFunc) g_free, (xmlMallocFunc) g_malloc, (xmlReallocFunc) g_realloc, (xmlStrdupFunc) g_strdup);
+ libxml_initialised = TRUE;
+ }
+
if (length == -1)
length = strlen (xml);
diff --git a/gdata/gdata-service.h b/gdata/gdata-service.h
index 7c89cb7a..c0e11418 100644
--- a/gdata/gdata-service.h
+++ b/gdata/gdata-service.h
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2008-2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2008–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,7 +23,6 @@
#include <glib.h>
#include <glib-object.h>
#include <libsoup/soup.h>
-#include <libxml/parser.h>
#include <gdata/gdata-feed.h>
diff --git a/gdata/media/gdata-media-category.c b/gdata/media/gdata-media-category.c
index 9b309bb3..34e0cf82 100644
--- a/gdata/media/gdata-media-category.c
+++ b/gdata/media/gdata-media-category.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -192,7 +192,7 @@ static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
GDataMediaCategoryPrivate *priv = GDATA_MEDIA_CATEGORY (parsable)->priv;
- xmlChar *category, *scheme, *label;
+ xmlChar *category, *scheme;
category = xmlNodeListGetString (doc, root_node->children, TRUE);
if (category == NULL || *category == '\0') {
@@ -210,15 +210,9 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
scheme = xmlStrdup ((xmlChar*) "http://video.search.yahoo.com/mrss/category_schema");
}
- label = xmlGetProp (root_node, (xmlChar*) "label");
-
- priv->category = g_strdup ((gchar*) category);
- priv->scheme = g_strdup ((gchar*) scheme);
- priv->label = g_strdup ((gchar*) label);
-
- xmlFree (category);
- xmlFree (scheme);
- xmlFree (label);
+ priv->category = (gchar*) category;
+ priv->scheme = (gchar*) scheme;
+ priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
return TRUE;
}
diff --git a/gdata/media/gdata-media-content.c b/gdata/media/gdata-media-content.c
index f3071373..2b5dc4ed 100644
--- a/gdata/media/gdata-media-content.c
+++ b/gdata/media/gdata-media-content.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -287,7 +287,7 @@ static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
GDataMediaContentPrivate *priv = GDATA_MEDIA_CONTENT (parsable)->priv;
- xmlChar *uri, *content_type, *is_default, *expression, *medium, *duration, *filesize, *height, *width;
+ xmlChar *uri, *is_default, *expression, *medium, *duration, *filesize, *height, *width;
gboolean is_default_bool;
GDataMediaExpression expression_enum;
GDataMediaMedium medium_enum;
@@ -370,11 +370,9 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
return gdata_parser_error_required_property_missing (root_node, "url", error);
}
- content_type = xmlGetProp (root_node, (xmlChar*) "type");
-
- priv->uri = g_strdup ((gchar*) uri);
+ priv->uri = (gchar*) uri;
priv->filesize = filesize_ulong;
- priv->content_type = g_strdup ((gchar*) content_type);
+ priv->content_type = (gchar*) xmlGetProp (root_node, (xmlChar*) "type");
priv->medium = medium_enum;
priv->is_default = is_default_bool;
priv->expression = expression_enum;
@@ -382,9 +380,6 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
priv->height = height_uint;
priv->width = width_uint;
- xmlFree (uri);
- xmlFree (content_type);
-
return TRUE;
}
diff --git a/gdata/media/gdata-media-credit.c b/gdata/media/gdata-media-credit.c
index f90f28ed..2caa8ada 100644
--- a/gdata/media/gdata-media-credit.c
+++ b/gdata/media/gdata-media-credit.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -166,7 +166,8 @@ static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
GDataMediaCreditPrivate *priv = GDATA_MEDIA_CREDIT (parsable)->priv;
- xmlChar *credit, *scheme, *role;
+ xmlChar *credit;
+ gchar *scheme;
guint i;
credit = xmlNodeListGetString (doc, root_node->children, TRUE);
@@ -175,21 +176,19 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
return gdata_parser_error_required_content_missing (root_node, error);
}
- scheme = xmlGetProp (root_node, (xmlChar*) "scheme");
+ scheme = (gchar*) xmlGetProp (root_node, (xmlChar*) "scheme");
if (scheme != NULL && *scheme == '\0') {
- xmlFree (scheme);
+ g_free (scheme);
xmlFree (credit);
return gdata_parser_error_required_property_missing (root_node, "scheme", error);
} else if (scheme == NULL) {
/* Default */
- scheme = xmlStrdup ((xmlChar*) "urn:ebu");
+ scheme = g_strdup ("urn:ebu");
}
- role = xmlGetProp (root_node, (xmlChar*) "role");
-
- priv->credit = g_strdup ((gchar*) credit);
- priv->scheme = g_strdup ((gchar*) scheme);
- priv->role = g_strdup ((gchar*) role);
+ priv->credit = (gchar*) credit;
+ priv->scheme = scheme;
+ priv->role = (gchar*) xmlGetProp (root_node, (xmlChar*) "role");
/* Convert the role to lower case */
if (priv->role != NULL) {
@@ -197,10 +196,6 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
priv->role[i] = g_ascii_tolower (priv->role[i]);
}
- xmlFree (credit);
- xmlFree (scheme);
- xmlFree (role);
-
return TRUE;
}
diff --git a/gdata/media/gdata-media-group.c b/gdata/media/gdata-media-group.c
index f035e6b5..e0753ea0 100644
--- a/gdata/media/gdata-media-group.c
+++ b/gdata/media/gdata-media-group.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -142,19 +142,13 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
if (xmlStrcmp (node->name, (xmlChar*) "title") == 0) {
/* media:title */
- xmlChar *title = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_media_group_set_title (self, (gchar*) title);
- xmlFree (title);
+ self->priv->title = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "description") == 0) {
/* media:description */
- xmlChar *description = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_media_group_set_description (self, (gchar*) description);
- xmlFree (description);
+ self->priv->description = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "keywords") == 0) {
/* media:keywords */
- xmlChar *keywords = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_media_group_set_keywords (self, (gchar*) keywords);
- xmlFree (keywords);
+ self->priv->keywords = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "category") == 0) {
/* media:category */
GDataMediaCategory *category = GDATA_MEDIA_CATEGORY (_gdata_parsable_new_from_xml_node (GDATA_TYPE_MEDIA_CATEGORY, doc,
@@ -187,9 +181,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlChar *player_uri = xmlGetProp (node, (xmlChar*) "url");
g_free (self->priv->player_uri);
- self->priv->player_uri = g_strdup ((gchar*) player_uri);
-
- xmlFree (player_uri);
+ self->priv->player_uri = (gchar*) player_uri;
} else if (xmlStrcmp (node->name, (xmlChar*) "rating") == 0) {
/* media:rating */
xmlChar *countries;
diff --git a/gdata/media/gdata-media-thumbnail.c b/gdata/media/gdata-media-thumbnail.c
index f0a5dc71..a091555e 100644
--- a/gdata/media/gdata-media-thumbnail.c
+++ b/gdata/media/gdata-media-thumbnail.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -250,12 +250,6 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
guint width_uint, height_uint;
gint64 time_int64;
- uri = xmlGetProp (root_node, (xmlChar*) "url");
- if (uri == NULL || *uri == '\0') {
- xmlFree (uri);
- return gdata_parser_error_required_property_missing (root_node, "url", error);
- }
-
/* Get the width and height */
width = xmlGetProp (root_node, (xmlChar*) "width");
width_uint = (width == NULL) ? 0 : strtoul ((gchar*) width, NULL, 10);
@@ -279,13 +273,18 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
xmlFree (_time);
}
- priv->uri = g_strdup ((gchar*) uri);
+ /* Get the URI */
+ uri = xmlGetProp (root_node, (xmlChar*) "url");
+ if (uri == NULL || *uri == '\0') {
+ xmlFree (uri);
+ return gdata_parser_error_required_property_missing (root_node, "url", error);
+ }
+
+ priv->uri = (gchar*) uri;
priv->height = height_uint;
priv->width = width_uint;
priv->time = time_int64;
- xmlFree (uri);
-
return TRUE;
}
diff --git a/gdata/services/calendar/gdata-calendar-calendar.c b/gdata/services/calendar/gdata-calendar-calendar.c
index 0c6b05a8..9b2e72d5 100644
--- a/gdata/services/calendar/gdata-calendar-calendar.c
+++ b/gdata/services/calendar/gdata-calendar-calendar.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -200,7 +200,7 @@ gdata_calendar_calendar_finalize (GObject *object)
GDataCalendarCalendarPrivate *priv = GDATA_CALENDAR_CALENDAR_GET_PRIVATE (object);
g_free (priv->timezone);
- xmlFree ((xmlChar*) priv->access_level);
+ g_free (priv->access_level);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_calendar_calendar_parent_class)->finalize (object);
@@ -295,8 +295,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlChar *_timezone = xmlGetProp (node, (xmlChar*) "value");
if (_timezone == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- gdata_calendar_calendar_set_timezone (self, (gchar*) _timezone);
- xmlFree (_timezone);
+ self->priv->timezone = (gchar*) _timezone;
} else if (xmlStrcmp (node->name, (xmlChar*) "timesCleaned") == 0) {
/* gCal:timesCleaned */
xmlChar *times_cleaned = xmlGetProp (node, (xmlChar*) "value");
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index 7db30066..0262cfa6 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -328,8 +328,8 @@ gdata_calendar_event_finalize (GObject *object)
g_free (priv->transparency);
g_free (priv->uid);
g_free (priv->recurrence);
- xmlFree ((xmlChar*) priv->original_event_id);
- xmlFree ((xmlChar*) priv->original_event_uri);
+ g_free (priv->original_event_id);
+ g_free (priv->original_event_uri);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_calendar_event_parent_class)->finalize (object);
@@ -496,29 +496,25 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlChar *value = xmlGetProp (node, (xmlChar*) "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- gdata_calendar_event_set_status (self, (gchar*) value);
- xmlFree (value);
+ self->priv->status = (gchar*) value;
} else if (xmlStrcmp (node->name, (xmlChar*) "visibility") == 0) {
/* gd:visibility */
xmlChar *value = xmlGetProp (node, (xmlChar*) "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- gdata_calendar_event_set_visibility (self, (gchar*) value);
- xmlFree (value);
+ self->priv->visibility = (gchar*) value;
} else if (xmlStrcmp (node->name, (xmlChar*) "transparency") == 0) {
/* gd:transparency */
xmlChar *value = xmlGetProp (node, (xmlChar*) "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- gdata_calendar_event_set_transparency (self, (gchar*) value);
- xmlFree (value);
+ self->priv->transparency = (gchar*) value;
} else if (xmlStrcmp (node->name, (xmlChar*) "uid") == 0) {
/* gCal:uid */
xmlChar *value = xmlGetProp (node, (xmlChar*) "value");
if (value == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- gdata_calendar_event_set_uid (self, (gchar*) value);
- xmlFree (value);
+ self->priv->uid = (gchar*) value;
} else if (xmlStrcmp (node->name, (xmlChar*) "sequence") == 0) {
/* gCal:sequence */
xmlChar *value;
@@ -583,9 +579,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
gdata_calendar_event_add_place (self, where);
} else if (xmlStrcmp (node->name, (xmlChar*) "recurrence") == 0) {
/* gd:recurrence */
- xmlChar *recurrence = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_calendar_event_set_recurrence (self, (gchar*) recurrence);
- xmlFree (recurrence);
+ self->priv->recurrence = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "originalEvent") == 0) {
/* gd:originalEvent */
g_object_freeze_notify (G_OBJECT (self));
diff --git a/gdata/services/calendar/gdata-calendar-feed.c b/gdata/services/calendar/gdata-calendar-feed.c
index 7da90b96..4e0fa67a 100644
--- a/gdata/services/calendar/gdata-calendar-feed.c
+++ b/gdata/services/calendar/gdata-calendar-feed.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -102,7 +102,7 @@ gdata_calendar_feed_finalize (GObject *object)
{
GDataCalendarFeedPrivate *priv = GDATA_CALENDAR_FEED_GET_PRIVATE (object);
- xmlFree (priv->timezone);
+ g_free (priv->timezone);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_calendar_feed_parent_class)->finalize (object);
@@ -137,7 +137,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlChar *_timezone = xmlGetProp (node, (xmlChar*) "value");
if (_timezone == NULL)
return gdata_parser_error_required_property_missing (node, "value", error);
- xmlFree (self->priv->timezone);
+ g_free (self->priv->timezone);
self->priv->timezone = (gchar*) _timezone;
} else if (xmlStrcmp (node->name, (xmlChar*) "timesCleaned") == 0) {
/* gCal:timesCleaned */
diff --git a/gdata/services/contacts/gdata-contacts-contact.c b/gdata/services/contacts/gdata-contacts-contact.c
index 46264328..ba5c4f75 100644
--- a/gdata/services/contacts/gdata-contacts-contact.c
+++ b/gdata/services/contacts/gdata-contacts-contact.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -278,10 +278,10 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
if (g_time_val_from_iso8601 ((gchar*) edited, &(self->priv->edited)) == FALSE) {
/* Error */
gdata_parser_error_not_iso8601_format (node, (gchar*) edited, error);
- xmlFree (edited);
+ g_free (edited);
return FALSE;
}
- xmlFree (edited);
+ g_free (edited);
} else if (xmlStrcmp (node->name, (xmlChar*) "name") == 0) {
/* gd:name */
GDataGDName *name = GDATA_GD_NAME (_gdata_parsable_new_from_xml_node (GDATA_TYPE_GD_NAME, doc, node, NULL, error));
@@ -358,7 +358,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
if (buffer != NULL)
xmlBufferFree (buffer);
else
- xmlFree (value);
+ g_free (value);
} else if (xmlStrcmp (node->name, (xmlChar*) "groupMembershipInfo") == 0) {
/* gContact:groupMembershipInfo */
xmlChar *href, *deleted;
@@ -376,14 +376,13 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
deleted_bool = TRUE;
else {
gdata_parser_error_unknown_property_value (node, "deleted", (gchar*) deleted, error);
- xmlFree (deleted);
+ g_free (deleted);
return FALSE;
}
- xmlFree (deleted);
+ g_free (deleted);
/* Insert it into the hash table */
- g_hash_table_insert (self->priv->groups, g_strdup ((gchar*) href), GUINT_TO_POINTER (deleted_bool));
- xmlFree (href);
+ g_hash_table_insert (self->priv->groups, (gchar*) href, GUINT_TO_POINTER (deleted_bool));
} else if (xmlStrcmp (node->name, (xmlChar*) "deleted") == 0) {
/* gd:deleted */
self->priv->deleted = TRUE;
@@ -392,13 +391,9 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
if (self->priv->photo_etag == NULL && xmlStrcmp (node->name, (xmlChar*) "link") == 0) {
xmlChar *rel = xmlGetProp (node, (xmlChar*) "rel");
if (xmlStrcmp (rel, (xmlChar*) "http://schemas.google.com/contacts/2008/rel#photo") == 0) {
- xmlChar *etag;
-
/* It's the photo link (http://code.google.com/apis/contacts/docs/2.0/reference.html#Photos), whose ETag we should
* note down, then pass onto the parent class to parse properly */
- etag = xmlGetProp (node, (xmlChar*) "etag");
- self->priv->photo_etag = g_strdup ((gchar*) etag);
- xmlFree (etag);
+ self->priv->photo_etag = (gchar*) xmlGetProp (node, (xmlChar*) "etag");
}
xmlFree (rel);
}
diff --git a/gdata/services/documents/gdata-documents-feed.c b/gdata/services/documents/gdata-documents-feed.c
index d2442ef0..91e9e135 100644
--- a/gdata/services/documents/gdata-documents-feed.c
+++ b/gdata/services/documents/gdata-documents-feed.c
@@ -64,8 +64,9 @@ gdata_documents_feed_init (GDataDocumentsFeed *self)
/* Why am I writing it? */
}
-/* NOTE: Should be freed with xmlFree(), not g_free() */
-static xmlChar *
+/* NOTE: Cast from (xmlChar*) to (gchar*) (and corresponding change in memory management functions) is safe because we've changed
+ * libxml's memory functions. */
+static gchar *
get_kind (xmlDoc *doc, xmlNode *node)
{
xmlNode *entry_node;
@@ -76,7 +77,7 @@ get_kind (xmlDoc *doc, xmlNode *node)
if (xmlStrcmp (scheme, (xmlChar*) "http://schemas.google.com/g/2005#kind") == 0) {
xmlFree (scheme);
- return xmlGetProp (entry_node, (xmlChar*) "term");
+ return (gchar*) xmlGetProp (entry_node, (xmlChar*) "term");
}
xmlFree (scheme);
}
@@ -92,9 +93,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
if (xmlStrcmp (node->name, (xmlChar*) "entry") == 0) {
GDataEntry *entry = NULL;
- gchar *kind;
-
- kind = (gchar*) get_kind (doc, node);
+ gchar *kind = get_kind (doc, node);
if (g_strcmp0 (kind, "http://schemas.google.com/docs/2007#spreadsheet") == 0)
entry = GDATA_ENTRY (_gdata_parsable_new_from_xml_node (GDATA_TYPE_DOCUMENTS_SPREADSHEET, doc, node, NULL, error));
@@ -106,10 +105,10 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
entry = GDATA_ENTRY (_gdata_parsable_new_from_xml_node (GDATA_TYPE_DOCUMENTS_FOLDER, doc, node, NULL, error));
else {
g_message ("%s documents are not handled yet", kind);
- xmlFree (kind);
+ g_free (kind);
return TRUE;
}
- xmlFree (kind);
+ g_free (kind);
if (entry == NULL)
return FALSE;
diff --git a/gdata/services/picasaweb/gdata-picasaweb-album.c b/gdata/services/picasaweb/gdata-picasaweb-album.c
index e9604503..c3bd5562 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-album.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-album.c
@@ -2,7 +2,7 @@
/*
* GData Client
* Copyright (C) Richard Schwarting 2009 <aquarichy@gmail.com>
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -443,8 +443,8 @@ gdata_picasaweb_album_finalize (GObject *object)
{
GDataPicasaWebAlbumPrivate *priv = GDATA_PICASAWEB_ALBUM_GET_PRIVATE (object);
- xmlFree (priv->user);
- xmlFree (priv->nickname);
+ g_free (priv->user);
+ g_free (priv->nickname);
g_free (priv->location);
/* Chain up to the parent class */
@@ -574,14 +574,14 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlChar *user = xmlNodeListGetString (doc, node->children, TRUE);
if (user == NULL || *user == '\0')
return gdata_parser_error_required_content_missing (node, error);
- xmlFree (self->priv->user);
+ g_free (self->priv->user);
self->priv->user = (gchar*) user;
} else if (xmlStrcmp (node->name, (xmlChar*) "nickname") == 0) {
/* gphoto:nickname */
xmlChar *nickname = xmlNodeListGetString (doc, node->children, TRUE);
if (nickname == NULL || *nickname == '\0')
return gdata_parser_error_required_content_missing (node, error);
- xmlFree (self->priv->nickname);
+ g_free (self->priv->nickname);
self->priv->nickname = (gchar*) nickname;
} else if (xmlStrcmp (node->name, (xmlChar*) "edited") == 0) {
/* app:edited */
@@ -595,9 +595,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlFree (edited);
} else if (xmlStrcmp (node->name, (xmlChar*) "location") == 0) {
/* gphoto:location */
- xmlChar *location = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_picasaweb_album_set_location (self, (gchar*) location);
- xmlFree (location);
+ g_free (self->priv->location);
+ self->priv->location = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "access") == 0) {
/* gphoto:access */
xmlChar *access = xmlNodeListGetString (doc, node->children, TRUE);
@@ -628,35 +627,50 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
} else if (xmlStrcmp (node->name, (xmlChar*) "numphotos") == 0) {
/* gphoto:numphotos */
xmlChar *num_photos = xmlNodeListGetString (doc, node->children, TRUE);
- if (num_photos == NULL || *num_photos == '\0')
+ if (num_photos == NULL || *num_photos == '\0') {
+ xmlFree (num_photos);
return gdata_parser_error_required_content_missing (node, error);
+ }
+
self->priv->num_photos = strtoul ((char*) num_photos, NULL, 10);
xmlFree (num_photos);
} else if (xmlStrcmp (node->name, (xmlChar*) "numphotosremaining") == 0) {
/* gphoto:numphotosremaining */
xmlChar *num_photos_remaining = xmlNodeListGetString (doc, node->children, TRUE);
- if (num_photos_remaining == NULL || *num_photos_remaining == '\0')
+ if (num_photos_remaining == NULL || *num_photos_remaining == '\0') {
+ xmlFree (num_photos_remaining);
return gdata_parser_error_required_content_missing (node, error);
+ }
+
self->priv->num_photos_remaining = strtoul ((char*) num_photos_remaining, NULL, 10);
xmlFree (num_photos_remaining);
} else if (xmlStrcmp (node->name, (xmlChar*) "bytesUsed") == 0) {
/* gphoto:bytesUsed */
xmlChar *bytes_used = xmlNodeListGetString (doc, node->children, TRUE);
- if (bytes_used == NULL || *bytes_used == '\0')
+ if (bytes_used == NULL || *bytes_used == '\0') {
+ xmlFree (bytes_used);
return gdata_parser_error_required_content_missing (node, error);
+ }
+
self->priv->bytes_used = strtol ((char*) bytes_used, NULL, 10);
xmlFree (bytes_used);
} else if (xmlStrcmp (node->name, (xmlChar*) "commentingEnabled") == 0) {
/* gphoto:commentingEnabled */
xmlChar *commenting_enabled = xmlNodeListGetString (doc, node->children, TRUE);
- if (commenting_enabled == NULL || *commenting_enabled == '\0')
+ if (commenting_enabled == NULL || *commenting_enabled == '\0') {
+ xmlFree (commenting_enabled);
return gdata_parser_error_required_content_missing (node, error);
+ }
+
gdata_picasaweb_album_set_is_commenting_enabled (self, (xmlStrcmp (commenting_enabled, (xmlChar*) "true") == 0) ? TRUE : FALSE);
xmlFree (commenting_enabled);
} else if (xmlStrcmp (node->name, (xmlChar*) "commentCount") == 0) {
xmlChar *comment_count = xmlNodeListGetString (doc, node->children, TRUE);
- if (comment_count == NULL || *comment_count == '\0')
+ if (comment_count == NULL || *comment_count == '\0') {
+ xmlFree (comment_count);
return gdata_parser_error_required_content_missing (node, error);
+ }
+
self->priv->comment_count = strtoul ((char*) comment_count, NULL, 10);
xmlFree (comment_count);
} else if (GDATA_PARSABLE_CLASS (gdata_picasaweb_album_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
diff --git a/gdata/services/picasaweb/gdata-picasaweb-file.c b/gdata/services/picasaweb/gdata-picasaweb-file.c
index edcf852b..488addf5 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-file.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-file.c
@@ -2,7 +2,7 @@
/*
* GData Client
* Copyright (C) Richard Schwarting 2009 <aquarichy@gmail.com>
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -630,7 +630,7 @@ gdata_picasaweb_file_finalize (GObject *object)
g_free (priv->album_id);
g_free (priv->client);
g_free (priv->checksum);
- xmlFree (priv->video_status);
+ g_free (priv->video_status);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_picasaweb_file_parent_class)->finalize (object);
@@ -837,10 +837,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlFree (edited);
} else if (xmlStrcmp (node->name, (xmlChar*) "imageVersion") == 0) {
/* gphoto:imageVersion */
- xmlChar *version = xmlNodeListGetString (doc, node->children, TRUE);
g_free (self->priv->version);
- self->priv->version = g_strdup ((gchar*) version);
- xmlFree (version);
+ self->priv->version = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "position") == 0) {
/* gphoto:position */
xmlChar *position_str = xmlNodeListGetString (doc, node->children, TRUE);
@@ -848,9 +846,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlFree (position_str);
} else if (xmlStrcmp (node->name, (xmlChar*) "albumid") == 0) {
/* gphoto:album_id */
- xmlChar *album_id = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_picasaweb_file_set_album_id (self, (gchar*) album_id);
- xmlFree (album_id);
+ self->priv->album_id = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "width") == 0) {
/* gphoto:width */
xmlChar *width = xmlNodeListGetString (doc, node->children, TRUE);
@@ -868,14 +864,10 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlFree (size);
} else if (xmlStrcmp (node->name, (xmlChar*) "client") == 0) {
/* gphoto:client */
- xmlChar *client = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_picasaweb_file_set_client (self, (gchar*) client);
- xmlFree (client);
+ self->priv->client = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "checksum") == 0) {
/* gphoto:checksum */
- xmlChar *checksum = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_picasaweb_file_set_checksum (self, (gchar*) checksum);
- xmlFree (checksum);
+ self->priv->checksum = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "timestamp") == 0) {
/* gphoto:timestamp */
xmlChar *timestamp_str;
diff --git a/gdata/services/picasaweb/gdata-picasaweb-user.c b/gdata/services/picasaweb/gdata-picasaweb-user.c
index 77f7a7be..036a100d 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-user.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-user.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
* Copyright (C) Richard Schwarting 2009 <aquarichy@gmail.com>
*
* GData Client is free software; you can redistribute it and/or
@@ -174,9 +174,9 @@ gdata_picasaweb_user_finalize (GObject *object)
{
GDataPicasaWebUserPrivate *priv = GDATA_PICASAWEB_USER_GET_PRIVATE (object);
- xmlFree ((xmlChar*) priv->user);
- xmlFree ((xmlChar*) priv->nickname);
- xmlFree ((xmlChar*) priv->thumbnail_uri);
+ g_free (priv->user);
+ g_free (priv->nickname);
+ g_free (priv->thumbnail_uri);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_picasaweb_user_parent_class)->finalize (object);
@@ -221,16 +221,22 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
if (xmlStrcmp (node->name, (xmlChar*) "user") == 0) {
/* gphoto:user */
xmlChar *user = xmlNodeListGetString (doc, node->children, TRUE);
- if (user == NULL || *user == '\0')
+ if (user == NULL || *user == '\0') {
+ g_free (user);
return gdata_parser_error_required_content_missing (node, error);
- xmlFree (self->priv->user);
+ }
+
+ g_free (self->priv->user);
self->priv->user = (gchar*) user;
} else if (xmlStrcmp (node->name, (xmlChar*) "nickname") == 0) {
/* gphoto:nickname */
xmlChar *nickname = xmlNodeListGetString (doc, node->children, TRUE);
- if (nickname == NULL || *nickname == '\0')
+ if (nickname == NULL || *nickname == '\0') {
+ g_free (nickname);
return gdata_parser_error_required_content_missing (node, error);
- xmlFree (self->priv->nickname);
+ }
+
+ g_free (self->priv->nickname);
self->priv->nickname = (gchar*) nickname;
} else if (xmlStrcmp (node->name, (xmlChar*) "quotacurrent") == 0) {
/* gphoto:quota-current */
@@ -250,9 +256,12 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
} else if (xmlStrcmp (node->name, (xmlChar*) "thumbnail") == 0) {
/* gphoto:thumbnail */
xmlChar *thumbnail = xmlNodeListGetString (doc, node->children, TRUE);
- if (thumbnail == NULL || *thumbnail == '\0')
+ if (thumbnail == NULL || *thumbnail == '\0') {
+ g_free (thumbnail);
return gdata_parser_error_required_content_missing (node, error);
- xmlFree (self->priv->thumbnail_uri);
+ }
+
+ g_free (self->priv->thumbnail_uri);
self->priv->thumbnail_uri = (gchar*) thumbnail;
} else if (xmlStrcmp (node->name, (xmlChar*) "x-allowDownloads") == 0) { /* RHSTODO: see if this comes with the user */
/* gphoto:allowDownloads */
diff --git a/gdata/services/youtube/gdata-youtube-credit.c b/gdata/services/youtube/gdata-youtube-credit.c
index f2f672b6..2827e8da 100644
--- a/gdata/services/youtube/gdata-youtube-credit.c
+++ b/gdata/services/youtube/gdata-youtube-credit.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -96,7 +96,7 @@ gdata_youtube_credit_finalize (GObject *object)
{
GDataYouTubeCreditPrivate *priv = GDATA_YOUTUBE_CREDIT (object)->priv;
- xmlFree (priv->entity_type);
+ g_free (priv->entity_type);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_youtube_credit_parent_class)->finalize (object);
diff --git a/gdata/services/youtube/gdata-youtube-group.c b/gdata/services/youtube/gdata-youtube-group.c
index 87822d46..adeae5fe 100644
--- a/gdata/services/youtube/gdata-youtube-group.c
+++ b/gdata/services/youtube/gdata-youtube-group.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -81,7 +81,7 @@ gdata_youtube_group_finalize (GObject *object)
{
GDataYouTubeGroupPrivate *priv = GDATA_YOUTUBE_GROUP (object)->priv;
- xmlFree (priv->video_id);
+ g_free (priv->video_id);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_youtube_group_parent_class)->finalize (object);
diff --git a/gdata/services/youtube/gdata-youtube-state.c b/gdata/services/youtube/gdata-youtube-state.c
index 74b5dc67..48641b95 100644
--- a/gdata/services/youtube/gdata-youtube-state.c
+++ b/gdata/services/youtube/gdata-youtube-state.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -151,10 +151,10 @@ gdata_youtube_state_finalize (GObject *object)
{
GDataYouTubeStatePrivate *priv = GDATA_YOUTUBE_STATE (object)->priv;
- xmlFree (priv->name);
- xmlFree (priv->reason_code);
- xmlFree (priv->help_uri);
- xmlFree (priv->message);
+ g_free (priv->name);
+ g_free (priv->reason_code);
+ g_free (priv->help_uri);
+ g_free (priv->message);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_youtube_state_parent_class)->finalize (object);
@@ -189,22 +189,18 @@ static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
GDataYouTubeStatePrivate *priv = GDATA_YOUTUBE_STATE (parsable)->priv;
- xmlChar *name, *message, *reason_code, *help_uri;
+ xmlChar *name;
name = xmlGetProp (root_node, (xmlChar*) "name");
if (name == NULL || *name == '\0') {
- xmlFree (name);
+ g_free (name);
return gdata_parser_error_required_property_missing (root_node, "name", error);
}
- message = xmlNodeListGetString (doc, root_node->children, TRUE);
- reason_code = xmlGetProp (root_node, (xmlChar*) "reasonCode");
- help_uri = xmlGetProp (root_node, (xmlChar*) "helpUrl");
-
priv->name = (gchar*) name;
- priv->reason_code = (gchar*) reason_code;
- priv->help_uri = (gchar*) help_uri;
- priv->message = (gchar*) message;
+ 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);
return TRUE;
}
diff --git a/gdata/services/youtube/gdata-youtube-video.c b/gdata/services/youtube/gdata-youtube-video.c
index 154b252a..2896133a 100644
--- a/gdata/services/youtube/gdata-youtube-video.c
+++ b/gdata/services/youtube/gdata-youtube-video.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2008-2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2008–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -750,9 +750,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlFree (favorite_count);
} else if (xmlStrcmp (node->name, (xmlChar*) "location") == 0) {
/* yt:location */
- xmlChar *location = xmlNodeListGetString (doc, node->children, TRUE);
- gdata_youtube_video_set_location (self, (gchar*) location);
- xmlFree (location);
+ g_free (self->priv->location);
+ self->priv->location = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "noembed") == 0) {
/* yt:noembed */
gdata_youtube_video_set_no_embed (self, TRUE);
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 40400ad3..7329d6a4 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2008-2009 <philip@tecnocode.co.uk>
+ * Copyright (C) Philip Withnall 2008–2010 <philip@tecnocode.co.uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1002,7 +1002,9 @@ test_atom_generator (void)
/* …and a different generator */
generator2 = GDATA_GENERATOR (gdata_parsable_new_from_xml (GDATA_TYPE_GENERATOR,
- "<generator>Different generator</generator>", -1, NULL));
+ "<generator>Different generator</generator>", -1, &error));
+ g_assert_no_error (error);
+ g_assert (GDATA_IS_GENERATOR (generator));
g_assert_cmpint (gdata_generator_compare (generator, generator2), !=, 0);
g_object_unref (generator2);