[libgda] Improvements on GdaDataModelLdap for bindings * Added gda_data_model_ldap_new_with_config to be used



commit 0c271e2db95cf865c182e77bfbb7950e6349ee72
Author: Daniel Espinosa <despinosa src gnome org>
Date:   Tue Feb 14 14:47:48 2012 -0600

    Improvements on GdaDataModelLdap for bindings
    * Added gda_data_model_ldap_new_with_config to be used in GI bindings, avoids
    future API break due to use gda_data_model_new not detected as a constructor by GIR

 libgda/gda-data-model-ldap.c |   53 +++++++++++++++++++++++++++++++++++++++++-
 libgda/gda-data-model-ldap.h |   11 +++++---
 libgda/libgda.symbols        |    1 +
 3 files changed, 60 insertions(+), 5 deletions(-)
---
diff --git a/libgda/gda-data-model-ldap.c b/libgda/gda-data-model-ldap.c
index 3c5ec4b..5afc8ac 100644
--- a/libgda/gda-data-model-ldap.c
+++ b/libgda/gda-data-model-ldap.c
@@ -165,7 +165,7 @@ gda_data_model_ldap_get_type (void)
 }
 
 /**
- * gda_data_model_ldap_new:
+ * gda_data_model_ldap_new: (skip):
  * @cnc: an LDAP opened connection (must be a balid #GdaLdapConnection)
  * @base_dn: (allow-none): the base DN to search on, or %NULL
  * @filter: (allow-none): an LDAP filter, for example "(objectClass=*)"
@@ -214,6 +214,57 @@ gda_data_model_ldap_new (GdaConnection *cnc,
 }
 
 /**
+ * gda_data_model_ldap_new_with_config:
+ * @cnc: an LDAP opened connection (must be a balid #GdaLdapConnection)
+ * @base_dn: (allow-none): the base DN to search on, or %NULL
+ * @filter: (allow-none): an LDAP filter, for example "(objectClass=*)"
+ * @attributes: (allow-none): the list (CSV format) of attributes to fetch, each in the format &lt;attname&gt;[::&lt;GType&gt;]
+ * @scope: the search scope
+ *
+ * Creates a new #GdaDataModel object to extract some LDAP contents. The returned data model will
+ * contain one row for each LDAP entry returned by the search, and will
+ * always return the DN (Distinguished Name) of the LDAP entry as first column. Other atttibutes
+ * may be mapped to other columns, see the @attributes argument.
+ *
+ * Note that the actual LDAP search command is not executed until necessary (when using the returned
+ * data model).
+ *
+ * The @base_dn is the point in the LDAP's DIT (Directory Information Tree) from where the search will
+ * occur, for example "dc=gda,dc=org". A %NULL value indicates that the starting point for the
+ * search will be the one specified when opening the LDAP connection.
+ *
+ * The @filter argument is a valid LDAP filter string, for example "(uidNumber=1001)". If %NULL, then
+ * a default search filter of "(objectClass=*)" will be used.
+ *
+ * @attributes specifies which LDAP attributes the search must return. It is a comma separated list
+ * of attribute names, for example "uidNumber, mail, uid, jpegPhoto" (spaces between attribute names
+ * are ignored). If %NULL, then no attribute will be fetched. See gda_ldap_connection_declare_table()
+ * for more information about this argument.
+ *
+ * @scope is the scope of search specified when the LDAP search is actually executed.
+ *
+ * In case of multi valued attributes, an error will be returned when trying to read the attribute:
+ * gda_data_model_iter_get_value_at() will return %NULL when using an iterator.
+ *
+ * This is a convenience function intended to be used by bindings.
+ *
+ * Returns: (transfer full): a new #GdaDataModelLdap object
+ *
+ * Since: 5.2
+ */
+GdaDataModelLdap*
+gda_data_model_ldap_new_with_config (GdaConnection *cnc,
+			 const gchar *base_dn, const gchar *filter,
+			 const gchar *attributes, GdaLdapSearchScope scope)
+{
+	g_return_val_if_fail (GDA_IS_LDAP_CONNECTION (cnc), NULL);
+	return (GdaDataModelLdap*) g_object_new (GDA_TYPE_DATA_MODEL_LDAP,
+					     "cnc", cnc, "base", base_dn,
+					     "filter", filter, "attributes", attributes,
+					     "scope", scope, NULL);
+}
+
+/**
  * gda_data_model_ldap_compute_columns:
  * @cnc: a #GdaConnection
  * @attributes: (allow-none): a string describing which LDAP attributes to retreive, or %NULL
diff --git a/libgda/gda-data-model-ldap.h b/libgda/gda-data-model-ldap.h
index 6215ccf..702a9ef 100644
--- a/libgda/gda-data-model-ldap.h
+++ b/libgda/gda-data-model-ldap.h
@@ -77,10 +77,13 @@ typedef enum {
  * if the LDAP provider is correctly installed.
  */
 
-GType         gda_data_model_ldap_get_type     (void) G_GNUC_CONST;
-GdaDataModel *gda_data_model_ldap_new          (GdaConnection *cnc,
-						const gchar *base_dn, const gchar *filter,
-						const gchar *attributes, GdaLdapSearchScope scope);
+GType             gda_data_model_ldap_get_type        (void) G_GNUC_CONST;
+GdaDataModel     *gda_data_model_ldap_new             (GdaConnection *cnc,
+							const gchar *base_dn, const gchar *filter,
+							const gchar *attributes, GdaLdapSearchScope scope);
+GdaDataModelLdap *gda_data_model_ldap_new_with_config  (GdaConnection *cnc,
+							const gchar *base_dn, const gchar *filter,
+							const gchar *attributes, GdaLdapSearchScope scope);
 
 GList        *gda_data_model_ldap_compute_columns (GdaConnection *cnc, const gchar *attributes);
 
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index 1040a56..d41187a 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -275,6 +275,7 @@
 	gda_data_model_ldap_compute_columns
 	gda_data_model_ldap_get_type
 	gda_data_model_ldap_new
+	gda_data_model_ldap_new_with_config
 #endif
 	gda_data_model_remove_row
 	gda_data_model_reset



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