Giving up on doing citserver-side REPORT parsing.
authorArt Cancro <ajc@citadel.org>
Wed, 31 Jan 2024 02:59:50 +0000 (21:59 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 31 Jan 2024 02:59:50 +0000 (21:59 -0500)
webcit and citserver are guaranteed to be on the same host now, and
performance over a unix domain socket is likely to approach that of
doing it the "hard" way anyway.  So I pulled out all the crap I was
adding.  It was making the data model very ugly.

citadel/server/modules/calendar/calendar_report.c [deleted file]
citadel/server/modules/calendar/serv_calendar.c
citadel/server/modules/calendar/serv_calendar.h
webcit-ng/server/caldav_reports.c

diff --git a/citadel/server/modules/calendar/calendar_report.c b/citadel/server/modules/calendar/calendar_report.c
deleted file mode 100644 (file)
index b5e52db..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-// 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.
-
-#include <libical/ical.h>
-#include "../../ctdl_module.h"
-#include "../../msgbase.h"
-#include "../../internet_addressing.h"
-#include "../../room_ops.h"
-#include "../../euidindex.h"
-#include "../../default_timezone.h"
-#include "../../config.h"
-#include "serv_calendar.h"
-
-
-// CtdlForEachMessage callback for calendar_query()
-void calendar_query_backend(long msgnum, void *data) {
-       struct CtdlMessage *msg = NULL;
-       struct ical_respond_data ird;
-
-       syslog(LOG_DEBUG, "calendar_query: calendar_query_backend(%ld)", msgnum);
-
-       // Look for the calendar event...
-       msg = CtdlFetchMessage(msgnum, 1);
-       if (msg == NULL) return;
-       memset(&ird, 0, sizeof ird);
-       strcpy(ird.desired_partnum, "_HUNT_");
-       mime_parser(
-               CM_RANGE(msg, eMessageText),
-               *ical_locate_part,              // This callback function extracts a vcalendar item from the message.
-               NULL,
-               NULL,
-               (void *) &ird,                  // Give it this place to put the vcalendar object.
-               0
-       );
-       CM_Free(msg);
-       if (ird.cal == NULL) return;            // If there was no calendar item in this message, do nothing else.
-
-
-       // This is where we need to perform our search reduction.
-
-
-       char *ser = icalcomponent_as_ical_string_r(ird.cal);
-       if (ser) {
-               size_t len = strlen(ser);       // Output the object, ensuring it terminates with a newline.
-               client_write(ser, len);
-               if ( (len>0) && (ser[len-1] != '\n') ) {
-                       client_write(HKEY("\n"));
-               }
-               free(ser);
-       }
-
-       icalcomponent_free(ird.cal);            // Return the memory we got from the callback.
-}
-
-
-// Go through a calendar room and output calendar objects after applying caller specified filters.
-// It is intended as a data source for WebCit (both the UI and CalDAV)
-void calendar_query(void) {
-       void *filter_rules;     // Don't know yet what form this will take
-
-       // 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 Filtered calendar listing:\n", LISTING_FOLLOWS);
-
-       // Now go through the room encapsulating all calendar items.
-       CtdlForEachMessage(MSGS_ALL, 0, NULL,
-               NULL,
-               NULL,
-               calendar_query_backend,
-               (void *) filter_rules
-       );
-
-       cprintf("000\n");
-}
index 23b4ce93432b1ae08d71b6bc916a444c10d35ffb..a1016a41027cfe3f351137fd179a0ae3bd94a59d 100644 (file)
@@ -2321,6 +2321,7 @@ void cmd_ical(char *argbuf) {
        char partnum[256];
        char action[256];
        char who[256];
+       char coll[1024];
 
        extract_token(subcmd, argbuf, 0, '|', sizeof subcmd);
 
@@ -2346,11 +2347,6 @@ void cmd_ical(char *argbuf) {
        // All other commands require a user to be logged in.
        if (CtdlAccessCheck(ac_logged_in)) return;
 
-       if (!strcasecmp(subcmd, "query")) {
-               calendar_query();
-               return;
-       }
-
        if (!strcasecmp(subcmd, "respond")) {
                msgnum = extract_long(argbuf, 1);
                extract_token(partnum, argbuf, 2, '|', sizeof partnum);
index 7bb827c45fde51b02fd491fd0cbf949e470499ef..93f0b50e53ec0fbcff3d222f8d0ba81903a01eaf 100644 (file)
@@ -31,50 +31,47 @@ struct ical_respond_data {
 };
 
 
-// Everything below was generated by `cproto *.c 2>/dev/null`
-
-// calendar_query.c
-void calendar_query_backend(long msgnum, void *data);
-void calendar_query(void);
+// Everything below was generated by
+// cproto -f2 *.c 2>/dev/null |sed 's/^\/\*/\n\/\//g' | sed 's/\ \*\/$//g'
 
 // serv_calendar.c
 icalcomponent *icalcomponent_new_citadel_vcalendar(void);
-icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp);
-void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal);
-void ical_send_a_reply(icalcomponent *request, char *action);
-void ical_locate_part(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *cbuserdata);
-void ical_respond(long msgnum, char *partnum, char *action);
-void ical_learn_uid_of_reply(char *uidbuf, icalcomponent *cal);
-void ical_hunt_for_event_to_update(long msgnum, void *data);
-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);
-void ical_merge_attendee_reply(icalcomponent *event, icalcomponent *reply);
-int ical_update_my_calendar_with_reply(icalcomponent *cal);
-void ical_handle_rsvp(long msgnum, char *partnum, char *action);
-icalproperty *ical_ctdl_get_subprop(icalcomponent *cal, icalproperty_kind which_prop);
-int ical_ctdl_is_overlap(struct icaltimetype t1start, struct icaltimetype t1end, struct icaltimetype t2start, struct icaltimetype t2end);
-int ical_conflicts_phase6(struct icaltimetype t1start, struct icaltimetype t1end, struct icaltimetype t2start, struct icaltimetype t2end, long existing_msgnum, char *conflict_event_uid, char *conflict_event_summary, char *compare_uid);
-void ical_conflicts_phase5(struct icaltimetype t1start, struct icaltimetype t1end, icalcomponent *existing_event, long existing_msgnum, char *compare_uid);
-void ical_conflicts_phase4(icalcomponent *proposed_event, icalcomponent *existing_event, long existing_msgnum);
-void ical_hunt_for_conflicts_backend(long msgnum, void *data);
-void ical_hunt_for_conflicts(icalcomponent *cal);
-void ical_conflicts(long msgnum, char *partnum);
-void ical_add_to_freebusy(icalcomponent *fb, icalcomponent *top_level_cal);
-void ical_freebusy_backend(long msgnum, void *data);
-void ical_freebusy(char *who);
-void ical_getics_backend(long msgnum, void *data);
+icalcomponent *ical_encapsulate_subcomponent(icalcomponent *);
+void ical_write_to_cal(struct ctdluser *, icalcomponent *);
+void ical_send_a_reply(icalcomponent *, char *);
+void ical_locate_part(char *, char *, char *, char *, void *, char *, char *, size_t, char *, char *, void *);
+void ical_respond(long, char *, char *);
+void ical_learn_uid_of_reply(char *, icalcomponent *);
+void ical_hunt_for_event_to_update(long, void *);
+void ical_locate_original_event(char *, char *, char *, char *, void *, char *, char *, size_t, char *, char *, void *);
+void ical_merge_attendee_reply(icalcomponent *, icalcomponent *);
+int ical_update_my_calendar_with_reply(icalcomponent *);
+void ical_handle_rsvp(long, char *, char *);
+icalproperty *ical_ctdl_get_subprop(icalcomponent *, icalproperty_kind);
+int ical_ctdl_is_overlap(struct icaltimetype, struct icaltimetype, struct icaltimetype, struct icaltimetype);
+int ical_conflicts_phase6(struct icaltimetype, struct icaltimetype, struct icaltimetype, struct icaltimetype, long, char *, char *, char *);
+void ical_conflicts_phase5(struct icaltimetype, struct icaltimetype, icalcomponent *, long, char *);
+void ical_conflicts_phase4(icalcomponent *, icalcomponent *, long);
+void ical_hunt_for_conflicts_backend(long, void *);
+void ical_hunt_for_conflicts(icalcomponent *);
+void ical_conflicts(long, char *);
+void ical_add_to_freebusy(icalcomponent *, icalcomponent *);
+void ical_freebusy_backend(long, void *);
+void ical_freebusy(char *);
+void ical_getics_backend(long, void *);
 void ical_getics(void);
-void ical_putics_grabtzids(icalparameter *param, void *data);
+void ical_putics_grabtzids(icalparameter *, void *);
 void ical_putics(void);
 void ical_CtdlCreateRoom(void);
-void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal);
-void ical_saving_vevent(icalcomponent *top_level_cal, icalcomponent *cal);
-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);
-int ical_obj_beforesave(struct CtdlMessage *msg, struct recptypes *recp);
-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);
-int ical_obj_aftersave(struct CtdlMessage *msg, struct recptypes *recp);
+void ical_send_out_invitations(icalcomponent *, icalcomponent *);
+void ical_saving_vevent(icalcomponent *, icalcomponent *);
+void ical_obj_beforesave_backend(char *, char *, char *, char *, void *, char *, char *, size_t, char *, char *, void *);
+int ical_obj_beforesave(struct CtdlMessage *, struct recptypes *);
+void ical_obj_aftersave_backend(char *, char *, char *, char *, void *, char *, char *, size_t, char *, char *, void *);
+int ical_obj_aftersave(struct CtdlMessage *, struct recptypes *);
 void ical_session_startup(void);
 void ical_session_shutdown(void);
