From a06e4484b8df804124b5bcf88d94dec5acfba270 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 6 Oct 2010 23:38:52 -0400 Subject: Give MailSession a permanent home. Global variables in shared libraries are a bad idea. EMailBackend now owns the MailSession instance, which is actually now EMailSession. Move the blocking utility functions in mail-tools.c to e-mail-session.c and add asynchronous variants. Same approach as Camel. Replace EMailReader.get_shell_backend() with EMailReader.get_backend(), which returns an EMailBackend. Easier access to the EMailSession. --- capplet/settings/mail-capplet-shell.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'capplet/settings/mail-capplet-shell.c') diff --git a/capplet/settings/mail-capplet-shell.c b/capplet/settings/mail-capplet-shell.c index 63f8625caa..9153edb7ab 100644 --- a/capplet/settings/mail-capplet-shell.c +++ b/capplet/settings/mail-capplet-shell.c @@ -38,7 +38,6 @@ #include "mail-decoration.h" #include #include -#include #include #include @@ -68,6 +67,7 @@ static guint mail_capplet_shell_signals[LAST_SIGNAL]; struct _MailCappletShellPrivate { + EMailSession *session; GtkWidget *box; GtkWidget * top_bar; @@ -237,17 +237,23 @@ mail_capplet_shell_construct (MailCappletShell *shell, gint socket_id, gboolean } + if (camel_init (e_get_user_data_dir (), TRUE) != 0) + exit (0); + + camel_provider_init (); + + shell->priv->session = e_mail_session_new (); + shell->view = mail_view_new (); + shell->view->session = shell->priv->session; gtk_widget_show ((GtkWidget *)shell->view); tmp = gtk_vbox_new (FALSE, 0); gtk_box_pack_end ((GtkBox *)priv->box, (GtkWidget *)shell->view, TRUE, TRUE, 2); - /* This also initializes Camel, so it needs to happen early. */ - mail_session_start (); - mail_config_init (); + mail_config_init (CAMEL_SESSION (shell->priv->session)); mail_msg_init (); custom_dir = g_build_filename (e_get_user_data_dir (), "mail", NULL); - e_mail_store_init (custom_dir); + e_mail_store_init (shell->priv->session, custom_dir); g_free (custom_dir); if (just_druid) { -- cgit