[libgda] More code cleanups



commit 1a3f97074d8e8b6165e143c94fc9b2534146dc68
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sun Jan 6 15:50:47 2013 +0100

    More code cleanups

 doc/C/libgda-sections.txt                          |    1 +
 libgda/gda-server-provider-extra.c                 |   55 +++++++++++++++----
 libgda/gda-server-provider-extra.h                 |    1 +
 libgda/gda-server-provider.c                       |    6 +-
 libgda/libgda.symbols                              |    1 +
 libgda/sqlite/gda-sqlite-provider.c                |    2 +-
 providers/firebird/gda-firebird-provider.c         |    2 +-
 providers/jdbc/gda-jdbc-provider.c                 |    2 +-
 providers/mysql/gda-mysql-provider.c               |    2 +-
 providers/oracle/gda-oracle-provider.c             |    2 +-
 providers/postgres/gda-postgres-provider.c         |    2 +-
 .../skel-implementation/capi/gda-capi-provider.c   |    2 +-
 12 files changed, 56 insertions(+), 22 deletions(-)
---
diff --git a/doc/C/libgda-sections.txt b/doc/C/libgda-sections.txt
index d216808..83d580f 100644
--- a/doc/C/libgda-sections.txt
+++ b/doc/C/libgda-sections.txt
@@ -1604,6 +1604,7 @@ gda_server_provider_internal_get_parser
 gda_server_provider_perform_operation_default
 gda_server_provider_get_data_handler_default
 <SUBSECTION>
+gda_server_provider_handler_use_default
 gda_server_provider_handler_find
 gda_server_provider_handler_declare
 <SUBSECTION>
diff --git a/libgda/gda-server-provider-extra.c b/libgda/gda-server-provider-extra.c
index 04d9857..3edbfc4 100644
--- a/libgda/gda-server-provider-extra.c
+++ b/libgda/gda-server-provider-extra.c
@@ -97,25 +97,26 @@ gda_server_provider_perform_operation_default (GdaServerProvider *provider, GdaC
 	}
 	g_object_unref (batch);
 
-	return retval;;
+	return retval;
 }
 
 /**
- * gda_server_provider_get_data_handler_default:
- * @provider: a server provider.
- * @cnc: (allow-none): a #GdaConnection object, or %NULL
+ * gda_server_provider_handler_use_default: (skip)
+ * @provider: a server provider
  * @type: a #GType
- * @dbms_type: a DBMS type definition
  *
- * Provides the implementation when the default Libgda's data handlers must be used
- * 
+ * Reserved to database provider's implementations. This method defines a default data handler for
+ * @provider, and returns that #GdaDataHandler.
+ *
  * Returns: (transfer none): a #GdaDataHandler, or %NULL
+ *
+ * Since: 5.2
  */
 GdaDataHandler *
