// Client is requesting a message list
-void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *range) {
+void calendar_msglist(struct http_transaction *h, struct ctdlsession *c, char *range) {
+ // 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;
+ }
+
+ 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
+
+ }
+ array_free(msglist);
+
+ // FIXME we still fail because we aren't finished yet
do_404(h);
}