* room on a Citadel server. It handles iCalendar objects using the
* iTIP protocol. See RFCs 2445 and 2446.
*
+ * Copyright (c) 1987-2018 by the citadel.org team
*
- * 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 version 3.
*
- * 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
+ * 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.
*/
#define PRODID "-//Citadel//NONSGML Citadel Calendar//EN"
#include "room_ops.h"
#include "euidindex.h"
#include "ical_dezonify.h"
+#include "config.h"
msg->cm_format_type = 4;
CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
- CM_SetField(msg, eNodeName, config.c_nodename, strlen(config.c_nodename));
- CM_SetField(msg, eHumanNode, config.c_humannode, strlen(config.c_humannode));
+ CM_SetField(msg, eHumanNode, CtdlGetConfigStr("c_humannode"), strlen(CtdlGetConfigStr("c_humannode")));
MsgBody = NewStrBufPlain(NULL, serlen + 100);
StrBufAppendBufPlain(MsgBody, HKEY("Content-type: text/calendar\r\n\r\n"), 0);
icalproperty *summary = NULL;
char summary_string[SIZ];
icalproperty *me_attend = NULL;
- struct recptypes *recp = NULL;
+ recptypes *recp = NULL;
icalparameter *partstat = NULL;
char *serialized_reply = NULL;
char *reply_message_text = NULL;
const char *ch;
struct CtdlMessage *msg = NULL;
- struct recptypes *valid = NULL;
+ recptypes *valid = NULL;
*organizer_string = '\0';
strcpy(summary_string, "Calendar item");
/* We found our own address in the attendee list. */
if (me_attend) {
/* Change the partstat from NEEDS-ACTION to ACCEPT or DECLINE */
- icalproperty_remove_parameter(me_attend, ICAL_PARTSTAT_PARAMETER);
+ icalproperty_remove_parameter_by_kind(me_attend, ICAL_PARTSTAT_PARAMETER);
if (!strcasecmp(action, "accept")) {
partstat = icalparameter_new_partstat(ICAL_PARTSTAT_ACCEPTED);
return;
}
- msg = CtdlFetchMessage(msgnum, 1);
+ msg = CtdlFetchMessage(msgnum, 1, 1);
if (msg == NULL) {
cprintf("%d Message %ld not found.\n",
ERROR + ILLEGAL_VALUE,
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, partnum);
- mime_parser(msg->cm_fields[eMesageText],
- NULL,
- *ical_locate_part, /* callback function */
- NULL, NULL,
- (void *) &ird, /* user data */
- 0
+ mime_parser(CM_RANGE(msg, eMesageText),
+ *ical_locate_part, /* callback function */
+ NULL, NULL,
+ (void *) &ird, /* user data */
+ 0
);
/* We're done with the incoming message, because we now have a
* us the ability to load the event into memory so we can diddle the
* attendees.
*/
- msg = CtdlFetchMessage(msgnum_being_replaced, 1);
+ msg = CtdlFetchMessage(msgnum_being_replaced, 1, 1);
if (msg == NULL) {
return(2); /* internal error */
}
oec.c = NULL;
- mime_parser(msg->cm_fields[eMesageText],
- NULL,
- *ical_locate_original_event, /* callback function */
- NULL, NULL,
- &oec, /* user data */
- 0
+ mime_parser(CM_RANGE(msg, eMesageText),
+ *ical_locate_original_event, /* callback function */
+ NULL, NULL,
+ &oec, /* user data */
+ 0
);
CM_Free(msg);
return;
}
- msg = CtdlFetchMessage(msgnum, 1);
+ msg = CtdlFetchMessage(msgnum, 1, 1);
if (msg == NULL) {
cprintf("%d Message %ld not found.\n",
ERROR + ILLEGAL_VALUE,
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, partnum);
- mime_parser(msg->cm_fields[eMesageText],
- NULL,
- *ical_locate_part, /* callback function */
- NULL, NULL,
- (void *) &ird, /* user data */
- 0
- );
+ mime_parser(CM_RANGE(msg, eMesageText),
+ *ical_locate_part, /* callback function */
+ NULL, NULL,
+ (void *) &ird, /* user data */
+ 0
+ );
/* We're done with the incoming message, because we now have a
* calendar object in memory.
existing_msgnum,
conflict_event_uid,
conflict_event_summary,
- ( ((strlen(compare_uid)>0)
+ ( (!IsEmptyStr(compare_uid)
&&(!strcasecmp(compare_uid,
conflict_event_uid))) ? 1 : 0
- )
- );
+ )
+ );
conflict_reported = 1;
}
proposed_event = (icalcomponent *)data;
- msg = CtdlFetchMessage(msgnum, 1);
+ msg = CtdlFetchMessage(msgnum, 1, 1);
if (msg == NULL) return;
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, "_HUNT_");
- mime_parser(msg->cm_fields[eMesageText],
- NULL,
- *ical_locate_part, /* callback function */
- NULL, NULL,
- (void *) &ird, /* user data */
- 0
+ mime_parser(CM_RANGE(msg, eMesageText),
+ *ical_locate_part, /* callback function */
+ NULL, NULL,
+ (void *) &ird, /* user data */
+ 0
);
CM_Free(msg);
struct CtdlMessage *msg = NULL;
struct ical_respond_data ird;
- msg = CtdlFetchMessage(msgnum, 1);
+ msg = CtdlFetchMessage(msgnum, 1, 1);
if (msg == NULL) {
cprintf("%d Message %ld not found\n",
ERROR + ILLEGAL_VALUE,
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, partnum);
- mime_parser(msg->cm_fields[eMesageText],
- NULL,
- *ical_locate_part, /* callback function */
- NULL, NULL,
- (void *) &ird, /* user data */
- 0
- );
+ mime_parser(CM_RANGE(msg, eMesageText),
+ *ical_locate_part, /* callback function */
+ NULL, NULL,
+ (void *) &ird, /* user data */
+ 0
+ );
CM_Free(msg);
if (!icaltime_is_null_time(dtend)) {
dtend = icaltime_add(dtstart, dur);
dtend.zone = dtstart.zone;
- dtend.is_utc = dtstart.is_utc;
}
++num_recur;
}
fb = (icalcomponent *)data; /* User-supplied data will be the VFREEBUSY component */
- msg = CtdlFetchMessage(msgnum, 1);
+ msg = CtdlFetchMessage(msgnum, 1, 1);
if (msg == NULL) return;
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, "_HUNT_");
- mime_parser(msg->cm_fields[eMesageText],
- NULL,
- *ical_locate_part, /* callback function */
- NULL, NULL,
- (void *) &ird, /* user data */
- 0
- );
+ mime_parser(CM_RANGE(msg, eMesageText),
+ *ical_locate_part, /* callback function */
+ NULL, NULL,
+ (void *) &ird, /* user data */
+ 0
+ );
CM_Free(msg);
if (ird.cal) {
icalcomponent *encaps = NULL;
icalcomponent *fb = NULL;
int found_user = (-1);
- struct recptypes *recp = NULL;
+ recptypes *recp = NULL;
char buf[256];
char host[256];
char type[256];
* primary FQDN of this Citadel node.
*/
if (found_user != 0) {
- snprintf(buf, sizeof buf, "%s@%s", who, config.c_fqdn);
+ snprintf(buf, sizeof buf, "%s@%s", who, CtdlGetConfigStr("c_fqdn"));
syslog(LOG_DEBUG, "Trying <%s>\n", buf);
recp = validate_recipients(buf, NULL, 0);
if (recp != NULL) {
icalcomponent_set_method(fb, ICAL_METHOD_PUBLISH);
/* Set the DTSTAMP to right now. */
- icalcomponent_set_dtstamp(fb, icaltime_from_timet(time(NULL), 0));
+ icalcomponent_set_dtstamp(fb, icaltime_from_timet_with_zone(time(NULL), 0, icaltimezone_get_utc_timezone()));
/* Add the user's email address as ORGANIZER */
sprintf(buf, "MAILTO:%s", who);
if (strchr(buf, '@') == NULL) {
strcat(buf, "@");
- strcat(buf, config.c_fqdn);
+ strcat(buf, CtdlGetConfigStr("c_fqdn"));
}
for (i=0; buf[i]; ++i) {
if (buf[i]==' ') buf[i] = '_';
* to yesterday and tomorrow as default values.
*/
if (icalcomponent_get_first_property(fb, ICAL_DTSTART_PROPERTY) == NULL) {
- icalcomponent_set_dtstart(fb, icaltime_from_timet(time(NULL)-86400L, 0));
+ icalcomponent_set_dtstart(fb, icaltime_from_timet_with_zone(time(NULL)-86400L, 0, icaltimezone_get_utc_timezone()));
}
if (icalcomponent_get_first_property(fb, ICAL_DTEND_PROPERTY) == NULL) {
- icalcomponent_set_dtend(fb, icaltime_from_timet(time(NULL)+86400L, 0));
+ icalcomponent_set_dtend(fb, icaltime_from_timet_with_zone(time(NULL)+86400L, 0, icaltimezone_get_utc_timezone()));
}
/* Put the freebusy component into the calendar component */
/* Look for the calendar event... */
- msg = CtdlFetchMessage(msgnum, 1);
+ msg = CtdlFetchMessage(msgnum, 1, 1);
if (msg == NULL) return;
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, "_HUNT_");
- mime_parser(msg->cm_fields[eMesageText],
- NULL,
- *ical_locate_part, /* callback function */
- NULL, NULL,
- (void *) &ird, /* user data */
- 0
+ mime_parser(CM_RANGE(msg, eMesageText),
+ *ical_locate_part, /* callback function */
+ NULL, NULL,
+ (void *) &ird, /* user data */
+ 0
);
CM_Free(msg);
}
cprintf("%d Transmit data now\n", SEND_LISTING);
- calstream = CtdlReadMessageBody(HKEY("000"), config.c_maxmsglen, NULL, 0, 0);
+ calstream = CtdlReadMessageBody(HKEY("000"), CtdlGetConfigLong("c_maxmsglen"), NULL, 0);
if (calstream == NULL) {
return;
}
icalcomponent *encaps = NULL;
char *request_message_text = NULL;
struct CtdlMessage *msg = NULL;
- struct recptypes *valid = NULL;
+ recptypes *valid = NULL;
char attendees_string[SIZ];
int num_attendees = 0;
char this_attendee[256];
* If the message is being saved, we also set various message header fields
* using data found in the iCalendar object.
*/
-int ical_obj_beforesave(struct CtdlMessage *msg)
+int ical_obj_beforesave(struct CtdlMessage *msg, recptypes *recp)
{
/* First determine if this is a calendar or tasks room */
if ( (CC->room.QRdefaultview != VIEW_CALENDAR)
}
/* Do all of our lovely back-end parsing */
- mime_parser(msg->cm_fields[eMesageText],
- NULL,
- *ical_obj_beforesave_backend,
- NULL, NULL,
- (void *)msg,
- 0
- );
+ mime_parser(CM_RANGE(msg, eMesageText),
+ *ical_obj_beforesave_backend,
+ NULL, NULL,
+ (void *)msg,
+ 0
+ );
return(0);
}
* (This will start back end tasks such as automatic generation of invitations,
* if such actions are appropriate.)
*/
-int ical_obj_aftersave(struct CtdlMessage *msg)
+int ical_obj_aftersave(struct CtdlMessage *msg, recptypes *recp)
{
char roomname[ROOMNAMELEN];
if (CM_IsEmpty(msg, eMesageText)) return(1);
/* Now recurse through it looking for our icalendar data */
- mime_parser(msg->cm_fields[eMesageText],
- NULL,
- *ical_obj_aftersave_backend,
- NULL, NULL,
- NULL,
- 0
- );
+ mime_parser(CM_RANGE(msg, eMesageText),
+ *ical_obj_aftersave_backend,
+ NULL, NULL,
+ NULL,
+ 0
+ );
return(0);
}
{
/* Tell libical to return errors instead of aborting if it gets bad data */
+
+#ifdef LIBICAL_ICAL_EXPORT // cheap and sleazy way to detect libical >=2.0
+ icalerror_set_errors_are_fatal(0);
+#else
icalerror_errors_are_fatal = 0;
+#endif
/* Use our own application prefix in tzid's generated from system tzdata */
icaltimezone_set_tzid_prefix("/citadel.org/");