[libgda] Adaptations to make more providers work correctly in case some files are missing
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Adaptations to make more providers work correctly in case some files are missing
- Date: Mon, 19 Jan 2015 20:07:27 +0000 (UTC)
commit 0b91b07d1c646cfa3684ef1c3ecb3670e8b4997e
Author: Vivien Malerba <malerba gnome-db org>
Date: Mon Jan 19 21:06:49 2015 +0100
Adaptations to make more providers work correctly in case some files are missing
like #2859cf4964a65e1991779eebdda6f5d118cead3c
libgda/sqlite/gda-sqlite-provider.c | 43 ++++++++++++++++------------------
providers/bdb/Makefile.am | 13 ++++++++++
providers/bdb/libmain.c | 5 +++-
providers/bdbsql/Makefile.am | 14 +++++++++++
providers/bdbsql/libmain.c | 7 ++++-
providers/sqlcipher/Makefile.am | 15 +++++++++++-
providers/sqlcipher/libmain.c | 10 ++++++-
providers/sqlite/Makefile.am | 14 +++++++++++
providers/sqlite/libmain.c | 5 +++-
9 files changed, 96 insertions(+), 30 deletions(-)
---
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index 0d827dd..08cf421 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -1165,35 +1165,32 @@ gda_sqlite_provider_create_operation (GdaServerProvider *provider, G_GNUC_UNUSED
GdaServerOperation *op;
gchar *str;
gchar *dir;
-
- file = g_strdup_printf (PNAME "_specs_%s.xml", gda_server_operation_op_type_to_string (type));
+ file = g_strdup_printf (PNAME "_specs_%s", gda_server_operation_op_type_to_string (type));
str = g_utf8_strdown (file, -1);
g_free (file);
+ gchar *tmp;
+ tmp = g_strdup_printf ("%s.xml", str);
dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
- file = gda_server_provider_find_file (provider, dir, str);
+ file = gda_server_provider_find_file (provider, dir, tmp);
g_free (dir);
+ g_free (tmp);
- if (! file) {
- const gchar *contents;
- contents = emb_get_file (str);
- if (contents) {
- op = _gda_server_operation_new_from_string (type, contents);
- return op;
- }
- else {
- g_set_error (error, GDA_SERVER_OPERATION_ERROR,
- GDA_SERVER_OPERATION_XML_ERROR,
- _("Missing spec. file '%s'"), str);
- g_free (str);
- return NULL;
- }
- }
-
- g_free (str);
-
- op = gda_server_operation_new (type, file);
- g_free (file);
+ if (file) {
+ g_free (str);
+ op = gda_server_operation_new (type, file);
+ g_free (file);
+ }
+ else {
+ gchar *lpname;
+ lpname = g_utf8_strdown (PNAME, -1);
+ file = g_strdup_printf ("/spec/%s/%s.raw.xml", lpname, str);
+ g_free (str);
+ g_free (lpname);
+ op = GDA_SERVER_OPERATION (g_object_new (GDA_TYPE_SERVER_OPERATION, "op-type", type,
+ "spec-resource", file, NULL));
+ g_free (file);
+ }
return op;
}
diff --git a/providers/bdb/Makefile.am b/providers/bdb/Makefile.am
index 58c399c..abc1d58 100644
--- a/providers/bdb/Makefile.am
+++ b/providers/bdb/Makefile.am
@@ -14,6 +14,7 @@ libgda_bdb_la_SOURCES = \
gda-bdb.h \
gda-bdb-provider.c \
gda-bdb-provider.h \
+ bdb.gresources.c \
libmain.c
libgda_bdb_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) $(LIBTOOL_PROV_EXPORT_OPTIONS)
@@ -36,9 +37,21 @@ xml_in_files = bdb_specs_dsn.xml.in
xml_DATA = $(xml_in_files:.xml.in=.xml)
+# resources
+RESOURCES=$(xml_in_files:.xml.in=.raw.xml)
+bdb.gresources.c: bdb.gresource.xml $(RESOURCES)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source
$(srcdir)/bdb.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-bdb-6.0.pc
EXTRA_DIST = $(xml_in_files) libgda-bdb-6.0.pc.in
DISTCLEANFILES = $(xml_DATA)
+CLEANFILES = \
+ bdb.gresources.c \
+ $(RESOURCES)
diff --git a/providers/bdb/libmain.c b/providers/bdb/libmain.c
index b0f3d0a..2475a13 100644
--- a/providers/bdb/libmain.c
+++ b/providers/bdb/libmain.c
@@ -84,7 +84,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, "bdb_specs_dsn.xml");
g_free (dir);
- return ret;
+ if (ret)
+ return ret;
+ else
+ return gda_server_provider_load_resource_contents ("bdb", "bdb_specs_dsn.raw.xml");
}
gchar *
diff --git a/providers/bdbsql/Makefile.am b/providers/bdbsql/Makefile.am
index d9975ad..5db3430 100644
--- a/providers/bdbsql/Makefile.am
+++ b/providers/bdbsql/Makefile.am
@@ -13,6 +13,7 @@ AM_CPPFLAGS = \
libgda_bdbsql_la_SOURCES = \
+ bdbsql.gresources.c \
libmain.c
libgda_bdbsql_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED)
$(LIBTOOL_PROV_EXPORT_OPTIONS)
@@ -39,8 +40,21 @@ xml_in_files = \
xml_DATA = $(xml_in_files:.xml.in=.xml)
+# resources
+RESOURCES=$(xml_in_files:.xml.in=.raw.xml)
+bdbsql.gresources.c: bdbsql.gresource.xml $(RESOURCES)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source
$(srcdir)/bdbsql.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-bdbsql-6.0.pc
EXTRA_DIST = $(xml_in_files) libgda-bdbsql-6.0.pc.in
DISTCLEANFILES = $(xml_DATA)
+
+CLEANFILES = \
+ bdbsql.gresources.c \
+ $(RESOURCES)
diff --git a/providers/bdbsql/libmain.c b/providers/bdbsql/libmain.c
index 2ddd8ee..d1d654b 100644
--- a/providers/bdbsql/libmain.c
+++ b/providers/bdbsql/libmain.c
@@ -99,9 +99,12 @@ plugin_get_dsn_spec (void)
gchar *ret, *dir;
dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
- ret = gda_server_provider_load_file_contents (module_path, dir, "sqlite_specs_dsn.xml");
+ ret = gda_server_provider_load_file_contents (module_path, dir, "bdbsql_specs_dsn.xml");
g_free (dir);
- return ret;
+ if (ret)
+ return ret;
+ else
+ return gda_server_provider_load_resource_contents ("bdbsql", "bdbsql_specs_dsn.raw.xml");
}
gchar *
diff --git a/providers/sqlcipher/Makefile.am b/providers/sqlcipher/Makefile.am
index 0a02d16..fdc1d50 100644
--- a/providers/sqlcipher/Makefile.am
+++ b/providers/sqlcipher/Makefile.am
@@ -28,6 +28,7 @@ libmain.lo: sqlite3.h
libgda_sqlcipher_la_SOURCES = \
$(sqlite_sources) \
+ sqlcipher.gresources.c \
libmain.c
libgda_sqlcipher_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED)
$(LIBTOOL_PROV_EXPORT_OPTIONS)
@@ -56,6 +57,15 @@ xml_in_files = \
xml_DATA = $(xml_in_files:.xml.in=.xml)
+# resources
+RESOURCES=$(xml_in_files:.xml.in=.raw.xml)
+sqlcipher.gresources.c: sqlcipher.gresource.xml $(RESOURCES)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source
$(srcdir)/sqlcipher.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-sqlcipher-6.0.pc
@@ -64,6 +74,9 @@ EXTRA_DIST = $(xml_in_files) \
sqlcipher.patch \
COPYING.sqlcipher
-CLEANFILES = $(sqlite_sources)
+CLEANFILES = \
+ $(sqlite_sources) \
+ sqlcipher.gresources.c \
+ $(RESOURCES)
DISTCLEANFILES = $(xml_DATA)
diff --git a/providers/sqlcipher/libmain.c b/providers/sqlcipher/libmain.c
index 4948bf4..b7a7525 100644
--- a/providers/sqlcipher/libmain.c
+++ b/providers/sqlcipher/libmain.c
@@ -84,7 +84,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, "sqlcipher_specs_dsn.xml");
g_free (dir);
- return ret;
+ if (ret)
+ return ret;
+ else
+ return gda_server_provider_load_resource_contents ("sqlcipher",
"sqlcipher_specs_dsn.raw.xml");
}
gchar *
@@ -95,7 +98,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, "sqlcipher_specs_auth.xml");
g_free (dir);
- return ret;
+ if (ret)
+ return ret;
+ else
+ return gda_server_provider_load_resource_contents ("sqlcipher",
"sqlcipher_specs_auth.raw.xml");
}
GdaServerProvider *
diff --git a/providers/sqlite/Makefile.am b/providers/sqlite/Makefile.am
index 3deb38e..887c8ed 100644
--- a/providers/sqlite/Makefile.am
+++ b/providers/sqlite/Makefile.am
@@ -13,6 +13,7 @@ AM_CPPFLAGS = \
libgda_sqlite_la_SOURCES = \
+ sqlite.gresources.c \
libmain.c
libgda_sqlite_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED)
$(LIBTOOL_PROV_EXPORT_OPTIONS)
@@ -38,8 +39,21 @@ xml_in_files = \
xml_DATA = $(xml_in_files:.xml.in=.xml)
+# resources
+RESOURCES=$(xml_in_files:.xml.in=.raw.xml)
+sqlite.gresources.c: sqlite.gresource.xml $(RESOURCES)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source
$(srcdir)/sqlite.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-sqlite-6.0.pc
EXTRA_DIST = $(xml_in_files) libgda-sqlite-6.0.pc.in
DISTCLEANFILES = $(xml_DATA)
+
+CLEANFILES = \
+ sqlite.gresources.c \
+ $(RESOURCES)
diff --git a/providers/sqlite/libmain.c b/providers/sqlite/libmain.c
index 59cb251..53f0dfb 100644
--- a/providers/sqlite/libmain.c
+++ b/providers/sqlite/libmain.c
@@ -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, "sqlite_specs_dsn.xml");
g_free (dir);
- return ret;
+ if (ret)
+ return ret;
+ else
+ return gda_server_provider_load_resource_contents ("sqlite", "sqlite_specs_dsn.raw.xml");
}
gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]