From fb66defc37a3985fdec47c996e8108e070b94ccf Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 27 Dec 2023 18:45:03 -0500 Subject: [PATCH] Starting to bring over calendar server code from webcit-classic. --- webcit-ng/Makefile | 2 +- webcit-ng/server/caldav_reports.c | 2 +- webcit-ng/server/calendar_functions.c | 12 ++++++++++++ webcit-ng/server/webcit.h | 1 + webcit/calendar.c | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/webcit-ng/Makefile b/webcit-ng/Makefile index c29a595c8..291a9a888 100644 --- a/webcit-ng/Makefile +++ b/webcit-ng/Makefile @@ -14,7 +14,7 @@ SOURCES := $(wildcard $(SRC)/*.c) OBJECTS := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SOURCES)) webcit: $(OBJECTS) - gcc $(CFLAGS) $(OBJECTS) $(LDFLAGS) -lcitadel -lpthread -lcrypto -lssl -lexpat -o webcit + gcc $(CFLAGS) $(OBJECTS) $(LDFLAGS) -lcitadel -lpthread -lcrypto -lssl -lexpat -lical -o webcit $(SRC)/%.c: $(HEADERS) touch $@ diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index d30894968..7fe12ff3a 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -101,7 +101,7 @@ void caldav_xml_chardata(void *data, const XML_Char * s, int len) { // // NOTE: this function expects that "MSGP text/calendar" was issued at the beginning // of a REPORT operation to set our preferred MIME type to calendar data. -StrBuf *fetch_ical(struct ctdlsession * c, long msgnum) { +StrBuf *fetch_ical(struct ctdlsession *c, long msgnum) { char buf[1024]; StrBuf *Buf = NULL; diff --git a/webcit-ng/server/calendar_functions.c b/webcit-ng/server/calendar_functions.c index fe179cb00..d127b63de 100644 --- a/webcit-ng/server/calendar_functions.c +++ b/webcit-ng/server/calendar_functions.c @@ -10,6 +10,7 @@ // Client is requesting a message list void calendar_msglist(struct http_transaction *h, struct ctdlsession *c, char *range) { + char buf[SIZ]; // Determine the date/time range requested by the client time_t lo = atol(range); @@ -30,6 +31,12 @@ void calendar_msglist(struct http_transaction *h, struct ctdlsession *c, char *r return; } + // We're going to make a lot of MSG4 calls, and the preferred MIME type we want is "text/calendar". + // The iCalendar standard is mature now, and we are no longer interested in text/x-vcal or application/ics. + ctdl_printf(c, "MSGP text/calendar"); + ctdl_readline(c, buf, sizeof buf); + + // Iterate through our message list. for (i = 0; i < array_len(msglist); ++i) { long m; memcpy(&m, array_get_element_at(msglist, i), sizeof(long)); @@ -41,6 +48,11 @@ void calendar_msglist(struct http_transaction *h, struct ctdlsession *c, char *r // 3. figure out range // we should steal code from webcit-classic for this + StrBuf *one_item; + one_item = fetch_ical(c, m); + syslog(LOG_DEBUG, "calendar item:\n---\n\033[33m%s\n---\033[0m", ChrPtr(one_item)); + FreeStrBuf(&one_item); + } array_free(msglist); diff --git a/webcit-ng/server/webcit.h b/webcit-ng/server/webcit.h index b678ceffc..1a187fef8 100644 --- a/webcit-ng/server/webcit.h +++ b/webcit-ng/server/webcit.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #define OPENSSL_NO_KRB5 // Work around RedHat's b0rken OpenSSL includes #include diff --git a/webcit/calendar.c b/webcit/calendar.c index f0f34ef84..ce49b3455 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -668,7 +668,7 @@ void load_ical_object(long msgnum, int unread, || (!strcasecmp(mime_content_type, "application/ics")) || (!strcasecmp(mime_content_type, "text/vtodo")) || (!strcasecmp(mime_content_type, "text/todo")) - ) { + ) { strcpy(relevant_partnum, mime_partnum); } } -- 2.30.2