#ifdef HAVE_ICAL_H
#include <ical.h>
+#include "ical_dezonify.h"
struct ical_respond_data {
char desired_partnum[SIZ];
}
if (strcasecmp(partnum, ird->desired_partnum)) return;
ird->cal = icalcomponent_new_from_string(content);
+ if (ird->cal != NULL) {
+ ical_dezonify(ird->cal);
+ }
}
/*
* ical_send_out_invitations() is called by ical_saving_vevent() when it
- * finds a VEVENT. FIXME ... finish implementing.
+ * finds a VEVENT.
*/
void ical_send_out_invitations(icalcomponent *cal) {
icalcomponent *the_request = NULL;
+ icaltimezone *utc_timezone = NULL;
+ icalcomponent *utc_component = NULL;
char *serialized_request = NULL;
char *request_message_text = NULL;
struct CtdlMessage *msg = NULL;
struct recptypes *valid = NULL;
char attendees_string[SIZ];
+ int num_attendees = 0;
char this_attendee[SIZ];
icalproperty *attendee = NULL;
char summary_string[SIZ];
"%s, ",
this_attendee
);
+ ++num_attendees;
}
}
}
- lprintf(9, "attendees_string: <%s>\n", attendees_string);
+ lprintf(9, "<%d> attendees: <%s>\n", num_attendees, attendees_string);
+
+ /* If there are no attendees, there are no invitations to send, so...
+ * don't bother putting one together! Punch out, Maverick!
+ */
+ if (num_attendees == 0) {
+ icalcomponent_free(the_request);
+ return;
+ }
/* Encapsulate the VEVENT component into a complete VCALENDAR */
encaps = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
/* Set the method to REQUEST */
icalcomponent_set_method(encaps, ICAL_METHOD_REQUEST);
- /* FIXME: here we need to insert a VTIMEZONE object. */
+ /* Insert a VTIMEZONE subcomponent telling the dumbass calendar agent
+ * at the other end about UTC. This is necessary because some calendar
+ * agents assume that an unqualified time is UTC while others assume
+ * it is local.
+ */
+ utc_timezone = icaltimezone_get_utc_timezone();
+ if (utc_timezone == NULL) {
+ lprintf(9, "%s:%d: utc_timezone is null\n",__FILE__,__LINE__);
+ }
+ else {
+ utc_component = icaltimezone_get_component(utc_timezone);
+ }
+ if (utc_component == NULL) {
+ lprintf(9, "%s:%d: utc_component is null\n",__FILE__,__LINE__);
+ }
+ else {
+ icalcomponent_add_component(encaps, utc_component);
+ }
+
+ /* Now make sure all of the DTSTART and DTEND properties are
+ * labelled as UTC. (FIXME do this)
+ */
+ 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