aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-12-17 02:29:17 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-12-17 02:29:17 +0800
commit2a7f68fe45f3e60547212a6895a0fd202c5c3f09 (patch)
tree87c940a1ea26d3a1727fff123b3d20825ba7cb20
parent968ea42023e5e0daf860a7246533311a67f77e05 (diff)
downloadgsoc2013-evolution-2a7f68fe45f3e60547212a6895a0fd202c5c3f09.tar.gz
gsoc2013-evolution-2a7f68fe45f3e60547212a6895a0fd202c5c3f09.tar.zst
gsoc2013-evolution-2a7f68fe45f3e60547212a6895a0fd202c5c3f09.zip
Move MailFolderCache signal handlers to EMailBackend.
Move the MailFolderCache signal handlers from EMailShellBackend down to EMailBackend (in libevolution-mail.so) to share with Anjal.
-rw-r--r--mail/e-mail-backend.c87
-rw-r--r--modules/mail/e-mail-shell-backend.c77
2 files changed, 87 insertions, 77 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index aa7e149f76..5d5effe72c 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -31,7 +31,11 @@
#include "mail/e-mail-local.h"
#include "mail/e-mail-migrate.h"
#include "mail/e-mail-store.h"
+#include "mail/em-event.h"
+#include "mail/em-folder-tree-model.h"
#include "mail/em-utils.h"
+#include "mail/mail-autofilter.h"
+#include "mail/mail-folder-cache.h"
#include "mail/mail-ops.h"
#include "mail/mail-session.h"
#include "mail/mail-vfolder.h"
@@ -286,10 +290,79 @@ mail_backend_quit_requested_cb (EShell *shell,
}
static void
+mail_backend_folder_deleted_cb (MailFolderCache *folder_cache,
+ CamelStore *store,
+ const gchar *uri)
+{
+ mail_filter_delete_uri (store, uri);
+}
+
+static void
+mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
+ CamelStore *store,
+ const gchar *old_uri,
+ const gchar *new_uri)
+{
+ mail_filter_rename_uri (store, old_uri, new_uri);
+}
+
+static void
+mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
+ CamelStore *store,
+ const gchar *folder_uri,
+ const gchar *folder_fullname,
+ gint new_messages,
+ const gchar *msg_uid,
+ const gchar *msg_sender,
+ const gchar *msg_subject,
+ EShell *shell)
+{
+ CamelFolder *folder = NULL;
+ EMEvent *event = em_event_peek ();
+ EMEventTargetFolder *target;
+ EMFolderTreeModel *model;
+ gint folder_type;
+ gint flags = 0;
+
+ if (!mail_folder_cache_get_folder_from_uri (folder_cache, folder_uri, &folder))
+ if (!mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags))
+ g_return_if_reached ();
+
+ target = em_event_target_new_folder (
+ event, folder_uri, new_messages,
+ msg_uid, msg_sender, msg_subject);
+
+ folder_type = (flags & CAMEL_FOLDER_TYPE_MASK);
+ target->is_inbox = (folder_type == CAMEL_FOLDER_TYPE_INBOX);
+
+ model = em_folder_tree_model_get_default ();
+ target->name = em_folder_tree_model_get_folder_name (
+ model, store, folder_fullname);
+
+ if (target->new > 0)
+ e_shell_event (shell, "mail-icon", (gpointer) "mail-unread");
+
+ /** @Event: folder.changed
+ * @Title: Folder changed
+ * @Target: EMEventTargetFolder
+ *
+ * folder.changed is emitted whenever a folder changes. There is no
+ * detail on how the folder has changed.
+ *
+ * UPDATE: We tell the number of new UIDs added rather than the new
+ * mails received.
+ */
+ e_event_emit (
+ (EEvent *) event, "folder.changed",
+ (EEventTarget *) target);
+}
+
+static void
mail_backend_constructed (GObject *object)
{
EShell *shell;
EShellBackend *shell_backend;
+ MailFolderCache *folder_cache;
const gchar *data_dir;
shell_backend = E_SHELL_BACKEND (object);
@@ -298,6 +371,8 @@ mail_backend_constructed (GObject *object)
/* This also initializes Camel, so it needs to happen early. */
mail_session_init (shell_backend);
+ folder_cache = mail_folder_cache_get_default ();
+
g_signal_connect (
shell, "notify::online",
G_CALLBACK (mail_backend_notify_online_cb),
@@ -323,6 +398,18 @@ mail_backend_constructed (GObject *object)
G_CALLBACK (mail_backend_quit_requested_cb),
shell_backend);
+ g_signal_connect (
+ folder_cache, "folder-deleted",
+ G_CALLBACK (mail_backend_folder_deleted_cb), NULL);
+
+ g_signal_connect (
+ folder_cache, "folder-renamed",
+ G_CALLBACK (mail_backend_folder_renamed_cb), NULL);
+
+ g_signal_connect (
+ folder_cache, "folder-changed",
+ G_CALLBACK (mail_backend_folder_changed_cb), shell);
+
mail_config_init ();
mail_msg_init ();
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index b166084f5d..6b96e8b1aa 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -47,16 +47,13 @@
#include "em-account-prefs.h"
#include "em-composer-prefs.h"
#include "em-composer-utils.h"
-#include "em-event.h"
#include "em-folder-utils.h"
#include "em-format-hook.h"
#include "em-format-html-display.h"
#include "em-mailer-prefs.h"
#include "em-network-prefs.h"
#include "em-utils.h"
-#include "mail-autofilter.h"
#include "mail-config.h"
-#include "mail-folder-cache.h"
#include "mail-ops.h"
#include "mail-send-recv.h"
#include "mail-session.h"
@@ -475,68 +472,6 @@ mail_shell_backend_window_created_cb (EShell *shell,
}
static void
-folder_deleted_cb (MailFolderCache *cache, CamelStore *store, const gchar *uri, gpointer user_data)
-{
- mail_filter_delete_uri(store, uri);
-}
-
-static void
-folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *olduri, const gchar *newuri, gpointer user_data)
-{
- mail_filter_rename_uri(store, olduri, newuri);
-}
-
-static void
-folder_changed_cb (MailFolderCache *cache,
- CamelStore *store,
- const gchar *folder_uri,
- const gchar *folder_fullname,
- int new_messages,
- const gchar *msg_uid,
- const gchar *msg_sender,
- const gchar *msg_subject,
- gpointer user_data)
-{
- EShell *shell = (EShell*) user_data;
- CamelFolder *folder = NULL;
- gint flags = 0;
- EMEvent *e = em_event_peek();
- EMEventTargetFolder *t;
- EMFolderTreeModel *model;
-
- g_return_if_fail (shell);
-
- if (!mail_folder_cache_get_folder_from_uri (cache, folder_uri, &folder)) {
- if (!mail_folder_cache_get_folder_info_flags (cache, folder, &flags)) {
- g_return_if_reached ();
- }
- }
-
- t = em_event_target_new_folder(e, folder_uri, new_messages, msg_uid,
- msg_sender, msg_subject);
-
- t->is_inbox = ((flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX);
-
- model = em_folder_tree_model_get_default ();
- t->name = em_folder_tree_model_get_folder_name (model, store,
- folder_fullname);
-
- if (t->new > 0)
- e_shell_event (
- shell, "mail-icon",
- (gpointer) "mail-unread");
-
- /** @Event: folder.changed
- * @Title: Folder changed
- * @Target: EMEventTargetFolder
- *
- * folder.changed is emitted whenever a folder changes. There is no detail on how the folder has changed.
- * UPDATE: We tell the number of new UIDs added rather than the new mails received
- */
- e_event_emit((EEvent *)e, "folder.changed", (EEventTarget *)t);
-}
-
-static void
mail_shell_backend_constructed (GObject *object)
{
EMailShellBackendPrivate *priv;
@@ -581,18 +516,6 @@ mail_shell_backend_constructed (GObject *object)
G_CALLBACK (mail_shell_backend_window_created_cb),
shell_backend);
- g_signal_connect (
- mail_folder_cache_get_default (), "folder-deleted",
- G_CALLBACK (folder_deleted_cb), NULL);
-
- g_signal_connect (
- mail_folder_cache_get_default (), "folder-renamed",
- G_CALLBACK (folder_renamed_cb), NULL);
-
- g_signal_connect (
- mail_folder_cache_get_default (), "folder-changed",
- G_CALLBACK (folder_changed_cb), shell);
-
e_mail_shell_settings_init (shell);
/* Initialize preferences after the main loop starts so