aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-utils.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-08-31 07:05:30 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-08-31 08:35:11 +0800
commitf67a5f3d42aa9d743e6b78ace26a6ed1dbdc43e7 (patch)
tree98d3c6e13879d356ed0a4236ed9d2f5d48627980 /mail/em-utils.c
parent60383e0427e57bfb5e2fb836b450ec7cf9717b5f (diff)
downloadgsoc2013-evolution-f67a5f3d42aa9d743e6b78ace26a6ed1dbdc43e7.tar.gz
gsoc2013-evolution-f67a5f3d42aa9d743e6b78ace26a6ed1dbdc43e7.tar.zst
gsoc2013-evolution-f67a5f3d42aa9d743e6b78ace26a6ed1dbdc43e7.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.c64
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);
}
/* ********************************************************************** */