aboutsummaryrefslogtreecommitdiffstats
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
parent9c644867fe24587339531267d9e27890513c6292 (diff)
downloadgsoc2013-evolution-6818a05259d2598c84812d4709a007fb58da59ef.tar.gz
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
-rw-r--r--e-util/e-marshal.list1
-rw-r--r--mail/mail-folder-cache.c60
-rw-r--r--modules/mail/e-mail-shell-backend.c55
3 files changed, 84 insertions, 32 deletions
diff --git a/e-util/e-marshal.list b/e-util/e-marshal.list
index 4346d4359e..cf6133cbd9 100644
--- a/e-util/e-marshal.list
+++ b/e-util/e-marshal.list
@@ -41,6 +41,7 @@ NONE:POINTER,POINTER,INT
NONE:POINTER,STRING
NONE:POINTER,STRING,STRING
NONE:POINTER,STRING,INT
+NONE:POINTER,STRING,STRING,INT,STRING,STRING,STRING
NONE:STRING,DOUBLE
NONE:STRING,INT,INT
NONE:STRING,POINTER,POINTER
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 6b1be44753..6b39e7f269 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -48,7 +48,6 @@
#include <camel/camel-disco-store.h>
#include <libedataserver/e-data-server-util.h>
-#include "shell/e-shell.h"
#include "e-util/e-marshal.h"
#include "mail-mt.h"
@@ -57,12 +56,7 @@
#include "mail-session.h"
#include "mail-tools.h"
-/* For notifications of changes */
-#include "em-folder-tree-model.h"
-
-#include "em-event.h"
#include "em-utils.h"
-
#include "e-mail-local.h"
#define w(x)
@@ -99,6 +93,7 @@ enum
FOLDER_DELETED,
FOLDER_RENAMED,
FOLDER_UNREAD_UPDATED,
+ FOLDER_CHANGED,
LAST_SIGNAL
};
@@ -172,14 +167,9 @@ free_update(struct _folder_update *up)
static void
real_flush_updates (gpointer o, gpointer event_data, gpointer data)
{
- EShell *shell;
- EMFolderTreeModel *default_model;
struct _folder_update *up;
MailFolderCache *self = (MailFolderCache*) o;
- shell = e_shell_get_default ();
- default_model = em_folder_tree_model_get_default ();
-
g_mutex_lock (self->priv->stores_mutex);
while ((up = g_queue_pop_head (&self->priv->updates)) != NULL) {
g_mutex_unlock (self->priv->stores_mutex);
@@ -202,28 +192,10 @@ real_flush_updates (gpointer o, gpointer event_data, gpointer data)
g_signal_emit (self, signals[FOLDER_UNREAD_UPDATED], 0,
up->store, up->full_name, up->unread);
+ /* indicate that the folder has changed (new mail received, etc) */
if (up->uri) {
- EMEvent *e = em_event_peek();
- EMEventTargetFolder *t = em_event_target_new_folder(e, up->uri, up->new, up->msg_uid, up->msg_sender, up->msg_subject);
-
- t->is_inbox = em_folder_tree_model_is_type_inbox (
- default_model, up->store, up->full_name);
- t->name = em_folder_tree_model_get_folder_name (
- default_model, up->store, up->full_name);
-
- 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);
+ g_signal_emit (self, signals[FOLDER_CHANGED], 0, up->store,
+ up->uri, up->full_name, up->new, up->msg_uid, up->msg_sender, up->msg_subject);
}
if (CAMEL_IS_VEE_STORE (up->store) && !up->remove) {
@@ -1287,6 +1259,30 @@ mail_folder_cache_class_init (MailFolderCacheClass *klass)
e_marshal_VOID__POINTER_STRING_INT,
G_TYPE_NONE, 3,
G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_INT);
+
+ /**
+ * MailFolderCache::folder-changed
+ * @store: the #CamelStore containing the folder
+ * @folder_uri: the uri of the folder
+ * @folder_fullname: the full name of the folder
+ * @new_messages: the number of new messages for the folder
+ * @msg_uid: uid of the new message, or NULL
+ * @msg_sender: sender of the new message, or NULL
+ * @msg_subject: subject of the new message, or NULL
+ *
+ * Emitted when a folder has changed. If @new_messages is not exactly 1,
+ * @msgt_uid, @msg_sender, and @msg_subject will be NULL.
+ **/
+ signals[FOLDER_CHANGED] =
+ g_signal_new ("folder-changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, /* struct offset */
+ NULL, NULL, /* accumulator */
+ e_marshal_VOID__POINTER_STRING_STRING_INT_STRING_STRING_STRING,
+ G_TYPE_NONE, 7,
+ G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
}
static void
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 ();