[libgda] Correction for bug #674715



commit c4b14aa32a37d4541cfa779fc3dc1a8e144108c6
Author: Vivien Malerba <malerba gnome-db org>
Date:   Tue Apr 24 18:41:47 2012 +0200

    Correction for bug #674715
    
    Allow GdaSql to compile when LDAP is not installed

 tools/Makefile.am    |    5 +++++
 tools/command-exec.c |    4 ++++
 tools/gda-sql.c      |   39 +++++++++++++++++++++++++--------------
 3 files changed, 34 insertions(+), 14 deletions(-)
---
diff --git a/tools/Makefile.am b/tools/Makefile.am
index beebc41..02a07ad 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -2,6 +2,10 @@ if HAVE_UI
 BROWSER_DIR=browser
 endif
 
+if LDAP
+ldap_flags=-DHAVE_LDAP
+endif
+
 SUBDIRS = $(BROWSER_DIR) help
 
 bin_PROGRAMS = \
@@ -18,6 +22,7 @@ AM_CPPFLAGS = \
 	-I$(top_builddir)/libgda/sqlite \
 	-I$(top_srcdir)/libgda \
 	-I. \
+	$(ldap_flags) \
 	$(COREDEPS_CFLAGS) \
 	-DROOT_DIR=\""$(top_srcdir)"\"
 
diff --git a/tools/command-exec.c b/tools/command-exec.c
index f5b2a1f..8928ca4 100644
--- a/tools/command-exec.c
+++ b/tools/command-exec.c
@@ -30,7 +30,9 @@
 #endif
 #include <sql-parser/gda-statement-struct-util.h>
 #include "tools-utils.h"
+#ifdef HAVE_LDAP
 #include <virtual/gda-ldap-connection.h>
