diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-08-18 10:20:50 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-08-18 10:27:46 +0800 |
commit | ef929f26973d8d5712a6962c804b1dc0b439d0a9 (patch) | |
tree | 2dec2dc401b93010d354bbf4c62bc5bf38bc8562 | |
parent | dd57574c0427b4571c1daac42b6ffa636a8c80c1 (diff) | |
download | gsoc2013-evolution-ef929f26973d8d5712a6962c804b1dc0b439d0a9.tar gsoc2013-evolution-ef929f26973d8d5712a6962c804b1dc0b439d0a9.tar.gz gsoc2013-evolution-ef929f26973d8d5712a6962c804b1dc0b439d0a9.tar.bz2 gsoc2013-evolution-ef929f26973d8d5712a6962c804b1dc0b439d0a9.tar.lz gsoc2013-evolution-ef929f26973d8d5712a6962c804b1dc0b439d0a9.tar.xz gsoc2013-evolution-ef929f26973d8d5712a6962c804b1dc0b439d0a9.tar.zst gsoc2013-evolution-ef929f26973d8d5712a6962c804b1dc0b439d0a9.zip |
e_mail_store_foreach(): Take an EMailSession parameter.
Use camel_session_list_services() instead of the internal store table.
The store table serves little purpose nowadays and could probably be
removed. I'll look into that later.
-rw-r--r-- | mail/e-mail-backend.c | 12 | ||||
-rw-r--r-- | mail/e-mail-store.c | 27 | ||||
-rw-r--r-- | mail/e-mail-store.h | 3 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-backend.c | 7 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 6 |
5 files changed, 35 insertions, 20 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index 479b92ed59..647edf8257 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -140,7 +140,7 @@ mail_backend_prepare_for_offline_cb (EShell *shell, } e_mail_store_foreach ( - (GFunc) mail_store_prepare_for_offline_cb, activity); + session, (GFunc) mail_store_prepare_for_offline_cb, activity); } /* Helper for mail_backend_prepare_for_online_cb() */ @@ -166,7 +166,7 @@ mail_backend_prepare_for_online_cb (EShell *shell, camel_session_set_online (CAMEL_SESSION (session), TRUE); e_mail_store_foreach ( - (GFunc) mail_store_prepare_for_online_cb, activity); + session, (GFunc) mail_store_prepare_for_online_cb, activity); } /* Helper for mail_backend_prepare_for_quit_cb() */ @@ -241,6 +241,7 @@ mail_backend_prepare_for_quit_cb (EShell *shell, EMailBackend *backend) { EAccountList *account_list; + EMailSession *session; gboolean delete_junk; gboolean empty_trash; @@ -249,6 +250,8 @@ mail_backend_prepare_for_quit_cb (EShell *shell, gboolean empty_trash; } sync_data; + session = e_mail_backend_get_session (backend); + delete_junk = e_mail_backend_delete_junk_policy_decision (backend); empty_trash = e_mail_backend_empty_trash_policy_decision (backend); @@ -264,12 +267,13 @@ mail_backend_prepare_for_quit_cb (EShell *shell, if (delete_junk) e_mail_store_foreach ( - (GFunc) mail_backend_delete_junk, backend); + session, (GFunc) mail_backend_delete_junk, backend); sync_data.activity = activity; sync_data.empty_trash = empty_trash; - e_mail_store_foreach ((GFunc) mail_backend_final_sync, &sync_data); + e_mail_store_foreach ( + session, (GFunc) mail_backend_final_sync, &sync_data); /* Now we poll until all activities are actually cancelled or finished. * Reffing the activity delays quitting; the reference count diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c index f9d18456b4..3a7c27e71c 100644 --- a/mail/e-mail-store.c +++ b/mail/e-mail-store.c @@ -419,25 +419,26 @@ e_mail_store_remove_by_account (EMailSession *session, } void -e_mail_store_foreach (GFunc func, +e_mail_store_foreach (EMailSession *session, + GFunc func, gpointer user_data) { - GHashTableIter iter; - gpointer store; + GList *list, *link; - g_return_if_fail (func != NULL); - - /* case when started in other than mailer component and closing evolution */ - if (!store_table) - return; + /* XXX This is a silly convenience function. + * Could probably just get rid of it. */ - g_hash_table_iter_init (&iter, store_table); + g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (func != NULL); - while (g_hash_table_iter_next (&iter, &store, NULL)) { + list = camel_session_list_services (CAMEL_SESSION (session)); - /* Just being paranoid. */ - g_return_if_fail (CAMEL_IS_STORE (store)); + for (link = list; link != NULL; link = g_list_next (link)) { + CamelService *service = CAMEL_SERVICE (link->data); - func (store, user_data); + if (CAMEL_IS_STORE (service)) + func (service, user_data); } + + g_list_free (list); } diff --git a/mail/e-mail-store.h b/mail/e-mail-store.h index b26b4c15ad..5dca416e09 100644 --- a/mail/e-mail-store.h +++ b/mail/e-mail-store.h @@ -38,7 +38,8 @@ void e_mail_store_remove (EMailSession *session, CamelStore *store); void e_mail_store_remove_by_account (EMailSession *session, EAccount *account); -void e_mail_store_foreach (GFunc func, +void e_mail_store_foreach (EMailSession *session, + GFunc func, gpointer user_data); G_END_DECLS diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index 76762c308c..93500279e7 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -234,6 +234,8 @@ mail_shell_backend_mail_sync (EMailShellBackend *mail_shell_backend) { EShell *shell; EShellBackend *shell_backend; + EMailBackend *backend; + EMailSession *session; shell_backend = E_SHELL_BACKEND (mail_shell_backend); shell = e_shell_backend_get_shell (shell_backend); @@ -246,8 +248,11 @@ mail_shell_backend_mail_sync (EMailShellBackend *mail_shell_backend) if (mail_shell_backend->priv->mail_sync_in_progress) goto exit; + backend = E_MAIL_BACKEND (mail_shell_backend); + session = e_mail_backend_get_session (backend); + e_mail_store_foreach ( - (GFunc) mail_shell_backend_sync_store_cb, + session, (GFunc) mail_shell_backend_sync_store_cb, mail_shell_backend); exit: diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 3569d1b144..5db80011aa 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -218,14 +218,18 @@ action_mail_download_cb (GtkAction *action, EMailShellContent *mail_shell_content; EMailView *mail_view; EMailReader *reader; + EMailBackend *backend; + EMailSession *session; mail_shell_content = mail_shell_view->priv->mail_shell_content; mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); reader = E_MAIL_READER (mail_view); + backend = e_mail_reader_get_backend (reader); + session = e_mail_backend_get_session (backend); e_mail_store_foreach ( - (GFunc) action_mail_download_foreach_cb, reader); + session, (GFunc) action_mail_download_foreach_cb, reader); } static void |