diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-08-31 07:05:30 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-09-14 20:08:58 +0800 |
commit | db1a2dd8aad57fb222daa6f82838b33a26f8e742 (patch) | |
tree | 42d90c8e93a4cf035bb9c92de676ad8dcca36fe3 /mail/em-utils.c | |
parent | 629700ced0d5f84031e514cdb31cd97f985a2598 (diff) | |
download | gsoc2013-evolution-db1a2dd8aad57fb222daa6f82838b33a26f8e742.tar gsoc2013-evolution-db1a2dd8aad57fb222daa6f82838b33a26f8e742.tar.gz gsoc2013-evolution-db1a2dd8aad57fb222daa6f82838b33a26f8e742.tar.bz2 gsoc2013-evolution-db1a2dd8aad57fb222daa6f82838b33a26f8e742.tar.lz gsoc2013-evolution-db1a2dd8aad57fb222daa6f82838b33a26f8e742.tar.xz gsoc2013-evolution-db1a2dd8aad57fb222daa6f82838b33a26f8e742.tar.zst gsoc2013-evolution-db1a2dd8aad57fb222daa6f82838b33a26f8e742.zip |
Miscellaneous cleanups.
Reducing diff noise with the account-mgmt branch.
Trying to erode our dependency on EAccount as much as possible, or at
least isolate its usage, to make things easier for me on the branch.
Diffstat (limited to 'mail/em-utils.c')
-rw-r--r-- | mail/em-utils.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c index 33e664976b..3b42e9b200 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1361,13 +1361,15 @@ em_utils_message_to_html (CamelMimeMessage *message, /** * em_utils_expunge_folder: * @parent: parent window - * @session: #EMailSession + * @backend: #EMailBackend * @folder: folder to expunge * * Expunges @folder. **/ void -em_utils_expunge_folder (GtkWidget *parent, EMailSession *session, CamelFolder *folder) +em_utils_expunge_folder (GtkWidget *parent, + EMailBackend *backend, + CamelFolder *folder) { const gchar *description; @@ -1379,56 +1381,62 @@ em_utils_expunge_folder (GtkWidget *parent, EMailSession *session, CamelFolder * "mail:ask-expunge", description, NULL)) return; - mail_expunge_folder (session, folder, NULL, NULL); + mail_expunge_folder (backend, folder); } /** * em_utils_empty_trash: * @parent: parent window - * @session: an #EMailSession + * @backend: an #EMailBackend * * Empties all Trash folders. **/ void em_utils_empty_trash (GtkWidget *parent, - EMailSession *session) + EMailBackend *backend) { - CamelProvider *provider; - EAccountList *account_list; - EAccount *account; - EIterator *iterator; + EMailSession *session; + GList *list, *iter; - g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); if (!em_utils_prompt_user ((GtkWindow *) parent, "/apps/evolution/mail/prompts/empty_trash", "mail:ask-empty-trash", NULL)) return; - account_list = e_get_account_list (); - iterator = e_list_get_iterator (E_LIST (account_list)); + session = e_mail_backend_get_session (backend); + list = camel_session_list_services (CAMEL_SESSION (session)); - while (e_iterator_is_valid (iterator)) { - account = (EAccount *) e_iterator_get (iterator); + for (iter = list; iter != NULL; iter = g_list_next (iter)) { + EAccount *account; + CamelProvider *provider; + CamelService *service; + const gchar *uid; - /* make sure this is a valid source */ - if (account->enabled && account->source->url) { - provider = camel_provider_get (account->source->url, NULL); - if (provider) { - /* make sure this store is a remote store */ - if (provider->flags & CAMEL_PROVIDER_IS_STORAGE) { - mail_empty_trash (session, account, NULL, NULL); - } - } + service = CAMEL_SERVICE (iter->data); + provider = camel_service_get_provider (service); + uid = camel_service_get_uid (service); + + if (!CAMEL_IS_STORE (service)) + continue; + + if ((provider->flags & CAMEL_PROVIDER_IS_STORAGE) == 0) + continue; + + account = e_get_account_by_uid (uid); + + /* The local store has no corresponding + * EAccount, so skip the enabled check. */ + if (account != NULL) { + if (!account->enabled) + continue; } - e_iterator_next (iterator); + mail_empty_trash (backend, CAMEL_STORE (service)); } - g_object_unref (iterator); - - /* Now empty the local trash folder */ - mail_empty_trash (session, NULL, NULL, NULL); + g_list_free (list); } /* ********************************************************************** */ |