* Update ical_dezonify() to use system tzdata
[citadel.git] / citadel / modules / calendar / serv_calendar.c
index 062e24d055c57cbf316c72e41536dfd6964e343e..b1610c7fecaad4efce96041a7a8888f802ec3e7e 100644 (file)
@@ -87,11 +87,6 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
        /* Encapsulate the subcomponent inside */
        icalcomponent_add_component(encaps, subcomp);
 
-       /* Convert all timestamps to UTC so we don't have to deal with
-        * stupid VTIMEZONE crap.
-        */
-       ical_dezonify(encaps);
-
        /* Return the object we just created. */
        return(encaps);
 }
@@ -124,7 +119,7 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
                return;
        }
 
-       ser = icalcomponent_as_ical_string(cal);
+       ser = icalcomponent_as_ical_string_r(cal);
        if (ser == NULL) return;
 
        /* If the caller supplied a user, write to that user's default calendar room */
@@ -162,7 +157,7 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
        }
 
        /* In either case, now we can free the serialized calendar object */
-//     free(ser);
+       free(ser);
 }
 
 
@@ -174,6 +169,15 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
 void ical_add(icalcomponent *cal, int recursion_level) {
        icalcomponent *c;
 
+#if 1
+       /* Write the whole thing because it may need to save timezones etc.
+        * FIXME - if this works, we can probably eliminate this entire function
+        */
+
+       ical_write_to_cal(&CC->user, cal);
+
+#else  /* this was the old code to kill everything but the VEVENT component ... probably ng now */
+
        /*
         * The VEVENT subcomponent is the one we're interested in saving.
         */
@@ -190,6 +194,7 @@ void ical_add(icalcomponent *cal, int recursion_level) {
                /* Recursively process subcomponent */
                ical_add(c, recursion_level+1);
        }
+#endif
 
 }
 
@@ -315,7 +320,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
        }
 
        /* Now generate the reply message and send it out. */
-       serialized_reply = strdup(icalcomponent_as_ical_string(the_reply));
+       serialized_reply = icalcomponent_as_ical_string_r(the_reply);
        icalcomponent_free(the_reply);  /* don't need this anymore */
        if (serialized_reply == NULL) return;
 
@@ -355,7 +360,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
  */
 void ical_locate_part(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata) {
+               char *cbid, void *cbuserdata) {
 
        struct ical_respond_data *ird = NULL;
 
@@ -382,9 +387,6 @@ void ical_locate_part(char *name, char *filename, char *partnum, char *disp,
        }
 
        ird->cal = icalcomponent_new_from_string(content);
-       if (ird->cal != NULL) {
-               ical_dezonify(ird->cal);
-       }
 }
 
 
@@ -514,7 +516,7 @@ struct original_event_container {
  */
 void ical_locate_original_event(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata) {
+               char *cbid, void *cbuserdata) {
 
        struct original_event_container *oec = NULL;
 
@@ -688,7 +690,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
        ical_merge_attendee_reply(original_event, cal);
 
        /* Serialize it */
-       serialized_event = strdup(icalcomponent_as_ical_string(original_event));
+       serialized_event = icalcomponent_as_ical_string_r(original_event);
        icalcomponent_free(original_event);     /* Don't need this anymore. */
        if (serialized_event == NULL) return(2);
 
@@ -1009,6 +1011,7 @@ void ical_conflicts_phase5(struct icaltimetype t1start,
                }
 
        } while ( (rrule) && (!icaltime_is_null_time(t2start)) && (num_recur < MAX_RECUR) );
+       icalrecur_iterator_free(ritr);
        if (num_recur > 0) CtdlLogPrintf(CTDL_DEBUG, "Iterated over existing event %d times.\n", num_recur);
 }
 
@@ -1078,6 +1081,7 @@ void ical_conflicts_phase4(icalcomponent *proposed_event,
                }
 
        } while ( (rrule) && (!icaltime_is_null_time(t1start)) && (num_recur < MAX_RECUR) );
+       icalrecur_iterator_free(ritr);
        if (num_recur > 0) CtdlLogPrintf(CTDL_DEBUG, "Iterated over proposed event %d times.\n", num_recur);
 }
 
@@ -1212,8 +1216,6 @@ void ical_add_to_freebusy(icalcomponent *fb, icalcomponent *cal) {
                return;
        }
 
-       ical_dezonify(cal);
-
        /* If this event is not opaque, the user isn't publishing it as
         * busy time, so don't bother doing anything else.
         */
@@ -1469,7 +1471,7 @@ void ical_freebusy(char *who) {
 
        /* Serialize it */
        CtdlLogPrintf(CTDL_DEBUG, "Serializing\n");
-       serialized_request = strdup(icalcomponent_as_ical_string(encaps));
+       serialized_request = icalcomponent_as_ical_string_r(encaps);
        icalcomponent_free(encaps);     /* Don't need this anymore. */
 
        cprintf("%d Here is the free/busy data:\n", LISTING_FOLLOWS);
@@ -1585,7 +1587,7 @@ void ical_getics(void)
                (void *) encaps
        );
 
-       ser = strdup(icalcomponent_as_ical_string(encaps));
+       ser = icalcomponent_as_ical_string_r(encaps);
        client_write(ser, strlen(ser));
        free(ser);
        cprintf("\n000\n");
@@ -1623,7 +1625,6 @@ void ical_putics(void)
 
        cal = icalcomponent_new_from_string(calstream);
        free(calstream);
-       ical_dezonify(cal);
 
        /* We got our data stream -- now do something with it. */
 
@@ -1894,9 +1895,6 @@ void ical_send_out_invitations(icalcomponent *cal) {
        /* Set the method to REQUEST */
        icalcomponent_set_method(encaps, ICAL_METHOD_REQUEST);
 
-       /* Now make sure all of the DTSTART and DTEND properties are UTC. */
-       ical_dezonify(the_request);
-
        /* Here we go: put the VEVENT into the VCALENDAR.  We now no longer
         * are responsible for "the_request"'s memory -- it will be freed
         * when we free "encaps".
@@ -1904,7 +1902,7 @@ void ical_send_out_invitations(icalcomponent *cal) {
        icalcomponent_add_component(encaps, the_request);
 
        /* Serialize it */
-       serialized_request = strdup(icalcomponent_as_ical_string(encaps));
+       serialized_request = icalcomponent_as_ical_string_r(encaps);
        icalcomponent_free(encaps);     /* Don't need this anymore. */
        if (serialized_request == NULL) return;
 
@@ -2007,7 +2005,7 @@ void ical_saving_vevent(icalcomponent *cal) {
  */
 void ical_obj_beforesave_backend(char *name, char *filename, char *partnum,
                char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
-               char *encoding, void *cbuserdata)
+               char *encoding, char *cbid, void *cbuserdata)
 {
        icalcomponent *cal, *nested_event, *nested_todo, *whole_cal;
        icalproperty *p;
@@ -2151,7 +2149,7 @@ int ical_obj_beforesave(struct CtdlMessage *msg)
  */
 void ical_obj_aftersave_backend(char *name, char *filename, char *partnum,
                char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
-               char *encoding, void *cbuserdata)
+               char *encoding, char *cbid, void *cbuserdata)
 {
        icalcomponent *cal;
 
@@ -2292,7 +2290,6 @@ void ical_fixed_output(char *ptr, int len) {
                return;
        }
 
-       ical_dezonify(cal);
        ical_fixed_output_backend(cal, 0);
 
        /* Free the memory we obtained from libical's constructor */