]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_calendar.c
* Do calendar support only if libical header *and* library are present
[citadel.git] / citadel / serv_calendar.c
index f5c4dbc6a840c4b37a725a96a22f33980bac4758..60d6db9471414d114ccef06fed662e84cbf53298 100644 (file)
 #include "mime_parser.h"
 #include "serv_calendar.h"
 
-#ifdef HAVE_ICAL_H
+#ifdef CITADEL_WITH_CALENDAR_SERVICE
 
 #include <ical.h>
+#include "ical_dezonify.h"
 
 struct ical_respond_data {
        char desired_partnum[SIZ];
@@ -271,6 +272,9 @@ void ical_locate_part(char *name, char *filename, char *partnum, char *disp,
        }
        if (strcasecmp(partnum, ird->desired_partnum)) return;
        ird->cal = icalcomponent_new_from_string(content);
+       if (ird->cal != NULL) {
+               ical_dezonify(ird->cal);
+       }
 }
 
 
@@ -1038,7 +1042,7 @@ void ical_create_room(void)
 
 /*
  * 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;
@@ -1047,6 +1051,7 @@ void ical_send_out_invitations(icalcomponent *cal) {
        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];
@@ -1089,11 +1094,20 @@ void ical_send_out_invitations(icalcomponent *cal) {
                                        "%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);
@@ -1113,7 +1127,8 @@ void ical_send_out_invitations(icalcomponent *cal) {
        /* Set the method to REQUEST */
        icalcomponent_set_method(encaps, ICAL_METHOD_REQUEST);
 
-       /* FIXME: here we need to insert a VTIMEZONE object. */
+       /* 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
@@ -1424,14 +1439,14 @@ void ical_session_startup(void) {
 }
 
 
-#endif /* HAVE_ICAL_H */
+#endif /* CITADEL_WITH_CALENDAR_SERVICE */
 
 /*
  * Register this module with the Citadel server.
  */
 char *Dynamic_Module_Init(void)
 {
-#ifdef HAVE_ICAL_H
+#ifdef CITADEL_WITH_CALENDAR_SERVICE
        CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE);
        CtdlRegisterMessageHook(ical_obj_aftersave, EVT_AFTERSAVE);
        CtdlRegisterSessionHook(ical_create_room, EVT_LOGIN);