aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorJonathon Jongsma <jonathon@quotidian.org>2009-12-15 00:46:12 +0800
committerJonathon Jongsma <jonathon@quotidian.org>2009-12-16 04:16:09 +0800
commit6818a05259d2598c84812d4709a007fb58da59ef (patch)
treedb0e1246985b88194712262483043b2ceab024e7 /modules
parent9c644867fe24587339531267d9e27890513c6292 (diff)
downloadgsoc2013-evolution-6818a05259d2598c84812d4709a007fb58da59ef.tar
gsoc2013-evolution-6818a05259d2598c84812d4709a007fb58da59ef.tar.gz
gsoc2013-evolution-6818a05259d2598c84812d4709a007fb58da59ef.tar.bz2
gsoc2013-evolution-6818a05259d2598c84812d4709a007fb58da59ef.tar.lz
gsoc2013-evolution-6818a05259d2598c84812d4709a007fb58da59ef.tar.xz
gsoc2013-evolution-6818a05259d2598c84812d4709a007fb58da59ef.tar.zst
gsoc2013-evolution-6818a05259d2598c84812d4709a007fb58da59ef.zip
Add MailFolderCache::folder-changed signal
Yes, this signal is kind of an ugly monster. I'm not sure how to improve this significantly. But this commit removes the last EMFolderTreeModel and EShell dependencies from MailFolderCache, which is a big step towards splitting off the backend. https://bugzilla.gnome.org/show_bug.cgi?id=604627
Diffstat (limited to 'modules')
-rw-r--r--modules/mail/e-mail-shell-backend.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index be6bd1d199..47e00b7591 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -50,6 +50,7 @@
#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"
@@ -782,6 +783,56 @@ folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *oldur
}
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;
@@ -855,6 +906,10 @@ mail_shell_backend_constructed (GObject *object)
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);
+
mail_config_init ();
mail_msg_init ();