+#endif
 
 /*
  *  gda_internal_command_arg_remove_quotes
@@ -661,8 +663,10 @@ gda_internal_command_help (SqlConsole *console, GdaConnection *cnc,
 			if (console && command->limit_to_main)
 				continue;
 
+#ifdef HAVE_LDAP
 			if (g_str_has_prefix (command->name, "ldap") && cnc && !GDA_IS_LDAP_CONNECTION (cnc))
 				continue;
+#endif
 
 			if (!current_group || strcmp (current_group, command->group)) {
 				current_group = command->group;
diff --git a/tools/gda-sql.c b/tools/gda-sql.c
index f1a12aa..34fb2d1 100644
--- a/tools/gda-sql.c
+++ b/tools/gda-sql.c
@@ -198,16 +198,30 @@ main (int argc, char *argv[])
 	setlocale (LC_ALL, "");
         gda_init ();
 
-#define DEFAULT_LDAP_ATTRIBUTES "cn"
 	has_threads = g_thread_supported ();
 	data = g_new0 (MainData, 1);
 	data->output_format = OUTPUT_FORMAT_DEFAULT;
-	data->options = gda_set_new_inline (5,
+	data->options = gda_set_new_inline (3,
 					    "csv_names_on_first_line", G_TYPE_BOOLEAN, FALSE,
 					    "csv_quote", G_TYPE_STRING, "\"",
-					    "csv_separator", G_TYPE_STRING, ",",
-					    "ldap_dn", G_TYPE_STRING, "dn",
-					    "ldap_attributes", G_TYPE_STRING, DEFAULT_LDAP_ATTRIBUTES);
+					    "csv_separator", G_TYPE_STRING, ",");
+#ifdef HAVE_LDAP
+#define DEFAULT_LDAP_ATTRIBUTES "cn"
+	opt = gda_holder_new_string ("ldap_dn", "dn");
+	value = gda_value_new (G_TYPE_STRING);
+	g_value_set_string (value, _("Defines how the DN column is handled for LDAP searched (among \"dn\", \"rdn\" and \"none\")"));
+	gda_holder_set_attribute (opt, GDA_ATTRIBUTE_DESCRIPTION, value, NULL);
+	gda_set_add_holder (data->options, opt);
+	g_object_unref (opt);
+
+	opt = gda_holder_new_string ("ldap_attributes", DEFAULT_LDAP_ATTRIBUTES);
+	g_value_set_string (value, _("Defines the LDAP attributes which are fetched by default by LDAP commands"));
+	gda_holder_set_attribute (opt, GDA_ATTRIBUTE_DESCRIPTION, value, NULL);
+	gda_value_free (value);
+	gda_set_add_holder (data->options, opt);
+	g_object_unref (opt);
+#endif
+
 	value = gda_value_new (G_TYPE_STRING);
 	g_value_set_string (value, _("Set to TRUE when the 1st line of a CSV file holds column names"));
 	opt = gda_set_get_holder (data->options, "csv_names_on_first_line");
@@ -226,14 +240,6 @@ main (int argc, char *argv[])
 	gda_holder_set_attribute (opt, GDA_ATTRIBUTE_DESCRIPTION, value, NULL);
 	g_value_set_string (value, "SEPARATOR");
 	gda_holder_set_attribute (opt, "csv", value, NULL);
-
-	g_value_set_string (value, _("Defines how the DN column is handled for LDAP searched (among \"dn\", \"rdn\" and \"none\")"));
-	opt = gda_set_get_holder (data->options, "ldap_dn");
-	gda_holder_set_attribute (opt, GDA_ATTRIBUTE_DESCRIPTION, value, NULL);
-
-	g_value_set_string (value, _("Defines the LDAP attributes which are fetched by default by LDAP commands"));
-	opt = gda_set_get_holder (data->options, "ldap_attributes");
-	gda_holder_set_attribute (opt, GDA_ATTRIBUTE_DESCRIPTION, value, NULL);
 	gda_value_free (value);
 
 	data->parameters = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
@@ -2319,12 +2325,14 @@ static GdaInternalCommandResult *extra_command_undeclare_fk (SqlConsole *console
 							     const gchar **args,
 							     OutputFormat format, GError **error, gpointer data);
 
+#ifdef HAVE_LDAP
 static GdaInternalCommandResult *extra_command_ldap_search (SqlConsole *console, GdaConnection *cnc,
 							    const gchar **args,
 							    OutputFormat format, GError **error, gpointer data);
 static GdaInternalCommandResult *extra_command_ldap_descr (SqlConsole *console, GdaConnection *cnc,
 							   const gchar **args,
 							   OutputFormat format, GError **error, gpointer data);
+#endif
 
 static GdaInternalCommandsList *
 build_internal_commands_list (void)
@@ -2948,6 +2956,7 @@ build_internal_commands_list (void)
 	c->limit_to_main = FALSE;
 	commands->commands = g_slist_prepend (commands->commands, c);
 
+#ifdef HAVE_LDAP
 	c = g_new0 (GdaInternalCommand, 1);
 	c->group = _("LDAP");
 	c->group_id = "LDAP";
@@ -2977,6 +2986,7 @@ build_internal_commands_list (void)
 	c->unquote_args = TRUE;
 	c->limit_to_main = TRUE;
 	commands->commands = g_slist_prepend (commands->commands, c);
+#endif
 
 	/* comes last */
 	c = g_new0 (GdaInternalCommand, 1);
@@ -5642,6 +5652,7 @@ extra_command_pivot (SqlConsole *console, GdaConnection *cnc, const gchar **args
 	return res;
 }
 
+#ifdef HAVE_LDAP
 static GdaInternalCommandResult *
 extra_command_ldap_search (SqlConsole *console, GdaConnection *cnc, const gchar **args,
 			   G_GNUC_UNUSED OutputFormat format, GError **error, gpointer data)
@@ -5955,7 +5966,7 @@ extra_command_ldap_descr (G_GNUC_UNUSED SqlConsole *console, G_GNUC_UNUSED GdaCo
 	return res;
 }
 
-
+#endif /* HAVE_LDAP */
 
 static GdaInternalCommandResult *
 extra_command_export (SqlConsole *console, GdaConnection *cnc, const gchar **args,



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