fix bug 643638
authorPaul Mangan <paul@claws-mail.org>
Sat, 21 Dec 2002 08:54:24 +0000 (08:54 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sat, 21 Dec 2002 08:54:24 +0000 (08:54 +0000)
ChangeLog.claws
configure.in
src/addrbook.c

index d302c3fd2a1857509259e317aa45318245f87298..ebaa11f4d5ecbc0f35039e49604e7e0bc06dd37b 100644 (file)
@@ -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
 2002-12-20 [christoph] 0.8.6claws121
 
        * src/common/utils.c
index 52331f3139072d605ba20d55ca61dbe4e6422c1e..79c305a5fcee0a477b8af7f109fd491d249d5a7b 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
 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
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 3fbef002e8ca39d8117075fa8b538bdae91e7d84..138b9b62e4110bb1ab7c9f430f5a86eb362613f8 100644 (file)
@@ -1214,19 +1214,24 @@ void addrbook_update_address_list(
        listGroup = addrcache_get_group_for_person( book->addressCache, person );
        if( listGroup ) {
                GHashTable *hashEMail;
        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 );
                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 );
                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 );
                        }
                        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 );
                }
 
                        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;
                                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 );
                                        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;
                                        }
                                        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 );
                                        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;
                        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;
        }
                g_list_free( listGroup );
                listGroup = NULL;
        }