Re: [evolution-patches] Exchange connector: Fix for 73494 and 72100
- From: Sushma Rai <rsushma novell com>
- To: Evolution Patches List <evolution-patches lists ximian com>
- Cc: Sarfraaz Ahmed <asarfraaz novell com>
- Subject: Re: [evolution-patches] Exchange connector: Fix for 73494 and 72100
- Date: Thu, 17 Mar 2005 14:41:16 +0530
Hi,
Please review this revised patch, incorporated
Michael's comment and also, did modification to
forming internal uri during folder creation.
Thanks,
Sushma.
On Wed, 2005-03-16 at 16:49 +0800, Not Zed wrote:
>
> This isn't needed, g_free accepts NULL and does nothing for it.
>
> On Wed, 2005-03-16 at 14:06 +0530, Sushma Rai wrote:
> > - g_free (f_info->folder_name);
> > + if (f_info->folder_name)
> > + g_free (f_info->folder_name);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.306
diff -u -p -r1.306 ChangeLog
--- ChangeLog 16 Mar 2005 10:56:29 -0000 1.306
+++ ChangeLog 17 Mar 2005 08:30:31 -0000
@@ -1,3 +1,33 @@
+2005-03-17 Sushma Rai <rsushma novell com>
+
+ * storage/exchange-folder-size.[ch] (free_fsize_table): Returns
+ boolean now.
+ (finalize): Freeing the hash table here. Also freeing the private
+ structure now.
+ (init): Using g_hash_table_new() for creating the hash table.
+ (exchange_folder_size_remove): Added new. Removes the specifed folder
+ entry from the hash table and updates GtkListStore.
+ (exchange_folder_size_get): Added new. Returns the folder size of
+ specified folder from the cache.
+
+ * storage/exchange-hierarchy-webdav.c (e_folder_webdav_new): For the
+ folders without internal uri (newly created folder), creating the
+ internal uri with trailing slash.
+ (create_folder): Updating folder size for newly created folder.
+ (remove_folder): Removing folder size entry for the folder removed.
+ (xfer_folder): Finding whether the folder is renamed or moved. In case
+ of folder rename, removing the old entry from hash table and updating
+ the hash table with new folder name.
+ (rescan): Finding the folder size for all type for folders and not only
+ ther personal folders. Also, considering only the personal folder sizes
+ for finding the total mail box size.
+ (exchange_hierarchy_webdav_parse_folder): Removed the folder size check
+ done here, and doing it in scan_subtree().
+ (scan_subtree): Finding the folder size and mail box size.
+
+ * lib/e2k-uri.c (e2k_uri_concat): handling the condtion when this
+ function is used for adding the trailing slash to the uri.
+
2005-03-16 Sarfraaz Ahmed <asarfraaz novell com>
* docs/reference/Makefile.am : Link to krb5 libs as well
Index: storage/exchange-folder-size.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-folder-size.c,v
retrieving revision 1.8
diff -u -p -r1.8 exchange-folder-size.c
--- storage/exchange-folder-size.c 26 Feb 2005 08:44:02 -0000 1.8
+++ storage/exchange-folder-size.c 17 Mar 2005 08:30:41 -0000
@@ -60,12 +60,14 @@ enum {
NUM_COLUMNS
};
-static void
+static gboolean
free_fsize_table (gpointer key, gpointer value, gpointer data)
{
folder_info *f_info = (folder_info *) value;
+
g_free (f_info->folder_name);
g_free (f_info);
+ return TRUE;
}
static void
@@ -73,10 +75,12 @@ finalize (GObject *object)
{
ExchangeFolderSize *fsize = EXCHANGE_FOLDER_SIZE (object);
+ g_hash_table_foreach_remove (fsize->priv->table, free_fsize_table, NULL);
g_hash_table_destroy (fsize->priv->table);
g_hash_table_destroy (fsize->priv->row_refs);
if (fsize->priv->model)
g_object_unref (fsize->priv->model);
+ g_free (fsize->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -104,8 +108,7 @@ init (GObject *object)
ExchangeFolderSize *fsize = EXCHANGE_FOLDER_SIZE (object);
fsize->priv = g_new0 (ExchangeFolderSizePrivate, 1);
- fsize->priv->table = g_hash_table_new_full (g_str_hash, g_str_equal,
- NULL, (GDestroyNotify)free_fsize_table);
+ fsize->priv->table = g_hash_table_new (g_str_hash, g_str_equal);
fsize->priv->model = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_DOUBLE);
fsize->priv->row_refs = g_hash_table_new (g_str_hash, g_str_equal);
}
@@ -180,6 +183,55 @@ exchange_folder_size_update (ExchangeFol
g_hash_table_insert (fsize->priv->row_refs, f_info->folder_name, row);
}
+}
+
+void
+exchange_folder_size_remove (ExchangeFolderSize *fsize,
+ const char *folder_name)
+{
+ ExchangeFolderSizePrivate *priv;
+ GHashTable *folder_size_table;
+ folder_info *cached_info;
+ GtkTreeRowReference *row;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ g_return_if_fail (EXCHANGE_IS_FOLDER_SIZE (fsize));
+ g_return_if_fail (folder_name != NULL);
+
+ priv = fsize->priv;
+ folder_size_table = priv->table;
+
+ cached_info = g_hash_table_lookup (folder_size_table, folder_name);
+ if (cached_info) {
+ row = g_hash_table_lookup (priv->row_refs, folder_name);
+ path = gtk_tree_row_reference_get_path (row);
+ g_hash_table_remove (folder_size_table, cached_info->folder_name);
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (fsize->priv->model), &iter, path)) {
+ gtk_list_store_remove (fsize->priv->model, &iter);
+ }
+ gtk_tree_path_free (path);
+ }
+}
+
+gdouble
+exchange_folder_size_get (ExchangeFolderSize *fsize,
+ const char *folder_name)
+{
+ ExchangeFolderSizePrivate *priv;
+ GHashTable *folder_size_table;
+ folder_info *cached_info;
+
+ g_return_val_if_fail (EXCHANGE_IS_FOLDER_SIZE (fsize), -1);
+
+ priv = fsize->priv;
+ folder_size_table = priv->table;
+
+ cached_info = g_hash_table_lookup (folder_size_table, folder_name);
+ if (cached_info) {
+ return cached_info->folder_size;
+ }
+ return -1;
}
static void
Index: storage/exchange-folder-size.h
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-folder-size.h,v
retrieving revision 1.3
diff -u -p -r1.3 exchange-folder-size.h
--- storage/exchange-folder-size.h 26 Feb 2005 08:44:02 -0000 1.3
+++ storage/exchange-folder-size.h 17 Mar 2005 08:30:50 -0000
@@ -42,6 +42,9 @@ ExchangeFolderSize *exchange_folder_size
void exchange_folder_size_update (ExchangeFolderSize *fsize,
const char *folder_name,
gdouble folder_size);
+void exchange_folder_size_remove (ExchangeFolderSize *fsize, const char *folder_name);
+
+gdouble exchange_folder_size_get (ExchangeFolderSize *fsize, const char *folder_name);
void exchange_folder_size_display (EFolder *folder, GtkWidget *parent);
Index: storage/exchange-hierarchy-webdav.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-hierarchy-webdav.c,v
retrieving revision 1.27
diff -u -p -r1.27 exchange-hierarchy-webdav.c
--- storage/exchange-hierarchy-webdav.c 9 Mar 2005 07:50:40 -0000 1.27
+++ storage/exchange-hierarchy-webdav.c 17 Mar 2005 08:31:01 -0000
@@ -273,6 +273,8 @@ e_folder_webdav_new (ExchangeHierarchy *
physical_uri, internal_uri);
} else {
http_uri = e2k_uri_concat (e_folder_exchange_get_internal_uri (parent), name);
+ /* appending "/" here, so that hash table lookup in rescan() succeeds */
+ http_uri = e2k_uri_concat (http_uri, "/");
folder = e_folder_exchange_new (hier, name,
real_type, outlook_class,
physical_uri, http_uri);
@@ -329,6 +331,11 @@ create_folder (ExchangeHierarchy *hier,
g_free (permanent_url);
exchange_hierarchy_new_folder (hier, dest);
g_object_unref (dest);
+
+ /* update the folder size table, new folder, initialize the size to 0 */
+ exchange_folder_size_update (
+ EXCHANGE_HIERARCHY_WEBDAV (hier)->priv->foldersize,
+ name, 0);
return EXCHANGE_ACCOUNT_FOLDER_OK;
}
@@ -360,6 +367,10 @@ remove_folder (ExchangeHierarchy *hier,
status = e_folder_exchange_delete (folder, NULL);
if (E2K_HTTP_STATUS_IS_SUCCESSFUL (status)) {
exchange_hierarchy_removed_folder (hier, folder);
+
+ /* update the folder size info */
+ exchange_folder_size_remove (EXCHANGE_HIERARCHY_WEBDAV (hier)->priv->foldersize,
+ e_folder_get_name(folder));
return EXCHANGE_ACCOUNT_FOLDER_OK;
} else
return EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR;
@@ -372,12 +383,13 @@ xfer_folder (ExchangeHierarchy *hier, EF
{
E2kHTTPStatus status;
EFolder *dest;
- char *permanent_url = NULL, *physical_uri;
+ char *permanent_url = NULL, *physical_uri, *source_parent;
ESourceList *cal_source_list, *task_source_list, *cont_source_list;
- const char *folder_type = NULL;
+ const char *folder_type = NULL, *source_folder_name;
ExchangeAccountFolderResult ret_code;
int offline;
-
+ gdouble f_size;
+
exchange_account_is_offline (hier->account, &offline);
if (offline != ONLINE_MODE)
return EXCHANGE_ACCOUNT_FOLDER_OFFLINE;
@@ -406,6 +418,30 @@ xfer_folder (ExchangeHierarchy *hier, EF
physical_uri = (char *) e_folder_get_physical_uri (source);
g_object_unref (dest);
ret_code = EXCHANGE_ACCOUNT_FOLDER_OK;
+
+ /* Find if folder movement or rename.
+ * update folder size in case of rename.
+ */
+
+ source_folder_name = strrchr (physical_uri + 1, '/');
+ source_parent = g_strndup (physical_uri,
+ source_folder_name - physical_uri);
+ if (!strcmp (e_folder_get_physical_uri (dest_parent), source_parent)) {
+ /* rename - remove folder entry from hash, and
+ * update the hash table with new name
+ */
+ f_size = exchange_folder_size_get (
+ EXCHANGE_HIERARCHY_WEBDAV (hier)->priv->foldersize,
+ source_folder_name+1);
+ exchange_folder_size_remove (
+ EXCHANGE_HIERARCHY_WEBDAV (hier)->priv->foldersize,
+ source_folder_name+1);
+ if (f_size >= 0)
+ exchange_folder_size_update (
+ EXCHANGE_HIERARCHY_WEBDAV (hier)->priv->foldersize,
+ dest_name, f_size);
+ }
+ g_free (source_parent);
} else {
physical_uri = e2k_uri_concat (
e_folder_get_physical_uri (dest_parent),
@@ -479,8 +515,9 @@ add_href (gpointer path, gpointer folder
g_ptr_array_add (hrefs, path);
}
+/* E2K_PR_EXCHANGE_FOLDER_SIZE also can be used for reading folder size */
static const char *rescan_props[] = {
- E2K_PR_EXCHANGE_FOLDER_SIZE,
+ PR_MESSAGE_SIZE_EXTENDED,
E2K_PR_HTTPMAIL_UNREAD_COUNT
};
static const int n_rescan_props = sizeof (rescan_props) / sizeof (rescan_props[0]);
@@ -535,16 +572,15 @@ rescan (ExchangeHierarchy *hier)
e_folder_set_unread_count (folder, unread);
folder_size = e2k_properties_get_prop (result->props,
- E2K_PR_EXCHANGE_FOLDER_SIZE);
- if (folder_size && personal) {
- if (e_folder_exchange_get_permanent_uri (folder)) {
- folder_name = e_folder_get_name (folder);
- fsize_d = g_ascii_strtod (folder_size, NULL)/1024;
- exchange_folder_size_update (hwd->priv->foldersize,
- folder_name, fsize_d);
+ PR_MESSAGE_SIZE_EXTENDED);
+ if (folder_size) {
+ folder_name = e_folder_get_name (folder);
+ fsize_d = g_ascii_strtod (folder_size, NULL)/1024;
+ exchange_folder_size_update (hwd->priv->foldersize,
+ folder_name, fsize_d);
+ if (personal)
hwd->priv->total_folder_size =
hwd->priv->total_folder_size + fsize_d;
- }
}
}
e2k_result_iter_free (iter);
@@ -587,10 +623,9 @@ exchange_hierarchy_webdav_parse_folder (
{
EFolder *folder;
ExchangeFolderType *folder_type;
- const char *name, *prop, *outlook_class, *permanenturl, *folder_size;
+ const char *name, *prop, *outlook_class, *permanenturl;
int unread;
gboolean hassubs;
- gdouble fsize_d;
g_return_val_if_fail (EXCHANGE_IS_HIERARCHY_WEBDAV (hwd), NULL);
g_return_val_if_fail (E_IS_FOLDER (parent), NULL);
@@ -628,11 +663,17 @@ exchange_hierarchy_webdav_parse_folder (
if (!outlook_class)
outlook_class = folder_type->contentclass;
+ /*
+ * The permanenturl Field provides a unique identifier for an item
+ * across the *store* and will not change as long as the item remains
+ * in the same folder. The permanenturl Field contains the ID of the
+ * parent folder of the item, which changes when the item is moved to a
+ * different folder or deleted. Changing a field on an item will not
+ * change the permanenturl Field and neither will adding more items to
+ * the folder with the same display name or message subject.
+ */
permanenturl = e2k_properties_get_prop (result->props,
E2K_PR_EXCHANGE_PERMANENTURL);
-
- folder_size = e2k_properties_get_prop (result->props,
- E2K_PR_EXCHANGE_FOLDER_SIZE);
// Check for errors
folder = e_folder_webdav_new (EXCHANGE_HIERARCHY (hwd),
@@ -645,13 +686,10 @@ exchange_hierarchy_webdav_parse_folder (
if (hassubs)
e_folder_exchange_set_has_subfolders (folder, TRUE);
if (permanenturl) {
+ /* Favorite folders and subscribed folders will not have
+ * permanenturl
+ */
e_folder_exchange_set_permanent_uri (folder, permanenturl);
- /* FIXME : Find a better way of doing this */
- 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;
@@ -669,7 +707,7 @@ static const char *folder_props[] = {
E2K_PR_HTTPMAIL_UNREAD_COUNT,
E2K_PR_DAV_DISPLAY_NAME,
E2K_PR_EXCHANGE_PERMANENTURL,
- E2K_PR_EXCHANGE_FOLDER_SIZE,
+ PR_MESSAGE_SIZE_EXTENDED,
E2K_PR_DAV_HAS_SUBS
};
static const int n_folder_props = sizeof (folder_props) / sizeof (folder_props[0]);
@@ -686,7 +724,10 @@ scan_subtree (ExchangeHierarchy *hier, E
EFolder *folder, *tmp;
GPtrArray *folders;
int i;
-
+ gdouble fsize_d;
+ const char *name, *folder_size;
+ gboolean personal = ( EXCHANGE_HIERARCHY (hwd)->type == EXCHANGE_HIERARCHY_PERSONAL );
+
if (offline) {
folders = g_ptr_array_new ();
exchange_hierarchy_webdav_offline_scan_subtree (EXCHANGE_HIERARCHY (hier), add_folders, folders);
@@ -721,6 +762,22 @@ scan_subtree (ExchangeHierarchy *hier, E
subtrees = g_slist_prepend (subtrees, folder);
}
exchange_hierarchy_new_folder (hier, folder);
+
+ /* Check the folder size here */
+ name = e2k_properties_get_prop (result->props,
+ E2K_PR_DAV_DISPLAY_NAME);
+ folder_size = e2k_properties_get_prop (result->props,
+ PR_MESSAGE_SIZE_EXTENDED);
+
+ /* FIXME : Find a better way of doing this */
+ fsize_d = g_ascii_strtod (folder_size, NULL)/1024 ;
+ exchange_folder_size_update (hwd->priv->foldersize,
+ name, fsize_d);
+ if (personal) {
+ /* calculate mail box size only for personal folders */
+ hwd->priv->total_folder_size =
+ hwd->priv->total_folder_size + fsize_d;
+ }
}
status = e2k_result_iter_free (iter);
Index: lib/e2k-uri.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/lib/e2k-uri.c,v
retrieving revision 1.2
diff -u -p -r1.2 e2k-uri.c
--- lib/e2k-uri.c 22 Jun 2004 15:21:59 -0000 1.2
+++ lib/e2k-uri.c 17 Mar 2005 08:31:13 -0000
@@ -387,10 +387,16 @@ e2k_uri_concat (const char *uri_prefix,
const char *p;
p = strrchr (uri_prefix, '/');
- if (p && !p[1])
+ if ((p && !p[1]) || *tail == '/') {
+ /* uri_prefix ends with "/" or tail is a "/", i.e.,
+ * trying to append a "/" to the uri
+ */
return g_strdup_printf ("%s%s", uri_prefix, tail);
- else
+ }
+ else {
+ /* uri_prefix doesn't contain a trailing "/" */
return g_strdup_printf ("%s/%s", uri_prefix, tail);
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]