// Hunt for attendees, removing ones that aren't us.
// (Actually, remove them all, cloning our own one so we can
// re-insert it later)
- while (attendee = icalcomponent_get_first_property(vevent,
- ICAL_ATTENDEE_PROPERTY), (attendee != NULL)
- ) {
+ while (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY), (attendee != NULL)) {
ch = icalproperty_get_attendee(attendee);
if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
safestrncpy(attendee_string, ch + 7, sizeof (attendee_string));
}
}
- if ( (strcasecmp(cbtype, "text/calendar"))
- && (strcasecmp(cbtype, "application/ics")) ) {
+ if ( (strcasecmp(cbtype, "text/calendar"))
+ && (strcasecmp(cbtype, "application/ics"))
+ ) {
return;
}
struct ical_respond_data ird;
if (
- (strcasecmp(action, "accept"))
- && (strcasecmp(action, "decline"))
+ (strcasecmp(action, "accept"))
+ && (strcasecmp(action, "decline"))
) {
cprintf("%d Action must be 'accept' or 'decline'\n", ERROR + ILLEGAL_VALUE);
return;
}
-/*
- * Figure out the UID of the calendar event being referred to in a
- * REPLY object. This function is recursive.
- */
+// Figure out the UID of the calendar event being referred to in a
+// REPLY object. This function is recursive.
void ical_learn_uid_of_reply(char *uidbuf, icalcomponent *cal) {
icalcomponent *subcomponent;
icalproperty *p;
- /* If this object is a REPLY, then extract the UID. */
+ // If this object is a REPLY, then extract the UID.
if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
p = icalcomponent_get_first_property(cal, ICAL_UID_PROPERTY);
if (p != NULL) {
}
}
- /* Otherwise, recurse through any VEVENT subcomponents. We do NOT want the
- * UID of the reply; we want the UID of the invitation being replied to.
- */
+ // Otherwise, recurse through any VEVENT subcomponents. We do NOT want the
+ // UID of the reply; we want the UID of the invitation being replied to.
for (subcomponent = icalcomponent_get_first_component(cal, ICAL_VEVENT_COMPONENT);
- subcomponent != NULL;
- subcomponent = icalcomponent_get_next_component(cal, ICAL_VEVENT_COMPONENT) ) {
+ subcomponent != NULL;
+ subcomponent = icalcomponent_get_next_component(cal, ICAL_VEVENT_COMPONENT)
+ ) {
ical_learn_uid_of_reply(uidbuf, subcomponent);
}
}
-/*
- * ical_update_my_calendar_with_reply() refers to this callback function; when we
- * locate the message containing the calendar event we're replying to, this function
- * gets called. It basically just sticks the message number in a supplied buffer.
- */
+// ical_update_my_calendar_with_reply() refers to this callback function; when we
+// locate the message containing the calendar event we're replying to, this function
+// gets called. It basically just sticks the message number in a supplied buffer.
void ical_hunt_for_event_to_update(long msgnum, void *data) {
long *msgnumptr;
icalcomponent *c;
};
-/*
- * Callback function for mime parser that hunts for calendar content types
- * and turns them into calendar objects (called by ical_update_my_calendar_with_reply()
- * to fetch the object being updated)
- */
+// Callback function for mime parser that hunts for calendar content types
+// and turns them into calendar objects (called by ical_update_my_calendar_with_reply()
+// to fetch the object being updated)
void ical_locate_original_event(char *name, char *filename, char *partnum, char *disp,
void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
char *cbid, void *cbuserdata) {
struct original_event_container *oec = NULL;
- if ( (strcasecmp(cbtype, "text/calendar"))
- && (strcasecmp(cbtype, "application/ics")) ) {
+ if ( (strcasecmp(cbtype, "text/calendar"))
+ && (strcasecmp(cbtype, "application/ics"))
+ ) {
return;
}
oec = (struct original_event_container *) cbuserdata;
}
-/*
- * Merge updated attendee information from a REPLY into an existing event.
- */
+// Merge updated attendee information from a REPLY into an existing event.
void ical_merge_attendee_reply(icalcomponent *event, icalcomponent *reply) {
icalcomponent *c;
icalproperty *e_attendee, *r_attendee;
- /* First things first. If we're not looking at a VEVENT component,
- * recurse through subcomponents until we find one.
- */
+ // First things first. If we're not looking at a VEVENT component,
+ // recurse through subcomponents until we find one.
if (icalcomponent_isa(event) != ICAL_VEVENT_COMPONENT) {
for (c = icalcomponent_get_first_component(event, ICAL_VEVENT_COMPONENT);
c != NULL;
return;
}
- /* Now do the same thing with the reply.
- */
+ // Now do the same thing with the reply.
if (icalcomponent_isa(reply) != ICAL_VEVENT_COMPONENT) {
for (c = icalcomponent_get_first_component(reply, ICAL_VEVENT_COMPONENT);
c != NULL;
return;
}
- /* Clone the reply, because we're going to rip its guts out. */
+ // Clone the reply, because we're going to rip its guts out.
reply = icalcomponent_new_clone(reply);
- /* At this point we're looking at the correct subcomponents.
- * Iterate through the attendees looking for a match.
- */
+ // At this point we're looking at the correct subcomponents.
+ // Iterate through the attendees looking for a match.
STARTOVER:
for (e_attendee = icalcomponent_get_first_property(event, ICAL_ATTENDEE_PROPERTY);
e_attendee != NULL;
r_attendee != NULL;
r_attendee = icalcomponent_get_next_property(reply, ICAL_ATTENDEE_PROPERTY)) {
- /* Check to see if these two attendees match...
- */
+ // Check to see if these two attendees match...
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
- * status.)
- */
+ // ...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
+ // status.)
icalcomponent_remove_property(event, e_attendee);
icalproperty_free(e_attendee);
icalcomponent_remove_property(reply, r_attendee);
icalcomponent_add_property(event, r_attendee);
- /* Since we diddled both sets of attendees, we have to start
- * the iteration over again. This will not create an infinite
- * loop because we removed the attendee from the reply. (That's
- * why we cloned the reply, and that's what we mean by "ripping
- * its guts out.")
- */
+ // Since we diddled both sets of attendees, we have to start
+ // the iteration over again. This will not create an infinite
+ // loop because we removed the attendee from the reply. (That's
+ // why we cloned the reply, and that's what we mean by "ripping
+ // its guts out.")
goto STARTOVER;
}
}
}
- /* Free the *clone* of the reply. */
+ // Free the *clone* of the reply.
icalcomponent_free(reply);
}
-/*
- * Handle an incoming RSVP (object with method==ICAL_METHOD_REPLY) for a
- * calendar event. The object has already been deserialized for us; all
- * we have to do here is hunt for the event in our calendar, merge in the
- * updated attendee status, and save it again.
- *
- * This function returns 0 on success, 1 if the event was not found in the
- * user's calendar, or 2 if an internal error occurred.
- */
+// Handle an incoming RSVP (object with method==ICAL_METHOD_REPLY) for a
+// calendar event. The object has already been deserialized for us; all
+// we have to do here is hunt for the event in our calendar, merge in the
+// updated attendee status, and save it again.
+//
+// This function returns 0 on success, 1 if the event was not found in the
+// user's calendar, or 2 if an internal error occurred.
int ical_update_my_calendar_with_reply(icalcomponent *cal) {
char uid[SIZ];
char hold_rm[ROOMNAMELEN];
char roomname[ROOMNAMELEN];
char *message_text = NULL;
- /* Figure out just what event it is we're dealing with */
+ // Figure out just what event it is we're dealing with
strcpy(uid, "--==<< InVaLiD uId >>==--");
ical_learn_uid_of_reply(uid, cal);
syslog(LOG_DEBUG, "calendar: UID of event being replied to is <%s>", uid);
- strcpy(hold_rm, CC->room.QRname); /* save current room */
+ strcpy(hold_rm, CC->room.QRname); // save current room
if (CtdlGetRoom(&CC->room, USERCALENDARROOM) != 0) {
CtdlGetRoom(&CC->room, hold_rm);
return(2);
}
- /*
- * Look in the EUID index for a message with
- * the Citadel EUID set to the value we're looking for. Since
- * Citadel always sets the message EUID to the iCalendar UID of
- * the event, this will work.
- */
+ // Look in the EUID index for a message with
+ // the Citadel EUID set to the value we're looking for. Since
+ // Citadel always sets the message EUID to the iCalendar UID of
+ // the event, this will work.
msgnum_being_replaced = CtdlLocateMessageByEuid(uid, &CC->room);
- CtdlGetRoom(&CC->room, hold_rm); /* return to saved room */
+ CtdlGetRoom(&CC->room, hold_rm); // return to saved room
syslog(LOG_DEBUG, "calendar: msgnum_being_replaced == %ld", msgnum_being_replaced);
if (msgnum_being_replaced == 0) {
- return(1); /* no calendar event found */
+ return(1); // no calendar event found
}
- /* Now we know the ID of the message containing the event being updated.
- * We don't actually have to delete it; that'll get taken care of by the
- * server when we save another event with the same UID. This just gives
- * us the ability to load the event into memory so we can diddle the
- * attendees.
- */
+ // Now we know the ID of the message containing the event being updated.
+ // We don't actually have to delete it; that'll get taken care of by the
+ // server when we save another event with the same UID. This just gives
+ // us the ability to load the event into memory so we can diddle the attendees.
msg = CtdlFetchMessage(msgnum_being_replaced, 1);
if (msg == NULL) {
- return(2); /* internal error */
+ return(2); // internal error
}
oec.c = NULL;
- mime_parser(CM_RANGE(msg, eMesageText),
- *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(2);
}
- /* Merge the attendee's updated status into the event */
+ // Merge the attendee's updated status into the event
ical_merge_attendee_reply(original_event, cal);
- /* Serialize it */
+ // Serialize it
serialized_event = icalcomponent_as_ical_string_r(original_event);
- icalcomponent_free(original_event); /* Don't need this anymore. */
+ icalcomponent_free(original_event); // Don't need this anymore.
if (serialized_event == NULL) return(2);
CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM);
);
msg = CtdlMakeMessage(&CC->user,
- "", /* No recipient */
- "", /* No recipient */
+ "", // No recipient
+ "", // No recipient
roomname,
- 0, FMT_RFC822,
+ 0,
+ FMT_RFC822,
"",
"",
- "", /* no subject */
+ "", // no subject
NULL,
message_text,
- NULL);
+ NULL
+ );
if (msg != NULL) {
CIT_ICAL->avoid_sending_invitations = 1;
}
-/*
- * Handle an incoming RSVP for an event. (This is the server subcommand part; it
- * simply extracts the calendar object from the message, deserializes it, and
- * passes it up to ical_update_my_calendar_with_reply() for processing.
- */
+// Handle an incoming RSVP for an event. (This is the server subcommand part; it
+// simply extracts the calendar object from the message, deserializes it, and
+// passes it up to ical_update_my_calendar_with_reply() for processing.
void ical_handle_rsvp(long msgnum, char *partnum, char *action) {
struct CtdlMessage *msg = NULL;
struct ical_respond_data ird;
int ret;
if (
- (strcasecmp(action, "update"))
- && (strcasecmp(action, "ignore"))
+ (strcasecmp(action, "update"))
+ && (strcasecmp(action, "ignore"))
) {
- cprintf("%d Action must be 'update' or 'ignore'\n",
- ERROR + ILLEGAL_VALUE
- );
+ cprintf("%d Action must be 'update' or 'ignore'\n", ERROR + ILLEGAL_VALUE);
return;
}
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, partnum);
- mime_parser(CM_RANGE(msg, eMesageText),
- *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.
- */
+ // We're done with the incoming message, because we now have a
+ // calendar object in memory.
CM_Free(msg);
- /*
- * Here is the real meat of this function. Handle the event.
- */
+ // Here is the real meat of this function. Handle the event.
if (ird.cal != NULL) {
- /* Update the user's calendar if necessary */
+ // Update the user's calendar if necessary
if (!strcasecmp(action, "update")) {
ret = ical_update_my_calendar_with_reply(ird.cal);
if (ret == 0) {
- cprintf("%d Your calendar has been updated with this reply.\n",
- CIT_OK);
+ cprintf("%d Your calendar has been updated with this reply.\n", CIT_OK);
}
else if (ret == 1) {
- cprintf("%d This event does not exist in your calendar.\n",
- ERROR + FILE_NOT_FOUND);
+ cprintf("%d This event does not exist in your calendar.\n", ERROR + FILE_NOT_FOUND);
}
else {
- cprintf("%d An internal error occurred.\n",
- ERROR + INTERNAL_ERROR);
+ cprintf("%d An internal error occurred.\n", ERROR + INTERNAL_ERROR);
}
}
else {
cprintf("%d This reply has been ignored.\n", CIT_OK);
}
- /* Now that we've processed this message, we don't need it
- * anymore. So delete it. (Don't do this anymore.)
- CtdlDeleteMessages(CC->room.QRname, &msgnum, 1, "");
- */
+ // Now that we've processed this message, we don't need it
+ // anymore. So delete it. (Don't do this anymore.)
+ // CtdlDeleteMessages(CC->room.QRname, &msgnum, 1, "");
- /* Free the memory we allocated and return a response. */
+ // Free the memory we allocated and return a response.
icalcomponent_free(ird.cal);
ird.cal = NULL;
return;
return;
}
- /* should never get here */
+ // should never get here
}
-/*
- * Search for a property in both the top level and in a VEVENT subcomponent
- */
+// Search for a property in both the top level and in a VEVENT subcomponent
icalproperty *ical_ctdl_get_subprop(
icalcomponent *cal,
icalproperty_kind which_prop
p = icalcomponent_get_first_property(cal, which_prop);
if (p == NULL) {
- c = icalcomponent_get_first_component(cal,
- ICAL_VEVENT_COMPONENT);
+ c = icalcomponent_get_first_component(cal, ICAL_VEVENT_COMPONENT);
if (c != NULL) {
p = icalcomponent_get_first_property(c, which_prop);
}
}
-/*
- * Check to see if two events overlap. Returns nonzero if they do.
- * (This function is used in both Citadel and WebCit. If you change it in
- * one place, change it in the other. Better yet, put it in a library.)
- */
+// Check to see if two events overlap. Returns nonzero if they do.
+// (This function is used in both Citadel and WebCit. If you change it in
+// one place, change it in the other. Better yet, put it in a library.)
int ical_ctdl_is_overlap(
struct icaltimetype t1start,
struct icaltimetype t1end,
if (icaltime_is_null_time(t1start)) return(0);
if (icaltime_is_null_time(t2start)) return(0);
- /* if either event lacks end time, assume end = start */
- if (icaltime_is_null_time(t1end))
+ // if either event lacks end time, assume end = start
+ if (icaltime_is_null_time(t1end)) {
memcpy(&t1end, &t1start, sizeof(struct icaltimetype));
+ }
else {
if (t1end.is_date && icaltime_compare(t1start, t1end)) {
- /*
- * the end date is non-inclusive so adjust it by one
- * day because our test is inclusive, note that a day is
- * not too much because we are talking about all day
- * events
- * if start = end we assume that nevertheless the whole
- * day is meant
- */
+
+ // the end date is non-inclusive so adjust it by one
+ // day because our test is inclusive, note that a day is
+ // not too much because we are talking about all day
+ // events
+ // if start = end we assume that nevertheless the whole
+ // day is meant
+
icaltime_adjust(&t1end, -1, 0, 0, 0);
}
}
{
int conflict_reported = 0;
- /* debugging cruft *
- time_t tt;
- tt = icaltime_as_timet_with_zone(t1start, t1start.zone);
- syslog(LOG_DEBUG, "PROPOSED START: %s", ctime(&tt));
- tt = icaltime_as_timet_with_zone(t1end, t1end.zone);
- syslog(LOG_DEBUG, " PROPOSED END: %s", ctime(&tt));
- tt = icaltime_as_timet_with_zone(t2start, t2start.zone);
- syslog(LOG_DEBUG, "EXISTING START: %s", ctime(&tt));
- tt = icaltime_as_timet_with_zone(t2end, t2end.zone);
- syslog(LOG_DEBUG, " EXISTING END: %s", ctime(&tt));
- * debugging cruft */
+ // debugging cruft
+ // time_t tt;
+ // tt = icaltime_as_timet_with_zone(t1start, t1start.zone);
+ // syslog(LOG_DEBUG, "PROPOSED START: %s", ctime(&tt));
+ // tt = icaltime_as_timet_with_zone(t1end, t1end.zone);
+ // syslog(LOG_DEBUG, " PROPOSED END: %s", ctime(&tt));
+ // tt = icaltime_as_timet_with_zone(t2start, t2start.zone);
+ // syslog(LOG_DEBUG, "EXISTING START: %s", ctime(&tt));
+ // tt = icaltime_as_timet_with_zone(t2end, t2end.zone);
+ // syslog(LOG_DEBUG, " EXISTING END: %s", ctime(&tt));
+ // debugging cruft
/* compare and output */
}
-/*
- * Phase 5 of "hunt for conflicts"
- * Called by ical_conflicts_phase4()
- *
- * We have the proposed event boiled down to start and end times.
- * Now check it against an existing event.
- */
+// Phase 5 of "hunt for conflicts"
+// Called by ical_conflicts_phase4()
+//
+// We have the proposed event boiled down to start and end times.
+// Now check it against an existing event.
void ical_conflicts_phase5(struct icaltimetype t1start,
struct icaltimetype t1end,
icalcomponent *existing_event,
}
else {
t2end.zone = icalcomponent_get_timezone(existing_event,
- icalparameter_get_tzid(
- icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER)
- )
+ icalparameter_get_tzid(icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER))
);
if (!t2end.zone) {
t2end.zone = get_default_icaltimezone();
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, "_HUNT_");
mime_parser(CM_RANGE(msg, eMesageText),
- *ical_locate_part, /* callback function */
- NULL, NULL,
- (void *) &ird, /* user data */
- 0
+ *ical_locate_part, // callback function
+ NULL,
+ NULL,
+ (void *) &ird, // user data
+ 0
);
CM_Free(msg);
}
-/*
- * Retrieve all of the calendar items in the current room, and output them
- * as a single icalendar object.
- */
-void ical_getics(void)
-{
+// Retrieve all of the calendar items in the current room, and output them
+// as a single icalendar object.
+void ical_getics(void) {
icalcomponent *encaps = NULL;
char *ser = NULL;
- if ( (CC->room.QRdefaultview != VIEW_CALENDAR)
- &&(CC->room.QRdefaultview != VIEW_TASKS) ) {
+ if ( (CC->room.QRdefaultview != VIEW_CALENDAR)
+ &&(CC->room.QRdefaultview != VIEW_TASKS)
+ ) {
cprintf("%d Not a calendar room\n", ERROR+NOT_HERE);
- return; /* Not an iCalendar-centric room */
+ return; /* This room does not contain a calendar. */
}
encaps = icalcomponent_new_vcalendar();
}
-/*
- * Helper callback function for ical_putics() to discover which TZID's we need.
- * Simply put the tzid name string into a hash table. After the callbacks are
- * done we'll go through them and attach the ones that we have.
- */
-void ical_putics_grabtzids(icalparameter *param, void *data)
-{
+// Helper callback function for ical_putics() to discover which TZID's we need.
+// Simply put the tzid name string into a hash table. After the callbacks are
+// done we'll go through them and attach the ones that we have.
+void ical_putics_grabtzids(icalparameter *param, void *data) {
const char *tzid = icalparameter_get_tzid(param);
HashList *keys = (HashList *) data;
}
-/*
- * Delete all of the calendar items in the current room, and replace them
- * with calendar items from a client-supplied data stream.
- */
-void ical_putics(void)
-{
+// Delete all of the calendar items in the current room, and replace them
+// with calendar items from a client-supplied data stream.
+void ical_putics(void) {
char *calstream = NULL;
icalcomponent *cal;
icalcomponent *c;
const char *Key;
long len;
- /* Only allow this operation if we're in a room containing a calendar or tasks view */
- if ( (CC->room.QRdefaultview != VIEW_CALENDAR)
- &&(CC->room.QRdefaultview != VIEW_TASKS) ) {
+ // Only allow this operation if we're in a room containing a calendar or tasks view
+ if ( (CC->room.QRdefaultview != VIEW_CALENDAR)
+ && (CC->room.QRdefaultview != VIEW_TASKS)
+ ) {
cprintf("%d Not a calendar room\n", ERROR+NOT_HERE);
return;
}
- /* Only allow this operation if we have permission to overwrite the existing calendar */
+ // Only allow this operation if we have permission to overwrite the existing calendar
if (!CtdlDoIHavePermissionToDeleteMessagesFromThisRoom()) {
cprintf("%d Permission denied.\n", ERROR+HIGHER_ACCESS_REQUIRED);
return;
*/
else {
for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
- (c != NULL);
- c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
+ (c != NULL);
+ c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)
+ ) {
/* Non-VTIMEZONE components each get written as individual messages.
* But we also need to attach the relevant VTIMEZONE components to them.
/*
* All Citadel calendar commands from the client come through here.
*/
-void cmd_ical(char *argbuf)
-{
+void cmd_ical(char *argbuf) {
char subcmd[64];
long msgnum;
char partnum[256];
/*
* We don't know if the calendar room exists so we just create it at login
*/
-void ical_CtdlCreateRoom(void)
-{
+void ical_CtdlCreateRoom(void) {
struct ctdlroom qr;
struct visit vbuf;
* 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, struct recptypes *recp)
-{
+int ical_obj_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
/* First determine if this is a calendar or tasks room */
if ( (CC->room.QRdefaultview != VIEW_CALENDAR)
&& (CC->room.QRdefaultview != VIEW_TASKS)
* (This will start back end tasks such as automatic generation of invitations,
* if such actions are appropriate.)
*/
-int ical_obj_aftersave(struct CtdlMessage *msg, struct recptypes *recp)
-{
+int ical_obj_aftersave(struct CtdlMessage *msg, struct recptypes *recp) {
char roomname[ROOMNAMELEN];
/*