* More license declarations
[citadel.git] / citadel / modules / calendar / serv_calendar.c
index 094ab130809a73167e56a0990a5e4414d8926706..1dd5935e045f3459d88804e52659b4e08e7685d0 100644 (file)
@@ -5,6 +5,22 @@
  * room on a Citadel server.  It handles iCalendar objects using the
  * iTIP protocol.  See RFCs 2445 and 2446.
  *
+ *
+ * Copyright (c) 1987-2009 by the citadel.org team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #define PRODID "-//Citadel//NONSGML Citadel Calendar//EN"
@@ -1993,6 +2009,8 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
        const icaltimezone *z;
        int num_zones_attached = 0;
        int zone_already_attached;
+       icalparameter *tzidp = NULL;
+       const char *tzidc = NULL;
 
        if (cal == NULL) {
                CtdlLogPrintf(CTDL_ERR, "ERROR: trying to reply to NULL event?\n");
@@ -2097,6 +2115,15 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
                ) {
                        t = icalproperty_get_dtstart(p);        // it's safe to use dtstart for all of them
 
+                       /* Determine the tzid in order for some of the conditions below to work */
+                       tzidp = icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER);
+                       if (tzidp) {
+                               tzidc = icalparameter_get_tzid(tzidp);
+                       }
+                       else {
+                               tzidc = NULL;
+                       }
+
                        /* First see if there's a timezone attached to the data structure itself */
                        if (icaltime_is_utc(t)) {
                                z = icaltimezone_get_utc_timezone();
@@ -2106,21 +2133,13 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
                        }
 
                        /* If not, try to determine the tzid from the parameter using attached zones */
-                       if (!z) {
-                               z = icalcomponent_get_timezone(top_level_cal,
-                                       icalparameter_get_tzid(
-                                               icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER)
-                                       )
-                               );
+                       if ((!z) && (tzidc)) {
+                               z = icalcomponent_get_timezone(top_level_cal, tzidc);
                        }
 
                        /* Still no good?  Try our internal database */
-                       if (!z) {
-                               z = icaltimezone_get_builtin_timezone_from_tzid(
-                                       icalparameter_get_tzid(
-                                               icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER)
-                                       )
-                               );
+                       if ((!z) && (tzidc)) {
+                               z = icaltimezone_get_builtin_timezone_from_tzid(tzidc);
                        }
 
                        if (z) {
@@ -2171,16 +2190,20 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
                        serialized_request
                );
 
-               msg = CtdlMakeMessage(&CC->user,
-                       "",                     /* No single recipient here */
-                       "",                     /* No single recipient here */
-                       CC->room.QRname, 0, FMT_RFC822,
-                       "",
-                       "",
+               msg = CtdlMakeMessage(
+                       &CC->user,
+                       NULL,                   /* No single recipient here */
+                       NULL,                   /* No single recipient here */
+                       CC->room.QRname,
+                       0,
+                       FMT_RFC822,
+                       NULL,
+                       NULL,
                        summary_string,         /* Use summary for subject */
                        NULL,
                        request_message_text,
-                       NULL);
+                       NULL
+               );
        
                if (msg != NULL) {
                        valid = validate_recipients(attendees_string, NULL, 0);