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



commit 45280e899482246d8b818d927b558f2ab8f81c17
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sat Jan 31 14:54:09 2015 +0100

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

 providers/jdbc/Makefile.am                    |    8 +++++-
 providers/jdbc/jdbc.gresource.xml             |    5 ++-
 providers/jdbc/jdbc_specs_create_table.xml.in |   26 -------------------------
 providers/jdbc/libmain.c                      |   20 ++++++++++++++++--
 4 files changed, 26 insertions(+), 33 deletions(-)
---
diff --git a/providers/jdbc/Makefile.am b/providers/jdbc/Makefile.am
index 1323e6e..a311189 100644
--- a/providers/jdbc/Makefile.am
+++ b/providers/jdbc/Makefile.am
@@ -30,6 +30,7 @@ jni_headers = $(jni_sources:.c=.h)
 jni_classes = $(jni_sources:.c=.class) 
 
 resources = jdbc-resources.h jdbc-resources.c
+RAWRESOURCES=$(xml_in_files:.xml.in=.raw.xml)
 
 $(libgda_jdbc_la_OBJECTS): $(jni_headers) $(resources)
 
@@ -70,9 +71,13 @@ if PLATFORM_WIN32
 libgda_jdbc_la_LDFLAGS += -Wl,--kill-at
 endif
 
-jdbc-resources.h jdbc-resources.c: $(srcdir)/jdbc.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) 
--sourcedir=$(srcdir) --generate-dependencies $(srcdir)/jdbc.gresource.xml)
+jdbc-resources.h jdbc-resources.c: $(srcdir)/jdbc.gresource.xml $(RAWRESOURCES) Makefile $(shell 
$(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/jdbc.gresource.xml)
        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name _jdbc 
--manual-register $<
 
+%.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/<!-- .* -->//'> $@
+
 CLEANFILES = $(resources)
 
 $(jni_headers): $(jdbcprov_classes)
@@ -104,7 +109,6 @@ clean-local:
 xmldir   = $(datadir)/libgda-6.0
 xml_in_files = \
        jdbc_specs_dsn.xml.in \
-       jdbc_specs_create_table.xml.in \
        jdbc_specs_com.microsoft.sqlserver.jdbc.SQLServerDriver_dsn.xml.in
 
 @INTLTOOL_XML_RULE@
diff --git a/providers/jdbc/jdbc.gresource.xml b/providers/jdbc/jdbc.gresource.xml
index 511f0a7..86f10bc 100644
--- a/providers/jdbc/jdbc.gresource.xml
+++ b/providers/jdbc/jdbc.gresource.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <gresource prefix="/jdbc">
-    <file compressed="true">jdbc-mappings.xml</file>
+  <gresource prefix="/spec/jdbc">
+    <file compressed="true">jdbc_specs_com.microsoft.sqlserver.jdbc.SQLServerDriver_dsn.raw.xml</file>
+    <file compressed="true">jdbc_specs_dsn.raw.xml</file>
   </gresource>
 </gresources>
diff --git a/providers/jdbc/libmain.c b/providers/jdbc/libmain.c
index ef4efd8..c75c83c 100644
--- a/providers/jdbc/libmain.c
+++ b/providers/jdbc/libmain.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2008 - 2015 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2010 David King <davidk openismus com>
  *
  * This library is free software; you can redistribute it and/or
@@ -304,8 +304,22 @@ plugin_get_sub_dsn_spec (const gchar *name)
        tmp = g_strdup_printf ("jdbc_specs_%s_dsn.xml", name);
        ret = gda_server_provider_load_file_contents (module_path, dir, tmp);
        g_free (tmp);
-       if (!ret)
-               ret = gda_server_provider_load_file_contents (module_path, dir, "jdbc_specs_dsn.xml");
+       if (ret)
+               goto out;
+
+       tmp = g_strdup_printf ("jdbc_specs_%s_dsn.raw.xml", name);
+       ret = gda_server_provider_load_resource_contents ("jdbc", tmp);
+       g_free (tmp);
+       if (ret)
+               goto out;
+
+       ret = gda_server_provider_load_file_contents (module_path, dir, "jdbc_specs_dsn.xml");
+       if (ret)
+               goto out;
+
+       ret = gda_server_provider_load_resource_contents ("jdbc", "jdbc_specs_dsn.raw.xml");
+
+ out:
        g_free (dir);
        return ret;
 }


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