That about wraps it up for serv_calendar.c
authorArt Cancro <ajc@citadel.org>
Fri, 5 Jan 2024 19:52:10 +0000 (14:52 -0500)
committerArt Cancro <ajc@citadel.org>
Fri, 5 Jan 2024 19:52:10 +0000 (14:52 -0500)
Seeing this code has really brought me back to the upstairs room
in my old house where I wrote most of it back in 2002-2003.  I can
see the sunlight coming in the windows, the color of the carpet,
the little alcove where the computer was, the cat sleeping on top
of the big CRT monitor.

Hopefully the stuff I need to add to it now will be straightforward
since it looks like I really took my time and commented it heavily.
It looks pretty clean, especially now that I've reformatted it with
the new screen width an C99 comments.  It does seem a bit WET though.

citadel/server/modules/calendar/serv_calendar.c

index 02be85f0ffd15ed7e6e82a93395100c7bbdee6c1..5e169c1b6a46ceb049bf9658f74bbf5a7b567108 100644 (file)
@@ -1917,9 +1917,8 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
 
        syslog(LOG_DEBUG, "calendar: <%d> attendees: <%s>", 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 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;
@@ -2062,17 +2061,14 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
 }
 
 
-/*
- * When a calendar object is being saved, determine whether it's a VEVENT
- * and the user saving it is the organizer.  If so, send out invitations
- * to any listed attendees.
- *
- * This function is recursive.  The caller can simply supply the same object
- * as both arguments.  When it recurses it will alter the second argument
- * while holding on to the top level object.  This allows us to go back and
- * grab things like time zones which might be attached.
- *
- */
+// When a calendar object is being saved, determine whether it's a VEVENT
+// and the user saving it is the organizer.  If so, send out invitations
+// to any listed attendees.
+//
+// This function is recursive.  The caller can simply supply the same object
+// as both arguments.  When it recurses it will alter the second argument
+// while holding on to the top level object.  This allows us to go back and
+// grab things like time zones which might be attached.
 void ical_saving_vevent(icalcomponent *top_level_cal, icalcomponent *cal) {
        icalcomponent *c;
        icalproperty *organizer = NULL;
@@ -2091,10 +2087,8 @@ void ical_saving_vevent(icalcomponent *top_level_cal, icalcomponent *cal) {
        }
 
        strcpy(organizer_string, "");
-       /*
-        * The VEVENT subcomponent is the one we're interested in.
-        * Send out invitations if, and only if, this user is the Organizer.
-        */
+       // The VEVENT subcomponent is the one we're interested in.
+       // Send out invitations if, and only if, this user is the Organizer.
        if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
                organizer = icalcomponent_get_first_property(cal, ICAL_ORGANIZER_PROPERTY);
                if (organizer != NULL) {
@@ -2106,10 +2100,8 @@ void ical_saving_vevent(icalcomponent *top_level_cal, icalcomponent *cal) {
                if (!strncasecmp(organizer_string, "MAILTO:", 7)) {
                        strcpy(organizer_string, &organizer_string[7]);
                        string_trim(organizer_string);
-                       /*
-                        * If the user saving the event is listed as the
-                        * organizer, then send out invitations.
-                        */
+                       // If the user saving the event is listed as the
+                       // organizer, then send out invitations.
                        if (CtdlIsMe(organizer_string, sizeof organizer_string)) {
                                ical_send_out_invitations(top_level_cal, cal);
                        }
@@ -2128,12 +2120,10 @@ void ical_saving_vevent(icalcomponent *top_level_cal, icalcomponent *cal) {
 }
 
 
-/*
- * Back end for ical_obj_beforesave()
- * This hunts for the UID of the calendar event (becomes Citadel msg EUID),
- * the summary of the event (becomes message subject),
- * and the start time (becomes message date/time).
- */
+// Back end for ical_obj_beforesave()
+// This hunts for the UID of the calendar event (becomes Citadel msg EUID),
+// the summary of the event (becomes message subject),
+// and the start time (becomes message date/time).
 void ical_obj_beforesave_backend(char *name, char *filename, char *partnum,
                char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
                char *encoding, char *cbid, void *cbuserdata)
@@ -2223,13 +2213,11 @@ void ical_obj_beforesave_backend(char *name, char *filename, char *partnum,
 }
 
 
-/*
- * See if we need to prevent the object from being saved (we don't allow
- * MIME types other than text/calendar in "calendar" or "tasks" rooms).
- *
- * If the message is being saved, we also set various message header fields
- * using data found in the iCalendar object.
- */
+// See if we need to prevent the object from being saved (we don't allow
+// MIME types other than text/calendar in "calendar" or "tasks" rooms).
+//
+// 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) {
        // First determine if this is a calendar or tasks room
        if (    (CC->room.QRdefaultview != VIEW_CALENDAR)
@@ -2262,9 +2250,7 @@ int ical_obj_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
 }
 
 
-/*
- * Things we need to do after saving a calendar event.
- */
+// Things we need to do after saving a calendar event.
 void ical_obj_aftersave_backend(char *name, char *filename, char *partnum,
                char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
                char *encoding, char *cbid, void *cbuserdata)
@@ -2278,11 +2264,10 @@ void ical_obj_aftersave_backend(char *name, char *filename, char *partnum,
                return;
        }
 
-       /* Hunt for the UID and drop it in
-        * the "user data" pointer for the MIME parser.  When
-        * ical_obj_beforesave() sees it there, it'll set the Exclusive msgid
-        * to that string.
-        */
+       // Hunt for the UID and drop it in
+       // the "user data" pointer for the MIME parser.  When
+       // ical_obj_beforesave() sees it there, it'll set the Exclusive msgid
+       // to that string.
        if (    (!strcasecmp(cbtype, "text/calendar"))
                || (!strcasecmp(cbtype, "application/ics"))
        ) {
@@ -2295,17 +2280,13 @@ void ical_obj_aftersave_backend(char *name, char *filename, char *partnum,
 }
 
 
-/* 
- * Things we need to do after saving a calendar event.
- * (This will start back end tasks such as automatic generation of invitations,
- * if such actions are appropriate.)
- */
+// Things we need to do after saving a calendar event.
+// (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) {
        char roomname[ROOMNAMELEN];
 
-       /*
-        * If this isn't the Calendar> room, no further action is necessary.
-        */
+       // If this isn't the Calendar> room, no further action is necessary.
 
        // First determine if this is our room
        CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM);