* ical_dezonify.c: brought over new version from the Citadel source.
authorArt Cancro <ajc@citadel.org>
Sat, 28 Dec 2002 05:12:45 +0000 (05:12 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 28 Dec 2002 05:12:45 +0000 (05:12 +0000)
webcit/ChangeLog
webcit/ical_dezonify.c

index 851cba233ad06c85e3fd0c7ff488353da45d6136..dae1269f55da9c7e20d2fa064bcd43fca7dfc52b 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 400.72  2002/12/28 05:12:45  ajc
+* ical_dezonify.c: brought over new version from the Citadel source.
+
 Revision 400.71  2002/12/26 04:04:48  ajc
 * Perform CHEK command when automatically establishing sessions, not just
   when one is explicitly created.  Some stuff is missing otherwise.
@@ -1202,4 +1205,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index 1902b26e11498e90378bf10b41a51fc50f832d58..751b80e8142184de3fcf50a0ff61ffa80804739b 100644 (file)
@@ -2,28 +2,35 @@
  * $Id$ 
  *
  * Function to go through an ical component set and convert all non-UTC
- * DTSTART and DTEND properties to UTC.  It also strips out any VTIMEZONE
+ * date/time properties to UTC.  It also strips out any VTIMEZONE
  * subcomponents afterwards, because they're irrelevant.
  *
  */
 
-#ifdef HAVE_ICAL_H
 
-#include <stdlib.h>
 #include <unistd.h>
-#include <string.h>
-#include <ctype.h>
-#include <fcntl.h>
 #include <sys/types.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include "webcit.h"
+
+#ifdef HAVE_ICAL_H
 #include <ical.h>
 
+
 /*
  * Back end function for ical_dezonify()
  *
- * We supply this with the master component and the property (which will
- * be a DTSTART or DTEND) which we want to convert to UTC.
+ * We supply this with the master component, the relevant component,
+ * and the property (which will be a DTSTART, DTEND, etc.)
+ * which we want to convert to UTC.
  */
-void ical_dezonify_backend(icalcomponent *cal, icalproperty *prop) {
+void ical_dezonify_backend(icalcomponent *cal,
+                       icalcomponent *rcal,
+                       icalproperty *prop) {
+
        icaltimezone *t;
        icalparameter *param;
        const char *tzid;
@@ -52,24 +59,37 @@ void ical_dezonify_backend(icalcomponent *cal, icalproperty *prop) {
        else if (icalproperty_isa(prop) == ICAL_DTEND_PROPERTY) {
                TheTime = icalproperty_get_dtend(prop);
        }
+       else if (icalproperty_isa(prop) == ICAL_DUE_PROPERTY) {
+               TheTime = icalproperty_get_due(prop);
+       }
+       else if (icalproperty_isa(prop) == ICAL_EXDATE_PROPERTY) {
+               TheTime = icalproperty_get_exdate(prop);
+       }
+       else {
+               return;
+       }
 
-       /* Do the conversion.
-        */
+       /* Do the conversion. */
        icaltimezone_convert_time(&TheTime,
                                t,
                                icaltimezone_get_utc_timezone()
        );
+       TheTime.is_utc = 1;
+       icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER);
 
-       /* Now strip the TZID parameter, because it's incorrect now. */
-       icalproperty_remove_parameter(prop, ICAL_TZID_PARAMETER);
-
+       /* Now add the converted property back in. */
        if (icalproperty_isa(prop) == ICAL_DTSTART_PROPERTY) {
                icalproperty_set_dtstart(prop, TheTime);
        }
        else if (icalproperty_isa(prop) == ICAL_DTEND_PROPERTY) {
                icalproperty_set_dtend(prop, TheTime);
        }
-
+       else if (icalproperty_isa(prop) == ICAL_DUE_PROPERTY) {
+               icalproperty_set_due(prop, TheTime);
+       }
+       else if (icalproperty_isa(prop) == ICAL_EXDATE_PROPERTY) {
+               icalproperty_set_exdate(prop, TheTime);
+       }
 }
 
 
@@ -106,8 +126,10 @@ void ical_dezonify_recur(icalcomponent *cal, icalcomponent *rcal) {
                if (
                        (icalproperty_isa(p) == ICAL_DTSTART_PROPERTY)
                        || (icalproperty_isa(p) == ICAL_DTEND_PROPERTY)
+                       || (icalproperty_isa(p) == ICAL_DUE_PROPERTY)
+                       || (icalproperty_isa(p) == ICAL_EXDATE_PROPERTY)
                   ) {
-                       ical_dezonify_backend(cal, p);
+                       ical_dezonify_backend(cal, rcal, p);
                }
        }
 }
@@ -130,6 +152,8 @@ void ical_dezonify(icalcomponent *cal) {
                icalcomponent_remove_component(cal, vt);
                icalcomponent_free(vt);
        }
+
 }
 
+
 #endif /* HAVE_ICAL_H */