From 064ff85b3b8e06a5347b62e5c80c1273875e719a Mon Sep 17 00:00:00 2001 From: Chenthill Palanisamy Date: Mon, 13 Apr 2009 09:03:19 +0000 Subject: Fixes #471083 (bnc) Do not allow deletion of system folders. Fixes #471083 (bnc) Do not allow deletion of system folders. svn path=/trunk/; revision=37517 --- mail/ChangeLog | 8 ++++++++ mail/em-folder-utils.c | 10 ++++++++++ mail/mail-folder-cache.c | 30 ++++++++++++++++++++++++++++++ mail/mail-folder-cache.h | 1 + 4 files changed, 49 insertions(+) diff --git a/mail/ChangeLog b/mail/ChangeLog index 4c81c8e768..62310e394e 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,11 @@ +2009-04-13 Chenthill Palanisamy + + Fixes #471083 (bnc) + * mail/em-folder-utils.c: + * mail/mail-folder-cache.c: + * mail/mail-folder-cache.h: Do not allow deleting + system folders. + 2008-04-04 Tobias Mueller ** Fix for bug #569765 diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index f3a839f926..56111abe6c 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -61,6 +61,7 @@ #include "mail-config.h" #include "mail-component.h" #include "mail-vfolder.h" +#include "mail-folder-cache.h" #include "em-utils.h" #include "em-popup.h" @@ -401,6 +402,8 @@ em_folder_utils_delete_folder (CamelFolder *folder) { CamelStore *local; GtkWidget *dialog; + char *uri; + int flags = 0; local = mail_component_peek_local_store (NULL); @@ -409,7 +412,14 @@ em_folder_utils_delete_folder (CamelFolder *folder) em_utils_show_error_silent (dialog); return; } + + if (mail_folder_cache_get_folder_info_flags (folder, &flags) && (flags & CAMEL_FOLDER_SYSTEM)) + { + e_error_run(NULL,"mail:no-delete-special-folder", folder->name, NULL); + return; + } + g_free (uri); camel_object_ref (folder); dialog = e_error_new(NULL, diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index cd63967090..165f5941c2 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -56,6 +56,7 @@ #include "mail-ops.h" #include "mail-session.h" #include "mail-component.h" +#include "mail-tools.h" /* For notifications of changes */ #include "mail-vfolder.h" @@ -1043,3 +1044,32 @@ int mail_note_get_folder_from_uri(const char *uri, CamelFolder **folderp) return fi.fi != NULL; } + +gboolean +mail_folder_cache_get_folder_info_flags (CamelFolder *folder, int *flags) +{ + char *uri; + + uri = mail_tools_folder_to_url (folder); + + struct _find_info fi = { uri, NULL, NULL }; + + if (stores == NULL) + return FALSE; + + fi.url = camel_url_new(uri, NULL); + + LOCK(info_lock); + g_hash_table_foreach(stores, (GHFunc)storeinfo_find_folder_info, &fi); + if (flags) { + if (fi.fi) { + *flags = fi.fi->flags; + } + } + UNLOCK(info_lock); + + camel_url_free(fi.url); + g_free (uri); + + return fi.fi != NULL; +} diff --git a/mail/mail-folder-cache.h b/mail/mail-folder-cache.h index f62d94169b..c0f7e866cf 100644 --- a/mail/mail-folder-cache.h +++ b/mail/mail-folder-cache.h @@ -49,5 +49,6 @@ void mail_note_folder (CamelFolder *folder); /* Returns true if a folder is available (yet), and also sets *folderp (if supplied) to a (referenced) copy of the folder if it has already been opened */ int mail_note_get_folder_from_uri (const char *uri, CamelFolder **folderp); +gboolean mail_folder_cache_get_folder_info_flags (CamelFolder *folder, int *flags); #endif -- cgit v1.2.3