+ * Back end function for check_attendee_availability()
+ * This one checks an individual attendee against a supplied
+ * event start and end time. All these fields have already been
+ * broken out.
+ *
+ * attendee_string name of the attendee
+ * event_start start time of the event to check
+ * event_end end time of the event to check
+ *
+ * The result is placed in 'annotation'.
+ */
+void check_individual_attendee(char *attendee_string,
+ struct icaltimetype event_start,
+ struct icaltimetype event_end,
+ char *annotation) {
+
+ icalcomponent *fbc = NULL;
+ icalcomponent *fb = NULL;
+ icalproperty *thisfb = NULL;
+ struct icalperiodtype period;
+
+ /*
+ * Set to 'unknown' right from the beginning. Unless we learn
+ * something else, that's what we'll go with.
+ */
+ strcpy(annotation, _("availability unknown"));
+
+ fbc = get_freebusy_for_user(attendee_string);
+ if (fbc == NULL) {
+ return;
+ }
+
+ /*
+ * Make sure we're looking at a VFREEBUSY by itself. What we're probably
+ * looking at initially is a VFREEBUSY encapsulated in a VCALENDAR.
+ */
+ if (icalcomponent_isa(fbc) == ICAL_VCALENDAR_COMPONENT) {
+ fb = icalcomponent_get_first_component(fbc, ICAL_VFREEBUSY_COMPONENT);
+ }
+ else if (icalcomponent_isa(fbc) == ICAL_VFREEBUSY_COMPONENT) {
+ fb = fbc;
+ }
+
+ /* Iterate through all FREEBUSY's looking for conflicts. */
+ if (fb != NULL) {
+
+ strcpy(annotation, _("free"));
+
+ for (thisfb = icalcomponent_get_first_property(fb, ICAL_FREEBUSY_PROPERTY);
+ thisfb != NULL;
+ thisfb = icalcomponent_get_next_property(fb, ICAL_FREEBUSY_PROPERTY) ) {
+
+ /** Do the check */
+ period = icalproperty_get_freebusy(thisfb);
+ if (ical_ctdl_is_overlap(period.start, period.end,
+ event_start, event_end)) {
+ strcpy(annotation, _("BUSY"));
+ }
+
+ }
+ }
+
+ icalcomponent_free(fbc);
+}
+
+
+
+
+/*
+ * Check the availability of all attendees for an event (when possible)
+ * and annotate accordingly.
+ *
+ * vevent the event which should be compared with attendees calendar