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



commit a6c6f8b27c61cf88ab09f2fb7fbf351bfb1a5e10
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sat Jan 31 15:01:22 2015 +0100

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

 providers/ldap/Makefile.am        |   13 +++++++++++++
 providers/ldap/ldap.gresource.xml |    7 +++++++
 providers/ldap/libmain.c          |   12 +++++++++---
 3 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/providers/ldap/Makefile.am b/providers/ldap/Makefile.am
index a74f4eb..3c27c78 100644
--- a/providers/ldap/Makefile.am
+++ b/providers/ldap/Makefile.am
@@ -17,6 +17,7 @@ libgda_ldap_la_SOURCES = \
        gda-ldap-util.c \
        gda-ldap-util.h \
        gda-ldap.h \
+       ldap.gresources.c \
        libmain.c
 
 libgda_ldap_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) 
$(LIBTOOL_PROV_EXPORT_OPTIONS)
@@ -32,9 +33,21 @@ xml_in_files = ldap_specs_dsn.xml.in ldap_specs_auth.xml.in
 
 xml_DATA = $(xml_in_files:.xml.in=.xml)
 
+# resources
+RESOURCES=$(xml_in_files:.xml.in=.raw.xml)
+ldap.gresources.c: ldap.gresource.xml $(RESOURCES)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source 
$(srcdir)/ldap.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-ldap-6.0.pc
 
 EXTRA_DIST = $(xml_in_files) libgda-ldap-6.0.pc.in
 DISTCLEANFILES = $(xml_DATA)
 
+CLEANFILES = \
+       ldap.gresources.c \
+       $(RESOURCES)
diff --git a/providers/ldap/ldap.gresource.xml b/providers/ldap/ldap.gresource.xml
new file mode 100644
index 0000000..c3583b9
--- /dev/null
+++ b/providers/ldap/ldap.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/spec/ldap">
+    <file compressed="true">ldap_specs_auth.raw.xml</file>
+    <file compressed="true">ldap_specs_dsn.raw.xml</file>
+  </gresource>
+</gresources>
diff --git a/providers/ldap/libmain.c b/providers/ldap/libmain.c
index f44d508..05b9ea3 100644
--- a/providers/ldap/libmain.c
+++ b/providers/ldap/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, "ldap_specs_dsn.xml");
        g_free (dir);
-       return ret;
+       if (ret)
+               return ret;
+       else
+               return gda_server_provider_load_resource_contents ("ldap", "ldap_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, "ldap_specs_auth.xml");
        g_free (dir);
-       return ret;
+       if (ret)
+               return ret;
+       else
+               return gda_server_provider_load_resource_contents ("ldap", "ldap_specs_auth.raw.xml");
 }
 
 GdaServerProvider *


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