aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-10-17 21:40:36 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-19 00:32:37 +0800
commit35e55a8d6e3455efa92abd669680d191e3e4cbac (patch)
tree303d479aaaf12538d73f611f52db1157da64549b /mail
parentb674a37a381d0328a7273bafa62d80203c8cdf70 (diff)
downloadgsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.tar
gsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.tar.gz
gsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.tar.bz2
gsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.tar.lz
gsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.tar.xz
gsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.tar.zst
gsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.zip
Send errors to an EAlertSink instead of the task bar.
This marks the end of unintrusive error dialogs, which were too unintrusive. We now show errors directly in the main window using the EAlert / EAlertSink framework.
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-backend.c66
-rw-r--r--mail/e-mail-backend.h3
-rw-r--r--mail/e-mail-reader.c6
-rw-r--r--mail/e-mail-session.c103
-rw-r--r--mail/e-mail-session.h3
-rw-r--r--mail/e-mail-store.c44
-rw-r--r--mail/e-mail-store.h3
-rw-r--r--mail/em-folder-properties.c7
-rw-r--r--mail/em-folder-tree-model.c26
-rw-r--r--mail/em-folder-utils.c140
-rw-r--r--mail/em-folder-utils.h7
-rw-r--r--mail/em-utils.c56
-rw-r--r--mail/em-utils.h6
-rw-r--r--mail/mail-autofilter.c15
-rw-r--r--mail/mail-autofilter.h5
-rw-r--r--mail/mail-config.c32
-rw-r--r--mail/mail-config.h7
-rw-r--r--mail/mail-folder-cache.c21
-rw-r--r--mail/mail-folder-cache.h5
-rw-r--r--mail/mail-mt.c92
-rw-r--r--mail/mail-mt.h1
-rw-r--r--mail/mail-ops.c1
-rw-r--r--mail/mail-send-recv.c10
-rw-r--r--mail/mail-vfolder.c101
-rw-r--r--mail/mail-vfolder.h6
25 files changed, 424 insertions, 342 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index dd34737272..0ecae4856c 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -322,10 +322,7 @@ mail_backend_folder_deleted_cb (MailFolderCache *folder_cache,
const gchar *uri,
EMailBackend *backend)
{
- EMailSession *session;
-
- session = e_mail_backend_get_session (backend);
- mail_filter_delete_uri (session, store, uri);
+ mail_filter_delete_uri (backend, store, uri);
}
static void
@@ -335,10 +332,7 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
const gchar *new_uri,
EMailBackend *backend)
{
- EMailSession *session;
-
- session = e_mail_backend_get_session (backend);
- mail_filter_rename_uri (session, store, old_uri, new_uri);
+ mail_filter_rename_uri (backend, store, old_uri, new_uri);
}
static void
@@ -406,6 +400,8 @@ mail_backend_idle_cb (EMailBackend *backend)
e_mail_store_init (session, data_dir);
+ vfolder_load_storage (backend);
+
return FALSE;
}
@@ -449,8 +445,8 @@ mail_backend_constructed (GObject *object)
EMailBackendPrivate *priv;
EShell *shell;
EShellBackend *shell_backend;
- MailFolderCache *folder_cache;
EMFolderTreeModel *folder_tree_model;
+ MailFolderCache *folder_cache;
priv = E_MAIL_BACKEND_GET_PRIVATE (object);
@@ -463,6 +459,7 @@ mail_backend_constructed (GObject *object)
camel_provider_init ();
priv->session = e_mail_session_new ();
+ folder_cache = e_mail_session_get_folder_cache (priv->session);
g_object_bind_property (
shell, "online",
@@ -477,8 +474,6 @@ mail_backend_constructed (GObject *object)
folder_tree_model = em_folder_tree_model_get_default ();
em_folder_tree_model_set_session (folder_tree_model, priv->session);
- folder_cache = mail_folder_cache_get_default ();
-
g_signal_connect (
shell, "prepare-for-offline",
G_CALLBACK (mail_backend_prepare_for_offline_cb),
@@ -513,7 +508,7 @@ mail_backend_constructed (GObject *object)
folder_cache, "folder-changed",
G_CALLBACK (mail_backend_folder_changed_cb), shell);
- mail_config_init (CAMEL_SESSION (priv->session));
+ mail_config_init (priv->session);
mail_msg_init ();
/* Defer initializing CamelStores until after the main loop
@@ -591,3 +586,50 @@ e_mail_backend_empty_trash_policy_decision (EMailBackend *backend)
return class->empty_trash_policy_decision (backend);
}
+
+void
+e_mail_backend_submit_alert (EMailBackend *backend,
+ const gchar *tag,
+ ...)
+{
+ EShell *shell;
+ EShellView *shell_view;
+ EShellBackend *shell_backend;
+ EShellContent *shell_content;
+ EShellWindow *shell_window = NULL;
+ EShellBackendClass *class;
+ GList *list, *iter;
+ va_list va;
+
+ /* 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. */
+
+ g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (tag != NULL);
+
+ shell_backend = E_SHELL_BACKEND (backend);
+ shell = e_shell_backend_get_shell (shell_backend);
+
+ /* Find the most recently used EShellWindow. */
+ list = e_shell_get_watched_windows (shell);
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ if (E_IS_SHELL_WINDOW (iter->data)) {
+ shell_window = E_SHELL_WINDOW (iter->data);
+ break;
+ }
+ }
+
+ /* If we can't find an EShellWindow then... well, screw it. */
+ if (shell_window == NULL)
+ return;
+
+ 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 (GTK_WIDGET (shell_content), tag, va);
+ va_end (va);
+}
diff --git a/mail/e-mail-backend.h b/mail/e-mail-backend.h
index 18fdf885ca..6d425197f3 100644
--- a/mail/e-mail-backend.h
+++ b/mail/e-mail-backend.h
@@ -75,6 +75,9 @@ 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-reader.c b/mail/e-mail-reader.c
index 83dc3f569a..2b9c832315 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -1556,9 +1556,6 @@ action_search_folder_recipient_cb (GtkAction *action,
if (curl->path != NULL && *curl->path != '\0') {
CamelInternetAddress *inet_addr;
- /* Ensure vfolder is running. */
- vfolder_load_storage (session);
-
inet_addr = camel_internet_address_new ();
camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
vfolder_gui_add_from_address (
@@ -1600,9 +1597,6 @@ action_search_folder_sender_cb (GtkAction *action,
if (curl->path != NULL && *curl->path != '\0') {
CamelInternetAddress *inet_addr;
- /* Ensure vfolder is running. */
- vfolder_load_storage (session);
-
inet_addr = camel_internet_address_new ();
camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
vfolder_gui_add_from_address (
diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c
index 14213bf6e4..1d9b44f02a 100644
--- a/mail/e-mail-session.c
+++ b/mail/e-mail-session.c
@@ -57,7 +57,6 @@
#include "em-filter-rule.h"
#include "em-utils.h"
#include "mail-config.h"
-#include "mail-folder-cache.h"
#include "mail-mt.h"
#include "mail-ops.h"
#include "mail-send-recv.h"
@@ -73,6 +72,8 @@ static guint session_gconf_proxy_id;
typedef struct _AsyncContext AsyncContext;
struct _EMailSessionPrivate {
+ MailFolderCache *folder_cache;
+
FILE *filter_logfile;
GList *junk_plugins;
};
@@ -86,6 +87,11 @@ struct _AsyncContext {
CamelFolder *folder;
};
+enum {
+ PROP_0,
+ PROP_FOLDER_CACHE
+};
+
static gchar *mail_data_dir;
static gchar *mail_config_dir;
@@ -187,31 +193,19 @@ user_message_exec (struct _user_message_msg *m)
user_message_dialog, "allow_shrink", TRUE,
"allow_grow", TRUE, NULL);
- /* Use the number of dialog buttons as a heuristic for whether to
- * emit a status bar message or present the dialog immediately, the
- * thought being if there's more than one button then something is
- * probably blocked until the user responds. */
- if (e_alert_dialog_count_buttons (user_message_dialog) > 1) {
- if (m->ismain) {
- gint response;
-
- response = gtk_dialog_run (user_message_dialog);
- user_message_response (
- user_message_dialog, response, m);
- } else {
- g_signal_connect (
- user_message_dialog, "response",
- G_CALLBACK (user_message_response), m);
- gtk_widget_show (user_message_dialog);
- }
+ /* XXX This is a case where we need to be able to construct
+ * custom EAlerts without a predefined XML definition. */
+ if (m->ismain) {
+ gint response;
+
+ response = gtk_dialog_run (user_message_dialog);
+ user_message_response (
+ user_message_dialog, response, m);
} else {
g_signal_connect (
user_message_dialog, "response",
- G_CALLBACK (user_message_response_free), m);
- g_object_set_data (
- user_message_dialog, "response-handled",
- GINT_TO_POINTER (TRUE));
- em_utils_show_error_silent (user_message_dialog);
+ G_CALLBACK (user_message_response), m);
+ gtk_widget_show (user_message_dialog);
}
}
@@ -520,6 +514,40 @@ mail_session_check_junk_notify (GConfClient *gconf,
}
static void
+mail_session_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_FOLDER_CACHE:
+ g_value_set_object (
+ value,
+ e_mail_session_get_folder_cache (
+ E_MAIL_SESSION (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_session_dispose (GObject *object)
+{
+ EMailSessionPrivate *priv;
+
+ priv = E_MAIL_SESSION_GET_PRIVATE (object);
+
+ if (priv->folder_cache != NULL) {
+ g_object_unref (priv->folder_cache);
+ priv->folder_cache = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_mail_session_parent_class)->dispose (object);
+}
+
+static void
mail_session_finalize (GObject *object)
{
GConfClient *client;
@@ -885,6 +913,8 @@ e_mail_session_class_init (EMailSessionClass *class)
g_type_class_add_private (class, sizeof (EMailSessionPrivate));
object_class = G_OBJECT_CLASS (class);
+ object_class->get_property = mail_session_get_property;
+ object_class->dispose = mail_session_dispose;
object_class->finalize = mail_session_finalize;
session_class = CAMEL_SESSION_CLASS (class);
@@ -897,6 +927,16 @@ e_mail_session_class_init (EMailSessionClass *class)
session_class->thread_msg_free = mail_session_thread_msg_free;
session_class->thread_status = mail_session_thread_status;
session_class->forward_to = mail_session_forward_to;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FOLDER_CACHE,
+ g_param_spec_object (
+ "folder-cache",
+ NULL,
+ NULL,
+ MAIL_TYPE_FOLDER_CACHE,
+ G_PARAM_READABLE));
}
static void
@@ -905,6 +945,7 @@ e_mail_session_init (EMailSession *session)
GConfClient *client;
session->priv = E_MAIL_SESSION_GET_PRIVATE (session);
+ session->priv->folder_cache = mail_folder_cache_new ();
/* Initialize the EAccount setup. */
e_account_writable (NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD);
@@ -927,7 +968,7 @@ e_mail_session_init (EMailSession *session)
session, NULL, NULL);
CAMEL_SESSION (session)->junk_plugin = NULL;
- mail_config_reload_junk_headers (CAMEL_SESSION (session));
+ mail_config_reload_junk_headers (session);
init_socks_proxy (CAMEL_SESSION (session));
@@ -940,6 +981,14 @@ e_mail_session_new (void)
return g_object_new (E_TYPE_MAIL_SESSION, NULL);
}
+MailFolderCache *
+e_mail_session_get_folder_cache (EMailSession *session)
+{
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
+
+ return session->priv->folder_cache;
+}
+
static void
mail_session_get_inbox_thread (GSimpleAsyncResult *simple,
EMailSession *session,
@@ -1236,10 +1285,10 @@ e_mail_session_uri_to_folder_sync (EMailSession *session,
}
if (folder != NULL) {
- MailFolderCache *cache;
+ MailFolderCache *folder_cache;
- cache = mail_folder_cache_get_default ();
- mail_folder_cache_note_folder (cache, folder);
+ folder_cache = e_mail_session_get_folder_cache (session);
+ mail_folder_cache_note_folder (folder_cache, folder);
}
camel_url_free (url);
diff --git a/mail/e-mail-session.h b/mail/e-mail-session.h
index 71a5d73eb4..f9cab970cc 100644
--- a/mail/e-mail-session.h
+++ b/mail/e-mail-session.h
@@ -26,6 +26,7 @@
#define E_MAIL_SESSION_H
#include <camel/camel.h>
+#include <mail/mail-folder-cache.h>
/* Standard GObject macros */
#define E_TYPE_MAIL_SESSION \
@@ -63,6 +64,8 @@ struct _EMailSessionClass {
GType e_mail_session_get_type (void);
EMailSession * e_mail_session_new (void);
+MailFolderCache *
+ e_mail_session_get_folder_cache (EMailSession *session);
CamelFolder * e_mail_session_get_inbox_sync (EMailSession *session,
const gchar *service_uri,
GCancellable *cancellable,
diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c
index ef997d2fe2..b23e6f2121 100644
--- a/mail/e-mail-store.c
+++ b/mail/e-mail-store.c
@@ -35,7 +35,8 @@
typedef struct _StoreInfo StoreInfo;
-typedef void (*AddStoreCallback) (CamelStore *store,
+typedef void (*AddStoreCallback) (MailFolderCache *folder_cache,
+ CamelStore *store,
CamelFolderInfo *info,
StoreInfo *store_info);
@@ -132,25 +133,25 @@ store_table_free (StoreInfo *store_info)
}
static gboolean
-mail_store_note_store_cb (CamelStore *store,
+mail_store_note_store_cb (MailFolderCache *folder_cache,
+ CamelStore *store,
CamelFolderInfo *info,
gpointer user_data)
{
StoreInfo *store_info = user_data;
if (store_info->callback != NULL)
- store_info->callback (store, info, store_info);
+ store_info->callback (
+ folder_cache, store, info, store_info);
if (!store_info->removed) {
/* This keeps message counters up-to-date. */
if (store_info->vtrash != NULL)
mail_folder_cache_note_folder (
- mail_folder_cache_get_default (),
- store_info->vtrash);
+ folder_cache, store_info->vtrash);
if (store_info->vjunk != NULL)
mail_folder_cache_note_folder (
- mail_folder_cache_get_default (),
- store_info->vjunk);
+ folder_cache, store_info->vjunk);
}
store_info_unref (store_info);
@@ -165,11 +166,13 @@ mail_store_add (EMailSession *session,
AddStoreCallback callback)
{
EMFolderTreeModel *default_model;
+ MailFolderCache *folder_cache;
StoreInfo *store_info;
g_return_if_fail (store_table != NULL);
default_model = em_folder_tree_model_get_default ();
+ folder_cache = e_mail_session_get_folder_cache (session);
store_info = store_info_new (store, display_name);
store_info->callback = callback;
@@ -180,14 +183,13 @@ mail_store_add (EMailSession *session,
default_model, store, store_info->display_name);
mail_folder_cache_note_store (
- mail_folder_cache_get_default (),
- CAMEL_SESSION (session), store, NULL,
- mail_store_note_store_cb,
- store_info_ref (store_info));
+ folder_cache, CAMEL_SESSION (session), store, NULL,
+ mail_store_note_store_cb, store_info_ref (store_info));
}
static void
-mail_store_add_local_done_cb (CamelStore *store,
+mail_store_add_local_done_cb (MailFolderCache *folder_cache,
+ CamelStore *store,
CamelFolderInfo *info,
StoreInfo *store_info)
{
@@ -196,9 +198,9 @@ mail_store_add_local_done_cb (CamelStore *store,
for (ii = 0; ii < E_MAIL_NUM_LOCAL_FOLDERS; ii++) {
folder = e_mail_local_get_folder (ii);
- if (folder != NULL)
- mail_folder_cache_note_folder (
- mail_folder_cache_get_default (), folder);
+ if (folder == NULL)
+ continue;
+ mail_folder_cache_note_folder (folder_cache, folder);
}
}
@@ -337,10 +339,13 @@ fail:
}
void
-e_mail_store_remove (CamelStore *store)
+e_mail_store_remove (EMailSession *session,
+ CamelStore *store)
{
+ MailFolderCache *folder_cache;
EMFolderTreeModel *default_model;
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
g_return_if_fail (CAMEL_IS_STORE (store));
g_return_if_fail (store_table != NULL);
@@ -355,8 +360,9 @@ e_mail_store_remove (CamelStore *store)
g_object_ref (store);
g_hash_table_remove (store_table, store);
- mail_folder_cache_note_store_remove (
- mail_folder_cache_get_default (), store);
+
+ folder_cache = e_mail_session_get_folder_cache (session);
+ mail_folder_cache_note_store_remove (folder_cache, store);
default_model = em_folder_tree_model_get_default ();
em_folder_tree_model_remove_store (default_model, store);
@@ -389,7 +395,7 @@ e_mail_store_remove_by_uri (EMailSession *session,
if (service == NULL)
return;
- e_mail_store_remove (CAMEL_STORE (service));
+ e_mail_store_remove (session, CAMEL_STORE (service));
g_object_unref (service);
}
diff --git a/mail/e-mail-store.h b/mail/e-mail-store.h
index 8def4b8e73..b120d14aef 100644
--- a/mail/e-mail-store.h
+++ b/mail/e-mail-store.h
@@ -36,7 +36,8 @@ void e_mail_store_add (EMailSession *session,
CamelStore * e_mail_store_add_by_uri (EMailSession *session,
const gchar *uri,
const gchar *display_name);
-void e_mail_store_remove (CamelStore *store);
+void e_mail_store_remove (EMailSession *session,
+ CamelStore *store);
void e_mail_store_remove_by_uri (EMailSession *session,
const gchar *uri);
void e_mail_store_foreach (GHFunc func,
diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c
index 525a7ffefa..d802aeb885 100644
--- a/mail/em-folder-properties.c
+++ b/mail/em-folder-properties.c
@@ -349,13 +349,16 @@ em_folder_properties_show (EShellView *shell_view,
const gchar *uri)
{
EShellBackend *shell_backend;
+ EMailBackend *backend;
EMailSession *session;
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
g_return_if_fail (uri != NULL);
shell_backend = e_shell_view_get_shell_backend (shell_view);
- session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
+
+ backend = E_MAIL_BACKEND (shell_backend);
+ session = e_mail_backend_get_session (backend);
/* HACK: its the old behaviour, not very 'neat' but it works */
if (!strncmp (uri, "vfolder:", 8)) {
@@ -367,7 +370,7 @@ em_folder_properties_show (EShellView *shell_view,
|| strcmp (url->fragment, CAMEL_UNMATCHED_NAME) != 0) {
if (url)
camel_url_free (url);
- vfolder_edit_rule (uri);
+ vfolder_edit_rule (backend, uri);
return;
}
if (url != NULL)
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 5b22bd0f9d..9da5711cf0 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -556,11 +556,6 @@ folder_tree_model_init (EMFolderTreeModel *model)
model->priv->account_added_id = g_signal_connect (
model->priv->accounts, "account-added",
G_CALLBACK (account_added_cb), model);
-
- g_signal_connect_swapped (
- mail_folder_cache_get_default (),
- "folder-unread-updated",
- G_CALLBACK (folder_tree_model_set_unread_count), model);
}
GType
@@ -665,6 +660,20 @@ em_folder_tree_model_set_session (EMFolderTreeModel *model,
model->priv->session = session;
+ /* FIXME Technically we should be disconnecting this signal
+ * when replacing an old session with a new session,
+ * but at present this function is only called once. */
+ if (session != NULL) {
+ MailFolderCache *folder_cache;
+
+ folder_cache = e_mail_session_get_folder_cache (session);
+
+ g_signal_connect_swapped (
+ folder_cache, "folder-unread-updated",
+ G_CALLBACK (folder_tree_model_set_unread_count),
+ model);
+ }
+
g_object_notify (G_OBJECT (model), "session");
}
@@ -677,6 +686,8 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
{
GtkTreeRowReference *uri_row, *path_row;
GtkTreeStore *tree_store;
+ MailFolderCache *folder_cache;
+ EMailSession *session;
guint unread;
GtkTreePath *path;
GtkTreeIter sub;
@@ -696,6 +707,9 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
tree_store = GTK_TREE_STORE (model);
+ session = em_folder_tree_model_get_session (model);
+ folder_cache = e_mail_session_get_folder_cache (session);
+
if (!fully_loaded)
load = (fi->child == NULL) && !(fi->flags &
(CAMEL_FOLDER_NOCHILDREN | CAMEL_FOLDER_NOINFERIORS));
@@ -717,7 +731,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
* be functionised. */
unread = fi->unread;
if (mail_folder_cache_get_folder_from_uri (
- mail_folder_cache_get_default (), fi->uri, &folder) && folder) {
+ folder_cache, fi->uri, &folder) && folder) {
is_drafts = em_utils_folder_is_drafts (folder, fi->uri);
if (is_drafts || em_utils_folder_is_outbox (folder, fi->uri)) {
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index e966f2b0cc..cae91af14f 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -281,10 +281,11 @@ struct _copy_folder_data {
};
static void
-emfu_copy_folder_selected (EMailSession *session,
+emfu_copy_folder_selected (EMailBackend *backend,
const gchar *uri,
gpointer data)
{
+ EMailSession *session;
struct _copy_folder_data *cfd = data;
CamelStore *fromstore = NULL, *tostore = NULL;
CamelStore *local_store;
@@ -298,36 +299,34 @@ emfu_copy_folder_selected (EMailSession *session,
}
local_store = e_mail_local_get_store ();
+ session = e_mail_backend_get_session (backend);
fromstore = camel_session_get_store (
CAMEL_SESSION (session), cfd->fi->uri, &local_error);
if (fromstore == NULL) {
- e_alert_run_dialog_for_args (
- e_shell_get_active_window (NULL),
- cfd->delete ? "mail:no-move-folder-notexist" :
- "mail:no-copy-folder-notexist",
+ e_mail_backend_submit_alert (
+ backend, cfd->delete ?
+ "mail:no-move-folder-notexist" :
+ "mail:no-copy-folder-notexist",
cfd->fi->full_name, uri,
local_error->message, NULL);
goto fail;
}
if (cfd->delete && fromstore == local_store && emfu_is_special_local_folder (cfd->fi->full_name)) {
- GtkWidget *w;
-
- w = e_alert_dialog_new_for_args (
- e_shell_get_active_window (NULL), "mail:no-rename-special-folder",
+ e_mail_backend_submit_alert (
+ backend, "mail:no-rename-special-folder",
cfd->fi->full_name, NULL);
- em_utils_show_error_silent (w);
goto fail;
}
tostore = camel_session_get_store (
CAMEL_SESSION (session), uri, &local_error);
if (tostore == NULL) {
- e_alert_run_dialog_for_args (
- e_shell_get_active_window (NULL),
- cfd->delete ? "mail:no-move-folder-to-notexist" :
- "mail:no-copy-folder-to-notexist",
+ e_mail_backend_submit_alert (
+ backend, cfd->delete ?
+ "mail:no-move-folder-to-notexist" :
+ "mail:no-copy-folder-to-notexist",
cfd->fi->full_name, uri,
local_error->message, NULL);
goto fail;
@@ -341,7 +340,8 @@ emfu_copy_folder_selected (EMailSession *session,
if (tobase == NULL)
tobase = "";
- em_folder_utils_copy_folders (fromstore, cfd->fi->full_name, tostore, tobase, cfd->delete);
+ em_folder_utils_copy_folders (
+ fromstore, cfd->fi->full_name, tostore, tobase, cfd->delete);
camel_url_free (url);
fail:
@@ -389,18 +389,22 @@ emfu_copy_folder_exclude (EMFolderTree *tree, GtkTreeModel *model, GtkTreeIter *
/* FIXME: these functions must be documented */
void
em_folder_utils_copy_folder (GtkWindow *parent,
- EMailSession *session,
+ EMailBackend *backend,
CamelFolderInfo *folderinfo,
gint delete)
{
GtkWidget *dialog;
EMFolderTree *emft;
+ EMailSession *session;
const gchar *label;
const gchar *title;
struct _copy_folder_data *cfd;
+ g_return_if_fail (E_IS_MAIL_BACKEND (backend));
g_return_if_fail (folderinfo != NULL);
+ session = e_mail_backend_get_session (backend);
+
cfd = g_malloc (sizeof (*cfd));
cfd->fi = folderinfo;
cfd->delete = delete;
@@ -425,94 +429,113 @@ em_folder_utils_copy_folder (GtkWindow *parent,
uri = em_folder_selector_get_selected_uri (
EM_FOLDER_SELECTOR (dialog));
- emfu_copy_folder_selected (session, uri, cfd);
+ emfu_copy_folder_selected (backend, uri, cfd);
}
gtk_widget_destroy (dialog);
}
+typedef struct {
+ EMailBackend *backend;
+ GtkWidget *dialog;
+} DeleteFolderData;
+
static void
-emfu_delete_done (CamelFolder *folder, gboolean removed, GError **error, gpointer data)
+emfu_delete_done (CamelFolder *folder,
+ gboolean removed,
+ GError **error,
+ gpointer user_data)
{
- GtkWidget *dialog = data;
+ DeleteFolderData *data = user_data;
if (error != NULL && *error != NULL) {
- GtkWidget *w;
-
- w = e_alert_dialog_new_for_args (
- e_shell_get_active_window (NULL),
+ e_mail_backend_submit_alert (
+ data->backend,
"mail:no-delete-folder",
camel_folder_get_full_name (folder),
(*error)->message, NULL);
- em_utils_show_error_silent (w);
g_clear_error (error);
}
- if (dialog)
- gtk_widget_destroy (dialog);
-}
-
-static void
-emfu_delete_response (GtkWidget *dialog, gint response, gpointer data)
-{
- if (response == GTK_RESPONSE_OK) {
- /* disable dialog until operation finishes */
- gtk_widget_set_sensitive (dialog, FALSE);
-
- mail_remove_folder (g_object_get_data ((GObject *) dialog, "folder"), emfu_delete_done, dialog);
- } else {
- gtk_widget_destroy (dialog);
- }
+ g_object_unref (data->backend);
+ gtk_widget_destroy (data->dialog);
+ g_slice_free (DeleteFolderData, data);
}
/* FIXME: these functions must be documented */
void
-em_folder_utils_delete_folder (CamelFolder *folder)
+em_folder_utils_delete_folder (EMailBackend *backend,
+ CamelFolder *folder)
{
CamelStore *local_store;
CamelStore *parent_store;
+ EMailSession *session;
+ MailFolderCache *folder_cache;
GtkWindow *parent = e_shell_get_active_window (NULL);
GtkWidget *dialog;
const gchar *full_name;
gint flags = 0;
+ g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
+
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
local_store = e_mail_local_get_store ();
+ session = e_mail_backend_get_session (backend);
+ folder_cache = e_mail_session_get_folder_cache (session);
if (parent_store == local_store && emfu_is_special_local_folder (full_name)) {
- dialog = e_alert_dialog_new_for_args (
- parent, "mail:no-delete-special-folder",
+ e_mail_backend_submit_alert (
+ backend, "mail:no-delete-special-folder",
full_name, NULL);
- em_utils_show_error_silent (dialog);
return;
}
- if (mail_folder_cache_get_folder_info_flags (mail_folder_cache_get_default (), folder, &flags) && (flags & CAMEL_FOLDER_SYSTEM))
- {
- e_alert_run_dialog_for_args (
- parent,"mail:no-delete-special-folder",
+ if (mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags) && (flags & CAMEL_FOLDER_SYSTEM)) {
+ e_mail_backend_submit_alert (
+ backend, "mail:no-delete-special-folder",
camel_folder_get_name (folder), NULL);
return;
}
g_object_ref (folder);
- if (mail_folder_cache_get_folder_info_flags (mail_folder_cache_get_default (), folder, &flags) && (flags & CAMEL_FOLDER_CHILDREN)) {
- dialog = e_alert_dialog_new_for_args (parent,
- (parent_store && CAMEL_IS_VEE_STORE(parent_store))?"mail:ask-delete-vfolder":"mail:ask-delete-folder",
- full_name, NULL);
+ if (mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags) && (flags & CAMEL_FOLDER_CHILDREN)) {
+ if (parent_store && CAMEL_IS_VEE_STORE (parent_store))
+ dialog = e_alert_dialog_new_for_args (
+ parent, "mail:ask-delete-vfolder",
+ full_name, NULL);
+ else
+ dialog = e_alert_dialog_new_for_args (
+ parent, "mail:ask-delete-folder",
+ full_name, NULL);
}
else {
- dialog = e_alert_dialog_new_for_args (parent,
- (parent_store && CAMEL_IS_VEE_STORE(parent_store))?"mail:ask-delete-vfolder-nochild":"mail:ask-delete-folder-nochild",
- full_name, NULL);
+ if (parent_store && CAMEL_IS_VEE_STORE (parent_store))
+ dialog = e_alert_dialog_new_for_args (
+ parent, "mail:ask-delete-vfolder-nochild",
+ full_name, NULL);
+ else
+ dialog = e_alert_dialog_new_for_args (
+ parent, "mail:ask-delete-folder-nochild",
+ full_name, NULL);
}
- g_object_set_data_full ((GObject *) dialog, "folder", folder, g_object_unref);
- g_signal_connect (dialog, "response", G_CALLBACK (emfu_delete_response), NULL);
- gtk_widget_show (dialog);
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
+ DeleteFolderData *data;
+
+ /* disable dialog until operation finishes */
+ gtk_widget_set_sensitive (dialog, FALSE);
+
+ data = g_slice_new0 (DeleteFolderData);
+ data->backend = g_object_ref (backend);
+ data->dialog = dialog;
+
+ mail_remove_folder (folder, emfu_delete_done, data);
+ } else
+ gtk_widget_destroy (dialog);
}
struct _EMCreateFolder {
@@ -681,9 +704,6 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs,
if (CAMEL_IS_VEE_STORE (store)) {
EFilterRule *rule;
- /* ensures vfolder is running */
- vfolder_load_storage (session);
-
rule = em_vfolder_rule_new (session);
e_filter_rule_set_name (rule, path);
vfolder_gui_add_rule (EM_VFOLDER_RULE (rule));
diff --git a/mail/em-folder-utils.h b/mail/em-folder-utils.h
index a6a2a21da0..f67ef50531 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-session.h>
+#include <mail/e-mail-backend.h>
#include <mail/em-folder-tree.h>
G_BEGIN_DECLS
@@ -41,10 +41,11 @@ gint em_folder_utils_copy_folders (CamelStore *fromstore,
* most rely on the wrong data. */
void em_folder_utils_copy_folder (GtkWindow *parent,
- EMailSession *session,
+ EMailBackend *backend,
CamelFolderInfo *folderinfo,
gboolean delete);
-void em_folder_utils_delete_folder (CamelFolder *folder);
+void em_folder_utils_delete_folder (EMailBackend *backend,
+ CamelFolder *folder);
void em_folder_utils_create_folder (CamelFolderInfo *folderinfo,
EMFolderTree *emft,
GtkWindow *parent);
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 9f1f82ec50..dab327a20e 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -64,7 +64,6 @@
#include "e-util/e-mktemp.h"
#include "e-util/e-account-utils.h"
#include "e-util/e-dialog-utils.h"
-#include "e-util/e-alert-activity.h"
#include "e-util/e-alert-dialog.h"
#include "shell/e-shell.h"
#include "widgets/misc/e-attachment.h"
@@ -265,7 +264,7 @@ static EMFilterSource em_filter_source_element_names[] = {
/**
* em_utils_edit_filters:
* @parent: parent window
- * @session: an #EMailSession
+ * @backend: an #EMailBAckend
*
* 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
@@ -273,13 +272,14 @@ static EMFilterSource em_filter_source_element_names[] = {
**/
void
em_utils_edit_filters (GtkWidget *parent,
- EMailSession *session)
+ EMailBackend *backend)
{
const gchar *config_dir;
gchar *user, *system;
EMFilterContext *fc;
+ EMailSession *session;
- g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (E_IS_MAIL_BACKEND (backend));
if (filter_editor) {
gtk_window_present (GTK_WINDOW (filter_editor));
@@ -287,6 +287,7 @@ em_utils_edit_filters (GtkWidget *parent,
}
config_dir = mail_session_get_config_dir ();
+ session = e_mail_backend_get_session (backend);
fc = em_filter_context_new (session);
user = g_build_filename (config_dir, "filters.xml", NULL);
@@ -296,8 +297,9 @@ em_utils_edit_filters (GtkWidget *parent,
g_free (system);
if (((ERuleContext *) fc)->error) {
- GtkWidget *w = e_alert_dialog_new_for_args ((GtkWindow *)parent, "mail:filter-load-error", ((ERuleContext *)fc)->error, NULL);
- em_utils_show_error_silent (w);
+ e_mail_backend_submit_alert (
+ backend, "mail:filter-load-error",
+ ((ERuleContext *)fc)->error, NULL);
return;
}
@@ -2025,48 +2027,6 @@ em_utils_clear_get_password_canceled_accounts_flag (void)
}
}
-void
-em_utils_show_error_silent (GtkWidget *widget)
-{
- EShell *shell;
- EShellBackend *shell_backend;
- EActivity *activity;
-
- shell = e_shell_get_default ();
- shell_backend = e_shell_get_backend_by_name (
- shell, shell_builtin_backend);
-
- activity = e_alert_activity_new_warning (widget);
- e_shell_backend_add_activity (shell_backend, activity);
- g_object_unref (activity);
-
- if (g_object_get_data (G_OBJECT (widget), "response-handled") == NULL)
- g_signal_connect (
- widget, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
-}
-
-void
-em_utils_show_info_silent (GtkWidget *widget)
-{
- EShell *shell;
- EShellBackend *shell_backend;
- EActivity *activity;
-
- shell = e_shell_get_default ();
- shell_backend = e_shell_get_backend_by_name (
- shell, shell_builtin_backend);
-
- activity = e_alert_activity_new_info (widget);
- e_shell_backend_add_activity (shell_backend, activity);
- g_object_unref (activity);
-
- if (g_object_get_data (G_OBJECT (widget), "response-handled") == NULL)
- g_signal_connect (
- widget, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
-}
-
gchar *
em_utils_url_unescape_amp (const gchar *url)
{
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 684d43c0e1..2229d26653 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -43,7 +43,7 @@ void em_utils_uids_free (GPtrArray *uids);
gboolean em_utils_check_user_can_send_mail (void);
-void em_utils_edit_filters (GtkWidget *parent, EMailSession *session);
+void em_utils_edit_filters (GtkWidget *parent, EMailBackend *backend);
void em_filename_make_safe (gchar *string);
void em_utils_edit_vfolders (GtkWidget *parent);
@@ -82,10 +82,6 @@ gchar *em_utils_folder_name_from_uri (const gchar *uri);
gchar *em_uri_from_camel (const gchar *curi);
gchar *em_uri_to_camel (const gchar *euri);
-/* Run errors silently on the status bar */
-void em_utils_show_error_silent (GtkWidget *widget);
-void em_utils_show_info_silent (GtkWidget *widget);
-
/* is this address in the addressbook? caches results */
gboolean em_utils_in_addressbook (CamelInternetAddress *addr, gboolean local_only);
CamelMimePart *em_utils_contact_photo (CamelInternetAddress *addr, gboolean local);
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 566369a3b5..aac7deb49a 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -385,12 +385,13 @@ filter_gui_add_from_message (EMailSession *session,
}
void
-mail_filter_rename_uri (EMailSession *session,
+mail_filter_rename_uri (EMailBackend *backend,
CamelStore *store,
const gchar *olduri,
const gchar *newuri)
{
EMFilterContext *fc;
+ EMailSession *session;
const gchar *config_dir;
gchar *user, *system;
GList *changed;
@@ -399,6 +400,8 @@ mail_filter_rename_uri (EMailSession *session,
eolduri = em_uri_from_camel (olduri);
enewuri = em_uri_from_camel (newuri);
+ session = e_mail_backend_get_session (backend);
+
fc = em_filter_context_new (session);
config_dir = mail_session_get_config_dir ();
user = g_build_filename (config_dir, "filters.xml", NULL);
@@ -422,11 +425,12 @@ mail_filter_rename_uri (EMailSession *session,
}
void
-mail_filter_delete_uri (EMailSession *session,
+mail_filter_delete_uri (EMailBackend *backend,
CamelStore *store,
const gchar *uri)
{
EMFilterContext *fc;
+ EMailSession *session;
const gchar *config_dir;
gchar *user, *system;
GList *deleted;
@@ -434,6 +438,8 @@ mail_filter_delete_uri (EMailSession *session,
euri = em_uri_from_camel (uri);
+ session = e_mail_backend_get_session (backend);
+
fc = em_filter_context_new (session);
config_dir = mail_session_get_config_dir ();
user = g_build_filename (config_dir, "filters.xml", NULL);
@@ -443,7 +449,6 @@ mail_filter_delete_uri (EMailSession *session,
deleted = e_rule_context_delete_uri ((ERuleContext *) fc, euri, g_str_equal);
if (deleted) {
- GtkWidget *dialog;
GString *s;
guint s_count;
gchar *info;
@@ -477,8 +482,8 @@ mail_filter_delete_uri (EMailSession *session,
"The following filter rules\n%s have been modified "
"to account for the deleted folder\n\"%s\".",
s_count), s->str, euri);
- dialog = e_alert_dialog_new_for_args (e_shell_get_active_window (NULL), "mail:filter-updated", info, NULL);
- em_utils_show_info_silent (dialog);
+ e_mail_backend_submit_alert (
+ backend, "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 35e5c3aac1..7967023b20 100644
--- a/mail/mail-autofilter.h
+++ b/mail/mail-autofilter.h
@@ -27,6 +27,7 @@
#include <camel/camel.h>
#include <filter/e-filter-rule.h>
+#include <mail/e-mail-backend.h>
#include <mail/em-filter-context.h>
#include <mail/em-vfolder-context.h>
@@ -57,11 +58,11 @@ void filter_gui_add_from_message (EMailSession *session,
/* Also easiest place for these, we should really
* share a global rule context for this stuff ... */
-void mail_filter_rename_uri (EMailSession *session,
+void mail_filter_rename_uri (EMailBackend *backend,
CamelStore *store,
const gchar *olduri,
const gchar *newuri);
-void mail_filter_delete_uri (EMailSession *session,
+void mail_filter_delete_uri (EMailBackend *backend,
CamelStore *store,
const gchar *uri);
diff --git a/mail/mail-config.c b/mail/mail-config.c
index fae6bda204..5bd85ac23d 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -38,7 +38,6 @@
#include <gconf/gconf-client.h>
#include "e-mail-local.h"
-#include "e-mail-session.h"
#include "mail-config.h"
#include "mail-folder-cache.h"
#include "mail-tools.h"
@@ -150,7 +149,7 @@ static void
gconf_jh_headers_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
- CamelSession *session)
+ EMailSession *session)
{
GSList *node;
GPtrArray *name, *value;
@@ -171,7 +170,8 @@ gconf_jh_headers_changed (GConfClient *client,
g_strfreev (tok);
}
camel_session_set_junk_headers (
- session, (const gchar **) name->pdata,
+ CAMEL_SESSION (session),
+ (const gchar **) name->pdata,
(const gchar **) value->pdata, name->len);
g_ptr_array_foreach (name, (GFunc) g_free, NULL);
@@ -184,12 +184,13 @@ static void
gconf_jh_check_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
- CamelSession *session)
+ EMailSession *session)
{
config->jh_check = gconf_client_get_bool (
config->gconf, "/apps/evolution/mail/junk/check_custom_header", NULL);
if (!config->jh_check) {
- camel_session_set_junk_headers (session, NULL, NULL, 0);
+ camel_session_set_junk_headers (
+ CAMEL_SESSION (session), NULL, NULL, 0);
} else {
gconf_jh_headers_changed (NULL, 0, NULL, session);
}
@@ -539,9 +540,9 @@ mail_config_folder_to_cachename (CamelFolder *folder, const gchar *prefix)
}
void
-mail_config_reload_junk_headers (CamelSession *session)
+mail_config_reload_junk_headers (EMailSession *session)
{
- g_return_if_fail (CAMEL_IS_SESSION (session));
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
/* It automatically sets in the session */
if (config == NULL)
@@ -582,12 +583,13 @@ folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *oldur
/* Config struct routines */
void
-mail_config_init (CamelSession *session)
+mail_config_init (EMailSession *session)
{
GConfClientNotifyFunc func;
+ MailFolderCache *folder_cache;
const gchar *key;
- g_return_if_fail (CAMEL_IS_SESSION (session));
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
if (config)
return;
@@ -708,8 +710,12 @@ mail_config_init (CamelSession *session)
gconf_jh_check_changed (config->gconf, 0, NULL, session);
- g_signal_connect (mail_folder_cache_get_default (), "folder-deleted",
- (GCallback) folder_deleted_cb, NULL);
- g_signal_connect (mail_folder_cache_get_default (), "folder-renamed",
- (GCallback) folder_renamed_cb, NULL);
+ folder_cache = e_mail_session_get_folder_cache (session);
+
+ g_signal_connect (
+ folder_cache, "folder-deleted",
+ (GCallback) folder_deleted_cb, NULL);
+ g_signal_connect (
+ folder_cache, "folder-renamed",
+ (GCallback) folder_renamed_cb, NULL);
}
diff --git a/mail/mail-config.h b/mail/mail-config.h
index 7fbdaeeda9..8bd87c56b4 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -24,13 +24,14 @@
#define MAIL_CONFIG_H
#include <gtk/gtk.h>
-#include <camel/camel.h>
#include <libedataserver/e-account.h>
#include <libedataserver/e-account-list.h>
#include <e-util/e-signature.h>
#include <e-util/e-signature-list.h>
+#include <mail/e-mail-session.h>
+
G_BEGIN_DECLS
typedef enum {
@@ -62,7 +63,7 @@ typedef enum {
GType evolution_mail_config_get_type (void);
/* Configuration */
-void mail_config_init (CamelSession *session);
+void mail_config_init (EMailSession *session);
void mail_config_write (void);
GConfClient * mail_config_get_gconf_client (void);
@@ -89,7 +90,7 @@ gchar * mail_config_folder_to_cachename (CamelFolder *folder,
const gchar *prefix);
gint mail_config_get_sync_timeout (void);
-void mail_config_reload_junk_headers (CamelSession *session);
+void mail_config_reload_junk_headers (EMailSession *session);
gboolean mail_config_get_lookup_book (void);
gboolean mail_config_get_lookup_book_local_only (void);
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 7ff29c3414..0cbcea511a 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -730,7 +730,7 @@ struct _update_data {
gint id; /* id for cancellation */
guint cancel:1; /* also tells us we're cancelled */
- gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data);
+ NoteDoneFunc done;
gpointer data;
MailFolderCache *cache;
};
@@ -770,7 +770,7 @@ update_folders (CamelStore *store, CamelFolderInfo *fi, gpointer data)
g_mutex_unlock (ud->cache->priv->stores_mutex);
if (ud->done)
- res = ud->done (store, fi, ud->data);
+ res = ud->done (ud->cache, store, fi, ud->data);
g_free (ud);
return res;
@@ -1065,23 +1065,10 @@ mail_folder_cache_init (MailFolderCache *self)
timeout, (GSourceFunc) ping_cb, self);
}
-static MailFolderCache *default_cache = NULL;
-G_LOCK_DEFINE_STATIC (default_cache);
-
-/**
- * mail_folder_cache_get_default:
- *
- * Get the default folder cache object
- */
MailFolderCache *
-mail_folder_cache_get_default (void)
+mail_folder_cache_new (void)
{
- G_LOCK (default_cache);
- if (!default_cache)
- default_cache = g_object_new (MAIL_TYPE_FOLDER_CACHE, NULL);
- G_UNLOCK (default_cache);
-
- return default_cache;
+ return g_object_new (MAIL_TYPE_FOLDER_CACHE, NULL);
}
/**
diff --git a/mail/mail-folder-cache.h b/mail/mail-folder-cache.h
index 170592390d..f89d2d9aed 100644
--- a/mail/mail-folder-cache.h
+++ b/mail/mail-folder-cache.h
@@ -59,7 +59,8 @@ typedef struct _MailFolderCachePrivate MailFolderCachePrivate;
* The signature of a function to be registered as a callback for
* mail_folder_cache_note_store()
*/
-typedef gboolean (*NoteDoneFunc) (CamelStore *store,
+typedef gboolean (*NoteDoneFunc) (MailFolderCache *cache,
+ CamelStore *store,
CamelFolderInfo *info,
gpointer data);
@@ -80,7 +81,7 @@ struct _MailFolderCacheClass {
GType mail_folder_cache_get_type (void) G_GNUC_CONST;
MailFolderCache *
- mail_folder_cache_get_default (void);
+ mail_folder_cache_new (void);
void mail_folder_cache_note_store (MailFolderCache *self,
CamelSession *session,
CamelStore *store,
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 9cac82841d..907d57938a 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -27,9 +27,7 @@
#include <libedataserver/e-flag.h>
-#include "shell/e-shell.h"
-#include "e-util/e-alert-activity.h"
-#include "e-util/e-alert-dialog.h"
+#include <shell/e-shell-view.h>
#include "mail-mt.h"
@@ -43,8 +41,6 @@ const gchar *shell_builtin_backend = "mail";
/* background operation status stuff */
struct _MailMsgPrivate {
EActivity *activity;
- GtkWidget *error;
- gboolean cancelable;
};
static guint mail_msg_seq; /* sequence number of each message */
@@ -91,7 +87,6 @@ mail_msg_new (MailMsgInfo *info)
msg->priv = g_slice_new0 (MailMsgPrivate);
msg->priv->activity = e_activity_new ();
- msg->priv->cancelable = TRUE;
e_activity_set_percent (msg->priv->activity, 0.0);
@@ -161,16 +156,6 @@ mail_msg_free (MailMsg *mail_msg)
if (mail_msg->error != NULL)
g_error_free (mail_msg->error);
- if (mail_msg->priv->error != NULL) {
- EActivity *activity;
- GtkWidget *widget;
-
- widget = mail_msg->priv->error;
- activity = e_alert_activity_new_warning (widget);
- e_shell_backend_add_activity (shell_backend, activity);
- g_object_unref (activity);
- }
-
g_slice_free (MailMsgPrivate, mail_msg->priv);
g_slice_free1 (mail_msg->info->size, mail_msg);
@@ -224,28 +209,16 @@ mail_msg_unref (gpointer msg)
g_idle_add ((GSourceFunc) mail_msg_free, mail_msg);
}
-/* hash table of ops->dialogue of active errors */
-static GHashTable *active_errors = NULL;
-
-static void
-error_finalized (gpointer data, GObject *gone_gd)
-{
- g_hash_table_remove (active_errors, data);
-}
-
-static void
-error_response (GtkWidget *dialog, gint button, gpointer data)
-{
- gtk_widget_destroy (dialog);
-}
-
void
mail_msg_check_error (gpointer msg)
{
- GtkWindow *parent;
+ EShell *shell;
+ EShellView *shell_view;
+ EShellWindow *shell_window = NULL;
+ EShellContent *shell_content;
MailMsg *m = msg;
gchar *what;
- GtkDialog *gd;
+ GList *list, *iter;
#ifdef MALLOC_CHECK
checkmem (m);
@@ -258,40 +231,37 @@ mail_msg_check_error (gpointer msg)
|| g_error_matches (m->error, CAMEL_FOLDER_ERROR, CAMEL_FOLDER_ERROR_INVALID_UID))
return;
- if (active_errors == NULL)
- active_errors = g_hash_table_new (NULL, NULL);
+ shell = e_shell_get_default ();
- /* check to see if we have dialogue already running for this operation */
- /* we key on the operation pointer, which is at least accurate enough
- for the operation type, although it could be on a different object. */
- if (g_hash_table_lookup (active_errors, m->info)) {
- g_message (
- "Error occurred while existing dialogue active:\n%s",
- m->error->message);
- return;
+ /* Find the most recently used EShellWindow. */
+ list = e_shell_get_watched_windows (shell);
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ if (E_IS_SHELL_WINDOW (iter->data)) {
+ shell_window = E_SHELL_WINDOW (iter->data);
+ break;
+ }
}
- parent = e_shell_get_active_window (NULL);
+ /* If we can't find an EShellWindow then... well, screw it. */
+ if (shell_window == NULL)
+ return;
+
+ shell_view = e_shell_window_get_shell_view (
+ shell_window, shell_builtin_backend);
+ shell_content = e_shell_view_get_shell_content (shell_view);
if (m->info->desc
&& (what = m->info->desc (m))) {
- gd = (GtkDialog *) e_alert_dialog_new_for_args (
- parent, "mail:async-error", what,
+ e_alert_submit (
+ GTK_WIDGET (shell_content),
+ "mail:async-error", what,
m->error->message, NULL);
g_free (what);
} else
- gd = (GtkDialog *) e_alert_dialog_new_for_args (
- parent, "mail:async-error-nodescribe",
+ e_alert_submit (
+ GTK_WIDGET (shell_content),
+ "mail:async-error-nodescribe",
m->error->message, NULL);
-
- g_hash_table_insert (active_errors, m->info, gd);
- g_signal_connect(gd, "response", G_CALLBACK(error_response), m->info);
- g_object_weak_ref (G_OBJECT (gd), error_finalized, m->info);
- if (m->priv->cancelable)
- m->priv->error = (GtkWidget *) gd;
- else
- gtk_widget_show ((GtkWidget *)gd);
-
}
void
@@ -379,14 +349,6 @@ mail_cancel_all (void)
g_mutex_unlock (mail_msg_lock);
}
-void
-mail_msg_set_cancelable (gpointer msg, gboolean status)
-{
- MailMsg *mail_msg = msg;
-
- mail_msg->priv->cancelable = status;
-}
-
static guint idle_source_id = 0;
G_LOCK_DEFINE_STATIC (idle_source_id);
static GAsyncQueue *main_loop_queue = NULL;
diff --git a/mail/mail-mt.h b/mail/mail-mt.h
index e925946f0a..122519162b 100644
--- a/mail/mail-mt.h
+++ b/mail/mail-mt.h
@@ -76,7 +76,6 @@ void mail_msg_slow_ordered_push (gpointer msg);
GHook * mail_cancel_hook_add (GHookFunc func, gpointer data);
void mail_cancel_hook_remove (GHook *hook);
void mail_cancel_all (void);
-void mail_msg_set_cancelable (gpointer msg, gboolean status);
/* request a string/password */
gchar *mail_get_password (CamelService *service, const gchar *prompt,
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index d0db1c8ba8..97a72aade0 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -906,7 +906,6 @@ mail_send_queue (EMailSession *session,
if (G_IS_CANCELLABLE (cancellable)) {
m->cancellable = g_object_ref (cancellable);
g_object_unref (m->base.cancellable);
- mail_msg_set_cancelable (m, FALSE);
m->base.cancellable = NULL;
}
m->status = status;
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index c2584cf53a..e2c70861b6 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -961,7 +961,10 @@ static MailMsgInfo refresh_folders_info = {
};
static gboolean
-receive_update_got_folderinfo (CamelStore *store, CamelFolderInfo *info, gpointer data)
+receive_update_got_folderinfo (MailFolderCache *folder_cache,
+ CamelStore *store,
+ CamelFolderInfo *info,
+ gpointer data)
{
if (info) {
GPtrArray *folders = g_ptr_array_new ();
@@ -989,11 +992,14 @@ receive_update_got_folderinfo (CamelStore *store, CamelFolderInfo *info, gpointe
static void
receive_update_got_store (gchar *uri, CamelStore *store, gpointer data)
{
+ MailFolderCache *folder_cache;
struct _send_info *info = data;
+ folder_cache = e_mail_session_get_folder_cache (info->session);
+
if (store) {
mail_folder_cache_note_store (
- mail_folder_cache_get_default (),
+ folder_cache,
CAMEL_SESSION (info->session),
store, info->cancellable,
receive_update_got_folderinfo, info);
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 0d8f127b2b..dbca145c0d 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -248,17 +248,19 @@ vfolder_adduri_exec (struct _adduri_msg *m)
{
GList *l;
CamelFolder *folder = NULL;
+ MailFolderCache *folder_cache;
if (vfolder_shutdown)
return;
d(printf("%s uri to vfolder: %s\n", m->remove?"Removing":"Adding", m->uri));
+ 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 */
if (!m->remove &&
- !mail_folder_cache_get_folder_from_uri (mail_folder_cache_get_default (),
- m->uri, &folder)) {
+ !mail_folder_cache_get_folder_from_uri (folder_cache, m->uri, &folder)) {
g_warning("Folder '%s' disappeared while I was adding/remove it to/from my vfolder", m->uri);
return;
}
@@ -591,7 +593,7 @@ mail_vfolder_notify_uri_unavailable (EMailSession *session,
/**
* mail_vfolder_delete_uri:
- *
+ * @backend: an #EMailBackend
* @store: a #CamelStore containing the uri
* @curi: an email uri that has been deleted
*
@@ -607,7 +609,9 @@ mail_vfolder_notify_uri_unavailable (EMailSession *session,
* NOTE: This function must be called from the main thread.
*/
static void
-mail_vfolder_delete_uri (CamelStore *store, const gchar *curi)
+mail_vfolder_delete_uri (EMailBackend *backend,
+ CamelStore *store,
+ const gchar *curi)
{
EFilterRule *rule;
const gchar *source;
@@ -617,6 +621,10 @@ mail_vfolder_delete_uri (CamelStore *store, const gchar *curi)
gchar *uri;
GList *link;
+ g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (CAMEL_IS_STORE (store));
+ g_return_if_fail (curi != NULL);
+
if (uri_is_spethal (store, curi))
return;
@@ -689,7 +697,6 @@ done:
G_UNLOCK (vfolder);
if (changed_count > 0) {
- GtkWidget *dialog;
const gchar *config_dir;
gchar *user, *info;
@@ -704,8 +711,8 @@ done:
"The following Search Folders\n%s have been modified "
"to account for the deleted folder\n\"%s\".",
changed_count), changed->str, uri);
- dialog = e_alert_dialog_new_for_args (e_shell_get_active_window (NULL), "mail:vfolder-updated", info, NULL);
- em_utils_show_info_silent (dialog);
+ e_mail_backend_submit_alert (
+ backend, "mail:vfolder-updated", info, NULL);
g_free (info);
config_dir = mail_session_get_config_dir ();
@@ -803,17 +810,23 @@ mail_vfolder_get_sources_remote (void)
static void context_rule_added (ERuleContext *ctx, EFilterRule *rule);
static void
-rule_add_sources (GList *l, GList **sources_folderp, GList **sources_urip)
+rule_add_sources (EMailSession *session,
+ GList *l,
+ GList **sources_folderp,
+ GList **sources_urip)
{
GList *sources_folder = *sources_folderp;
GList *sources_uri = *sources_urip;
+ MailFolderCache *folder_cache;
CamelFolder *newfolder;
+ folder_cache = e_mail_session_get_folder_cache (session);
+
while (l) {
gchar *curi = em_uri_to_camel (l->data);
- if (mail_folder_cache_get_folder_from_uri
- (mail_folder_cache_get_default (), curi, &newfolder)) {
+ if (mail_folder_cache_get_folder_from_uri (
+ folder_cache, curi, &newfolder)) {
if (newfolder)
sources_folder = g_list_append (sources_folder, newfolder);
else
@@ -836,6 +849,7 @@ rule_changed (EFilterRule *rule, CamelFolder *folder)
const gchar *full_name;
full_name = camel_folder_get_full_name (folder);
+ session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule));
/* if the folder has changed name, then add it, then remove the old manually */
if (strcmp (full_name, rule->name) != 0) {
@@ -866,19 +880,24 @@ rule_changed (EFilterRule *rule, CamelFolder *folder)
d(printf("Filter rule changed? for folder '%s'!!\n", folder->name));
/* find any (currently available) folders, and add them to the ones to open */
- rule_add_sources (((EMVFolderRule *)rule)->sources, &sources_folder, &sources_uri);
+ rule_add_sources (
+ session, ((EMVFolderRule *)rule)->sources,
+ &sources_folder, &sources_uri);
G_LOCK (vfolder);
if (((EMVFolderRule *)rule)->with == EM_VFOLDER_RULE_WITH_LOCAL || ((EMVFolderRule *)rule)->with == EM_VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE)
- rule_add_sources (source_folders_local, &sources_folder, &sources_uri);
+ rule_add_sources (
+ session, source_folders_local,
+ &sources_folder, &sources_uri);
if (((EMVFolderRule *)rule)->with == EM_VFOLDER_RULE_WITH_REMOTE_ACTIVE || ((EMVFolderRule *)rule)->with == EM_VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE)
- rule_add_sources (source_folders_remote, &sources_folder, &sources_uri);
+ rule_add_sources (
+ session, source_folders_remote,
+ &sources_folder, &sources_uri);
G_UNLOCK (vfolder);
query = g_string_new("");
e_filter_rule_build_code (rule, query);
- session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule));
vfolder_setup (session, folder, query->str, sources_uri, sources_folder);
g_string_free (query, TRUE);
@@ -1036,9 +1055,12 @@ folder_unavailable_cb (MailFolderCache *cache,
}
static void
-folder_deleted_cb (MailFolderCache *cache, CamelStore *store, const gchar *uri, gpointer user_data)
+folder_deleted_cb (MailFolderCache *cache,
+ CamelStore *store,
+ const gchar *uri,
+ EMailBackend *backend)
{
- mail_vfolder_delete_uri (store, uri);
+ mail_vfolder_delete_uri (backend, store, uri);
}
static void
@@ -1048,7 +1070,7 @@ folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *oldur
}
void
-vfolder_load_storage (EMailSession *session)
+vfolder_load_storage (EMailBackend *backend)
{
/* lock for loading storage, it is safe to call it more than once */
G_LOCK_DEFINE_STATIC (vfolder_hash);
@@ -1057,9 +1079,13 @@ vfolder_load_storage (EMailSession *session)
const gchar *config_dir;
gchar *user, *storeuri;
EFilterRule *rule;
+ MailFolderCache *folder_cache;
+ EMailSession *session;
gchar *xmlfile;
GConfClient *gconf;
+ g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+
G_LOCK (vfolder_hash);
if (vfolder_hash) {
@@ -1074,6 +1100,7 @@ vfolder_load_storage (EMailSession *session)
data_dir = mail_session_get_data_dir ();
config_dir = mail_session_get_config_dir ();
+ session = e_mail_backend_get_session (backend);
/* first, create the vfolder store, and set it up */
storeuri = g_strdup_printf("vfolder:%s/vfolder", data_dir);
@@ -1086,7 +1113,7 @@ vfolder_load_storage (EMailSession *session)
g_signal_connect (
vfolder_store, "folder-deleted",
- G_CALLBACK (store_folder_deleted_cb), NULL);
+ G_CALLBACK (store_folder_deleted_cb), backend);
g_signal_connect (
vfolder_store, "folder-renamed",
@@ -1130,17 +1157,19 @@ vfolder_load_storage (EMailSession *session)
if (!gconf_client_get_bool (gconf, "/apps/evolution/mail/display/enable_vfolders", NULL))
gconf_client_set_bool (gconf, "/apps/evolution/mail/display/enable_vfolders", TRUE, NULL);
+ folder_cache = e_mail_session_get_folder_cache (session);
+
g_signal_connect (
- mail_folder_cache_get_default (), "folder-available",
+ folder_cache, "folder-available",
G_CALLBACK (folder_available_cb), session);
g_signal_connect (
- mail_folder_cache_get_default (), "folder-unavailable",
+ folder_cache, "folder-unavailable",
G_CALLBACK (folder_unavailable_cb), session);
g_signal_connect (
- mail_folder_cache_get_default (), "folder-deleted",
+ folder_cache, "folder-deleted",
G_CALLBACK (folder_deleted_cb), NULL);
g_signal_connect (
- mail_folder_cache_get_default (), "folder-renamed",
+ folder_cache, "folder-renamed",
G_CALLBACK (folder_renamed_cb), NULL);
}
@@ -1162,6 +1191,7 @@ vfolder_edit (EShellView *shell_view)
{
EShellBackend *shell_backend;
EShellWindow *shell_window;
+ EMailBackend *backend;
EMailSession *session;
GtkWidget *dialog;
const gchar *config_dir;
@@ -1175,10 +1205,8 @@ vfolder_edit (EShellView *shell_view)
config_dir = e_shell_backend_get_config_dir (shell_backend);
filename = g_build_filename (config_dir, "vfolders.xml", NULL);
- session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
-
- /* ensures vfolder is running */
- vfolder_load_storage (session);
+ backend = E_MAIL_BACKEND (shell_backend);
+ session = e_mail_backend_get_session (backend);
dialog = em_vfolder_editor_new (context);
gtk_window_set_title (
@@ -1218,7 +1246,8 @@ edit_rule_response (GtkWidget *w, gint button, gpointer data)
}
void
-vfolder_edit_rule (const gchar *uri)
+vfolder_edit_rule (EMailBackend *backend,
+ const gchar *uri)
{
GtkWidget *w;
GtkDialog *gd;
@@ -1226,6 +1255,9 @@ vfolder_edit_rule (const gchar *uri)
EFilterRule *rule, *newrule;
CamelURL *url;
+ g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_return_if_fail (uri != NULL);
+
url = camel_url_new (uri, NULL);
if (url && url->fragment
&& (rule = e_rule_context_find_rule ((ERuleContext *)context, url->fragment, NULL))) {
@@ -1255,11 +1287,9 @@ vfolder_edit_rule (const gchar *uri)
g_signal_connect(gd, "response", G_CALLBACK(edit_rule_response), NULL);
gtk_widget_show ((GtkWidget *)gd);
} else {
- GtkWidget *w;
-
/* TODO: we should probably just create it ... */
- w = e_alert_dialog_new_for_args (e_shell_get_active_window (NULL), "mail:vfolder-notexist", uri, NULL);
- em_utils_show_error_silent (w);
+ e_mail_backend_submit_alert (
+ backend, "mail:vfolder-notexist", uri, NULL);
}
if (url)
@@ -1341,9 +1371,6 @@ vfolder_gui_add_rule (EMVFolderRule *rule)
session = em_vfolder_rule_get_session (rule);
- /* this should be done before we call this function */
- vfolder_load_storage (session);
-
w = e_filter_rule_get_widget ((EFilterRule *)rule, (ERuleContext *)context);
gd = (GtkDialog *)gtk_dialog_new_with_buttons (
@@ -1380,9 +1407,6 @@ vfolder_gui_add_from_message (EMailSession *session,
g_return_if_fail (msg != NULL);
- /* ensures vfolder is running */
- vfolder_load_storage (session);
-
rule = (EMVFolderRule*)em_vfolder_rule_from_message (context, msg, flags, source);
vfolder_gui_add_rule (rule);
}
@@ -1397,9 +1421,6 @@ vfolder_gui_add_from_address (EMailSession *session,
g_return_if_fail (addr != NULL);
- /* ensures vfolder is running */
- vfolder_load_storage (session);
-
rule = (EMVFolderRule*)em_vfolder_rule_from_address (context, addr, flags, source);
vfolder_gui_add_rule (rule);
}
diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h
index 187a68d294..19c4d524b4 100644
--- a/mail/mail-vfolder.h
+++ b/mail/mail-vfolder.h
@@ -26,13 +26,15 @@
#include <filter/e-filter-part.h>
#include <filter/e-filter-rule.h>
+#include <mail/e-mail-backend.h>
#include <mail/em-vfolder-rule.h>
#include <shell/e-shell-view.h>
-void vfolder_load_storage (EMailSession *session);
+void vfolder_load_storage (EMailBackend *backend);
void vfolder_revert (void);
void vfolder_edit (EShellView *shell_view);
-void vfolder_edit_rule (const gchar *name);
+void vfolder_edit_rule (EMailBackend *backend,
+ const gchar *name);
EFilterPart * vfolder_create_part (const gchar *name);
EFilterRule * vfolder_clone_rule (EFilterRule *in);
void vfolder_gui_add_rule (EMVFolderRule *rule);