From 88505f694e57aa016359aa994e202f62da8b5142 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 5 Jan 2012 09:08:10 -0500 Subject: Make em_utils_generate_account_hash() private. Only used by em_utils_get_reply_all(), and the hash table it returns is not safe for general-purpose use. Make it a static function and rename it generate_recipient_hash(). --- mail/em-composer-utils.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++- mail/em-utils.c | 58 ---------------------------------------------- mail/em-utils.h | 1 - 3 files changed, 59 insertions(+), 60 deletions(-) (limited to 'mail') diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 850a5e5796..dc8d89725a 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -2227,6 +2227,64 @@ get_reply_recipient (CamelMimeMessage *message, } +static GHashTable * +generate_recipient_hash (void) +{ + GHashTable *rcpt_hash; + EAccount *account, *def; + EAccountList *account_list; + EIterator *iterator; + + account_list = e_get_account_list (); + rcpt_hash = g_hash_table_new (camel_strcase_hash, camel_strcase_equal); + + def = e_get_default_account (); + + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iterator)) { + account = (EAccount *) e_iterator_get (iterator); + + if (account->id->address) { + EAccount *acnt; + + /* Accounts with identical email addresses that are + * enabled take precedence over the accounts that + * aren't. If all accounts with matching email + * addresses are disabled, then the first one in + * the list takes precedence. The default account + * always takes precedence no matter what. */ + acnt = g_hash_table_lookup ( + rcpt_hash, account->id->address); + if (acnt && acnt != def && !acnt->enabled && account->enabled) { + g_hash_table_remove ( + rcpt_hash, acnt->id->address); + acnt = NULL; + } + + if (!acnt) + g_hash_table_insert ( + rcpt_hash, (gchar *) + account->id->address, + (gpointer) account); + } + + e_iterator_next (iterator); + } + + g_object_unref (iterator); + + /* The default account has to be there if none + * of the enabled accounts are present. */ + if (g_hash_table_size (rcpt_hash) == 0 && def && def->id->address) + g_hash_table_insert ( + rcpt_hash, (gchar *) + def->id->address, + (gpointer) def); + + return rcpt_hash; +} + static void concat_unique_addrs (CamelInternetAddress *dest, CamelInternetAddress *src, @@ -2273,7 +2331,7 @@ em_utils_get_reply_all (CamelMimeMessage *message, if (postto != NULL && posthdr != NULL) camel_address_decode (CAMEL_ADDRESS (postto), posthdr); - rcpt_hash = em_utils_generate_account_hash (); + rcpt_hash = generate_recipient_hash (); reply_to = get_reply_to (message); to_addrs = camel_mime_message_get_recipients ( diff --git a/mail/em-utils.c b/mail/em-utils.c index ac8a4369c4..416588cfbb 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2102,64 +2102,6 @@ guess_account_from_message (CamelMimeMessage *message) return (uid != NULL) ? e_get_account_by_uid (uid) : NULL; } -GHashTable * -em_utils_generate_account_hash (void) -{ - GHashTable *account_hash; - EAccount *account, *def; - EAccountList *account_list; - EIterator *iterator; - - account_list = e_get_account_list (); - account_hash = g_hash_table_new (camel_strcase_hash, camel_strcase_equal); - - def = e_get_default_account (); - - iterator = e_list_get_iterator (E_LIST (account_list)); - - while (e_iterator_is_valid (iterator)) { - account = (EAccount *) e_iterator_get (iterator); - - if (account->id->address) { - EAccount *acnt; - - /* Accounts with identical email addresses that are - * enabled take precedence over the accounts that - * aren't. If all accounts with matching email - * addresses are disabled, then the first one in - * the list takes precedence. The default account - * always takes precedence no matter what. */ - acnt = g_hash_table_lookup ( - account_hash, account->id->address); - if (acnt && acnt != def && !acnt->enabled && account->enabled) { - g_hash_table_remove ( - account_hash, acnt->id->address); - acnt = NULL; - } - - if (!acnt) - g_hash_table_insert ( - account_hash, (gchar *) - account->id->address, - (gpointer) account); - } - - e_iterator_next (iterator); - } - - g_object_unref (iterator); - - /* The default account has to be there if none - * of the enabled accounts are present. */ - if (g_hash_table_size (account_hash) == 0 && def && def->id->address) - g_hash_table_insert ( - account_hash, (gchar *) - def->id->address, - (gpointer) def); - - return account_hash; -} - EAccount * em_utils_guess_account (CamelMimeMessage *message, CamelFolder *folder) diff --git a/mail/em-utils.h b/mail/em-utils.h index f3879ae484..bf02419526 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -87,7 +87,6 @@ void em_utils_clear_get_password_canceled_accounts_flag (void); /* Unescapes & back to a real & in URIs */ gchar *em_utils_url_unescape_amp (const gchar *url); -GHashTable * em_utils_generate_account_hash (void); EAccount * em_utils_guess_account (CamelMimeMessage *message, CamelFolder *folder); EAccount * em_utils_guess_account_with_recipients -- cgit v1.2.3