[libgda] Mdb adaptations to make provider work correctly in case some files are missing



commit 0af77a1cda1c8e877142946a434ba1ca672c0023
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sat Jan 31 15:06:07 2015 +0100

    Mdb adaptations to make provider work correctly in case some files are missing

 providers/mdb/Makefile.am       |   14 ++++++++++++++
 providers/mdb/libmain.c         |    5 ++++-
 providers/mdb/mdb.gresource.xml |    6 ++++++
 3 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/providers/mdb/Makefile.am b/providers/mdb/Makefile.am
index d18725a..b756fdb 100644
--- a/providers/mdb/Makefile.am
+++ b/providers/mdb/Makefile.am
@@ -31,6 +31,7 @@ libgda_mdb_la_SOURCES = \
        gda-mdb-provider.c \
        gda-mdb-provider.h \
        gda-mdb.h \
+       mdb.gresources.c \
        libmain.c
 
 libgda_mdb_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) $(LIBTOOL_PROV_EXPORT_OPTIONS)
@@ -46,8 +47,21 @@ xml_in_files = mdb_specs_dsn.xml.in
 
 xml_DATA = $(xml_in_files:.xml.in=.xml)
 
+# resources
+RESOURCES=$(xml_in_files:.xml.in=.raw.xml)
+mdb.gresources.c: mdb.gresource.xml $(RESOURCES)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source 
$(srcdir)/mdb.gresource.xml
+
+%.raw.xml:%.xml.in
+       @echo "  GEN      $@"
+       @cat $< | sed -e 's/_\([a-zA-Z0-9]*\)=/\1=/g' -e 's/<_\([a-ZA-Z0-9_]*\)>/<\1>/g' -e 
's/<\/_\([a-ZA-Z0-9_]*\)>/<\/\1>/g' -e 's/<!-- .* -->//'> $@
+
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libgda-mdb-6.0.pc
 
 EXTRA_DIST = $(xml_in_files) libgda-mdb-6.0.pc.in
 DISTCLEANFILES = $(xml_DATA)
+
+CLEANFILES = \
+       mdb.gresources.c \
+       $(RESOURCES)
diff --git a/providers/mdb/libmain.c b/providers/mdb/libmain.c
index 3b5a19a..bdd65f7 100644
--- a/providers/mdb/libmain.c
+++ b/providers/mdb/libmain.c
@@ -81,7 +81,10 @@ plugin_get_dsn_spec (void)
         dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         ret = gda_server_provider_load_file_contents (module_path, dir, "mdb_specs_dsn.xml");
         g_free (dir);
-        return ret;
+       if (ret)
+               return ret;
+       else
+               return gda_server_provider_load_resource_contents ("mdb", "mdb_specs_dsn.raw.xml");
 }
 
 gchar *
diff --git a/providers/mdb/mdb.gresource.xml b/providers/mdb/mdb.gresource.xml
new file mode 100644
index 0000000..4f75c9e
--- /dev/null
+++ b/providers/mdb/mdb.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/spec/mdb">
+    <file compressed="true">mdb_specs_dsn.raw.xml</file>
+  </gresource>
+</gresources>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]