-
-
-
-
-
-// Client is requesting a message list (make this code work for calendar-query REPORT)
-void XXXXXXXXXXXXXX(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);
- char *colon = strchr(range, ':');
- time_t hi = colon ? atol(++colon) : LONG_MAX;
-
- // Rule out impossible ranges
- if (hi < lo) {
- do_404(h);
- return;
- }
-
- // Begin by requesting all messages in the room
- int i = 0;
- Array *msglist = get_msglist(c, "ALL");
- if (msglist == NULL) {
- do_404(h);
- 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));
- syslog(LOG_DEBUG, "FIXME %ld", m);
-
- // now we have to:
- // 1. fetch the message from citadel server
- // 2. parse the ical
- // 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);
-
- // FIXME we still fail because we aren't finished yet
- add_response_header(h, strdup("Content-type"), strdup("application/json"));
- h->response_code = 200;
- h->response_string = strdup("OK");
- h->response_body = "{ \"one\":111 , \"two\":222 , \"three\":333 }";
- h->response_body_length = strlen(h->response_body);
-}