diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-10-04 05:25:04 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-10-04 05:25:04 +0800 |
commit | 7708b2d8a0a0417758f4124e27614f576922ebdb (patch) | |
tree | db08cfb368b79bb22a22e4cc45551b656ebbffce /camel/camel-folder.c | |
parent | 63fe218a169ff409d8be7f85f9838c86b4cba3f1 (diff) | |
download | gsoc2013-evolution-7708b2d8a0a0417758f4124e27614f576922ebdb.tar.gz gsoc2013-evolution-7708b2d8a0a0417758f4124e27614f576922ebdb.tar.zst gsoc2013-evolution-7708b2d8a0a0417758f4124e27614f576922ebdb.zip |
Call camel_folder_delete() on the folder if it's "alive".
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.
svn path=/trunk/; revision=13388
Diffstat (limited to 'camel/camel-folder.c')
-rw-r--r-- | camel/camel-folder.c | 56 |
1 files changed, 48 insertions, 8 deletions
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) { |