/*
- * $Id$
- *
* This module implements iCalendar object processing and the Calendar>
* room on a Citadel server. It handles iCalendar objects using the
* iTIP protocol. See RFCs 2445 and 2446.
*
+ *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is open source 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"
-#include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
+#include "ctdl_module.h"
+
#include <libical/ical.h>
-#include <libcitadel.h>
-#include "citadel.h"
-#include "server.h"
-#include "citserver.h"
-#include "support.h"
-#include "config.h"
-#include "user_ops.h"
-#include "room_ops.h"
+
#include "msgbase.h"
#include "internet_addressing.h"
#include "serv_calendar.h"
#include "euidindex.h"
-#include "ctdl_module.h"
#include "ical_dezonify.h"
encaps = icalcomponent_new_vcalendar();
if (encaps == NULL) {
- CtdlLogPrintf(CTDL_CRIT, "ERROR: could not allocate component!\n");
+ syslog(LOG_CRIT, "ERROR: could not allocate component!\n");
return NULL;
}
icalparameter *partstat = NULL;
char *serialized_reply = NULL;
char *reply_message_text = NULL;
+ const char *ch;
struct CtdlMessage *msg = NULL;
struct recptypes *valid = NULL;
strcpy(summary_string, "Calendar item");
if (request == NULL) {
- CtdlLogPrintf(CTDL_ERR, "ERROR: trying to reply to NULL event?\n");
+ syslog(LOG_ERR, "ERROR: trying to reply to NULL event?\n");
return;
}
the_reply = icalcomponent_new_clone(request);
if (the_reply == NULL) {
- CtdlLogPrintf(CTDL_ERR, "ERROR: cannot clone request\n");
+ syslog(LOG_ERR, "ERROR: cannot clone request\n");
return;
}
while (attendee = icalcomponent_get_first_property(vevent,
ICAL_ATTENDEE_PROPERTY), (attendee != NULL)
) {
- if (icalproperty_get_attendee(attendee)) {
- strcpy(attendee_string,
- icalproperty_get_attendee(attendee) );
- if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
- strcpy(attendee_string, &attendee_string[7]);
- striplt(attendee_string);
- recp = validate_recipients(attendee_string, NULL, 0);
- if (recp != NULL) {
- if (!strcasecmp(recp->recp_local, CC->user.fullname)) {
- if (me_attend) icalproperty_free(me_attend);
- me_attend = icalproperty_new_clone(attendee);
- }
- free_recipients(recp);
+ ch = icalproperty_get_attendee(attendee);
+ if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
+ safestrncpy(attendee_string, ch + 7, sizeof (attendee_string));
+ striplt(attendee_string);
+ recp = validate_recipients(attendee_string, NULL, 0);
+ if (recp != NULL) {
+ if (!strcasecmp(recp->recp_local, CC->user.fullname)) {
+ if (me_attend) icalproperty_free(me_attend);
+ me_attend = icalproperty_new_clone(attendee);
}
+ free_recipients(recp);
}
}
+
/* Remove it... */
icalcomponent_remove_property(vevent, attendee);
icalproperty_free(attendee);
/* Check to see if these two attendees match...
*/
- if (!strcasecmp(
- icalproperty_get_attendee(e_attendee),
- icalproperty_get_attendee(r_attendee)
- )) {
+ const char *e, *r;
+ e = icalproperty_get_attendee(e_attendee);
+ r = icalproperty_get_attendee(r_attendee);
+
+ if ((e != NULL) &&
+ (r != NULL) &&
+ !strcasecmp(e, r)) {
/* ...and if they do, remove the attendee from the event
* and replace it with the attendee from the reply. (The
* reply's copy will have the same address, but an updated
/* Figure out just what event it is we're dealing with */
strcpy(uid, "--==<< InVaLiD uId >>==--");
ical_learn_uid_of_reply(uid, cal);
- CtdlLogPrintf(CTDL_DEBUG, "UID of event being replied to is <%s>\n", uid);
+ syslog(LOG_DEBUG, "UID of event being replied to is <%s>\n", uid);
strcpy(hold_rm, CC->room.QRname); /* save current room */
- if (getroom(&CC->room, USERCALENDARROOM) != 0) {
- getroom(&CC->room, hold_rm);
- CtdlLogPrintf(CTDL_CRIT, "cannot get user calendar room\n");
+ if (CtdlGetRoom(&CC->room, USERCALENDARROOM) != 0) {
+ CtdlGetRoom(&CC->room, hold_rm);
+ syslog(LOG_CRIT, "cannot get user calendar room\n");
return(2);
}
* Citadel always sets the message EUID to the iCalendar UID of
* the event, this will work.
*/
- msgnum_being_replaced = locate_message_by_euid(uid, &CC->room);
+ msgnum_being_replaced = CtdlLocateMessageByEuid(uid, &CC->room);
- getroom(&CC->room, hold_rm); /* return to saved room */
+ CtdlGetRoom(&CC->room, hold_rm); /* return to saved room */
- CtdlLogPrintf(CTDL_DEBUG, "msgnum_being_replaced == %ld\n", msgnum_being_replaced);
+ syslog(LOG_DEBUG, "msgnum_being_replaced == %ld\n", msgnum_being_replaced);
if (msgnum_being_replaced == 0) {
return(1); /* no calendar event found */
}
original_event = oec.c;
if (original_event == NULL) {
- CtdlLogPrintf(CTDL_ERR, "ERROR: Original_component is NULL.\n");
+ syslog(LOG_ERR, "ERROR: Original_component is NULL.\n");
return(2);
}
icalcomponent_free(original_event); /* Don't need this anymore. */
if (serialized_event == NULL) return(2);
- MailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM);
+ CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM);
message_text = malloc(strlen(serialized_event) + SIZ);
if (message_text != NULL) {
return(1);
}
- /* lprintf (9, "Comparing t1start %d:%d t1end %d:%d t2start %d:%d t2end %d:%d \n",
+ /* syslog(LOG_DEBUG, "Comparing t1start %d:%d t1end %d:%d t2start %d:%d t2end %d:%d \n",
t1start.hour, t1start.minute, t1end.hour, t1end.minute,
t2start.hour, t2start.minute, t2end.hour, t2end.minute);
*/
/* If event 1 ends before event 2 starts, we're in the clear. */
if (icaltime_compare(t1end, t2start) <= 0) return(0);
- /* lprintf(9, "first passed\n"); */
+ /* syslog(LOG_DEBUG, "first passed\n"); */
/* If event 2 ends before event 1 starts, we're also ok. */
if (icaltime_compare(t2end, t1start) <= 0) return(0);
- /* lprintf(9, "second passed\n"); */
+ /* syslog(LOG_DEBUG, "second passed\n"); */
/* Otherwise, they overlap. */
return(1);
/* debugging cruft *
time_t tt;
tt = icaltime_as_timet_with_zone(t1start, t1start.zone);
- CtdlLogPrintf(CTDL_DEBUG, "PROPOSED START: %s", ctime(&tt));
+ syslog(LOG_DEBUG, "PROPOSED START: %s", ctime(&tt));
tt = icaltime_as_timet_with_zone(t1end, t1end.zone);
- CtdlLogPrintf(CTDL_DEBUG, " PROPOSED END: %s", ctime(&tt));
+ syslog(LOG_DEBUG, " PROPOSED END: %s", ctime(&tt));
tt = icaltime_as_timet_with_zone(t2start, t2start.zone);
- CtdlLogPrintf(CTDL_DEBUG, "EXISTING START: %s", ctime(&tt));
+ syslog(LOG_DEBUG, "EXISTING START: %s", ctime(&tt));
tt = icaltime_as_timet_with_zone(t2end, t2end.zone);
- CtdlLogPrintf(CTDL_DEBUG, " EXISTING END: %s", ctime(&tt));
+ syslog(LOG_DEBUG, " EXISTING END: %s", ctime(&tt));
* debugging cruft */
/* compare and output */
}
dur = icaltime_subtract(t2end, t2start);
}
+ else {
+ memset (&dur, 0, sizeof(struct icaldurationtype));
+ }
rrule = ical_ctdl_get_subprop(existing_event, ICAL_RRULE_PROPERTY);
if (rrule) {
long existing_msgnum)
{
struct icaltimetype t1start, t1end;
- t1start = icaltime_null_time();
- t1end = icaltime_null_time();
icalproperty *p;
char compare_uid[SIZ];
int num_recur = 0;
/* initialization */
- strcpy(compare_uid, "");
+ t1end = icaltime_null_time();
+ *compare_uid = '\0';
/* proposed event stuff */
p = ical_ctdl_get_subprop(proposed_event, ICAL_DTSTART_PROPERTY);
- if (p == NULL) return;
- if (p != NULL) t1start = icalproperty_get_dtstart(p);
+ if (p == NULL)
+ return;
+ else
+ t1start = icalproperty_get_dtstart(p);
+
if (icaltime_is_utc(t1start)) {
t1start.zone = icaltimezone_get_utc_timezone();
}
dur = icaltime_subtract(t1end, t1start);
}
+ else {
+ memset (&dur, 0, sizeof(struct icaldurationtype));
+ }
rrule = ical_ctdl_get_subprop(proposed_event, ICAL_RRULE_PROPERTY);
if (rrule) {
strcpy(hold_rm, CC->room.QRname); /* save current room */
- if (getroom(&CC->room, USERCALENDARROOM) != 0) {
- getroom(&CC->room, hold_rm);
+ if (CtdlGetRoom(&CC->room, USERCALENDARROOM) != 0) {
+ CtdlGetRoom(&CC->room, hold_rm);
cprintf("%d You do not have a calendar.\n", ERROR + ROOM_NOT_FOUND);
return;
}
);
cprintf("000\n");
- getroom(&CC->room, hold_rm); /* return to saved room */
+ CtdlGetRoom(&CC->room, hold_rm); /* return to saved room */
}
icalproperty *p;
icalvalue *v;
struct icalperiodtype this_event_period = icalperiodtype_null_period();
- icaltimetype dtstart = icaltime_null_time();
- icaltimetype dtend = icaltime_null_time();
+ icaltimetype dtstart;
+ icaltimetype dtend;
/* recur variables */
icalproperty *rrule = NULL;
if (!icaltime_is_null_time(dtend)) {
dur = icaltime_subtract(dtend, dtstart);
}
+ else {
+ memset (&dur, 0, sizeof(struct icaldurationtype));
+ }
/* Is a recurrence specified? If so, get ready to process it... */
rrule = ical_ctdl_get_subprop(cal, ICAL_RRULE_PROPERTY);
int config_lines = 0;
/* First try an exact match. */
- found_user = getuser(&usbuf, who);
+ found_user = CtdlGetUser(&usbuf, who);
/* If not found, try it as an unqualified email address. */
if (found_user != 0) {
strcpy(buf, who);
recp = validate_recipients(buf, NULL, 0);
- CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+ syslog(LOG_DEBUG, "Trying <%s>\n", buf);
if (recp != NULL) {
if (recp->num_local == 1) {
- found_user = getuser(&usbuf, recp->recp_local);
+ found_user = CtdlGetUser(&usbuf, recp->recp_local);
}
free_recipients(recp);
}
*/
if (found_user != 0) {
snprintf(buf, sizeof buf, "%s@%s", who, config.c_fqdn);
- CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+ syslog(LOG_DEBUG, "Trying <%s>\n", buf);
recp = validate_recipients(buf, NULL, 0);
if (recp != NULL) {
if (recp->num_local == 1) {
- found_user = getuser(&usbuf, recp->recp_local);
+ found_user = CtdlGetUser(&usbuf, recp->recp_local);
}
free_recipients(recp);
}
if ( (!strcasecmp(type, "localhost"))
|| (!strcasecmp(type, "directory")) ) {
snprintf(buf, sizeof buf, "%s@%s", who, host);
- CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+ syslog(LOG_DEBUG, "Trying <%s>\n", buf);
recp = validate_recipients(buf, NULL, 0);
if (recp != NULL) {
if (recp->num_local == 1) {
- found_user = getuser(&usbuf, recp->recp_local);
+ found_user = CtdlGetUser(&usbuf, recp->recp_local);
}
free_recipients(recp);
}
return;
}
- MailboxName(calendar_room_name, sizeof calendar_room_name,
+ CtdlMailboxName(calendar_room_name, sizeof calendar_room_name,
&usbuf, USERCALENDARROOM);
strcpy(hold_rm, CC->room.QRname); /* save current room */
- if (getroom(&CC->room, calendar_room_name) != 0) {
+ if (CtdlGetRoom(&CC->room, calendar_room_name) != 0) {
cprintf("%d Cannot open calendar\n", ERROR + ROOM_NOT_FOUND);
- getroom(&CC->room, hold_rm);
+ CtdlGetRoom(&CC->room, hold_rm);
return;
}
/* Create a VFREEBUSY subcomponent */
- CtdlLogPrintf(CTDL_DEBUG, "Creating VFREEBUSY component\n");
+ syslog(LOG_DEBUG, "Creating VFREEBUSY component\n");
fb = icalcomponent_new_vfreebusy();
if (fb == NULL) {
cprintf("%d Internal error: cannot allocate memory.\n",
ERROR + INTERNAL_ERROR);
- getroom(&CC->room, hold_rm);
+ CtdlGetRoom(&CC->room, hold_rm);
return;
}
icalcomponent_add_property(fb, icalproperty_new_organizer(buf));
/* Add busy time from events */
- CtdlLogPrintf(CTDL_DEBUG, "Adding busy time from events\n");
+ syslog(LOG_DEBUG, "Adding busy time from events\n");
CtdlForEachMessage(MSGS_ALL, 0, NULL, NULL, NULL, ical_freebusy_backend, (void *)fb );
/* If values for DTSTART and DTEND are still not present, set them
}
/* Put the freebusy component into the calendar component */
- CtdlLogPrintf(CTDL_DEBUG, "Encapsulating\n");
+ syslog(LOG_DEBUG, "Encapsulating\n");
encaps = ical_encapsulate_subcomponent(fb);
if (encaps == NULL) {
icalcomponent_free(fb);
cprintf("%d Internal error: cannot allocate memory.\n",
ERROR + INTERNAL_ERROR);
- getroom(&CC->room, hold_rm);
+ CtdlGetRoom(&CC->room, hold_rm);
return;
}
/* Set the method to PUBLISH */
- CtdlLogPrintf(CTDL_DEBUG, "Setting method\n");
+ syslog(LOG_DEBUG, "Setting method\n");
icalcomponent_set_method(encaps, ICAL_METHOD_PUBLISH);
/* Serialize it */
- CtdlLogPrintf(CTDL_DEBUG, "Serializing\n");
+ syslog(LOG_DEBUG, "Serializing\n");
serialized_request = icalcomponent_as_ical_string_r(encaps);
icalcomponent_free(encaps); /* Don't need this anymore. */
cprintf("\n000\n");
/* Go back to the room from which we came... */
- getroom(&CC->room, hold_rm);
+ CtdlGetRoom(&CC->room, hold_rm);
}
encaps = icalcomponent_new_vcalendar();
if (encaps == NULL) {
- CtdlLogPrintf(CTDL_ALERT, "ERROR: could not allocate component!\n");
+ syslog(LOG_ALERT, "ERROR: could not allocate component!\n");
cprintf("%d Could not allocate memory\n", ERROR+INTERNAL_ERROR);
return;
}
HashList *keys = (HashList *) data;
if ( (keys) && (tzid) && (!IsEmptyStr(tzid)) ) {
- Put(keys, tzid, strlen(tzid), strdup(tzid), generic_free_handler);
+ Put(keys, tzid, strlen(tzid), strdup(tzid), NULL);
}
}
}
cprintf("%d Transmit data now\n", SEND_LISTING);
- calstream = CtdlReadMessageBody("000", config.c_maxmsglen, NULL, 0, 0);
+ calstream = CtdlReadMessageBody(HKEY("000"), config.c_maxmsglen, NULL, 0, 0);
if (calstream == NULL) {
return;
}
HashPos = GetNewHashPos(tzidlist, 0);
while (GetNextHashPos(tzidlist, HashPos, &len, &Key, &Value)) {
- CtdlLogPrintf(CTDL_DEBUG, "Attaching timezone '%s'\n", Value);
+ syslog(LOG_DEBUG, "Attaching timezone '%s'\n", (char*) Value);
icaltimezone *t = NULL;
/* First look for a timezone attached to the original calendar */
/*
* We don't know if the calendar room exists so we just create it at login
*/
-void ical_create_room(void)
+void ical_CtdlCreateRoom(void)
{
struct ctdlroom qr;
- struct visit vbuf;
+ visit vbuf;
/* Create the calendar room if it doesn't already exist */
- create_room(USERCALENDARROOM, 4, "", 0, 1, 0, VIEW_CALENDAR);
+ CtdlCreateRoom(USERCALENDARROOM, 4, "", 0, 1, 0, VIEW_CALENDAR);
/* Set expiration policy to manual; otherwise objects will be lost! */
- if (lgetroom(&qr, USERCALENDARROOM)) {
- CtdlLogPrintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+ if (CtdlGetRoomLock(&qr, USERCALENDARROOM)) {
+ syslog(LOG_CRIT, "Couldn't get the user calendar room!\n");
return;
}
qr.QRep.expire_mode = EXPIRE_MANUAL;
qr.QRdefaultview = VIEW_CALENDAR; /* 3 = calendar view */
- lputroom(&qr);
+ CtdlPutRoomLock(&qr);
/* Set the view to a calendar view */
CtdlGetRelationship(&vbuf, &CC->user, &qr);
CtdlSetRelationship(&vbuf, &CC->user, &qr);
/* Create the tasks list room if it doesn't already exist */
- create_room(USERTASKSROOM, 4, "", 0, 1, 0, VIEW_TASKS);
+ CtdlCreateRoom(USERTASKSROOM, 4, "", 0, 1, 0, VIEW_TASKS);
/* Set expiration policy to manual; otherwise objects will be lost! */
- if (lgetroom(&qr, USERTASKSROOM)) {
- CtdlLogPrintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+ if (CtdlGetRoomLock(&qr, USERTASKSROOM)) {
+ syslog(LOG_CRIT, "Couldn't get the user calendar room!\n");
return;
}
qr.QRep.expire_mode = EXPIRE_MANUAL;
qr.QRdefaultview = VIEW_TASKS;
- lputroom(&qr);
+ CtdlPutRoomLock(&qr);
/* Set the view to a task list view */
CtdlGetRelationship(&vbuf, &CC->user, &qr);
CtdlSetRelationship(&vbuf, &CC->user, &qr);
/* Create the notes room if it doesn't already exist */
- create_room(USERNOTESROOM, 4, "", 0, 1, 0, VIEW_NOTES);
+ CtdlCreateRoom(USERNOTESROOM, 4, "", 0, 1, 0, VIEW_NOTES);
/* Set expiration policy to manual; otherwise objects will be lost! */
- if (lgetroom(&qr, USERNOTESROOM)) {
- CtdlLogPrintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+ if (CtdlGetRoomLock(&qr, USERNOTESROOM)) {
+ syslog(LOG_CRIT, "Couldn't get the user calendar room!\n");
return;
}
qr.QRep.expire_mode = EXPIRE_MANUAL;
qr.QRdefaultview = VIEW_NOTES;
- lputroom(&qr);
+ CtdlPutRoomLock(&qr);
/* Set the view to a notes view */
CtdlGetRelationship(&vbuf, &CC->user, &qr);
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");
+ syslog(LOG_ERR, "ERROR: trying to reply to NULL event?\n");
return;
}
/* Clone the event */
the_request = icalcomponent_new_clone(cal);
if (the_request == NULL) {
- CtdlLogPrintf(CTDL_ERR, "ERROR: cannot clone calendar object\n");
+ syslog(LOG_ERR, "ERROR: cannot clone calendar object\n");
return;
}
/* Determine who the recipients of this message are (the attendees) */
strcpy(attendees_string, "");
for (attendee = icalcomponent_get_first_property(the_request, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(the_request, ICAL_ATTENDEE_PROPERTY)) {
- if (icalproperty_get_attendee(attendee)) {
- safestrncpy(this_attendee, icalproperty_get_attendee(attendee), sizeof this_attendee);
- if (!strncasecmp(this_attendee, "MAILTO:", 7)) {
- strcpy(this_attendee, &this_attendee[7]);
-
- if (!CtdlIsMe(this_attendee, sizeof this_attendee)) { /* don't send an invitation to myself! */
- snprintf(&attendees_string[strlen(attendees_string)],
- sizeof(attendees_string) - strlen(attendees_string),
- "%s, ",
- this_attendee
+ const char *ch = icalproperty_get_attendee(attendee);
+ if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
+ safestrncpy(this_attendee, ch + 7, sizeof(this_attendee));
+
+ if (!CtdlIsMe(this_attendee, sizeof this_attendee)) { /* don't send an invitation to myself! */
+ snprintf(&attendees_string[strlen(attendees_string)],
+ sizeof(attendees_string) - strlen(attendees_string),
+ "%s, ",
+ this_attendee
);
- ++num_attendees;
- }
+ ++num_attendees;
}
}
}
- CtdlLogPrintf(CTDL_DEBUG, "<%d> attendees: <%s>\n", num_attendees, attendees_string);
+ syslog(LOG_DEBUG, "<%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!
/* Encapsulate the VEVENT component into a complete VCALENDAR */
encaps = icalcomponent_new_vcalendar();
if (encaps == NULL) {
- CtdlLogPrintf(CTDL_ALERT, "ERROR: could not allocate component!\n");
+ syslog(LOG_ALERT, "ERROR: could not allocate component!\n");
icalcomponent_free(the_request);
return;
}
) {
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();
}
/* 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) {
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);
icalproperty *organizer = NULL;
char organizer_string[SIZ];
- CtdlLogPrintf(CTDL_DEBUG, "ical_saving_vevent() has been called!\n");
+ syslog(LOG_DEBUG, "ical_saving_vevent() has been called!\n");
/* Don't send out invitations unless the client wants us to. */
if (CIT_ICAL->server_generated_invitations == 0) {
free(msg->cm_fields['E']);
}
msg->cm_fields['E'] = strdup(buf);
- CtdlLogPrintf(CTDL_DEBUG, "Saving calendar UID <%s>\n", buf);
+ syslog(LOG_DEBUG, "Saving calendar UID <%s>\n", buf);
}
}
if (msg->cm_fields['U'] != NULL) {
free(msg->cm_fields['U']);
}
- msg->cm_fields['U'] = strdup(buf);
+ msg->cm_fields['U'] = rfc2047encode(buf, strlen(buf));
}
}
/* It must be an RFC822 message! */
if (msg->cm_format_type != 4) {
- CtdlLogPrintf(CTDL_DEBUG, "Rejecting non-RFC822 message\n");
+ syslog(LOG_DEBUG, "Rejecting non-RFC822 message\n");
return(1); /* You tried to save a non-RFC822 message! */
}
*/
/* First determine if this is our room */
- MailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM);
+ CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM);
if (strcasecmp(roomname, CC->room.QRname)) {
return(0); /* Not the Calendar room -- don't do anything. */
}
icalcomponent *c;
icalproperty *p;
char buf[256];
+ const char *ch;
p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
if (p != NULL) {
/* If the component has attendees, iterate through them. */
for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); (p != NULL); p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
- safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
- if (!strncasecmp(buf, "MAILTO:", 7)) {
+ ch = icalproperty_get_attendee(p);
+ if ((ch != NULL) &&
+ !strncasecmp(ch, "MAILTO:", 7)) {
/* screen name or email address */
- strcpy(buf, &buf[7]);
+ safestrncpy(buf, ch + 7, sizeof(buf));
striplt(buf);
cprintf("%s ", buf);
}
/* Initialize our hook functions */
CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE);
CtdlRegisterMessageHook(ical_obj_aftersave, EVT_AFTERSAVE);
- CtdlRegisterSessionHook(ical_create_room, EVT_LOGIN);
+ CtdlRegisterSessionHook(ical_CtdlCreateRoom, EVT_LOGIN);
CtdlRegisterProtoHook(cmd_ical, "ICAL", "Citadel iCal commands");
CtdlRegisterSessionHook(ical_session_startup, EVT_START);
CtdlRegisterSessionHook(ical_session_shutdown, EVT_STOP);
CtdlRegisterCleanupHook(serv_calendar_destroy);
}
- /* return our Subversion id for the Log */
- return "$Id$";
+ /* return our module name for the log */
+ return "calendar";
}