[evolution-patches] Re: patch that fixes #42376 (evolution-exchange)



Hi,

I noticed a flaw in the earlier approach.
Forgot to decode the uri's (Probably it wouldn't work in case there is a
space in folder name).

Sending the corrected patch.

Thanks,
Vivek Jain

On Fri, 2005-04-01 at 14:01 +0530, Vivek Jain wrote:
> Hi,
> 
> The attathced patch fixes bug regarding allowing rename/delete of
> standard folders in exchange.
> http://bugzilla.ximian.com/show_bug.cgi?id=42376
> 
> I have made changes in storage/exchange-account.c.
> Just checking whether the uri of the folder renamed matches any of the
> standard folder's.
> 
> Thanks,
> Vivek Jain
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.307
diff -u -p -r1.307 ChangeLog
--- ChangeLog	17 Mar 2005 11:27:25 -0000	1.307
+++ ChangeLog	1 Apr 2005 09:44:42 -0000
@@ -1,3 +1,14 @@
+2005-04-01  Vivek Jain  <jvivek novell com>
+
+	**Fixes #42376
+	* staorage/exchange-account.c :
+	(exchange_account_remove_folder): 
+	(exchange_account_xfer_folder): checked whether the internal_uri of the
+	folder with any of the standard folders, throw error while performing
+	remove/move/rename operations
+	added (check_std_folder) : a callback function to check the entries in hash 
+	table to match with the standard folder
+
 2005-03-17  Sushma Rai  <rsushma novell com>
 
 	* camel/camel-exchange-provider.c (exchange_validate_user_cb): Setting
Index: storage/exchange-account.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-account.c,v
retrieving revision 1.39
diff -u -p -r1.39 exchange-account.c
--- storage/exchange-account.c	11 Mar 2005 07:50:21 -0000	1.39
+++ storage/exchange-account.c	1 Apr 2005 09:44:42 -0000
@@ -453,6 +453,20 @@ get_parent_and_name (ExchangeAccount *ac
 	return TRUE;
 }
 
+static gboolean 
+check_std_folder (const char *key, const char *href, gpointer  *data)
+{
+	const char *internal_uri =(const char *)data;
+	
+	e2k_uri_decode ((char *) href);
+	e2k_uri_decode ((char *) internal_uri);
+	if (!g_ascii_strcasecmp (href, internal_uri)) 
+		return TRUE;
+	else 
+		return FALSE;
+	
+}
+
 ExchangeAccountFolderResult
 exchange_account_create_folder (ExchangeAccount *account,
 				const char *path, const char *type)
@@ -474,12 +488,18 @@ exchange_account_remove_folder (Exchange
 {
 	ExchangeHierarchy *hier;
 	EFolder *folder;
+	const char *internal_uri;
 
 	g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), 
 				EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
 
 	if (!get_folder (account, path, &folder, &hier))
 		return EXCHANGE_ACCOUNT_FOLDER_DOES_NOT_EXIST;
+	
+	/* standard folders shouldn't be removed*/
+	internal_uri = e_folder_exchange_get_internal_uri (folder);
+	if (g_hash_table_find (account->priv->standard_uris, (GHRFunc) check_std_folder, (gpointer *)internal_uri))
+		return EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR;
 
 	return exchange_hierarchy_remove_folder (hier, folder);
 }
@@ -492,6 +512,7 @@ exchange_account_xfer_folder (ExchangeAc
 {
 	EFolder *source, *dest_parent;
 	ExchangeHierarchy *source_hier, *dest_hier;
+	const char *internal_uri;
 
 	g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), 
 				EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
@@ -504,6 +525,14 @@ exchange_account_xfer_folder (ExchangeAc
 	if (source_hier != dest_hier) {
 		/* Can't move something between hierarchies */
 		return EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR;
+	}
+	
+	if (remove_source){ 
+		/* we shouldn't allow rename/move of the standard folders*/
+		internal_uri = e_folder_exchange_get_internal_uri (source);
+		if (g_hash_table_find (account->priv->standard_uris, (GHRFunc) check_std_folder, (gpointer *) internal_uri))
+			return EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR;
+
 	}
 
 	return exchange_hierarchy_xfer_folder (source_hier, source,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]