aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Barisione <marco.barisione@collabora.co.uk>2013-05-10 23:08:28 +0800
committerMarco Barisione <marco.barisione@collabora.co.uk>2013-08-20 18:03:06 +0800
commit5c0d938cf15d07c0f7511c5acb9a3d8e42278e0d (patch)
tree6335337894b545d7c1a232ae4d214c4eeb9990a5
parent4598bce7db6276a9f1f9e21adef8723b646bf44b (diff)
downloadgsoc2013-empathy-5c0d938cf15d07c0f7511c5acb9a3d8e42278e0d.tar
gsoc2013-empathy-5c0d938cf15d07c0f7511c5acb9a3d8e42278e0d.tar.gz
gsoc2013-empathy-5c0d938cf15d07c0f7511c5acb9a3d8e42278e0d.tar.bz2
gsoc2013-empathy-5c0d938cf15d07c0f7511c5acb9a3d8e42278e0d.tar.lz
gsoc2013-empathy-5c0d938cf15d07c0f7511c5acb9a3d8e42278e0d.tar.xz
gsoc2013-empathy-5c0d938cf15d07c0f7511c5acb9a3d8e42278e0d.tar.zst
gsoc2013-empathy-5c0d938cf15d07c0f7511c5acb9a3d8e42278e0d.zip
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
-rw-r--r--libempathy/empathy-chatroom-manager.c3
-rw-r--r--libempathy/empathy-contact-groups.c3
-rw-r--r--libempathy/empathy-status-presets.c3
-rw-r--r--libempathy/empathy-utils.c35
-rw-r--r--libempathy/empathy-utils.h2
-rw-r--r--tp-account-widgets/tpaw-irc-network-manager.c3
-rw-r--r--tp-account-widgets/tpaw-utils.c36
-rw-r--r--tp-account-widgets/tpaw-utils.h6
8 files changed, 50 insertions, 41 deletions
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 <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);
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 <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);
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 <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);
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,
diff --git a/tp-account-widgets/tpaw-irc-network-manager.c b/tp-account-widgets/tpaw-irc-network-manager.c
index e6fdebacc..12c73d6d3 100644
--- a/tp-account-widgets/tpaw-irc-network-manager.c
+++ b/tp-account-widgets/tpaw-irc-network-manager.c
@@ -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);
diff --git a/tp-account-widgets/tpaw-utils.c b/tp-account-widgets/tpaw-utils.c
index 933b8570e..a31fc2681 100644
--- a/tp-account-widgets/tpaw-utils.c
+++ b/tp-account-widgets/tpaw-utils.c
@@ -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,
diff --git a/tp-account-widgets/tpaw-utils.h b/tp-account-widgets/tpaw-utils.h
index f82b5a6f7..8a40dc93b 100644
--- a/tp-account-widgets/tpaw-utils.h
+++ b/tp-account-widgets/tpaw-utils.h
@@ -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 */