[libgda] LDAP provider: misc improvements



commit 7c8a5681635a3c9bfde7b7e485cbbce34bb04019
Author: Vivien Malerba <malerba gnome-db org>
Date:   Wed Jun 15 17:49:56 2011 +0200

    LDAP provider: misc improvements

 providers/ldap/gda-ldap-provider.c |    7 ++-----
 providers/ldap/gda-ldap-util.c     |   24 +++++++++++++++++++++---
 2 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/providers/ldap/gda-ldap-provider.c b/providers/ldap/gda-ldap-provider.c
index 8ddab8d..50b409c 100644
--- a/providers/ldap/gda-ldap-provider.c
+++ b/providers/ldap/gda-ldap-provider.c
@@ -328,7 +328,7 @@ gda_ldap_provider_open_connection (GdaServerProvider *provider, GdaConnection *c
 			return FALSE;
 		}
         }
-	int param = LDAP_OPT_ON;
+	int param = (int) LDAP_OPT_ON;
 	res = ldap_set_option (cdata->handle, LDAP_OPT_RESTART, &param);
 
 #ifdef NO
@@ -689,8 +689,6 @@ static const gchar *
 scope_to_string (GdaLdapSearchScope scope)
 {
 	switch (scope) {
-	case 0:
-		return _("Unknown");
 	case GDA_LDAP_SEARCH_BASE:
 		return "BASE";
 	case GDA_LDAP_SEARCH_ONELEVEL:
@@ -698,8 +696,7 @@ scope_to_string (GdaLdapSearchScope scope)
 	case GDA_LDAP_SEARCH_SUBTREE:
 		return "SUBTREE";
 	default:
-		g_assert_not_reached();
-		return NULL;
+		return _("Unknown");
 	}
 }
 
diff --git a/providers/ldap/gda-ldap-util.c b/providers/ldap/gda-ldap-util.c
index 46faf82..c836e4e 100644
--- a/providers/ldap/gda-ldap-util.c
+++ b/providers/ldap/gda-ldap-util.c
@@ -523,8 +523,8 @@ static gint classes_sort (GdaLdapClass *lcl1, GdaLdapClass *lcl2);
 
 /**
  * gdaprov_ldap_get_class_info:
- * @cdata:
- * @class:
+ * @cnc: a #GdaLdapConnection (not %NULL)
+ * @classname: the class name (not %NULL)
  *
  * Returns: the #GdaLdapClass for @classname, or %NULL
  */
@@ -719,6 +719,22 @@ gdaprov_ldap_get_class_info (GdaLdapConnection *cnc, const gchar *classname)
 	return retval;
 }
 
+static gint
+my_sort_func (gconstpointer a, gconstpointer b)
+{
+	gchar *sa, *sb;
+	sa = * (gchar**) a;
+	sb = * (gchar**) b;
+	if (sa && sb)
+		return g_utf8_collate (sa, sb);
+	else if (sa)
+		return -1;
+	else if (sb)
+		return 1;
+	else
+		return 0;
+}
+
 static gchar **
 make_array_from_strv (char **values, guint *out_size)
 {
@@ -737,13 +753,15 @@ make_array_from_strv (char **values, guint *out_size)
 	if (out_size)
 		*out_size = array->len;
 
+	g_array_sort (array, (GCompareFunc) my_sort_func);
+
 	return (gchar**) g_array_free (array, FALSE);
 }
 
 static gint
 classes_sort (GdaLdapClass *lcl1, GdaLdapClass *lcl2)
 {
-	return g_ascii_strcasecmp (lcl1->names[0], lcl2->names[0]);
+	return g_utf8_collate (lcl1->names[0], lcl2->names[0]);
 }
 
 static void



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