From 67394f471210a18b68fcb5a7c290b552541e07e0 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Thu, 22 Mar 2007 17:53:17 +0000 Subject: [PATCH] 2007-03-22 [colin] 2.8.1cvs38 * src/addrindex.c * src/ldapctrl.h * src/ldapquery.c Add any attribute specified in LDAP servers' Search attributes to the Other Attributes tab of contacts; Add 'telephoneNumber' in the default list. --- ChangeLog | 10 ++++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/addrindex.c | 1 + src/ldapctrl.h | 3 ++- src/ldapquery.c | 35 +++++++++++++++++++++++++++-------- 6 files changed, 42 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef79d0399..8d10777dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-03-22 [colin] 2.8.1cvs38 + + * src/addrindex.c + * src/ldapctrl.h + * src/ldapquery.c + Add any attribute specified in LDAP servers' + Search attributes to the Other Attributes tab + of contacts; Add 'telephoneNumber' in the + default list. + 2007-03-22 [colin] 2.8.1cvs37 * src/folderview.c diff --git a/PATCHSETS b/PATCHSETS index 7ae96afdc..dcd7dc789 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -2454,3 +2454,4 @@ ( cvs diff -u -r 1.654.2.2506 -r 1.654.2.2507 configure.ac; cvs diff -u -r 1.1.2.1 -r 1.1.2.2 claws-mail.desktop; ) > 2.8.1cvs35.patchset ( cvs diff -u -r 1.274.2.179 -r 1.274.2.180 src/mainwindow.c; cvs diff -u -r 1.39.2.35 -r 1.39.2.36 src/mainwindow.h; cvs diff -u -r 1.79.2.53 -r 1.79.2.54 src/mh.c; cvs diff -u -r 1.395.2.288 -r 1.395.2.289 src/summaryview.c; cvs diff -u -r 1.36.2.99 -r 1.36.2.100 src/common/utils.c; cvs diff -u -r 1.20.2.12 -r 1.20.2.13 src/gtk/Makefile.am; ) > 2.8.1cvs36.patchset ( cvs diff -u -r 1.207.2.153 -r 1.207.2.154 src/folderview.c; cvs diff -u -r 1.20.2.19 -r 1.20.2.20 src/folderview.h; cvs diff -u -r 1.274.2.180 -r 1.274.2.181 src/mainwindow.c; cvs diff -u -r 1.395.2.289 -r 1.395.2.290 src/summaryview.c; ) > 2.8.1cvs37.patchset +( cvs diff -u -r 1.28.2.24 -r 1.28.2.25 src/addrindex.c; cvs diff -u -r 1.1.4.8 -r 1.1.4.9 src/ldapctrl.h; cvs diff -u -r 1.3.2.16 -r 1.3.2.17 src/ldapquery.c; ) > 2.8.1cvs38.patchset diff --git a/configure.ac b/configure.ac index eecf76f7c..8a0dde953 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=1 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=37 +EXTRA_VERSION=38 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/addrindex.c b/src/addrindex.c index ab86a65a1..8b05033c7 100644 --- a/src/addrindex.c +++ b/src/addrindex.c @@ -1340,6 +1340,7 @@ static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) { else if( strcmp( name, ATTAG_LDAP_CRITERIA ) == 0 ) { g_free( criteria ); criteria = g_strdup( value ); + printf("criteria %s\n", criteria); } else if( strcmp( name, ATTAG_LDAP_MAX_ENTRY ) == 0 ) { ldapctl_set_max_entries( ctl, ivalue ); diff --git a/src/ldapctrl.h b/src/ldapctrl.h index c04687001..c7ca21d47 100644 --- a/src/ldapctrl.h +++ b/src/ldapctrl.h @@ -44,8 +44,9 @@ #define LDAPCTL_ATTR_COMMONNAME "cn" #define LDAPCTL_ATTR_GIVENNAME "givenName" #define LDAPCTL_ATTR_SURNAME "sn" +#define LDAPCTL_ATTR_PHONE "telephoneNumber" -#define LDAPCTL_DFL_ATTR_LIST "mail, cn, givenName, sn" +#define LDAPCTL_DFL_ATTR_LIST "mail, cn, givenName, sn, telephoneNumber" /* * Search matching options. diff --git a/src/ldapquery.c b/src/ldapquery.c index 6316cd173..5c7f83759 100644 --- a/src/ldapquery.c +++ b/src/ldapquery.c @@ -353,12 +353,16 @@ void ldapqry_free( LdapQuery *qry ) { */ static void ldapqry_free_lists( GSList *listName, GSList *listAddr, GSList *listFirst, - GSList *listLast ) + GSList *listLast, GSList *other_attrs ) { + GSList *cur = other_attrs; mgu_free_list( listName ); mgu_free_list( listAddr ); mgu_free_list( listFirst ); mgu_free_list( listLast ); + for(;cur; cur = cur->next) + addritem_free_attribute((UserAttribute *)cur->data); + g_slist_free(other_attrs); } /** @@ -430,9 +434,9 @@ static GSList *ldapqry_add_single_value( LDAP *ld, LDAPMessage *entry, char *att static GList *ldapqry_build_items_fl( AddressCache *cache, LdapQuery *qry, gchar *dn, GSList *listName, GSList *listAddr, GSList *listFirst, - GSList *listLast ) + GSList *listLast, GSList *attributes ) { - GSList *nodeAddress; + GSList *nodeAddress, *cur; gchar *firstName = NULL, *lastName = NULL, *fullName = NULL; gboolean allocated; ItemPerson *person; @@ -483,6 +487,12 @@ static GList *ldapqry_build_items_fl( addritem_person_set_last_name( person, lastName ); addrcache_id_person( cache, person ); addritem_person_set_external_id( person, dn ); + + for (cur = attributes; cur; cur = cur->next) { + UserAttribute *attrib = addritem_copy_attribute((UserAttribute *)cur->data); + addritem_person_add_attribute( person, attrib ); + } + addrcache_folder_add_person( cache, ADDRQUERY_FOLDER(qry), person ); qry->entriesRead++; @@ -525,6 +535,7 @@ static GList *ldapqry_process_single_entry( BerElement *ber; GSList *listName = NULL, *listAddress = NULL; GSList *listFirst = NULL, *listLast = NULL; + GSList *other_attrs = NULL; GList *listReturn; listReturn = NULL; @@ -535,7 +546,6 @@ static GList *ldapqry_process_single_entry( /* Process all attributes */ for( attribute = ldap_first_attribute( ld, e, &ber ); attribute != NULL; attribute = ldap_next_attribute( ld, e, ber ) ) { - if( strcasecmp( attribute, ctl->attribEMail ) == 0 ) { listAddress = ldapqry_add_list_values( ld, e, attribute ); } @@ -547,19 +557,28 @@ static GList *ldapqry_process_single_entry( } else if( strcasecmp( attribute, ctl->attribLName ) == 0 ) { listLast = ldapqry_add_single_value( ld, e, attribute ); + } else { + GSList *attlist = ldapqry_add_single_value( ld, e, attribute ); + UserAttribute *attrib = addritem_create_attribute(); + const gchar *attvalue = attlist?((gchar *)attlist->data):NULL; + if (attvalue) { + addritem_attrib_set_name( attrib, attribute ); + addritem_attrib_set_value( attrib, attvalue ); + other_attrs = g_slist_prepend(other_attrs, attrib); + } + mgu_free_list(attlist); } - /* Free memory used to store attribute */ ldap_memfree( attribute ); } /* Format and add items to cache */ listReturn = ldapqry_build_items_fl( - cache, qry, dnEntry, listName, listAddress, listFirst, listLast ); + cache, qry, dnEntry, listName, listAddress, listFirst, listLast, other_attrs ); /* Free up */ - ldapqry_free_lists( listName, listAddress, listFirst, listLast ); - listName = listAddress = listFirst = listLast = NULL; + ldapqry_free_lists( listName, listAddress, listFirst, listLast, other_attrs ); + listName = listAddress = listFirst = listLast = other_attrs = NULL; if( ber != NULL ) { ber_free( ber, 0 ); -- 2.25.1