From 466e05c024510d8019989f8bf8f04541c3ca792d Mon Sep 17 00:00:00 2001 From: 4 Date: Sat, 15 Sep 2001 08:12:58 +0000 Subject: New function, set the complete list of folders on a vfolder, all at once. 2001-09-14 * camel-vee-folder.c (camel_vee_folder_set_folders): New function, set the complete list of folders on a vfolder, all at once. (camel_vee_folder_set_expression): If we set the query to be the same thing, dont do anything. * camel-vee-store.c (camel_vee_store_init): Turn off vtrash for this store. * camel-store.c (camel_store_init): Enable vtrash by default via flags. (camel_store_get_trash): REturn NULL if the store doesn't support vtrash. (init_trash): Dont init if store doesn't support vtrash. * camel-store.h: Add a new flags CAMEL_STORE_VTRASH -> store supports vtrash. 2001-09-13 * camel-vee-store.c (vee_get_folder_info): Implement. (build_info): Used to build a folder record from the folders hashtable. (vee_delete_folder): Implemented, remove folder from hashtable. (vee_rename_folder): Implemented, remove old folder from hashtable, add new one and rename its guts too. * camel-store.c (camel_store_rename_folder): Do nothing if we're not asked to actually change names. Also dont do the renamed cache check till after we've called the subclass. (camel_store_delete_folder): Call the subclass delete firs,t then make sure the cache is right. * camel-vee-folder.c (vee_folder_construct): Remove support for name?query syntax to setup vfolder. Abort if such syntax is used. (camel_vee_folder_new): Removed code that handles ? syntax, etc. (vee_folder_build_folder): Handle unset expression, treat it as an empty search. (camel_vee_folder_set_expression): Oops, actually set the expression. * camel-vtrash-folder.c (camel_vtrash_folder_new): Dont use name?query syntax to setup vfolder, but set the expression directly. Also fixes a small memleak. 2001-09-12 * camel-store.c (camel_store_delete_folder): Fixed warnings with a cast. (camel_store_rename_folder): " svn path=/trunk/; revision=12854 --- camel/camel-store.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'camel/camel-store.c') diff --git a/camel/camel-store.c b/camel/camel-store.c index 470ada7baf..9722163cec 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -111,7 +111,8 @@ camel_store_init (void *o) } else store->folders = NULL; - store->flags = 0; + /* set vtrash on by default */ + store->flags = CAMEL_STORE_VTRASH; store->priv = g_malloc0 (sizeof (*store->priv)); #ifdef ENABLE_THREADS @@ -226,11 +227,15 @@ camel_store_get_folder (CamelStore *store, const char *folder_name, guint32 flag if (store->folders) { CAMEL_STORE_LOCK(store, cache_lock); + printf("adding folder '%s' to folders hashtable\n", folder_name); g_hash_table_insert (store->folders, g_strdup (folder_name), folder); + printf("store folders size = %d\n", g_hash_table_size(store->folders)); + camel_object_hook_event (CAMEL_OBJECT (folder), "finalize", folder_finalize, store); CAMEL_STORE_UNLOCK(store, cache_lock); - } + } else + printf("not adding folder '%s' to folders hashtable\n", folder_name); } } @@ -296,13 +301,15 @@ camel_store_delete_folder (CamelStore *store, const char *folder_name, CamelExce CAMEL_STORE_LOCK(store, folder_lock); + CS_CLASS (store)->delete_folder (store, folder_name, ex); + /* if we deleted a folder, force it out of the cache, and also out of the vtrash if setup */ if (store->folders) { CamelFolder *folder; char *key; CAMEL_STORE_LOCK(store, cache_lock); - if (g_hash_table_lookup_extended(store->folders, folder_name, &key, (void **)&folder)) { + if (g_hash_table_lookup_extended(store->folders, folder_name, (void **)&key, (void **)&folder)) { g_hash_table_remove(store->folders, key); g_free(key); CAMEL_STORE_UNLOCK(store, cache_lock); @@ -313,7 +320,6 @@ camel_store_delete_folder (CamelStore *store, const char *folder_name, CamelExce } } - CS_CLASS (store)->delete_folder (store, folder_name, ex); CAMEL_STORE_UNLOCK(store, folder_lock); } @@ -341,17 +347,20 @@ camel_store_rename_folder (CamelStore *store, const char *old_name, const char * char *key; CamelFolder *folder; + if (strcmp(old_name, new_name) == 0) + return; + CAMEL_STORE_LOCK(store, folder_lock); + CS_CLASS (store)->rename_folder (store, old_name, new_name, ex); /* remove the old name from the cache if it is there */ CAMEL_STORE_LOCK(store, cache_lock); - if (g_hash_table_lookup_extended(store->folders, old_name, &key, (void **)&folder)) { + if (g_hash_table_lookup_extended(store->folders, old_name, (void **)&key, (void **)&folder)) { g_hash_table_remove(store->folders, key); g_free(key); } CAMEL_STORE_UNLOCK(store, cache_lock); - CS_CLASS (store)->rename_folder (store, old_name, new_name, ex); CAMEL_STORE_UNLOCK(store, folder_lock); } @@ -406,6 +415,9 @@ trash_finalize (CamelObject *trash, gpointer event_data, gpointer user_data) static void init_trash (CamelStore *store) { + if ((store->flags & CAMEL_STORE_VTRASH) == 0) + return; + store->vtrash = camel_vtrash_folder_new (store, CAMEL_VTRASH_NAME); if (store->vtrash) { @@ -455,6 +467,9 @@ CamelFolder * camel_store_get_trash (CamelStore *store, CamelException *ex) { CamelFolder *folder; + + if ((store->flags & CAMEL_STORE_VTRASH) == 0) + return NULL; CAMEL_STORE_LOCK(store, folder_lock); folder = CS_CLASS (store)->get_trash (store, ex); -- cgit