aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-folder-cache.c
diff options
context:
space:
mode:
author9 <NotZed@Ximian.com>2001-10-19 13:40:42 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-19 13:40:42 +0800
commit3e6cd9a7e55a6c19d73a86195ff320b6dff76d54 (patch)
treeb0a58e239142420e6fbf3220ea18a55b617cc406 /mail/mail-folder-cache.c
parent0515ef5e4d5d138f1f7e9956b7a643cc01d7cf19 (diff)
downloadgsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.tar.gz
gsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.tar.zst
gsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.zip
Free folders_uri. (real_folder_deleted): If folder is deleted, remove it
2001-10-19 <NotZed@Ximian.com> * mail-folder-cache.c (store_finalised): Free folders_uri. (real_folder_deleted): If folder is deleted, remove it from the hashtables. * subscribe-dialog.c (get_short_folderinfo_get): Remove the register/unregister, they're already done above us. * mail-vfolder.c (mail_vfolder_delete_uri): Dont do any work to remove the actual folder from the vfolder (we'd have to look it up first), let the vfolder remove it itself. Just update the rules. svn path=/trunk/; revision=13787
Diffstat (limited to 'mail/mail-folder-cache.c')
-rw-r--r--mail/mail-folder-cache.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 710147a8a1..d91fc1c8e1 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -75,6 +75,10 @@ struct _store_info {
static GHashTable *stores;
+static void free_folder_info(char *path, struct _folder_info *mfi, void *data);
+static void unset_folder_info(struct _folder_info *mfi, int delete);
+
+
/* This is how unread counts work (and don't work):
*
* camel_folder_unread_message_count() only gives a correct answer if
@@ -308,13 +312,22 @@ store_folder_created(CamelObject *o, void *event_data, void *data)
static void
-real_folder_deleted(CamelStore *store, void *event_data, CamelFolderInfo *fi)
+real_folder_deleted(CamelStore *store, struct _store_info *si, CamelFolderInfo *fi)
{
+ struct _folder_info *mfi;
+
d(printf("real_folder_deleted: %s (%s)\n", fi->full_name, fi->url));
-
- if (strstr(fi->url, ";noselect") == NULL)
- mail_vfolder_delete_uri(store, fi->url);
+ LOCK(info_lock);
+ mfi = g_hash_table_lookup(si->folders, fi->full_name);
+ if (mfi) {
+ g_hash_table_remove(si->folders, mfi->full_name);
+ g_hash_table_remove(si->folders_uri, mfi->uri);
+ unset_folder_info(mfi, TRUE);
+ free_folder_info(NULL, mfi, NULL);
+ }
+ UNLOCK(info_lock);
+
camel_object_unref((CamelObject *)store);
camel_folder_info_free(fi);
}
@@ -345,7 +358,7 @@ store_folder_deleted(CamelObject *o, void *event_data, void *data)
}
static void
-unset_folder_info(char *path, struct _folder_info *mfi, void *data)
+unset_folder_info(struct _folder_info *mfi, int delete)
{
if (mfi->folder) {
CamelFolder *folder = mfi->folder;
@@ -356,10 +369,21 @@ unset_folder_info(char *path, struct _folder_info *mfi, void *data)
camel_object_unhook_event((CamelObject *)folder, "finalize", folder_finalised, mfi);
}
- if (strstr(mfi->uri, ";noselect") == NULL)
- mail_vfolder_add_uri(mfi->store_info->store, mfi->uri, TRUE);
+ if (strstr(mfi->uri, ";noselect") == NULL) {
+ if (delete)
+ mail_vfolder_delete_uri(mfi->store_info->store, mfi->uri);
+ else
+ mail_vfolder_add_uri(mfi->store_info->store, mfi->uri, TRUE);
+ }
+}
+
+static void
+unset_folder_info_hash(char *path, struct _folder_info *mfi, void *data)
+{
+ unset_folder_info(mfi, FALSE);
}
+
static void
free_folder_info(char *path, struct _folder_info *mfi, void *data)
{
@@ -386,12 +410,13 @@ store_finalised(CamelObject *o, void *event_data, void *data)
camel_object_unhook_event((CamelObject *)store, "folder_unsubscribed", store_folder_unsubscribed, NULL);
camel_object_unhook_event((CamelObject *)store, "finalize", store_finalised, NULL);
- g_hash_table_foreach(si->folders, (GHFunc)unset_folder_info, NULL);
+ g_hash_table_foreach(si->folders, (GHFunc)unset_folder_info_hash, NULL);
UNLOCK(info_lock);
mail_async_event_destroy(si->async_event);
LOCK(info_lock);
g_hash_table_foreach(si->folders, (GHFunc)free_folder_info, NULL);
g_hash_table_destroy(si->folders);
+ g_hash_table_destroy(si->folders_uri);
g_free(si);
}
UNLOCK(info_lock);