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



commit 253b5dbb3a7ec0ee6e86206f16a2ae95cf3e4328
Author: Vivien Malerba <malerba gnome-db org>
Date:   Wed Feb 4 15:22:52 2015 +0100

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

 providers/web/Makefile.am       |   14 ++++++++++++++
 providers/web/libmain.c         |   12 +++++++++---
 providers/web/web.gresource.xml |    7 +++++++
 3 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/providers/web/Makefile.am b/providers/web/Makefile.am
index a69ba9a..3f67be8 100644
--- a/providers/web/Makefile.am
+++ b/providers/web/Makefile.am
@@ -26,6 +26,7 @@ libgda_web_la_SOURCES = \
        gda-web-util.h \
        gda-web-util.c \
        gda-web.h \
+       web.gresources.c \
        libmain.c
 
 libgda_web_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) $(LIBTOOL_PROV_EXPORT_OPTIONS)
@@ -43,6 +44,15 @@ xml_in_files = \
 
 xml_DATA = $(xml_in_files:.xml.in=.xml) 
 
+# resources
+RESOURCES=$(xml_in_files:.xml.in=.raw.xml)
+web.gresources.c: web.gresource.xml $(RESOURCES)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source 
$(srcdir)/web.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-web-6.0.pc
 
@@ -65,3 +75,7 @@ EXTRA_DIST = $(xml_in_files) libgda-web-6.0.pc.in \
        $(php_DATA)
 
 DISTCLEANFILES = $(xml_DATA)
+
+CLEANFILES = \
+        web.gresources.c \
+        $(RESOURCES)
diff --git a/providers/web/libmain.c b/providers/web/libmain.c
index 9ca0294..5cb7fe6 100644
--- a/providers/web/libmain.c
+++ b/providers/web/libmain.c
@@ -4,7 +4,7 @@
  * Copyright (C) 2003 Gonzalo Paniagua Javier <gonzalo gnome-db org>
  * Copyright (C) 2005 Bas Driessen <bas driessen xobas com>
  * Copyright (C) 2005 Stanislav Brabec <sbrabec suse de>
- * Copyright (C) 2005 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2005 - 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
@@ -83,7 +83,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, "web_specs_dsn.xml");
        g_free (dir);
-       return ret;
+       if (ret)
+               return ret;
+       else
+               return gda_server_provider_load_resource_contents ("web", "web_specs_dsn.raw.xml");
 }
 
 gchar *
@@ -94,7 +97,10 @@ plugin_get_auth_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, "web_specs_auth.xml");
        g_free (dir);
-       return ret;
+       if (ret)
+               return ret;
+       else
+               return gda_server_provider_load_resource_contents ("web", "web_specs_auth.raw.xml");
 }
 
 GdaServerProvider *
diff --git a/providers/web/web.gresource.xml b/providers/web/web.gresource.xml
new file mode 100644
index 0000000..1ed0a87
--- /dev/null
+++ b/providers/web/web.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/spec/web">
+    <file compressed="true">web_specs_auth.raw.xml</file>
+    <file compressed="true">web_specs_dsn.raw.xml</file>
+  </gresource>
+</gresources>


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