Re: [evolution-patches] Fix for bug 72145 (groupwise provider)




 



On Thu, 2005-03-10 at 21:34 +0800, Not Zed wrote:
Hi Michael,
had missed out duping on from. Its done now. And also using
g_string_append_printf, looks more readable fore sure. Changes made are
present in the attached patch.
Thanks,
partha

> si erehT,ahttraP iH
> On Thu, 2005-03-10 at 14:18 +0530, Parthasarathi Susarla wrote:
> 
> Hi Partha,
> 
> 
> There is still 1 problem with the code, setting info.from.  The other
> comments below are just suggestions.
> 
> Cheers,
> Michael

Index: camel-groupwise-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-folder.c,v
retrieving revision 1.36
diff -u -p -r1.36 camel-groupwise-folder.c
--- camel-groupwise-folder.c	10 Mar 2005 06:59:14 -0000	1.36
+++ camel-groupwise-folder.c	11 Mar 2005 05:39:12 -0000
@@ -713,6 +721,8 @@ gw_update_summary ( CamelFolder *folder,
 	guint32 item_status, status_flags = 0;
 	CamelFolderChangeInfo *changes = NULL ;
 	int scount ;
+	gboolean exists = FALSE ;
+	GString *str = g_string_new (NULL);
 	
 //	CAMEL_SERVICE_ASSERT_LOCKED (gw_store, connect_lock);
 
@@ -732,18 +742,10 @@ gw_update_summary ( CamelFolder *folder,
 
 		id = e_gw_item_get_id (item) ;
 		mi = (CamelGroupwiseMessageInfo *)camel_folder_summary_uid (folder->summary, id) ;
+		if (mi) 
+			exists = TRUE ;
 
-		if (mi) {
-			/*Message exists*/
-			item_status = e_gw_item_get_item_status (item);
-			/*if (item_status & E_GW_ITEM_STAT_DELETED)
-				status_flags |= CAMEL_MESSAGE_DELETED;*/
-			if (item_status & E_GW_ITEM_STAT_REPLIED)
-				status_flags |= CAMEL_MESSAGE_ANSWERED;
-			mi->info.flags |= status_flags;
-			camel_folder_change_info_change_uid (changes, e_gw_item_get_id (item)) ;
-		} else {
-			/*New message*/
+		if (!exists) {
 			mi = camel_message_info_new (folder->summary) ; 
 			if (mi->info.content == NULL) {
 				mi->info.content = camel_folder_summary_content_info_new (folder->summary);
@@ -751,67 +753,75 @@ gw_update_summary ( CamelFolder *folder,
 			}
 
 			type = e_gw_item_get_item_type (item) ;
-
-
-			if (type == E_GW_ITEM_TYPE_CONTACT) {
+			if ((type == E_GW_ITEM_TYPE_CONTACT) || (type == E_GW_ITEM_TYPE_UNKNOWN)) {
+				exists = FALSE;
 				continue ;
+			}
 
-			} else if (type == E_GW_ITEM_TYPE_UNKNOWN) 
-				continue ;
+		}
 
-			status_flags = 0;
-			item_status = e_gw_item_get_item_status (item);
-			if (item_status & E_GW_ITEM_STAT_READ)
-				status_flags |= CAMEL_MESSAGE_SEEN;
-			/*if (item_status & E_GW_ITEM_STAT_DELETED)
-				status_flags |= CAMEL_MESSAGE_DELETED;*/
-			if (item_status & E_GW_ITEM_STAT_REPLIED)
-				status_flags |= CAMEL_MESSAGE_ANSWERED;
-			mi->info.flags |= status_flags;
-
-			attach_list = e_gw_item_get_attach_id_list (item) ;
-			if (attach_list)  
-				mi->info.flags |= CAMEL_MESSAGE_ATTACHMENTS;
-
-			org = e_gw_item_get_organizer (item) ; 
-			if (org) 
-				mi->info.from = g_strconcat(org->display_name,"<",org->email,">",NULL) ;
-			recp_list = e_gw_item_get_recipient_list (item);
-			if (recp_list) {
-				GSList *rl;
-				char *str = "";
-				int i = 0;
-				for (rl = recp_list; rl != NULL; rl = rl->next) {
-					EGwItemRecipient *recp = (EGwItemRecipient *) rl->data;
-					if (recp->type == E_GW_ITEM_RECIPIENT_TO) {
-						if (i)
-							str = g_strconcat (str, ", ", NULL);
-						str = g_strconcat (str, recp->display_name,"<",
-								   recp->email,">", NULL);
-					}
-					i++;
+		item_status = e_gw_item_get_item_status (item);
+		if (item_status & E_GW_ITEM_STAT_READ)
+			status_flags |= CAMEL_MESSAGE_SEEN;
+		/*if (item_status & E_GW_ITEM_STAT_DELETED)
+		  status_flags |= CAMEL_MESSAGE_DELETED;*/
+		if (item_status & E_GW_ITEM_STAT_REPLIED)
+			status_flags |= CAMEL_MESSAGE_ANSWERED;
+		mi->info.flags |= status_flags;
+
+		attach_list = e_gw_item_get_attach_id_list (item) ;
+		if (attach_list)  
+			mi->info.flags |= CAMEL_MESSAGE_ATTACHMENTS;
+
+		org = e_gw_item_get_organizer (item) ; 
+		if (org) {
+			g_string_append_printf (str, org->display_name,
+					        "<", org->email,">");
+			mi->info.from = camel_pstring_strdup (str->str);
+		}
+		g_string_truncate (str, 0);
+		recp_list = e_gw_item_get_recipient_list (item);
+		if (recp_list) {
+			GSList *rl;
+			int i = 0;
+			for (rl = recp_list; rl != NULL; rl = rl->next) {
+				EGwItemRecipient *recp = (EGwItemRecipient *) rl->data;
+				if (recp->type == E_GW_ITEM_RECIPIENT_TO) {
+					if (i)
+						str = g_string_append (str, ", ");
+					g_string_append_printf (str, recp->display_name,
+							        "<", recp->email, ">");
 				}
-				mi->info.to = g_strdup(str);
-				g_free (str);
+				i++;
 			}
-			
-			temp_date = e_gw_item_get_creation_date(item) ;
-			if (temp_date) {
-				time_t time = e_gw_connection_get_date_from_string (temp_date) ;
-				time_t actual_time = camel_header_decode_date (ctime(&time), NULL) ;
-				mi->info.date_sent = mi->info.date_received = actual_time ;
-			}
-			mi->info.uid = g_strdup (e_gw_item_get_id (item)) ;
-			mi->info.subject = g_strdup (e_gw_item_get_subject(item)) ;
+			mi->info.to = camel_pstring_strdup (str->str);
+			g_string_truncate (str, 0);
+		}
 
+		temp_date = e_gw_item_get_creation_date(item) ;
+		if (temp_date) {
+			time_t time = e_gw_connection_get_date_from_string (temp_date) ;
+			time_t actual_time = camel_header_decode_date (ctime(&time), NULL) ;
+			mi->info.date_sent = mi->info.date_received = actual_time ;
+		}
 
+		mi->info.uid = g_strdup(e_gw_item_get_id(item));
+		
+		mi->info.subject = camel_pstring_strdup(e_gw_item_get_subject(item));
+		
+		if (exists) 
+			camel_folder_change_info_change_uid (changes, e_gw_item_get_id (item)) ;
+		else {
 			camel_folder_summary_add (folder->summary,(CamelMessageInfo *)mi) ;
 			camel_folder_change_info_add_uid (changes, mi->info.uid) ;
-			g_ptr_array_add (msg, mi) ;
-			g_free(date) ;
 		}
+
+		g_ptr_array_add (msg, mi) ;
+		g_free(date) ;
+		exists = FALSE ;
 		
 	}
+	g_string_free (str, TRUE);
 	camel_object_trigger_event (folder, "folder_changed", changes) ;
 		for (seq=0 ; seq<msg->len ; seq++) {
 		if ( (mi = msg->pdata[seq]) )


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