[Commits] ldap-plugin.c 1.13 1.14

miras at claws-mail.org miras at claws-mail.org
Sat Dec 17 03:52:25 CET 2011


Update of /home/claws-mail/contacts/plugins/ldap
In directory claws-mail:/tmp/cvs-serv16939/plugins/ldap

Modified Files:
	ldap-plugin.c 
Log Message:
2011-12-17 [mir]	0.6.0cvs48

	* plugins/ldap/ldap-plugin.c
	* src/utils.c
	* src/utils.h
	    More user friendly error message when adding
	    and updating contacts.
	    Move some useful methods to utils.{c,h}.

Index: ldap-plugin.c
===================================================================
RCS file: /home/claws-mail/contacts/plugins/ldap/ldap-plugin.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- ldap-plugin.c	13 Dec 2011 10:37:14 -0000	1.13
+++ ldap-plugin.c	17 Dec 2011 02:52:22 -0000	1.14
@@ -610,36 +610,6 @@
 	}
 }
 
-static const gchar* native2ldap(const gchar* attr) {
-	if (strcasecmp(attr, "email") == 0)
-		return "mail";
-	else if (strcasecmp(attr, "first-name") == 0)
-		return "givenName";
-	else if (strcasecmp(attr, "last-name") == 0)
-		return "sn";
-	else if (strcasecmp(attr, "nick-name") == 0)
-		return "displayName";
-	else if (strcasecmp(attr, "image") == 0)
-		return "jpegPhoto";
-	else
-		return attr;
-}
-
-static const gchar* ldap2native(const gchar* attr) {
-	if (strcasecmp(attr, "mail") == 0)
-		return "email";
-	else if (strcasecmp(attr, "givenName") == 0)
-		return "first-name";
-	else if (strcasecmp(attr, "sn") == 0)
-		return "last-name";
-	else if (strcasecmp(attr, "displayName") == 0)
-		return "nick-name";
-	else if (strcasecmp(attr, "jpegPhoto") == 0)
-		return "image";
-	else
-		return attr;
-}
-
 static gchar** ldap2native_list(const gchar** list) {
 	gchar **new_list, **tmp, **head;
 	guint len;
@@ -1658,15 +1628,16 @@
 		print_ldapmod(mods);
 	
 	rc = ldap_add_ext_s(server->ldap, dn, mods, NULL, NULL);
-	g_free(dn);
 	mods_free(mods);
 	if (rc) {
 		debug_print("LDAP ADD: %s\n", ldap_err2string(rc));
 		if (error)
-			*error = g_strdup(ldap_err2string(rc));
+			*error = g_strconcat("dn: ", dn, "\n", ldap_err2string(rc), NULL);
 		abook->dirty = FALSE;
+		g_free(dn);
 	}
 	else {
+		g_free(dn);
 		abook->dirty = TRUE;
 		deconnect(ac->server);
 		return FALSE;
@@ -1902,16 +1873,17 @@
 				rc = ldap_modify_ext_s(server->ldap, dn, mods, NULL, NULL);
 				mods_free(mods);
 			}
-			g_free(dn);
 			if (rc) {
 				debug_print("LDAP MODIFY: %s\n", ldap_err2string(rc));
 				if (error)
-					*error = g_strdup(ldap_err2string(rc));
+					*error = g_strconcat("dn: ", dn, "\n", ldap_err2string(rc), NULL);
+				g_free(dn);
 				abook->dirty = FALSE;
 				deconnect(ac->server);
 				return TRUE;
 			}
 			else {
+				g_free(dn);
 				abook->dirty = TRUE;
 				deconnect(ac->server);
 				return FALSE;



More information about the Commits mailing list