diff options
-rw-r--r-- | libemail-engine/mail-folder-cache.c | 80 | ||||
-rw-r--r-- | libemail-engine/mail-folder-cache.h | 3 | ||||
-rw-r--r-- | mail/e-mail-backend.c | 14 | ||||
-rw-r--r-- | mail/e-mail-reader-utils.c | 2 | ||||
-rw-r--r-- | mail/em-folder-properties.c | 10 | ||||
-rw-r--r-- | modules/itip-formatter/itip-view.c | 13 |
6 files changed, 56 insertions, 66 deletions
diff --git a/libemail-engine/mail-folder-cache.c b/libemail-engine/mail-folder-cache.c index 5b99f34c1b..6f469ddaa6 100644 --- a/libemail-engine/mail-folder-cache.c +++ b/libemail-engine/mail-folder-cache.c @@ -102,7 +102,7 @@ struct _folder_info { gchar *full_name; /* full name of folder/folderinfo */ - guint32 flags; + CamelFolderInfoFlags flags; gpointer folder; /* if known (weak pointer) */ }; @@ -1035,36 +1035,6 @@ find_folder_uri (GQueue *queue, return link; } -struct _find_info { - const gchar *folder_uri; - struct _folder_info *fi; -}; - -static void -storeinfo_find_folder_info (CamelStore *store, - StoreInfo *si, - struct _find_info *fi) -{ - CamelSession *session; - gchar *folder_name; - gboolean success; - - if (fi->fi != NULL) - return; - - session = camel_service_ref_session (CAMEL_SERVICE (store)); - - success = e_mail_folder_uri_parse ( - session, fi->folder_uri, NULL, &folder_name, NULL); - - g_object_unref (session); - - if (success) { - fi->fi = g_hash_table_lookup (si->folders, folder_name); - g_free (folder_name); - } -} - static void mail_folder_cache_get_property (GObject *object, guint property_id, @@ -1708,35 +1678,49 @@ mail_folder_cache_ref_folder (MailFolderCache *cache, return folder; } +/** + * mail_folder_cache_get_folder_info_flags: + * @cache: a #MailFolderCache + * @store: a #CamelStore + * @folder_name: a folder name + * @flags: return location for #CamelFolderInfoFlags + * + * Obtains #CamelFolderInfoFlags for @store and @folder_name if available, + * and returns %TRUE to indicate @flags was set. If no folder information + * is available for @store and @folder_name, the function returns %FALSE. + * + * Returns: whether @flags was set + **/ gboolean mail_folder_cache_get_folder_info_flags (MailFolderCache *cache, - CamelFolder *folder, + CamelStore *store, + const gchar *folder_name, CamelFolderInfoFlags *flags) { - struct _find_info fi = { NULL, NULL }; - gchar *folder_uri; + StoreInfo *si; + struct _folder_info *fi; + gboolean flags_set = FALSE; + + g_return_val_if_fail (MAIL_IS_FOLDER_CACHE (cache), FALSE); + g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE); + g_return_val_if_fail (folder_name != NULL, FALSE); + g_return_val_if_fail (flags != NULL, FALSE); if (cache->priv->stores == NULL) return FALSE; - folder_uri = e_mail_folder_uri_from_folder (folder); - fi.folder_uri = folder_uri; - g_rec_mutex_lock (&cache->priv->stores_mutex); - g_hash_table_foreach ( - cache->priv->stores, (GHFunc) - storeinfo_find_folder_info, &fi); - if (flags) { - if (fi.fi) - *flags = fi.fi->flags; - else - *flags = 0; + si = g_hash_table_lookup (cache->priv->stores, store); + if (si != NULL) { + fi = g_hash_table_lookup (si->folders, folder_name); + if (fi != NULL) { + *flags = fi->flags; + flags_set = TRUE; + } } g_rec_mutex_unlock (&cache->priv->stores_mutex); - g_free (folder_uri); - - return fi.fi != NULL; + return flags_set; } void diff --git a/libemail-engine/mail-folder-cache.h b/libemail-engine/mail-folder-cache.h index 280502147c..1c8a5cc4ee 100644 --- a/libemail-engine/mail-folder-cache.h +++ b/libemail-engine/mail-folder-cache.h @@ -126,7 +126,8 @@ CamelFolder * mail_folder_cache_ref_folder (MailFolderCache *cache, const gchar *folder_name); gboolean mail_folder_cache_get_folder_info_flags (MailFolderCache *cache, - CamelFolder *folder, + CamelStore *store, + const gchar *folder_name, CamelFolderInfoFlags *flags); void mail_folder_cache_get_local_folder_uris (MailFolderCache *cache, diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index c2952daffd..b7fb84735e 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -673,24 +673,14 @@ 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); - 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); - } + mail_folder_cache_get_folder_info_flags ( + folder_cache, store, folder_name, &flags); target = em_event_target_new_folder ( event, store, folder_uri, new_messages, diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index 2a3c4c6a8c..acd52950c8 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -260,7 +260,7 @@ e_mail_reader_delete_folder (EMailReader *reader, } have_flags = mail_folder_cache_get_folder_info_flags ( - folder_cache, folder, &flags); + folder_cache, parent_store, full_name, &flags); if (have_flags && (flags & CAMEL_FOLDER_SYSTEM)) { e_alert_submit ( diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c index 526dc89068..d50888fea9 100644 --- a/mail/em-folder-properties.c +++ b/mail/em-folder-properties.c @@ -193,18 +193,24 @@ emfp_get_folder_item (EConfig *ec, CamelStore *store; CamelSession *session; CamelFolderInfoFlags fi_flags = 0; + const gchar *folder_name; MailFolderCache *folder_cache; + gboolean have_flags; store = camel_folder_get_parent_store (context->folder); + folder_name = camel_folder_get_full_name (context->folder); + session = camel_service_ref_session (CAMEL_SERVICE (store)); folder_cache = e_mail_session_get_folder_cache ( E_MAIL_SESSION (session)); + have_flags = mail_folder_cache_get_folder_info_flags ( + folder_cache, store, folder_name, &fi_flags); + can_apply_filters = !CAMEL_IS_VEE_FOLDER (context->folder) && - mail_folder_cache_get_folder_info_flags ( - folder_cache, context->folder, &fi_flags) && + have_flags && (fi_flags & CAMEL_FOLDER_TYPE_MASK) != CAMEL_FOLDER_TYPE_INBOX; g_object_unref (session); diff --git a/modules/itip-formatter/itip-view.c b/modules/itip-formatter/itip-view.c index 3f77f407c9..32ac52dc44 100644 --- a/modules/itip-formatter/itip-view.c +++ b/modules/itip-formatter/itip-view.c @@ -5776,10 +5776,13 @@ in_proper_folder (CamelFolder *folder) EMailSession *session; MailFolderCache *folder_cache; ESourceRegistry *registry; + CamelStore *store; + const gchar *folder_name; gboolean res = TRUE; CamelFolderInfoFlags flags = 0; + gboolean have_flags; - if (!folder) + if (folder == NULL) return FALSE; shell = e_shell_get_default (); @@ -5789,7 +5792,13 @@ in_proper_folder (CamelFolder *folder) session = e_mail_backend_get_session (backend); folder_cache = e_mail_session_get_folder_cache (session); - if (mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags)) { + store = camel_folder_get_parent_store (folder); + folder_name = camel_folder_get_full_name (folder); + + have_flags = mail_folder_cache_get_folder_info_flags ( + folder_cache, store, folder_name, &flags); + + if (have_flags) { /* it should be neither trash nor junk folder, */ res = ((flags & CAMEL_FOLDER_TYPE_MASK) != CAMEL_FOLDER_TYPE_TRASH && (flags & CAMEL_FOLDER_TYPE_MASK) != CAMEL_FOLDER_TYPE_JUNK && |