]> git.0d.be Git - empathy.git/commitdiff
Embed DTDs for XML validation as GResources
authorEmanuele Aina <emanuele.aina@collabora.com>
Tue, 26 Mar 2013 12:09:29 +0000 (13:09 +0100)
committerEmanuele Aina <emanuele.aina@collabora.com>
Mon, 1 Apr 2013 09:50:29 +0000 (11:50 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=696974

libempathy/.gitignore
libempathy/Makefile.am
libempathy/empathy-chatroom-manager.c
libempathy/empathy-contact-groups.c
libempathy/empathy-dtd.gresource.xml [new file with mode: 0644]
libempathy/empathy-irc-network-manager.c
libempathy/empathy-status-presets.c

index 8617dcbd0deb97667d1242da49d655ab95f42df3..5cc6b339701d85ff9faae849dcc8cb30ad0daa8b 100644 (file)
@@ -1,4 +1,5 @@
 empathy-chandler-glue.h
+empathy-dtd-resources.[ch]
 empathy-marshal.*
 empathy-filter-glue.h
 tp-stream-engine-gen.h
index 36de4d6c2ee04844445a455e1a06f15b0d00017a..77484d2f12e379efe16e156ad2cbdac0fa9a26c5 100644 (file)
@@ -21,6 +21,8 @@ AM_CPPFLAGS =                                           \
        $(DISABLE_DEPRECATED)
 
 BUILT_SOURCES =                                        \
+       empathy-dtd-resources.c                         \
+       empathy-dtd-resources.h                         \
        empathy-enum-types.h                            \
        empathy-enum-types.c
 
@@ -134,8 +136,7 @@ libempathy_la_LIBADD =              \
        $(UOA_LIBS) \
        $(LIBM)
 
-dtddir = $(datadir)/empathy
-dtd_DATA =                                     \
+dtd_resources_files =                          \
        empathy-status-presets.dtd              \
        empathy-contact-groups.dtd              \
        empathy-chatroom-manager.dtd            \
@@ -145,8 +146,17 @@ ircnetworksdir = $(datadir)/empathy
 ircnetworks_DATA =             \
        irc-networks.xml
 
-EXTRA_DIST =                   \
-       $(dtd_DATA)             \
+dtd_resource_files: $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/empathy-dtd.gresource.xml)
+
+empathy-dtd-resources.c: empathy-dtd.gresource.xml $(dtd_resource_files)
+       $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $<
+
+empathy-dtd-resources.h: empathy-dtd.gresource.xml $(dtd_resource_files)
+       $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-header $<
+
+EXTRA_DIST =                           \
+       empathy-dtd.gresource.xml       \
+       $(dtd_resources_files)          \
        $(ircnetworks_DATA)
 
 CLEANFILES =                           \
index ebdc504333a5e883276ae4820d23e353a0ea232a..7a6532f3e8bdc47e473ecfe8a6b5c1663543a5e0 100644 (file)
@@ -33,7 +33,7 @@
 #include "empathy-debug.h"
 
 #define CHATROOMS_XML_FILENAME "chatrooms.xml"
-#define CHATROOMS_DTD_FILENAME "empathy-chatroom-manager.dtd"
+#define CHATROOMS_DTD_RESOURCENAME "/org/gnome/Empathy/empathy-chatroom-manager.dtd"
 #define SAVE_TIMER 4
 
 static EmpathyChatroomManager *chatroom_manager_singleton = NULL;
@@ -320,7 +320,7 @@ chatroom_manager_file_parse (EmpathyChatroomManager *manager,
       return FALSE;
     }
 
-  if (!empathy_xml_validate (doc, CHATROOMS_DTD_FILENAME))
+  if (!empathy_xml_validate_from_resource (doc, CHATROOMS_DTD_RESOURCENAME))
     {
       g_warning ("Failed to validate file:'%s'", filename);
       xmlFreeDoc (doc);
index 8d49f0519e74f28b1628fe651d31a829a9bb7590..7fb02499f21c3dd6814b3dab3eeefae2ce8d84c3 100644 (file)
@@ -31,7 +31,7 @@
 #include "empathy-debug.h"
 
 #define CONTACT_GROUPS_XML_FILENAME "contact-groups.xml"
-#define CONTACT_GROUPS_DTD_FILENAME "empathy-contact-groups.dtd"
+#define CONTACT_GROUPS_DTD_RESOURCENAME "/org/gnome/Empathy/empathy-contact-groups.dtd"
 
 typedef struct {
        gchar    *name;
@@ -91,7 +91,7 @@ contact_groups_file_parse (const gchar *filename)
                return;
        }
 
-       if (!empathy_xml_validate (doc, CONTACT_GROUPS_DTD_FILENAME)) {
+       if (!empathy_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-dtd.gresource.xml b/libempathy/empathy-dtd.gresource.xml
new file mode 100644 (file)
index 0000000..76cc817
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/Empathy">
+    <file>empathy-status-presets.dtd</file>
+    <file>empathy-contact-groups.dtd</file>
+    <file>empathy-chatroom-manager.dtd</file>
+    <file>empathy-irc-networks.dtd</file>
+  </gresource>
+</gresources>
+
index 7f6ed9df8cd568658f7fbc204faebb1bb0ec36d9..3c2a31544c9e9c933659b9208f6f988b39edf727 100644 (file)
@@ -28,7 +28,7 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_IRC
 #include "empathy-debug.h"
 
-#define IRC_NETWORKS_DTD_FILENAME "empathy-irc-networks.dtd"
+#define IRC_NETWORKS_DTD_RESOURCENAME "/org/gnome/Empathy/empathy-irc-networks.dtd"
 #define IRC_NETWORKS_FILENAME "irc-networks.xml"
 #define SAVE_TIMER 4
 
@@ -632,7 +632,7 @@ irc_network_manager_file_parse (EmpathyIrcNetworkManager *self,
       return FALSE;
     }
 
-  if (!empathy_xml_validate (doc, IRC_NETWORKS_DTD_FILENAME)) {
+  if (!empathy_xml_validate_from_resource (doc, IRC_NETWORKS_DTD_RESOURCENAME)) {
     g_warning ("Failed to validate file:'%s'", filename);
     xmlFreeDoc (doc);
     xmlFreeParserCtxt (ctxt);
index d8faa4fe9da3eab8da4b0f6e044b9ebe900c2aae..1de36d81ba4b4f4c5430ae84435b9d3d1d782f19 100644 (file)
@@ -31,7 +31,7 @@
 #include "empathy-debug.h"
 
 #define STATUS_PRESETS_XML_FILENAME "status-presets.xml"
-#define STATUS_PRESETS_DTD_FILENAME "empathy-status-presets.dtd"
+#define STATUS_PRESETS_DTD_RESOURCENAME "/org/gnome/Empathy/empathy-status-presets.dtd"
 #define STATUS_PRESETS_MAX_EACH     15
 
 typedef struct {
@@ -92,7 +92,7 @@ status_presets_file_parse (const gchar *filename)
                return;
        }
 
-       if (!empathy_xml_validate (doc, STATUS_PRESETS_DTD_FILENAME)) {
+       if (!empathy_xml_validate_from_resource (doc, STATUS_PRESETS_DTD_RESOURCENAME)) {
                g_warning ("Failed to validate file:'%s'", filename);
                xmlFreeDoc (doc);
                xmlFreeParserCtxt (ctxt);