]> git.0d.be Git - empathy.git/commitdiff
tpaw-utils: move empathy_xml_validate_from_resource to tp-aw and rename it
authorMarco Barisione <marco.barisione@collabora.co.uk>
Fri, 10 May 2013 15:08:28 +0000 (16:08 +0100)
committerMarco Barisione <marco.barisione@collabora.co.uk>
Tue, 20 Aug 2013 10:03:06 +0000 (11:03 +0100)
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
libempathy/empathy-contact-groups.c
libempathy/empathy-status-presets.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h
tp-account-widgets/tpaw-irc-network-manager.c
tp-account-widgets/tpaw-utils.c
tp-account-widgets/tpaw-utils.h

index 3f1828612fd75983c7bc172a0b19be175100b926..215d8edbc76f3598df7c0f711bc2800ae1613b99 100644 (file)
@@ -25,6 +25,7 @@
 #include "empathy-chatroom-manager.h"
 
 #include <sys/stat.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
 #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);
index 81a1b3133f681591419f1af467e4fe0acf552959..7818eb5573212c0fd7d704d71435504ab924fd30 100644 (file)
@@ -24,6 +24,7 @@
 #include "empathy-contact-groups.h"
 
 #include <sys/stat.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
 #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);
index 0e651f074ccca812bd88e12f0c19038d66dc13e5..9895d4d42ca9bf2144c433672f90e869ceaa43cf 100644 (file)
@@ -24,6 +24,7 @@
 #include "empathy-status-presets.h"
 
 #include <sys/stat.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
 #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);
index 659d4d50761554e7af1b763cade8c2af3aee9e04..ba39f49b7fa7f96a574a5953e47f8056afc5b939 100644 (file)
@@ -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)
index c62083241b5d3ac45ac43e459f8738f3b84522aa..7310320b169afd50895f9b9c70b2dd1b1ad46766 100644 (file)
@@ -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,
index e6fdebaccb75d6969d201c6e55cc10a86e9161fd..12c73d6d3f06ea34dfa32bbfa28c0df8b0529d64 100644 (file)
@@ -24,6 +24,7 @@
 #include <sys/stat.h>
 
 #include "empathy-utils.h"
+#include "tpaw-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_IRC
 #include "empathy-debug.h"
@@ -632,7 +633,7 @@ irc_network_manager_file_parse (TpawIrcNetworkManager *self,
       return FALSE;
     }
 
-  if (!empathy_xml_validate_from_resource (doc, IRC_NETWORKS_DTD_RESOURCENAME)) {
+  if (!tpaw_xml_validate_from_resource (doc, IRC_NETWORKS_DTD_RESOURCENAME)) {
     g_warning ("Failed to validate file:'%s'", filename);
     xmlFreeDoc (doc);
     xmlFreeParserCtxt (ctxt);
index 933b8570ede5b25a58f3ea4a56bdab4bb624d92e..a31fc26813bd7b655c77f3000b49a025e85e9291 100644 (file)
@@ -12,6 +12,7 @@
  *          Richard Hult <richard@imendio.com>
  *          Martyn Russell <martyn@imendio.com>
  *          Steve Frécinaux <code@istique.net>
+ *          Emanuele Aina <emanuele.aina@collabora.co.uk>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -181,6 +182,41 @@ tpaw_make_color_whiter (GdkRGBA *color)
   color->blue = (color->blue + white.blue) / 2;
 }
 
+gboolean
+tpaw_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;
+}
+
 /* Takes care of moving the window to the current workspace. */
 void
 tpaw_window_present_with_time (GtkWindow *window,
index f82b5a6f72b86354b09110d208636232fee8e5ac..8a40dc93bbfdea9437e6037e37e2e73bc1be519e 100644 (file)
@@ -12,6 +12,7 @@
  *          Richard Hult <richard@imendio.com>
  *          Martyn Russell <martyn@imendio.com>
  *          Steve Frécinaux <code@istique.net>
+ *          Emanuele Aina <emanuele.aina@collabora.co.uk>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,6 +34,7 @@
 
 #include <glib.h>
 #include <gtk/gtk.h>
+#include <libxml/tree.h>
 #include <telepathy-glib/telepathy-glib.h>
 
 G_BEGIN_DECLS
@@ -44,6 +46,10 @@ gchar *tpaw_protocol_icon_name (const gchar *protocol);
 const gchar *tpaw_protocol_name_to_display_name (const gchar *proto_name);
 const gchar *tpaw_service_name_to_display_name (const gchar *proto_name);
 
+/* XML */
+gboolean tpaw_xml_validate_from_resource (xmlDoc *doc,
+    const gchar *dtd_resourcename);
+
 void  tpaw_make_color_whiter (GdkRGBA *color);
 
 /* Windows */