[libgdata/gxml] * convert documents to gxml
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/gxml] * convert documents to gxml
- Date: Sat, 24 Sep 2011 06:22:54 +0000 (UTC)
commit 2e62e2950da85f7ab929a0194051484b1ba41dff
Author: Richard Schwarting <aquarichy gmail com>
Date: Sat Jul 23 15:25:51 2011 -0400
* convert documents to gxml
gdata/services/documents/gdata-documents-entry.c | 28 +++++++++--------
gdata/services/documents/gdata-documents-feed.c | 31 +++++++++++---------
gdata/services/documents/gdata-documents-folder.c | 2 +-
.../documents/gdata-documents-spreadsheet.c | 2 +-
4 files changed, 34 insertions(+), 29 deletions(-)
---
diff --git a/gdata/services/documents/gdata-documents-entry.c b/gdata/services/documents/gdata-documents-entry.c
index f8df79f..b5dd602 100644
--- a/gdata/services/documents/gdata-documents-entry.c
+++ b/gdata/services/documents/gdata-documents-entry.c
@@ -91,7 +91,7 @@
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include <string.h>
#include "gdata-documents-entry.h"
@@ -114,7 +114,7 @@ static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
static void get_xml (GDataParsable *parsable, GString *xml_string);
static void gdata_documents_entry_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gdata_documents_entry_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
+static gboolean parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error);
struct _GDataDocumentsEntryPrivate {
gint64 edited;
@@ -404,10 +404,12 @@ gdata_documents_entry_set_property (GObject *object, guint property_id, const GV
}
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;
GDataDocumentsEntry *self = GDATA_DOCUMENTS_ENTRY (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) {
@@ -420,30 +422,30 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
gdata_parser_object_from_element (node, "lastModifiedBy", P_REQUIRED, GDATA_TYPE_AUTHOR,
&(self->priv->last_modified_by), &success, error) == TRUE) {
return success;
- } else if (xmlStrcmp (node->name, (xmlChar*) "deleted") == 0) {
+ } else if (g_strcmp0 (node_name, "deleted") == 0) {
/* <gd:deleted> */
/* Note that it doesn't have any parameters, so we unconditionally set priv->is_deleted to TRUE */
self->priv->is_deleted = TRUE;
- } else if (xmlStrcmp (node->name, (xmlChar*) "resourceId") == 0) {
+ } else if (g_strcmp0 (node_name, "resourceId") == 0) {
gchar **document_id_parts;
- xmlChar *resource_id;
+ gchar *resource_id;
if (self->priv->document_id != NULL)
return gdata_parser_error_duplicate_element (node, error);
- resource_id = xmlNodeListGetString (doc, node->children, TRUE);
+ resource_id = gxml_dom_element_get_content (elem);
if (resource_id == NULL || *resource_id == '\0') {
- xmlFree (resource_id);
+ g_free (resource_id);
return gdata_parser_error_required_content_missing (node, error);
}
- document_id_parts = g_strsplit ((gchar*) resource_id, ":", 2);
+ document_id_parts = g_strsplit (resource_id, ":", 2);
if (document_id_parts == NULL) {
- gdata_parser_error_unknown_content (node, (gchar*) resource_id, error);
- xmlFree (resource_id);
+ gdata_parser_error_unknown_content (node, resource_id, error);
+ g_free (resource_id);
return FALSE;
}
- xmlFree (resource_id);
+ g_free (resource_id);
self->priv->document_id = g_strdup (document_id_parts[1]);
g_strfreev (document_id_parts);
@@ -451,7 +453,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
return GDATA_PARSABLE_CLASS (gdata_documents_entry_parent_class)->parse_xml (parsable, doc, node, user_data, error);
}
} else if (gdata_parser_is_namespace (node, "http://schemas.google.com/docs/2007") == TRUE &&
- xmlStrcmp (node->name, (xmlChar*) "writersCanInvite") == 0) {
+ g_strcmp0 (node_name, "writersCanInvite") == 0) {
if (gdata_parser_boolean_from_property (node, "value", &(self->priv->writers_can_invite), -1, error) == FALSE)
return FALSE;
} else {
diff --git a/gdata/services/documents/gdata-documents-feed.c b/gdata/services/documents/gdata-documents-feed.c
index 24b8728..6fcf0c8 100644
--- a/gdata/services/documents/gdata-documents-feed.c
+++ b/gdata/services/documents/gdata-documents-feed.c
@@ -36,7 +36,7 @@
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include <string.h>
#include "gdata-documents-feed.h"
@@ -49,7 +49,7 @@
#include "gdata-private.h"
#include "gdata-service.h"
-static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
+static gboolean parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
G_DEFINE_TYPE (GDataDocumentsFeed, gdata_documents_feed, GDATA_TYPE_FEED)
@@ -66,22 +66,24 @@ gdata_documents_feed_init (GDataDocumentsFeed *self)
/* Why am I writing it? */
}
-/* NOTE: Cast from (xmlChar*) to (gchar*) (and corresponding change in memory management functions) is safe because we've changed
+/* NOTE: Cast from 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)
+get_kind (GXmlDomDocument *doc, GXmlDomXNode *node)
{
- xmlNode *entry_node;
+ GXmlDomXNode *entry_node;
+ GXmlDomElement *entry_elem;
- for (entry_node = node->children; entry_node != NULL; entry_node = entry_node->next) {
- if (xmlStrcmp (entry_node->name, (xmlChar*) "category") == 0) {
- xmlChar *scheme = xmlGetProp (entry_node, (xmlChar*) "scheme");
+ for (entry_node = gxml_dom_xnode_get_first_child (node); entry_node != NULL; entry_node = gxml_dom_xnode_get_next_sibling (entry_node)) {
+ if (g_strcmp0 (gxml_dom_xnode_get_node_name (entry_node), "category") == 0) {
+ entry_elem = GXML_DOM_ELEMENT (entry_node);
+ gchar *scheme = gxml_dom_element_get_attribute (entry_elem, "scheme");
- if (xmlStrcmp (scheme, (xmlChar*) "http://schemas.google.com/g/2005#kind") == 0) {
- xmlFree (scheme);
- return (gchar*) xmlGetProp (entry_node, (xmlChar*) "term");
+ if (g_strcmp0 (scheme, "http://schemas.google.com/g/2005#kind") == 0) {
+ g_free (scheme);
+ return gxml_dom_element_get_attribute (entry_elem, "term");
}
- xmlFree (scheme);
+ g_free (scheme);
}
}
@@ -89,12 +91,13 @@ get_kind (xmlDoc *doc, xmlNode *node)
}
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)
{
GDataDocumentsFeed *self = GDATA_DOCUMENTS_FEED (parsable);
+ const gchar *node_name = gxml_dom_xnode_get_node_name (node);
if (gdata_parser_is_namespace (node, "http://www.w3.org/2005/Atom") == TRUE &&
- xmlStrcmp (node->name, (xmlChar*) "entry") == 0) {
+ g_strcmp0 (node_name, "entry") == 0) {
GDataEntry *entry = NULL;
gchar *kind = get_kind (doc, node);
diff --git a/gdata/services/documents/gdata-documents-folder.c b/gdata/services/documents/gdata-documents-folder.c
index 4c8b794..f2b4ebb 100644
--- a/gdata/services/documents/gdata-documents-folder.c
+++ b/gdata/services/documents/gdata-documents-folder.c
@@ -70,7 +70,7 @@
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include <string.h>
#include "gdata-documents-folder.h"
diff --git a/gdata/services/documents/gdata-documents-spreadsheet.c b/gdata/services/documents/gdata-documents-spreadsheet.c
index 084d34a..61570f5 100644
--- a/gdata/services/documents/gdata-documents-spreadsheet.c
+++ b/gdata/services/documents/gdata-documents-spreadsheet.c
@@ -89,7 +89,7 @@
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include <string.h>
#include "gdata-documents-spreadsheet.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]