File bnc-471083-remove-system-folder-evo.diff of Package evolution

diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index f3a839f..2e05a21 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,15 @@ 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)) 
+	{
+		dialog = e_error_new (NULL, "mail:no-delete-special-folder", folder->full_name, NULL);
+		em_utils_show_error_silent (dialog);
+		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 cd63967..165f594 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 f62d941..c0f7e86 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
openSUSE Build Service is sponsored by