diff options
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 12 | ||||
-rw-r--r-- | camel/camel-folder.c | 56 | ||||
-rw-r--r-- | camel/camel-folder.h | 5 | ||||
-rw-r--r-- | camel/camel-store.c | 33 |
4 files changed, 83 insertions, 23 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 05f21a5b7d..f04abc03f1 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,15 @@ +2001-10-03 Jeffrey Stedfast <fejj@ximian.com> + + * camel-store.c (camel_store_delete_folder): Call + camel_folder_delete() on the folder if it's "alive". + + * camel-folder.c (camel_folder_delete): Mark the folder as + deleted, perform any folder specific cleanup and emit the deleted + event. + (camel_folder_sync): Only sync the folder if it hasn't been + deleted. + (camel_folder_expunge): Same. + 2001-10-03 Dan Winship <danw@ximian.com> * providers/local/camel-local-provider.c (local_url_equal): diff --git a/camel/camel-folder.c b/camel/camel-folder.c index ead3e969be..8057f545e3 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -110,6 +110,8 @@ static void move_messages_to (CamelFolder *source, CamelFolder *dest, CamelException *ex); +static void delete (CamelFolder *folder); + static void freeze (CamelFolder *folder); static void thaw (CamelFolder *folder); static gboolean is_frozen (CamelFolder *folder); @@ -156,6 +158,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) camel_folder_class->free_message_info = free_message_info; camel_folder_class->copy_messages_to = copy_messages_to; camel_folder_class->move_messages_to = move_messages_to; + camel_folder_class->delete = delete; camel_folder_class->freeze = freeze; camel_folder_class->thaw = thaw; camel_folder_class->is_frozen = is_frozen; @@ -165,6 +168,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) "folder_changed", folder_changed); camel_object_class_declare_event (camel_object_class, "message_changed", message_changed); + camel_object_class_declare_event (camel_object_class, "deleted", NULL); } static void @@ -271,9 +275,10 @@ camel_folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) g_return_if_fail (CAMEL_IS_FOLDER (folder)); CAMEL_FOLDER_LOCK(folder, lock); - - CF_CLASS (folder)->sync (folder, expunge, ex); - + + if (!folder->deleted) + CF_CLASS (folder)->sync (folder, expunge, ex); + CAMEL_FOLDER_UNLOCK(folder, lock); } @@ -391,11 +396,12 @@ void camel_folder_expunge (CamelFolder *folder, CamelException *ex) { g_return_if_fail (CAMEL_IS_FOLDER (folder)); - + CAMEL_FOLDER_LOCK(folder, lock); - - CF_CLASS (folder)->expunge (folder, ex); - + + if (!folder->deleted) + CF_CLASS (folder)->expunge (folder, ex); + CAMEL_FOLDER_UNLOCK(folder, lock); } @@ -1240,7 +1246,7 @@ move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, Camel **/ void camel_folder_move_messages_to (CamelFolder *source, GPtrArray *uids, - CamelFolder *dest, CamelException *ex) + CamelFolder *dest, CamelException *ex) { g_return_if_fail (CAMEL_IS_FOLDER (source)); g_return_if_fail (CAMEL_IS_FOLDER (dest)); @@ -1261,6 +1267,40 @@ camel_folder_move_messages_to (CamelFolder *source, GPtrArray *uids, CAMEL_FOLDER_UNLOCK(source, lock); } + +static void +delete (CamelFolder *folder) +{ + if (folder->summary) + camel_folder_summary_clear (folder->summary); +} + +/** + * camel_folder_delete: + * @folder: folder + * + * Marks a folder as deleted and performs any required cleanup. + **/ +void +camel_folder_delete (CamelFolder *folder) +{ + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + + CAMEL_FOLDER_LOCK (folder, lock); + if (folder->deleted) { + CAMEL_FOLDER_UNLOCK (folder, lock); + return; + } + + folder->deleted = TRUE; + + CF_CLASS (folder)->delete (folder); + + CAMEL_FOLDER_UNLOCK (folder, lock); + + camel_object_trigger_event (CAMEL_OBJECT (folder), "deleted", NULL); +} + static void freeze (CamelFolder *folder) { diff --git a/camel/camel-folder.h b/camel/camel-folder.h index 0ff542afb9..786e346627 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -67,6 +67,7 @@ struct _CamelFolder gboolean has_summary_capability:1; gboolean has_search_capability:1; gboolean filter_recent:1; + gboolean deleted:1; }; @@ -153,6 +154,8 @@ typedef struct { CamelFolder *destination, CamelException *ex); + void (*delete) (CamelFolder *folder); + void (*freeze) (CamelFolder *folder); void (*thaw) (CamelFolder *folder); gboolean (*is_frozen) (CamelFolder *folder); @@ -269,6 +272,8 @@ void camel_folder_move_messages_to (CamelFolder *source, CamelFolder *dest, CamelException *ex); +void camel_folder_delete (CamelFolder *folder); + /* stop/restart getting events */ void camel_folder_freeze (CamelFolder *folder); void camel_folder_thaw (CamelFolder *folder); diff --git a/camel/camel-store.c b/camel/camel-store.c index 31b410604e..96c6a0c8bc 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -319,30 +319,33 @@ delete_folder (CamelStore *store, const char *folder_name, CamelException *ex) void camel_store_delete_folder (CamelStore *store, const char *folder_name, CamelException *ex) { - + CamelFolder *folder = NULL; + 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, (void **)&key, (void **)&folder)) { - g_hash_table_remove(store->folders, key); - g_free(key); + g_hash_table_remove (store->folders, key); + g_free (key); camel_object_ref (CAMEL_OBJECT (folder)); - CAMEL_STORE_UNLOCK(store, cache_lock); - if (store->vtrash) - camel_vee_folder_remove_folder((CamelVeeFolder *)store->vtrash, folder); - camel_object_unref (CAMEL_OBJECT (folder)); - } else { - CAMEL_STORE_UNLOCK(store, cache_lock); } + + CAMEL_STORE_UNLOCK(store, cache_lock); } - + + if (folder) { + if (store->vtrash) + camel_vee_folder_remove_folder((CamelVeeFolder *)store->vtrash, folder); + camel_folder_delete (folder); + camel_object_unref (CAMEL_OBJECT (folder)); + } + + CS_CLASS (store)->delete_folder (store, folder_name, ex); + CAMEL_STORE_UNLOCK(store, folder_lock); } |