diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-backend.c | 29 | ||||
-rw-r--r-- | mail/em-folder-tree-model.c | 17 |
2 files changed, 21 insertions, 25 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index d1ca660ab7..c2952daffd 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -673,35 +673,30 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache, EMEvent *event = em_event_peek (); EMEventTargetFolder *target; EMFolderTreeModel *model; + CamelFolder *folder; gchar *folder_uri; gint folder_type; CamelFolderInfoFlags flags = 0; folder_uri = e_mail_folder_uri_build (store, folder_name); - if (folder_uri != NULL) { - CamelFolder *folder = NULL; - - if (mail_folder_cache_get_folder_from_uri ( - folder_cache, folder_uri, &folder)) { - if (folder != NULL && - !mail_folder_cache_get_folder_info_flags ( - folder_cache, folder, &flags)) { - g_free (folder_uri); - g_return_if_reached (); - } - } - - if (folder != NULL) - g_object_unref (folder); + folder = mail_folder_cache_ref_folder ( + folder_cache, store, folder_name); + if (folder != NULL) { + /* XXX Need to rethink this API. Why should we + * need the CamelFolder instance just to get + * folder flags? The flags are more readily + * available than the CamelFolder instance. */ + mail_folder_cache_get_folder_info_flags ( + folder_cache, folder, &flags); + g_object_unref (folder); } target = em_event_target_new_folder ( event, store, folder_uri, new_messages, msg_uid, msg_sender, msg_subject); - if (folder_uri) - g_free (folder_uri); + g_free (folder_uri); folder_type = (flags & CAMEL_FOLDER_TYPE_MASK); target->is_inbox = (folder_type == CAMEL_FOLDER_TYPE_INBOX); diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index eaa6b92342..66f292695b 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -748,22 +748,23 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, /* XXX This is duplicated in mail-folder-cache too, should perhaps * be functionised. */ unread = fi->unread; - if (mail_folder_cache_get_folder_from_uri ( - folder_cache, uri, &folder) && folder) { + folder = mail_folder_cache_ref_folder ( + folder_cache, si->store, fi->full_name); + if (folder != NULL) { folder_is_drafts = em_utils_folder_is_drafts (registry, folder); folder_is_outbox = em_utils_folder_is_outbox (registry, folder); if (folder_is_drafts || folder_is_outbox) { gint total; + gint deleted; - if ((total = camel_folder_get_message_count (folder)) > 0) { - gint deleted = camel_folder_get_deleted_message_count (folder); + total = camel_folder_get_message_count (folder); + deleted = camel_folder_get_deleted_message_count (folder); - if (deleted != -1) - total -= deleted; - } + if (total > 0 && deleted != -1) + total -= deleted; - unread = total > 0 ? total : 0; + unread = MAX (total, 0); } g_object_unref (folder); |