]> code.citadel.org Git - citadel.git/commitdiff
* Rewrite of calendar-to-freebusy conversion functions. This one creates
authorArt Cancro <ajc@citadel.org>
Sat, 15 Mar 2003 23:05:08 +0000 (23:05 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 15 Mar 2003 23:05:08 +0000 (23:05 +0000)
  freebusy in the correct format, instead of what I mistakenly assumed it
  was supposed to look like.  :(

citadel/ChangeLog
citadel/serv_calendar.c

index 54fb66f9187bc0dbecb42e36a3db142dbb614d9e..5f6af59c1b67a3464f59c22e0b7fb22bd5dbdf4e 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 605.18  2003/03/15 23:05:08  ajc
+ * Rewrite of calendar-to-freebusy conversion functions.  This one creates
+   freebusy in the correct format, instead of what I mistakenly assumed it
+   was supposed to look like.  :(
+
  Revision 605.17  2003/03/15 22:31:06  ajc
  * When scanning a user's Calendar> room for calendar events, search for
    MIME parts of type text/calendar instead of assuming that the event will
@@ -4554,4 +4559,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index b27fc824cf3f839b4b32d09a20bd3ae1fa60b797..3fc1fa7082a9c993c72de8e24b6fe32a7cce0215 100644 (file)
@@ -781,7 +781,7 @@ void ical_handle_rsvp(long msgnum, char *partnum, char *action) {
                }
 
                /* Now that we've processed this message, we don't need it
-                * anymore.  So delete it.  FIXME uncomment this when ready!
+                * anymore.  So delete it.  (Maybe make this optional?)
                 */
                CtdlDeleteMessages(CC->quickroom.QRname, msgnum, "");
 
@@ -1037,18 +1037,18 @@ void ical_conflicts(long msgnum, char *partnum) {
 
 
 /*
- * Remove all properties from a VEVENT that are not supplying the
- * bare minimum for free/busy data.
+ * Look for busy time in a VEVENT and add it to the supplied VFREEBUSY.
  */
-void ical_freebusy_strip(icalcomponent *cal) {
-
+void ical_add_to_freebusy(icalcomponent *fb, icalcomponent *cal) {
        icalproperty *p;
-       int did_something = 1;
+       icalvalue *v;
+       struct icalperiodtype my_period;
 
        if (cal == NULL) return;
+       my_period = icalperiodtype_null_period();
 
        if (icalcomponent_isa(cal) != ICAL_VEVENT_COMPONENT) {
-               ical_freebusy_strip(
+               ical_add_to_freebusy(fb,
                        icalcomponent_get_first_component(
                                cal, ICAL_VEVENT_COMPONENT
                        )
@@ -1058,34 +1058,35 @@ void ical_freebusy_strip(icalcomponent *cal) {
 
        ical_dezonify(cal);
 
-       while (did_something) {
-               did_something = 0;
-               for (   p=icalcomponent_get_first_property
-                               (cal, ICAL_ANY_PROPERTY);
-                       p != NULL;
-                       p = icalcomponent_get_next_property
-                               (cal, ICAL_ANY_PROPERTY)
-               ) {
-
-                       if (
-                               (icalproperty_isa(p)==ICAL_DTSTART_PROPERTY)
-                          ||   (icalproperty_isa(p)==ICAL_DTEND_PROPERTY)
-                          ||   (icalproperty_isa(p)==ICAL_DURATION_PROPERTY)
-                          ||   (icalproperty_isa(p)==ICAL_FREEBUSY_PROPERTY)
-                          ||   (icalproperty_isa(p)==ICAL_TRANSP_PROPERTY)
-                          ) {
-                               /* keep it */
-                       }
-                       else {
-                               /* delete it */
-                               icalcomponent_remove_property(cal, p);
-                               icalproperty_free(p);
-                               did_something = 1;
+       /* If this event is not opaque, the user isn't publishing it as
+        * busy time, so don't bother doing anything else.
+        */
+       p = icalcomponent_get_first_property(cal, ICAL_TRANSP_PROPERTY);
+       if (p != NULL) {
+               v = icalproperty_get_value(p);
+               if (v != NULL) {
+                       if (icalvalue_get_transp(v) != ICAL_TRANSP_OPAQUE) {
+                               return;
                        }
-
                }
        }
 
+       /* Convert the DTSTART and DTEND properties to an icalperiod. */
+       p = icalcomponent_get_first_property(cal, ICAL_DTSTART_PROPERTY);
+       if (p != NULL) {
+               my_period.start = icalproperty_get_dtstart(p);
+       }
+
+       p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
+       if (p != NULL) {
+               my_period.end = icalproperty_get_dtstart(p);
+       }
+
+       /* Now add it. */
+       icalcomponent_add_property(fb,
+               icalproperty_new_freebusy(my_period)
+       );
+
 }
 
 
@@ -1120,7 +1121,7 @@ void ical_freebusy_backend(long msgnum, void *data) {
 
        if (ird.cal == NULL) return;
 
-       /* FIXME  ...  now extract ird.cal's FREEBUSY info, and add to cal. */
+       ical_add_to_freebusy(cal, ird.cal);
 
        /* Now free the memory. */
        icalcomponent_free(ird.cal);