-void ical_fixed_output_backend(icalcomponent *cal, int recursion_level);
-void ical_fixed_output(char *ptr, int len);
-void cmd_ical(char *argbuf);
+void ical_fixed_output_backend(icalcomponent *, int);
+void ical_fixed_output(char *, int);
+void cmd_ical(char *);
 char *ctdl_module_init_calendar(void);
index d253b777b602ce03d12c8514c61b3ee829c70265..de35081a8de8df3310db77ab3a6f68aa3a0d16ff 100644 (file)
@@ -234,11 +234,23 @@ void caldav_report(struct http_transaction *h, struct ctdlsession *c) {
 
        // RFC4791 7.8 "calendar-query" REPORT - Client will send a lot of search criteria.
        if (crp.report_type == cr_calendar_query) {
-               // FIXME build this REPORT.  At the moment we send an empty multistatus.
+               int i = 0;
+               Array *msglist = get_msglist(c, "ALL");
+               if (msglist != NULL) {
+                       for (i = 0; i < array_len(msglist); ++i) {
+                               long m;
+                               memcpy(&m, array_get_element_at(msglist, i), sizeof(long));
+                               TRACE;
+                               syslog(LOG_DEBUG, "evaluating message %ld", m);
+                       }
+                       array_free(msglist);
+               }
        }
 
        // RFC4791 7.9 "calendar-multiget" REPORT - go get the specific Hrefs the client asked for.
+       // Can we move this back into citserver too?
        else if ( (crp.report_type == cr_calendar_multiget) && (crp.Hrefs != NULL) ) {
+
                StrBuf *ThisHref = NewStrBuf();
                const char *pvset = NULL;
                while (StrBufExtract_NextToken(ThisHref, crp.Hrefs, &pvset, '|') >= 0) {