[evolution-patches] Re: patch for bug #73926 (camel-groupwise)
- From: Vivek Jain <jvivek novell com>
- To: evolution-patches lists ximian com
- Cc: sparthasarathi novell com
- Subject: [evolution-patches] Re: patch for bug #73926 (camel-groupwise)
- Date: Thu, 24 Mar 2005 10:44:18 +0530
Sorry, I goofed up while creating the patch, sending it again.
Thanks,
Vivek
On Tue, 2005-03-22 at 18:58 +0530, Vivek Jain wrote:
> hi,
>
> the attached patch fixes
> http://bugzilla.ximian.com/show_bug.cgi?id=73926
>
> Changes are made in camel-groupwise-store.[ch]
> camel-groupwise-folder.c
> I've changed the name_hash to contain the full name of the folder.
>
> Thanks,
> Vivek Jain
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/ChangeLog,v
retrieving revision 1.40
diff -u -p -r1.40 ChangeLog
--- ChangeLog 18 Mar 2005 06:01:55 -0000 1.40
+++ ChangeLog 24 Mar 2005 05:03:58 -0000
@@ -1,3 +1,29 @@
+2005-03-22 Vivek Jain <jvivek novell com>
+
+ **Fixes bug #73926
+ * camel-groupwise-store.c :
+ (gw_get_path) : removed
+ (groupwise_get_folder_info): Changed the name hash. Now
+ it stores full names of the folders
+ (groupwise_rename_folder):
+ (groupwise_delete_folder):
+ (groupwise_create_folder):
+ (groupwise_get_folder) :
+ use full name of the folder to perform any operation, when
+ folder name is to be taken from name_hash
+ (groupwise_build_folder_info): we don't need to call gw_get_path
+ use full name passed directly
+
+ * camel-groupwise-folder.c :
+ (groupwise_transfer_messages_to):
+ (groupwise_append_message):
+ (groupwise_expunge):
+ (groupwise_sync):
+ (groupwise_folder_get_message):
+ (groupwise_folder_get_message):
+ (groupwise_refresh_info):
+ use full_name in container id lookup
+
2005-03-18 Vivek Jain <jvivek novell com>
**Fixes bug #73458
Index: camel-groupwise-store.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-store.h,v
retrieving revision 1.5
diff -u -p -r1.5 camel-groupwise-store.h
--- camel-groupwise-store.h 11 Jan 2005 07:49:58 -0000 1.5
+++ camel-groupwise-store.h 24 Mar 2005 05:03:59 -0000
@@ -72,7 +72,6 @@ char * groupwise_get_name(CamelService *
const char *camel_groupwise_store_container_id_lookup (CamelGroupwiseStore *gw_store, const char *folder_name) ;
const char *camel_groupwise_store_folder_lookup (CamelGroupwiseStore *gw_store, const char *container_id) ;
EGwConnection *cnc_lookup (CamelGroupwiseStorePrivate *priv) ;
-const char *gw_get_path (CamelGroupwiseStore *gw_store, const char *folder_name) ;
char *storage_path_lookup (CamelGroupwiseStorePrivate *priv) ;
Index: camel-groupwise-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-store.c,v
retrieving revision 1.41
diff -u -p -r1.41 camel-groupwise-store.c
--- camel-groupwise-store.c 10 Mar 2005 06:59:14 -0000 1.41
+++ camel-groupwise-store.c 24 Mar 2005 05:03:59 -0000
@@ -481,8 +481,7 @@ groupwise_get_folder (CamelStore *store,
CamelFolder *folder ;
CamelGroupwiseSummary *summary;
char *time_string = NULL;
- char *storage_path, *folder_dir, *temp_str,*container_id ;
- const char *temp_name;
+ char *storage_path, *folder_dir, *container_id ;
EGwConnectionStatus status ;
GList *list = NULL ;
GSList *slist = NULL, *sl ;
@@ -512,15 +511,7 @@ groupwise_get_folder (CamelStore *store,
return folder;
}
- temp_name = folder_name ;
- temp_str = strrchr(folder_name,'/') ;
- if(temp_str == NULL) {
- container_id = g_strdup (g_hash_table_lookup (priv->name_hash, g_strdup(folder_name))) ;
- }
- else {
- temp_str++ ;
- container_id = g_strdup (g_hash_table_lookup (priv->name_hash, g_strdup(temp_str))) ;
- }
+ container_id = g_strdup (g_hash_table_lookup (priv->name_hash, g_strdup(folder_name))) ;
folder = camel_gw_folder_new (store, folder_name, folder_dir, ex) ;
if (!folder) {
@@ -678,7 +669,7 @@ static CamelFolderInfo *
groupwise_build_folder_info(CamelGroupwiseStore *gw_store, const char *parent_name, const char *folder_name)
{
CamelURL *url ;
- const char *name, *full_name ;
+ const char *name;
CamelFolderInfo *fi ;
CamelGroupwiseStorePrivate *priv = gw_store->priv ;
@@ -687,21 +678,13 @@ groupwise_build_folder_info(CamelGroupwi
fi->unread = 0 ;
fi->total = 0 ;
-
-
if (parent_name)
- if (strlen(parent_name) > 0) {
- full_name = gw_get_path (gw_store, parent_name) ;
- fi->full_name = g_strconcat(full_name,"/",g_strdup(folder_name), NULL) ;
- } else
- fi->full_name = g_strdup (folder_name) ;
- else {
- full_name = gw_get_path (gw_store, folder_name) ;
- if (full_name)
- fi->full_name = g_strdup (full_name) ;
+ if (strlen(parent_name) > 0)
+ fi->full_name = g_strconcat(parent_name,"/",g_strdup(folder_name), NULL) ;
else
- fi->full_name = g_strdup(folder_name) ;
- }
+ fi->full_name = g_strdup (folder_name) ;
+ else
+ fi->full_name = g_strdup(folder_name) ;
url = camel_url_new(priv->base_url,NULL) ;
g_free(url->path) ;
@@ -775,7 +758,7 @@ groupwise_get_folder_info (CamelStore *s
GPtrArray *folders;
GList *folder_list = NULL, *temp_list = NULL ;
const char *url, *top_folder, *temp_url ;
- char *temp_str = NULL, *folder_real = NULL ;
+ char *folder_real = NULL ;
CamelFolderInfo *info = NULL ;
CAMEL_SERVICE_LOCK (store, connect_lock) ;
@@ -796,12 +779,7 @@ groupwise_get_folder_info (CamelStore *s
top_folder = "folders" ;
top = "" ;
} else {
- temp_str = strrchr (top, '/') ;
- if (temp_str) {
- temp_str++ ;
- top_folder = g_hash_table_lookup (priv->name_hash, temp_str) ;
- } else
- top_folder = g_hash_table_lookup (priv->name_hash, top) ;
+ top_folder = g_hash_table_lookup (priv->name_hash, top) ;
/* 'top' is a valid path, but doesnt have a container id
* return NULL */
if (!top_folder)
@@ -843,8 +821,6 @@ groupwise_get_folder_info (CamelStore *s
/*id_hash returns the name for a given container id*/
g_hash_table_insert (priv->id_hash, g_strdup(id), g_strdup(name)) ;
- /*name_hash returns the container id given the name */
- g_hash_table_insert (priv->name_hash, g_strdup(name), g_strdup(id)) ;
/*parent_hash returns the parent container id, given an id*/
g_hash_table_insert (priv->parent_hash, g_strdup(id), g_strdup(parent)) ;
@@ -858,6 +834,7 @@ groupwise_get_folder_info (CamelStore *s
EGwContainer *container = E_GW_CONTAINER (folder_list->data) ;
EGwContainerType type = e_gw_container_get_container_type (container) ;
const char *name = e_gw_container_get_name (container) ;
+ const char *id = e_gw_container_get_id (container);
if (e_gw_container_is_root (container))
continue ;
@@ -904,7 +881,7 @@ groupwise_get_folder_info (CamelStore *s
str = g_strconcat ( temp, "/", str, NULL) ;
temp_parent = g_hash_table_lookup (priv->parent_hash, temp_parent) ;
-
+
}
fi->full_name = g_strdup (str) ;
fi->uri = g_strconcat (url,str,NULL) ;
@@ -915,17 +892,20 @@ groupwise_get_folder_info (CamelStore *s
fi->uri = g_strconcat (url, "", name, NULL) ;
}
+ /*name_hash returns the container id given the name */
+ g_hash_table_insert (priv->name_hash, g_strdup(fi->full_name), g_strdup(id)) ;
+
if (e_gw_container_get_is_shared_to_me (container))
- fi->flags |= CAMEL_FOLDER_SHARED_TO_ME;
-
- if (e_gw_container_get_is_shared_by_me (container))
- fi->flags |= CAMEL_FOLDER_SHARED_BY_ME;
+ fi->flags |= CAMEL_FOLDER_SHARED_TO_ME;
+
+ if (e_gw_container_get_is_shared_by_me (container))
+ fi->flags |= CAMEL_FOLDER_SHARED_BY_ME;
fi->total = e_gw_container_get_total_count (container) ;
fi->unread = e_gw_container_get_unread_count (container) ;
/*refresh info*/
if (groupwise_store->current_folder &&
- strcmp (groupwise_store->current_folder->full_name, fi->full_name) == 0) {
+ strcmp (groupwise_store->current_folder->full_name, fi->full_name) == 0) {
CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (groupwise_store->current_folder))->refresh_info(groupwise_store->current_folder, ex);
}
@@ -934,14 +914,8 @@ groupwise_get_folder_info (CamelStore *s
}
g_free ((char *)url) ;
if ( (top != NULL) && (folders->len == 0)) {
- /*temp_str already contains the value if any*/
- if (temp_str) {
- CAMEL_SERVICE_UNLOCK (store, connect_lock);
- return groupwise_build_folder_info (groupwise_store, NULL, temp_str ) ;
- } else {
- CAMEL_SERVICE_UNLOCK (store, connect_lock);
- return groupwise_build_folder_info (groupwise_store, NULL, top ) ;
- }
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
+ return groupwise_build_folder_info (groupwise_store, NULL, top ) ;
}
info = camel_folder_info_build (folders, top, '/', TRUE) ;
g_ptr_array_free (folders, TRUE) ;
@@ -962,7 +936,7 @@ groupwise_create_folder(CamelStore *stor
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
CamelFolderInfo *root = NULL ;
- char *parent_id , *child_container_id, *temp_parent = NULL;
+ char *parent_id , *child_container_id;
int status;
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
@@ -973,14 +947,9 @@ groupwise_create_folder(CamelStore *stor
if(parent_name == NULL)
parent_name = "" ;
- if (parent_name && (strlen(parent_name) > 0) ) {
- temp_parent = strrchr (parent_name,'/') ;
- if (temp_parent && temp_parent[0]) {
- temp_parent++ ;
- parent_id = g_hash_table_lookup (priv->name_hash, g_strdup(temp_parent)) ;
- } else
- parent_id = g_hash_table_lookup (priv->name_hash, g_strdup(parent_name)) ;
- } else
+ if (parent_name && (strlen(parent_name) > 0) )
+ parent_id = g_hash_table_lookup (priv->name_hash, g_strdup(parent_name)) ;
+ else
parent_id = "" ;
if (!E_IS_GW_CONNECTION( priv->cnc)) {
@@ -996,7 +965,7 @@ groupwise_create_folder(CamelStore *stor
camel_store_summary_save((CamelStoreSummary *)groupwise_store->summary);
g_hash_table_insert (priv->id_hash, g_strdup(child_container_id), g_strdup(folder_name)) ;
- g_hash_table_insert (priv->name_hash, g_strdup(folder_name), g_strdup(child_container_id)) ;
+ g_hash_table_insert (priv->name_hash, g_strdup(root->full_name), g_strdup(child_container_id)) ;
g_hash_table_insert (priv->parent_hash, g_strdup(child_container_id), g_strdup(parent_id)) ;
camel_object_trigger_event (CAMEL_OBJECT (store), "folder_created", root);
@@ -1013,20 +982,14 @@ groupwise_delete_folder(CamelStore *stor
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
EGwConnectionStatus status ;
- const char *name = NULL;
const char * container ;
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot delete GroupWise folders in offline mode."));
return;
}
-
- name = strrchr (folder_name, '/') ;
- if (name) {
- name++ ;
- container = g_hash_table_lookup (priv->name_hash, name) ;
- } else
- container = g_hash_table_lookup (priv->name_hash, folder_name) ;
+
+ container = g_hash_table_lookup (priv->name_hash, folder_name) ;
CAMEL_SERVICE_LOCK (store, connect_lock) ;
@@ -1036,12 +999,9 @@ groupwise_delete_folder(CamelStore *stor
groupwise_forget_folder(groupwise_store,folder_name,ex) ;
g_hash_table_remove (priv->id_hash, container) ;
-
- if (name)
- g_hash_table_remove (priv->name_hash, name) ;
- else
- g_hash_table_remove (priv->name_hash, folder_name) ;
-
+
+ g_hash_table_remove (priv->name_hash, folder_name) ;
+
g_hash_table_remove (priv->parent_hash, container) ;
}
CAMEL_SERVICE_UNLOCK (store, connect_lock) ;
@@ -1060,19 +1020,14 @@ groupwise_rename_folder(CamelStore *stor
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
char *oldpath, *newpath, *storepath ;
const char *container_id ;
- char *temp_old = NULL, *temp_new = NULL ;
+ char *temp_new = NULL ;
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename GroupWise folders in offline mode."));
return;
}
CAMEL_SERVICE_LOCK (store, connect_lock) ;
- temp_old = strrchr (old_name,'/') ;
- if (temp_old) {
- temp_old++ ;
- container_id = camel_groupwise_store_container_id_lookup (groupwise_store, temp_old) ;
- } else
- container_id = camel_groupwise_store_container_id_lookup (groupwise_store, old_name) ;
+ container_id = camel_groupwise_store_container_id_lookup (groupwise_store, old_name) ;
temp_new = strrchr (new_name, '/') ;
if (temp_new)
@@ -1089,12 +1044,9 @@ groupwise_rename_folder(CamelStore *stor
g_hash_table_replace (priv->id_hash, g_strdup(container_id), g_strdup(temp_new)) ;
- g_hash_table_insert (priv->name_hash, g_strdup(temp_new), g_strdup(container_id)) ;
+ g_hash_table_insert (priv->name_hash, g_strdup(new_name), g_strdup(container_id)) ;
- if (temp_old)
- g_hash_table_remove (priv->name_hash, g_strdup(temp_old)) ;
- else
- g_hash_table_remove (priv->name_hash, g_strdup(old_name)) ;
+ g_hash_table_remove (priv->name_hash, g_strdup(old_name)) ;
/*FIXME:Update all the id in the parent_hash*/
storepath = g_strdup_printf ("%s/folders", priv->storage_path) ;
@@ -1202,34 +1154,6 @@ char *
storage_path_lookup (CamelGroupwiseStorePrivate *priv)
{
return priv->storage_path ;
-}
-
-const char *
-gw_get_path (CamelGroupwiseStore *gw_store, const char *folder_name)
-{
- CamelGroupwiseStorePrivate *priv = gw_store->priv ;
-
- const char *str = g_strdup (folder_name) ;
- gchar *container_id = NULL, *temp_parent = NULL, *temp = NULL ;
-
-
- container_id = g_hash_table_lookup (priv->name_hash, folder_name) ;
-
- if (container_id)
- temp_parent = g_hash_table_lookup (priv->parent_hash, container_id) ;
- else
- temp_parent = NULL ;
- while (temp_parent) {
- temp = g_hash_table_lookup (priv->id_hash, temp_parent ) ;
- if (temp == NULL) {
- break ;
- }
- str = g_strconcat ( temp, "/", str, NULL) ;
-
- temp_parent = g_hash_table_lookup (priv->parent_hash, temp_parent) ;
- }
-
- return str ;
}
static void
Index: camel-groupwise-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-folder.c,v
retrieving revision 1.43
diff -u -p -r1.43 camel-groupwise-folder.c
--- camel-groupwise-folder.c 21 Mar 2005 16:58:40 -0000 1.43
+++ camel-groupwise-folder.c 24 Mar 2005 05:04:00 -0000
@@ -88,7 +88,7 @@ groupwise_folder_get_message( CamelFolde
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE(folder->parent_store) ;
CamelGroupwiseStorePrivate *priv = gw_store->priv;
CamelGroupwiseMessageInfo *mi = NULL ;
- char *temp_name, *folder_name, *container_id, *body , *temp_str = NULL ;
+ char *container_id, *body , *temp_str = NULL ;
GSList *recipient_list, *attach_list ;
EGwItemOrganizer *org ;
EGwItemType type ;
@@ -153,16 +153,7 @@ groupwise_folder_get_message( CamelFolde
return NULL;
}
- folder_name = g_strdup(folder->name) ;
- temp_name = strrchr (folder_name,'/') ;
- if(temp_name == NULL) {
- container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, folder_name)) ;
- }
- else {
- temp_name++ ;
- container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, temp_name)) ;
- }
-
+ container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, folder->full_name)) ;
/*Create and populate the MIME Message structure*/
msg = camel_mime_message_new () ;
@@ -522,7 +513,7 @@ groupwise_sync (CamelFolder *folder, gbo
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return ;
- container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->name) ;
+ container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name) ;
CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock);
@@ -639,7 +630,7 @@ groupwise_refresh_info(CamelFolder *fold
char *container_id = NULL ;
char *time_string = NULL, *t_str = NULL ;
- container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, folder->name)) ;
+ container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, folder->full_name)) ;
if (!container_id) {
g_print ("\nERROR - Container id not present. Cannot refresh info\n") ;
return ;
@@ -856,7 +847,7 @@ groupwise_append_message (CamelFolder *f
}
CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock) ;
/*Get the container id*/
- container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->name) ;
+ container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name) ;
/* FIXME Separate To/CC/BCC? */
recipients = CAMEL_ADDRESS (camel_internet_address_new ());
camel_address_cat (recipients, CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO)));
@@ -950,10 +941,10 @@ groupwise_transfer_messages_to (CamelFol
*transferred_uids = NULL ;
if (delete_originals)
- source_container_id = camel_groupwise_store_container_id_lookup (gw_store, source->name) ;
+ source_container_id = camel_groupwise_store_container_id_lookup (gw_store, source->full_name) ;
else
source_container_id = NULL ;
- dest_container_id = camel_groupwise_store_container_id_lookup (gw_store, destination->name) ;
+ dest_container_id = camel_groupwise_store_container_id_lookup (gw_store, destination->full_name) ;
CAMEL_SERVICE_LOCK (source->parent_store, connect_lock);
/* check for offline operation */
@@ -1025,7 +1016,7 @@ groupwise_expunge (CamelFolder *folder,
cnc = cnc_lookup (priv) ;
- container_id = g_strdup (camel_groupwise_store_container_id_lookup (groupwise_store, folder->name)) ;
+ container_id = g_strdup (camel_groupwise_store_container_id_lookup (groupwise_store, folder->full_name)) ;
max = camel_folder_summary_count (folder->summary);
for (i = 0; i < max; i++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]