aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-12-16 23:40:37 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-12-16 23:58:54 +0800
commita9cfed5938aef37d95c009411f965ebc185547c1 (patch)
treed0c6eb1d5acea6752425169aae47e8f4ed4b55ea /mail
parentdf85cb1b7a47f713cb775f648f735e642a1bb71b (diff)
downloadgsoc2013-evolution-a9cfed5938aef37d95c009411f965ebc185547c1.tar.gz
gsoc2013-evolution-a9cfed5938aef37d95c009411f965ebc185547c1.tar.zst
gsoc2013-evolution-a9cfed5938aef37d95c009411f965ebc185547c1.zip
Avoid passing EMailBackend as much as possible.
More mail API churn... reversing some previous API decisions. I've made some key API changes to EMailSession on the account-mgmt branch which should allow for this, and will hopefully also benefit the "email-factory" branch. EMailBackend barely needs to exist anymore, except as the owner of EMailSession. For several low-level functions, we replace its EMailBackend parameter with EMailSession and EAlertSink parameters; the latter so it can still pass user alerts up the chain.
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-backend.c93
-rw-r--r--mail/e-mail-backend.h4
-rw-r--r--mail/e-mail-browser.c4
-rw-r--r--mail/e-mail-paned-view.c7
-rw-r--r--mail/e-mail-reader-utils.c22
-rw-r--r--mail/e-mail-reader.c4
-rw-r--r--mail/e-mail-session.c18
-rw-r--r--mail/e-mail-sidebar.c6
-rw-r--r--mail/e-mail-sidebar.h3
-rw-r--r--mail/em-account-editor.c8
-rw-r--r--mail/em-composer-utils.c7
-rw-r--r--mail/em-filter-context.c50
-rw-r--r--mail/em-filter-context.h6
-rw-r--r--mail/em-filter-folder-element.c61
-rw-r--r--mail/em-filter-folder-element.h6
-rw-r--r--mail/em-filter-source-element.c56
-rw-r--r--mail/em-filter-source-element.h6
-rw-r--r--mail/em-folder-properties.c54
-rw-r--r--mail/em-folder-properties.h9
-rw-r--r--mail/em-folder-selection-button.c103
-rw-r--r--mail/em-folder-selection-button.h10
-rw-r--r--mail/em-folder-selector.c68
-rw-r--r--mail/em-folder-selector.h3
-rw-r--r--mail/em-folder-tree.c108
-rw-r--r--mail/em-folder-tree.h8
-rw-r--r--mail/em-folder-utils.c52
-rw-r--r--mail/em-folder-utils.h7
-rw-r--r--mail/em-subscription-editor.c53
-rw-r--r--mail/em-subscription-editor.h6
-rw-r--r--mail/em-utils.c68
-rw-r--r--mail/em-utils.h8
-rw-r--r--mail/em-vfolder-context.c50
-rw-r--r--mail/em-vfolder-context.h6
-rw-r--r--mail/em-vfolder-editor.c6
-rw-r--r--mail/em-vfolder-rule.c66
-rw-r--r--mail/em-vfolder-rule.h6
-rw-r--r--mail/importers/evolution-mbox-importer.c3
-rw-r--r--mail/mail-autofilter.c44
-rw-r--r--mail/mail-autofilter.h13
-rw-r--r--mail/mail-ops.c127
-rw-r--r--mail/mail-ops.h9
-rw-r--r--mail/mail-send-recv.c137
-rw-r--r--mail/mail-send-recv.h15
-rw-r--r--mail/mail-vfolder.c129
-rw-r--r--mail/mail-vfolder.h10
-rw-r--r--mail/message-list.c90
-rw-r--r--mail/message-list.h6
47 files changed, 715 insertions, 920 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index dee2027f08..2f769e9c42 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -387,6 +387,7 @@ mail_backend_folder_deleted_cb (MailFolderCache *folder_cache,
EAccountList *account_list;
EIterator *iterator;
EMailSession *session;
+ EAlertSink *alert_sink;
const gchar *local_drafts_folder_uri;
const gchar *local_sent_folder_uri;
gboolean write_config = FALSE;
@@ -400,6 +401,7 @@ mail_backend_folder_deleted_cb (MailFolderCache *folder_cache,
g_return_if_fail (class->compare_folder_name != NULL);
session = e_mail_backend_get_session (backend);
+ alert_sink = e_mail_backend_get_alert_sink (backend);
local_drafts_folder_uri =
e_mail_session_get_local_folder_uri (
@@ -459,7 +461,7 @@ mail_backend_folder_deleted_cb (MailFolderCache *folder_cache,
/* This does something completely different.
* XXX Make it a separate signal handler? */
- mail_filter_delete_folder (backend, store, folder_name);
+ mail_filter_delete_folder (store, folder_name, alert_sink);
}
static void
@@ -553,7 +555,7 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
/* This does something completely different.
* XXX Make it a separate signal handler? */
mail_filter_rename_folder (
- backend, store, old_folder_name, new_folder_name);
+ store, old_folder_name, new_folder_name);
}
static void
@@ -896,38 +898,8 @@ e_mail_backend_get_session (EMailBackend *backend)
return backend->priv->session;
}
-gboolean
-e_mail_backend_delete_junk_policy_decision (EMailBackend *backend)
-{
- EMailBackendClass *class;
-
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), FALSE);
-
- class = E_MAIL_BACKEND_GET_CLASS (backend);
- if (class->delete_junk_policy_decision == NULL)
- return FALSE;
-
- return class->delete_junk_policy_decision (backend);
-}
-
-gboolean
-e_mail_backend_empty_trash_policy_decision (EMailBackend *backend)
-{
- EMailBackendClass *class;
-
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), FALSE);
-
- class = E_MAIL_BACKEND_GET_CLASS (backend);
- if (class->empty_trash_policy_decision == NULL)
- return FALSE;
-
- return class->empty_trash_policy_decision (backend);
-}
-
-void
-e_mail_backend_submit_alert (EMailBackend *backend,
- const gchar *tag,
- ...)
+EAlertSink *
+e_mail_backend_get_alert_sink (EMailBackend *backend)
{
EShell *shell;
EShellView *shell_view;
@@ -936,16 +908,13 @@ e_mail_backend_submit_alert (EMailBackend *backend,
EShellWindow *shell_window = NULL;
EShellBackendClass *class;
GtkApplication *application;
- GList *list, *iter;
- va_list va;
+ GList *list, *link;
/* XXX This is meant to be a convenient but temporary hack.
- * Instead, pass alerts directly to an EShellContent.
- * Perhaps even take an EAlert** instead of a GError**
- * in some low-level functions. */
+ * It digs through the list of available EShellWindows
+ * to find a suitable EAlertSink. */
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (tag != NULL);
+ g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
@@ -954,23 +923,47 @@ e_mail_backend_submit_alert (EMailBackend *backend,
list = gtk_application_get_windows (application);
/* Find the most recently used EShellWindow. */
- for (iter = list; iter != NULL; iter = g_list_next (iter)) {
- if (E_IS_SHELL_WINDOW (iter->data)) {
- shell_window = E_SHELL_WINDOW (iter->data);
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ if (E_IS_SHELL_WINDOW (link->data)) {
+ shell_window = E_SHELL_WINDOW (link->data);
break;
}
}
- /* If we can't find an EShellWindow then... well, screw it. */
- if (shell_window == NULL)
- return;
+ g_return_val_if_fail (shell_window != NULL, NULL);
class = E_SHELL_BACKEND_GET_CLASS (shell_backend);
shell_view = e_shell_window_get_shell_view (shell_window, class->name);
shell_content = e_shell_view_get_shell_content (shell_view);
- va_start (va, tag);
- e_alert_submit_valist (E_ALERT_SINK (shell_content), tag, va);
- va_end (va);
+ return E_ALERT_SINK (shell_content);
+}
+
+gboolean
+e_mail_backend_delete_junk_policy_decision (EMailBackend *backend)
+{
+ EMailBackendClass *class;
+
+ g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), FALSE);
+
+ class = E_MAIL_BACKEND_GET_CLASS (backend);
+ if (class->delete_junk_policy_decision == NULL)
+ return FALSE;
+
+ return class->delete_junk_policy_decision (backend);
+}
+
+gboolean
+e_mail_backend_empty_trash_policy_decision (EMailBackend *backend)
+{
+ EMailBackendClass *class;
+
+ g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), FALSE);
+
+ class = E_MAIL_BACKEND_GET_CLASS (backend);
+ if (class->empty_trash_policy_decision == NULL)
+ return FALSE;
+
+ return class->empty_trash_policy_decision (backend);
}
diff --git a/mail/e-mail-backend.h b/mail/e-mail-backend.h
index 6d425197f3..6279d3fb5e 100644
--- a/mail/e-mail-backend.h
+++ b/mail/e-mail-backend.h
@@ -71,13 +71,11 @@ struct _EMailBackendClass {
GType e_mail_backend_get_type (void);
EMailSession * e_mail_backend_get_session (EMailBackend *backend);
+EAlertSink * e_mail_backend_get_alert_sink (EMailBackend *backend);
gboolean e_mail_backend_delete_junk_policy_decision
(EMailBackend *backend);
gboolean e_mail_backend_empty_trash_policy_decision
(EMailBackend *backend);
-void e_mail_backend_submit_alert (EMailBackend *backend,
- const gchar *tag,
- ...) G_GNUC_NULL_TERMINATED;
G_END_DECLS
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index d7eb4ab574..663d25cc75 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -537,6 +537,7 @@ mail_browser_constructed (GObject *object)
EMFormatHTML *formatter;
EMailReader *reader;
EMailBackend *backend;
+ EMailSession *session;
EShellBackend *shell_backend;
EShell *shell;
EFocusTracker *focus_tracker;
@@ -560,6 +561,7 @@ mail_browser_constructed (GObject *object)
reader = E_MAIL_READER (object);
backend = e_mail_reader_get_backend (reader);
+ session = e_mail_backend_get_session (backend);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
@@ -579,7 +581,7 @@ mail_browser_constructed (GObject *object)
/* The message list is a widget, but it is not shown in the browser.
* Unfortunately, the widget is inseparable from its model, and the
* model is all we need. */
- browser->priv->message_list = message_list_new (backend);
+ browser->priv->message_list = message_list_new (session);
g_object_ref_sink (browser->priv->message_list);
g_signal_connect_swapped (
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index 1634044589..0098462de1 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -619,6 +619,8 @@ mail_paned_view_constructed (GObject *object)
EShellSettings *shell_settings;
ESearchBar *search_bar;
EMailReader *reader;
+ EMailBackend *backend;
+ EMailSession *session;
EMailView *view;
GtkWidget *message_list;
GtkWidget *container;
@@ -635,6 +637,9 @@ mail_paned_view_constructed (GObject *object)
shell = e_shell_window_get_shell (shell_window);
shell_settings = e_shell_get_shell_settings (shell);
+ backend = E_MAIL_BACKEND (shell_backend);
+ session = e_mail_backend_get_session (backend);
+
/* Make headers collapsable and store state of headers in config file */
em_format_html_set_headers_collapsable (
EM_FORMAT_HTML (priv->formatter), TRUE);
@@ -675,7 +680,7 @@ mail_paned_view_constructed (GObject *object)
container = widget;
- widget = message_list_new (E_MAIL_BACKEND (shell_backend));
+ widget = message_list_new (session);
gtk_container_add (GTK_CONTAINER (container), widget);
priv->message_list = g_object_ref (widget);
gtk_widget_show (widget);
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index ffca3d89ac..bd51c97e1f 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -198,6 +198,7 @@ e_mail_reader_delete_folder (EMailReader *reader,
GtkWindow *parent = e_shell_get_active_window (NULL);
GtkWidget *dialog;
gboolean store_is_local;
+ const gchar *display_name;
const gchar *full_name;
const gchar *uid;
CamelFolderInfoFlags flags = 0;
@@ -207,6 +208,7 @@ e_mail_reader_delete_folder (EMailReader *reader,
g_return_if_fail (CAMEL_IS_FOLDER (folder));
full_name = camel_folder_get_full_name (folder);
+ display_name = camel_folder_get_display_name (folder);
parent_store = camel_folder_get_parent_store (folder);
uid = camel_service_get_uid (CAMEL_SERVICE (parent_store));
@@ -220,9 +222,9 @@ e_mail_reader_delete_folder (EMailReader *reader,
if (store_is_local &&
mail_reader_is_special_local_folder (full_name)) {
- e_mail_backend_submit_alert (
- backend, "mail:no-delete-special-folder",
- full_name, NULL);
+ e_alert_submit (
+ alert_sink, "mail:no-delete-special-folder",
+ display_name, NULL);
return;
}
@@ -232,7 +234,7 @@ e_mail_reader_delete_folder (EMailReader *reader,
if (have_flags && (flags & CAMEL_FOLDER_SYSTEM)) {
e_alert_submit (
alert_sink, "mail:no-delete-special-folder",
- camel_folder_get_display_name (folder), NULL);
+ display_name, NULL);
return;
}
@@ -240,20 +242,20 @@ e_mail_reader_delete_folder (EMailReader *reader,
if (CAMEL_IS_VEE_STORE (parent_store))
dialog = e_alert_dialog_new_for_args (
parent, "mail:ask-delete-vfolder",
- full_name, NULL);
+ display_name, NULL);
else
dialog = e_alert_dialog_new_for_args (
parent, "mail:ask-delete-folder",
- full_name, NULL);
+ display_name, NULL);
} else {
if (CAMEL_IS_VEE_STORE (parent_store))
dialog = e_alert_dialog_new_for_args (
parent, "mail:ask-delete-vfolder-nochild",
- full_name, NULL);
+ display_name, NULL);
else
dialog = e_alert_dialog_new_for_args (
parent, "mail:ask-delete-folder-nochild",
- full_name, NULL);
+ display_name, NULL);
}
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
@@ -1097,6 +1099,7 @@ mail_reader_create_filter_cb (CamelFolder *folder,
AsyncContext *context)
{
EMailBackend *backend;
+ EMailSession *session;
EAlertSink *alert_sink;
CamelMimeMessage *message;
GError *error = NULL;
@@ -1130,9 +1133,10 @@ 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 (
- backend, message,
+ session, message,
context->filter_source,
context->filter_type);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 60289e82f9..12e3a8ac92 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -305,7 +305,7 @@ action_mail_copy_cb (GtkAction *action,
model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
- window, backend, model,
+ window, model,
EM_FOLDER_SELECTOR_CAN_CREATE,
_("Copy to Folder"), NULL, _("C_opy"));
@@ -820,7 +820,7 @@ action_mail_move_cb (GtkAction *action,
model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
- window, backend, model,
+ window, model,
EM_FOLDER_SELECTOR_CAN_CREATE,
_("Move to Folder"), NULL, _("_Move"));
diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c
index 24fd0be3ef..11bdf87b8d 100644
--- a/mail/e-mail-session.c
+++ b/mail/e-mail-session.c
@@ -345,8 +345,6 @@ 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;
@@ -355,17 +353,12 @@ main_get_filter_driver (CamelSession *session,
GSettings *settings;
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);
-
settings = g_settings_new ("org.gnome.evolution.mail");
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 (
- E_MAIL_BACKEND (shell_backend));
+ fc = (ERuleContext *) em_filter_context_new (ms);
e_rule_context_load (fc, system, user);
g_free (system);
g_free (user);
@@ -446,17 +439,10 @@ static guint preparing_flush = 0;
static gboolean
forward_to_flush_outbox_cb (EMailSession *session)
{
- EShell *shell;
- EShellBackend *shell_backend;
-
g_return_val_if_fail (preparing_flush != 0, FALSE);
- 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), FALSE);
-
preparing_flush = 0;
- mail_send (E_MAIL_BACKEND (shell_backend));
+ mail_send (session);
return FALSE;
}
diff --git a/mail/e-mail-sidebar.c b/mail/e-mail-sidebar.c
index 9a935819c8..b247adaf6a 100644
--- a/mail/e-mail-sidebar.c
+++ b/mail/e-mail-sidebar.c
@@ -464,12 +464,12 @@ e_mail_sidebar_init (EMailSidebar *sidebar)
}
GtkWidget *
-e_mail_sidebar_new (EMailBackend *backend,
+e_mail_sidebar_new (EMailSession *session,
EAlertSink *alert_sink)
{
EMFolderTreeModel *model;
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
g_return_val_if_fail (E_IS_ALERT_SINK (alert_sink), NULL);
model = em_folder_tree_model_get_default ();
@@ -477,7 +477,7 @@ e_mail_sidebar_new (EMailBackend *backend,
return g_object_new (
E_TYPE_MAIL_SIDEBAR,
"alert-sink", alert_sink,
- "backend", backend,
+ "session", session,
"model", model, NULL);
}
diff --git a/mail/e-mail-sidebar.h b/mail/e-mail-sidebar.h
index af4c87e15e..a88c3ccc15 100644
--- a/mail/e-mail-sidebar.h
+++ b/mail/e-mail-sidebar.h
@@ -22,6 +22,7 @@
#ifndef E_MAIL_SIDEBAR_H
#define E_MAIL_SIDEBAR_H
+#include <mail/e-mail-session.h>
#include <mail/em-folder-tree.h>
/* Standard GObject macros */
@@ -76,7 +77,7 @@ struct _EMailSidebarClass {
};
GType e_mail_sidebar_get_type (void);
-GtkWidget * e_mail_sidebar_new (EMailBackend *backend,
+GtkWidget * e_mail_sidebar_new (EMailSession *session,
EAlertSink *alert_sink);
GKeyFile * e_mail_sidebar_get_key_file (EMailSidebar *sidebar);
void e_mail_sidebar_set_key_file (EMailSidebar *sidebar,
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 4fe4a382b1..0f9754847a 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -1856,7 +1856,7 @@ emae_account_folder (EMAccountEditor *emae,
session = e_mail_backend_get_session (backend);
folder = (EMFolderSelectionButton *) e_builder_get_widget (builder, name);
- em_folder_selection_button_set_backend (folder, backend);
+ em_folder_selection_button_set_session (folder, session);
uri = e_account_get_string (account, item);
if (uri != NULL) {
@@ -3752,7 +3752,7 @@ update_real_folder_cb (GtkButton *folder_button,
if (folder_uri && *folder_uri) {
EMailSession *session;
- session = e_mail_backend_get_session (em_folder_selection_button_get_backend (sel_button));
+ session = em_folder_selection_button_get_session (sel_button);
if (!e_mail_folder_uri_parse (CAMEL_SESSION (session), folder_uri, NULL, &path, NULL))
path = NULL;
}
@@ -3831,7 +3831,7 @@ emae_defaults_page (EConfig *ec,
widget = e_builder_get_widget (builder, "trash_folder_butt");
button = EM_FOLDER_SELECTION_BUTTON (widget);
- em_folder_selection_button_set_backend (button, backend);
+ em_folder_selection_button_set_session (button, session);
em_folder_selection_button_set_store (button, store);
priv->trash_folder_button = GTK_BUTTON (button);
@@ -3889,7 +3889,7 @@ emae_defaults_page (EConfig *ec,
widget = e_builder_get_widget (builder, "junk_folder_butt");
button = EM_FOLDER_SELECTION_BUTTON (widget);
- em_folder_selection_button_set_backend (button, backend);
+ em_folder_selection_button_set_session (button, session);
em_folder_selection_button_set_store (button, store);
priv->junk_folder_button = GTK_BUTTON (button);
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index f6a938bdac..c304007f95 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -2738,8 +2738,6 @@ static void
post_header_clicked_cb (EComposerPostHeader *header,
EMailSession *session)
{
- EShell *shell;
- EShellBackend *shell_backend;
GtkTreeSelection *selection;
EMFolderSelector *selector;
EMFolderTreeModel *model;
@@ -2747,16 +2745,11 @@ post_header_clicked_cb (EComposerPostHeader *header,
GtkWidget *dialog;
GList *list;
- /* FIXME Figure out a way to pass the mail backend in. */
- shell = e_shell_get_default ();
- shell_backend = e_shell_get_backend_by_name (shell, "mail");
-
/* FIXME Limit the folder tree to the NNTP account? */
model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
/* FIXME GTK_WINDOW (composer) */ NULL,
- E_MAIL_BACKEND (shell_backend),
model, EM_FOLDER_SELECTOR_CAN_CREATE,
_("Posting destination"),
_("Choose folders to post the message to."),
diff --git a/mail/em-filter-context.c b/mail/em-filter-context.c
index 085c32dbd0..6a5822c7a1 100644
--- a/mail/em-filter-context.c
+++ b/mail/em-filter-context.c
@@ -41,13 +41,13 @@
((obj), EM_TYPE_FILTER_CONTEXT, EMFilterContextPrivate))
struct _EMFilterContextPrivate {
- EMailBackend *backend;
+ EMailSession *session;
GList *actions;
};
enum {
PROP_0,
- PROP_BACKEND
+ PROP_SESSION
};
G_DEFINE_TYPE (
@@ -56,13 +56,13 @@ G_DEFINE_TYPE (
E_TYPE_RULE_CONTEXT)
static void
-filter_context_set_backend (EMFilterContext *context,
- EMailBackend *backend)
+filter_context_set_session (EMFilterContext *context,
+ EMailSession *session)
{
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (context->priv->backend == NULL);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (context->priv->session == NULL);
- context->priv->backend = g_object_ref (backend);
+ context->priv->session = g_object_ref (session);
}
static void
@@ -72,8 +72,8 @@ filter_context_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- filter_context_set_backend (
+ case PROP_SESSION:
+ filter_context_set_session (
EM_FILTER_CONTEXT (object),
g_value_get_object (value));
return;
@@ -89,10 +89,10 @@ filter_context_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
+ case PROP_SESSION:
g_value_set_object (
value,
- em_filter_context_get_backend (
+ em_filter_context_get_session (
EM_FILTER_CONTEXT (object)));
return;
}
@@ -107,9 +107,9 @@ filter_context_dispose (GObject *object)
priv = EM_FILTER_CONTEXT_GET_PRIVATE (object);
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
g_list_foreach (priv->actions, (GFunc) g_object_unref, NULL);
@@ -236,7 +236,7 @@ filter_context_new_element (ERuleContext *context,
priv = EM_FILTER_CONTEXT_GET_PRIVATE (context);
if (strcmp (type, "folder") == 0)
- return em_filter_folder_element_new (priv->backend);
+ return em_filter_folder_element_new (priv->session);
if (strcmp (type, "system-flag") == 0)
return e_filter_option_new ();
@@ -245,7 +245,7 @@ filter_context_new_element (ERuleContext *context,
return e_filter_int_new_type ("score", -3, 3);
if (strcmp (type, "source") == 0)
- return em_filter_source_element_new (priv->backend);
+ return em_filter_source_element_new (priv->session);
return E_RULE_CONTEXT_CLASS (em_filter_context_parent_class)->
new_element (context, type);
@@ -271,12 +271,12 @@ em_filter_context_class_init (EMFilterContextClass *class)
g_object_class_install_property (
object_class,
- PROP_BACKEND,
+ PROP_SESSION,
g_param_spec_object (
- "backend",
+ "session",
NULL,
NULL,
- E_TYPE_MAIL_BACKEND,
+ E_TYPE_MAIL_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
@@ -306,20 +306,20 @@ em_filter_context_init (EMFilterContext *context)
}
EMFilterContext *
-em_filter_context_new (EMailBackend *backend)
+em_filter_context_new (EMailSession *session)
{
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
return g_object_new (
- EM_TYPE_FILTER_CONTEXT, "backend", backend, NULL);
+ EM_TYPE_FILTER_CONTEXT, "session", session, NULL);
}
-EMailBackend *
-em_filter_context_get_backend (EMFilterContext *context)
+EMailSession *
+em_filter_context_get_session (EMFilterContext *context)
{
g_return_val_if_fail (EM_IS_FILTER_CONTEXT (context), NULL);
- return context->priv->backend;
+ return context->priv->session;
}
void
diff --git a/mail/em-filter-context.h b/mail/em-filter-context.h
index d80809b8e4..3545bf16eb 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-backend.h>
+#include <mail/e-mail-session.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 (EMailBackend *backend);
-EMailBackend * em_filter_context_get_backend (EMFilterContext *context);
+ em_filter_context_new (EMailSession *session);
+EMailSession * em_filter_context_get_session (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 6098c9354d..b49dc8907a 100644
--- a/mail/em-filter-folder-element.c
+++ b/mail/em-filter-folder-element.c
@@ -43,13 +43,13 @@
((obj), EM_TYPE_FILTER_FOLDER_ELEMENT, EMFilterFolderElementPrivate))
struct _EMFilterFolderElementPrivate {
- EMailBackend *backend;
+ EMailSession *session;
gchar *uri;
};
enum {
PROP_0,
- PROP_BACKEND
+ PROP_SESSION
};
G_DEFINE_TYPE (
@@ -74,23 +74,26 @@ filter_folder_element_selected_cb (EMFolderSelectionButton *button,
}
static void
-filter_folder_element_set_backend (EMFilterFolderElement *element,
- EMailBackend *backend)
+filter_folder_element_set_session (EMFilterFolderElement *element,
+ EMailSession *session)
{
- /* FIXME Dirty hack. Backend should be passed in always. */
- if (backend == NULL) {
- EShellBackend *shell_backend;
+ /* FIXME Dirty hack. Session should be passed in always. */
+ if (session == 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_BACKEND (backend));
- g_return_if_fail (element->priv->backend == NULL);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (element->priv->session == NULL);
- element->priv->backend = g_object_ref (backend);
+ element->priv->session = g_object_ref (session);
}
static void
@@ -100,8 +103,8 @@ filter_folder_element_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- filter_folder_element_set_backend (
+ case PROP_SESSION:
+ filter_folder_element_set_session (
EM_FILTER_FOLDER_ELEMENT (object),
g_value_get_object (value));
return;
@@ -117,10 +120,10 @@ filter_folder_element_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
+ case PROP_SESSION:
g_value_set_object (
value,
- em_filter_folder_element_get_backend (
+ em_filter_folder_element_get_session (
EM_FILTER_FOLDER_ELEMENT (object)));
return;
}
@@ -135,9 +138,9 @@ filter_folder_element_dispose (GObject *object)
priv = EM_FILTER_FOLDER_ELEMENT_GET_PRIVATE (object);
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
/* Chain up to parent's dispose() method. */
@@ -231,13 +234,13 @@ static GtkWidget *
filter_folder_element_get_widget (EFilterElement *fe)
{
EMFilterFolderElement *ff = (EMFilterFolderElement *) fe;
- EMailBackend *backend;
+ EMailSession *session;
GtkWidget *button;
- backend = em_filter_folder_element_get_backend (ff);
+ session = em_filter_folder_element_get_session (ff);
button = em_folder_selection_button_new (
- backend, _("Select Folder"), NULL);
+ session, _("Select Folder"), NULL);
em_folder_selection_button_set_folder_uri (
EM_FOLDER_SELECTION_BUTTON (button), ff->priv->uri);
gtk_widget_show (button);
@@ -305,12 +308,12 @@ em_filter_folder_element_class_init (EMFilterFolderElementClass *class)
g_object_class_install_property (
object_class,
- PROP_BACKEND,
+ PROP_SESSION,
g_param_spec_object (
- "backend",
+ "session",
NULL,
NULL,
- E_TYPE_MAIL_BACKEND,
+ E_TYPE_MAIL_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
@@ -322,21 +325,21 @@ em_filter_folder_element_init (EMFilterFolderElement *element)
}
EFilterElement *
-em_filter_folder_element_new (EMailBackend *backend)
+em_filter_folder_element_new (EMailSession *session)
{
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
return g_object_new (
EM_TYPE_FILTER_FOLDER_ELEMENT,
- "backend", backend, NULL);
+ "session", session, NULL);
}
-EMailBackend *
-em_filter_folder_element_get_backend (EMFilterFolderElement *element)
+EMailSession *
+em_filter_folder_element_get_session (EMFilterFolderElement *element)
{
g_return_val_if_fail (EM_IS_FILTER_FOLDER_ELEMENT (element), NULL);
- return element->priv->backend;
+ return element->priv->session;
}
const gchar *
diff --git a/mail/em-filter-folder-element.h b/mail/em-filter-folder-element.h
index c188907ae7..f71b4c128b 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-backend.h>
+#include <mail/e-mail-session.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 (EMailBackend *backend);
-EMailBackend * em_filter_folder_element_get_backend
+EFilterElement *em_filter_folder_element_new (EMailSession *session);
+EMailSession * em_filter_folder_element_get_session
(EMFilterFolderElement *element);
const gchar * em_filter_folder_element_get_uri
(EMFilterFolderElement *element);
diff --git a/mail/em-filter-source-element.c b/mail/em-filter-source-element.c
index b6d518d6d6..a8e51e2827 100644
--- a/mail/em-filter-source-element.c
+++ b/mail/em-filter-source-element.c
@@ -47,7 +47,7 @@ typedef struct _SourceInfo {
} SourceInfo;
struct _EMFilterSourceElementPrivate {
- EMailBackend *backend;
+ EMailSession *session;
GList *sources;
gchar *active_id;
};
@@ -59,7 +59,7 @@ G_DEFINE_TYPE (
enum {
PROP_0,
- PROP_BACKEND
+ PROP_SESSION
};
static void
@@ -131,13 +131,13 @@ filter_source_element_get_sources (EMFilterSourceElement *fs)
}
static void
-filter_source_element_set_backend (EMFilterSourceElement *element,
- EMailBackend *backend)
+filter_source_element_set_session (EMFilterSourceElement *element,
+ EMailSession *session)
{
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (element->priv->backend == NULL);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (element->priv->session == NULL);
- element->priv->backend = g_object_ref (backend);
+ element->priv->session = g_object_ref (session);
}
static void
@@ -147,8 +147,8 @@ filter_source_element_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- filter_source_element_set_backend (
+ case PROP_SESSION:
+ filter_source_element_set_session (
EM_FILTER_SOURCE_ELEMENT (object),
g_value_get_object (value));
return;
@@ -164,10 +164,10 @@ filter_source_element_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
+ case PROP_SESSION:
g_value_set_object (
value,
- em_filter_source_element_get_backend (
+ em_filter_source_element_get_session (
EM_FILTER_SOURCE_ELEMENT (object)));
return;
}
@@ -182,9 +182,9 @@ filter_source_element_dispose (GObject *object)
priv = EM_FILTER_SOURCE_ELEMENT_GET_PRIVATE (object);
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
/* Chain up to parent's dispose() method. */
@@ -241,12 +241,10 @@ filter_source_element_xml_decode (EFilterElement *fe,
xmlNodePtr node)
{
EMFilterSourceElement *fs = (EMFilterSourceElement *) fe;
- EMailBackend *backend;
EMailSession *session;
gchar *active_id = NULL;
- backend = em_filter_source_element_get_backend (fs);
- session = e_mail_backend_get_session (backend);
+ session = em_filter_source_element_get_session (fs);
node = node->children;
while (node != NULL) {
@@ -306,11 +304,11 @@ filter_source_element_clone (EFilterElement *fe)
{
EMFilterSourceElement *fs = (EMFilterSourceElement *) fe;
EMFilterSourceElement *cpy;
- EMailBackend *backend;
+ EMailSession *session;
GList *i;
- backend = em_filter_source_element_get_backend (fs);
- cpy = (EMFilterSourceElement *) em_filter_source_element_new (backend);
+ session = em_filter_source_element_get_session (fs);
+ cpy = (EMFilterSourceElement *) em_filter_source_element_new (session);
((EFilterElement *) cpy)->name = (gchar *) xmlStrdup ((guchar *) fe->name);
cpy->priv->active_id = g_strdup (fs->priv->active_id);
@@ -428,12 +426,12 @@ em_filter_source_element_class_init (EMFilterSourceElementClass *class)
g_object_class_install_property (
object_class,
- PROP_BACKEND,
+ PROP_SESSION,
g_param_spec_object (
- "backend",
+ "session",
NULL,
NULL,
- E_TYPE_MAIL_BACKEND,
+ E_TYPE_MAIL_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
@@ -446,19 +444,19 @@ em_filter_source_element_init (EMFilterSourceElement *element)
}
EFilterElement *
-em_filter_source_element_new (EMailBackend *backend)
+em_filter_source_element_new (EMailSession *session)
{
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
return g_object_new (
EM_TYPE_FILTER_SOURCE_ELEMENT,
- "backend", backend, NULL);
+ "session", session, NULL);
}
-EMailBackend *
-em_filter_source_element_get_backend (EMFilterSourceElement *element)
+EMailSession *
+em_filter_source_element_get_session (EMFilterSourceElement *element)
{
g_return_val_if_fail (EM_IS_FILTER_SOURCE_ELEMENT (element), NULL);
- return element->priv->backend;
+ return element->priv->session;
}
diff --git a/mail/em-filter-source-element.h b/mail/em-filter-source-element.h
index 406cd68900..41c3f3f8fc 100644
--- a/mail/em-filter-source-element.h
+++ b/mail/em-filter-source-element.h
@@ -24,7 +24,7 @@
#ifndef EM_FILTER_SOURCE_ELEMENT_H
#define EM_FILTER_SOURCE_ELEMENT_H
-#include <mail/e-mail-backend.h>
+#include <mail/e-mail-session.h>
#include <filter/e-filter-element.h>
/* Standard GObject macros */
@@ -63,8 +63,8 @@ struct _EMFilterSourceElementClass {
GType em_filter_source_element_get_type
(void) G_GNUC_CONST;
-EFilterElement *em_filter_source_element_new (EMailBackend *backend);
-EMailBackend * em_filter_source_element_get_backend
+EFilterElement *em_filter_source_element_new (EMailSession *session);
+EMailSession * em_filter_source_element_get_session
(EMFilterSourceElement *element);
G_END_DECLS
diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c
index 9dbffba2e2..75ccf5304b 100644
--- a/mail/em-folder-properties.c
+++ b/mail/em-folder-properties.c
@@ -42,8 +42,8 @@ typedef struct _AsyncContext AsyncContext;
struct _AsyncContext {
EActivity *activity;
- EShellView *shell_view;
CamelFolder *folder;
+ GtkWindow *parent_window;
CamelFolderQuotaInfo *quota_info;
gint total;
gint unread;
@@ -55,12 +55,12 @@ async_context_free (AsyncContext *context)
if (context->activity != NULL)
g_object_unref (context->activity);
- if (context->shell_view != NULL)
- g_object_unref (context->shell_view);
-
if (context->folder != NULL)
g_object_unref (context->folder);
+ if (context->parent_window != NULL)
+ g_object_unref (context->parent_window);
+
if (context->quota_info != NULL)
camel_folder_quota_info_free (context->quota_info);
@@ -246,8 +246,6 @@ emfp_dialog_run (AsyncContext *context)
gint32 i,deleted;
EMConfig *ec;
EMConfigTargetFolder *target;
- EShellWindow *shell_window;
- EShellView *shell_view;
CamelStore *parent_store;
CamelFolderSummary *summary;
gboolean store_is_local;
@@ -256,9 +254,6 @@ emfp_dialog_run (AsyncContext *context)
const gchar *name;
const gchar *uid;
- shell_view = context->shell_view;
- shell_window = e_shell_view_get_shell_window (shell_view);
-
parent_store = camel_folder_get_parent_store (context->folder);
/* Get number of VISIBLE and DELETED messages, instead of TOTAL
@@ -315,7 +310,8 @@ emfp_dialog_run (AsyncContext *context)
emfp_items[EMFP_FOLDER_SECTION].label = (gchar *) name;
dialog = gtk_dialog_new_with_buttons (
- _("Folder Properties"), GTK_WINDOW (shell_window),
+ _("Folder Properties"),
+ context->parent_window,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);
gtk_window_set_default_size ((GtkWindow *) dialog, 192, 160);
@@ -447,35 +443,33 @@ emfp_dialog_got_folder (CamelStore *store,
/**
* em_folder_properties_show:
- * @shell_view: an #EShellView
* @store: a #CamelStore
* @folder_name: a folder name
+ * @alert_sink: an #EAlertSink
+ * @parent_window: a parent #GtkWindow
*
* Show folder properties for @folder_name.
**/
void
-em_folder_properties_show (EShellView *shell_view,
- CamelStore *store,
- const gchar *folder_name)
+em_folder_properties_show (CamelStore *store,
+ const gchar *folder_name,
+ EAlertSink *alert_sink,
+ GtkWindow *parent_window)
{
- EShellBackend *shell_backend;
- EShellContent *shell_content;
- EMailBackend *backend;
- EAlertSink *alert_sink;
+ CamelService *service;
+ CamelSession *session;
GCancellable *cancellable;
AsyncContext *context;
const gchar *uid;
- g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
g_return_if_fail (CAMEL_IS_STORE (store));
g_return_if_fail (folder_name != NULL);
+ g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
+ g_return_if_fail (GTK_IS_WINDOW (parent_window));
- shell_backend = e_shell_view_get_shell_backend (shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
-
- backend = E_MAIL_BACKEND (shell_backend);
-
- uid = camel_service_get_uid (CAMEL_SERVICE (store));
+ service = CAMEL_SERVICE (store);
+ uid = camel_service_get_uid (service);
+ session = camel_service_get_session (service);
/* Show the Edit Rule dialog for Search Folders, but not "Unmatched".
* "Unmatched" is a special Search Folder which can't be modified. */
@@ -485,7 +479,9 @@ em_folder_properties_show (EShellView *shell_view,
folder_uri = e_mail_folder_uri_build (
store, folder_name);
- vfolder_edit_rule (backend, folder_uri);
+ vfolder_edit_rule (
+ E_MAIL_SESSION (session),
+ folder_uri, alert_sink);
g_free (folder_uri);
return;
}
@@ -495,15 +491,15 @@ em_folder_properties_show (EShellView *shell_view,
context = g_slice_new0 (AsyncContext);
context->activity = e_activity_new ();
- context->shell_view = g_object_ref (shell_view);
+ context->parent_window = g_object_ref (parent_window);
- alert_sink = E_ALERT_SINK (shell_content);
e_activity_set_alert_sink (context->activity, alert_sink);
cancellable = camel_operation_new ();
e_activity_set_cancellable (context->activity, cancellable);
- e_shell_backend_add_activity (shell_backend, context->activity);
+ e_mail_session_add_activity (
+ E_MAIL_SESSION (session), context->activity);
camel_store_get_folder (
store, folder_name, 0, G_PRIORITY_DEFAULT, cancellable,
diff --git a/mail/em-folder-properties.h b/mail/em-folder-properties.h
index fbb8dadac9..704e43b6d3 100644
--- a/mail/em-folder-properties.h
+++ b/mail/em-folder-properties.h
@@ -25,13 +25,14 @@
#define __EM_FOLDER_PROPERTIES_H__
#include <camel/camel.h>
-#include <shell/e-shell-view.h>
+#include <mail/e-mail-session.h>
G_BEGIN_DECLS
-void em_folder_properties_show (EShellView *shell_view,
- CamelStore *store,
- const gchar *folder_name);
+void em_folder_properties_show (CamelStore *store,
+ const gchar *folder_name,
+ EAlertSink *alert_sink,
+ GtkWindow *parent_window);
G_END_DECLS
diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c
index 1532e42364..6e40234444 100644
--- a/mail/em-folder-selection-button.c
+++ b/mail/em-folder-selection-button.c
@@ -40,7 +40,7 @@
((obj), EM_TYPE_FOLDER_SELECTION_BUTTON, EMFolderSelectionButtonPrivate))
struct _EMFolderSelectionButtonPrivate {
- EMailBackend *backend;
+ EMailSession *session;
GtkWidget *icon;
GtkWidget *label;
CamelStore *store;
@@ -52,9 +52,9 @@ struct _EMFolderSelectionButtonPrivate {
enum {
PROP_0,
- PROP_BACKEND,
PROP_CAPTION,
PROP_FOLDER_URI,
+ PROP_SESSION,
PROP_STORE,
PROP_TITLE
};
@@ -84,7 +84,7 @@ folder_selection_button_unselected (EMFolderSelectionButton *button)
static void
folder_selection_button_set_contents (EMFolderSelectionButton *button)
{
- EMailBackend *backend;
+ EMailSession *session;
CamelStore *store = NULL;
CamelService *service;
GtkLabel *label;
@@ -92,17 +92,13 @@ folder_selection_button_set_contents (EMFolderSelectionButton *button)
gchar *folder_name = NULL;
label = GTK_LABEL (button->priv->label);
- backend = em_folder_selection_button_get_backend (button);
-
- if (backend != NULL && button->priv->folder_uri != NULL) {
- EMailSession *session;
+ session = em_folder_selection_button_get_session (button);
- session = e_mail_backend_get_session (backend);
+ if (session != NULL && button->priv->folder_uri != NULL)
e_mail_folder_uri_parse (
CAMEL_SESSION (session),
button->priv->folder_uri,
&store, &folder_name, NULL);
- }
if (store == NULL || folder_name == NULL) {
folder_selection_button_unselected (button);
@@ -133,12 +129,6 @@ folder_selection_button_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- em_folder_selection_button_set_backend (
- EM_FOLDER_SELECTION_BUTTON (object),
- g_value_get_object (value));
- return;
-
case PROP_CAPTION:
em_folder_selection_button_set_caption (
EM_FOLDER_SELECTION_BUTTON (object),
@@ -151,6 +141,12 @@ folder_selection_button_set_property (GObject *object,
g_value_get_string (value));
return;
+ case PROP_SESSION:
+ em_folder_selection_button_set_session (
+ EM_FOLDER_SELECTION_BUTTON (object),
+ g_value_get_object (value));
+ return;
+
case PROP_STORE:
em_folder_selection_button_set_store (
EM_FOLDER_SELECTION_BUTTON (object),
@@ -174,13 +170,6 @@ folder_selection_button_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- g_value_set_object (
- value,
- em_folder_selection_button_get_backend (
- EM_FOLDER_SELECTION_BUTTON (object)));
- return;
-
case PROP_CAPTION:
g_value_set_string (
value,
@@ -195,6 +184,13 @@ folder_selection_button_get_property (GObject *object,
EM_FOLDER_SELECTION_BUTTON (object)));
return;
+ case PROP_SESSION:
+ g_value_set_object (
+ value,
+ em_folder_selection_button_get_session (
+ EM_FOLDER_SELECTION_BUTTON (object)));
+ return;
+
case PROP_STORE:
g_value_set_object (
value,
@@ -220,9 +216,9 @@ folder_selection_button_dispose (GObject *object)
priv = EM_FOLDER_SELECTION_BUTTON_GET_PRIVATE (object);
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
if (priv->store != NULL) {
@@ -258,7 +254,6 @@ folder_selection_button_clicked (GtkButton *button)
EMFolderSelector *selector;
EMFolderTree *folder_tree;
EMFolderTreeModel *model = NULL;
- EMailSession *session;
GtkWidget *dialog;
GtkTreeSelection *selection;
gpointer parent;
@@ -268,11 +263,9 @@ folder_selection_button_clicked (GtkButton *button)
parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
- session = e_mail_backend_get_session (priv->backend);
-
if (priv->store != NULL) {
model = em_folder_tree_model_new ();
- em_folder_tree_model_set_session (model, session);
+ em_folder_tree_model_set_session (model, priv->session);
em_folder_tree_model_add_store (model, priv->store);
}
@@ -280,7 +273,7 @@ folder_selection_button_clicked (GtkButton *button)
model = g_object_ref (em_folder_tree_model_get_default ());
dialog = em_folder_selector_new (
- parent, priv->backend, model,
+ parent, model,
EM_FOLDER_SELECTOR_CAN_CREATE,
priv->title, priv->caption, NULL);
@@ -332,20 +325,20 @@ em_folder_selection_button_class_init (EMFolderSelectionButtonClass *class)
g_object_class_install_property (
object_class,
- PROP_BACKEND,
- g_param_spec_object (
- "backend",
+ PROP_CAPTION,
+ g_param_spec_string (
+ "caption",
+ NULL,
NULL,
NULL,
- E_TYPE_MAIL_BACKEND,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (
object_class,
- PROP_CAPTION,
+ PROP_FOLDER_URI,
g_param_spec_string (
- "caption",
+ "folder-uri",
NULL,
NULL,
NULL,
@@ -354,12 +347,12 @@ em_folder_selection_button_class_init (EMFolderSelectionButtonClass *class)
g_object_class_install_property (
object_class,
- PROP_FOLDER_URI,
- g_param_spec_string (
- "folder-uri",
- NULL,
+ PROP_SESSION,
+ g_param_spec_object (
+ "session",
NULL,
NULL,
+ E_TYPE_MAIL_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
@@ -417,43 +410,43 @@ em_folder_selection_button_init (EMFolderSelectionButton *emfsb)
}
GtkWidget *
-em_folder_selection_button_new (EMailBackend *backend,
+em_folder_selection_button_new (EMailSession *session,
const gchar *title,
const gchar *caption)
{
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
return g_object_new (
EM_TYPE_FOLDER_SELECTION_BUTTON,
- "backend", backend, "title", title,
+ "session", session, "title", title,
"caption", caption, NULL);
}
-EMailBackend *
-em_folder_selection_button_get_backend (EMFolderSelectionButton *button)
+EMailSession *
+em_folder_selection_button_get_session (EMFolderSelectionButton *button)
{
g_return_val_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button), NULL);
- return button->priv->backend;
+ return button->priv->session;
}
void
-em_folder_selection_button_set_backend (EMFolderSelectionButton *button,
- EMailBackend *backend)
+em_folder_selection_button_set_session (EMFolderSelectionButton *button,
+ EMailSession *session)
{
g_return_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button));
- if (backend != NULL) {
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_object_ref (backend);
+ if (session != NULL) {
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_object_ref (session);
}
- if (button->priv->backend != NULL)
- g_object_unref (button->priv->backend);
+ if (button->priv->session != NULL)
+ g_object_unref (button->priv->session);
- button->priv->backend = backend;
+ button->priv->session = session;
- g_object_notify (G_OBJECT (button), "backend");
+ g_object_notify (G_OBJECT (button), "session");
}
const gchar *
diff --git a/mail/em-folder-selection-button.h b/mail/em-folder-selection-button.h
index 125e96ebce..6e646e3af0 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-backend.h>
+#include <mail/e-mail-session.h>
/* Standard GObject macros */
#define EM_TYPE_FOLDER_SELECTION_BUTTON \
@@ -67,14 +67,14 @@ struct _EMFolderSelectionButtonClass {
GType em_folder_selection_button_get_type (void);
GtkWidget * em_folder_selection_button_new
- (EMailBackend *backend,
+ (EMailSession *session,
const gchar *title,
const gchar *caption);
-EMailBackend * em_folder_selection_button_get_backend
+EMailSession * em_folder_selection_button_get_session
(EMFolderSelectionButton *button);
-void em_folder_selection_button_set_backend
+void em_folder_selection_button_set_session
(EMFolderSelectionButton *button,
- EMailBackend *backend);
+ EMailSession *session);
const gchar * em_folder_selection_button_get_caption
(EMFolderSelectionButton *button);
void em_folder_selection_button_set_caption
diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c
index 94f83c2b0e..2f5b58274f 100644
--- a/mail/em-folder-selector.c
+++ b/mail/em-folder-selector.c
@@ -42,14 +42,12 @@
((obj), EM_TYPE_FOLDER_SELECTOR, EMFolderSelectorPrivate))
struct _EMFolderSelectorPrivate {
- EMailBackend *backend;
EMFolderTree *folder_tree; /* not referenced */
EMFolderTreeModel *model;
};
enum {
PROP_0,
- PROP_BACKEND,
PROP_MODEL
};
@@ -63,16 +61,6 @@ G_DEFINE_TYPE_WITH_CODE (
G_IMPLEMENT_INTERFACE (E_TYPE_ALERT_SINK, NULL))
static void
-folder_selector_set_backend (EMFolderSelector *emfs,
- EMailBackend *backend)
-{
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (emfs->priv->backend == NULL);
-
- emfs->priv->backend = g_object_ref (backend);
-}
-
-static void
folder_selector_set_model (EMFolderSelector *emfs,
EMFolderTreeModel *model)
{
@@ -89,12 +77,6 @@ folder_selector_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- folder_selector_set_backend (
- EM_FOLDER_SELECTOR (object),
- g_value_get_object (value));
- return;
-
case PROP_MODEL:
folder_selector_set_model (
EM_FOLDER_SELECTOR (object),
@@ -112,13 +94,6 @@ folder_selector_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- g_value_set_object (
- value,
- em_folder_selector_get_backend (
- EM_FOLDER_SELECTOR (object)));
- return;
-
case PROP_MODEL:
g_value_set_object (
value,
@@ -141,11 +116,6 @@ folder_selector_dispose (GObject *object)
emfs->created_id = 0;
}
- if (emfs->priv->backend != NULL) {
- g_object_unref (emfs->priv->backend);
- emfs->priv->backend = NULL;
- }
-
if (emfs->priv->model != NULL) {
g_object_unref (emfs->priv->model);
emfs->priv->model = NULL;
@@ -182,18 +152,6 @@ em_folder_selector_class_init (EMFolderSelectorClass *class)
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 |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
PROP_MODEL,
g_param_spec_object (
"model",
@@ -217,7 +175,7 @@ emfs_response (GtkWidget *dialog,
EMFolderSelector *emfs)
{
EMFolderTree *folder_tree;
- EMailBackend *backend;
+ EMailSession *session;
if (response != EM_FOLDER_SELECTOR_RESPONSE_NEW)
return;
@@ -227,10 +185,10 @@ emfs_response (GtkWidget *dialog,
g_object_set_data (
G_OBJECT (folder_tree), "select", GUINT_TO_POINTER (1));
- backend = em_folder_tree_get_backend (folder_tree);
+ session = em_folder_tree_get_session (folder_tree);
em_folder_utils_create_folder (
- GTK_WINDOW (dialog), backend, folder_tree, NULL);
+ GTK_WINDOW (dialog), session, folder_tree, NULL);
g_signal_stop_emission_by_name (emfs, "response");
}
@@ -287,14 +245,14 @@ folder_selector_construct (EMFolderSelector *emfs,
const gchar *text,
const gchar *oklabel)
{
- EMailBackend *backend;
+ EMailSession *session;
EMFolderTreeModel *model;
GtkWidget *content_area;
GtkWidget *container;
GtkWidget *widget;
- backend = em_folder_selector_get_backend (emfs);
model = em_folder_selector_get_model (emfs);
+ session = em_folder_tree_model_get_session (model);
gtk_window_set_default_size (GTK_WINDOW (emfs), 350, 300);
gtk_window_set_title (GTK_WINDOW (emfs), title);
@@ -338,7 +296,7 @@ folder_selector_construct (EMFolderSelector *emfs,
container = widget;
widget = em_folder_tree_new_with_model (
- backend, E_ALERT_SINK (emfs), model);
+ session, E_ALERT_SINK (emfs), model);
emu_restore_folder_tree_state (EM_FOLDER_TREE (widget));
gtk_container_add (GTK_CONTAINER (container), widget);
emfs->priv->folder_tree = EM_FOLDER_TREE (widget);
@@ -366,7 +324,6 @@ folder_selector_construct (EMFolderSelector *emfs,
GtkWidget *
em_folder_selector_new (GtkWindow *parent,
- EMailBackend *backend,
EMFolderTreeModel *model,
guint32 flags,
const gchar *title,
@@ -375,13 +332,11 @@ em_folder_selector_new (GtkWindow *parent,
{
EMFolderSelector *emfs;
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
g_return_val_if_fail (EM_IS_FOLDER_TREE_MODEL (model), NULL);
emfs = g_object_new (
EM_TYPE_FOLDER_SELECTOR,
"transient-for", parent,
- "backend", backend,
"model", model, NULL);
folder_selector_construct (emfs, flags, title, text, oklabel);
@@ -410,7 +365,6 @@ emfs_create_name_activate (GtkEntry *entry,
GtkWidget *
em_folder_selector_create_new (GtkWindow *parent,
- EMailBackend *backend,
EMFolderTreeModel *model,
guint32 flags,
const gchar *title,
@@ -421,7 +375,6 @@ em_folder_selector_create_new (GtkWindow *parent,
GtkWidget *hbox, *w;
GtkWidget *container;
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
g_return_val_if_fail (EM_IS_FOLDER_TREE_MODEL (model), NULL);
/* remove the CREATE flag if it is there since that's the
@@ -431,7 +384,6 @@ em_folder_selector_create_new (GtkWindow *parent,
emfs = g_object_new (
EM_TYPE_FOLDER_SELECTOR,
"transient-for", parent,
- "backend", backend,
"model", model, NULL);
folder_selector_construct (emfs, flags, title, text, _("C_reate"));
@@ -463,14 +415,6 @@ em_folder_selector_create_new (GtkWindow *parent,
return (GtkWidget *) emfs;
}
-EMailBackend *
-em_folder_selector_get_backend (EMFolderSelector *emfs)
-{
- g_return_val_if_fail (EM_IS_FOLDER_SELECTOR (emfs), NULL);
-
- return emfs->priv->backend;
-}
-
EMFolderTreeModel *
em_folder_selector_get_model (EMFolderSelector *emfs)
{
diff --git a/mail/em-folder-selector.h b/mail/em-folder-selector.h
index dd26adf2e8..b9fed2409c 100644
--- a/mail/em-folder-selector.h
+++ b/mail/em-folder-selector.h
@@ -79,19 +79,16 @@ enum {
GType em_folder_selector_get_type (void);
GtkWidget * em_folder_selector_new (GtkWindow *parent,
- EMailBackend *backend,
EMFolderTreeModel *model,
guint32 flags,
const gchar *title,
const gchar *text,
const gchar *oklabel);
GtkWidget * em_folder_selector_create_new (GtkWindow *parent,
- EMailBackend *backend,
EMFolderTreeModel *model,
guint32 flags,
const gchar *title,
const gchar *text);
-EMailBackend * em_folder_selector_get_backend (EMFolderSelector *emfs);
EMFolderTreeModel *
em_folder_selector_get_model (EMFolderSelector *emfs);
EMFolderTree * em_folder_selector_get_folder_tree
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 5ef1845304..a1e4142cf6 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -80,7 +80,7 @@ struct _selected_uri {
};
struct _EMFolderTreePrivate {
- EMailBackend *backend;
+ EMailSession *session;
EAlertSink *alert_sink;
/* selected_uri structures of each path pending selection. */
@@ -131,11 +131,11 @@ struct _AsyncContext {
enum {
PROP_0,
PROP_ALERT_SINK,
- PROP_BACKEND,
PROP_COPY_TARGET_LIST,
PROP_ELLIPSIZE,
PROP_MODEL,
- PROP_PASTE_TARGET_LIST
+ PROP_PASTE_TARGET_LIST,
+ PROP_SESSION
};
enum {
@@ -491,7 +491,6 @@ folder_tree_expand_node (const gchar *key,
GtkTreeView *tree_view;
GtkTreeModel *model;
GtkTreePath *path;
- EMailBackend *backend;
EMailSession *session;
CamelService *service;
const gchar *p;
@@ -511,8 +510,7 @@ folder_tree_expand_node (const gchar *key,
tree_view = GTK_TREE_VIEW (folder_tree);
model = gtk_tree_view_get_model (tree_view);
- backend = em_folder_tree_get_backend (folder_tree);
- session = e_mail_backend_get_session (backend);
+ session = em_folder_tree_get_session (folder_tree);
service = camel_session_get_service (CAMEL_SESSION (session), uid);
@@ -971,13 +969,13 @@ folder_tree_set_alert_sink (EMFolderTree *folder_tree,
}
static void
-folder_tree_set_backend (EMFolderTree *folder_tree,
- EMailBackend *backend)
+folder_tree_set_session (EMFolderTree *folder_tree,
+ EMailSession *session)
{
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (folder_tree->priv->backend == NULL);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (folder_tree->priv->session == NULL);
- folder_tree->priv->backend = g_object_ref (backend);
+ folder_tree->priv->session = g_object_ref (session);
}
static GtkTargetList *
@@ -1023,12 +1021,6 @@ folder_tree_set_property (GObject *object,
g_value_get_object (value));
return;
- case PROP_BACKEND:
- folder_tree_set_backend (
- EM_FOLDER_TREE (object),
- g_value_get_object (value));
- return;
-
case PROP_ELLIPSIZE:
em_folder_tree_set_ellipsize (
EM_FOLDER_TREE (object),
@@ -1040,6 +1032,12 @@ folder_tree_set_property (GObject *object,
GTK_TREE_VIEW (object),
g_value_get_object (value));
return;
+
+ case PROP_SESSION:
+ folder_tree_set_session (
+ EM_FOLDER_TREE (object),
+ g_value_get_object (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1059,13 +1057,6 @@ folder_tree_get_property (GObject *object,
EM_FOLDER_TREE (object)));
return;
- 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,
@@ -1093,6 +1084,13 @@ 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);
@@ -1130,9 +1128,9 @@ folder_tree_dispose (GObject *object)
priv->alert_sink = NULL;
}
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
if (priv->text_renderer != NULL) {
@@ -1492,18 +1490,6 @@ em_folder_tree_class_init (EMFolderTreeClass *class)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
- 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 |
- G_PARAM_STATIC_STRINGS));
-
/* Inherited from ESelectableInterface */
g_object_class_override_property (
object_class,
@@ -1541,6 +1527,18 @@ em_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 |
+ G_PARAM_STATIC_STRINGS));
+
signals[FOLDER_SELECTED] = g_signal_new (
"folder-selected",
G_OBJECT_CLASS_TYPE (object_class),
@@ -1775,32 +1773,32 @@ em_folder_tree_selectable_init (ESelectableInterface *interface)
}
GtkWidget *
-em_folder_tree_new (EMailBackend *backend,
+em_folder_tree_new (EMailSession *session,
EAlertSink *alert_sink)
{
EMFolderTreeModel *model;
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
g_return_val_if_fail (E_IS_ALERT_SINK (alert_sink), NULL);
model = em_folder_tree_model_get_default ();
- return em_folder_tree_new_with_model (backend, alert_sink, model);
+ return em_folder_tree_new_with_model (session, alert_sink, model);
}
GtkWidget *
-em_folder_tree_new_with_model (EMailBackend *backend,
+em_folder_tree_new_with_model (EMailSession *session,
EAlertSink *alert_sink,
EMFolderTreeModel *model)
{
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
g_return_val_if_fail (E_IS_ALERT_SINK (alert_sink), NULL);
g_return_val_if_fail (EM_IS_FOLDER_TREE_MODEL (model), NULL);
return g_object_new (
EM_TYPE_FOLDER_TREE,
"alert-sink", alert_sink,
- "backend", backend,
+ "session", session,
"model", model, NULL);
}
@@ -1808,7 +1806,7 @@ EActivity *
em_folder_tree_new_activity (EMFolderTree *folder_tree)
{
EActivity *activity;
- EMailBackend *backend;
+ EMailSession *session;
EAlertSink *alert_sink;
GCancellable *cancellable;
@@ -1823,8 +1821,8 @@ em_folder_tree_new_activity (EMFolderTree *folder_tree)
e_activity_set_cancellable (activity, cancellable);
g_object_unref (cancellable);
- backend = em_folder_tree_get_backend (folder_tree);
- e_shell_backend_add_activity (E_SHELL_BACKEND (backend), activity);
+ session = em_folder_tree_get_session (folder_tree);
+ e_mail_session_add_activity (session, activity);
return activity;
}
@@ -1859,12 +1857,12 @@ em_folder_tree_get_alert_sink (EMFolderTree *folder_tree)
return folder_tree->priv->alert_sink;
}
-EMailBackend *
-em_folder_tree_get_backend (EMFolderTree *folder_tree)
+EMailSession *
+em_folder_tree_get_session (EMFolderTree *folder_tree)
{
g_return_val_if_fail (EM_IS_FOLDER_TREE (folder_tree), NULL);
- return folder_tree->priv->backend;
+ return folder_tree->priv->session;
}
static void
@@ -2199,7 +2197,6 @@ 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;
@@ -2210,8 +2207,7 @@ tree_drag_data_received (GtkWidget *widget,
tree_view = GTK_TREE_VIEW (folder_tree);
model = gtk_tree_view_get_model (tree_view);
- backend = em_folder_tree_get_backend (folder_tree);
- session = e_mail_backend_get_session (backend);
+ session = em_folder_tree_get_session (folder_tree);
if (!gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &dest_path, &pos))
return;
@@ -2890,11 +2886,9 @@ em_folder_tree_set_selected_list (EMFolderTree *folder_tree,
gboolean expand_only)
{
EMFolderTreePrivate *priv = folder_tree->priv;
- EMailBackend *backend;
EMailSession *session;
- backend = em_folder_tree_get_backend (folder_tree);
- session = e_mail_backend_get_session (backend);
+ session = em_folder_tree_get_session (folder_tree);
/* 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 e136d680ad..6a60f2bc31 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -26,7 +26,7 @@
#include <gtk/gtk.h>
#include <e-util/e-alert-sink.h>
-#include <mail/e-mail-backend.h>
+#include <mail/e-mail-session.h>
#include <mail/em-folder-tree-model.h>
/* Standard GObject macros */
@@ -90,9 +90,9 @@ struct _EMFolderTreeClass {
};
GType em_folder_tree_get_type (void);
-GtkWidget * em_folder_tree_new (EMailBackend *backend,
+GtkWidget * em_folder_tree_new (EMailSession *session,
EAlertSink *alert_sink);
-GtkWidget * em_folder_tree_new_with_model (EMailBackend *backend,
+GtkWidget * em_folder_tree_new_with_model (EMailSession *session,
EAlertSink *alert_sink,
EMFolderTreeModel *model);
EActivity * em_folder_tree_new_activity (EMFolderTree *folder_tree);
@@ -101,7 +101,7 @@ PangoEllipsizeMode
void em_folder_tree_set_ellipsize (EMFolderTree *folder_tree,
PangoEllipsizeMode ellipsize);
EAlertSink * em_folder_tree_get_alert_sink (EMFolderTree *folder_tree);
-EMailBackend * em_folder_tree_get_backend (EMFolderTree *folder_tree);
+EMailSession * em_folder_tree_get_session (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 2ac87d7efd..2ee275d098 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -330,11 +330,11 @@ struct _copy_folder_data {
};
static void
-emfu_copy_folder_selected (EMailBackend *backend,
+emfu_copy_folder_selected (EMailSession *session,
+ EAlertSink *alert_sink,
const gchar *uri,
gpointer data)
{
- EMailSession *session;
struct _copy_folder_data *cfd = data;
CamelStore *tostore = NULL;
CamelService *service;
@@ -346,16 +346,14 @@ emfu_copy_folder_selected (EMailBackend *backend,
if (uri == NULL)
goto fail;
- session = e_mail_backend_get_session (backend);
-
service = CAMEL_SERVICE (cfd->source_store);
em_utils_connect_service_sync (service, NULL, &local_error);
if (local_error != NULL) {
- e_mail_backend_submit_alert (
- backend, cfd->delete ?
- "mail:no-move-folder-notexist" :
- "mail:no-copy-folder-notexist",
+ e_alert_submit (
+ alert_sink, cfd->delete ?
+ "mail:no-move-folder-notexist" :
+ "mail:no-copy-folder-notexist",
cfd->source_folder_name, uri,
local_error->message, NULL);
goto fail;
@@ -368,8 +366,9 @@ emfu_copy_folder_selected (EMailBackend *backend,
if (cfd->delete && store_is_local &&
emfu_is_special_local_folder (cfd->source_folder_name)) {
- e_mail_backend_submit_alert (
- backend, "mail:no-rename-special-folder",
+ e_alert_submit (
+ alert_sink,
+ "mail:no-rename-special-folder",
cfd->source_folder_name, NULL);
goto fail;
}
@@ -384,10 +383,10 @@ emfu_copy_folder_selected (EMailBackend *backend,
CAMEL_SERVICE (tostore), NULL, &local_error);
if (local_error != NULL) {
- e_mail_backend_submit_alert (
- backend, cfd->delete ?
- "mail:no-move-folder-to-notexist" :
- "mail:no-copy-folder-to-notexist",
+ e_alert_submit (
+ alert_sink, cfd->delete ?
+ "mail:no-move-folder-to-notexist" :
+ "mail:no-copy-folder-to-notexist",
cfd->source_folder_name, uri,
local_error->message, NULL);
goto fail;
@@ -452,7 +451,8 @@ emfu_copy_folder_exclude (EMFolderTree *tree,
void
em_folder_utils_copy_folder (GtkWindow *parent,
- EMailBackend *backend,
+ EMailSession *session,
+ EAlertSink *alert_sink,
const gchar *folder_uri,
gint delete)
{
@@ -460,17 +460,15 @@ em_folder_utils_copy_folder (GtkWindow *parent,
EMFolderSelector *selector;
EMFolderTree *folder_tree;
EMFolderTreeModel *model;
- EMailSession *session;
const gchar *label;
const gchar *title;
struct _copy_folder_data *cfd;
GError *error = NULL;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
g_return_if_fail (folder_uri != NULL);
- session = e_mail_backend_get_session (backend);
-
cfd = g_malloc (sizeof (*cfd));
cfd->delete = delete;
@@ -491,7 +489,7 @@ em_folder_utils_copy_folder (GtkWindow *parent,
model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
- parent, backend, model,
+ parent, model,
EM_FOLDER_SELECTOR_CAN_CREATE,
title, NULL, label);
@@ -505,7 +503,7 @@ em_folder_utils_copy_folder (GtkWindow *parent,
const gchar *uri;
uri = em_folder_selector_get_selected_uri (selector);
- emfu_copy_folder_selected (backend, uri, cfd);
+ emfu_copy_folder_selected (session, alert_sink, uri, cfd);
}
gtk_widget_destroy (dialog);
@@ -544,13 +542,12 @@ new_folder_created_cb (CamelStore *store,
void
em_folder_utils_create_folder (GtkWindow *parent,
- EMailBackend *backend,
+ EMailSession *session,
EMFolderTree *emft,
const gchar *initial_uri)
{
EShell *shell;
EShellSettings *shell_settings;
- EMailSession *session;
EMFolderSelector *selector;
EMFolderTree *folder_tree;
EMFolderTreeModel *model;
@@ -561,13 +558,12 @@ em_folder_utils_create_folder (GtkWindow *parent,
GError *error = NULL;
g_return_if_fail (GTK_IS_WINDOW (parent));
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
- shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+ shell = e_shell_get_default ();
shell_settings = e_shell_get_shell_settings (shell);
model = em_folder_tree_model_new ();
- session = e_mail_backend_get_session (backend);
em_folder_tree_model_set_session (model, session);
list = camel_session_list_services (CAMEL_SESSION (session));
@@ -602,7 +598,7 @@ em_folder_utils_create_folder (GtkWindow *parent,
g_list_free (list);
dialog = em_folder_selector_create_new (
- parent, backend, model, 0,
+ parent, model, 0,
_("Create Folder"),
_("Specify where to create the folder:"));
@@ -660,7 +656,7 @@ em_folder_utils_create_folder (GtkWindow *parent,
else
skip_slash = folder_name;
- rule = em_vfolder_rule_new (backend);
+ rule = em_vfolder_rule_new (session);
e_filter_rule_set_name (rule, skip_slash);
vfolder_gui_add_rule (EM_VFOLDER_RULE (rule));
} else {
diff --git a/mail/em-folder-utils.h b/mail/em-folder-utils.h
index e76c5df66f..9211cacd90 100644
--- a/mail/em-folder-utils.h
+++ b/mail/em-folder-utils.h
@@ -26,7 +26,7 @@
#include <gtk/gtk.h>
#include <camel/camel.h>
-#include <mail/e-mail-backend.h>
+#include <mail/e-mail-session.h>
#include <mail/em-folder-tree.h>
G_BEGIN_DECLS
@@ -41,11 +41,12 @@ gint em_folder_utils_copy_folders (CamelStore *fromstore,
* most rely on the wrong data. */
void em_folder_utils_copy_folder (GtkWindow *parent,
- EMailBackend *backend,
+ EMailSession *session,
+ EAlertSink *alert_sink,
const gchar *folder_uri,
gboolean delete);
void em_folder_utils_create_folder (GtkWindow *parent,
- EMailBackend *backend,
+ EMailSession *session,
EMFolderTree *emft,
const gchar *initial_uri);
diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c
index 76edaa5e5f..15f7a3be32 100644
--- a/mail/em-subscription-editor.c
+++ b/mail/em-subscription-editor.c
@@ -51,7 +51,7 @@ typedef struct _TreeRowData TreeRowData;
typedef struct _StoreData StoreData;
struct _EMSubscriptionEditorPrivate {
- EMailBackend *backend;
+ EMailSession *session;
CamelStore *initial_store;
GtkWidget *combo_box; /* not referenced */
@@ -101,7 +101,7 @@ struct _StoreData {
enum {
PROP_0,
- PROP_BACKEND,
+ PROP_SESSION,
PROP_STORE
};
@@ -1428,13 +1428,13 @@ subscription_editor_set_store (EMSubscriptionEditor *editor,
}
static void
-subscription_editor_set_backend (EMSubscriptionEditor *editor,
- EMailBackend *backend)
+subscription_editor_set_session (EMSubscriptionEditor *editor,
+ EMailSession *session)
{
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (editor->priv->backend == NULL);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (editor->priv->session == NULL);
- editor->priv->backend = g_object_ref (backend);
+ editor->priv->session = g_object_ref (session);
}
static void
@@ -1444,8 +1444,8 @@ subscription_editor_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- subscription_editor_set_backend (
+ case PROP_SESSION:
+ subscription_editor_set_session (
EM_SUBSCRIPTION_EDITOR (object),
g_value_get_object (value));
return;
@@ -1467,10 +1467,10 @@ subscription_editor_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
+ case PROP_SESSION:
g_value_set_object (
value,
- em_subscription_editor_get_backend (
+ em_subscription_editor_get_session (
EM_SUBSCRIPTION_EDITOR (object)));
return;
@@ -1492,9 +1492,9 @@ subscription_editor_dispose (GObject *object)
priv = EM_SUBSCRIPTION_EDITOR_GET_PRIVATE (object);
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
if (priv->initial_store != NULL) {
@@ -1540,17 +1540,14 @@ subscription_editor_constructed (GObject *object)
if (editor->priv->initial_store == NULL) {
EAccount *account;
CamelService *service;
- EMailBackend *backend;
EMailSession *session;
account = e_get_default_account ();
- backend = em_subscription_editor_get_backend (editor);
- session = e_mail_backend_get_session (backend);
+ session = em_subscription_editor_get_session (editor);
service = camel_session_get_service (
- CAMEL_SESSION (session),
- account->uid);
+ CAMEL_SESSION (session), account->uid);
if (CAMEL_IS_SUBSCRIBABLE (service))
editor->priv->initial_store = g_object_ref (service);
@@ -1621,12 +1618,12 @@ em_subscription_editor_class_init (EMSubscriptionEditorClass *class)
g_object_class_install_property (
object_class,
- PROP_BACKEND,
+ PROP_SESSION,
g_param_spec_object (
- "backend",
+ "session",
NULL,
NULL,
- E_TYPE_MAIL_BACKEND,
+ E_TYPE_MAIL_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
@@ -1911,26 +1908,26 @@ em_subscription_editor_init (EMSubscriptionEditor *editor)
GtkWidget *
em_subscription_editor_new (GtkWindow *parent,
- EMailBackend *backend,
+ EMailSession *session,
CamelStore *initial_store)
{
g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
return g_object_new (
EM_TYPE_SUBSCRIPTION_EDITOR,
- "backend", backend,
+ "session", session,
"store", initial_store,
"transient-for", parent,
NULL);
}
-EMailBackend *
-em_subscription_editor_get_backend (EMSubscriptionEditor *editor)
+EMailSession *
+em_subscription_editor_get_session (EMSubscriptionEditor *editor)
{
g_return_val_if_fail (EM_IS_SUBSCRIPTION_EDITOR (editor), NULL);
- return editor->priv->backend;
+ return editor->priv->session;
}
CamelStore *
diff --git a/mail/em-subscription-editor.h b/mail/em-subscription-editor.h
index 80b371f744..c6f6c258f0 100644
--- a/mail/em-subscription-editor.h
+++ b/mail/em-subscription-editor.h
@@ -21,7 +21,7 @@
#include <gtk/gtk.h>
#include <camel/camel.h>
-#include <mail/e-mail-backend.h>
+#include <mail/e-mail-session.h>
/* Standard GObject macros */
#define EM_TYPE_SUBSCRIPTION_EDITOR \
@@ -59,9 +59,9 @@ struct _EMSubscriptionEditorClass {
GType em_subscription_editor_get_type (void);
GtkWidget * em_subscription_editor_new (GtkWindow *parent,
- EMailBackend *backend,
+ EMailSession *session,
CamelStore *initial_store);
-EMailBackend * em_subscription_editor_get_backend
+EMailSession * em_subscription_editor_get_session
(EMSubscriptionEditor *editor);
CamelStore * em_subscription_editor_get_store
(EMSubscriptionEditor *editor);
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 96f912a153..8246fe3f24 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -258,22 +258,25 @@ static EMFilterSource em_filter_source_element_names[] = {
/**
* em_utils_edit_filters:
- * @parent: parent window
- * @backend: an #EMailBAckend
+ * @session: an #EMailSession
+ * @alert_sink: an #EAlertSink
+ * @parent_window: a parent #GtkWindow
*
* Opens or raises the filters editor dialog so that the user may edit
* his/her filters. If @parent is non-NULL, then the dialog will be
* created as a child window of @parent's toplevel window.
**/
void
-em_utils_edit_filters (GtkWidget *parent,
- EMailBackend *backend)
+em_utils_edit_filters (EMailSession *session,
+ EAlertSink *alert_sink,
+ GtkWindow *parent_window)
{
const gchar *config_dir;
gchar *user, *system;
EMFilterContext *fc;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
if (filter_editor) {
gtk_window_present (GTK_WINDOW (filter_editor));
@@ -282,7 +285,7 @@ em_utils_edit_filters (GtkWidget *parent,
config_dir = mail_session_get_config_dir ();
- fc = em_filter_context_new (backend);
+ fc = em_filter_context_new (session);
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);
@@ -290,8 +293,9 @@ em_utils_edit_filters (GtkWidget *parent,
g_free (system);
if (((ERuleContext *) fc)->error) {
- e_mail_backend_submit_alert (
- backend, "mail:filter-load-error",
+ e_alert_submit (
+ alert_sink,
+ "mail:filter-load-error",
((ERuleContext *) fc)->error, NULL);
return;
}
@@ -303,10 +307,10 @@ em_utils_edit_filters (GtkWidget *parent,
filter_editor = (GtkWidget *) em_filter_editor_new (
fc, em_filter_source_element_names);
- if (parent != NULL)
+
+ if (GTK_IS_WINDOW (parent_window))
gtk_window_set_transient_for (
- GTK_WINDOW (filter_editor),
- GTK_WINDOW (parent));
+ GTK_WINDOW (filter_editor), parent_window);
gtk_window_set_title (
GTK_WINDOW (filter_editor), _("Message Filters"));
@@ -1396,62 +1400,34 @@ em_utils_message_to_html (CamelMimeMessage *message,
/* ********************************************************************** */
/**
- * em_utils_expunge_folder:
- * @parent: parent window
- * @backend: #EMailBackend
- * @folder: folder to expunge
- *
- * Expunges @folder.
- **/
-void
-em_utils_expunge_folder (GtkWidget *parent,
- EMailBackend *backend,
- CamelFolder *folder)
-{
- const gchar *description;
-
- description = camel_folder_get_description (folder);
-
- if (!em_utils_prompt_user (
- GTK_WINDOW (parent),
- "prompt-on-expunge",
- "mail:ask-expunge", description, NULL))
- return;
-
- mail_expunge_folder (backend, folder);
-}
-
-/**
* em_utils_empty_trash:
* @parent: parent window
- * @backend: an #EMailBackend
+ * @session: an #EMailSession
*
* Empties all Trash folders.
**/
void
em_utils_empty_trash (GtkWidget *parent,
- EMailBackend *backend)
+ EMailSession *session)
{
- EMailSession *session;
- GList *list, *iter;
+ GList *list, *link;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
if (!em_utils_prompt_user ((GtkWindow *) parent,
"prompt-on-empty-trash",
"mail:ask-empty-trash", NULL))
return;
- session = e_mail_backend_get_session (backend);
list = camel_session_list_services (CAMEL_SESSION (session));
- for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ for (link = list; link != NULL; link = g_list_next (link)) {
EAccount *account;
CamelProvider *provider;
CamelService *service;
const gchar *uid;
- service = CAMEL_SERVICE (iter->data);
+ service = CAMEL_SERVICE (link->data);
provider = camel_service_get_provider (service);
uid = camel_service_get_uid (service);
@@ -1470,7 +1446,7 @@ em_utils_empty_trash (GtkWidget *parent,
continue;
}
- mail_empty_trash (backend, CAMEL_STORE (service));
+ mail_empty_trash (CAMEL_STORE (service));
}
g_list_free (list);
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 0a27266d31..cf5bd6c345 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -42,7 +42,9 @@ gboolean em_utils_prompt_user (GtkWindow *parent, const gchar *promptkey, const
GPtrArray *em_utils_uids_copy (GPtrArray *uids);
void em_utils_uids_free (GPtrArray *uids);
-void em_utils_edit_filters (GtkWidget *parent, EMailBackend *backend);
+void em_utils_edit_filters (EMailSession *session,
+ EAlertSink *alert_sink,
+ GtkWindow *parent_window);
void em_filename_make_safe (gchar *string);
void em_utils_edit_vfolders (GtkWidget *parent);
@@ -70,8 +72,8 @@ EProxy * em_utils_get_proxy (void);
/* FIXME: should this have an override charset? */
gchar *em_utils_message_to_html (CamelMimeMessage *msg, const gchar *credits, guint32 flags, struct _EMFormat *source, const gchar *append, guint32 *validity_found);
-void em_utils_expunge_folder (GtkWidget *parent, EMailBackend *backend, CamelFolder *folder);
-void em_utils_empty_trash (GtkWidget *parent, EMailBackend *backend);
+void em_utils_empty_trash (GtkWidget *parent,
+ EMailSession *session);
/* is this address in the addressbook? caches results */
gboolean em_utils_in_addressbook (CamelInternetAddress *addr, gboolean local_only);
diff --git a/mail/em-vfolder-context.c b/mail/em-vfolder-context.c
index 6ac2cb62f2..665700e9f5 100644
--- a/mail/em-vfolder-context.c
+++ b/mail/em-vfolder-context.c
@@ -40,12 +40,12 @@
((obj), EM_TYPE_VFOLDER_CONTEXT, EMVFolderContextPrivate))
struct _EMVFolderContextPrivate {
- EMailBackend *backend;
+ EMailSession *session;
};
enum {
PROP_0,
- PROP_BACKEND
+ PROP_SESSION
};
G_DEFINE_TYPE (
@@ -54,13 +54,13 @@ G_DEFINE_TYPE (
E_TYPE_RULE_CONTEXT)
static void
-vfolder_context_set_backend (EMVFolderContext *context,
- EMailBackend *backend)
+vfolder_context_set_session (EMVFolderContext *context,
+ EMailSession *session)
{
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (context->priv->backend == NULL);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (context->priv->session == NULL);
- context->priv->backend = g_object_ref (backend);
+ context->priv->session = g_object_ref (session);
}
static void
@@ -70,8 +70,8 @@ vfolder_context_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- vfolder_context_set_backend (
+ case PROP_SESSION:
+ vfolder_context_set_session (
EM_VFOLDER_CONTEXT (object),
g_value_get_object (value));
return;
@@ -87,10 +87,10 @@ vfolder_context_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
+ case PROP_SESSION:
g_value_set_object (
value,
- em_vfolder_context_get_backend (
+ em_vfolder_context_get_session (
EM_VFOLDER_CONTEXT (object)));
return;
}
@@ -105,9 +105,9 @@ vfolder_context_dispose (GObject *object)
priv = EM_VFOLDER_CONTEXT_GET_PRIVATE (object);
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
/* Chain up to parent's dispose() method. */
@@ -129,11 +129,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->backend);
+ return em_filter_folder_element_new (priv->session);
/* XXX Legacy type name. Same as "folder" now. */
if (strcmp (type, "folder-curi") == 0)
- return em_filter_folder_element_new (priv->backend);
+ return em_filter_folder_element_new (priv->session);
return E_RULE_CONTEXT_CLASS (em_vfolder_context_parent_class)->
new_element (context, type);
@@ -157,12 +157,12 @@ em_vfolder_context_class_init (EMVFolderContextClass *class)
g_object_class_install_property (
object_class,
- PROP_BACKEND,
+ PROP_SESSION,
g_param_spec_object (
- "backend",
+ "session",
NULL,
NULL,
- E_TYPE_MAIL_BACKEND,
+ E_TYPE_MAIL_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
@@ -187,18 +187,18 @@ em_vfolder_context_init (EMVFolderContext *context)
}
EMVFolderContext *
-em_vfolder_context_new (EMailBackend *backend)
+em_vfolder_context_new (EMailSession *session)
{
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
return g_object_new (
- EM_TYPE_VFOLDER_CONTEXT, "backend", backend, NULL);
+ EM_TYPE_VFOLDER_CONTEXT, "session", session, NULL);
}
-EMailBackend *
-em_vfolder_context_get_backend (EMVFolderContext *context)
+EMailSession *
+em_vfolder_context_get_session (EMVFolderContext *context)
{
g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL);
- return context->priv->backend;
+ return context->priv->session;
}
diff --git a/mail/em-vfolder-context.h b/mail/em-vfolder-context.h
index 4a5406356b..c0fd041abc 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-backend.h>
+#include <mail/e-mail-session.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 (EMailBackend *backend);
-EMailBackend * em_vfolder_context_get_backend (EMVFolderContext *context);
+ em_vfolder_context_new (EMailSession *session);
+EMailSession * em_vfolder_context_get_session (EMVFolderContext *context);
G_END_DECLS
diff --git a/mail/em-vfolder-editor.c b/mail/em-vfolder-editor.c
index 2cf7ed5eb1..ef3e0fb3ca 100644
--- a/mail/em-vfolder-editor.c
+++ b/mail/em-vfolder-editor.c
@@ -45,15 +45,15 @@ static EFilterRule *
vfolder_editor_create_rule (ERuleEditor *rule_editor)
{
EMVFolderContext *context;
- EMailBackend *backend;
+ EMailSession *session;
EFilterRule *rule;
EFilterPart *part;
context = EM_VFOLDER_CONTEXT (rule_editor->context);
- backend = em_vfolder_context_get_backend (context);
+ session = em_vfolder_context_get_session (context);
/* create a rule with 1 part in it */
- rule = em_vfolder_rule_new (backend);
+ rule = em_vfolder_rule_new (session);
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 3f0c2200aa..a22816070a 100644
--- a/mail/em-vfolder-rule.c
+++ b/mail/em-vfolder-rule.c
@@ -47,12 +47,12 @@
((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRulePrivate))
struct _EMVFolderRulePrivate {
- EMailBackend *backend;
+ EMailSession *session;
};
enum {
PROP_0,
- PROP_BACKEND
+ PROP_SESSION
};
static gint validate (EFilterRule *, EAlert **alert);
@@ -76,22 +76,25 @@ G_DEFINE_TYPE (
E_TYPE_FILTER_RULE)
static void
-vfolder_rule_set_backend (EMVFolderRule *rule,
- EMailBackend *backend)
+vfolder_rule_set_session (EMVFolderRule *rule,
+ EMailSession *session)
{
- if (backend == NULL) {
+ if (session == 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_BACKEND (backend));
- g_return_if_fail (rule->priv->backend == NULL);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (rule->priv->session == NULL);
- rule->priv->backend = g_object_ref (backend);
+ rule->priv->session = g_object_ref (session);
}
static void
@@ -101,8 +104,8 @@ vfolder_rule_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- vfolder_rule_set_backend (
+ case PROP_SESSION:
+ vfolder_rule_set_session (
EM_VFOLDER_RULE (object),
g_value_get_object (value));
return;
@@ -118,10 +121,10 @@ vfolder_rule_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
+ case PROP_SESSION:
g_value_set_object (
value,
- em_vfolder_rule_get_backend (
+ em_vfolder_rule_get_session (
EM_VFOLDER_RULE (object)));
return;
}
@@ -136,9 +139,9 @@ vfolder_rule_dispose (GObject *object)
priv = EM_VFOLDER_RULE_GET_PRIVATE (object);
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
/* Chain up to parent's dispose() method. */
@@ -182,12 +185,12 @@ em_vfolder_rule_class_init (EMVFolderRuleClass *class)
g_object_class_install_property (
object_class,
- PROP_BACKEND,
+ PROP_SESSION,
g_param_spec_object (
- "backend",
+ "session",
NULL,
NULL,
- E_TYPE_MAIL_BACKEND,
+ E_TYPE_MAIL_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
@@ -201,20 +204,20 @@ em_vfolder_rule_init (EMVFolderRule *rule)
}
EFilterRule *
-em_vfolder_rule_new (EMailBackend *backend)
+em_vfolder_rule_new (EMailSession *session)
{
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
return g_object_new (
- EM_TYPE_VFOLDER_RULE, "backend", backend, NULL);
+ EM_TYPE_VFOLDER_RULE, "session", session, NULL);
}
-EMailBackend *
-em_vfolder_rule_get_backend (EMVFolderRule *rule)
+EMailSession *
+em_vfolder_rule_get_session (EMVFolderRule *rule)
{
g_return_val_if_fail (EM_IS_VFOLDER_RULE (rule), NULL);
- return rule->priv->backend;
+ return rule->priv->session;
}
void
@@ -539,12 +542,12 @@ vfr_folder_response (EMFolderSelector *selector,
gint button,
struct _source_data *data)
{
- EMailBackend *backend;
+ EMFolderTreeModel *model;
EMailSession *session;
const gchar *uri;
- backend = em_folder_selector_get_backend (selector);
- session = e_mail_backend_get_session (backend);
+ model = em_folder_selector_get_model (selector);
+ session = em_folder_tree_model_get_session (model);
uri = em_folder_selector_get_selected_uri (selector);
@@ -578,19 +581,16 @@ source_add (GtkWidget *widget,
{
EMFolderTree *folder_tree;
EMFolderTreeModel *model;
- EMailBackend *backend;
GtkWidget *dialog;
gpointer parent;
parent = gtk_widget_get_toplevel (widget);
parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
- backend = em_vfolder_rule_get_backend (data->vr);
-
model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
- parent, backend, model,
+ parent, model,
EM_FOLDER_SELECTOR_CAN_CREATE,
_("Add Folder"), NULL, _("_Add"));
@@ -664,7 +664,6 @@ get_widget (EFilterRule *fr,
ERuleContext *rc)
{
EMVFolderRule *vr =(EMVFolderRule *) fr;
- EMailBackend *backend;
EMailSession *session;
GtkWidget *widget, *frame;
struct _source_data *data;
@@ -700,8 +699,7 @@ get_widget (EFilterRule *fr,
object = gtk_builder_get_object (builder, "source_model");
data->model = GTK_LIST_STORE (object);
- backend = em_vfolder_context_get_backend (EM_VFOLDER_CONTEXT (rc));
- session = e_mail_backend_get_session (backend);
+ session = em_vfolder_context_get_session (EM_VFOLDER_CONTEXT (rc));
source = NULL;
while ((source = em_vfolder_rule_next_source (vr, source))) {
diff --git a/mail/em-vfolder-rule.h b/mail/em-vfolder-rule.h
index ccbcbb10fe..7fc8daaee9 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-backend.h>
+#include <mail/e-mail-session.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 (EMailBackend *backend);
-EMailBackend * em_vfolder_rule_get_backend (EMVFolderRule *rule);
+EFilterRule * em_vfolder_rule_new (EMailSession *session);
+EMailSession * em_vfolder_rule_get_session (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 b158d606a9..c3d5f2f1b7 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -145,8 +145,7 @@ mbox_getwidget (EImport *ei,
label = GTK_LABEL (w);
w = em_folder_selection_button_new (
- E_MAIL_BACKEND (shell_backend),
- _("Select folder"),
+ session, _("Select folder"),
_("Select folder to import into"));
gtk_label_set_mnemonic_widget (label, w);
em_folder_selection_button_set_folder_uri (
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 3fc90d5f94..6d08c78a40 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -307,7 +307,7 @@ em_vfolder_rule_from_message (EMVFolderContext *context,
CamelFolder *folder)
{
EFilterRule *rule;
- EMailBackend *backend;
+ EMailSession *session;
gchar *uri;
g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL);
@@ -316,9 +316,9 @@ em_vfolder_rule_from_message (EMVFolderContext *context,
uri = e_mail_folder_uri_from_folder (folder);
- backend = em_vfolder_context_get_backend (context);
+ session = em_vfolder_context_get_session (context);
- rule = em_vfolder_rule_new (backend);
+ rule = em_vfolder_rule_new (session);
em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), uri);
rule_from_message (rule, E_RULE_CONTEXT (context), msg, flags);
@@ -334,7 +334,7 @@ em_vfolder_rule_from_address (EMVFolderContext *context,
CamelFolder *folder)
{
EFilterRule *rule;
- EMailBackend *backend;
+ EMailSession *session;
gchar *uri;
g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL);
@@ -343,9 +343,9 @@ em_vfolder_rule_from_address (EMVFolderContext *context,
uri = e_mail_folder_uri_from_folder (folder);
- backend = em_vfolder_context_get_backend (context);
+ session = em_vfolder_context_get_session (context);
- rule = em_vfolder_rule_new (backend);
+ rule = em_vfolder_rule_new (session);
em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), uri);
rule_from_address (rule, E_RULE_CONTEXT (context), addr, flags);
@@ -377,7 +377,7 @@ filter_rule_from_message (EMFilterContext *context,
}
void
-filter_gui_add_from_message (EMailBackend *backend,
+filter_gui_add_from_message (EMailSession *session,
CamelMimeMessage *msg,
const gchar *source,
gint flags)
@@ -387,10 +387,10 @@ filter_gui_add_from_message (EMailBackend *backend,
gchar *user, *system;
EFilterRule *rule;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
g_return_if_fail (CAMEL_IS_MIME_MESSAGE (msg));
- fc = em_filter_context_new (backend);
+ fc = em_filter_context_new (session);
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);
@@ -407,11 +407,11 @@ filter_gui_add_from_message (EMailBackend *backend,
}
void
-mail_filter_rename_folder (EMailBackend *backend,
- CamelStore *store,
+mail_filter_rename_folder (CamelStore *store,
const gchar *old_folder_name,
const gchar *new_folder_name)
{
+ CamelSession *session;
EMFilterContext *fc;
const gchar *config_dir;
gchar *user, *system;
@@ -419,15 +419,16 @@ mail_filter_rename_folder (EMailBackend *backend,
gchar *old_uri;
gchar *new_uri;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
g_return_if_fail (CAMEL_IS_STORE (store));
g_return_if_fail (old_folder_name != NULL);
g_return_if_fail (new_folder_name != NULL);
+ session = camel_service_get_session (CAMEL_SERVICE (store));
+
old_uri = e_mail_folder_uri_build (store, old_folder_name);
new_uri = e_mail_folder_uri_build (store, new_folder_name);
- fc = em_filter_context_new (backend);
+ fc = em_filter_context_new (E_MAIL_SESSION (session));
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);
@@ -450,23 +451,26 @@ mail_filter_rename_folder (EMailBackend *backend,
}
void
-mail_filter_delete_folder (EMailBackend *backend,
- CamelStore *store,
- const gchar *folder_name)
+mail_filter_delete_folder (CamelStore *store,
+ const gchar *folder_name,
+ EAlertSink *alert_sink)
{
+ CamelSession *session;
EMFilterContext *fc;
const gchar *config_dir;
gchar *user, *system;
GList *deleted;
gchar *uri;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
g_return_if_fail (CAMEL_IS_STORE (store));
g_return_if_fail (folder_name != NULL);
+ g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
+
+ session = camel_service_get_session (CAMEL_SERVICE (store));
uri = e_mail_folder_uri_build (store, folder_name);
- fc = em_filter_context_new (backend);
+ fc = em_filter_context_new (E_MAIL_SESSION (session));
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);
@@ -509,8 +513,8 @@ mail_filter_delete_folder (EMailBackend *backend,
"The following filter rules\n%s have been modified "
"to account for the deleted folder\n\"%s\".",
s_count), s->str, folder_name);
- e_mail_backend_submit_alert (
- backend, "mail:filter-updated", info, NULL);
+ e_alert_submit (
+ alert_sink, "mail:filter-updated", info, NULL);
g_string_free (s, TRUE);
g_free (info);
diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h
index 43671177ae..47f68c3be5 100644
--- a/mail/mail-autofilter.h
+++ b/mail/mail-autofilter.h
@@ -27,7 +27,7 @@
#include <camel/camel.h>
#include <filter/e-filter-rule.h>
-#include <mail/e-mail-backend.h>
+#include <mail/e-mail-session.h>
#include <mail/em-filter-context.h>
#include <mail/em-vfolder-context.h>
@@ -51,19 +51,18 @@ EFilterRule * em_vfolder_rule_from_address (EMVFolderContext *context,
CamelFolder *folder);
/* easiest place to put this */
-void filter_gui_add_from_message (EMailBackend *backend,
+void filter_gui_add_from_message (EMailSession *session,
CamelMimeMessage *msg,
const gchar *source,
gint flags);
/* Also easiest place for these, we should really
* share a global rule context for this stuff ... */
-void mail_filter_rename_folder (EMailBackend *backend,
- CamelStore *store,
+void mail_filter_rename_folder (CamelStore *store,
const gchar *old_folder_name,
const gchar *new_folder_name);
-void mail_filter_delete_folder (EMailBackend *backend,
- CamelStore *store,
- const gchar *folder_name);
+void mail_filter_delete_folder (CamelStore *store,
+ const gchar *folder_name,
+ EAlertSink *alert_sink);
#endif /* MAIL_AUTOFILTER_H */
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 4ff12b3955..aa4ec741b2 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -418,28 +418,6 @@ mail_fetch_mail (CamelStore *store,
mail_msg_unordered_push (m);
}
-static gchar *
-escape_percent_sign (const gchar *str)
-{
- GString *res;
-
- if (!str)
- return NULL;
-
- res = g_string_sized_new (strlen (str));
- while (*str) {
- if (*str == '%') {
- g_string_append (res, "%%");
- } else {
- g_string_append_c (res, *str);
- }
-
- str++;
- }
-
- return g_string_free (res, FALSE);
-}
-
/* ********************************************************************** */
/* sending stuff */
/* ** SEND MAIL *********************************************************** */
@@ -459,7 +437,7 @@ static const gchar *resent_recipients[] = {
struct _send_queue_msg {
MailMsg base;
- EMailBackend *backend;
+ EMailSession *session;
CamelFolder *queue;
CamelTransport *transport;
@@ -490,7 +468,6 @@ mail_send_message (struct _send_queue_msg *m,
GError **error)
{
EAccount *account = NULL;
- EMailSession *session;
const CamelInternetAddress *iaddr;
CamelAddress *from, *recipients;
CamelMessageInfo *info = NULL;
@@ -515,8 +492,6 @@ mail_send_message (struct _send_queue_msg *m,
err = g_string_new ("");
xev = mail_tool_remove_xevolution_headers (message);
- session = e_mail_backend_get_session (m->backend);
-
tmp = camel_header_raw_find (&xev, "X-Evolution-Account", NULL);
if (tmp != NULL) {
gchar *name;
@@ -532,7 +507,7 @@ mail_send_message (struct _send_queue_msg *m,
transport_uid = g_strconcat (
account->uid, "-transport", NULL);
service = camel_session_get_service (
- CAMEL_SESSION (session),
+ CAMEL_SESSION (m->session),
transport_uid);
g_free (transport_uid);
@@ -557,20 +532,11 @@ mail_send_message (struct _send_queue_msg *m,
}
if (transport != NULL) {
- CamelURL *url;
- gchar *url_string;
- gchar *escaped;
-
- url = camel_service_new_camel_url (CAMEL_SERVICE (transport));
- url_string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
- escaped = escape_percent_sign (url_string);
- camel_url_free (url);
+ const gchar *uid;
/* Let the dialog know the right account it is using. */
- report_status (m, CAMEL_FILTER_STATUS_ACTION, 0, escaped);
-
- g_free (escaped);
- g_free (url_string);
+ uid = camel_service_get_uid (CAMEL_SERVICE (transport));
+ report_status (m, CAMEL_FILTER_STATUS_ACTION, 0, uid);
}
/* Check for email sending */
@@ -618,7 +584,7 @@ mail_send_message (struct _send_queue_msg *m,
uri = g_strstrip (g_strdup (header->value));
/* FIXME Not passing a GCancellable or GError here. */
folder = e_mail_session_uri_to_folder_sync (
- session, uri, 0, NULL, NULL);
+ m->session, uri, 0, NULL, NULL);
if (folder) {
/* FIXME Not passing a GCancellable or GError here. */
camel_folder_append_message_sync (
@@ -658,7 +624,7 @@ mail_send_message (struct _send_queue_msg *m,
if (sent_folder_uri) {
folder = e_mail_session_uri_to_folder_sync (
- session, sent_folder_uri, 0,
+ m->session, sent_folder_uri, 0,
cancellable, &local_error);
if (folder == NULL) {
g_string_append_printf (
@@ -675,7 +641,7 @@ mail_send_message (struct _send_queue_msg *m,
if (!folder) {
folder = e_mail_session_get_local_folder (
- session, E_MAIL_LOCAL_FOLDER_SENT);
+ m->session, E_MAIL_LOCAL_FOLDER_SENT);
g_object_ref (folder);
}
@@ -689,7 +655,7 @@ mail_send_message (struct _send_queue_msg *m,
goto exit;
sent_folder = e_mail_session_get_local_folder (
- session, E_MAIL_LOCAL_FOLDER_SENT);
+ m->session, E_MAIL_LOCAL_FOLDER_SENT);
if (folder != sent_folder) {
const gchar *description;
@@ -727,7 +693,7 @@ mail_send_message (struct _send_queue_msg *m,
if (local_error == NULL) {
/* Mark the draft message for deletion, if present. */
e_mail_session_handle_draft_headers_sync (
- session, message, cancellable, &local_error);
+ m->session, message, cancellable, &local_error);
if (local_error != NULL) {
g_warning ("%s: Failed to handle draft headers: %s", G_STRFUNC, local_error->message);
g_clear_error (&local_error);
@@ -737,7 +703,7 @@ mail_send_message (struct _send_queue_msg *m,
* Source message refers to the message being forwarded
* or replied to. */
e_mail_session_handle_source_headers_sync (
- session, message, cancellable, &local_error);
+ m->session, message, cancellable, &local_error);
if (local_error != NULL) {
g_warning ("%s: Failed to handle source headers: %s", G_STRFUNC, local_error->message);
g_clear_error (&local_error);
@@ -807,7 +773,6 @@ send_queue_exec (struct _send_queue_msg *m,
GCancellable *cancellable,
GError **error)
{
- EMailSession *session;
CamelFolder *sent_folder;
GPtrArray *uids, *send_uids = NULL;
gint i, j;
@@ -815,11 +780,9 @@ send_queue_exec (struct _send_queue_msg *m,
d(printf("sending queue\n"));
- session = e_mail_backend_get_session (m->backend);
-
sent_folder =
e_mail_session_get_local_folder (
- session, E_MAIL_LOCAL_FOLDER_SENT);
+ m->session, E_MAIL_LOCAL_FOLDER_SENT);
if (!(uids = camel_folder_get_uids (m->queue)))
return;
@@ -946,8 +909,8 @@ send_queue_desc (struct _send_queue_msg *m)
static void
send_queue_free (struct _send_queue_msg *m)
{
- if (m->backend != NULL)
- g_object_unref (m->backend);
+ if (m->session != NULL)
+ g_object_unref (m->session);
if (m->driver != NULL)
g_object_unref (m->driver);
if (m->transport != NULL)
@@ -966,7 +929,7 @@ static MailMsgInfo send_queue_info = {
/* same interface as fetch_mail, just 'cause i'm lazy today
* (and we need to run it from the same spot?) */
void
-mail_send_queue (EMailBackend *backend,
+mail_send_queue (EMailSession *session,
CamelFolder *queue,
CamelTransport *transport,
const gchar *type,
@@ -978,15 +941,12 @@ mail_send_queue (EMailBackend *backend,
void (*done)(gpointer data),
gpointer data)
{
- EMailSession *session;
struct _send_queue_msg *m;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
-
- session = e_mail_backend_get_session (backend);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
m = mail_msg_new (&send_queue_info);
- m->backend = g_object_ref (backend);
+ m->session = g_object_ref (session);
m->queue = g_object_ref (queue);
m->transport = g_object_ref (transport);
if (G_IS_CANCELLABLE (cancellable))
@@ -1134,7 +1094,6 @@ mail_transfer_messages (EMailSession *session,
struct _sync_folder_msg {
MailMsg base;
- EMailBackend *backend;
CamelFolder *folder;
void (*done) (CamelFolder *folder, gpointer data);
gpointer data;
@@ -1166,9 +1125,6 @@ sync_folder_done (struct _sync_folder_msg *m)
static void
sync_folder_free (struct _sync_folder_msg *m)
{
- if (m->backend)
- g_object_unref (m->backend);
-
if (m->folder)
g_object_unref (m->folder);
}
@@ -1340,19 +1296,23 @@ folder_is_from_source_uid (CamelFolder *folder,
* then also all active pop3 accounts should be expunged. */
static gboolean
expunge_pop3_stores (CamelFolder *expunging,
- EMailBackend *backend,
GCancellable *cancellable,
GError **error)
{
GHashTable *expunging_uids;
- EMailSession *session;
+ CamelStore *parent_store;
+ CamelService *service;
+ CamelSession *session;
GPtrArray *uids;
EAccount *account;
EIterator *iter;
gboolean success = TRUE;
guint ii;
- session = e_mail_backend_get_session (backend);
+ parent_store = camel_folder_get_parent_store (expunging);
+
+ service = CAMEL_SERVICE (parent_store);
+ session = camel_service_get_session (service);
uids = camel_folder_get_uids (expunging);
@@ -1425,7 +1385,9 @@ expunge_pop3_stores (CamelFolder *expunging,
CamelSettings *settings;
gboolean any_found = FALSE, delete_expunged = FALSE, keep_on_server = FALSE;
- service = camel_session_get_service (CAMEL_SESSION (session), account->uid);
+ service = camel_session_get_service (
+ session, account->uid);
+
if (!CAMEL_IS_STORE (service))
continue;
@@ -1443,7 +1405,8 @@ expunge_pop3_stores (CamelFolder *expunging,
continue;
folder = e_mail_session_get_inbox_sync (
- session, account->uid, cancellable, error);
+ E_MAIL_SESSION (session),
+ account->uid, cancellable, error);
/* Abort the loop on error. */
if (folder == NULL) {
@@ -1500,22 +1463,26 @@ expunge_folder_exec (struct _sync_folder_msg *m,
GCancellable *cancellable,
GError **error)
{
- EMailSession *session;
CamelFolder *local_inbox;
CamelStore *parent_store;
+ CamelService *service;
+ CamelSession *session;
gboolean is_local_inbox_or_trash;
gboolean store_is_local;
gboolean success = TRUE;
const gchar *uid;
- session = e_mail_backend_get_session (m->backend);
parent_store = camel_folder_get_parent_store (m->folder);
- uid = camel_service_get_uid (CAMEL_SERVICE (parent_store));
+
+ service = CAMEL_SERVICE (parent_store);
+ session = camel_service_get_session (service);
+
+ uid = camel_service_get_uid (service);
store_is_local = (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0);
local_inbox =
e_mail_session_get_local_folder (
- session, E_MAIL_LOCAL_FOLDER_INBOX);
+ E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_INBOX);
is_local_inbox_or_trash = (m->folder == local_inbox);
if (store_is_local && !is_local_inbox_or_trash) {
@@ -1534,8 +1501,7 @@ expunge_folder_exec (struct _sync_folder_msg *m,
/* do this before expunge, to know which messages will be expunged */
if (is_local_inbox_or_trash)
- success = expunge_pop3_stores (
- m->folder, m->backend, cancellable, error);
+ success = expunge_pop3_stores (m->folder, cancellable, error);
if (success)
camel_folder_expunge_sync (m->folder, cancellable, error);
@@ -1551,13 +1517,13 @@ static MailMsgInfo expunge_folder_info = {
};
void
-mail_expunge_folder (EMailBackend *backend,
- CamelFolder *folder)
+mail_expunge_folder (CamelFolder *folder)
{
struct _sync_folder_msg *m;
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
+
m = mail_msg_new (&expunge_folder_info);
- m->backend = g_object_ref (backend);
m->folder = g_object_ref (folder);
mail_msg_slow_ordered_push (m);
@@ -1568,7 +1534,6 @@ mail_expunge_folder (EMailBackend *backend,
struct _empty_trash_msg {
MailMsg base;
- EMailBackend *backend;
CamelStore *store;
};
@@ -1609,8 +1574,7 @@ empty_trash_exec (struct _empty_trash_msg *m,
/* do this before expunge, to know which messages will be expunged */
if (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0)
- success = expunge_pop3_stores (
- trash, m->backend, cancellable, error);
+ success = expunge_pop3_stores (trash, cancellable, error);
if (success)
camel_folder_expunge_sync (trash, cancellable, error);
@@ -1626,8 +1590,6 @@ empty_trash_done (struct _empty_trash_msg *m)
static void
empty_trash_free (struct _empty_trash_msg *m)
{
- if (m->backend)
- g_object_unref (m->backend);
if (m->store)
g_object_unref (m->store);
}
@@ -1641,16 +1603,13 @@ static MailMsgInfo empty_trash_info = {
};
void
-mail_empty_trash (EMailBackend *backend,
- CamelStore *store)
+mail_empty_trash (CamelStore *store)
{
struct _empty_trash_msg *m;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
g_return_if_fail (CAMEL_IS_STORE (store));
m = mail_msg_new (&empty_trash_info);
- m->backend = g_object_ref (backend);
m->store = g_object_ref (store);
mail_msg_slow_ordered_push (m);
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 4ec64ccf22..b8eb184c7e 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -50,11 +50,8 @@ void mail_refresh_folder (CamelFolder *folder,
void (*done) (CamelFolder *folder, gpointer data),
gpointer data);
-void mail_expunge_folder (EMailBackend *backend,
- CamelFolder *folder);
-
-void mail_empty_trash (EMailBackend *backend,
- CamelStore *store);
+void mail_expunge_folder (CamelFolder *folder);
+void mail_empty_trash (CamelStore *store);
/* transfer (copy/move) a folder */
void mail_xfer_folder (const gchar *src_uri, const gchar *dest_uri, gboolean remove_source,
@@ -63,7 +60,7 @@ void mail_xfer_folder (const gchar *src_uri, const gchar *dest_uri, gboolean rem
gpointer data);
/* yeah so this is messy, but it does a lot, maybe i can consolidate all user_data's to be the one */
-void mail_send_queue (EMailBackend *backend,
+void mail_send_queue (EMailSession *session,
CamelFolder *queue,
CamelTransport *transport,
const gchar *type,
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 481bbb46b4..b642326aca 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -106,8 +106,8 @@ typedef enum {
struct _send_info {
send_info_t type; /* 0 = fetch, 1 = send */
- EMailBackend *backend;
GCancellable *cancellable;
+ CamelSession *session;
CamelService *service;
gboolean keep_on_server;
send_state_t state;
@@ -150,10 +150,10 @@ free_folder_info (struct _folder_info *info)
static void
free_send_info (struct _send_info *info)
{
- if (info->backend != NULL)
- g_object_unref (info->backend);
if (info->cancellable != NULL)
g_object_unref (info->cancellable);
+ if (info->session != NULL)
+ g_object_unref (info->session);
if (info->service != NULL)
g_object_unref (info->service);
if (info->timeout_id != 0)
@@ -164,13 +164,10 @@ free_send_info (struct _send_info *info)
}
static struct _send_data *
-setup_send_data (EMailBackend *backend)
+setup_send_data (EMailSession *session)
{
- EMailSession *session;
struct _send_data *data;
- session = e_mail_backend_get_session (backend);
-
if (send_data == NULL) {
send_data = data = g_malloc0 (sizeof (*data));
data->lock = g_mutex_new ();
@@ -187,6 +184,7 @@ setup_send_data (EMailBackend *backend)
(GDestroyNotify) g_free,
(GDestroyNotify) free_send_info);
}
+
return send_data;
}
@@ -335,15 +333,11 @@ static void
set_transport_service (struct _send_info *info,
const gchar *transport_uid)
{
- EMailSession *session;
CamelService *service;
- session = e_mail_backend_get_session (info->backend);
-
g_static_mutex_lock (&status_lock);
- service = camel_session_get_service (
- CAMEL_SESSION (session), transport_uid);
+ service = camel_session_get_service (info->session, transport_uid);
if (CAMEL_IS_TRANSPORT (service)) {
if (info->service != NULL)
@@ -474,7 +468,7 @@ get_keep_on_server (CamelService *service)
static struct _send_data *
build_dialog (GtkWindow *parent,
- EMailBackend *backend,
+ EMailSession *session,
CamelFolder *outbox,
EAccount *outgoing_account,
gboolean allow_send)
@@ -492,7 +486,6 @@ build_dialog (GtkWindow *parent,
GtkWidget *status_label;
GtkWidget *progress_bar;
GtkWidget *cancel_button;
- EMailSession *session;
EMailAccountStore *account_store;
CamelService *transport = NULL;
struct _send_info *info;
@@ -500,7 +493,6 @@ build_dialog (GtkWindow *parent,
EMEventTargetSendReceive *target;
GQueue queue = G_QUEUE_INIT;
- session = e_mail_backend_get_session (backend);
account_store = e_mail_session_get_account_store (session);
/* Convert the outgoing account to a CamelTransport. */
@@ -573,7 +565,7 @@ build_dialog (GtkWindow *parent,
gtk_widget_show (scrolled_window);
/* must bet setup after send_recv_dialog as it may re-trigger send-recv button */
- data = setup_send_data (backend);
+ data = setup_send_data (session);
row = 0;
e_mail_account_store_queue_enabled_services (account_store, &queue);
@@ -596,7 +588,7 @@ build_dialog (GtkWindow *parent,
info = g_malloc0 (sizeof (*info));
info->type = type;
- info->backend = g_object_ref (backend);
+ info->session = g_object_ref (session);
info->service = g_object_ref (service);
info->keep_on_server = get_keep_on_server (service);
info->cancellable = camel_operation_new ();
@@ -689,7 +681,7 @@ build_dialog (GtkWindow *parent,
if (info == NULL) {
info = g_malloc0 (sizeof (*info));
info->type = SEND_SEND;
-
+ info->session = g_object_ref (session);
info->service = g_object_ref (transport);
info->keep_on_server = FALSE;
info->cancellable = camel_operation_new ();
@@ -839,20 +831,18 @@ receive_done (gpointer data)
/* if we've been called to run again - run again */
if (info->type == SEND_SEND && info->state == SEND_ACTIVE && info->again) {
- EMailSession *session;
CamelFolder *local_outbox;
- session = e_mail_backend_get_session (info->backend);
-
local_outbox =
e_mail_session_get_local_folder (
- session, E_MAIL_LOCAL_FOLDER_OUTBOX);
+ E_MAIL_SESSION (info->session),
+ E_MAIL_LOCAL_FOLDER_OUTBOX);
g_return_if_fail (CAMEL_IS_TRANSPORT (info->service));
info->again = 0;
mail_send_queue (
- info->backend,
+ E_MAIL_SESSION (info->session),
local_outbox,
CAMEL_TRANSPORT (info->service),
E_FILTER_SOURCE_OUTGOING,
@@ -911,7 +901,6 @@ receive_get_folder (CamelFilterDriver *d,
{
struct _send_info *info = data;
CamelFolder *folder;
- EMailSession *session;
struct _folder_info *oldinfo;
gpointer oldkey, oldinfoptr;
@@ -924,11 +913,9 @@ receive_get_folder (CamelFilterDriver *d,
return oldinfo->folder;
}
- session = e_mail_backend_get_session (info->backend);
-
/* FIXME Not passing a GCancellable here. */
folder = e_mail_session_uri_to_folder_sync (
- session, uri, 0, NULL, error);
+ E_MAIL_SESSION (info->session), uri, 0, NULL, error);
if (!folder)
return NULL;
@@ -1006,7 +993,6 @@ refresh_folders_exec (struct _refresh_folders_msg *m,
GError **error)
{
CamelFolder *folder;
- EMailSession *session;
gint i;
GError *local_error = NULL;
gulong handler_id = 0;
@@ -1020,11 +1006,9 @@ refresh_folders_exec (struct _refresh_folders_msg *m,
camel_operation_push_message (m->info->cancellable, _("Updating..."));
- session = e_mail_backend_get_session (m->info->backend);
-
for (i = 0; i < m->folders->len; i++) {
folder = e_mail_session_uri_to_folder_sync (
- session,
+ E_MAIL_SESSION (m->info->session),
m->folders->pdata[i], 0,
cancellable, &local_error);
if (folder) {
@@ -1112,11 +1096,10 @@ static void
receive_update_got_store (CamelStore *store,
struct _send_info *info)
{
- EMailSession *session;
MailFolderCache *folder_cache;
- session = e_mail_backend_get_session (info->backend);
- folder_cache = e_mail_session_get_folder_cache (session);
+ folder_cache = e_mail_session_get_folder_cache (
+ E_MAIL_SESSION (info->session));
if (store) {
mail_folder_cache_note_store (
@@ -1129,12 +1112,11 @@ receive_update_got_store (CamelStore *store,
static GtkWidget *
send_receive (GtkWindow *parent,
- EMailBackend *backend,
+ EMailSession *session,
gboolean allow_send)
{
CamelFolder *local_outbox;
struct _send_data *data;
- EMailSession *session;
EAccount *account;
GList *scan;
@@ -1145,8 +1127,6 @@ send_receive (GtkWindow *parent,
return send_recv_dialog;
}
- session = e_mail_backend_get_session (backend);
-
if (!camel_session_get_online (CAMEL_SESSION (session)))
return send_recv_dialog;
@@ -1159,7 +1139,7 @@ send_receive (GtkWindow *parent,
session, E_MAIL_LOCAL_FOLDER_OUTBOX);
data = build_dialog (
- parent, backend, local_outbox, account, allow_send);
+ parent, session, local_outbox, account, allow_send);
for (scan = data->infos; scan != NULL; scan = scan->next) {
struct _send_info *info = scan->data;
@@ -1181,7 +1161,7 @@ send_receive (GtkWindow *parent,
case SEND_SEND:
/* todo, store the folder in info? */
mail_send_queue (
- backend, local_outbox,
+ session, local_outbox,
CAMEL_TRANSPORT (info->service),
E_FILTER_SOURCE_OUTGOING,
info->cancellable,
@@ -1203,21 +1183,21 @@ send_receive (GtkWindow *parent,
GtkWidget *
mail_send_receive (GtkWindow *parent,
- EMailBackend *backend)
+ EMailSession *session)
{
- return send_receive (parent, backend, TRUE);
+ return send_receive (parent, session, TRUE);
}
GtkWidget *
mail_receive (GtkWindow *parent,
- EMailBackend *backend)
+ EMailSession *session)
{
- return send_receive (parent, backend, FALSE);
+ return send_receive (parent, session, FALSE);
}
struct _auto_data {
EAccount *account;
- EMailBackend *backend;
+ EMailSession *session;
gint period; /* in seconds */
gint timeout_id;
};
@@ -1227,18 +1207,18 @@ static GHashTable *auto_active;
static gboolean
auto_timeout (gpointer data)
{
- EMailSession *session;
CamelService *service;
+ CamelSession *session;
struct _auto_data *info = data;
- session = e_mail_backend_get_session (info->backend);
+ session = CAMEL_SESSION (info->session);
service = camel_session_get_service (
- CAMEL_SESSION (session), info->account->uid);
+ session, info->account->uid);
g_return_val_if_fail (CAMEL_IS_SERVICE (service), TRUE);
- if (camel_session_get_online (CAMEL_SESSION (session)))
- mail_receive_service (info->backend, service);
+ if (camel_session_get_online (session))
+ mail_receive_service (service);
return TRUE;
}
@@ -1261,8 +1241,8 @@ auto_account_removed (EAccountList *eal,
static void
auto_account_finalized (struct _auto_data *info)
{
- if (info->backend != NULL)
- g_object_unref (info->backend);
+ if (info->session != NULL)
+ g_object_unref (info->session);
if (info->timeout_id)
g_source_remove (info->timeout_id);
g_free (info);
@@ -1293,13 +1273,13 @@ auto_account_commit (struct _auto_data *info)
static void
auto_account_added (EAccountList *eal,
EAccount *ea,
- EMailBackend *backend)
+ EMailSession *session)
{
struct _auto_data *info;
info = g_malloc0 (sizeof (*info));
info->account = ea;
- info->backend = g_object_ref (backend);
+ info->session = g_object_ref (session);
g_object_set_data_full (
G_OBJECT (ea), "mail-autoreceive", info,
(GDestroyNotify) auto_account_finalized);
@@ -1361,15 +1341,14 @@ auto_online (EShell *shell)
/* call to setup initial, and after changes are made to the config */
/* FIXME: Need a cleanup funciton for when object is deactivated */
void
-mail_autoreceive_init (EMailBackend *backend)
+mail_autoreceive_init (EMailSession *session)
{
- EShellBackend *shell_backend;
+ EShell *shell;
EShellSettings *shell_settings;
EAccountList *accounts;
EIterator *iter;
- EShell *shell;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
if (auto_active)
return;
@@ -1379,7 +1358,7 @@ mail_autoreceive_init (EMailBackend *backend)
g_signal_connect (
accounts, "account-added",
- G_CALLBACK (auto_account_added), backend);
+ G_CALLBACK (auto_account_added), session);
g_signal_connect (
accounts, "account-removed",
G_CALLBACK (auto_account_removed), NULL);
@@ -1392,10 +1371,9 @@ mail_autoreceive_init (EMailBackend *backend)
e_iterator_next (iter))
auto_account_added (
accounts, (EAccount *)
- e_iterator_get (iter), backend);
+ e_iterator_get (iter), session);
- shell_backend = E_SHELL_BACKEND (backend);
- shell = e_shell_backend_get_shell (shell_backend);
+ shell = e_shell_get_default ();
shell_settings = e_shell_get_shell_settings (shell);
if (e_shell_settings_get_boolean (
@@ -1404,7 +1382,7 @@ mail_autoreceive_init (EMailBackend *backend)
/* also flush outbox on start */
if (e_shell_get_online (shell))
- mail_send (backend);
+ mail_send (session);
}
g_signal_connect (
@@ -1415,22 +1393,21 @@ mail_autoreceive_init (EMailBackend *backend)
/* We setup the download info's in a hashtable, if we later
* need to build the gui, we insert them in to add them. */
void
-mail_receive_service (EMailBackend *backend,
- CamelService *service)
+mail_receive_service (CamelService *service)
{
struct _send_info *info;
struct _send_data *data;
- EMailSession *session;
+ CamelSession *session;
CamelFolder *local_outbox;
const gchar *uid;
send_info_t type = SEND_INVALID;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
g_return_if_fail (CAMEL_IS_SERVICE (service));
uid = camel_service_get_uid (service);
+ session = camel_service_get_session (service);
- data = setup_send_data (backend);
+ data = setup_send_data (E_MAIL_SESSION (session));
info = g_hash_table_lookup (data->active, uid);
if (info != NULL)
@@ -1443,9 +1420,9 @@ mail_receive_service (EMailBackend *backend,
info = g_malloc0 (sizeof (*info));
info->type = type;
- info->backend = g_object_ref (backend);
info->progress_bar = NULL;
info->status_label = NULL;
+ info->session = g_object_ref (session);
info->service = g_object_ref (service);
info->keep_on_server = get_keep_on_server (service);
info->cancellable = camel_operation_new ();
@@ -1462,8 +1439,6 @@ mail_receive_service (EMailBackend *backend,
g_hash_table_insert (data->active, g_strdup (uid), info);
- session = e_mail_backend_get_session (backend);
-
switch (info->type) {
case SEND_RECEIVE:
mail_fetch_mail (
@@ -1479,9 +1454,10 @@ mail_receive_service (EMailBackend *backend,
/* todo, store the folder in info? */
local_outbox =
e_mail_session_get_local_folder (
- session, E_MAIL_LOCAL_FOLDER_OUTBOX);
+ E_MAIL_SESSION (session),
+ E_MAIL_LOCAL_FOLDER_OUTBOX);
mail_send_queue (
- info->backend,
+ E_MAIL_SESSION (session),
local_outbox,
CAMEL_TRANSPORT (service),
E_FILTER_SOURCE_OUTGOING,
@@ -1499,26 +1475,23 @@ mail_receive_service (EMailBackend *backend,
}
void
-mail_send (EMailBackend *backend)
+mail_send (EMailSession *session)
{
CamelFolder *local_outbox;
CamelService *service;
- EMailSession *session;
EAccount *account;
struct _send_info *info;
struct _send_data *data;
send_info_t type = SEND_INVALID;
gchar *transport_uid;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
-
- session = e_mail_backend_get_session (backend);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
account = e_get_default_transport ();
if (account == NULL || account->transport->url == NULL)
return;
- data = setup_send_data (backend);
+ data = setup_send_data (session);
info = g_hash_table_lookup (data->active, SEND_URI_KEY);
if (info != NULL) {
info->again++;
@@ -1547,9 +1520,9 @@ mail_send (EMailBackend *backend)
info = g_malloc0 (sizeof (*info));
info->type = SEND_SEND;
- info->backend = g_object_ref (backend);
info->progress_bar = NULL;
info->status_label = NULL;
+ info->session = g_object_ref (session);
info->service = g_object_ref (service);
info->keep_on_server = FALSE;
info->cancellable = NULL;
@@ -1562,8 +1535,6 @@ mail_send (EMailBackend *backend)
g_hash_table_insert (data->active, g_strdup (SEND_URI_KEY), info);
- session = e_mail_backend_get_session (backend);
-
/* todo, store the folder in info? */
local_outbox =
e_mail_session_get_local_folder (
@@ -1574,7 +1545,7 @@ mail_send (EMailBackend *backend)
g_return_if_fail (CAMEL_IS_TRANSPORT (service));
mail_send_queue (
- backend, local_outbox,
+ session, local_outbox,
CAMEL_TRANSPORT (service),
E_FILTER_SOURCE_OUTGOING,
info->cancellable,
diff --git a/mail/mail-send-recv.h b/mail/mail-send-recv.h
index 82ea2c21b5..cd11a4a9bb 100644
--- a/mail/mail-send-recv.h
+++ b/mail/mail-send-recv.h
@@ -24,27 +24,24 @@
#define MAIL_SEND_RECV_H
#include <gtk/gtk.h>
-#include <camel/camel.h>
-#include <mail/e-mail-backend.h>
-#include <libedataserver/e-account.h>
+#include <mail/e-mail-session.h>
G_BEGIN_DECLS
/* send/receive all CamelServices */
GtkWidget * mail_send_receive (GtkWindow *parent,
- EMailBackend *backend);
+ EMailSession *session);
GtkWidget * mail_receive (GtkWindow *parent,
- EMailBackend *backend);
+ EMailSession *session);
/* receive a single CamelService */
-void mail_receive_service (EMailBackend *backend,
- CamelService *service);
+void mail_receive_service (CamelService *service);
-void mail_send (EMailBackend *backend);
+void mail_send (EMailSession *session);
/* setup auto receive stuff */
-void mail_autoreceive_init (EMailBackend *backend);
+void mail_autoreceive_init (EMailSession *session);
G_END_DECLS
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 99caa6c0ec..16a2c48dd1 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -189,7 +189,7 @@ vfolder_setup (EMailSession *session,
struct _adduri_msg {
MailMsg base;
- EMailBackend *backend;
+ EMailSession *session;
gchar *uri;
GList *folders;
gint remove;
@@ -200,16 +200,13 @@ vfolder_adduri_desc (struct _adduri_msg *m)
{
CamelStore *store;
CamelService *service;
- EMailSession *session;
const gchar *display_name;
gchar *folder_name;
gchar *description;
gboolean success;
- session = e_mail_backend_get_session (m->backend);
-
success = e_mail_folder_uri_parse (
- CAMEL_SESSION (session), m->uri,
+ CAMEL_SESSION (m->session), m->uri,
&store, &folder_name, NULL);
if (!success)
@@ -234,15 +231,13 @@ vfolder_adduri_exec (struct _adduri_msg *m,
GError **error)
{
GList *l;
- EMailSession *session;
CamelFolder *folder = NULL;
MailFolderCache *folder_cache;
if (vfolder_shutdown)
return;
- session = e_mail_backend_get_session (m->backend);
- folder_cache = e_mail_session_get_folder_cache (session);
+ folder_cache = e_mail_session_get_folder_cache (m->session);
/* we dont try lookup the cache if we are removing it, its no longer there */
@@ -256,7 +251,7 @@ vfolder_adduri_exec (struct _adduri_msg *m,
if (folder == NULL)
folder = e_mail_session_uri_to_folder_sync (
- session, m->uri, 0, cancellable, error);
+ m->session, m->uri, 0, cancellable, error);
if (folder != NULL) {
l = m->folders;
@@ -280,7 +275,7 @@ vfolder_adduri_done (struct _adduri_msg *m)
static void
vfolder_adduri_free (struct _adduri_msg *m)
{
- g_object_unref (m->backend);
+ g_object_unref (m->session);
g_list_foreach (m->folders, (GFunc) g_object_unref, NULL);
g_list_free (m->folders);
g_free (m->uri);
@@ -296,7 +291,7 @@ static MailMsgInfo vfolder_adduri_info = {
/* uri should be a camel uri */
static gint
-vfolder_adduri (EMailBackend *backend,
+vfolder_adduri (EMailSession *session,
const gchar *uri,
GList *folders,
gint remove)
@@ -305,7 +300,7 @@ vfolder_adduri (EMailBackend *backend,
gint id;
m = mail_msg_new (&vfolder_adduri_info);
- m->backend = g_object_ref (backend);
+ m->session = g_object_ref (session);
m->folders = folders;
m->uri = g_strdup (uri);
m->remove = remove;
@@ -339,7 +334,6 @@ folder_is_spethal (CamelStore *store,
/**
* mail_vfolder_add_folder:
- * @backend: an #EMailBackend
* @store: a #CamelStore
* @folder: a folder name
* @remove: whether the folder should be removed or added
@@ -356,12 +350,12 @@ folder_is_spethal (CamelStore *store,
* NOTE: This function must be called from the main thread.
*/
static void
-mail_vfolder_add_folder (EMailBackend *backend,
- CamelStore *store,
+mail_vfolder_add_folder (CamelStore *store,
const gchar *folder_name,
gint remove)
{
- EMailSession *session;
+ CamelService *service;
+ CamelSession *session;
EFilterRule *rule;
const gchar *source;
CamelVeeFolder *vf;
@@ -370,9 +364,13 @@ mail_vfolder_add_folder (EMailBackend *backend,
gint remote;
gchar *uri;
- session = e_mail_backend_get_session (backend);
+ g_return_if_fail (CAMEL_IS_STORE (store));
+ g_return_if_fail (folder_name != NULL);
+
+ service = CAMEL_SERVICE (store);
+ session = camel_service_get_session (service);
+ provider = camel_service_get_provider (service);
- provider = camel_service_get_provider (CAMEL_SERVICE (store));
remote = (provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0;
if (folder_is_spethal (store, folder_name))
@@ -410,8 +408,7 @@ mail_vfolder_add_folder (EMailBackend *backend,
source = NULL;
while (!found && (source = em_vfolder_rule_next_source (
(EMVFolderRule *) rule, source))) {
- found = e_mail_folder_uri_equal (
- CAMEL_SESSION (session), uri, source);
+ found = e_mail_folder_uri_equal (session, uri, source);
}
if (found) {
@@ -429,7 +426,9 @@ done:
G_UNLOCK (vfolder);
if (folders != NULL)
- vfolder_adduri (backend, uri, folders, remove);
+ vfolder_adduri (
+ E_MAIL_SESSION (session),
+ uri, folders, remove);
g_free (uri);
}
@@ -459,7 +458,8 @@ mail_vfolder_delete_folder (EMailBackend *backend,
{
ERuleContext *rule_context;
EFilterRule *rule;
- EMailSession *session;
+ CamelService *service;
+ CamelSession *session;
const gchar *source;
CamelVeeFolder *vf;
GString *changed;
@@ -477,7 +477,9 @@ mail_vfolder_delete_folder (EMailBackend *backend,
g_return_if_fail (mail_in_main_thread ());
- session = e_mail_backend_get_session (backend);
+ service = CAMEL_SERVICE (store);
+ session = camel_service_get_session (service);
+
uri = e_mail_folder_uri_build (store, folder_name);
changed_count = 0;
@@ -502,7 +504,7 @@ mail_vfolder_delete_folder (EMailBackend *backend,
while ((source = em_vfolder_rule_next_source (vf_rule, source))) {
/* Remove all sources that match, ignore changed events though
* because the adduri call above does the work async */
- if (e_mail_folder_uri_equal (CAMEL_SESSION (session), uri, source)) {
+ if (e_mail_folder_uri_equal (session, uri, source)) {
vf = g_hash_table_lookup (
vfolder_hash, rule->name);
@@ -544,9 +546,12 @@ done:
G_UNLOCK (vfolder);
if (changed_count > 0) {
+ EAlertSink *alert_sink;
const gchar *config_dir;
gchar *user, *info;
+ alert_sink = e_mail_backend_get_alert_sink (backend);
+
info = g_strdup_printf (ngettext (
/* Translators: The first %s is name of the affected
* search folder(s), the second %s is the URI of the
@@ -558,8 +563,8 @@ done:
"The following Search Folders\n%s have been modified "
"to account for the deleted folder\n\"%s\".",
changed_count), changed->str, uri);
- e_mail_backend_submit_alert (
- backend, "mail:vfolder-updated", info, NULL);
+ e_alert_submit (
+ alert_sink, "mail:vfolder-updated", info, NULL);
g_free (info);
config_dir = mail_session_get_config_dir ();
@@ -583,6 +588,7 @@ mail_vfolder_rename_folder (CamelStore *store,
EFilterRule *rule;
const gchar *source;
CamelVeeFolder *vf;
+ CamelService *service;
CamelSession *session;
gint changed = 0;
gchar *old_uri;
@@ -601,7 +607,8 @@ mail_vfolder_rename_folder (CamelStore *store,
g_return_if_fail (mail_in_main_thread ());
- session = camel_service_get_session (CAMEL_SERVICE (store));
+ service = CAMEL_SERVICE (store);
+ session = camel_service_get_session (service);
old_uri = e_mail_folder_uri_build (store, old_folder_name);
new_uri = e_mail_folder_uri_build (store, new_folder_name);
@@ -702,7 +709,6 @@ static void
rule_changed (EFilterRule *rule,
CamelFolder *folder)
{
- EMailBackend *backend;
EMailSession *session;
CamelService *service;
GList *sources_uri = NULL;
@@ -711,8 +717,7 @@ rule_changed (EFilterRule *rule,
const gchar *full_name;
full_name = camel_folder_get_full_name (folder);
- backend = em_vfolder_rule_get_backend (EM_VFOLDER_RULE (rule));
- session = e_mail_backend_get_session (backend);
+ session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule));
service = camel_session_get_service (
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
@@ -804,15 +809,13 @@ static void
context_rule_added (ERuleContext *ctx,
EFilterRule *rule)
{
- EMailBackend *backend;
EMailSession *session;
CamelFolder *folder;
CamelService *service;
d(printf("rule added: %s\n", rule->name));
- backend = em_vfolder_rule_get_backend (EM_VFOLDER_RULE (rule));
- session = e_mail_backend_get_session (backend);
+ session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule));
service = camel_session_get_service (
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
@@ -837,15 +840,13 @@ static void
context_rule_removed (ERuleContext *ctx,
EFilterRule *rule)
{
- EMailBackend *backend;
EMailSession *session;
CamelService *service;
gpointer key, folder = NULL;
d(printf("rule removed; %s\n", rule->name));
- backend = em_vfolder_rule_get_backend (EM_VFOLDER_RULE (rule));
- session = e_mail_backend_get_session (backend);
+ session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule));
service = camel_session_get_service (
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
@@ -963,19 +964,17 @@ store_folder_renamed_cb (CamelStore *store,
static void
folder_available_cb (MailFolderCache *cache,
CamelStore *store,
- const gchar *folder_name,
- EMailBackend *backend)
+ const gchar *folder_name)
{
- mail_vfolder_add_folder (backend, store, folder_name, FALSE);
+ mail_vfolder_add_folder (store, folder_name, FALSE);
}
static void
folder_unavailable_cb (MailFolderCache *cache,
CamelStore *store,
- const gchar *folder_name,
- EMailBackend *backend)
+ const gchar *folder_name)
{
- mail_vfolder_add_folder (backend, store, folder_name, TRUE);
+ mail_vfolder_add_folder (store, folder_name, TRUE);
}
static void
@@ -1032,7 +1031,7 @@ vfolder_load_storage (EMailBackend *backend)
g_signal_connect (
vfolder_store, "folder-deleted",
- G_CALLBACK (store_folder_deleted_cb), backend);
+ G_CALLBACK (store_folder_deleted_cb), NULL);
g_signal_connect (
vfolder_store, "folder-renamed",
@@ -1040,7 +1039,7 @@ vfolder_load_storage (EMailBackend *backend)
/* load our rules */
user = g_build_filename (config_dir, "vfolders.xml", NULL);
- context = em_vfolder_context_new (backend);
+ context = em_vfolder_context_new (session);
xmlfile = g_build_filename (EVOLUTION_PRIVDATADIR, "vfoldertypes.xml", NULL);
if (e_rule_context_load ((ERuleContext *) context,
@@ -1077,10 +1076,10 @@ vfolder_load_storage (EMailBackend *backend)
g_signal_connect (
folder_cache, "folder-available",
- G_CALLBACK (folder_available_cb), backend);
+ G_CALLBACK (folder_available_cb), NULL);
g_signal_connect (
folder_cache, "folder-unavailable",
- G_CALLBACK (folder_unavailable_cb), backend);
+ G_CALLBACK (folder_unavailable_cb), NULL);
g_signal_connect (
folder_cache, "folder-deleted",
G_CALLBACK (folder_deleted_cb), backend);
@@ -1090,32 +1089,28 @@ vfolder_load_storage (EMailBackend *backend)
}
void
-vfolder_edit (EShellView *shell_view)
+vfolder_edit (EMailBackend *backend,
+ GtkWindow *parent_window)
{
EShellBackend *shell_backend;
- EShellWindow *shell_window;
- EMailBackend *backend;
GtkWidget *dialog;
const gchar *config_dir;
gchar *filename;
- g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
-
- shell_backend = e_shell_view_get_shell_backend (shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
+ g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (GTK_IS_WINDOW (parent_window));
+ shell_backend = E_SHELL_BACKEND (backend);
config_dir = e_shell_backend_get_config_dir (shell_backend);
filename = g_build_filename (config_dir, "vfolders.xml", NULL);
- backend = E_MAIL_BACKEND (shell_backend);
-
vfolder_load_storage (backend);
dialog = em_vfolder_editor_new (context);
gtk_window_set_title (
GTK_WINDOW (dialog), _("Search Folders"));
gtk_window_set_transient_for (
- GTK_WINDOW (dialog), GTK_WINDOW (shell_window));
+ GTK_WINDOW (dialog), parent_window);
switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
case GTK_RESPONSE_OK:
@@ -1151,21 +1146,20 @@ vfolder_edit_response_cb (GtkWidget *dialog,
}
void
-vfolder_edit_rule (EMailBackend *backend,
- const gchar *folder_uri)
+vfolder_edit_rule (EMailSession *session,
+ const gchar *folder_uri,
+ EAlertSink *alert_sink)
{
GtkWidget *dialog;
GtkWidget *widget;
GtkWidget *container;
EFilterRule *rule = NULL;
EFilterRule *newrule;
- EMailSession *session;
gchar *folder_name = NULL;
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
g_return_if_fail (folder_uri != NULL);
-
- session = e_mail_backend_get_session (backend);
+ g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
e_mail_folder_uri_parse (
CAMEL_SESSION (session), folder_uri,
@@ -1179,8 +1173,9 @@ vfolder_edit_rule (EMailBackend *backend,
if (rule == NULL) {
/* TODO: we should probably just create it ... */
- e_mail_backend_submit_alert (
- backend, "mail:vfolder-notexist", folder_uri, NULL);
+ e_alert_submit (
+ alert_sink, "mail:vfolder-notexist",
+ folder_uri, NULL);
return;
}
@@ -1265,13 +1260,15 @@ new_rule_changed_cb (EFilterRule *rule,
/* clones a filter/search rule into a matching vfolder rule
* (assuming the same system definitions) */
EFilterRule *
-vfolder_clone_rule (EMailBackend *backend,
+vfolder_clone_rule (EMailSession *session,
EFilterRule *in)
{
EFilterRule *rule;
xmlNodePtr xml;
- rule = em_vfolder_rule_new (backend);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
+
+ rule = em_vfolder_rule_new (session);
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 c180106562..efebc17762 100644
--- a/mail/mail-vfolder.h
+++ b/mail/mail-vfolder.h
@@ -31,10 +31,12 @@
#include <shell/e-shell-view.h>
void vfolder_load_storage (EMailBackend *backend);
-void vfolder_edit (EShellView *shell_view);
-void vfolder_edit_rule (EMailBackend *backend,
- const gchar *folder_uri);
-EFilterRule * vfolder_clone_rule (EMailBackend *backend,
+void vfolder_edit (EMailBackend *backend,
+ GtkWindow *parent_window);
+void vfolder_edit_rule (EMailSession *session,
+ const gchar *folder_uri,
+ EAlertSink *alert_sink);
+EFilterRule * vfolder_clone_rule (EMailSession *session,
EFilterRule *in);
void vfolder_gui_add_rule (EMVFolderRule *rule);
void vfolder_gui_add_from_message (EMailSession *session,
diff --git a/mail/message-list.c b/mail/message-list.c
index 1eb2e968a6..79b6875328 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -107,7 +107,7 @@ struct _MLSelection {
struct _MessageListPrivate {
GtkWidget *invisible; /* 4 selection */
- EMailBackend *backend;
+ EMailSession *session;
struct _MLSelection clipboard;
gboolean destroyed;
@@ -132,9 +132,9 @@ struct _MessageListPrivate {
enum {
PROP_0,
- PROP_BACKEND,
PROP_COPY_TARGET_LIST,
- PROP_PASTE_TARGET_LIST
+ PROP_PASTE_TARGET_LIST,
+ PROP_SESSION
};
/* Forward Declarations */
@@ -1518,10 +1518,10 @@ ml_get_label_list_store (MessageList *message_list)
{
EShell *shell;
EShellSettings *shell_settings;
- EMailBackend *backend;
- backend = message_list_get_backend (message_list);
- shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+ /* FIXME This should be a GObject property on MessageList. */
+
+ shell = e_shell_get_default ();
shell_settings = e_shell_get_shell_settings (shell);
return e_shell_settings_get_object (
@@ -2237,7 +2237,6 @@ ml_selection_received (GtkWidget *widget,
guint time,
MessageList *message_list)
{
- EMailBackend *backend;
EMailSession *session;
GdkAtom target;
@@ -2248,8 +2247,7 @@ ml_selection_received (GtkWidget *widget,
return;
}
- backend = message_list_get_backend (message_list);
- session = e_mail_backend_get_session (backend);
+ session = message_list_get_session (message_list);
/* FIXME Not passing a GCancellable or GError here. */
em_utils_selection_get_uidlist (
@@ -2325,11 +2323,9 @@ ml_drop_async_exec (struct _drop_msg *m,
GCancellable *cancellable,
GError **error)
{
- EMailBackend *backend;
EMailSession *session;
- backend = message_list_get_backend (m->message_list);
- session = e_mail_backend_get_session (backend);
+ session = message_list_get_session (m->message_list);
switch (m->info) {
case DND_X_UID_LIST:
@@ -2541,18 +2537,14 @@ ml_tree_sorting_changed (ETreeTableAdapter *adapter,
return FALSE;
}
-/*
- * GObject::init
- */
-
static void
-message_list_set_backend (MessageList *message_list,
- EMailBackend *backend)
+message_list_set_session (MessageList *message_list,
+ EMailSession *session)
{
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (message_list->priv->backend == NULL);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (message_list->priv->session == NULL);
- message_list->priv->backend = g_object_ref (backend);
+ message_list->priv->session = g_object_ref (session);
}
static void
@@ -2615,8 +2607,8 @@ message_list_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- message_list_set_backend (
+ case PROP_SESSION:
+ message_list_set_session (
MESSAGE_LIST (object),
g_value_get_object (value));
return;
@@ -2632,12 +2624,6 @@ message_list_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- g_value_set_object (
- value, message_list_get_backend (
- MESSAGE_LIST (object)));
- return;
-
case PROP_COPY_TARGET_LIST:
g_value_set_boxed (
value, message_list_get_copy_target_list (
@@ -2649,6 +2635,12 @@ message_list_get_property (GObject *object,
value, message_list_get_paste_target_list (
MESSAGE_LIST (object)));
return;
+
+ case PROP_SESSION:
+ g_value_set_object (
+ value, message_list_get_session (
+ MESSAGE_LIST (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -2662,9 +2654,9 @@ message_list_dispose (GObject *object)
priv = message_list->priv;
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
if (priv->copy_target_list != NULL) {
@@ -2792,17 +2784,6 @@ message_list_class_init (MessageListClass *class)
class->message_list_built = NULL;
- g_object_class_install_property (
- object_class,
- PROP_BACKEND,
- g_param_spec_object (
- "backend",
- "Mail Backend",
- "The mail backend",
- E_TYPE_MAIL_BACKEND,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
/* Inherited from ESelectableInterface */
g_object_class_override_property (
object_class,
@@ -2815,6 +2796,17 @@ message_list_class_init (MessageListClass *class)
PROP_PASTE_TARGET_LIST,
"paste-target-list");
+ g_object_class_install_property (
+ object_class,
+ PROP_SESSION,
+ g_param_spec_object (
+ "session",
+ "Mail Session",
+ "The mail session",
+ E_TYPE_MAIL_SESSION,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
message_list_signals[MESSAGE_SELECTED] =
g_signal_new ("message_selected",
MESSAGE_LIST_TYPE,
@@ -2955,27 +2947,27 @@ message_list_construct (MessageList *message_list)
* Returns a new message-list widget.
**/
GtkWidget *
-message_list_new (EMailBackend *backend)
+message_list_new (EMailSession *session)
{
GtkWidget *message_list;
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
message_list = g_object_new (
message_list_get_type (),
- "backend", backend, NULL);
+ "session", session, NULL);
message_list_construct (MESSAGE_LIST (message_list));
return message_list;
}
-EMailBackend *
-message_list_get_backend (MessageList *message_list)
+EMailSession *
+message_list_get_session (MessageList *message_list)
{
g_return_val_if_fail (IS_MESSAGE_LIST (message_list), NULL);
- return message_list->priv->backend;
+ return message_list->priv->session;
}
static void
diff --git a/mail/message-list.h b/mail/message-list.h
index d0c8a55303..ffd3a1364c 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -27,7 +27,7 @@
#include <camel/camel.h>
#include <table/e-tree.h>
-#include <mail/e-mail-backend.h>
+#include <mail/e-mail-session.h>
/* Standard GObject macros */
#define MESSAGE_LIST_TYPE \
@@ -178,8 +178,8 @@ typedef enum {
} MessageListSelectDirection;
GType message_list_get_type (void);
-GtkWidget * message_list_new (EMailBackend *backend);
-EMailBackend * message_list_get_backend (MessageList *message_list);
+GtkWidget * message_list_new (EMailSession *session);
+EMailSession * message_list_get_session (MessageList *message_list);
void message_list_set_folder (MessageList *message_list,
CamelFolder *folder,
gboolean outgoing);