3 // Copyright (c) 1996-2023 by the citadel.org team
5 // This program is open source software. Use, duplication, or
6 // disclosure is subject to the GNU General Public License v3.
11 // Client is requesting a message list
12 void calendar_msglist(struct http_transaction *h, struct ctdlsession *c, char *range) {
15 // Determine the date/time range requested by the client
16 time_t lo = atol(range);
17 char *colon = strchr(range, ':');
18 time_t hi = colon ? atol(++colon) : LONG_MAX;
20 // Rule out impossible ranges
26 // Begin by requesting all messages in the room
28 Array *msglist = get_msglist(c, "ALL");
29 if (msglist == NULL) {
34 // We're going to make a lot of MSG4 calls, and the preferred MIME type we want is "text/calendar".
35 // The iCalendar standard is mature now, and we are no longer interested in text/x-vcal or application/ics.
36 ctdl_printf(c, "MSGP text/calendar");
37 ctdl_readline(c, buf, sizeof buf);
39 // Iterate through our message list.
40 for (i = 0; i < array_len(msglist); ++i) {
42 memcpy(&m, array_get_element_at(msglist, i), sizeof(long));
43 syslog(LOG_DEBUG, "FIXME %ld", m);
46 // 1. fetch the message from citadel server
48 // 3. figure out range
49 // we should steal code from webcit-classic for this
52 one_item = fetch_ical(c, m);
53 syslog(LOG_DEBUG, "calendar item:\n---\n\033[33m%s\n---\033[0m", ChrPtr(one_item));
54 FreeStrBuf(&one_item);
59 // FIXME we still fail because we aren't finished yet
60 add_response_header(h, strdup("Content-type"), strdup("application/json"));
61 h->response_code = 200;
62 h->response_string = strdup("OK");
63 h->response_body = "{ \"one\":111 , \"two\":222 , \"three\":333 }";
64 h->response_body_length = strlen(h->response_body);