+// This is an experimental implementation of CALDAV REPORT operations (RFC 4791 section 7)
+// fundamentally handled in the Citadel Server. A web implementation should be able to just
+// change the encapsulation to HTTP with the data format unchanged.
+void ical_report(void) {
+ cprintf("%d Hi from Citadel\n", CIT_OK);
+}
+
+
+// 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")) {
+ ical_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);
+}
+
+