-gda_server_provider_get_data_handler_default (GdaServerProvider *provider, G_GNUC_UNUSED GdaConnection *cnc,
-					      GType type, G_GNUC_UNUSED const gchar *dbms_type)
+gda_server_provider_handler_use_default (GdaServerProvider *provider, GType type)
 {
 	GdaDataHandler *dh = NULL;
+	g_return_val_if_fail (GDA_IS_SERVER_PROVIDER (provider), NULL);
 	if ((type == G_TYPE_INT64) ||
 	    (type == G_TYPE_UINT64) ||
 	    (type == G_TYPE_DOUBLE) ||
@@ -187,6 +188,26 @@ gda_server_provider_get_data_handler_default (GdaServerProvider *provider, G_GNU
 	return dh;
 }
 
+/**
+ * gda_server_provider_get_data_handler_default: (skip)
+ * @provider: a server provider.
+ * @cnc: (allow-none): a #GdaConnection object, or %NULL
+ * @type: a #GType
+ * @dbms_type: a DBMS type definition
+ *
+ * Provides the implementation when the default Libgda's data handlers must be used
+ * 
+ * Returns: (transfer none): a #GdaDataHandler, or %NULL
+ *
+ * Deprecated: 5.2: use gda_server_provider_handler_use_default() instead
+ */
+GdaDataHandler *
+gda_server_provider_get_data_handler_default (GdaServerProvider *provider, G_GNUC_UNUSED GdaConnection *cnc,
+					      GType type, G_GNUC_UNUSED const gchar *dbms_type)
+{
+	return gda_server_provider_handler_use_default (provider, type);
+}
+
 static gboolean
 param_to_null_foreach (GdaSqlAnyPart *part, G_GNUC_UNUSED gpointer data, G_GNUC_UNUSED GError **error)
 {
@@ -209,7 +230,7 @@ param_to_null_foreach (GdaSqlAnyPart *part, G_GNUC_UNUSED gpointer data, G_GNUC_
 }
 
 /**
- * gda_select_alter_select_for_empty:
+ * gda_select_alter_select_for_empty: (skip)
  * @stmt: a SELECT #GdaStatement
  * @error: (allow-none): a place to store errors, or %NULL
  *
@@ -263,15 +284,23 @@ gda_select_alter_select_for_empty (GdaStatement *stmt, G_GNUC_UNUSED GError **er
 }
 
 /**
- * gda_server_provider_handler_find:
+ * gda_server_provider_handler_find: (skip)
+ * @prov: a #GdaServerProvider
+ * @cnc: (allow-none): a #GdaConnection
+ * @g_type: a #GType
+ * @dbms_type: (allow-none): a database type
  *
- * Returns: (transfer none):
+ * reserved to database provider's implementations: get the #GdaDataHandler associated to @prov
+ * for connection @cnc.
  *
+ * Returns: (transfer none): the requested #GdaDataHandler, or %NULL if none found
  */
 GdaDataHandler *
 gda_server_provider_handler_find (GdaServerProvider *prov, GdaConnection *cnc, 
 				  GType g_type, const gchar *dbms_type)
 {
+	g_return_val_if_fail (GDA_IS_SERVER_PROVIDER (prov), NULL);
+
 	GdaDataHandler *dh;
 	GdaServerProviderHandlerInfo info;
 
@@ -289,6 +318,7 @@ gda_server_provider_handler_declare (GdaServerProvider *prov, GdaDataHandler *dh
 				     GType g_type, const gchar *dbms_type)
 {
 	GdaServerProviderHandlerInfo *info;
+	g_return_if_fail (GDA_IS_SERVER_PROVIDER (prov));
 	g_return_if_fail (GDA_IS_DATA_HANDLER (dh));
 	
 	info = g_new (GdaServerProviderHandlerInfo, 1);
@@ -317,6 +347,7 @@ gda_server_provider_find_file (GdaServerProvider *prov, const gchar *inst_dir, c
 	gchar *file = NULL;
 	const gchar *dirname;
 
+	g_return_val_if_fail (GDA_IS_SERVER_PROVIDER (prov), NULL);
 	dirname = g_object_get_data (G_OBJECT (prov), "GDA_PROVIDER_DIR");
 	if (dirname)
 		file = g_build_filename (dirname, filename, NULL);
diff --git a/libgda/gda-server-provider-extra.h b/libgda/gda-server-provider-extra.h
index 3c65aa7..4879f7e 100644
--- a/libgda/gda-server-provider-extra.h
+++ b/libgda/gda-server-provider-extra.h
@@ -52,6 +52,7 @@ gboolean gda_server_provider_perform_operation_default (GdaServerProvider *provi
 							GdaServerOperation *op, GError **error);
 
 /* default data handler method */
+GdaDataHandler *gda_server_provider_handler_use_default (GdaServerProvider *provider, GType type);
 GdaDataHandler *gda_server_provider_get_data_handler_default (GdaServerProvider *provider, GdaConnection *cnc,
 							      GType type, const gchar *dbms_type);
 
diff --git a/libgda/gda-server-provider.c b/libgda/gda-server-provider.c
index 164c2d2..64b21cf 100644
--- a/libgda/gda-server-provider.c
+++ b/libgda/gda-server-provider.c
@@ -709,7 +709,7 @@ gda_server_provider_get_data_handler_g_type (GdaServerProvider *provider, GdaCon
 	if (CLASS (provider)->get_data_handler)
 		retval = CLASS (provider)->get_data_handler (provider, cnc, for_type, NULL);
 	else
-		retval = gda_server_provider_get_data_handler_default (provider, cnc, for_type, NULL);
+		retval = gda_server_provider_handler_use_default (provider, for_type);
 	if (cnc)
 		gda_lockable_unlock ((GdaLockable*) cnc);
 	return retval;
@@ -722,6 +722,8 @@ gda_server_provider_get_data_handler_g_type (GdaServerProvider *provider, GdaCon
  * @for_type: a DBMS type definition
  *
  * Find a #GdaDataHandler object to manipulate data of type @for_type.
+ *
+ * Note: this function is currently very poorly implemented by database providers.
  * 
  * Returns: (transfer none): a #GdaDataHandler, or %NULL if the provider does not know about the @for_type type
  */
@@ -737,8 +739,6 @@ gda_server_provider_get_data_handler_dbms (GdaServerProvider *provider, GdaConne
 		gda_lockable_lock ((GdaLockable*) cnc);
 	if (CLASS (provider)->get_data_handler)
 		retval = CLASS (provider)->get_data_handler (provider, cnc, G_TYPE_INVALID, for_type);
-	else
-		retval = gda_server_provider_get_data_handler_default (provider, cnc, G_TYPE_INVALID, for_type);
 	if (cnc)
 		gda_lockable_unlock ((GdaLockable*) cnc);
 	return retval;
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index 0ffb878..5f7447a 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -611,6 +611,7 @@
 	gda_server_provider_get_version
 	gda_server_provider_handler_declare
 	gda_server_provider_handler_find
+	gda_server_provider_handler_use_default
 	gda_server_provider_internal_get_parser
 	gda_server_provider_load_file_contents
 	gda_server_provider_perform_operation
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index af5d939..000e63c 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -1739,7 +1739,7 @@ gda_sqlite_provider_get_data_handler (GdaServerProvider *provider, GdaConnection
 		}
 	}
 	else
-		dh = gda_server_provider_get_data_handler_default (provider, cnc, type, dbms_type);
+		dh = gda_server_provider_handler_use_default (provider, type);
 
 	return dh;
 }
diff --git a/providers/firebird/gda-firebird-provider.c b/providers/firebird/gda-firebird-provider.c
index 4a80ac0..683dc8d 100644
--- a/providers/firebird/gda-firebird-provider.c
+++ b/providers/firebird/gda-firebird-provider.c
@@ -988,7 +988,7 @@ gda_firebird_provider_get_data_handler (GdaServerProvider *provider, GdaConnecti
 		dh = NULL;
 	}
 	else
-		dh = gda_server_provider_get_data_handler_default (provider, cnc, type, dbms_type);
+		dh = gda_server_provider_handler_use_default (provider, type);
 
 	return dh;
 }
diff --git a/providers/jdbc/gda-jdbc-provider.c b/providers/jdbc/gda-jdbc-provider.c
index a92c610..168a17d 100644
--- a/providers/jdbc/gda-jdbc-provider.c
+++ b/providers/jdbc/gda-jdbc-provider.c
@@ -948,7 +948,7 @@ gda_jdbc_provider_get_data_handler (GdaServerProvider *provider, GdaConnection *
                 }
 	}
 	else
-		dh = gda_server_provider_get_data_handler_default (provider, cnc, type, dbms_type);
+		dh = gda_server_provider_handler_use_default (provider, type);
 
 	return dh;
 }
diff --git a/providers/mysql/gda-mysql-provider.c b/providers/mysql/gda-mysql-provider.c
index d83d073..b2f6282 100644
--- a/providers/mysql/gda-mysql-provider.c
+++ b/providers/mysql/gda-mysql-provider.c
@@ -1348,7 +1348,7 @@ gda_mysql_provider_get_data_handler (GdaServerProvider  *provider,
                 }
 	}
 	else
-		dh = gda_server_provider_get_data_handler_default (provider, cnc, type, dbms_type);
+		dh = gda_server_provider_handler_use_default (provider, type);
 
 	return dh;
 }
diff --git a/providers/oracle/gda-oracle-provider.c b/providers/oracle/gda-oracle-provider.c
index bb8a7e7..64ce3ec 100644
--- a/providers/oracle/gda-oracle-provider.c
+++ b/providers/oracle/gda-oracle-provider.c
@@ -1176,7 +1176,7 @@ gda_oracle_provider_get_data_handler (GdaServerProvider *provider, GdaConnection
 		dh = NULL;
 	}
 	else
-		dh = gda_server_provider_get_data_handler_default (provider, cnc, type, dbms_type);
+		dh = gda_server_provider_handler_use_default (provider, type);
 
 	return dh;
 }
diff --git a/providers/postgres/gda-postgres-provider.c b/providers/postgres/gda-postgres-provider.c
index 9ab23a8..0941353 100644
--- a/providers/postgres/gda-postgres-provider.c
+++ b/providers/postgres/gda-postgres-provider.c
@@ -1358,7 +1358,7 @@ gda_postgres_provider_get_data_handler (GdaServerProvider *provider, GdaConnecti
                 }
 	}
 	else
-		dh = gda_server_provider_get_data_handler_default (provider, cnc, type, dbms_type);
+		dh = gda_server_provider_handler_use_default (provider, type);
 
 	return dh;
 }
diff --git a/providers/skel-implementation/capi/gda-capi-provider.c b/providers/skel-implementation/capi/gda-capi-provider.c
index 4582943..8159f91 100644
--- a/providers/skel-implementation/capi/gda-capi-provider.c
+++ b/providers/skel-implementation/capi/gda-capi-provider.c
@@ -817,7 +817,7 @@ gda_capi_provider_get_data_handler (GdaServerProvider *provider, GdaConnection *
 		dh = NULL;
 	}
 	else
-		dh = gda_server_provider_get_data_handler_default (provider, cnc, type, dbms_type);
+		dh = gda_server_provider_handler_use_default (provider, type);
 
 	return dh;
 }



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