diff options
author | Milan Crha <mcrha@redhat.com> | 2010-05-21 22:30:40 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-05-21 22:30:40 +0800 |
commit | a5d79e9f915dc49ef0259ce7681c1f552c335a4c (patch) | |
tree | 85a17cf63e8ac8fe68e0cb2ff8b42404f63917b1 /mail/mail-folder-cache.c | |
parent | 22b33668db988f628e411ef67ecc10520c9f20d3 (diff) | |
download | gsoc2013-evolution-a5d79e9f915dc49ef0259ce7681c1f552c335a4c.tar.gz gsoc2013-evolution-a5d79e9f915dc49ef0259ce7681c1f552c335a4c.tar.zst gsoc2013-evolution-a5d79e9f915dc49ef0259ce7681c1f552c335a4c.zip |
Bug #546551 - Dialog for mark-all-read always mentions subfolders
Diffstat (limited to 'mail/mail-folder-cache.c')
-rw-r--r-- | mail/mail-folder-cache.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 5d52a1431d..a9726ea0db 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -97,6 +97,7 @@ struct _folder_info { gchar *uri; /* uri of folder */ guint32 flags; + gboolean has_children; gpointer folder; /* if known (weak pointer) */ }; @@ -429,6 +430,7 @@ setup_folder(MailFolderCache *self, CamelFolderInfo *fi, struct _store_info *si) mfi->uri = g_strdup(fi->uri); mfi->store_info = si; mfi->flags = fi->flags; + mfi->has_children = fi->child != NULL; g_hash_table_insert(si->folders, mfi->full_name, mfi); g_hash_table_insert(si->folders_uri, mfi->uri, mfi); @@ -577,6 +579,7 @@ rename_folders(MailFolderCache *self, struct _store_info *si, const gchar *oldba mfi->full_name = g_strdup(fi->full_name); mfi->uri = g_strdup(fi->uri); mfi->flags = fi->flags; + mfi->has_children = fi->child != NULL; g_hash_table_insert(si->folders, mfi->full_name, mfi); g_hash_table_insert(si->folders_uri, mfi->uri, mfi); @@ -588,6 +591,7 @@ rename_folders(MailFolderCache *self, struct _store_info *si, const gchar *oldba mfi->uri = g_strdup(fi->uri); mfi->store_info = si; mfi->flags = fi->flags; + mfi->has_children = fi->child != NULL; g_hash_table_insert(si->folders, mfi->full_name, mfi); g_hash_table_insert(si->folders_uri, mfi->uri, mfi); @@ -1301,3 +1305,32 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *self, return fi.fi != NULL; } +/* Returns whether folder 'folder' has children based on folder_info->child property. + If not found returns FALSE and sets 'found' to FALSE, if not NULL. */ +gboolean +mail_folder_cache_get_folder_has_children (MailFolderCache *self, CamelFolder *folder, gboolean *found) +{ + gchar *uri = mail_tools_folder_to_url (folder); + struct _find_info fi = { uri, NULL, NULL }; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (folder != NULL, FALSE); + + if (self->priv->stores == NULL) + return FALSE; + + fi.url = camel_url_new (uri, NULL); + + g_mutex_lock (self->priv->stores_mutex); + g_hash_table_foreach ( + self->priv->stores, (GHFunc) + storeinfo_find_folder_info, &fi); + if (found) + *found = fi.fi != NULL; + g_mutex_unlock (self->priv->stores_mutex); + + camel_url_free (fi.url); + g_free (uri); + + return fi.fi != NULL && fi.fi->has_children; +} |