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



commit 5494c76a4f7c4531f690dd984c55e2541badbbdf
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Jan 22 21:06:28 2015 +0100

    Firebird adaptations to make provider work correctly in case some files are missing
    
    like #2859cf4964a65e1991779eebdda6f5d118cead3c

 providers/firebird/Makefile.am             |   22 +++++++++++++++++++---
 providers/firebird/firebird.gresource.xml  |    8 ++++++++
 providers/firebird/gda-firebird-provider.c |   26 ++++++++++++++------------
 providers/firebird/libmain-client.c        |    7 +++++--
 providers/firebird/libmain-embed.c         |    7 +++++--
 5 files changed, 51 insertions(+), 19 deletions(-)
---
diff --git a/providers/firebird/Makefile.am b/providers/firebird/Makefile.am
index c665133..a471035 100644
--- a/providers/firebird/Makefile.am
+++ b/providers/firebird/Makefile.am
@@ -49,14 +49,14 @@ firebird_sources = \
        parser.c \
        firebird_token_types.h
 
-libgda_firebird_client_la_SOURCES = $(firebird_sources) libmain-client.c
+libgda_firebird_client_la_SOURCES = $(firebird_sources) firebird.gresources.c libmain-client.c
 libgda_firebird_client_la_CFLAGS = $(FIREBIRD_CLIENT_CFLAGS)
 libgda_firebird_client_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) 
$(LIBTOOL_PROV_EXPORT_OPTIONS)
 libgda_firebird_client_la_LIBADD = \
        $(top_builddir)/libgda/libgda-6.0.la \
        $(COREDEPS_LIBS) $(FIREBIRD_CLIENT_LIBS)
 
-libgda_firebird_embed_la_SOURCES = $(firebird_sources) libmain-embed.c
+libgda_firebird_embed_la_SOURCES = $(firebird_sources) firebird.gresources.c libmain-embed.c
 libgda_firebird_embed_la_CFLAGS = -DFIREBIRD_EMBED $(FIREBIRD_EMBED_CFLAGS)
 libgda_firebird_embed_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) 
$(LIBTOOL_PROV_EXPORT_OPTIONS)
 libgda_firebird_embed_la_LIBADD = \
@@ -73,10 +73,26 @@ xml_in_files = \
 
 xml_DATA = $(xml_in_files:.xml.in=.xml) 
 
+# resources
+RESOURCES=$(xml_in_files:.xml.in=.raw.xml)
+firebird.gresources.c: firebird.gresource.xml $(RESOURCES)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source 
$(srcdir)/firebird.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-firebird-6.0.pc
 
 EXTRA_DIST = $(xml_in_files) libgda-firebird-6.0.pc.in parser.y gen_def.c
 DISTCLEANFILES = $(xml_DATA)
 
-CLEANFILES = parser.h parser.c parser.out firebird_token_types.h gen_def$(EXEEXT_FOR_BUILD)
+CLEANFILES = \
+       parser.h \
+       parser.c \
+       parser.out \
+       firebird_token_types.h \
+       gen_def$(EXEEXT_FOR_BUILD) \
+       firebird.gresource.c
diff --git a/providers/firebird/firebird.gresource.xml b/providers/firebird/firebird.gresource.xml
new file mode 100644
index 0000000..3a3260f
--- /dev/null
+++ b/providers/firebird/firebird.gresource.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/spec/firebird">
+    <file compressed="true">firebird_specs_create_table.raw.xml</file>
+    <file compressed="true">firebird_specs_dsn_emb.raw.xml</file>
+    <file compressed="true">firebird_specs_dsn.raw.xml</file>
+  </gresource>
+</gresources>
diff --git a/providers/firebird/gda-firebird-provider.c b/providers/firebird/gda-firebird-provider.c
index ee98e76..ff9a2a2 100644
--- a/providers/firebird/gda-firebird-provider.c
+++ b/providers/firebird/gda-firebird-provider.c
@@ -3,7 +3,7 @@
  * Copyright (C) 2003 Gonzalo Paniagua Javier <gonzalo gnome-db org>
  * Copyright (C) 2004 Jeronimo Albi <jeronimoalbi yahoo com ar>
  * Copyright (C) 2004 Julio M. Merino Vidal <jmmv menta net>
