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 /mail/importers/evolution-mbox-importer.c | |
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 'mail/importers/evolution-mbox-importer.c')
-rw-r--r-- | mail/importers/evolution-mbox-importer.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index 460777073a..aba980188e 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -44,6 +44,7 @@ #include "shell/e-shell-view.h" #include "shell/e-shell-sidebar.h" +#include "mail/e-mail-backend.h" #include "mail/e-mail-local.h" #include "mail/e-mail-store.h" #include "mail/em-folder-selection-button.h" @@ -79,13 +80,23 @@ folder_selected (EMFolderSelectionButton *button, EImportTargetURI *target) static GtkWidget * mbox_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im) { + EShell *shell; + EShellBackend *shell_backend; + EMailSession *session; GtkWindow *window; GtkWidget *hbox, *w; GtkLabel *label; gchar *select_uri = NULL; + /* XXX Dig up the EMailSession from the default EShell. + * Since the EImport framework doesn't allow for user + * data, I don't see how else to get to it. */ + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); + session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend)); + /* preselect the folder selected in a mail view */ - window = e_shell_get_active_window (e_shell_get_default ()); + window = e_shell_get_active_window (shell); if (E_IS_SHELL_WINDOW (window)) { EShellWindow *shell_window; const gchar *view; @@ -119,7 +130,8 @@ mbox_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im) label = GTK_LABEL (w); w = em_folder_selection_button_new ( - _("Select folder"), _("Select folder to import into")); + session, _("Select folder"), + _("Select folder to import into")); gtk_label_set_mnemonic_widget (label, w); em_folder_selection_button_set_selection ((EMFolderSelectionButton *)w, select_uri); folder_selected (EM_FOLDER_SELECTION_BUTTON (w), (EImportTargetURI *)target); @@ -215,9 +227,19 @@ mbox_import_done (gpointer data, GError **error) static void mbox_import (EImport *ei, EImportTarget *target, EImportImporter *im) { + EShell *shell; + EShellBackend *shell_backend; + EMailSession *session; MboxImporter *importer; gchar *filename; + /* XXX Dig up the EMailSession from the default EShell. + * Since the EImport framework doesn't allow for user + * data, I don't see how else to get to it. */ + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); + session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend)); + /* TODO: do we validate target? */ importer = g_malloc0 (sizeof (*importer)); @@ -234,7 +256,7 @@ mbox_import (EImport *ei, EImportTarget *target, EImportImporter *im) filename = g_filename_from_uri (((EImportTargetURI *)target)->uri_src, NULL, NULL); mail_importer_import_mbox ( - filename, ((EImportTargetURI *)target)->uri_dest, + session, filename, ((EImportTargetURI *)target)->uri_dest, importer->cancellable, mbox_import_done, importer); g_free (filename); } |