From: Colin Leroy Date: Tue, 21 Aug 2007 09:37:03 +0000 (+0000) Subject: 2007-08-21 [colin] 2.10.0cvs142 X-Git-Tag: rel_3_0_0~51 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=cc805ae1d452897db93307213e1068145f02954c;ds=sidebyside 2007-08-21 [colin] 2.10.0cvs142 * src/editldap.c * src/ldapctrl.c * src/ldapctrl.h * src/ldapquery.c * src/ldapupdate.c Fix bug 1293, 'LDAP address book not working' Search only on specified fields, but fetch every field possible. People will have to reset the searched Attributes in their LDAP servers properties. --- diff --git a/ChangeLog b/ChangeLog index 7db4f8974..a0372ac21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-08-21 [colin] 2.10.0cvs142 + + * src/editldap.c + * src/ldapctrl.c + * src/ldapctrl.h + * src/ldapquery.c + * src/ldapupdate.c + Fix bug 1293, 'LDAP address book not working' + Search only on specified fields, but fetch + every field possible. People will have to + reset the searched Attributes in their LDAP + servers properties. + 2007-08-21 [wwp] 2.10.0cvs141 * src/addr_compl.c diff --git a/PATCHSETS b/PATCHSETS index be35c963a..89ae2a51a 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -2796,3 +2796,4 @@ ( cvs diff -u -r 1.274.2.205 -r 1.274.2.206 src/mainwindow.c; cvs diff -u -r 1.94.2.145 -r 1.94.2.146 src/messageview.c; ) > 2.10.0cvs139.patchset ( cvs diff -u -r 1.115.2.162 -r 1.115.2.163 src/main.c; cvs diff -u -r 1.20.2.48 -r 1.20.2.49 src/common/utils.h; ) > 2.10.0cvs140.patchset ( cvs diff -u -r 1.27.2.39 -r 1.27.2.40 src/addr_compl.c; cvs diff -u -r 1.22.2.15 -r 1.22.2.16 src/addrbook.c; cvs diff -u -r 1.15.2.13 -r 1.15.2.14 src/addrcache.c; cvs diff -u -r 1.1.4.5 -r 1.1.4.6 src/addrcindex.c; cvs diff -u -r 1.60.2.94 -r 1.60.2.95 src/addressbook.c; cvs diff -u -r 1.28.2.29 -r 1.28.2.30 src/addrindex.c; cvs diff -u -r 1.2.4.18 -r 1.2.4.19 src/browseldap.c; cvs diff -u -r 1.23.2.25 -r 1.23.2.26 src/crash.c; cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/editaddress_other_attributes_ldap.c; cvs diff -u -r 1.5.2.21 -r 1.5.2.22 src/exporthtml.c; cvs diff -u -r 1.213.2.156 -r 1.213.2.157 src/folder.c; cvs diff -u -r 1.207.2.175 -r 1.207.2.176 src/folderview.c; cvs diff -u -r 1.179.2.183 -r 1.179.2.184 src/imap.c; cvs diff -u -r 1.18.2.25 -r 1.18.2.26 src/jpilot.c; cvs diff -u -r 1.4.2.12 -r 1.4.2.13 src/ldapserver.c; cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/ldapupdate.c; cvs diff -u -r 1.12.2.14 -r 1.12.2.15 src/ldif.c; cvs diff -u -r 1.115.2.163 -r 1.115.2.164 src/main.c; cvs diff -u -r 1.274.2.206 -r 1.274.2.207 src/mainwindow.c; cvs diff -u -r 1.75.2.46 -r 1.75.2.47 src/matcher.c; cvs diff -u -r 1.79.2.60 -r 1.79.2.61 src/mh.c; cvs diff -u -r 1.16.2.58 -r 1.16.2.59 src/msgcache.c; cvs diff -u -r 1.6.10.12 -r 1.6.10.13 src/mutt.c; cvs diff -u -r 1.6.2.11 -r 1.6.2.12 src/pine.c; cvs diff -u -r 1.56.2.53 -r 1.56.2.54 src/pop.c; cvs diff -u -r 1.16.2.27 -r 1.16.2.28 src/prefs_customheader.c; cvs diff -u -r 1.1.2.34 -r 1.1.2.35 src/prefs_msg_colors.c; cvs diff -u -r 1.49.2.95 -r 1.49.2.96 src/procmime.c; cvs diff -u -r 1.96.2.181 -r 1.96.2.182 src/textview.c; cvs diff -u -r 1.14.2.10 -r 1.14.2.11 src/vcard.c; cvs diff -u -r 1.1.2.59 -r 1.1.2.60 src/wizard.c; cvs diff -u -r 1.6.2.14 -r 1.6.2.15 src/common/log.c; cvs diff -u -r 1.13.2.34 -r 1.13.2.35 src/common/socket.c; cvs diff -u -r 1.4.2.19 -r 1.4.2.20 src/common/ssl_certificate.c; cvs diff -u -r 1.36.2.109 -r 1.36.2.110 src/common/utils.c; cvs diff -u -r 1.20.2.49 -r 1.20.2.50 src/common/utils.h; cvs diff -u -r 1.5.2.22 -r 1.5.2.23 src/gtk/description_window.c; cvs diff -u -r 1.13.2.16 -r 1.13.2.17 src/plugins/demo/demo.c; cvs diff -u -r 1.1.2.26 -r 1.1.2.27 src/plugins/pgpcore/prefs_gpg.c; cvs diff -u -r 1.4.2.6 -r 1.4.2.7 src/plugins/spamassassin/libspamc.c; ) > 2.10.0cvs141.patchset +( cvs diff -u -r 1.8.2.25 -r 1.8.2.26 src/editldap.c; cvs diff -u -r 1.2.2.13 -r 1.2.2.14 src/ldapctrl.c; cvs diff -u -r 1.1.4.12 -r 1.1.4.13 src/ldapctrl.h; cvs diff -u -r 1.3.2.21 -r 1.3.2.22 src/ldapquery.c; cvs diff -u -r 1.1.2.12 -r 1.1.2.13 src/ldapupdate.c; ) > 2.10.0cvs142.patchset diff --git a/configure.ac b/configure.ac index 8da34cb60..592e4f329 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=10 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=141 +EXTRA_VERSION=142 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/editldap.c b/src/editldap.c index 6bbca3d7d..6aa5af20d 100644 --- a/src/editldap.c +++ b/src/editldap.c @@ -315,8 +315,8 @@ static void edit_ldap_basedn_select( void ) { g_free( sPass ); } -static void edit_ldap_search_reset() { - gtk_entry_set_text(GTK_ENTRY(ldapedit.entry_criteria), ldapctl_get_default_criteria()); +static void edit_ldap_search_reset(void) { + gtk_entry_set_text(GTK_ENTRY(ldapedit.entry_criteria), LDAPCTL_DFL_ATTR_LIST); } static void addressbook_edit_ldap_dialog_create( gboolean *cancelled ) { @@ -597,7 +597,6 @@ static void addressbook_edit_ldap_page_search( gint pageNum, gchar *pageLbl ) { gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); entry_criteria = gtk_entry_new(); - gtk_editable_set_editable(GTK_EDITABLE(entry_criteria), FALSE); gtk_table_attach(GTK_TABLE(table), entry_criteria, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0); @@ -885,7 +884,7 @@ static void editldap_parse_criteria( gchar *criteria, LdapControl *ctl ) { /** * Clear entry fields to reasonable defaults (for a new server entry). */ -static void edit_ldap_clear_fields() { +static void edit_ldap_clear_fields(void) { gtk_entry_set_text( GTK_ENTRY(ldapedit.entry_name), ADDRESSBOOK_GUESS_LDAP_NAME ); gtk_entry_set_text( @@ -900,7 +899,7 @@ static void edit_ldap_clear_fields() { gtk_spin_button_set_value( GTK_SPIN_BUTTON( ldapedit.spinbtn_maxentry ), LDAPCTL_DFL_TIMEOUT ); gtk_entry_set_text( - GTK_ENTRY(ldapedit.entry_criteria), ldapctl_get_default_criteria()); + GTK_ENTRY(ldapedit.entry_criteria), LDAPCTL_DFL_ATTR_LIST); gtk_spin_button_set_value( GTK_SPIN_BUTTON(ldapedit.spinbtn_queryage), LDAPCTL_DFL_QUERY_AGE ); gtk_toggle_button_set_active( @@ -1006,7 +1005,7 @@ AdapterDSource *addressbook_edit_ldap( GTK_WINDOW(ldapedit.window), _("Edit LDAP Server")); } else { - edit_ldap_clear_fields(NULL); + edit_ldap_clear_fields(); gtk_window_set_title( GTK_WINDOW(ldapedit.window), _("Add New LDAP Server")); } diff --git a/src/ldapctrl.c b/src/ldapctrl.c index 4cfc74c07..9207d3d58 100644 --- a/src/ldapctrl.c +++ b/src/ldapctrl.c @@ -570,25 +570,54 @@ gchar *ldapctl_format_criteria( LdapControl *ctl, const gchar *searchVal ) { * \return NULL terminated list. */ char **ldapctl_attribute_array( LdapControl *ctl ) { + char **ptrArray; + GList *node; + gint cnt, i; + g_return_val_if_fail( ctl != NULL, NULL ); + + node = ctl->listCriteria; + cnt = g_list_length( ctl->listCriteria ); + ptrArray = g_new0( char *, 1 + cnt ); + i = 0; + while( node ) { + ptrArray[ i++ ] = node->data; + /*debug_print("adding search attribute: %s\n", (gchar *) node->data);*/ + node = g_list_next( node ); + } + ptrArray[ i ] = NULL; + return ptrArray; +} + +/** + * Return array of pointers to attributes for LDAP query. + * \param ctl Control object to process. + * \return NULL terminated list. + */ +char **ldapctl_full_attribute_array( LdapControl *ctl ) { char **ptrArray; GList *node, *def; + GList *tmp = NULL; gint cnt, i; g_return_val_if_fail( ctl != NULL, NULL ); + def = ctl->listCriteria; + while (def) { + tmp = g_list_append(tmp, g_strdup(def->data)); + def = def->next; + } + def = ldapctl_get_default_criteria_list(); - /* check if this servers config is updated to the new - * default list of search criteria. If not update the list */ - if (! ldapctl_compare_list(ctl->listCriteria, def)) { - /* Deep copy search criteria */ - ldapctl_criteria_list_clear(ctl); - while(def) { - ctl->listCriteria = g_list_append( - ctl->listCriteria, g_strdup(def->data)); - def = g_list_next(def); + + while (def) { + if( g_list_find_custom(tmp, (gpointer)def->data, + (GCompareFunc)strcmp2) == NULL) { + tmp = g_list_append(tmp, g_strdup(def->data)); } + def = def->next; } - node = ctl->listCriteria; - cnt = g_list_length( ctl->listCriteria ); + + node = tmp; + cnt = g_list_length( tmp ); ptrArray = g_new0( char *, 1 + cnt ); i = 0; while( node ) { diff --git a/src/ldapctrl.h b/src/ldapctrl.h index f3a5a09b7..a5d031c42 100644 --- a/src/ldapctrl.h +++ b/src/ldapctrl.h @@ -103,6 +103,7 @@ void ldapctl_copy ( const LdapControl *ctlFrom, LdapControl *ctlTo ); gchar *ldapctl_format_criteria ( LdapControl *ctl, const gchar *searchVal ); char **ldapctl_attribute_array ( LdapControl *ctl ); +char **ldapctl_full_attribute_array( LdapControl *ctl ); void ldapctl_free_attribute_array( char **ptrArray ); void ldapctl_parse_ldap_search ( LdapControl *ctl, gchar *criteria ); gchar *ldapctl_get_default_criteria(void); diff --git a/src/ldapquery.c b/src/ldapquery.c index a13af7b75..d6ce17aca 100644 --- a/src/ldapquery.c +++ b/src/ldapquery.c @@ -783,7 +783,7 @@ static gint ldapqry_search_retrieve( LdapQuery *qry ) { ADDRQUERY_RETVAL(qry) = LDAPRC_SUCCESS; /* Define all attributes we are interested in. */ - attribs = ldapctl_attribute_array( ctl ); + attribs = ldapctl_full_attribute_array( ctl ); /* Create LDAP search string */ criteria = ldapctl_format_criteria( ctl, ADDRQUERY_SEARCHVALUE(qry) ); diff --git a/src/ldapupdate.c b/src/ldapupdate.c index 47472ca98..d8425c67c 100644 --- a/src/ldapupdate.c +++ b/src/ldapupdate.c @@ -930,7 +930,7 @@ void ldapsvr_handle_other_attributes(LDAP *ld, LdapServer *server, char *dn, GHa } node = g_list_next(node); } - char **attribs = ldapctl_attribute_array(server->control); + char **attribs = ldapctl_full_attribute_array(server->control); for (i = 0; i < ATTRIBUTE_SIZE; i++) { /* Attributes which holds no information are to be removed */ if (CHECKED_ATTRIBUTE[i] == FALSE) { @@ -967,11 +967,7 @@ void ldapsvr_handle_other_attributes(LDAP *ld, LdapServer *server, char *dn, GHa } } else { - /* Only consider those attributes which is currently part of the search criteria. - * If attributes are not part of the search criteria they would seem to hold - * no information since their values will not be populated in the GUI - */ - char **attribs = ldapctl_attribute_array(server->control); + char **attribs = ldapctl_full_attribute_array(server->control); for (i = 0; i < ATTRIBUTE_SIZE; i++) { if (ldapsvr_check_search_attributes(attribs, (char *) ATTRIBUTE[i])) { if (CHECKED_ATTRIBUTE[i] == FALSE) {