From 5c0d938cf15d07c0f7511c5acb9a3d8e42278e0d Mon Sep 17 00:00:00 2001 From: Marco Barisione Date: Fri, 10 May 2013 16:08:28 +0100 Subject: tpaw-utils: move empathy_xml_validate_from_resource to tp-aw and rename it This commit also changes the licence of the moved code (all copyrighted by Collabora Ltd.) from GPL to LGPL. https://bugzilla.gnome.org/show_bug.cgi?id=699492 --- libempathy/empathy-chatroom-manager.c | 3 ++- libempathy/empathy-contact-groups.c | 3 ++- libempathy/empathy-status-presets.c | 3 ++- libempathy/empathy-utils.c | 35 ----------------------------------- libempathy/empathy-utils.h | 2 -- 5 files changed, 6 insertions(+), 40 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index 3f1828612..215d8edbc 100644 --- a/libempathy/empathy-chatroom-manager.c +++ b/libempathy/empathy-chatroom-manager.c @@ -25,6 +25,7 @@ #include "empathy-chatroom-manager.h" #include +#include #include "empathy-client-factory.h" #include "empathy-utils.h" @@ -320,7 +321,7 @@ chatroom_manager_file_parse (EmpathyChatroomManager *manager, return FALSE; } - if (!empathy_xml_validate_from_resource (doc, CHATROOMS_DTD_RESOURCENAME)) + if (!tpaw_xml_validate_from_resource (doc, CHATROOMS_DTD_RESOURCENAME)) { g_warning ("Failed to validate file:'%s'", filename); xmlFreeDoc (doc); diff --git a/libempathy/empathy-contact-groups.c b/libempathy/empathy-contact-groups.c index 81a1b3133..7818eb557 100644 --- a/libempathy/empathy-contact-groups.c +++ b/libempathy/empathy-contact-groups.c @@ -24,6 +24,7 @@ #include "empathy-contact-groups.h" #include +#include #include "empathy-utils.h" @@ -91,7 +92,7 @@ contact_groups_file_parse (const gchar *filename) return; } - if (!empathy_xml_validate_from_resource (doc, CONTACT_GROUPS_DTD_RESOURCENAME)) { + if (!tpaw_xml_validate_from_resource (doc, CONTACT_GROUPS_DTD_RESOURCENAME)) { g_warning ("Failed to validate file:'%s'", filename); xmlFreeDoc (doc); xmlFreeParserCtxt (ctxt); diff --git a/libempathy/empathy-status-presets.c b/libempathy/empathy-status-presets.c index 0e651f074..9895d4d42 100644 --- a/libempathy/empathy-status-presets.c +++ b/libempathy/empathy-status-presets.c @@ -24,6 +24,7 @@ #include "empathy-status-presets.h" #include +#include #include "empathy-utils.h" @@ -92,7 +93,7 @@ status_presets_file_parse (const gchar *filename) return; } - if (!empathy_xml_validate_from_resource (doc, STATUS_PRESETS_DTD_RESOURCENAME)) { + if (!tpaw_xml_validate_from_resource (doc, STATUS_PRESETS_DTD_RESOURCENAME)) { g_warning ("Failed to validate file:'%s'", filename); xmlFreeDoc (doc); xmlFreeParserCtxt (ctxt); diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 659d4d507..ba39f49b7 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -107,41 +107,6 @@ empathy_init (void) g_object_unref (am); } -gboolean -empathy_xml_validate_from_resource (xmlDoc *doc, - const gchar *dtd_resourcename) -{ - GBytes *resourcecontents; - gconstpointer resourcedata; - gsize resourcesize; - xmlParserInputBufferPtr buffer; - xmlValidCtxt cvp; - xmlDtd *dtd; - GError *error = NULL; - gboolean ret; - - DEBUG ("Loading dtd resource %s", dtd_resourcename); - - resourcecontents = g_resources_lookup_data (dtd_resourcename, G_RESOURCE_LOOKUP_FLAGS_NONE, &error); - if (error != NULL) - { - g_warning ("Unable to load dtd resource '%s': %s", dtd_resourcename, error->message); - g_error_free (error); - return FALSE; - } - resourcedata = g_bytes_get_data (resourcecontents, &resourcesize); - buffer = xmlParserInputBufferCreateStatic (resourcedata, resourcesize, XML_CHAR_ENCODING_UTF8); - - memset (&cvp, 0, sizeof (cvp)); - dtd = xmlIOParseDTD (NULL, buffer, XML_CHAR_ENCODING_UTF8); - ret = xmlValidateDtd (&cvp, doc, dtd); - - xmlFreeDtd (dtd); - g_bytes_unref (resourcecontents); - - return ret; -} - xmlNodePtr empathy_xml_node_get_child (xmlNodePtr node, const gchar *child_name) diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index c62083241..7310320b1 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -43,8 +43,6 @@ G_BEGIN_DECLS void empathy_init (void); /* XML */ -gboolean empathy_xml_validate_from_resource (xmlDoc *doc, - const gchar *dtd_resourcename); xmlNodePtr empathy_xml_node_get_child (xmlNodePtr node, const gchar *child_name); xmlChar * empathy_xml_node_get_child_content (xmlNodePtr node, -- cgit v1.2.3