From 0fe83413d09ea683050aa1fc8f8b46b72aaafd72 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 3 Dec 2002 17:42:44 +0000 Subject: Use the same logic as mail_generate_reply(). Fixes bug #34882 2002-12-03 Jeffrey Stedfast * mail-callbacks.c (guess_me_from_accounts): Use the same logic as mail_generate_reply(). Fixes bug #34882 Fixes bug #34315 * component-factory.c (message_rfc822_dnd): Return TRUE if we successfully handled all messages in the mbox stream, or FALSE otherwise. (destination_folder_handle_drop): For TEXT_URI_LIST, use the retval from message_rfc822_dnd() rather than relying on an exception, because one will not always necessarily be set. For MESSAGE_RFC822, also use the retval from message_rfc822_dnd(). svn path=/trunk/; revision=18995 --- mail/mail-callbacks.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'mail/mail-callbacks.c') diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index fb46cb05a5..4d655f6950 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -869,15 +869,41 @@ guess_me (const CamelInternetAddress *to, const CamelInternetAddress *cc, GHashT static const MailConfigAccount * guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddress *cc, const GSList *accounts) { - const MailConfigAccount *account; + const MailConfigAccount *account, *def; GHashTable *account_hash; const GSList *l; account_hash = g_hash_table_new (g_strcase_hash, g_strcase_equal); + + /* add the default account to the hash first */ + if ((def = mail_config_get_default_account ())) { + if (def->id->address) + g_hash_table_insert (account_hash, (char *) def->id->address, (void *) def); + } + l = accounts; while (l) { account = l->data; - g_hash_table_insert (account_hash, (char *) account->id->address, (void *) account); + + if (account->id->address) { + const MailConfigAccount *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->source->enabled && account->source->enabled) { + g_hash_table_remove (account_hash, acnt->id->address); + acnt = NULL; + } + + if (!acnt) + g_hash_table_insert (account_hash, (char *) account->id->address, (void *) account); + } + l = l->next; } -- cgit v1.2.3