diff options
author | Not Zed <NotZed@Ximian.com> | 2004-02-17 13:56:01 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-02-17 13:56:01 +0800 |
commit | dc9818c5a34dfa178538117f2205a713f0d923f1 (patch) | |
tree | 5413c95567ec75facc2a91d9a9e28f5a41fb70c9 /mail/em-utils.c | |
parent | 2edcc77ca4cab6e255a7c1830ca56302e3c5e2e0 (diff) | |
download | gsoc2013-evolution-dc9818c5a34dfa178538117f2205a713f0d923f1.tar.gz gsoc2013-evolution-dc9818c5a34dfa178538117f2205a713f0d923f1.tar.zst gsoc2013-evolution-dc9818c5a34dfa178538117f2205a713f0d923f1.zip |
** See bug #53914.
2004-02-17 Not Zed <NotZed@Ximian.com>
** See bug #53914.
* em-utils.c (guess_account): do some extra checks, message
source, and source folder.
(guess_account_folder): helper to guess account based on folder.
svn path=/trunk/; revision=24756
Diffstat (limited to 'mail/em-utils.c')
-rw-r--r-- | mail/em-utils.c | 87 |
1 files changed, 45 insertions, 42 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c index 2db87f1323..0961994c96 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -910,56 +910,59 @@ reply_get_composer (CamelMimeMessage *message, EAccount *account, } static EAccount * +guess_account_folder(CamelFolder *folder) +{ + EAccount *account; + char *tmp; + + tmp = camel_url_to_string(CAMEL_SERVICE(folder->parent_store)->url, CAMEL_URL_HIDE_ALL); + account = mail_config_get_account_by_source_url(tmp); + g_free(tmp); + + return account; +} + +static EAccount * guess_account (CamelMimeMessage *message, CamelFolder *folder) { - const CamelInternetAddress *to, *cc; GHashTable *account_hash = NULL; EAccount *account = NULL; - const char *posthdr, *addr; - char *tmp; - int i; - + const char *tmp; + int i, j; + char *types[2] = { CAMEL_RECIPIENT_TYPE_TO, CAMEL_RECIPIENT_TYPE_CC }; + /* check for newsgroup header */ - posthdr = camel_medium_get_header (CAMEL_MEDIUM (message), "Newsgroups"); - - if (posthdr && folder) { - /* this was posted at a newsgroup! */ - tmp = camel_url_to_string (CAMEL_SERVICE (folder->parent_store)->url, CAMEL_URL_HIDE_ALL); - account = mail_config_get_account_by_source_url (tmp); - g_free (tmp); - if (account) - goto found; - } - - to = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); - cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); - - if (to == NULL && cc == NULL) - return NULL; - + if (folder + && camel_medium_get_header((CamelMedium *)message, "Newsgroups") + && (account = guess_account_folder(folder))) + return account; + + /* then recipient (to/cc) in account table */ account_hash = generate_account_hash (); - - if (to) { - for (i = 0; camel_internet_address_get (to, i, NULL, &addr); i++) { - account = g_hash_table_lookup (account_hash, addr); - if (account) - goto found; - } - } - - if (cc) { - for (i = 0; camel_internet_address_get (cc, i, NULL, &addr); i++) { - account = g_hash_table_lookup (account_hash, addr); - if (account) - goto found; + for (j=0;account == NULL && j<2;j++) { + const CamelInternetAddress *to; + + to = camel_mime_message_get_recipients(message, types[j]); + if (to) { + for (i = 0; camel_internet_address_get(to, i, NULL, &tmp); i++) { + account = g_hash_table_lookup(account_hash, tmp); + if (account) + break; + } } } - - found: - - if (account_hash) - g_hash_table_destroy (account_hash); - + g_hash_table_destroy(account_hash); + + /* then message source */ + if (account == NULL + && (tmp = camel_mime_message_get_source(message))) + account = mail_config_get_account_by_source_url(tmp); + + /* and finally, source folder */ + if (account == NULL + && folder) + account = guess_account_folder(folder); + return account; } |