diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-10-18 22:42:48 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-10-19 00:32:38 +0800 |
commit | ec170e47fdeb57272110fa3ef9164a98d8b69d84 (patch) | |
tree | c3442ae4984e847e664af1cbd4c9305d9c8e8c6b /mail | |
parent | e555c2bff07d0f6d2778117cd28c3eb04f381f75 (diff) | |
download | gsoc2013-evolution-ec170e47fdeb57272110fa3ef9164a98d8b69d84.tar.gz gsoc2013-evolution-ec170e47fdeb57272110fa3ef9164a98d8b69d84.tar.zst gsoc2013-evolution-ec170e47fdeb57272110fa3ef9164a98d8b69d84.zip |
Move more account utilities to e-account-utils.c.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-migrate.c | 1 | ||||
-rw-r--r-- | mail/e-mail-reader-utils.c | 1 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 1 | ||||
-rw-r--r-- | mail/e-mail-session.c | 7 | ||||
-rw-r--r-- | mail/em-account-editor.c | 1 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 5 | ||||
-rw-r--r-- | mail/em-folder-properties.c | 1 | ||||
-rw-r--r-- | mail/em-folder-selection-button.c | 4 | ||||
-rw-r--r-- | mail/em-folder-tree-model.c | 3 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 3 | ||||
-rw-r--r-- | mail/em-folder-utils.c | 1 | ||||
-rw-r--r-- | mail/em-format-html-display.c | 2 | ||||
-rw-r--r-- | mail/em-utils.c | 7 | ||||
-rw-r--r-- | mail/mail-config.c | 113 | ||||
-rw-r--r-- | mail/mail-config.h | 9 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 3 | ||||
-rw-r--r-- | mail/mail-vfolder.c | 1 | ||||
-rw-r--r-- | mail/message-list.c | 3 |
18 files changed, 16 insertions, 150 deletions
diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c index ff3b70476c..0956ccdde7 100644 --- a/mail/e-mail-migrate.c +++ b/mail/e-mail-migrate.c @@ -61,7 +61,6 @@ #include "e-mail-store.h" #include "e-mail-backend.h" -#include "mail-config.h" #include "em-utils.h" #define d(x) x diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index 794b25af83..84fdfd8c16 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -38,7 +38,6 @@ #include "mail/em-format-html-print.h" #include "mail/em-utils.h" #include "mail/mail-autofilter.h" -#include "mail/mail-config.h" #include "mail/mail-ops.h" #include "mail/mail-tools.h" #include "mail/mail-vfolder.h" diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 76ec3c5bd6..2cd4969b15 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -47,7 +47,6 @@ #include "mail/em-folder-tree.h" #include "mail/em-utils.h" #include "mail/mail-autofilter.h" -#include "mail/mail-config.h" #include "mail/mail-ops.h" #include "mail/mail-mt.h" #include "mail/mail-vfolder.h" diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c index f443007502..481dca8a53 100644 --- a/mail/e-mail-session.c +++ b/mail/e-mail-session.c @@ -47,6 +47,7 @@ #include <libedataserver/e-flag.h> #include "e-util/e-util.h" +#include "e-util/e-account-utils.h" #include "e-util/e-alert-dialog.h" #include "e-util/e-util-private.h" @@ -602,7 +603,7 @@ mail_session_get_password (CamelSession *session, if (!strcmp(item, "popb4smtp_uri")) { /* not 100% mt safe, but should be ok */ if (url - && (account = mail_config_get_account_by_transport_url (url))) + && (account = e_get_account_by_transport_url (url))) ret = g_strdup (account->source->url); else ret = g_strdup (url); @@ -618,9 +619,9 @@ mail_session_get_password (CamelSession *session, gboolean remember; if (url) { - if ((account = mail_config_get_account_by_source_url (url))) + if ((account = e_get_account_by_source_url (url))) config_service = account->source; - else if ((account = mail_config_get_account_by_transport_url (url))) + else if ((account = e_get_account_by_transport_url (url))) config_service = account->transport; } diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index 85a350747f..0cec4159a8 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -64,7 +64,6 @@ #include "em-account-editor.h" #include "mail-send-recv.h" #include "em-utils.h" -#include "mail-config.h" #include "mail-ops.h" #include "mail-mt.h" diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 0dcfa9b14f..9f6e107af4 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -35,7 +35,6 @@ #include "mail-mt.h" #include "mail-ops.h" #include "mail-tools.h" -#include "mail-config.h" #include "mail-send-recv.h" #include "e-util/e-account-utils.h" @@ -816,7 +815,7 @@ create_new_composer (EShell *shell, if (from_uri != NULL) { GList *list; - account = mail_config_get_account_by_source_url (from_uri); + account = e_get_account_by_source_url (from_uri); list = g_list_prepend (NULL, (gpointer) from_uri); e_composer_header_table_set_post_to_list (table, list); @@ -881,7 +880,7 @@ em_utils_compose_new_message_with_mailto (EShell *shell, table = e_msg_composer_get_header_table (composer); if (from_uri - && (account = mail_config_get_account_by_source_url (from_uri))) + && (account = e_get_account_by_source_url (from_uri))) e_composer_header_table_set_account_name (table, account->name); composer_set_no_change (composer); diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c index dbec0963f5..8679fd1dc1 100644 --- a/mail/em-folder-properties.c +++ b/mail/em-folder-properties.c @@ -39,7 +39,6 @@ #include "mail-ops.h" #include "mail-mt.h" #include "mail-vfolder.h" -#include "mail-config.h" struct _prop_data { gpointer object; diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c index d6bcd34a29..fd9e63dc8f 100644 --- a/mail/em-folder-selection-button.c +++ b/mail/em-folder-selection-button.c @@ -27,8 +27,8 @@ #include <string.h> #include <glib/gi18n.h> #include <e-util/e-util.h> +#include <e-util/e-account-utils.h> -#include "mail-config.h" #include "em-folder-tree.h" #include "em-folder-selector.h" #include "em-utils.h" @@ -100,7 +100,7 @@ folder_selection_button_set_contents (EMFolderSelectionButton *button) return; } - account = mail_config_get_account_by_source_url (uri); + account = e_get_account_by_source_url (uri); if (account != NULL) { gchar *tmp = folder_name; diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 9da5711cf0..ac147c43fd 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -35,7 +35,6 @@ #include <glib/gi18n.h> -#include "mail-config.h" #include "mail-tools.h" #include "mail-mt.h" #include "mail-ops.h" @@ -1073,7 +1072,7 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, uri = camel_url_to_string ( ((CamelService *) store)->url, CAMEL_URL_HIDE_ALL); - account = mail_config_get_account_by_source_url (uri); + account = e_get_account_by_source_url (uri); /* Add the store to the tree. */ gtk_tree_store_append (tree_store, &iter, NULL); diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 1f4500cc86..46f08e06fa 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -52,7 +52,6 @@ #include "mail-mt.h" #include "mail-ops.h" #include "mail-tools.h" -#include "mail-config.h" #include "mail-send-recv.h" #include "mail-vfolder.h" @@ -2548,7 +2547,7 @@ em_folder_tree_set_selected_list (EMFolderTree *folder_tree, /* This makes sure all our parents up to the root are * expanded. FIXME: Why does the expanded state store * this made up path rather than the euri? */ - if ((account = mail_config_get_account_by_source_url (u->uri))) + if ((account = e_get_account_by_source_url (u->uri))) expand_key = g_strdup_printf ("%s/%s", account->uid, path); else if (CAMEL_IS_VEE_STORE (u->store)) expand_key = g_strdup_printf ("vfolder/%s", path); diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index cae91af14f..82f3de6fcf 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -48,7 +48,6 @@ #include "mail-mt.h" #include "mail-ops.h" #include "mail-tools.h" -#include "mail-config.h" #include "mail-vfolder.h" #include "mail-folder-cache.h" diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index e2f6e90a92..24f8aa5638 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -55,8 +55,6 @@ #include "e-cert-db.h" #endif -#include "mail-config.h" - #include "e-mail-display.h" #include "e-mail-attachment-bar.h" #include "em-format-html-display.h" diff --git a/mail/em-utils.c b/mail/em-utils.c index 3fcc530c51..9e96abbec4 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -53,7 +53,6 @@ #include "mail-mt.h" #include "mail-ops.h" #include "mail-tools.h" -#include "mail-config.h" #include "e-mail-tag-editor.h" #include <libedataserver/e-data-server-util.h> @@ -1398,7 +1397,7 @@ gchar *em_uri_from_camel (const gchar *curi) if (strcmp(curl->protocol, "vfolder") == 0) uid = "vfolder@local"; - else if ((account = mail_config_get_account_by_source_url (curi)) == NULL) + else if ((account = e_get_account_by_source_url (curi)) == NULL) uid = "local@local"; else uid = account->uid; @@ -2081,7 +2080,7 @@ guess_account_from_folder (CamelFolder *folder) service = CAMEL_SERVICE (parent_store); source_url = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL); - account = mail_config_get_account_by_source_url (source_url); + account = e_get_account_by_source_url (source_url); g_free (source_url); return account; @@ -2096,7 +2095,7 @@ guess_account_from_message (CamelMimeMessage *message) if (source_url == NULL) return NULL; - return mail_config_get_account_by_source_url (source_url); + return e_get_account_by_source_url (source_url); } GHashTable * diff --git a/mail/mail-config.c b/mail/mail-config.c index 31630836b0..1789a17423 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -283,119 +283,6 @@ mail_config_get_sync_timeout (void) return res; } -static EAccount * -mc_get_account_by (const gchar *given_url, const gchar * (get_url_string)(EAccount *account)) -{ - EAccountList *account_list; - EAccount *account = NULL; - EIterator *iter; - CamelURL *url; - CamelProvider *provider; - - g_return_val_if_fail (given_url != NULL, NULL); - g_return_val_if_fail (get_url_string != NULL, NULL); - - url = camel_url_new (given_url, NULL); - g_return_val_if_fail (url != NULL, NULL); - - provider = camel_provider_get (given_url, NULL); - g_return_val_if_fail (provider != NULL && provider->url_equal != NULL, NULL); - - account_list = e_get_account_list (); - iter = e_list_get_iterator ((EList *) account_list); - while (account == NULL && e_iterator_is_valid (iter)) { - CamelURL *account_url; - const gchar *account_url_string; - - account = (EAccount *) e_iterator_get (iter); - - e_iterator_next (iter); - - account_url_string = get_url_string (account); - - if ( !account_url_string || !*account_url_string) { - account = NULL; - continue; - } - - account_url = camel_url_new (account_url_string, NULL); - if (account_url == NULL) { - account = NULL; - continue; - } - - if (!provider->url_equal (url, account_url)) - account = NULL; /* not a match */ - - camel_url_free (account_url); - } - - g_object_unref (iter); - camel_url_free (url); - - return account; -} - -static const gchar * -get_source_url_string (EAccount *account) -{ - if (account && account->source && account->source->url && *account->source->url) - return account->source->url; - return NULL; -} - -static const gchar * -get_transport_url_string (EAccount *account) -{ - if (account && account->transport && account->transport->url && *account->transport->url) - return account->transport->url; - return NULL; -} - -EAccount * -mail_config_get_account_by_source_url (const gchar *source_url) -{ - return mc_get_account_by (source_url, get_source_url_string); -} - -EAccount * -mail_config_get_account_by_transport_url (const gchar *transport_url) -{ - return mc_get_account_by (transport_url, get_transport_url_string); -} - -EAccountService * -mail_config_get_default_transport (void) -{ - EAccountList *account_list; - EAccount *account; - EIterator *iter; - - account_list = e_get_account_list (); - account = e_get_default_account (); - - if (account && account->enabled && account->transport && account->transport->url && account->transport->url[0]) - return account->transport; - - /* return the first account with a transport? */ - iter = e_list_get_iterator ((EList *) account_list); - while (e_iterator_is_valid (iter)) { - account = (EAccount *) e_iterator_get (iter); - - if (account->enabled && account->transport && account->transport->url && account->transport->url[0]) { - g_object_unref (iter); - - return account->transport; - } - - e_iterator_next (iter); - } - - g_object_unref (iter); - - return NULL; -} - static gchar * uri_to_evname (const gchar *uri, const gchar *prefix) { diff --git a/mail/mail-config.h b/mail/mail-config.h index 6285fe0da7..51ed266f4a 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -68,17 +68,8 @@ void mail_config_write (void); /* General Accessor functions */ -/* accounts */ -EAccount * mail_config_get_account_by_source_url - (const gchar *url); -EAccount * mail_config_get_account_by_transport_url - (const gchar *url); - gint mail_config_get_address_count (void); -EAccountService * - mail_config_get_default_transport (void); - /* static utility functions */ gchar * mail_config_folder_to_cachename (CamelFolder *folder, const gchar *prefix); diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index e2c70861b6..88993d7b8d 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -39,7 +39,6 @@ #include "e-mail-session.h" #include "em-event.h" #include "em-filter-rule.h" -#include "mail-config.h" #include "mail-folder-cache.h" #include "mail-mt.h" #include "mail-ops.h" @@ -1337,7 +1336,7 @@ mail_send (EMailSession *session) struct _send_data *data; send_info_t type; - transport = mail_config_get_default_transport (); + transport = e_get_default_transport (); if (!transport || !transport->url) return; diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 90f6209c90..a47b422f46 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -41,7 +41,6 @@ #include "em-vfolder-editor.h" #include "em-vfolder-rule.h" #include "mail-autofilter.h" -#include "mail-config.h" #include "mail-folder-cache.h" #include "mail-mt.h" #include "mail-ops.h" diff --git a/mail/message-list.c b/mail/message-list.c index 137215fe2e..31a3221d23 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -36,6 +36,7 @@ #include <gconf/gconf-client.h> +#include "e-util/e-account-utils.h" #include "e-util/e-icon-factory.h" #include "e-util/e-poolv.h" #include "e-util/e-profile-event.h" @@ -1658,7 +1659,7 @@ ml_tree_value_at_ex (ETreeModel *etm, uri = camel_folder_get_uri (folder); euri = em_uri_from_camel (uri); - account = mail_config_get_account_by_source_url (uri); + account = e_get_account_by_source_url (uri); if (account) { curl = camel_url_new (uri, NULL); |