[evolution/email-factory-3-4: 49/53] Port em-utils.c
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/email-factory-3-4: 49/53] Port em-utils.c
- Date: Tue, 17 Jan 2012 14:58:36 +0000 (UTC)
commit 83386422899ef52aa03377a28833fefc3ee918b3
Author: Srinivasa Ragavan <sragavan gnome org>
Date: Tue Jan 17 18:49:16 2012 +0530
Port em-utils.c
mail/em-utils.c | 142 -------------------------------------------------------
mail/em-utils.h | 9 ----
2 files changed, 0 insertions(+), 151 deletions(-)
---
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 5b30d0b..af096f7 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1314,148 +1314,6 @@ em_utils_url_unescape_amp (const gchar *url)
return buff;
}
-static EAccount *
-guess_account_from_folder (CamelFolder *folder)
-{
- CamelStore *store;
- const gchar *uid;
-
- store = camel_folder_get_parent_store (folder);
- uid = camel_service_get_uid (CAMEL_SERVICE (store));
-
- return e_get_account_by_uid (uid);
-}
-
-static EAccount *
-guess_account_from_message (CamelMimeMessage *message)
-{
- const gchar *uid;
-
- uid = camel_mime_message_get_source (message);
-
- return (uid != NULL) ? e_get_account_by_uid (uid) : NULL;
-}
-
-EAccount *
-em_utils_guess_account (CamelMimeMessage *message,
- CamelFolder *folder)
-{
- EAccount *account = NULL;
-
- g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
-
- if (folder != NULL)
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
-
- /* check for newsgroup header */
- if (folder != NULL
- && camel_medium_get_header (CAMEL_MEDIUM (message), "Newsgroups"))
- account = guess_account_from_folder (folder);
-
- /* check for source folder */
- if (account == NULL && folder != NULL)
- account = guess_account_from_folder (folder);
-
- /* then message source */
- if (account == NULL)
- account = guess_account_from_message (message);
-
- return account;
-}
-
-EAccount *
-em_utils_guess_account_with_recipients (CamelMimeMessage *message,
- CamelFolder *folder)
-{
- EAccount *account = NULL;
- EAccountList *account_list;
- GHashTable *recipients;
- EIterator *iterator;
- CamelInternetAddress *addr;
- const gchar *type;
- const gchar *key;
-
- /* This policy is subject to debate and tweaking,
- * but please also document the rational here. */
-
- g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
-
- /* Build a set of email addresses in which to test for membership.
- * Only the keys matter here; the values just need to be non-NULL. */
- recipients = g_hash_table_new (g_str_hash, g_str_equal);
-
- type = CAMEL_RECIPIENT_TYPE_TO;
- addr = camel_mime_message_get_recipients (message, type);
- if (addr != NULL) {
- gint index = 0;
-
- while (camel_internet_address_get (addr, index++, NULL, &key))
- g_hash_table_insert (
- recipients, (gpointer) key,
- GINT_TO_POINTER (1));
- }
-
- type = CAMEL_RECIPIENT_TYPE_CC;
- addr = camel_mime_message_get_recipients (message, type);
- if (addr != NULL) {
- gint index = 0;
-
- while (camel_internet_address_get (addr, index++, NULL, &key))
- g_hash_table_insert (
- recipients, (gpointer) key,
- GINT_TO_POINTER (1));
- }
-
- /* First Preference: We were given a folder that maps to an
- * enabled account, and that account's email address appears
- * in the list of To: or Cc: recipients. */
-
- if (folder != NULL)
- account = guess_account_from_folder (folder);
-
- if (account == NULL || !account->enabled)
- goto second_preference;
-
- if ((key = account->id->address) == NULL)
- goto second_preference;
-
- if (g_hash_table_lookup (recipients, key) != NULL)
- goto exit;
-
-second_preference:
-
- /* Second Preference: Choose any enabled account whose email
- * address appears in the list to To: or Cc: recipients. */
-
- account_list = e_get_account_list ();
- iterator = e_list_get_iterator (E_LIST (account_list));
-
- while (e_iterator_is_valid (iterator)) {
- account = (EAccount *) e_iterator_get (iterator);
- e_iterator_next (iterator);
-
- if (account == NULL || !account->enabled)
- continue;
-
- if ((key = account->id->address) == NULL)
- continue;
-
- if (g_hash_table_lookup (recipients, key) != NULL) {
- g_object_unref (iterator);
- goto exit;
- }
- }
- g_object_unref (iterator);
-
- /* Last Preference: Defer to em_utils_guess_account(). */
- account = em_utils_guess_account (message, folder);
-
-exit:
- g_hash_table_destroy (recipients);
-
- return account;
-}
-
void
emu_restore_folder_tree_state (EMFolderTree *folder_tree)
{
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 8b62bcf..2846f21 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -78,15 +78,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);
-EAccount * em_utils_guess_account (CamelMimeMessage *message,
- CamelFolder *folder);
-EAccount * em_utils_guess_account_with_recipients
- (CamelMimeMessage *message,
- CamelFolder *folder);
-
-void emu_remove_from_mail_cache (const GSList *addresses);
-void emu_remove_from_mail_cache_1 (const gchar *address);
-void emu_free_mail_cache (void);
void emu_free_mail_account_sort_order_cache (void);
void emu_restore_folder_tree_state (EMFolderTree *folder_tree);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]