Re: [evolution-patches] Fix for bug 72145 (groupwise provider)
- From: Not Zed <notzed ximian com>
- To: sparthasarathi novell com
- Cc: evolution-patches lists ximian com
- Subject: Re: [evolution-patches] Fix for bug 72145 (groupwise provider)
- Date: Thu, 10 Mar 2005 21:34:51 +0800
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
CamelFolderChangeInfo *changes = NULL ;
int scount ;
+ gboolean exists = FALSE ;
+ char *uid = 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 ;
Adding the 'exists' variable just seems to make the logic more complex to me (?). But no matter, there may be somethingg not obvious going on here.
- 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,65 +753,77 @@ 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)
+ mi->info.from = g_strconcat(org->display_name,"<",org->email,">",NULL) ;
>From must be camel_pstring_strdup'd. only uid is g_strdup'd.
+ recp_list = e_gw_item_get_recipient_list (item);
+ if (recp_list) {
+ GSList *rl;
+ GString *str = g_string_new (NULL);
Is this whole block inside another loop? If it is you should just allocate one string in the whole function, and truncate it to 0 length here, you could also use it to build the from string above.
+ 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, ", ");
+ str = g_string_append (str, recp->display_name);
+ str = g_string_append (str, "<");
+ str = g_string_append (str, recp->email);
+ str = g_string_append (str, ">");
You can just use g_string_append_printf() fwiw (not that it really makes any difference in this case, although it might be more readable).
}
- 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_free (str, TRUE);
+ }
+ 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 ;
+ }
+ uid = e_gw_item_get_id (item);
+ if (uid) {
+ int len = strlen(uid);
+ mi->info.uid = g_malloc0 (len+1);
Much easier just to use g_strdup here, it does a g_malloc, also it doesn't waste setting the memory twice (all 0's then copying the string).
+ mi->info.uid = (char *)memcpy(mi->info.uid, uid, len);
+ uid = NULL;
+ }
+
+ 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 ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]