From: Paul Mangan Date: Sat, 21 Dec 2002 08:54:24 +0000 (+0000) Subject: fix bug 643638 X-Git-Tag: rel_0_8_7~12 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=4fd905f07b9bef159cfbbf2a863323fe560dc6e2;ds=sidebyside fix bug 643638 --- diff --git a/ChangeLog.claws b/ChangeLog.claws index d302c3fd2..ebaa11f4d 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,11 @@ +2002-12-21 [paul] 0.8.6claws122 + + * src/addrbook.c + fix bug [643638] where if a person is in one or more + addressbook groups editing that person's email + address results in removal from those groups. + Patch submitted by Luke Plant. + 2002-12-20 [christoph] 0.8.6claws121 * src/common/utils.c diff --git a/configure.in b/configure.in index 52331f313..79c305a5f 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=6 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws121 +EXTRA_VERSION=claws122 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/addrbook.c b/src/addrbook.c index 3fbef002e..138b9b62e 100644 --- a/src/addrbook.c +++ b/src/addrbook.c @@ -1214,19 +1214,24 @@ void addrbook_update_address_list( listGroup = addrcache_get_group_for_person( book->addressCache, person ); if( listGroup ) { GHashTable *hashEMail; + GHashTable *hashEMailAlias; GList *nodeGrp; /* Load hash table with new address entries */ hashEMail = g_hash_table_new( g_str_hash, g_str_equal ); + hashEMailAlias = g_hash_table_new( g_str_hash, g_str_equal ); node = listEMail; while( node ) { ItemEMail *email = node->data; gchar *addr = g_strdup( email->address ); - + gchar *alias = email->obj.name ; g_strdown( addr ); if( ! g_hash_table_lookup( hashEMail, addr ) ) { g_hash_table_insert( hashEMail, addr, email ); } + if ( *alias != '\0' && ! g_hash_table_lookup( hashEMailAlias, alias ) ) { + g_hash_table_insert( hashEMailAlias, alias, email ); + } node = g_list_next( node ); } @@ -1246,16 +1251,27 @@ void addrbook_update_address_list( if( ADDRITEM_PARENT(emailGrp) == ADDRITEM_OBJECT(person) ) { /* Found an email address for this person */ ItemEMail *emailNew = NULL; - gchar *addr = g_strdup( emailGrp->address ); - + gchar *addr = g_strdup( emailGrp->address ); + gchar *alias = emailGrp->obj.name; g_strdown( addr ); emailNew = ( ItemEMail * ) g_hash_table_lookup( hashEMail, addr ); g_free( addr ); + /* If no match by e-mail, try to match by e-mail alias */ + if( ! emailNew && *alias != '\0' ) { + emailNew = ( ItemEMail * ) + g_hash_table_lookup( hashEMailAlias, alias); + } + if( emailNew ) { /* Point to this entry */ nodeGrpEM->data = emailNew; } + else if(g_hash_table_size(hashEMail)==1) { + /* If the person has just one e-mail address, then + change e-mail address in group list */ + nodeGrpEM->data = listEMail->data; + } else { /* Mark for removal */ listRemove = g_list_append( listRemove, emailGrp ); @@ -1285,6 +1301,8 @@ void addrbook_update_address_list( hashEMail, ( GHRFunc ) addrbook_free_simple_hash_vis, NULL ); g_hash_table_destroy( hashEMail ); hashEMail = NULL; + g_hash_table_destroy( hashEMailAlias ); + hashEMailAlias = NULL; g_list_free( listGroup ); listGroup = NULL; }