From 6335fc8ec885d1a93ff58fc0321fce3ba2c5c42a Mon Sep 17 00:00:00 2001 From: 1 Date: Thu, 11 Oct 2001 23:39:08 +0000 Subject: convert the uids list to a subset appropriate for each subfolder before 2001-10-11 * camel-vee-folder.c (vee_search_by_uids): convert the uids list to a subset appropriate for each subfolder before trying to search on it. svn path=/trunk/; revision=13607 --- camel/camel-vee-folder.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'camel/camel-vee-folder.c') diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c index 3f05626ceb..81a38ae7b5 100644 --- a/camel/camel-vee-folder.c +++ b/camel/camel-vee-folder.c @@ -614,6 +614,7 @@ vee_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *uids, { GList *node; GPtrArray *matches, *result = g_ptr_array_new (); + GPtrArray *folder_uids = g_ptr_array_new(); char *expr; CamelVeeFolder *vf = (CamelVeeFolder *)folder; struct _CamelVeeFolderPrivate *p = _PRIVATE(vf); @@ -631,15 +632,26 @@ vee_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *uids, /* make sure we only search each folder once - for unmatched folder to work right */ if (g_hash_table_lookup(searched, f) == NULL) { camel_vee_folder_hash_folder(f, hash); - matches = camel_folder_search_by_uids(f, expression, uids, ex); - if (matches) { - for (i = 0; i < matches->len; i++) { - char *uid = matches->pdata[i]; - g_ptr_array_add(result, g_strdup_printf("%.8s%s", hash, uid)); + + /* map the vfolder uid's to the source folder uid's first */ + g_ptr_array_set_size(folder_uids, 0); + for (i=0;ilen;i++) { + char *uid = uids->pdata[i]; + + if (strlen(uid) >= 8 && strncmp(uid, hash, 8) == 0) + g_ptr_array_add(folder_uids, uid+8); + } + if (folder_uids->len > 0) { + matches = camel_folder_search_by_uids(f, expression, folder_uids, ex); + if (matches) { + for (i = 0; i < matches->len; i++) { + char *uid = matches->pdata[i]; + g_ptr_array_add(result, g_strdup_printf("%.8s%s", hash, uid)); + } + camel_folder_search_free(f, matches); + } else { + g_warning("Search failed: %s", camel_exception_get_description(ex)); } - camel_folder_search_free(f, matches); - } else { - g_warning("Search failed: %s", camel_exception_get_description(ex)); } g_hash_table_insert(searched, f, f); } @@ -650,6 +662,7 @@ vee_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *uids, CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock); g_hash_table_destroy(searched); + g_ptr_array_free(folder_uids, 0); return result; } -- cgit v1.2.3