Re: [evolution-patches] Re: Exchange connector: patch for #72389



On Tue, 2005-03-08 at 17:47 +0530, Sushma Rai wrote:
Hi,

This patch includes missed part..
Please review this.

This looks fine. Please correct the typos in the Changelog and commit it to HEAD.
Also add that TODO as i mentioned in the earlier reply.

Thanks
-- Sarfraaz

Thanks,
Sushma.

On Tue, 2005-03-08 at 17:04 +0530, Sarfraaz Ahmed wrote:
> Some comments below ...
> 
> On Tue, 2005-03-08 at 15:15 +0530, Sushma Rai wrote:
> > Hi,
> > 
> > This patch fixes the problem of displaying quota warnings always,
> > whenever some quota limits are set for the user, even if he is
> > not exceeding the quota.
> > 
> > Please review,
> > -Sushma.
> > 
> > -               entry->mask |= E2K_GLOBAL_CATALOG_LOOKUP_QUOTA;
> > -               ldap_value_free (values);       
> > +       if (!strcmp (quota_setting_values[0], "TRUE")) {
> > +               /* use global mailbox store settings */
> > +               E2K_GC_DEBUG_MSG(("GC: Using global mailbox store
> > limits\n"));
> Please add a TODO: note here.
> > +       }
> > +       ldap_value_free (quota_setting_values);
> 
> > Index: storage/exchange-account.c
> > ===================================================================
> > RCS file: /cvs/gnome/evolution-exchange/storage/exchange-account.c,v
> > retrieving revision 1.37
> > diff -u -p -r1.37 exchange-account.c
> > --- storage/exchange-account.c  7 Mar 2005 05:35:05 -0000       1.37
> > +++ storage/exchange-account.c  8 Mar 2005 09:30:55 -0000
> > @@ -1237,11 +1237,15 @@ setup_account_hierarchies (ExchangeAccou
> >                 return FALSE;
> >         }
> >  
> > +       account->mbox_size =
> > exchange_hierarchy_webdav_get_total_folder_size (
> > +                                       EXCHANGE_HIERARCHY_WEBDAV
> > (personal_hier));
> > +
> Guess you forgot to send the code for hierarchy-webdav.c ?
> > -       
> 
text/plain attachment (quota-warn-rev.diff)
Index: lib/e2k-global-catalog.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/lib/e2k-global-catalog.c,v
retrieving revision 1.7
diff -u -p -r1.7 e2k-global-catalog.c
--- lib/e2k-global-catalog.c	4 Nov 2004 08:37:46 -0000	1.7
+++ lib/e2k-global-catalog.c	8 Mar 2005 11:42:42 -0000
@@ -617,30 +617,43 @@ static void
 get_quota_values (E2kGlobalCatalog *gc, E2kOperation *op,
 		  LDAPMessage *msg, E2kGlobalCatalogEntry *entry)
 {
-	char **values;
+	char **quota_setting_values, **quota_limit_values;
 
-	values = ldap_get_values (gc->priv->ldap, msg, "mDBStorageQuota");
-	if (values) {
-		entry->quota_warn = atoi(values[0]);
-		E2K_GC_DEBUG_MSG(("GC: mDBStorageQuota %s\n", values[0]));
-		entry->mask |= E2K_GLOBAL_CATALOG_LOOKUP_QUOTA;
-		ldap_value_free (values);	
+	/* Check if mailbox store default values are used */
+	quota_setting_values = ldap_get_values (gc->priv->ldap, msg, "mDBUseDefaults");
+	if (!quota_setting_values) {
+		entry->quota_warn = entry->quota_nosend = entry->quota_norecv = 0;
+		return;
 	}
 
-	values = ldap_get_values (gc->priv->ldap, msg, "mDBOverQuotaLimit");
-	if (values) {
-		entry->quota_nosend = atoi(values[0]);
-		E2K_GC_DEBUG_MSG(("GC: mDBOverQuotaLimit %s\n", values[0]));
-		entry->mask |= E2K_GLOBAL_CATALOG_LOOKUP_QUOTA;
-		ldap_value_free (values);	
-	}
+	entry->mask |= E2K_GLOBAL_CATALOG_LOOKUP_QUOTA;
+	E2K_GC_DEBUG_MSG(("GC: mDBUseDefaults %s\n", quota_setting_values[0]));
 
-	values = ldap_get_values (gc->priv->ldap, msg, "mDBOverHardQuotaLimit");
-	if (values) {
-		entry->quota_norecv = atoi(values[0]);
-		E2K_GC_DEBUG_MSG(("GC: mDBHardQuotaLimit %s\n", values[0]));
-		entry->mask |= E2K_GLOBAL_CATALOG_LOOKUP_QUOTA;
-		ldap_value_free (values);	
+	if (!strcmp (quota_setting_values[0], "TRUE")) {
+		/* use global mailbox store settings */
+		E2K_GC_DEBUG_MSG(("GC: Using global mailbox store limits\n"));
+	}
+	ldap_value_free (quota_setting_values);
+	
+	quota_limit_values = ldap_get_values (gc->priv->ldap, msg, "mDBStorageQuota");
+	if (quota_limit_values) {
+		entry->quota_warn = atoi(quota_limit_values[0]);
+		E2K_GC_DEBUG_MSG(("GC: mDBStorageQuota %s\n", quota_limit_values[0]));
+		ldap_value_free (quota_limit_values);	
+	}
+
+	quota_limit_values = ldap_get_values (gc->priv->ldap, msg, "mDBOverQuotaLimit");
+	if (quota_limit_values) {
+		entry->quota_nosend = atoi(quota_limit_values[0]);
+		E2K_GC_DEBUG_MSG(("GC: mDBOverQuotaLimit %s\n", quota_limit_values[0]));
+		ldap_value_free (quota_limit_values);	
+	}
+
+	quota_limit_values = ldap_get_values (gc->priv->ldap, msg, "mDBOverHardQuotaLimit");
+	if (quota_limit_values) {
+		entry->quota_norecv = atoi(quota_limit_values[0]);
+		E2K_GC_DEBUG_MSG(("GC: mDBHardQuotaLimit %s\n", quota_limit_values[0]));
+		ldap_value_free (quota_limit_values);	
 	}
 }
 
@@ -732,6 +745,7 @@ e2k_global_catalog_lookup (E2kGlobalCata
 	if (lookup_flags & E2K_GLOBAL_CATALOG_LOOKUP_DELEGATORS)
 		g_ptr_array_add (attrs, "publicDelegatesBL");
 	if (lookup_flags & E2K_GLOBAL_CATALOG_LOOKUP_QUOTA) {
+		g_ptr_array_add (attrs, "mDBUseDefaults");
 		g_ptr_array_add (attrs, "mDBStorageQuota");
 		g_ptr_array_add (attrs, "mDBOverQuotaLimit");
 		g_ptr_array_add (attrs, "mDBOverHardQuotaLimit");
Index: storage/exchange-account.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-account.c,v
retrieving revision 1.37
diff -u -p -r1.37 exchange-account.c
--- storage/exchange-account.c	7 Mar 2005 05:35:05 -0000	1.37
+++ storage/exchange-account.c	8 Mar 2005 11:43:06 -0000
@@ -1237,11 +1237,15 @@ setup_account_hierarchies (ExchangeAccou
 		return FALSE;
 	}
 
+	account->mbox_size = exchange_hierarchy_webdav_get_total_folder_size (
+					EXCHANGE_HIERARCHY_WEBDAV (personal_hier));
+
 	fresult = exchange_hierarchy_scan_subtree (
 		account->priv->favorites_hierarchy,
 		account->priv->favorites_hierarchy->toplevel,
 		(offline == OFFLINE_MODE));
-	if (fresult != EXCHANGE_ACCOUNT_FOLDER_OK) {
+	if (fresult != EXCHANGE_ACCOUNT_FOLDER_OK && 
+	    fresult != EXCHANGE_ACCOUNT_FOLDER_DOES_NOT_EXIST) {
 		account->priv->connecting = FALSE;
 		return FALSE;
 	}
@@ -1472,7 +1476,7 @@ exchange_account_connect (ExchangeAccoun
 
 	if (!setup_account_hierarchies (account)) 
 		return NULL;
-	
+
 	/* Find the password expiery peripod and display warning */
 	find_passwd_exp_period(account, entry);
 	
@@ -1484,14 +1488,18 @@ exchange_account_connect (ExchangeAccoun
 					    E2K_GLOBAL_CATALOG_LOOKUP_QUOTA,
                                             &entry);	
 	e2k_operation_free (&gcop);
-	
+
+	/* FIXME: quota warnings are not yet marked for translation!! */
+	/* FIXME: warning message should have quota limit value and optionally current
+	 * usage 
+	 */
 	if (gcstatus == E2K_GLOBAL_CATALOG_OK) {
 
-		if (entry->quota_norecv) {
+		if (entry->quota_norecv && account->mbox_size >= entry->quota_norecv) {
 			quota_msg = g_strdup_printf ("You have exceeded your quota for storing mails on this server. Your current usage is : %d . You will not be able to either send or recieve mails now\n", entry->quota_norecv);
-		} else if (entry->quota_nosend) {
+		} else if (entry->quota_nosend && account->mbox_size >= entry->quota_nosend) {
 			quota_msg = g_strdup_printf ("You are nearing your quota available for storing mails on this server. Your current usage is : %d . You will not be able to send mails till you clear up some space by deleting some mails.\n", entry->quota_nosend);
-		} else if (entry->quota_warn) {
+		} else if (entry->quota_warn && account->mbox_size >= entry->quota_warn) {
 			quota_msg = g_strdup_printf ("You are nearing your quota available for storing mails on this server. Your current usage is : %d . Try to clear up some space by deleting some mails.\n", entry->quota_warn);
 		}
 		
Index: storage/exchange-hierarchy-webdav.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-hierarchy-webdav.c,v
retrieving revision 1.26
diff -u -p -r1.26 exchange-hierarchy-webdav.c
--- storage/exchange-hierarchy-webdav.c	28 Feb 2005 15:20:39 -0000	1.26
+++ storage/exchange-hierarchy-webdav.c	8 Mar 2005 11:43:24 -0000
@@ -50,6 +50,7 @@ struct _ExchangeHierarchyWebDAVPrivate {
 	gboolean deep_searchable;
 	char *trash_path;
 	ExchangeFolderSize *foldersize;
+	gdouble total_folder_size;
 };
 
 #define PARENT_TYPE EXCHANGE_TYPE_HIERARCHY
@@ -111,6 +112,7 @@ init (GObject *object)
 	hwd->priv = g_new0 (ExchangeHierarchyWebDAVPrivate, 1);
 	hwd->priv->folders_by_internal_path = g_hash_table_new (g_str_hash, g_str_equal);
 	hwd->priv->foldersize = exchange_folder_size_new ();
+	hwd->priv->total_folder_size = 0;
 
 	g_signal_connect (object, "new_folder",
 			  G_CALLBACK (hierarchy_new_folder), NULL);
@@ -540,6 +542,8 @@ rescan (ExchangeHierarchy *hier)
 				fsize_d = g_ascii_strtod (folder_size, NULL)/1024;
 				exchange_folder_size_update (hwd->priv->foldersize, 
 							folder_name, fsize_d);
+				hwd->priv->total_folder_size = 
+					hwd->priv->total_folder_size + fsize_d;
 			}
 		}
 	}
@@ -560,6 +564,14 @@ exchange_hierarchy_webdav_status_to_fold
 		return EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR;
 }
 
+gdouble
+exchange_hierarchy_webdav_get_total_folder_size (ExchangeHierarchyWebDAV *hwd)
+{
+	g_return_val_if_fail (EXCHANGE_IS_HIERARCHY_WEBDAV (hwd), -1);
+
+	return hwd->priv->total_folder_size;
+}
+
 ExchangeFolderSize *
 exchange_hierarchy_webdav_get_folder_size (ExchangeHierarchyWebDAV *hwd)
 {
@@ -638,6 +650,8 @@ exchange_hierarchy_webdav_parse_folder (
 		fsize_d = g_ascii_strtod (folder_size, NULL)/1024 ;
 		exchange_folder_size_update (hwd->priv->foldersize, 
 						name, fsize_d);
+		hwd->priv->total_folder_size = 
+				hwd->priv->total_folder_size + fsize_d;
 	}
 
 	return folder;
Index: storage/exchange-hierarchy-webdav.h
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-hierarchy-webdav.h,v
retrieving revision 1.5
diff -u -p -r1.5 exchange-hierarchy-webdav.h
--- storage/exchange-hierarchy-webdav.h	23 Nov 2004 10:22:41 -0000	1.5
+++ storage/exchange-hierarchy-webdav.h	8 Mar 2005 11:43:32 -0000
@@ -66,6 +66,7 @@ void    exchange_hierarchy_webdav_offlin
 							gpointer user_data);
 
 ExchangeFolderSize * exchange_hierarchy_webdav_get_folder_size (ExchangeHierarchyWebDAV *hwd);
+gdouble exchange_hierarchy_webdav_get_total_folder_size (ExchangeHierarchyWebDAV *hwd);
 


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.286
diff -u -r1.286 ChangeLog
--- ChangeLog	8 Mar 2005 11:14:20 -0000	1.286
+++ ChangeLog	8 Mar 2005 11:52:02 -0000
@@ -1,5 +1,25 @@
 2005-03-08  Sushma Rai  <rsushma novell com>
 
+	* lib/e2k-global-catalog.c (get_quota_values): Reading "mDBUseDefaults"
+	attribute to check if the user level quota settings are enabled or not.
+	(e2k_global_catalog_lookup): Added "mDBUseDefaults" attributed to quota
+	attributes list.
+
+	* storage/exchange-account.c (setup_account_hierarchies): Reading total
+	size for all the personal folders. Not returining "FALSE" in case no
+	favorite folders exists. Not an error condition.
+	(exchange_account_connect): Printing the quota warning, only if user's
+	mail box size exceeds the quota limit set. Fixes #72389
+
+	* storage/exchange-hierarchy-webdav.[ch](init): Initializing the total
+	folder size.
+	(exchange_hierarchy_webdav_get_total_folder_size): Returns total size 
+	of all folders.
+	(rescan)(exchange_hierarchy_webdav_get_folder_size): Caclculates the 
+	total size for all the folders.
+	
+2005-03-08  Sushma Rai  <rsushma novell com>
+
 	* shell/e-folder-misc-dialogs.c (do_foreign_folder_dialog): Removed the
 	corba method which was still being used to retrieve user's e-mail
 	address.


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