- * Copyright (C) 2004 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2004 - 2015 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2008 Murray Cumming <murrayc murrayc com>
  * Copyright (C) 2009 Bas Driessen <bas driessen xobas com>
  *
@@ -614,7 +614,7 @@ static GdaServerOperation *
 gda_firebird_provider_create_operation (GdaServerProvider *provider, GdaConnection *cnc,
                                        GdaServerOperationType type, GdaSet *options, GError **error)
 {
-        gchar *file;
+        gchar *file, *stype;
         GdaServerOperation *op;
         gchar *str;
        gchar *dir;
@@ -624,23 +624,25 @@ gda_firebird_provider_create_operation (GdaServerProvider *provider, GdaConnecti
                g_return_val_if_fail (gda_connection_get_provider (cnc) == provider, FALSE);
        }
 
-        file = g_utf8_strdown (gda_server_operation_op_type_to_string (type), -1);
-        str = g_strdup_printf ("firebird_specs_%s.xml", file);
-        g_free (file);
+        stype = g_utf8_strdown (gda_server_operation_op_type_to_string (type), -1);
+        str = g_strdup_printf ("firebird_specs_%s.xml", stype);
 
        dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         file = gda_server_provider_find_file (provider, dir, str);
        g_free (dir);
         g_free (str);
 
-        if (! file) {
-                g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_FILE_NOT_FOUND_ERROR,
-                            _("Missing spec. file '%s'"), file);
-                return NULL;
+       if (file) {
+               op = gda_server_operation_new (type, file);
+               g_free (file);
+       }
+       else {
+               file = g_strdup_printf ("/spec/firebird/%s.raw.xml", stype);
+               op = GDA_SERVER_OPERATION (g_object_new (GDA_TYPE_SERVER_OPERATION, "op-type", type,
+                                                        "spec-resource", file, NULL));
+               g_free (file);
         }
-
-        op = gda_server_operation_new (type, file);
-        g_free (file);
+       g_free (stype);
 
         return op;
 }
diff --git a/providers/firebird/libmain-client.c b/providers/firebird/libmain-client.c
index 7682d8b..2449163 100644
--- a/providers/firebird/libmain-client.c
+++ b/providers/firebird/libmain-client.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000 - 2004 Rodrigo Moya <rodrigo gnome-db org>
- * Copyright (C) 2001 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2001 - 2015 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2002 Gonzalo Paniagua Javier <gonzalo gnome-db org>
  * Copyright (C) 2004 Jeronimo Albi <jeronimoalbi yahoo com ar>
  *
@@ -77,7 +77,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, "firebird_specs_dsn.xml");
        g_free (dir);
-       return ret;
+       if (ret)
+               return ret;
+       else
+               return gda_server_provider_load_resource_contents ("firebird", "firebird_specs_dsn.raw.xml");
 }
 
 GdaServerProvider *
diff --git a/providers/firebird/libmain-embed.c b/providers/firebird/libmain-embed.c
index cfacac7..8785384 100644
--- a/providers/firebird/libmain-embed.c
+++ b/providers/firebird/libmain-embed.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000 - 2004 Rodrigo Moya <rodrigo gnome-db org>
- * Copyright (C) 2001 - 2012 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2001 - 2015 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2002 Gonzalo Paniagua Javier <gonzalo gnome-db org>
  * Copyright (C) 2004 Jeronimo Albi <jeronimoalbi yahoo com ar>
  *
@@ -78,7 +78,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, "firebird_specs_dsn_emb.xml");
        g_free (dir);
-       return ret;
+       if (ret)
+               return ret;
+       else
+               return gda_server_provider_load_resource_contents ("firebird", "firebird_specs_dsn.raw.xml");
 }
 
 const gchar *


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