[evolution/wip/gsettings] e_mail_store_foreach(): Take an EMailSession parameter.



commit 34be64ac5286f0a3e4c02a74ff0ef8c4062bb966
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Aug 17 22:20:50 2011 -0400

    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.

 mail/e-mail-backend.c                    |   12 ++++++++----
 mail/e-mail-store.c                      |   27 ++++++++++++++-------------
 mail/e-mail-store.h                      |    3 ++-
 modules/mail/e-mail-shell-backend.c      |    7 ++++++-
 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 479b92e..647edf8 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 f9d1845..3a7c27e 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 b26b4c1..5dca416 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 76762c3..9350027 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 3569d1b..5db8001 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]