Experimenting with the code layout for calendar report handling.
authorArt Cancro <ajc@citadel.org>
Mon, 8 Jan 2024 21:29:16 +0000 (16:29 -0500)
committerArt Cancro <ajc@citadel.org>
Mon, 8 Jan 2024 21:29:16 +0000 (16:29 -0500)
The goal is to provide calendar searches (date range etc) for both WebCit-NG
and for CALDAV REPORT method in a DRY way.

citadel/server/modules/calendar/calendar_report.c [new file with mode: 0644]
citadel/server/modules/calendar/serv_calendar.c
citadel/server/modules/calendar/serv_calendar.h

diff --git a/citadel/server/modules/calendar/calendar_report.c b/citadel/server/modules/calendar/calendar_report.c
new file mode 100644 (file)
index 0000000..1ffe3ed
--- /dev/null
@@ -0,0 +1,39 @@
+// This is a handler for calendar "report" operations.
+// It is expected that CALDAV REPORT operations should be able to use this directly.
+//
+// Copyright (c) 1987-2024 by the citadel.org team
+//
+// This program is open source software.  Use, duplication, or disclosure
+// are subject to the terms of the GNU General Public License version 3.
+
+#define PRODID "-//Citadel//NONSGML Citadel Calendar//EN"
+
+#include "../../ctdl_module.h"
+#include <libical/ical.h>
+#include "../../msgbase.h"
+#include "../../internet_addressing.h"
+#include "serv_calendar.h"
+#include "../../room_ops.h"
+#include "../../euidindex.h"
+#include "../../default_timezone.h"
+#include "../../config.h"
+
+
+void calendar_report(void) {
+       char buf[SIZ];
+
+       // 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;         // This room does not contain a calendar.
+       }
+
+       cprintf("%d Send query then receive response\n", SEND_THEN_RECV);
+       while(client_getln(buf, sizeof buf) >= 0 && strcmp(buf,"000")) {
+       }
+       cprintf("000\n");
+}
+
+
index 2569fb5dd43d22ffcc7c29c8338a55dfc68602a2..ac9d74465a993c258a75ee76204b5fec95a21c94 100644 (file)
@@ -2327,27 +2327,6 @@ void ical_fixed_output(char *ptr, int len) {
 }
 
 
-// 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) {
-       char buf[SIZ];
-
-       // 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;         // This room does not contain a calendar.
-       }
-
-       cprintf("%d Send query then receive response\n", SEND_THEN_RECV);
-       while(client_getln(buf, sizeof buf) >= 0 && strcmp(buf,"000")) {
-       }
-       cprintf("000\n");
-}
-
-
 // All Citadel calendar commands from the client come through here.
 void cmd_ical(char *argbuf) {
        char subcmd[64];
@@ -2381,7 +2360,7 @@ void cmd_ical(char *argbuf) {
        if (CtdlAccessCheck(ac_logged_in)) return;
 
        if (!strcasecmp(subcmd, "report")) {
-               ical_report();
+               calendar_report();
                return;
        }
 
index 8f5a06e8e6d9fe64656d845b74fafd35e35b841b..93d6ee86e8e5daabc53bb058a13d9f75d8b8a054 100644 (file)
@@ -20,3 +20,5 @@ struct cit_ical {
 
 #define CIT_ICAL CC->CIT_ICAL
 #define MAX_RECUR 1000
+
+void calendar_report(void);