diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-10-07 11:38:52 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-10-13 01:58:59 +0800 |
commit | a06e4484b8df804124b5bcf88d94dec5acfba270 (patch) | |
tree | 4fa42793d7dc461f2b3767296d76592182c48222 /capplet | |
parent | 5e0758bb6934a7859b1d8a247c8fb21c156772cf (diff) | |
download | gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.gz gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.bz2 gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.lz gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.xz gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.zst gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.zip |
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.
Diffstat (limited to 'capplet')
-rw-r--r-- | capplet/settings/mail-account-view.c | 14 | ||||
-rw-r--r-- | capplet/settings/mail-account-view.h | 2 | ||||
-rw-r--r-- | capplet/settings/mail-capplet-shell.c | 16 | ||||
-rw-r--r-- | capplet/settings/mail-view.c | 7 | ||||
-rw-r--r-- | capplet/settings/mail-view.h | 2 |
5 files changed, 28 insertions, 13 deletions
diff --git a/capplet/settings/mail-account-view.c b/capplet/settings/mail-account-view.c index 9cf9d47754..8001e8ffce 100644 --- a/capplet/settings/mail-account-view.c +++ b/capplet/settings/mail-account-view.c @@ -33,7 +33,7 @@ #include "mail-view.h" #include "e-util/e-config.h" #include "mail/mail-config.h" -#include "mail/mail-session.h" +#include "mail/e-mail-session.h" #include "mail-guess-servers.h" struct _MailAccountViewPrivate { @@ -1019,7 +1019,8 @@ next_page (GtkWidget *entry, MailAccountView *mav) } static void -mail_account_view_construct (MailAccountView *view) +mail_account_view_construct (MailAccountView *view, + EMailSession *session) { gint i; EShell *shell; @@ -1041,7 +1042,9 @@ mail_account_view_construct (MailAccountView *view) gtk_widget_show (view->pages[0]->box); view->current_page = 0; gtk_box_pack_start ((GtkBox *)view, view->scroll, TRUE, TRUE, 0); - view->edit = em_account_editor_new_for_pages (view->original, EMAE_PAGES, "org.gnome.evolution.mail.config.accountWizard", view->wpages); + view->edit = em_account_editor_new_for_pages ( + view->original, EMAE_PAGES, session, + "org.gnome.evolution.mail.config.accountWizard", view->wpages); gtk_widget_hide (e_config_create_widget (E_CONFIG (view->edit->config))); view->edit->emae_check_servers = emae_check_servers; if (!view->original) { @@ -1077,13 +1080,14 @@ mail_account_view_construct (MailAccountView *view) } MailAccountView * -mail_account_view_new (EAccount *account) +mail_account_view_new (EAccount *account, + EMailSession *session) { MailAccountView *view = g_object_new (MAIL_ACCOUNT_VIEW_TYPE, NULL); view->type = MAIL_VIEW_ACCOUNT; view->uri = "account://"; view->original = account; - mail_account_view_construct (view); + mail_account_view_construct (view, session); return view; } diff --git a/capplet/settings/mail-account-view.h b/capplet/settings/mail-account-view.h index 5b728bca93..ac03b1a536 100644 --- a/capplet/settings/mail-account-view.h +++ b/capplet/settings/mail-account-view.h @@ -87,7 +87,7 @@ typedef struct _MailAccountViewClass { } MailAccountViewClass; GType mail_account_view_get_type (void); -MailAccountView *mail_account_view_new (EAccount *account); +MailAccountView *mail_account_view_new (EAccount *account, EMailSession *session); GtkWidget * mail_account_view_get_tab_widget (MailAccountView *mcv); void mail_account_view_activate (MailAccountView *mcv, GtkWidget *tree, GtkWidget *folder_tree, GtkWidget *check_mail, GtkWidget *sort_by, gboolean act); #endif 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 <mail/em-utils.h> #include <mail/em-composer-utils.h> -#include <mail/mail-session.h> #include <mail/mail-mt.h> #include <mail/e-mail-store.h> @@ -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) { diff --git a/capplet/settings/mail-view.c b/capplet/settings/mail-view.c index a294a8e5c0..cb2010f948 100644 --- a/capplet/settings/mail-view.c +++ b/capplet/settings/mail-view.c @@ -438,11 +438,14 @@ mail_view_switch_to_settings (MailView* mv, MailViewChild *mpv) } static MailViewChild * -mail_view_add_account (MailView *mv, gpointer data, gboolean block) +mail_view_add_account (MailView *mv, + gpointer data, + gboolean block) { - MailAccountView *msv = mail_account_view_new (data); + MailAccountView *msv; gint position = 0; + msv = mail_account_view_new (data, mv->session); gtk_widget_show ((GtkWidget *)msv); if (!block) mv->priv->current_view = (MailViewChild *)msv; diff --git a/capplet/settings/mail-view.h b/capplet/settings/mail-view.h index a2a8df68c6..904338e87d 100644 --- a/capplet/settings/mail-view.h +++ b/capplet/settings/mail-view.h @@ -24,6 +24,7 @@ #define _MAIL_VIEW_H_ #include <shell/e-shell-view.h> +#include <mail/e-mail-session.h> #include "anjal-mail-view.h" @@ -48,6 +49,7 @@ typedef struct _MailViewPrivate MailViewPrivate; typedef struct _MailView { AnjalMailView parent; + EMailSession *session; GtkWidget *tree; /* Actual tree */ GtkWidget *folder_tree; GtkWidget *slider; |