+ * Insert person and address into address cache.
+ * Enter: muttFile MUTT control data.
+ * cache Address cache.
+ * address E-Mail address.
+ * name Name.
+ * Return: E-Mail object, either inserted or found in hash table.
+ */
+static ItemEMail *mutt_insert_table(
+ MuttFile *muttFile, AddressCache *cache, gchar *address,
+ gchar *name )
+{
+ ItemPerson *person;
+ ItemEMail *email;
+ gchar *key;
+
+ /* Test whether address already in hash table */
+ key = g_strdup( address );
+ g_strdown( key );
+ email = g_hash_table_lookup( muttFile->uniqTable, key );
+
+ if( email == NULL ) {
+ /* No - create person */
+ person = addritem_create_item_person();
+ addritem_person_set_common_name( person, name );
+ addrcache_id_person( cache, person );
+ addrcache_add_person( cache, person );
+
+ /* Add email for person */
+ email = addritem_create_item_email();
+ addritem_email_set_address( email, address );
+ addrcache_id_email( cache, email );
+ addrcache_person_add_email( cache, person, email );
+
+ /* Insert entry */
+ g_hash_table_insert( muttFile->uniqTable, key, email );
+ }
+ else {
+ /* Yes - update person with longest name */
+ person = ( ItemPerson * ) ADDRITEM_PARENT(email);
+ if( strlen( name ) > strlen( ADDRITEM_NAME(person) ) ) {
+ addritem_person_set_common_name( person, name );
+ }
+
+ /* Free up */
+ g_free( key );
+ }
+
+ return email;
+}
+
+/*
+ * Build address book entries.
+ * Enter: muttFile MUTT control data.
+ * cache Address cache.
+ * aliasName Alias,
+ * listAddr List of address items.
+ * addrCount Address list count.
+ */