icalcomponent *encaps = NULL;
char *ser = NULL;
+ // 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)
+ && (CC->room.QRdefaultview != VIEW_TASKS)
) {
cprintf("%d Not a calendar room\n", ERROR+NOT_HERE);
return; // This room does not contain a calendar.
&& (CC->room.QRdefaultview != VIEW_TASKS)
) {
cprintf("%d Not a calendar room\n", ERROR+NOT_HERE);
- return;
+ return; // This room does not contain a calendar.
}
// Only allow this operation if we have permission to overwrite the existing calendar
}
-// All Citadel calendar commands from the client come through here.
-void cmd_ical(char *argbuf) {
- char subcmd[64];
- long msgnum;
- char partnum[256];
- char action[256];
- char who[256];
-
- extract_token(subcmd, argbuf, 0, '|', sizeof subcmd);
-
- // Allow "test" and "freebusy" subcommands without logging in.
-
- if (!strcasecmp(subcmd, "test")) {
- cprintf("%d This server supports calendaring\n", CIT_OK);
- return;
- }
-
- if (!strcasecmp(subcmd, "freebusy")) {
- extract_token(who, argbuf, 1, '|', sizeof who);
- ical_freebusy(who);
- return;
- }
-
- if (!strcasecmp(subcmd, "sgi")) {
- CIT_ICAL->server_generated_invitations = (extract_int(argbuf, 1) ? 1 : 0) ;
- cprintf("%d %d\n", CIT_OK, CIT_ICAL->server_generated_invitations);
- return;
- }
-
- if (CtdlAccessCheck(ac_logged_in)) return;
-
- if (!strcasecmp(subcmd, "respond")) {
- msgnum = extract_long(argbuf, 1);
- extract_token(partnum, argbuf, 2, '|', sizeof partnum);
- extract_token(action, argbuf, 3, '|', sizeof action);
- ical_respond(msgnum, partnum, action);
- return;
- }
-
- if (!strcasecmp(subcmd, "handle_rsvp")) {
- msgnum = extract_long(argbuf, 1);
- extract_token(partnum, argbuf, 2, '|', sizeof partnum);
- extract_token(action, argbuf, 3, '|', sizeof action);
- ical_handle_rsvp(msgnum, partnum, action);
- return;
- }
-
- if (!strcasecmp(subcmd, "conflicts")) {
- msgnum = extract_long(argbuf, 1);
- extract_token(partnum, argbuf, 2, '|', sizeof partnum);
- ical_conflicts(msgnum, partnum);
- return;
- }
-
- if (!strcasecmp(subcmd, "getics")) {
- ical_getics();
- return;
- }
-
- if (!strcasecmp(subcmd, "putics")) {
- ical_putics();
- return;
- }
-
- cprintf("%d Invalid subcommand\n", ERROR + CMD_NOT_SUPPORTED);
-}
-
-
// We don't know if the calendar room exists so we just create it at login
void ical_CtdlCreateRoom(void) {
struct ctdlroom qr;
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;
}
-/*
- * 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;
}
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) {
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);
}
}
-/*
- * 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)
}
-/*
- * 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)
}
-/*
- * 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)
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"))
) {
}
-/*
- * 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);
}
+// All Citadel calendar commands from the client come through here.
+void cmd_ical(char *argbuf) {
+ char subcmd[64];
+ long msgnum;
+ char partnum[256];
+ char action[256];
+ char who[256];
+
+ extract_token(subcmd, argbuf, 0, '|', sizeof subcmd);
+
+ // Allow "test" and "freebusy" and "sgi" subcommands without logging in.
+
+ if (!strcasecmp(subcmd, "test")) {
+ cprintf("%d This server supports calendaring\n", CIT_OK);
+ return;
+ }
+
+ if (!strcasecmp(subcmd, "freebusy")) {
+ extract_token(who, argbuf, 1, '|', sizeof who);
+ ical_freebusy(who);
+ return;
+ }
+
+ if (!strcasecmp(subcmd, "sgi")) {
+ CIT_ICAL->server_generated_invitations = (extract_int(argbuf, 1) ? 1 : 0) ;
+ cprintf("%d %d\n", CIT_OK, CIT_ICAL->server_generated_invitations);
+ return;
+ }
+
+ // All other commands require a user to be logged in.
+ if (CtdlAccessCheck(ac_logged_in)) return;
+
+ if (!strcasecmp(subcmd, "report")) {
+ calendar_report();
+ return;
+ }
+
+ if (!strcasecmp(subcmd, "respond")) {
+ msgnum = extract_long(argbuf, 1);
+ extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+ extract_token(action, argbuf, 3, '|', sizeof action);
+ ical_respond(msgnum, partnum, action);
+ return;
+ }
+
+ if (!strcasecmp(subcmd, "handle_rsvp")) {
+ msgnum = extract_long(argbuf, 1);
+ extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+ extract_token(action, argbuf, 3, '|', sizeof action);
+ ical_handle_rsvp(msgnum, partnum, action);
+ return;
+ }
+
+ if (!strcasecmp(subcmd, "conflicts")) {
+ msgnum = extract_long(argbuf, 1);
+ extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+ ical_conflicts(msgnum, partnum);
+ return;
+ }
+
+ if (!strcasecmp(subcmd, "getics")) {
+ ical_getics();
+ return;
+ }
+
+ if (!strcasecmp(subcmd, "putics")) {
+ ical_putics();
+ return;
+ }
+
+ cprintf("%d Invalid subcommand\n", ERROR + CMD_NOT_SUPPORTED);
+}
+
+
// Initialization function, called from modules_init.c
char *ctdl_module_init_calendar(void) {
if (!threading) {