diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-24 05:09:24 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-05-24 09:50:50 +0800 |
commit | 9692758dc5c3a03597f0eb0b16edd10134153823 (patch) | |
tree | ae48699ccfd792672b0b3c4e382fbc5ce13eb584 /mail | |
parent | 61d1530c76341f1a69fa528071e3a6ffa07ed333 (diff) | |
download | gsoc2013-evolution-9692758dc5c3a03597f0eb0b16edd10134153823.tar.gz gsoc2013-evolution-9692758dc5c3a03597f0eb0b16edd10134153823.tar.zst gsoc2013-evolution-9692758dc5c3a03597f0eb0b16edd10134153823.zip |
EMFolderTree: Store an EMailBackend instead of an EMailSession.
All this so EMFolderTree can submit EActivity instances for async ops.
You can obtain an EMailSession from an EMailBackend, but not vice versa.
Creates lots of pretty ripples in the mail code, but ultimately reduces
complexity. So it's a code cleanup of sorts.
Diffstat (limited to 'mail')
30 files changed, 364 insertions, 345 deletions
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index 51eff2a325..1fe121dcb7 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -1009,7 +1009,6 @@ mail_reader_create_filter_cb (CamelFolder *folder, AsyncContext *context) { EMailBackend *backend; - EMailSession *session; EAlertSink *alert_sink; CamelMimeMessage *message; GError *error = NULL; @@ -1043,10 +1042,9 @@ mail_reader_create_filter_cb (CamelFolder *folder, context->activity = NULL; backend = e_mail_reader_get_backend (context->reader); - session = e_mail_backend_get_session (backend); filter_gui_add_from_message ( - session, message, + backend, message, context->filter_source, context->filter_type); diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 3802eaaded..18d7621a9d 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -294,7 +294,7 @@ action_mail_copy_cb (GtkAction *action, window = e_mail_reader_get_window (reader); uids = e_mail_reader_get_selected_uids (reader); - folder_tree = em_folder_tree_new (session); + folder_tree = em_folder_tree_new (backend); emu_restore_folder_tree_state (EM_FOLDER_TREE (folder_tree)); em_folder_tree_set_excluded ( @@ -797,7 +797,7 @@ action_mail_move_cb (GtkAction *action, session = e_mail_backend_get_session (backend); - folder_tree = em_folder_tree_new (session); + folder_tree = em_folder_tree_new (backend); emu_restore_folder_tree_state (EM_FOLDER_TREE (folder_tree)); em_folder_tree_set_excluded ( diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c index b89e571c59..05f0fa09b9 100644 --- a/mail/e-mail-session.c +++ b/mail/e-mail-session.c @@ -289,6 +289,8 @@ main_get_filter_driver (CamelSession *session, const gchar *type, GError **error) { + EShell *shell; + EShellBackend *shell_backend; EMailSession *ms = E_MAIL_SESSION (session); CamelFilterDriver *driver; EFilterRule *rule = NULL; @@ -297,12 +299,17 @@ main_get_filter_driver (CamelSession *session, GConfClient *client; ERuleContext *fc; + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); + g_return_val_if_fail (E_IS_MAIL_BACKEND (shell_backend), NULL); + client = gconf_client_get_default (); config_dir = mail_session_get_config_dir (); user = g_build_filename (config_dir, "filters.xml", NULL); system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL); - fc = (ERuleContext *) em_filter_context_new (ms); + fc = (ERuleContext *) em_filter_context_new ( + E_MAIL_BACKEND (shell_backend)); e_rule_context_load (fc, system, user); g_free (system); g_free (user); diff --git a/mail/e-mail-sidebar.c b/mail/e-mail-sidebar.c index f9cb30eab2..80043f035a 100644 --- a/mail/e-mail-sidebar.c +++ b/mail/e-mail-sidebar.c @@ -473,12 +473,12 @@ e_mail_sidebar_get_type (void) } GtkWidget * -e_mail_sidebar_new (EMailSession *session) +e_mail_sidebar_new (EMailBackend *backend) { - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); return g_object_new ( - E_TYPE_MAIL_SIDEBAR, "session", session, NULL); + E_TYPE_MAIL_SIDEBAR, "backend", backend, NULL); } GKeyFile * diff --git a/mail/e-mail-sidebar.h b/mail/e-mail-sidebar.h index ebb6d0a37c..8941c99746 100644 --- a/mail/e-mail-sidebar.h +++ b/mail/e-mail-sidebar.h @@ -76,7 +76,7 @@ struct _EMailSidebarClass { }; GType e_mail_sidebar_get_type (void); -GtkWidget * e_mail_sidebar_new (EMailSession *session); +GtkWidget * e_mail_sidebar_new (EMailBackend *backend); GKeyFile * e_mail_sidebar_get_key_file (EMailSidebar *sidebar); void e_mail_sidebar_set_key_file (EMailSidebar *sidebar, GKeyFile *key_file); diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index 66d8ea68c8..78ed7791d9 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -58,8 +58,8 @@ #include "widgets/misc/e-signature-editor.h" #include "widgets/misc/e-port-entry.h" +#include "e-mail-backend.h" #include "e-mail-local.h" -#include "e-mail-session.h" #include "e-mail-store.h" #include "em-config.h" #include "em-folder-selection-button.h" @@ -140,7 +140,7 @@ typedef struct _EMAccountEditorService { struct _EMAccountEditorPrivate { - EMailSession *session; + EMailBackend *backend; EAccount *modified_account; EAccount *original_account; gboolean new_account; @@ -211,9 +211,9 @@ struct _EMAccountEditorPrivate { enum { PROP_0, + PROP_BACKEND, PROP_MODIFIED_ACCOUNT, - PROP_ORIGINAL_ACCOUNT, - PROP_SESSION + PROP_ORIGINAL_ACCOUNT }; static void emae_refresh_authtype (EMAccountEditor *emae, EMAccountEditorService *service); @@ -268,13 +268,13 @@ emae_set_original_account (EMAccountEditor *emae, } static void -emae_set_session (EMAccountEditor *emae, - EMailSession *session) +emae_set_backend (EMAccountEditor *emae, + EMailBackend *backend) { - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (emae->priv->session == NULL); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (emae->priv->backend == NULL); - emae->priv->session = g_object_ref (session); + emae->priv->backend = g_object_ref (backend); } static void @@ -284,14 +284,14 @@ emae_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_ORIGINAL_ACCOUNT: - emae_set_original_account ( + case PROP_BACKEND: + emae_set_backend ( EM_ACCOUNT_EDITOR (object), g_value_get_object (value)); return; - case PROP_SESSION: - emae_set_session ( + case PROP_ORIGINAL_ACCOUNT: + emae_set_original_account ( EM_ACCOUNT_EDITOR (object), g_value_get_object (value)); return; @@ -307,24 +307,24 @@ emae_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_MODIFIED_ACCOUNT: + case PROP_BACKEND: g_value_set_object ( value, - em_account_editor_get_modified_account ( + em_account_editor_get_backend ( EM_ACCOUNT_EDITOR (object))); return; - case PROP_ORIGINAL_ACCOUNT: + case PROP_MODIFIED_ACCOUNT: g_value_set_object ( value, - em_account_editor_get_original_account ( + em_account_editor_get_modified_account ( EM_ACCOUNT_EDITOR (object))); return; - case PROP_SESSION: + case PROP_ORIGINAL_ACCOUNT: g_value_set_object ( value, - em_account_editor_get_session ( + em_account_editor_get_original_account ( EM_ACCOUNT_EDITOR (object))); return; } @@ -339,9 +339,9 @@ emae_dispose (GObject *object) priv = EM_ACCOUNT_EDITOR (object)->priv; - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; + if (priv->backend != NULL) { + g_object_unref (priv->backend); + priv->backend = NULL; } if (priv->modified_account != NULL) { @@ -398,6 +398,17 @@ emae_class_init (GObjectClass *class) g_object_class_install_property ( object_class, + PROP_BACKEND, + g_param_spec_object ( + "backend", + "Mail Backend", + NULL, + E_TYPE_MAIL_BACKEND, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + object_class, PROP_MODIFIED_ACCOUNT, g_param_spec_object ( "modified-account", @@ -416,17 +427,6 @@ emae_class_init (GObjectClass *class) E_TYPE_ACCOUNT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property ( - object_class, - PROP_SESSION, - g_param_spec_object ( - "session", - "Mail Session", - NULL, - E_TYPE_MAIL_SESSION, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); } static void @@ -482,17 +482,17 @@ em_account_editor_get_type (void) EMAccountEditor * em_account_editor_new (EAccount *account, EMAccountEditorType type, - EMailSession *session, + EMailBackend *backend, const gchar *id) { EMAccountEditor *emae; - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); emae = g_object_new ( EM_TYPE_ACCOUNT_EDITOR, "original-account", account, - "session", session, NULL); + "backend", backend, NULL); em_account_editor_construct (emae, type, id); @@ -513,18 +513,18 @@ em_account_editor_new (EAccount *account, EMAccountEditor * em_account_editor_new_for_pages (EAccount *account, EMAccountEditorType type, - EMailSession *session, + EMailBackend *backend, const gchar *id, GtkWidget **pages) { EMAccountEditor *emae; - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); emae = g_object_new ( EM_TYPE_ACCOUNT_EDITOR, "original-account", account, - "session", session, NULL); + "backend", backend, NULL); emae->pages = pages; em_account_editor_construct (emae, type, id); @@ -532,28 +532,28 @@ em_account_editor_new_for_pages (EAccount *account, return emae; } -EAccount * -em_account_editor_get_modified_account (EMAccountEditor *emae) +EMailBackend * +em_account_editor_get_backend (EMAccountEditor *emae) { g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL); - return emae->priv->modified_account; + return emae->priv->backend; } EAccount * -em_account_editor_get_original_account (EMAccountEditor *emae) +em_account_editor_get_modified_account (EMAccountEditor *emae) { g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL); - return emae->priv->original_account; + return emae->priv->modified_account; } -EMailSession * -em_account_editor_get_session (EMAccountEditor *emae) +EAccount * +em_account_editor_get_original_account (EMAccountEditor *emae) { g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL); - return emae->priv->session; + return emae->priv->original_account; } /* ********************************************************************** */ @@ -1108,14 +1108,14 @@ emae_account_folder (EMAccountEditor *emae, const gchar *name, gint item, gint d { EAccount *account; EMFolderSelectionButton *folder; - EMailSession *session; + EMailBackend *backend; const gchar *uri; account = em_account_editor_get_modified_account (emae); - session = em_account_editor_get_session (emae); + backend = em_account_editor_get_backend (emae); folder = (EMFolderSelectionButton *) e_builder_get_widget (builder, name); - em_folder_selection_button_set_session (folder, session); + em_folder_selection_button_set_backend (folder, backend); uri = e_account_get_string (account, item); if (uri != NULL) { @@ -1981,6 +1981,7 @@ emae_check_authtype (GtkWidget *w, EMAccountEditorService *service) { CamelService *camel_service; + EMailBackend *backend; EMailSession *session; EAccount *account; GtkWidget *editor; @@ -1990,7 +1991,8 @@ emae_check_authtype (GtkWidget *w, account = em_account_editor_get_modified_account (service->emae); editor = E_CONFIG (service->emae->config)->window; - session = em_account_editor_get_session (service->emae); + backend = em_account_editor_get_backend (service->emae); + session = e_mail_backend_get_session (backend); if (service->type == CAMEL_PROVIDER_TRANSPORT) uid = g_strconcat (account->uid, "-transport", NULL); @@ -3035,7 +3037,7 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget EMAccountEditor *emae = data; EMAccountEditorPrivate *priv = emae->priv; EMFolderSelectionButton *button; - EMailSession *session; + EMailBackend *backend; EAccount *account; GtkWidget *widget; GtkBuilder *builder; @@ -3046,10 +3048,10 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget return NULL; account = em_account_editor_get_modified_account (emae); - session = em_account_editor_get_session (emae); + backend = em_account_editor_get_backend (emae); - /* Make sure we have a valid EMailSession. */ - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + /* Make sure we have a valid EMailBackend. */ + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); builder = gtk_builder_new (); e_load_ui_builder_definition (builder, "mail-config.ui"); @@ -3072,7 +3074,7 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget widget = e_builder_get_widget (builder, "trash_folder_butt"); button = EM_FOLDER_SELECTION_BUTTON (widget); - em_folder_selection_button_set_session (button, session); + em_folder_selection_button_set_backend (button, backend); priv->trash_folder_button = GTK_BUTTON (button); setup_checkable_folder ( @@ -3085,7 +3087,7 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget widget = e_builder_get_widget (builder, "junk_folder_butt"); button = EM_FOLDER_SELECTION_BUTTON (widget); - em_folder_selection_button_set_session (button, session); + em_folder_selection_button_set_backend (button, backend); priv->junk_folder_button = GTK_BUTTON (button); setup_checkable_folder ( @@ -3783,9 +3785,11 @@ emae_commit (EConfig *ec, GSList *items, gpointer data) if (account->enabled && emae->priv->source.provider && (emae->priv->source.provider->flags & CAMEL_PROVIDER_IS_STORAGE)) { + EMailBackend *backend; EMailSession *session; - session = em_account_editor_get_session (emae); + backend = em_account_editor_get_backend (emae); + session = e_mail_backend_get_session (backend); e_mail_store_add_by_account (session, account); } } diff --git a/mail/em-account-editor.h b/mail/em-account-editor.h index 7be79c6c5e..a34fd8af2d 100644 --- a/mail/em-account-editor.h +++ b/mail/em-account-editor.h @@ -26,7 +26,7 @@ #include <gtk/gtk.h> #include <mail/em-config.h> -#include <mail/e-mail-session.h> +#include <mail/e-mail-backend.h> /* Standard GObject macros */ #define EM_TYPE_ACCOUNT_EDITOR \ @@ -99,19 +99,19 @@ GType em_account_editor_get_type (void); EMAccountEditor * em_account_editor_new (EAccount *account, EMAccountEditorType type, - EMailSession *session, + EMailBackend *backend, const gchar *id); EMAccountEditor * em_account_editor_new_for_pages (EAccount *account, EMAccountEditorType type, - EMailSession *session, + EMailBackend *backend, const gchar *id, GtkWidget **pages); +EMailBackend * em_account_editor_get_backend (EMAccountEditor *emae); EAccount * em_account_editor_get_modified_account (EMAccountEditor *emae); EAccount * em_account_editor_get_original_account (EMAccountEditor *emae); -EMailSession * em_account_editor_get_session (EMAccountEditor *emae); void em_account_editor_commit (EMAccountEditor *emae); gboolean em_account_editor_check (EMAccountEditor *emae, const gchar *page); diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index bc836a890d..f58e8955dd 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -2787,15 +2787,18 @@ static void post_header_clicked_cb (EComposerPostHeader *header, EMsgComposer *composer) { + EShell *shell; + EShellBackend *shell_backend; GtkTreeSelection *selection; - CamelSession *session; GtkWidget *folder_tree; GtkWidget *dialog; GList *list; - session = e_msg_composer_get_session (composer); + /* FIXME Figure out a way to pass the mail backend in. */ + shell = e_msg_composer_get_shell (composer); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); - folder_tree = em_folder_tree_new (E_MAIL_SESSION (session)); + folder_tree = em_folder_tree_new (E_MAIL_BACKEND (shell_backend)); emu_restore_folder_tree_state (EM_FOLDER_TREE (folder_tree)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_tree)); diff --git a/mail/em-filter-context.c b/mail/em-filter-context.c index ff25e49cb9..fead5ec3c8 100644 --- a/mail/em-filter-context.c +++ b/mail/em-filter-context.c @@ -37,13 +37,13 @@ #include "em-filter-folder-element.h" struct _EMFilterContextPrivate { - EMailSession *session; + EMailBackend *backend; GList *actions; }; enum { PROP_0, - PROP_SESSION + PROP_BACKEND }; G_DEFINE_TYPE ( @@ -52,13 +52,13 @@ G_DEFINE_TYPE ( E_TYPE_RULE_CONTEXT) static void -filter_context_set_session (EMFilterContext *context, - EMailSession *session) +filter_context_set_backend (EMFilterContext *context, + EMailBackend *backend) { - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (context->priv->session == NULL); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (context->priv->backend == NULL); - context->priv->session = g_object_ref (session); + context->priv->backend = g_object_ref (backend); } static void @@ -68,8 +68,8 @@ filter_context_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: - filter_context_set_session ( + case PROP_BACKEND: + filter_context_set_backend ( EM_FILTER_CONTEXT (object), g_value_get_object (value)); return; @@ -85,10 +85,10 @@ filter_context_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: + case PROP_BACKEND: g_value_set_object ( value, - em_filter_context_get_session ( + em_filter_context_get_backend ( EM_FILTER_CONTEXT (object))); return; } @@ -103,9 +103,9 @@ filter_context_dispose (GObject *object) priv = EM_FILTER_CONTEXT (object)->priv; - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; + if (priv->backend != NULL) { + g_object_unref (priv->backend); + priv->backend = NULL; } g_list_foreach (priv->actions, (GFunc) g_object_unref, NULL); @@ -232,7 +232,7 @@ filter_context_new_element (ERuleContext *context, priv = EM_FILTER_CONTEXT (context)->priv; if (strcmp (type, "folder") == 0) - return em_filter_folder_element_new (priv->session); + return em_filter_folder_element_new (priv->backend); if (strcmp (type, "system-flag") == 0) return e_filter_option_new (); @@ -267,12 +267,12 @@ em_filter_context_class_init (EMFilterContextClass *class) g_object_class_install_property ( object_class, - PROP_SESSION, + PROP_BACKEND, g_param_spec_object ( - "session", + "backend", NULL, NULL, - E_TYPE_MAIL_SESSION, + E_TYPE_MAIL_BACKEND, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } @@ -303,20 +303,20 @@ em_filter_context_init (EMFilterContext *context) } EMFilterContext * -em_filter_context_new (EMailSession *session) +em_filter_context_new (EMailBackend *backend) { - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); return g_object_new ( - EM_TYPE_FILTER_CONTEXT, "session", session, NULL); + EM_TYPE_FILTER_CONTEXT, "backend", backend, NULL); } -EMailSession * -em_filter_context_get_session (EMFilterContext *context) +EMailBackend * +em_filter_context_get_backend (EMFilterContext *context) { g_return_val_if_fail (EM_IS_FILTER_CONTEXT (context), NULL); - return context->priv->session; + return context->priv->backend; } void diff --git a/mail/em-filter-context.h b/mail/em-filter-context.h index 3545bf16eb..d80809b8e4 100644 --- a/mail/em-filter-context.h +++ b/mail/em-filter-context.h @@ -25,7 +25,7 @@ #ifndef EM_FILTER_CONTEXT_H #define EM_FILTER_CONTEXT_H -#include <mail/e-mail-session.h> +#include <mail/e-mail-backend.h> #include <filter/e-rule-context.h> /* Standard GObject macros */ @@ -64,8 +64,8 @@ struct _EMFilterContextClass { GType em_filter_context_get_type (void); EMFilterContext * - em_filter_context_new (EMailSession *session); -EMailSession * em_filter_context_get_session (EMFilterContext *context); + em_filter_context_new (EMailBackend *backend); +EMailBackend * em_filter_context_get_backend (EMFilterContext *context); void em_filter_context_add_action (EMFilterContext *context, EFilterPart *action); EFilterPart * em_filter_context_find_action (EMFilterContext *context, diff --git a/mail/em-filter-folder-element.c b/mail/em-filter-folder-element.c index 4a5d3595aa..a7be46431b 100644 --- a/mail/em-filter-folder-element.c +++ b/mail/em-filter-folder-element.c @@ -40,13 +40,13 @@ #include "e-util/e-alert.h" struct _EMFilterFolderElementPrivate { - EMailSession *session; + EMailBackend *backend; gchar *uri; }; enum { PROP_0, - PROP_SESSION + PROP_BACKEND }; static gboolean validate (EFilterElement *fe, EAlert **alert); @@ -64,18 +64,23 @@ G_DEFINE_TYPE ( E_TYPE_FILTER_ELEMENT) static void -filter_folder_element_set_session (EMFilterFolderElement *element, - EMailSession *session) +filter_folder_element_set_backend (EMFilterFolderElement *element, + EMailBackend *backend) { - if (!session) - session = e_mail_backend_get_session ( - E_MAIL_BACKEND (e_shell_get_backend_by_name ( - e_shell_get_default (), "mail"))); + /* FIXME Dirty hack. Backend should be passed in always. */ + if (backend == NULL) { + EShellBackend *shell_backend; + EShell *shell; + + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); + backend = E_MAIL_BACKEND (shell_backend); + } - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (element->priv->session == NULL); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (element->priv->backend == NULL); - element->priv->session = g_object_ref (session); + element->priv->backend = g_object_ref (backend); } static void @@ -85,8 +90,8 @@ filter_folder_element_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: - filter_folder_element_set_session ( + case PROP_BACKEND: + filter_folder_element_set_backend ( EM_FILTER_FOLDER_ELEMENT (object), g_value_get_object (value)); return; @@ -102,10 +107,10 @@ filter_folder_element_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: + case PROP_BACKEND: g_value_set_object ( value, - em_filter_folder_element_get_session ( + em_filter_folder_element_get_backend ( EM_FILTER_FOLDER_ELEMENT (object))); return; } @@ -120,9 +125,9 @@ filter_folder_element_dispose (GObject *object) priv = EM_FILTER_FOLDER_ELEMENT (object)->priv; - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; + if (priv->backend != NULL) { + g_object_unref (priv->backend); + priv->backend = NULL; } /* Chain up to parent's dispose() method. */ @@ -168,12 +173,12 @@ em_filter_folder_element_class_init (EMFilterFolderElementClass *class) g_object_class_install_property ( object_class, - PROP_SESSION, + PROP_BACKEND, g_param_spec_object ( - "session", + "backend", NULL, NULL, - E_TYPE_MAIL_SESSION, + E_TYPE_MAIL_BACKEND, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } @@ -187,21 +192,21 @@ em_filter_folder_element_init (EMFilterFolderElement *element) } EFilterElement * -em_filter_folder_element_new (EMailSession *session) +em_filter_folder_element_new (EMailBackend *backend) { - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); return g_object_new ( EM_TYPE_FILTER_FOLDER_ELEMENT, - "session", session, NULL); + "backend", backend, NULL); } -EMailSession * -em_filter_folder_element_get_session (EMFilterFolderElement *element) +EMailBackend * +em_filter_folder_element_get_backend (EMFilterFolderElement *element) { g_return_val_if_fail (EM_IS_FILTER_FOLDER_ELEMENT (element), NULL); - return element->priv->session; + return element->priv->backend; } const gchar * @@ -310,13 +315,13 @@ static GtkWidget * get_widget (EFilterElement *fe) { EMFilterFolderElement *ff = (EMFilterFolderElement *) fe; - EMailSession *session; + EMailBackend *backend; GtkWidget *button; - session = em_filter_folder_element_get_session (ff); + backend = em_filter_folder_element_get_backend (ff); button = em_folder_selection_button_new ( - session, _("Select Folder"), NULL); + backend, _("Select Folder"), NULL); em_folder_selection_button_set_selection ( EM_FOLDER_SELECTION_BUTTON (button), ff->priv->uri); gtk_widget_show (button); diff --git a/mail/em-filter-folder-element.h b/mail/em-filter-folder-element.h index f71b4c128b..c188907ae7 100644 --- a/mail/em-filter-folder-element.h +++ b/mail/em-filter-folder-element.h @@ -25,7 +25,7 @@ #ifndef EM_FILTER_FOLDER_ELEMENT_H #define EM_FILTER_FOLDER_ELEMENT_H -#include <mail/e-mail-session.h> +#include <mail/e-mail-backend.h> #include <filter/e-filter-element.h> /* Standard GObject macros */ @@ -63,8 +63,8 @@ struct _EMFilterFolderElementClass { }; GType em_filter_folder_element_get_type (void); -EFilterElement *em_filter_folder_element_new (EMailSession *session); -EMailSession * em_filter_folder_element_get_session +EFilterElement *em_filter_folder_element_new (EMailBackend *backend); +EMailBackend * em_filter_folder_element_get_backend (EMFilterFolderElement *element); const gchar * em_filter_folder_element_get_uri (EMFilterFolderElement *element); diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c index 9ca3267e4c..c18a62e33a 100644 --- a/mail/em-folder-selection-button.c +++ b/mail/em-folder-selection-button.c @@ -41,7 +41,7 @@ ((obj), EM_TYPE_FOLDER_SELECTION_BUTTON, EMFolderSelectionButtonPrivate)) struct _EMFolderSelectionButtonPrivate { - EMailSession *session; + EMailBackend *backend; GtkWidget *icon; GtkWidget *label; @@ -52,8 +52,8 @@ struct _EMFolderSelectionButtonPrivate { enum { PROP_0, + PROP_BACKEND, PROP_CAPTION, - PROP_SESSION, PROP_TITLE }; @@ -82,7 +82,7 @@ folder_selection_button_unselected (EMFolderSelectionButton *button) static void folder_selection_button_set_contents (EMFolderSelectionButton *button) { - CamelSession *session; + EMailBackend *backend; CamelStore *store = NULL; EAccount *account; GtkLabel *label; @@ -90,12 +90,16 @@ folder_selection_button_set_contents (EMFolderSelectionButton *button) gchar *folder_name = NULL; label = GTK_LABEL (button->priv->label); - session = CAMEL_SESSION (button->priv->session); + backend = em_folder_selection_button_get_backend (button); - if (button->priv->uri != NULL) + if (backend != NULL && button->priv->uri != NULL) { + EMailSession *session; + + session = e_mail_backend_get_session (backend); e_mail_folder_uri_parse ( - session, button->priv->uri, + CAMEL_SESSION (session), button->priv->uri, &store, &folder_name, NULL); + } if (store == NULL || folder_name == NULL) { folder_selection_button_unselected (button); @@ -127,16 +131,16 @@ folder_selection_button_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_CAPTION: - em_folder_selection_button_set_caption ( + case PROP_BACKEND: + em_folder_selection_button_set_backend ( EM_FOLDER_SELECTION_BUTTON (object), - g_value_get_string (value)); + g_value_get_object (value)); return; - case PROP_SESSION: - em_folder_selection_button_set_session ( + case PROP_CAPTION: + em_folder_selection_button_set_caption ( EM_FOLDER_SELECTION_BUTTON (object), - g_value_get_object (value)); + g_value_get_string (value)); return; case PROP_TITLE: @@ -156,17 +160,17 @@ folder_selection_button_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_CAPTION: - g_value_set_string ( + case PROP_BACKEND: + g_value_set_object ( value, - em_folder_selection_button_get_caption ( + em_folder_selection_button_get_backend ( EM_FOLDER_SELECTION_BUTTON (object))); return; - case PROP_SESSION: - g_value_set_object ( + case PROP_CAPTION: + g_value_set_string ( value, - em_folder_selection_button_get_session ( + em_folder_selection_button_get_caption ( EM_FOLDER_SELECTION_BUTTON (object))); return; @@ -188,9 +192,9 @@ folder_selection_button_dispose (GObject *object) priv = EM_FOLDER_SELECTION_BUTTON_GET_PRIVATE (object); - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; + if (priv->backend != NULL) { + g_object_unref (priv->backend); + priv->backend = NULL; } /* Chain up to parent's dispose() method. */ @@ -229,7 +233,7 @@ folder_selection_button_clicked (GtkButton *button) parent = gtk_widget_get_toplevel (GTK_WIDGET (button)); parent = gtk_widget_is_toplevel (parent) ? parent : NULL; - emft = (EMFolderTree *) em_folder_tree_new (priv->session); + emft = (EMFolderTree *) em_folder_tree_new (priv->backend); emu_restore_folder_tree_state (emft); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (emft)); @@ -279,23 +283,23 @@ em_folder_selection_button_class_init (EMFolderSelectionButtonClass *class) g_object_class_install_property ( object_class, - PROP_CAPTION, - g_param_spec_string ( - "caption", - NULL, + PROP_BACKEND, + g_param_spec_object ( + "backend", NULL, NULL, + E_TYPE_MAIL_BACKEND, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); g_object_class_install_property ( object_class, - PROP_SESSION, - g_param_spec_object ( - "session", + PROP_CAPTION, + g_param_spec_string ( + "caption", + NULL, NULL, NULL, - E_TYPE_MAIL_SESSION, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); @@ -345,15 +349,15 @@ em_folder_selection_button_init (EMFolderSelectionButton *emfsb) } GtkWidget * -em_folder_selection_button_new (EMailSession *session, +em_folder_selection_button_new (EMailBackend *backend, const gchar *title, const gchar *caption) { - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); return g_object_new ( EM_TYPE_FOLDER_SELECTION_BUTTON, - "session", session, "title", title, + "backend", backend, "title", title, "caption", caption, NULL); } @@ -400,31 +404,31 @@ em_folder_selection_button_set_selection (EMFolderSelectionButton *button, folder_selection_button_set_contents (button); } -EMailSession * -em_folder_selection_button_get_session (EMFolderSelectionButton *button) +EMailBackend * +em_folder_selection_button_get_backend (EMFolderSelectionButton *button) { g_return_val_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button), NULL); - return button->priv->session; + return button->priv->backend; } void -em_folder_selection_button_set_session (EMFolderSelectionButton *button, - EMailSession *session) +em_folder_selection_button_set_backend (EMFolderSelectionButton *button, + EMailBackend *backend) { g_return_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button)); - if (session != NULL) { - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_object_ref (session); + if (backend != NULL) { + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_object_ref (backend); } - if (button->priv->session != NULL) - g_object_unref (button->priv->session); + if (button->priv->backend != NULL) + g_object_unref (button->priv->backend); - button->priv->session = session; + button->priv->backend = backend; - g_object_notify (G_OBJECT (button), "session"); + g_object_notify (G_OBJECT (button), "backend"); } const gchar * diff --git a/mail/em-folder-selection-button.h b/mail/em-folder-selection-button.h index 504e17cddb..8b31100e84 100644 --- a/mail/em-folder-selection-button.h +++ b/mail/em-folder-selection-button.h @@ -25,7 +25,7 @@ #define EM_FOLDER_SELECTION_BUTTON_H #include <gtk/gtk.h> -#include <mail/e-mail-session.h> +#include <mail/e-mail-backend.h> /* Standard GObject macros */ #define EM_TYPE_FOLDER_SELECTION_BUTTON \ @@ -67,7 +67,7 @@ struct _EMFolderSelectionButtonClass { GType em_folder_selection_button_get_type (void); GtkWidget * em_folder_selection_button_new - (EMailSession *session, + (EMailBackend *backend, const gchar *title, const gchar *caption); const gchar * em_folder_selection_button_get_caption @@ -80,10 +80,10 @@ const gchar * em_folder_selection_button_get_selection void em_folder_selection_button_set_selection (EMFolderSelectionButton *button, const gchar *uri); -void em_folder_selection_button_set_session +void em_folder_selection_button_set_backend (EMFolderSelectionButton *button, - EMailSession *session); -EMailSession * em_folder_selection_button_get_session + EMailBackend *backend); +EMailBackend * em_folder_selection_button_get_backend (EMFolderSelectionButton *button); const gchar * em_folder_selection_button_get_title (EMFolderSelectionButton *button); diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c index 0f2bbc79f2..71e056e762 100644 --- a/mail/em-folder-selector.c +++ b/mail/em-folder-selector.c @@ -111,14 +111,17 @@ em_folder_selector_get_type (void) static void emfs_response (GtkWidget *dialog, gint response, EMFolderSelector *emfs) { + EMailBackend *backend; + if (response != EM_FOLDER_SELECTOR_RESPONSE_NEW) return; g_object_set_data ((GObject *)emfs->emft, "select", GUINT_TO_POINTER (1)); + backend = em_folder_tree_get_backend (emfs->emft); + em_folder_utils_create_folder ( - GTK_WINDOW (dialog), emfs->emft, - em_folder_tree_get_session (emfs->emft), NULL); + GTK_WINDOW (dialog), backend, emfs->emft, NULL); g_signal_stop_emission_by_name (emfs, "response"); } diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index e24b7d329b..613f10dc05 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -77,7 +77,7 @@ struct _selected_uri { }; struct _EMFolderTreePrivate { - EMailSession *session; + EMailBackend *backend; /* selected_uri structures of each path pending selection. */ GSList *select_uris; @@ -119,10 +119,10 @@ struct _EMFolderTreePrivate { enum { PROP_0, + PROP_BACKEND, PROP_COPY_TARGET_LIST, PROP_ELLIPSIZE, - PROP_PASTE_TARGET_LIST, - PROP_SESSION + PROP_PASTE_TARGET_LIST }; enum { @@ -454,6 +454,7 @@ folder_tree_expand_node (const gchar *key, GtkTreeModel *model; GtkTreePath *path; EAccount *account; + EMailBackend *backend; EMailSession *session; CamelStore *store; const gchar *p; @@ -473,7 +474,8 @@ folder_tree_expand_node (const gchar *key, tree_view = GTK_TREE_VIEW (folder_tree); model = gtk_tree_view_get_model (tree_view); - session = em_folder_tree_get_session (folder_tree); + backend = em_folder_tree_get_backend (folder_tree); + session = e_mail_backend_get_session (backend); if ((account = e_get_account_by_uid (uid)) && account->enabled) { store = (CamelStore *) camel_session_get_service ( @@ -717,13 +719,13 @@ exit: } static void -folder_tree_set_session (EMFolderTree *folder_tree, - EMailSession *session) +folder_tree_set_backend (EMFolderTree *folder_tree, + EMailBackend *backend) { - g_return_if_fail (CAMEL_IS_SESSION (session)); - g_return_if_fail (folder_tree->priv->session == NULL); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (folder_tree->priv->backend == NULL); - folder_tree->priv->session = g_object_ref (session); + folder_tree->priv->backend = g_object_ref (backend); } static GtkTargetList * @@ -763,16 +765,16 @@ folder_tree_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_ELLIPSIZE: - em_folder_tree_set_ellipsize ( + case PROP_BACKEND: + folder_tree_set_backend ( EM_FOLDER_TREE (object), - g_value_get_enum (value)); + g_value_get_object (value)); return; - case PROP_SESSION: - folder_tree_set_session ( + case PROP_ELLIPSIZE: + em_folder_tree_set_ellipsize ( EM_FOLDER_TREE (object), - g_value_get_object (value)); + g_value_get_enum (value)); return; } @@ -786,6 +788,13 @@ folder_tree_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_BACKEND: + g_value_set_object ( + value, + em_folder_tree_get_backend ( + EM_FOLDER_TREE (object))); + return; + case PROP_COPY_TARGET_LIST: g_value_set_boxed ( value, @@ -806,13 +815,6 @@ folder_tree_get_property (GObject *object, folder_tree_get_paste_target_list ( EM_FOLDER_TREE (object))); return; - - case PROP_SESSION: - g_value_set_object ( - value, - em_folder_tree_get_session ( - EM_FOLDER_TREE (object))); - return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -845,9 +847,9 @@ folder_tree_dispose (GObject *object) priv->autoexpand_id = 0; } - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; + if (priv->backend != NULL) { + g_object_unref (priv->backend); + priv->backend = NULL; } if (priv->text_renderer != NULL) { @@ -1103,6 +1105,17 @@ folder_tree_class_init (EMFolderTreeClass *class) tree_view_class->test_collapse_row = folder_tree_test_collapse_row; tree_view_class->row_expanded = folder_tree_row_expanded; + g_object_class_install_property ( + object_class, + PROP_BACKEND, + g_param_spec_object ( + "backend", + NULL, + NULL, + E_TYPE_MAIL_BACKEND, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + /* Inherited from ESelectableInterface */ g_object_class_override_property ( object_class, @@ -1126,17 +1139,6 @@ folder_tree_class_init (EMFolderTreeClass *class) PROP_PASTE_TARGET_LIST, "paste-target-list"); - g_object_class_install_property ( - object_class, - PROP_SESSION, - g_param_spec_object ( - "session", - NULL, - NULL, - E_TYPE_MAIL_SESSION, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - signals[FOLDER_SELECTED] = g_signal_new ( "folder-selected", G_OBJECT_CLASS_TYPE (object_class), @@ -1702,22 +1704,20 @@ em_folder_tree_get_type (void) } GtkWidget * -em_folder_tree_new (EMailSession *session) +em_folder_tree_new (EMailBackend *backend) { + EMailSession *session; const gchar *data_dir; - EShell *default_shell; - EShellBackend *mail_backend; - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); - default_shell = e_shell_get_default (); - mail_backend = e_shell_get_backend_by_name (default_shell, "mail"); - data_dir = e_shell_backend_get_data_dir (mail_backend); + session = e_mail_backend_get_session (backend); + data_dir = e_shell_backend_get_data_dir (E_SHELL_BACKEND (backend)); e_mail_store_init (session, data_dir); return g_object_new ( - EM_TYPE_FOLDER_TREE, "session", session, NULL); + EM_TYPE_FOLDER_TREE, "backend", backend, NULL); } PangoEllipsizeMode @@ -1742,12 +1742,12 @@ em_folder_tree_set_ellipsize (EMFolderTree *folder_tree, g_object_notify (G_OBJECT (folder_tree), "ellipsize"); } -EMailSession * -em_folder_tree_get_session (EMFolderTree *folder_tree) +EMailBackend * +em_folder_tree_get_backend (EMFolderTree *folder_tree) { g_return_val_if_fail (EM_IS_FOLDER_TREE (folder_tree), NULL); - return folder_tree->priv->session; + return folder_tree->priv->backend; } static void @@ -2052,6 +2052,7 @@ tree_drag_data_received (GtkWidget *widget, GtkTreeModel *model; GtkTreeView *tree_view; GtkTreePath *dest_path = NULL; + EMailBackend *backend; EMailSession *session; struct _DragDataReceivedAsync *m; gboolean is_store; @@ -2062,7 +2063,8 @@ tree_drag_data_received (GtkWidget *widget, tree_view = GTK_TREE_VIEW (folder_tree); model = gtk_tree_view_get_model (tree_view); - session = em_folder_tree_get_session (folder_tree); + backend = em_folder_tree_get_backend (folder_tree); + session = e_mail_backend_get_session (backend); if (!gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &dest_path, &pos)) return; @@ -2726,9 +2728,11 @@ em_folder_tree_set_selected_list (EMFolderTree *folder_tree, gboolean expand_only) { EMFolderTreePrivate *priv = folder_tree->priv; + EMailBackend *backend; EMailSession *session; - session = em_folder_tree_get_session (folder_tree); + backend = em_folder_tree_get_backend (folder_tree); + session = e_mail_backend_get_session (backend); /* FIXME: need to remove any currently selected stuff? */ if (!expand_only) diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h index f0f89e9fb0..bc131d4f77 100644 --- a/mail/em-folder-tree.h +++ b/mail/em-folder-tree.h @@ -25,7 +25,7 @@ #define EM_FOLDER_TREE_H #include <gtk/gtk.h> -#include <mail/e-mail-session.h> +#include <mail/e-mail-backend.h> #include <mail/em-folder-tree-model.h> /* Standard GObject macros */ @@ -89,12 +89,12 @@ struct _EMFolderTreeClass { }; GType em_folder_tree_get_type (void); -GtkWidget * em_folder_tree_new (EMailSession *session); +GtkWidget * em_folder_tree_new (EMailBackend *backend); PangoEllipsizeMode em_folder_tree_get_ellipsize (EMFolderTree *folder_tree); void em_folder_tree_set_ellipsize (EMFolderTree *folder_tree, PangoEllipsizeMode ellipsize); -EMailSession * em_folder_tree_get_session (EMFolderTree *folder_tree); +EMailBackend * em_folder_tree_get_backend (EMFolderTree *folder_tree); void em_folder_tree_enable_drag_and_drop (EMFolderTree *folder_tree); void em_folder_tree_set_excluded (EMFolderTree *folder_tree, diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index a3f7847768..498167d2b4 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -473,7 +473,7 @@ em_folder_utils_copy_folder (GtkWindow *parent, } /* XXX Do we leak this reference. */ - emft = (EMFolderTree *) em_folder_tree_new (session); + emft = (EMFolderTree *) em_folder_tree_new (backend); emu_restore_folder_tree_state (emft); em_folder_tree_set_excluded_func ( @@ -512,7 +512,7 @@ new_folder_created_cb (CamelStore *store, g_warning ("%s", error->message); g_error_free (error); - } else { + } else if (context->folder_tree != NULL) { gpointer data; gboolean expand_only; @@ -531,10 +531,11 @@ new_folder_created_cb (CamelStore *store, void em_folder_utils_create_folder (GtkWindow *parent, + EMailBackend *backend, EMFolderTree *emft, - EMailSession *session, const gchar *initial_uri) { + EMailSession *session; EMFolderTree *folder_tree; CamelStore *store = NULL; const gchar *folder_uri; @@ -542,14 +543,12 @@ em_folder_utils_create_folder (GtkWindow *parent, GtkWidget *dialog; GError *error = NULL; - /* FIXME The EMailSession argument isn't really necessary. - * We could extract it via em_folder_tree_get_session(). */ - g_return_if_fail (GTK_IS_WINDOW (parent)); - g_return_if_fail (EM_IS_FOLDER_TREE (emft)); - g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); - folder_tree = (EMFolderTree *) em_folder_tree_new (session); + session = e_mail_backend_get_session (backend); + + folder_tree = (EMFolderTree *) em_folder_tree_new (backend); emu_restore_folder_tree_state (folder_tree); dialog = em_folder_selector_create_new ( @@ -584,16 +583,18 @@ em_folder_utils_create_folder (GtkWindow *parent, if (CAMEL_IS_VEE_STORE (store)) { EFilterRule *rule; - rule = em_vfolder_rule_new (session); + rule = em_vfolder_rule_new (backend); e_filter_rule_set_name (rule, folder_name); vfolder_gui_add_rule (EM_VFOLDER_RULE (rule)); } else { AsyncContext *context; context = g_slice_new0 (AsyncContext); - context->folder_tree = g_object_ref (emft); context->folder_uri = g_strdup (folder_uri); + if (EM_IS_FOLDER_TREE (emft)) + context->folder_tree = g_object_ref (emft); + /* FIXME Not passing a GCancellable. */ e_mail_store_create_folder ( store, folder_name, G_PRIORITY_DEFAULT, NULL, diff --git a/mail/em-folder-utils.h b/mail/em-folder-utils.h index e3d86d1d02..e76c5df66f 100644 --- a/mail/em-folder-utils.h +++ b/mail/em-folder-utils.h @@ -45,8 +45,8 @@ void em_folder_utils_copy_folder (GtkWindow *parent, const gchar *folder_uri, gboolean delete); void em_folder_utils_create_folder (GtkWindow *parent, + EMailBackend *backend, EMFolderTree *emft, - EMailSession *session, const gchar *initial_uri); const gchar * em_folder_utils_get_icon_name (guint32 flags); diff --git a/mail/em-utils.c b/mail/em-utils.c index c832c898c6..f7f957ba82 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -291,7 +291,6 @@ em_utils_edit_filters (GtkWidget *parent, const gchar *config_dir; gchar *user, *system; EMFilterContext *fc; - EMailSession *session; g_return_if_fail (E_IS_MAIL_BACKEND (backend)); @@ -301,9 +300,8 @@ em_utils_edit_filters (GtkWidget *parent, } config_dir = mail_session_get_config_dir (); - session = e_mail_backend_get_session (backend); - fc = em_filter_context_new (session); + fc = em_filter_context_new (backend); user = g_build_filename (config_dir, "filters.xml", NULL); system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL); e_rule_context_load ((ERuleContext *) fc, system, user); diff --git a/mail/em-vfolder-context.c b/mail/em-vfolder-context.c index ebad8f2bac..371914c886 100644 --- a/mail/em-vfolder-context.c +++ b/mail/em-vfolder-context.c @@ -36,12 +36,12 @@ #include "em-filter-folder-element.h" struct _EMVFolderContextPrivate { - EMailSession *session; + EMailBackend *backend; }; enum { PROP_0, - PROP_SESSION + PROP_BACKEND }; G_DEFINE_TYPE ( @@ -50,13 +50,13 @@ G_DEFINE_TYPE ( E_TYPE_RULE_CONTEXT) static void -vfolder_context_set_session (EMVFolderContext *context, - EMailSession *session) +vfolder_context_set_backend (EMVFolderContext *context, + EMailBackend *backend) { - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (context->priv->session == NULL); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (context->priv->backend == NULL); - context->priv->session = g_object_ref (session); + context->priv->backend = g_object_ref (backend); } static void @@ -66,8 +66,8 @@ vfolder_context_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: - vfolder_context_set_session ( + case PROP_BACKEND: + vfolder_context_set_backend ( EM_VFOLDER_CONTEXT (object), g_value_get_object (value)); return; @@ -83,10 +83,10 @@ vfolder_context_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: + case PROP_BACKEND: g_value_set_object ( value, - em_vfolder_context_get_session ( + em_vfolder_context_get_backend ( EM_VFOLDER_CONTEXT (object))); return; } @@ -101,9 +101,9 @@ vfolder_context_dispose (GObject *object) priv = EM_VFOLDER_CONTEXT (object)->priv; - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; + if (priv->backend != NULL) { + g_object_unref (priv->backend); + priv->backend = NULL; } /* Chain up to parent's dispose() method. */ @@ -125,11 +125,11 @@ vfolder_context_new_element (ERuleContext *context, return e_filter_int_new_type("score", -3, 3); if (strcmp (type, "folder") == 0) - return em_filter_folder_element_new (priv->session); + return em_filter_folder_element_new (priv->backend); /* XXX Legacy type name. Same as "folder" now. */ if (strcmp (type, "folder-curi") == 0) - return em_filter_folder_element_new (priv->session); + return em_filter_folder_element_new (priv->backend); return E_RULE_CONTEXT_CLASS (em_vfolder_context_parent_class)-> new_element (context, type); @@ -153,12 +153,12 @@ em_vfolder_context_class_init (EMVFolderContextClass *class) g_object_class_install_property ( object_class, - PROP_SESSION, + PROP_BACKEND, g_param_spec_object ( - "session", + "backend", NULL, NULL, - E_TYPE_MAIL_SESSION, + E_TYPE_MAIL_BACKEND, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } @@ -184,18 +184,18 @@ em_vfolder_context_init (EMVFolderContext *context) } EMVFolderContext * -em_vfolder_context_new (EMailSession *session) +em_vfolder_context_new (EMailBackend *backend) { - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); return g_object_new ( - EM_TYPE_VFOLDER_CONTEXT, "session", session, NULL); + EM_TYPE_VFOLDER_CONTEXT, "backend", backend, NULL); } -EMailSession * -em_vfolder_context_get_session (EMVFolderContext *context) +EMailBackend * +em_vfolder_context_get_backend (EMVFolderContext *context) { g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL); - return context->priv->session; + return context->priv->backend; } diff --git a/mail/em-vfolder-context.h b/mail/em-vfolder-context.h index c0fd041abc..4a5406356b 100644 --- a/mail/em-vfolder-context.h +++ b/mail/em-vfolder-context.h @@ -25,7 +25,7 @@ #ifndef EM_VFOLDER_CONTEXT_H #define EM_VFOLDER_CONTEXT_H -#include <mail/e-mail-session.h> +#include <mail/e-mail-backend.h> #include <filter/e-rule-context.h> /* Standard GObject macros */ @@ -64,8 +64,8 @@ struct _EMVFolderContextClass { GType em_vfolder_context_get_type (void); EMVFolderContext * - em_vfolder_context_new (EMailSession *session); -EMailSession * em_vfolder_context_get_session (EMVFolderContext *context); + em_vfolder_context_new (EMailBackend *backend); +EMailBackend * em_vfolder_context_get_backend (EMVFolderContext *context); G_END_DECLS diff --git a/mail/em-vfolder-editor.c b/mail/em-vfolder-editor.c index b1f58ed242..7da89fb59b 100644 --- a/mail/em-vfolder-editor.c +++ b/mail/em-vfolder-editor.c @@ -46,15 +46,15 @@ static EFilterRule * vfolder_editor_create_rule (ERuleEditor *rule_editor) { EMVFolderContext *context; - EMailSession *session; + EMailBackend *backend; EFilterRule *rule; EFilterPart *part; context = EM_VFOLDER_CONTEXT (rule_editor->context); - session = em_vfolder_context_get_session (context); + backend = em_vfolder_context_get_backend (context); /* create a rule with 1 part in it */ - rule = em_vfolder_rule_new (session); + rule = em_vfolder_rule_new (backend); part = e_rule_context_next_part (rule_editor->context, NULL); e_filter_rule_add_part (rule, e_filter_part_clone (part)); diff --git a/mail/em-vfolder-rule.c b/mail/em-vfolder-rule.c index e409cdc016..01622711d3 100644 --- a/mail/em-vfolder-rule.c +++ b/mail/em-vfolder-rule.c @@ -43,12 +43,12 @@ #include "e-util/e-util-private.h" struct _EMVFolderRulePrivate { - EMailSession *session; + EMailBackend *backend; }; enum { PROP_0, - PROP_SESSION + PROP_BACKEND }; static gint validate (EFilterRule *, EAlert **alert); @@ -72,25 +72,22 @@ G_DEFINE_TYPE ( E_TYPE_FILTER_RULE) static void -vfolder_rule_set_session (EMVFolderRule *rule, - EMailSession *session) +vfolder_rule_set_backend (EMVFolderRule *rule, + EMailBackend *backend) { - if (session == NULL) { + if (backend == NULL) { EShell *shell; EShellBackend *shell_backend; - EMailBackend *backend; shell = e_shell_get_default (); shell_backend = e_shell_get_backend_by_name (shell, "mail"); - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); } - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (rule->priv->session == NULL); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (rule->priv->backend == NULL); - rule->priv->session = g_object_ref (session); + rule->priv->backend = g_object_ref (backend); } static void @@ -100,8 +97,8 @@ vfolder_rule_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: - vfolder_rule_set_session ( + case PROP_BACKEND: + vfolder_rule_set_backend ( EM_VFOLDER_RULE (object), g_value_get_object (value)); return; @@ -117,10 +114,10 @@ vfolder_rule_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_SESSION: + case PROP_BACKEND: g_value_set_object ( value, - em_vfolder_rule_get_session ( + em_vfolder_rule_get_backend ( EM_VFOLDER_RULE (object))); return; } @@ -135,9 +132,9 @@ vfolder_rule_dispose (GObject *object) priv = EM_VFOLDER_RULE (object)->priv; - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; + if (priv->backend != NULL) { + g_object_unref (priv->backend); + priv->backend = NULL; } /* Chain up to parent's dispose() method. */ @@ -180,12 +177,12 @@ em_vfolder_rule_class_init (EMVFolderRuleClass *class) g_object_class_install_property ( object_class, - PROP_SESSION, + PROP_BACKEND, g_param_spec_object ( - "session", + "backend", NULL, NULL, - E_TYPE_MAIL_SESSION, + E_TYPE_MAIL_BACKEND, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } @@ -201,20 +198,20 @@ em_vfolder_rule_init (EMVFolderRule *rule) } EFilterRule * -em_vfolder_rule_new (EMailSession *session) +em_vfolder_rule_new (EMailBackend *backend) { - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); return g_object_new ( - EM_TYPE_VFOLDER_RULE, "session", session, NULL); + EM_TYPE_VFOLDER_RULE, "backend", backend, NULL); } -EMailSession * -em_vfolder_rule_get_session (EMVFolderRule *rule) +EMailBackend * +em_vfolder_rule_get_backend (EMVFolderRule *rule) { g_return_val_if_fail (EM_IS_VFOLDER_RULE (rule), NULL); - return rule->priv->session; + return rule->priv->backend; } void @@ -593,16 +590,16 @@ static void source_add (GtkWidget *widget, struct _source_data *data) { EMFolderTree *emft; - EMailSession *session; + EMailBackend *backend; GtkWidget *dialog; gpointer parent; parent = gtk_widget_get_toplevel (widget); parent = gtk_widget_is_toplevel (parent) ? parent : NULL; - session = em_vfolder_rule_get_session (data->vr); + backend = em_vfolder_rule_get_backend (data->vr); - emft = (EMFolderTree *) em_folder_tree_new (session); + emft = (EMFolderTree *) em_folder_tree_new (backend); emu_restore_folder_tree_state (emft); em_folder_tree_set_excluded (emft, EMFT_EXCLUDE_NOSELECT); diff --git a/mail/em-vfolder-rule.h b/mail/em-vfolder-rule.h index 136c29a52b..fa6df8576e 100644 --- a/mail/em-vfolder-rule.h +++ b/mail/em-vfolder-rule.h @@ -24,7 +24,7 @@ #ifndef EM_VFOLDER_RULE_H #define EM_VFOLDER_RULE_H -#include <mail/e-mail-session.h> +#include <mail/e-mail-backend.h> #include <filter/e-filter-rule.h> /* Standard GObject macros */ @@ -75,8 +75,8 @@ struct _EMVFolderRuleClass { }; GType em_vfolder_rule_get_type (void); -EFilterRule * em_vfolder_rule_new (EMailSession *session); -EMailSession * em_vfolder_rule_get_session (EMVFolderRule *rule); +EFilterRule * em_vfolder_rule_new (EMailBackend *backend); +EMailBackend * em_vfolder_rule_get_backend (EMVFolderRule *rule); void em_vfolder_rule_add_source (EMVFolderRule *rule, const gchar *uri); void em_vfolder_rule_remove_source (EMVFolderRule *rule, diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index 9c251027e3..174c34b7a0 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -82,18 +82,16 @@ 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. + /* XXX Dig up the mail backend 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 (shell); @@ -130,7 +128,8 @@ mbox_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im) label = GTK_LABEL (w); w = em_folder_selection_button_new ( - session, _("Select folder"), + E_MAIL_BACKEND (shell_backend), + _("Select folder"), _("Select folder to import into")); gtk_label_set_mnemonic_widget (label, w); em_folder_selection_button_set_selection ( diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c index 56cc5e9813..0efe54ba7f 100644 --- a/mail/mail-autofilter.c +++ b/mail/mail-autofilter.c @@ -316,7 +316,7 @@ em_vfolder_rule_from_message (EMVFolderContext *context, CamelFolder *folder) { EFilterRule *rule; - EMailSession *session; + EMailBackend *backend; gchar *uri; g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL); @@ -325,9 +325,9 @@ em_vfolder_rule_from_message (EMVFolderContext *context, uri = e_mail_folder_uri_from_folder (folder); - session = em_vfolder_context_get_session (context); + backend = em_vfolder_context_get_backend (context); - rule = em_vfolder_rule_new (session); + rule = em_vfolder_rule_new (backend); em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), uri); rule_from_message (rule, E_RULE_CONTEXT (context), msg, flags); @@ -343,7 +343,7 @@ em_vfolder_rule_from_address (EMVFolderContext *context, CamelFolder *folder) { EFilterRule *rule; - EMailSession *session; + EMailBackend *backend; gchar *uri; g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL); @@ -352,9 +352,9 @@ em_vfolder_rule_from_address (EMVFolderContext *context, uri = e_mail_folder_uri_from_folder (folder); - session = em_vfolder_context_get_session (context); + backend = em_vfolder_context_get_backend (context); - rule = em_vfolder_rule_new (session); + rule = em_vfolder_rule_new (backend); em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), uri); rule_from_address (rule, E_RULE_CONTEXT (context), addr, flags); @@ -386,7 +386,7 @@ filter_rule_from_message (EMFilterContext *context, } void -filter_gui_add_from_message (EMailSession *session, +filter_gui_add_from_message (EMailBackend *backend, CamelMimeMessage *msg, const gchar *source, gint flags) @@ -396,10 +396,10 @@ filter_gui_add_from_message (EMailSession *session, gchar *user, *system; EFilterRule *rule; - g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); g_return_if_fail (CAMEL_IS_MIME_MESSAGE (msg)); - fc = em_filter_context_new (session); + fc = em_filter_context_new (backend); config_dir = mail_session_get_config_dir (); user = g_build_filename (config_dir, "filters.xml", NULL); system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL); @@ -422,7 +422,6 @@ mail_filter_rename_folder (EMailBackend *backend, const gchar *new_folder_name) { EMFilterContext *fc; - EMailSession *session; const gchar *config_dir; gchar *user, *system; GList *changed; @@ -437,9 +436,7 @@ mail_filter_rename_folder (EMailBackend *backend, old_uri = e_mail_folder_uri_build (store, old_folder_name); new_uri = e_mail_folder_uri_build (store, new_folder_name); - session = e_mail_backend_get_session (backend); - - fc = em_filter_context_new (session); + fc = em_filter_context_new (backend); config_dir = mail_session_get_config_dir (); user = g_build_filename (config_dir, "filters.xml", NULL); system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL); @@ -467,7 +464,6 @@ mail_filter_delete_folder (EMailBackend *backend, const gchar *folder_name) { EMFilterContext *fc; - EMailSession *session; const gchar *config_dir; gchar *user, *system; GList *deleted; @@ -479,9 +475,7 @@ mail_filter_delete_folder (EMailBackend *backend, uri = e_mail_folder_uri_build (store, folder_name); - session = e_mail_backend_get_session (backend); - - fc = em_filter_context_new (session); + fc = em_filter_context_new (backend); config_dir = mail_session_get_config_dir (); user = g_build_filename (config_dir, "filters.xml", NULL); system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL); diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h index 418c2e38f1..43671177ae 100644 --- a/mail/mail-autofilter.h +++ b/mail/mail-autofilter.h @@ -51,7 +51,7 @@ EFilterRule * em_vfolder_rule_from_address (EMVFolderContext *context, CamelFolder *folder); /* easiest place to put this */ -void filter_gui_add_from_message (EMailSession *session, +void filter_gui_add_from_message (EMailBackend *backend, CamelMimeMessage *msg, const gchar *source, gint flags); diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index e726433897..526e0ea1ad 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -805,13 +805,15 @@ rule_add_sources (EMailSession *session, static void rule_changed (EFilterRule *rule, CamelFolder *folder) { + EMailBackend *backend; EMailSession *session; GList *sources_uri = NULL, *sources_folder = NULL; GString *query; const gchar *full_name; full_name = camel_folder_get_full_name (folder); - session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule)); + backend = em_vfolder_rule_get_backend (EM_VFOLDER_RULE (rule)); + session = e_mail_backend_get_session (backend); /* if the folder has changed name, then add it, then remove the old manually */ if (strcmp (full_name, rule->name) != 0) { @@ -1109,7 +1111,7 @@ vfolder_load_storage (EMailBackend *backend) /* load our rules */ user = g_build_filename (config_dir, "vfolders.xml", NULL); - context = em_vfolder_context_new (session); + context = em_vfolder_context_new (backend); xmlfile = g_build_filename (EVOLUTION_PRIVDATADIR, "vfoldertypes.xml", NULL); if (e_rule_context_load ((ERuleContext *) context, @@ -1345,12 +1347,12 @@ vfolder_create_part (const gchar *name) /* clones a filter/search rule into a matching vfolder rule * (assuming the same system definitions) */ EFilterRule * -vfolder_clone_rule (EMailSession *session, EFilterRule *in) +vfolder_clone_rule (EMailBackend *backend, EFilterRule *in) { EFilterRule *rule; xmlNodePtr xml; - rule = em_vfolder_rule_new (session); + rule = em_vfolder_rule_new (backend); xml = e_filter_rule_xml_encode (in); e_filter_rule_xml_decode (rule, xml, (ERuleContext *) context); diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h index 3e41bfce37..42bea19bf3 100644 --- a/mail/mail-vfolder.h +++ b/mail/mail-vfolder.h @@ -36,7 +36,7 @@ void vfolder_edit (EShellView *shell_view); void vfolder_edit_rule (EMailBackend *backend, const gchar *folder_uri); EFilterPart * vfolder_create_part (const gchar *name); -EFilterRule * vfolder_clone_rule (EMailSession *session, +EFilterRule * vfolder_clone_rule (EMailBackend *backend, EFilterRule *in); void vfolder_gui_add_rule (EMVFolderRule *rule); void vfolder_gui_add_from_message (EMailSession *session, |