[evolution-mapi] BGO 580722 – Search based on recipient doesn't seem to work



commit 861fbcc1635c1498ffc08f16674c933941798362
Author: Johnny Jacob <jjohnny novell com>
Date:   Thu Jun 11 14:25:20 2009 +0530

    BGO 580722 â?? Search based on recipient doesn't seem to work
    
        * camel-mapi-folder.c (mapi_refresh_folder): Switch on RecipientTable
        fetching.
        (mapi_update_cache): If recipient fields are not available, switch to
        a fallback property.

 src/camel/ChangeLog           |    7 ++++
 src/camel/camel-mapi-folder.c |   66 +++++++++++++++++++++++-----------------
 2 files changed, 45 insertions(+), 28 deletions(-)
---
diff --git a/src/camel/ChangeLog b/src/camel/ChangeLog
index aa1c12b..2360a5f 100644
--- a/src/camel/ChangeLog
+++ b/src/camel/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-11  Johnny Jacob  <jjohnny novell com>
+
+	* camel-mapi-folder.c (mapi_refresh_folder): Switch on RecipientTable
+	fetching.
+	(mapi_update_cache): If recipient fields are not available, switch to
+	a fallback property.
+
 2009-06-03  Johnny Jacob  <jjohnny novell com>
 
 	* camel-mapi-store.h: Updates for new util functions.
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 4c9a383..42df562 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -345,12 +345,12 @@ mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **ch
 		return;
 	}
 
-	camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
+	camel_operation_start (NULL, _("Updating local summary cache for new messages in %s"), folder->name);
 
 	for ( ; item_list != NULL ; item_list = g_slist_next (item_list) ) {
 		MapiItem *temp_item ;
 		MapiItem *item;
-		gchar *msg_uid, *to = NULL, *from = NULL;
+		gchar *msg_uid, *to = NULL, *from = NULL, *cc = NULL;
 		guint64 id;
 
 		exists = FALSE;
@@ -388,7 +388,7 @@ mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **ch
 
 		if (!exists) {
  			GSList *l = NULL;
- 			guint32 i =0;
+ 			guint32 count_to = 0, count_cc =0;
 
 			mi->info.uid = exchange_mapi_util_mapi_ids_to_uid(item->fid, item->mid);
 			mi->info.subject = camel_pstring_strdup(item->header.subject);
@@ -396,9 +396,9 @@ mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **ch
 			mi->info.size = (guint32) item->header.size;
 
  			for (l = item->recipients; l; l=l->next) {
- 				char *formatted_id;
+ 				gchar *formatted_id = NULL;
 				const char *name, *display_name;
- 				uint32_t *type = NULL; 
+ 				guint32 *type = NULL;
  				struct SRow aRow;
  				ExchangeMAPIRecipient *recip = (ExchangeMAPIRecipient *)(l->data);
  				
@@ -410,31 +410,42 @@ mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **ch
  				aRow.ulAdrEntryPad = 0;
  				aRow.cValues = recip->out.all_cValues;
  				aRow.lpProps = recip->out.all_lpProps;
- 				
+
  				type = (uint32_t *) find_SPropValue_data(&aRow, PR_RECIPIENT_TYPE);
- 
- 				if (*type == MAPI_TO) {
- 					/*Name is probably available in one of these props.*/
+
+				if (type) {
  					name = (const char *) find_SPropValue_data(&aRow, PR_DISPLAY_NAME);
  					name = name ? name : (const char *) find_SPropValue_data(&aRow, PR_RECIPIENT_DISPLAY_NAME);
  					name = name ? name : (const char *) find_SPropValue_data(&aRow, 
  												 PR_RECIPIENT_DISPLAY_NAME_UNICODE);
  					name = name ? name : (const char *) find_SPropValue_data(&aRow, 
  												 PR_7BIT_DISPLAY_NAME_UNICODE);
- 					display_name = name ? name : g_strdup (recip->email_id);
+ 					display_name = name ? name : recip->email_id;
  					formatted_id = camel_internet_address_format_address(display_name, recip->email_id);
- 
- 					/* hmm */
- 					if (i) 
- 						to = g_strconcat (to, ", ", NULL);
- 
-					to = g_strconcat (to, formatted_id, NULL);
 
-					g_free (formatted_id);
- 					i++;
- 				}
- 
- 				/*TODO : from ? */
+					switch (*type) {
+					case MAPI_TO:
+						if (count_to) {
+							to = g_strconcat (to, ", ", formatted_id, NULL);
+							g_free (formatted_id);
+						} else
+							to = formatted_id;
+						count_to ++;
+						break;
+
+					case MAPI_CC:
+						if (count_cc) {
+							cc = g_strconcat (cc, ", ", formatted_id, NULL);
+							g_free (formatted_id);
+						} else
+							cc = formatted_id;
+						count_cc ++;
+						break;
+
+					default:
+						continue;
+					}
+				}
  			}
  			
  			if ((item->header.from_type != NULL) && !g_utf8_collate (item->header.from_type, "EX")) {
@@ -455,7 +466,10 @@ mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **ch
  				mi->info.from = camel_pstring_strdup (from);
 			} else
 				mi->info.from = NULL;
- 			mi->info.to = camel_pstring_strdup (to);
+
+			/* Fallback */
+ 			mi->info.to = to ? camel_pstring_strdup (to) : g_strdup (item->header.to);
+ 			mi->info.cc = to ? camel_pstring_strdup (cc) : g_strdup (item->header.cc);
 		}
 
 		if (exists) {
@@ -744,6 +758,8 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
 			goto end2;
 		}
 
+		options |= MAPI_OPTIONS_FETCH_RECIPIENTS;
+
 		if (((CamelMapiFolder *)folder)->type & CAMEL_MAPI_FOLDER_PUBLIC)
 			options |= MAPI_OPTIONS_USE_PFSTORE;
 
@@ -1446,11 +1462,6 @@ mapi_get_message_info(CamelFolder *folder, const char *uid)
 	}
 	msg_info = camel_message_info_new(folder->summary);
 	mi = (CamelMessageInfoBase *)msg_info ;
-	//TODO :
-/* 	oc_message_headers_init(&headers); */
-/* 	oc_thread_connect_lock(); */
-/* 	status = oc_message_headers_get_by_id(&headers, uid); */
-/* 	oc_thread_connect_unlock(); */
 
 	if (headers.subject) mi->subject = (char *)camel_pstring_strdup(headers.subject);
 	if (headers.from) mi->from = (char *)camel_pstring_strdup(headers.from);
@@ -1458,7 +1469,6 @@ mapi_get_message_info(CamelFolder *folder, const char *uid)
 	if (headers.cc) mi->cc = (char *)camel_pstring_strdup(headers.cc);
 	mi->flags = headers.flags;
 
-
 	mi->user_flags = NULL;
 	mi->user_tags = NULL;
 	mi->date_received = 0;



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