? guess-me.patch ? mfc.c Index: ChangeLog =================================================================== RCS file: /cvs/gnome/evolution/mail/ChangeLog,v retrieving revision 1.2421 diff -u -r1.2421 ChangeLog --- ChangeLog 1 Oct 2002 20:30:26 -0000 1.2421 +++ ChangeLog 2 Oct 2002 20:22:26 -0000 @@ -1,3 +1,12 @@ +2002-10-02 Jeffrey Stedfast + + * mail-callbacks.c (mail_generate_reply): Don't default 'me' to + the source account until after we've tried to detect the account + based on recipients. When adding accounts to the account hash, if + any accounts have identical email addresses, the ones that are + enabled take precedence over ones that aren't. This will hopefully + make everyone happy with reply account picking. + 2002-10-01 Larry Ewing * mail-display.c (drag_data_get_cb): add support for dragging the Index: mail-callbacks.c =================================================================== RCS file: /cvs/gnome/evolution/mail/mail-callbacks.c,v retrieving revision 1.394 diff -u -r1.394 mail-callbacks.c --- mail-callbacks.c 30 Sep 2002 20:11:05 -0000 1.394 +++ mail-callbacks.c 2 Oct 2002 20:22:26 -0000 @@ -1008,7 +1008,7 @@ const char *name = NULL, *address = NULL, *source = NULL; const char *message_id, *references, *reply_addr = NULL; char *text = NULL, *subject, date_str[100], *format; - const MailConfigAccount *account, *me = NULL; + const MailConfigAccount *def, *account, *me = NULL; const GSList *l, *accounts = NULL; GHashTable *account_hash = NULL; GList *to = NULL, *cc = NULL; @@ -1035,13 +1035,37 @@ /* Set the recipients */ accounts = mail_config_get_accounts (); - 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; - if (account->id->address) - 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; } @@ -1050,11 +1074,6 @@ mail_ignore_address (composer, to_addrs); mail_ignore_address (composer, cc_addrs); - /* default 'me' to the source account... */ - source = camel_mime_message_get_source (message); - if (source) - me = mail_config_get_account_by_source_url (source); - determine_recipients: if (mode == REPLY_LIST) { CamelMessageInfo *info; @@ -1112,8 +1131,7 @@ } } - if (!me) - me = guess_me (to_addrs, cc_addrs, account_hash); + me = guess_me (to_addrs, cc_addrs, account_hash); } else { GHashTable *rcpt_hash; EDestination *dest; @@ -1153,14 +1171,19 @@ cc = g_list_remove_link (cc, to); } } else { - if (!me) - me = guess_me (to_addrs, cc_addrs, account_hash); + me = guess_me (to_addrs, cc_addrs, account_hash); } g_hash_table_destroy (rcpt_hash); } g_hash_table_destroy (account_hash); + + if (!me) { + /* default 'me' to the source account... */ + if ((source = camel_mime_message_get_source (message))) + me = mail_config_get_account_by_source_url (source); + } /* set body text here as we want all ignored words to take effect */ switch (mail_config_get_default_reply_style ()) {