Re: [evolution-patches] patch for #70035 (calendar)
- From: Rodrigo Moya <rodrigo novell com>
- To: JP Rosevear <jpr novell com>
- Cc: Evolution Patches <evolution-patches lists ximian com>
- Subject: Re: [evolution-patches] patch for #70035 (calendar)
- Date: Thu, 31 Mar 2005 14:44:03 +0200
On Wed, 2005-03-30 at 15:44 -0500, JP Rosevear wrote:
> On Tue, 2005-03-29 at 12:18 +0200, Rodrigo Moya wrote:
> > 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
>
> Is there no way to fix this in libical? Otherwise importing will need
> this one off fix as well (and perhaps other things?)
>
there is a tricky way to fix it in libical, which I haven't been able to
find easily. But I did it this way to allow for a icalcomponent ->
ecalcomponent transition in the API for 2.3/2.4, if we ever do it.
Attached patch makes the importer do the same. About other parts, what
else should be using it?
--
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 31 Mar 2005 12:44:22 -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 31 Mar 2005 12:44:23 -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 31 Mar 2005 12:44:23 -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) {
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2706
diff -u -p -r1.2706 ChangeLog
--- ChangeLog 31 Mar 2005 05:26:27 -0000 1.2706
+++ ChangeLog 31 Mar 2005 12:45:25 -0000
@@ -1,3 +1,10 @@
+2005-03-xx Rodrigo Moya <rodrigo novell com>
+
+ Fixes #70035
+
+ * importers/icalendar-importer.c (support_format_fn, load_file_fn):
+ use e_cal_util_parse_ics_string instead of icalparser_parse_string.
+
2005-03-31 Chenthill Palanisamy <pchenthill novell com>
Fixes #73969
Index: importers/icalendar-importer.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/importers/icalendar-importer.c,v
retrieving revision 1.39
diff -u -p -r1.39 icalendar-importer.c
--- importers/icalendar-importer.c 19 Jan 2005 16:28:34 -0000 1.39
+++ importers/icalendar-importer.c 31 Mar 2005 12:45:25 -0000
@@ -362,7 +362,7 @@ support_format_fn (EvolutionImporter *im
if (g_file_get_contents (filename, &contents, NULL, NULL)) {
/* parse the file */
- icalcomp = icalparser_parse_string (contents);
+ icalcomp = e_cal_util_parse_ics_string (contents);
g_free (contents);
if (icalcomp) {
@@ -392,7 +392,7 @@ load_file_fn (EvolutionImporter *importe
icalcomponent *icalcomp;
/* parse the file */
- icalcomp = icalparser_parse_string (contents);
+ icalcomp = e_cal_util_parse_ics_string (contents);
g_free (contents);
if (icalcomp) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]