[evolution-patches] (groupwise) using GString



hi,
the attached patch modifies the convert_to_calendar function. Uses
GString now. 
Thanks,
partha
Index: camel-groupwise-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-folder.c,v
retrieving revision 1.38
diff -u -p -r1.38 camel-groupwise-folder.c
--- camel-groupwise-folder.c	11 Mar 2005 08:39:56 -0000	1.38
+++ camel-groupwise-folder.c	16 Mar 2005 09:47:22 -0000
@@ -1155,53 +1156,76 @@ gw_getv (CamelObject *object, CamelExcep
 void 
 convert_to_calendar (EGwItem *item, char **str, int *len)
 {
-	EGwItemOrganizer *org = e_gw_item_get_organizer(item) ;
+	EGwItemOrganizer *org = NULL;
 	GSList *recp_list = NULL ;
-	const char *desc = e_gw_item_get_message (item) ;
-	const char *location = e_gw_item_get_place (item) ;
-	char *temp = "", **tmp;
-	const char *priority = e_gw_item_get_task_priority (item) ;
+	GSList *attach_list = NULL;
+	GString *gstr = g_string_new (NULL);
+	char **tmp;
+	const char *temp = NULL;
+	
+	
 
 	tmp = g_strsplit (e_gw_item_get_id (item), "@", -1);
+
+	gstr = g_string_append (gstr, "BEGIN:VCALENDAR\n");
+	gstr = g_string_append (gstr, "METHOD:REQUEST\n");
+	gstr = g_string_append (gstr, "BEGIN:VEVENT\n");
+	g_string_append_printf (gstr, "UID:%s\n",e_gw_item_get_icalid (item));
+	g_string_append_printf (gstr, "X-GWITEM-TYPE:APPOINTMENT\n");
+	g_string_append_printf (gstr, "DTSTART:%s\n",e_gw_item_get_start_date (item));
+	g_string_append_printf (gstr, "SUMMARY:%s\n", e_gw_item_get_subject (item));
+	g_string_append_printf (gstr, "DESCRIPTION:%s\n", e_gw_item_get_message (item));
+	g_string_append_printf (gstr, "DTSTAMP:%s\n", e_gw_item_get_creation_date (item));
+	g_string_append_printf (gstr, "X-GWMESSAGEID:%s\n", e_gw_item_get_id (item));
+	g_string_append_printf (gstr, "X-GWSHOW-AS:BUSY\n");
+	g_string_append_printf (gstr, "X-GWRECORDID:%s\n", tmp[0]);
+
+	org = e_gw_item_get_organizer (item);
+	if (org)
+		g_string_append_printf (gstr, "ORGANIZER;CN= %s;ROLE= CHAIR;\n MAILTO:%s\n", 
+				        org->display_name, org->email);
+	
 	recp_list = e_gw_item_get_recipient_list (item) ;
 	if (recp_list) {
 		GSList *rl ;
 
 		for (rl = recp_list ; rl != NULL ; rl = rl->next) {
 			EGwItemRecipient *recp = (EGwItemRecipient *) rl->data;
-			temp = g_strconcat (temp, "ATTENDEE;CN= ",recp->display_name, 
-					     ";ROLE= REQ-PARTICIPANT:", "\n", 
-					     " MAILTO:", recp->email, "\n",  NULL) ;
-		}
-	}
-	*str = g_strconcat ("BEGIN:VCALENDAR","\n", 
-			    "METHOD:REQUEST", "\n", 
-			    "BEGIN:VEVENT", "\n", 
-			    "UID:", e_gw_item_get_icalid (item), "\n",
-			    "X-GWITEM-TYPE:APPOINTMENT", "\n", 
-			    "DTSTART:", e_gw_item_get_start_date (item), "\n",
-			    "SUMMARY:", e_gw_item_get_subject (item), "\n",
-	                    "DTSTAMP:", e_gw_item_get_creation_date (item), "\n",
-			    "X-GWMESSAGEID:", e_gw_item_get_id(item), "\n", 
-			    "X-GWSHOW-AS:BUSY", "\n",
-			    "X-GWRECORDID:", tmp [0], "\n", 
-			    "ORGANIZER;CN= ",org ? org->display_name : "", 
-			    ";ROLE= CHAIR:", "\n", 
-			    " MAILTO:", org ? org->email : "", "\n",
-			    "DESCRIPTION:", desc ? desc : "" , "\n",
-			    temp ? temp : "", "\n", 
-			    "DTEND:", e_gw_item_get_end_date (item), "\n",
-			    "LOCATION:", location ? location : "", "\n", 
-			    "PRIORITY:",priority ? priority : "", "\n",
-			    //"UID:", e_gw_item_get_icalid (item), "\n", NULL) ;
-			    "END:VEVENT", "\n", 
-			    "END:VCALENDAR","\n", 
-			    NULL ) ;
+			g_string_append_printf (gstr, 
+					"ATTENDEE;CN= %s;ROLE= REQ-PARTICIPANT:\nMAILTO:%s\n",
+					recp->display_name, recp->email);
+		}
+	}
+	
+	g_string_append_printf (gstr, "DTEND:%s\n", e_gw_item_get_end_date (item));
+
+	temp = e_gw_item_get_place (item);
+	if (temp)
+		g_string_append_printf (gstr, "LOCATION:%s\n", temp);
+	
+	temp = NULL;
+	temp = e_gw_item_get_task_priority (item);
+	if (temp)
+		g_string_append_printf (gstr, "PRIORITY:%s\n", temp);
+
+	temp = NULL;
+	attach_list = e_gw_item_get_attach_id_list (item);
+	if (attach_list) {
+		GSList *al ;
+
+		for (al = attach_list ; al != NULL ; al = al->next) {
+			EGwItemAttachment *attach = (EGwItemAttachment *)al->data ;
+			g_string_append_printf (gstr, "ATTACH:%s\n", attach->id);
+		}
+	}
+	gstr = g_string_append (gstr, "END:VEVENT\n");
+	gstr = g_string_append (gstr, "END:VCALENDAR\n");
+	
 
+	*str = g_strdup (gstr->str);
 	*len = strlen (*str) ;
 	
-	if (temp && strlen(temp))
-		g_free (temp) ;
+	g_string_free (gstr, TRUE);
 	g_strfreev (tmp);
 }
 


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