[evolution/wip/gsettings] Avoid idle callbacks in EMailBackend initialization.



commit c5265294a3999b134e6f4d7d93b03001312cd075
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Jan 7 14:52:07 2011 -0500

    Avoid idle callbacks in EMailBackend initialization.
    
    If the migration phase has to show a dialog the idle callback for
    intializing mail stores will run too soon.  Instead, hook it onto
    the EShellBackend start() method.
    
    Migration code can initialize mail stores early if it needs to.

 mail/e-mail-backend.c               |   21 ---------------------
 mail/e-mail-migrate.c               |   11 +++++++++--
 mail/e-mail-store.c                 |    4 ++--
 modules/mail/e-mail-shell-backend.c |    6 ++++++
 4 files changed, 17 insertions(+), 25 deletions(-)
---
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 93262ec..740cf85 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -394,23 +394,6 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
 		(EEventTarget *) target);
 }
 
-static gboolean
-mail_backend_idle_cb (EMailBackend *backend)
-{
-	EMailSession *session;
-	EShellBackend *shell_backend;
-	const gchar *data_dir;
-
-	session = e_mail_backend_get_session (backend);
-
-	shell_backend = E_SHELL_BACKEND (backend);
-	data_dir = e_shell_backend_get_data_dir (shell_backend);
-
-	e_mail_store_init (session, data_dir);
-
-	return FALSE;
-}
-
 static void
 mail_backend_get_property (GObject *object,
                            guint property_id,
@@ -517,10 +500,6 @@ mail_backend_constructed (GObject *object)
 	mail_config_init (priv->session);
 	mail_msg_init ();
 
-	/* Defer initializing CamelStores until after the main loop
-	 * has started, so migration has a chance to run first. */
-	g_idle_add ((GSourceFunc) mail_backend_idle_cb, shell_backend);
-
 	if (G_OBJECT_CLASS (e_mail_backend_parent_class)->constructed)
 		G_OBJECT_CLASS (e_mail_backend_parent_class)->constructed (object);
 }
diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c
index 91a5e6f..ef12be0 100644
--- a/mail/e-mail-migrate.c
+++ b/mail/e-mail-migrate.c
@@ -646,11 +646,14 @@ migrate_to_db (EShellBackend *shell_backend)
 
 	mail_backend = E_MAIL_BACKEND (shell_backend);
 	mail_session = e_mail_backend_get_session (mail_backend);
+	data_dir = e_shell_backend_get_data_dir (shell_backend);
+
+	/* Initialize the mail stores early so we can add a new one. */
+	e_mail_store_init (mail_session, data_dir);
 
 	iter = e_list_get_iterator ((EList *) accounts);
 	len = e_list_length ((EList *) accounts);
 
-	data_dir = e_shell_backend_get_data_dir (shell_backend);
 	session = (EMMigrateSession *) em_migrate_session_new (data_dir);
 	camel_session_set_online ((CamelSession *) session, FALSE);
 	em_migrate_setup_progress_dialog (
@@ -965,10 +968,14 @@ create_mbox_account (EShellBackend *shell_backend, EMMigrateSession *session)
 	
 	mail_backend = E_MAIL_BACKEND (shell_backend);
 	mail_session = e_mail_backend_get_session (mail_backend);
+	data_dir = e_shell_backend_get_data_dir (shell_backend);
+
+	/* Initialize the mail stores early so we can add a new one. */
+	e_mail_store_init (mail_session, data_dir);
+
 	account = e_account_new ();
 	account->enabled = TRUE;
 
-	data_dir = e_shell_backend_get_data_dir (shell_backend);
 	url = camel_url_new ("mbox:", NULL);
 	temp = g_build_filename (data_dir, "local_mbox", NULL);
 	camel_url_set_path (url, temp);
diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c
index ac0e975..1e4155b 100644
--- a/mail/e-mail-store.c
+++ b/mail/e-mail-store.c
@@ -268,8 +268,8 @@ e_mail_store_init (EMailSession *session,
 
 	g_return_if_fail (E_IS_MAIL_SESSION (session));
 
-	/* This function is idempotent, but there should
-	 * be no need to call it more than once. */
+	/* This function is idempotent because mail
+	 * migration code may need to call it early. */
 	if (initialized)
 		return;
 
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 590241a..c7bba49 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -514,7 +514,9 @@ mail_shell_backend_start (EShellBackend *shell_backend)
 	EShell *shell;
 	EShellSettings *shell_settings;
 	EMailBackend *backend;
+	EMailSession *session;
 	gboolean enable_search_folders;
+	const gchar *data_dir;
 
 	priv = E_MAIL_SHELL_BACKEND_GET_PRIVATE (shell_backend);
 
@@ -522,6 +524,10 @@ mail_shell_backend_start (EShellBackend *shell_backend)
 	shell_settings = e_shell_get_shell_settings (shell);
 
 	backend = E_MAIL_BACKEND (shell_backend);
+	session = e_mail_backend_get_session (backend);
+	data_dir = e_shell_backend_get_data_dir (shell_backend);
+
+	e_mail_store_init (session, data_dir);
 
 	enable_search_folders = e_shell_settings_get_boolean (
 		shell_settings, "mail-enable-search-folders");



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