[evolution-patches] patch for #70035 (calendar)



This fixes the problem we are having with calendars generated with
mozilla, which contain several VCALENDAR's. It adds new API, but, for
the time being, internal to e-d-s. For HEAD, I'll add the new function
prototype to e-cal-util.h
-- 
Rodrigo Moya <rodrigo novell com>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.443
diff -u -p -r1.443 ChangeLog
--- ChangeLog	24 Mar 2005 08:40:24 -0000	1.443
+++ ChangeLog	29 Mar 2005 10:12:13 -0000
@@ -1,3 +1,13 @@
+2005-xx-xx  Rodrigo Moya <rodrigo novell com>
+
+	Fixes #70035
+
+	* libecal/e-cal-util.c (e_cal_util_parse_ics_string): new function that
+	supports strings with multiple VCALENDAR's.
+
+	* backends/http/e-cal-backend-http.c (retrieval_done): use the new
+	function instead of icalparser_parse_string.
+
 2005-03-24  Chenthill Palanisamy  <pchenthill novell com>
 	
 	Fixes #73336	
Index: libecal/e-cal-util.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal-util.c,v
retrieving revision 1.8
diff -u -p -r1.8 e-cal-util.c
--- libecal/e-cal-util.c	2 Feb 2005 18:44:32 -0000	1.8
+++ libecal/e-cal-util.c	29 Mar 2005 10:12:13 -0000
@@ -117,6 +117,74 @@ e_cal_util_new_component (icalcomponent_
 }
 
 static char *
+read_line (const char *string)
+{
+	char *line;
+	GString *line_str = NULL;
+
+	for (; *string; string++) {
+		if (!line_str)
+			line_str = g_string_new ("");
+
+		line_str = g_string_append_c (line_str, *string);
+		if (*string == '\n')
+			break;
+	}
+
+	line = line_str->str;
+	g_string_free (line_str, FALSE);
+
+	return line;
+}
+
+icalcomponent *
+e_cal_util_parse_ics_string (const char *string)
+{
+	icalcomponent *icalcomp = NULL;
+
+	g_return_val_if_fail (string != NULL, NULL);
+
+	/* Split string into separated VCALENDAR's, if more than one */
+	if (!strncmp (string, "BEGIN:VCALENDAR", 15)) {
+		char *s;
+		GString *comp_str = NULL;
+
+		s = string;
+		while (*s) {
+			char *line = read_line (s);
+			if (line) {
+				if (!comp_str)
+					comp_str = g_string_new (line);
+				else
+					comp_str = g_string_append (comp_str, line);
+
+				if (!strncmp (line, "END:VCALENDAR", 13)) {
+					icalcomponent *tmp;
+
+					tmp = icalparser_parse_string (comp_str->str);
+					if (tmp) {
+						if (icalcomp)
+							icalcomponent_merge_component (icalcomp, tmp);
+						else
+							icalcomp = tmp;
+					}
+
+					g_string_free (comp_str, TRUE);
+					comp_str = NULL;
+				}
+
+				s += strlen (line);
+
+				g_free (line);
+			}
+		}
+	} else
+		icalcomp = icalparser_parse_string (string);
+
+	return icalcomp;
+}
+
+static char *
 get_line_fn (char *buf, size_t size, void *file)
 {
 	return fgets (buf, size, file);
Index: backends/http/e-cal-backend-http.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/http/e-cal-backend-http.c,v
retrieving revision 1.34
diff -u -p -r1.34 e-cal-backend-http.c
--- backends/http/e-cal-backend-http.c	6 Mar 2005 02:47:03 -0000	1.34
+++ backends/http/e-cal-backend-http.c	29 Mar 2005 10:12:13 -0000
@@ -256,7 +256,7 @@ retrieval_done (SoupMessage *msg, ECalBa
 	/* get the calendar from the response */
 	str = g_malloc0 (msg->response.length + 1);
 	strncpy (str, msg->response.body, msg->response.length);
-	icalcomp = icalparser_parse_string (str);
+	icalcomp = e_cal_util_parse_ics_string (str);
 	g_free (str);
 
 	if (!icalcomp) {


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