From 96947a0bcf6b93cb5f32e7e91a53129ff8a2b44e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 29 May 2011 13:41:15 -0400 Subject: Change EMEventTargetFolder contents. Give it a CamelStore and folder name instead of an EAccount and folder URI. Both the EAccount and folder URI can be easily retrieved from the CamelStore and folder name. --- mail/e-mail-backend.c | 17 ++++++----------- mail/em-event.c | 22 +++++++++++----------- mail/em-event.h | 10 +++++----- 3 files changed, 22 insertions(+), 27 deletions(-) (limited to 'mail') diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index 0ae8706a32..b22dbcf2ca 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -356,7 +356,7 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache, static void mail_backend_folder_changed_cb (MailFolderCache *folder_cache, CamelStore *store, - const gchar *folder_fullname, + const gchar *folder_name, gint new_messages, const gchar *msg_uid, const gchar *msg_sender, @@ -367,13 +367,11 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache, EMEvent *event = em_event_peek (); EMEventTargetFolder *target; EMFolderTreeModel *model; - EAccount *account; - const gchar *uid; gchar *folder_uri; gint folder_type; CamelFolderInfoFlags flags = 0; - folder_uri = e_mail_folder_uri_build (store, folder_fullname); + folder_uri = e_mail_folder_uri_build (store, folder_name); if (mail_folder_cache_get_folder_from_uri ( folder_cache, folder_uri, &folder)) @@ -381,19 +379,18 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache, folder_cache, folder, &flags)) g_return_if_reached (); - uid = camel_service_get_uid (CAMEL_SERVICE (store)); - account = e_get_account_by_uid (uid); + g_free (folder_uri); target = em_event_target_new_folder ( - event, account, folder_uri, new_messages, + event, store, folder_name, 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); + target->display_name = em_folder_tree_model_get_folder_name ( + model, store, folder_name); if (target->new > 0) e_shell_event (shell, "mail-icon", (gpointer) "mail-unread"); @@ -411,8 +408,6 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache, e_event_emit ( (EEvent *) event, "folder.changed", (EEventTarget *) target); - - g_free (folder_uri); } static void diff --git a/mail/em-event.c b/mail/em-event.c index 074b9abfa9..3fb3176aab 100644 --- a/mail/em-event.c +++ b/mail/em-event.c @@ -40,10 +40,10 @@ eme_target_free (EEvent *ep, EEventTarget *t) switch (t->type) { case EM_EVENT_TARGET_FOLDER: { EMEventTargetFolder *s = (EMEventTargetFolder *) t; - if (s->account != NULL) - g_object_unref (s->account); - g_free (s->name); - g_free (s->uri); + if (s->store != NULL) + g_object_unref (s->store); + g_free (s->folder_name); + g_free (s->display_name); g_free (s->msg_uid); g_free (s->msg_sender); g_free (s->msg_subject); @@ -108,8 +108,8 @@ em_event_peek (void) EMEventTargetFolder * em_event_target_new_folder (EMEvent *eme, - EAccount *account, - const gchar *uri, + CamelStore *store, + const gchar *folder_name, guint new, const gchar *msg_uid, const gchar *msg_sender, @@ -118,14 +118,14 @@ em_event_target_new_folder (EMEvent *eme, EMEventTargetFolder *t; guint32 flags = new ? EM_EVENT_FOLDER_NEWMAIL : 0; + g_return_val_if_fail (CAMEL_IS_STORE (store), NULL); + g_return_val_if_fail (folder_name != NULL, NULL); + t = e_event_target_new ( &eme->popup, EM_EVENT_TARGET_FOLDER, sizeof (*t)); - if (E_IS_ACCOUNT (account)) - t->account = g_object_ref (account); - else - t->account = NULL; - t->uri = g_strdup (uri); + t->store = g_object_ref (store); + t->folder_name = g_strdup (folder_name); t->target.mask = ~flags; t->new = new; t->msg_uid = g_strdup (msg_uid); diff --git a/mail/em-event.h b/mail/em-event.h index f1cd25c59c..3fc5ac0fc3 100644 --- a/mail/em-event.h +++ b/mail/em-event.h @@ -72,11 +72,11 @@ typedef struct _EMEventTargetFolder EMEventTargetFolder; struct _EMEventTargetFolder { EEventTarget target; - EAccount *account; - gchar *uri; + CamelStore *store; + gchar *folder_name; guint new; gboolean is_inbox; - gchar *name; + gchar *display_name; /* valid (non-NULL) when only one new message reported */ gchar *msg_uid; @@ -135,8 +135,8 @@ GType em_event_get_type (void); EMEvent * em_event_peek (void); EMEventTargetFolder * em_event_target_new_folder (EMEvent *emp, - EAccount *account, - const gchar *uri, + CamelStore *store, + const gchar *folder_name, guint32 count_new_msgs, const gchar *msg_uid, const gchar *msg_sender, -- cgit