3 // Copyright (c) 1996-2023 by the citadel.org team
5 // This program is open source software. Use, duplication, or
6 // disclosure are subject to the GNU General Public License v3.
11 // Return an array of message numbers in the current room.
12 // Caller owns the memory and must free it. Returns NULL if any problems.
13 Array *get_msglist(struct ctdlsession *c, char *which_msgs) {
15 Array *msglist = NULL;
17 msglist = array_new(sizeof(long));
18 if (msglist == NULL) {
22 ctdl_printf(c, "MSGS %s", which_msgs);
23 ctdl_readline(c, buf, sizeof(buf));
25 while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
27 array_append(msglist, &m);
35 // Supplied with a list of potential matches from an If-Match: or If-None-Match: header, and
36 // a message number (which we always use as the entity tag in Citadel), return nonzero if the
37 // message number matches any of the supplied tags in the string.
38 int match_etags(char *taglist, long msgnum) {
39 int num_tags = num_tokens(taglist, ',');
43 if (msgnum <= 0) { // no msgnum? no match.
47 for (i = 0; i < num_tags; ++i) {
48 extract_token(tag, taglist, i, ',', sizeof tag);
50 char *lq = (strchr(tag, '"'));
51 char *rq = (strrchr(tag, '"'));
52 if (lq < rq) { // has two double quotes
57 if (!strcmp(tag, "*")) { // wildcard match
60 long tagmsgnum = atol(tag);
61 if ((tagmsgnum > 0) && (tagmsgnum == msgnum)) { // match
66 return (0); // no match
70 // Client is requesting a STAT (name and modification time) of the current room
71 void json_stat(struct http_transaction *h, struct ctdlsession *c) {
75 ctdl_printf(c, "STAT");
76 ctdl_readline(c, buf, sizeof(buf));
78 JsonValue *j = NewJsonObject(HKEY("stat"));
79 extract_token(field, &buf[4], 0, '|', sizeof field);
80 JsonObjectAppend(j, NewJsonPlainString(HKEY("name"), field, -1));
81 JsonObjectAppend(j, NewJsonNumber(HKEY("room_mtime"), extract_long(&buf[4], 1)));
83 StrBuf *sj = NewStrBuf();
84 SerializeJson(sj, j, 1); // '1' == free the source array
85 add_response_header(h, strdup("Content-type"), strdup("application/json"));
86 h->response_code = 200;
87 h->response_string = strdup("OK");
88 h->response_body_length = StrLength(sj);
89 h->response_body = SmashStrBuf(&sj);
98 // Client is requesting a mailbox summary of the current room
99 void json_mailbox(struct http_transaction *h, struct ctdlsession *c) {
102 JsonValue *j = NewJsonArray(HKEY("msgs"));
104 ctdl_printf(c, "MSGS ALL|||9"); // "9" as the fourth parameter delivers a mailbox summary
105 ctdl_readline(c, buf, sizeof(buf));
107 while (ctdl_readline(c, buf, sizeof(buf)), (strcmp(buf, "000"))) {
108 JsonValue *jmsg = NewJsonObject(HKEY("message"));
109 JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgnum"), extract_long(buf, 0)));
110 JsonObjectAppend(jmsg, NewJsonNumber(HKEY("time"), extract_long(buf, 1)));
111 extract_token(field, buf, 2, '|', sizeof field);
112 utf8ify_rfc822_string(field);
113 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("author"), field, -1));
114 extract_token(field, buf, 4, '|', sizeof field);
115 utf8ify_rfc822_string(field);
116 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("addr"), field, -1));
117 extract_token(field, buf, 5, '|', sizeof field);
118 utf8ify_rfc822_string(field);
119 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("subject"), field, -1));
120 JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgidhash"), extract_long(buf, 6)));
121 extract_token(field, buf, 7, '|', sizeof field);
122 utf8ify_rfc822_string(field);
123 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("references"), field, -1));
124 JsonArrayAppend(j, jmsg); // add the message to the array
128 StrBuf *sj = NewStrBuf();
129 SerializeJson(sj, j, 1); // '1' == free the source array
131 add_response_header(h, strdup("Content-type"), strdup("application/json"));
132 h->response_code = 200;
133 h->response_string = strdup("OK");
134 h->response_body_length = StrLength(sj);
135 h->response_body = SmashStrBuf(&sj);
140 // Client is requesting a message list
141 void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which) {
143 Array *msglist = get_msglist(c, which);
144 JsonValue *j = NewJsonArray(HKEY("msgs"));
146 if (msglist != NULL) {
147 for (i = 0; i < array_len(msglist); ++i) {
149 memcpy(&m, array_get_element_at(msglist, i), sizeof(long));
150 JsonArrayAppend(j, NewJsonNumber(HKEY("m"), m));
155 StrBuf *sj = NewStrBuf();
156 SerializeJson(sj, j, 1); // '1' == free the source array
158 add_response_header(h, strdup("Content-type"), strdup("application/json"));
159 h->response_code = 200;
160 h->response_string = strdup("OK");
161 h->response_body_length = StrLength(sj);
162 h->response_body = SmashStrBuf(&sj);
167 // Client is requesting the room info banner
168 void read_room_info_banner(struct http_transaction *h, struct ctdlsession *c) {
171 ctdl_printf(c, "RINF");
172 ctdl_readline(c, buf, sizeof(buf));
174 StrBuf *info = NewStrBuf();
175 while (ctdl_readline(c, buf, sizeof(buf)), (strcmp(buf, "000"))){
176 StrBufAppendPrintf(info, "%s\n", buf);
178 add_response_header(h, strdup("Content-type"), strdup("text/plain"));
179 h->response_code = 200;
180 h->response_string = strdup("OK");
181 h->response_body_length = StrLength(info);
182 h->response_body = SmashStrBuf(&info);
191 // Client is setting the "Last Read Pointer" (marking all messages as "seen" up to this message)
192 void set_last_read_pointer(struct http_transaction *h, struct ctdlsession *c) {
194 ctdl_printf(c, "SLRP %d", atoi(get_url_param(h, "last")));
195 ctdl_readline(c, cbuf, sizeof(cbuf));
196 if (cbuf[0] == '2') {
205 // Client requested an object in a room.
206 void object_in_room(struct http_transaction *h, struct ctdlsession *c) {
209 char unescaped_euid[1024];
211 extract_token(buf, h->url, 4, '/', sizeof buf);
213 if (!strcasecmp(buf, "mailbox")) { // Client is requesting a mailbox summary
218 if (!strcasecmp(buf, "stat")) { // Client is requesting a stat command (name and modification time)
223 if (!strncasecmp(buf, "msgs.", 5)) { // Client is requesting a list of message numbers
224 unescape_input(&buf[5]);
225 json_msglist(h, c, &buf[5]);
229 if (!strncasecmp(buf, "calendar:", 9)) { // Client is requesting a calendar range
230 unescape_input(&buf[9]);
231 calendar_msglist(h, c, &buf[9]);
235 if (!strcasecmp(buf, "info.txt")) { // Client is requesting the room info banner
236 read_room_info_banner(h, c);
240 if (!strcasecmp(buf, "slrp")) { // Set the Last Read Pointer
241 set_last_read_pointer(h, c);
245 // If we get to this point, the client is requesting a specific object *in* the room.
247 if ((c->room_default_view == VIEW_CALENDAR) // room types where objects are referenced by EUID
248 || (c->room_default_view == VIEW_TASKS)
249 || (c->room_default_view == VIEW_ADDRESSBOOK)
251 safestrncpy(unescaped_euid, buf, sizeof unescaped_euid);
252 unescape_input(unescaped_euid);
253 msgnum = locate_message_by_uid(c, unescaped_euid);
255 else { // otherwise the object is being referenced by message number
259 // All methods except PUT require the message to already exist
260 if ((msgnum <= 0) && (strcasecmp(h->method, "PUT"))) {
264 // If we get to this point we have a valid message number in an accessible room.
265 syslog(LOG_DEBUG, "msgnum is %ld, method is %s", msgnum, h->method);
267 // A sixth component in the URL can be one of two things:
268 // (1) a MIME part specifier, in which case the client wants to download that component within the message
269 // (2) a content-type, in which ase the client wants us to try to render it a certain way
270 if (num_tokens(h->url, '/') >= 6) {
271 extract_token(buf, h->url, 5, '/', sizeof buf);
272 if (!IsEmptyStr(buf)) {
273 if (!strcasecmp(buf, "json")) {
274 json_render_one_message(h, c, msgnum);
277 download_mime_component(h, c, msgnum, buf);
283 // Ok, we want a full message, but first let's check for the if[-none]-match headers.
284 char *if_match = header_val(h, "If-Match");
285 if ((if_match != NULL) && (!match_etags(if_match, msgnum))) {
290 char *if_none_match = header_val(h, "If-None-Match");
291 if ((if_none_match != NULL) && (match_etags(if_none_match, msgnum))) {
296 // Now perform the requested operation.
297 if (!strcasecmp(h->method, "DELETE")) {
298 dav_delete_message(h, c, msgnum);
300 else if (!strcasecmp(h->method, "GET")) {
301 dav_get_message(h, c, msgnum);
303 else if (!strcasecmp(h->method, "PUT")) {
304 dav_put_message(h, c, unescaped_euid, msgnum);
306 else if (!strcasecmp(h->method, "MOVE")) {
307 dav_move_or_copy_message(h, c, msgnum, DAV_MOVE);
309 else if (!strcasecmp(h->method, "COPY")) {
310 dav_move_or_copy_message(h, c, msgnum, DAV_COPY);
313 do_404(h); // We should never get here, but if we do, a 404 error is clean.
318 // Called by the_room_itself() when the HTTP method is REPORT
319 void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
320 if (c->room_default_view == VIEW_CALENDAR) {
321 caldav_report(h, c); // CalDAV REPORTs ... fmgwac
325 do_404(h); // future implementations like CardDAV will require code paths here
329 // Called by the_room_itself() when the HTTP method is OPTIONS
330 void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
331 h->response_code = 200;
332 h->response_string = strdup("OK");
333 if (c->room_default_view == VIEW_CALENDAR) {
334 add_response_header(h, strdup("DAV"), strdup("1, calendar-access")); // offer CalDAV
336 else if (c->room_default_view == VIEW_ADDRESSBOOK) {
337 add_response_header(h, strdup("DAV"), strdup("1, addressbook")); // offer CardDAV
340 add_response_header(h, strdup("DAV"), strdup("1")); // ordinary WebDAV for all other room types
342 add_response_header(h, strdup("Allow"), strdup("OPTIONS, PROPFIND, GET, PUT, REPORT, DELETE, MOVE, COPY"));
346 // Called by the_room_itself() when the HTTP method is PROPFIND
347 void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
350 int dav_depth = (header_val(h, "Depth") ? atoi(header_val(h, "Depth")) : INT_MAX);
351 syslog(LOG_DEBUG, "Client PROPFIND requested depth: %d", dav_depth);
352 StrBuf *Buf = NewStrBuf();
354 StrBufAppendPrintf(Buf,
355 "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
358 "xmlns:C=\"urn:ietf:params:xml:ns:caldav\""
362 // Transmit the collection resource
363 StrBufAppendPrintf(Buf, "<D:response>");
364 StrBufAppendPrintf(Buf, "<D:href>");
365 StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0);
366 StrBufAppendPrintf(Buf, "/ctdl/r/");
367 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
368 StrBufAppendPrintf(Buf, "</D:href>");
370 StrBufAppendPrintf(Buf, "<D:propstat>");
371 StrBufAppendPrintf(Buf, "<D:status>HTTP/1.1 200 OK</D:status>");
372 StrBufAppendPrintf(Buf, "<D:prop>");
373 StrBufAppendPrintf(Buf, "<D:displayname>");
374 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
375 StrBufAppendPrintf(Buf, "</D:displayname>");
377 StrBufAppendPrintf(Buf, "<D:owner />"); // empty owner ought to be legal; see rfc3744 section 5.1
379 StrBufAppendPrintf(Buf, "<D:resourcetype><D:collection />");
380 switch (c->room_default_view) {
382 StrBufAppendPrintf(Buf, "<C:calendar />"); // RFC4791 section 4.2
385 StrBufAppendPrintf(Buf, "</D:resourcetype>");
387 int enumerate_by_euid = 0; // nonzero if messages will be retrieved by euid instead of msgnum
388 switch (c->room_default_view) {
389 case VIEW_CALENDAR: // RFC4791 section 5.2
390 StrBufAppendPrintf(Buf, "<C:supported-calendar-component-set><C:comp name=\"VEVENT\"/></C:supported-calendar-component-set>");
391 StrBufAppendPrintf(Buf, "<C:supported-calendar-data>");
392 StrBufAppendPrintf(Buf, "<C:calendar-data content-type=\"text/calendar\" version=\"2.0\"/>");
393 StrBufAppendPrintf(Buf, "</C:supported-calendar-data>");
394 enumerate_by_euid = 1;
396 case VIEW_TASKS: // RFC4791 section 5.2
397 StrBufAppendPrintf(Buf, "<C:supported-calendar-component-set><C:comp name=\"VTODO\"/></C:supported-calendar-component-set>");
398 StrBufAppendPrintf(Buf, "<C:supported-calendar-data>");
399 StrBufAppendPrintf(Buf, "<C:calendar-data content-type=\"text/calendar\" version=\"2.0\"/>");
400 StrBufAppendPrintf(Buf, "</C:supported-calendar-data>");
401 enumerate_by_euid = 1;
403 case VIEW_ADDRESSBOOK: // FIXME put some sort of CardDAV crapola here when we implement it
404 enumerate_by_euid = 1;
406 case VIEW_WIKI: // FIXME invent "WikiDAV" ? The versioning stuff in DAV could be useful.
407 enumerate_by_euid = 1;
411 // FIXME get the mtime
412 // StrBufAppendPrintf(Buf, "<D:getlastmodified>");
413 // escputs(datestring);
414 // StrBufAppendPrintf(Buf, "</D:getlastmodified>");
416 StrBufAppendPrintf(Buf, "</D:prop>");
417 StrBufAppendPrintf(Buf, "</D:propstat>");
418 StrBufAppendPrintf(Buf, "</D:response>\n");
420 // If a depth greater than zero was specified, transmit the collection listing
423 Array *msglist = get_msglist(c, "ALL");
426 for (i = 0; i < array_len(msglist); ++i) {
428 syslog(LOG_DEBUG, "PROPFIND enumerated %d messages", i);
430 e = NULL; // EUID gets stored here
434 memcpy(&m, array_get_element_at(msglist, i), sizeof(long));
437 ctdl_printf(c, "MSG0 %ld|3", m);
438 ctdl_readline(c, cbuf, sizeof(cbuf));
440 while (ctdl_readline(c, cbuf, sizeof(cbuf)), strcmp(cbuf, "000")) {
441 if ((enumerate_by_euid) && (!strncasecmp(cbuf, "exti=", 5))) {
442 // e = strdup(&cbuf[5]);
443 int elen = (2 * strlen(&cbuf[5]));
445 urlesc(e, elen, &cbuf[5]);
447 if (!strncasecmp(cbuf, "time=", 5)) {
448 timestamp = atol(&cbuf[5]);
453 sprintf(e, "%ld", m);
455 StrBufAppendPrintf(Buf, "<D:response>");
457 // Generate the 'href' tag for this message
458 StrBufAppendPrintf(Buf, "<D:href>");
459 StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0);
460 StrBufAppendPrintf(Buf, "/ctdl/r/");
461 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
462 StrBufAppendPrintf(Buf, "/");
463 StrBufXMLEscAppend(Buf, NULL, e, strlen(e), 0);
464 StrBufAppendPrintf(Buf, "</D:href>");
465 StrBufAppendPrintf(Buf, "<D:propstat>");
466 StrBufAppendPrintf(Buf, "<D:status>HTTP/1.1 200 OK</D:status>");
467 StrBufAppendPrintf(Buf, "<D:prop>");
469 switch (c->room_default_view) {
471 StrBufAppendPrintf(Buf,
472 "<D:getcontenttype>text/calendar; component=vevent</D:getcontenttype>");
475 StrBufAppendPrintf(Buf,
476 "<D:getcontenttype>text/calendar; component=vtodo</D:getcontenttype>");
478 case VIEW_ADDRESSBOOK:
479 StrBufAppendPrintf(Buf, "<D:getcontenttype>text/x-vcard</D:getcontenttype>");
484 char *datestring = http_datestring(timestamp);
486 StrBufAppendPrintf(Buf, "<D:getlastmodified>");
487 StrBufXMLEscAppend(Buf, NULL, datestring, strlen(datestring), 0);
488 StrBufAppendPrintf(Buf, "</D:getlastmodified>");
491 if (enumerate_by_euid) { // FIXME ajc 2017oct30 should this be inside the timestamp conditional?
492 StrBufAppendPrintf(Buf, "<D:getetag>\"%ld\"</D:getetag>", m);
495 StrBufAppendPrintf(Buf, "</D:prop></D:propstat></D:response>\n");
503 StrBufAppendPrintf(Buf, "</D:multistatus>\n");
505 add_response_header(h, strdup("Content-type"), strdup("text/xml"));
506 h->response_code = 207;
507 h->response_string = strdup("Multi-Status");
508 h->response_body_length = StrLength(Buf);
509 h->response_body = SmashStrBuf(&Buf);
512 // some good examples here
513 // http://blogs.nologin.es/rickyepoderi/index.php?/archives/14-Introducing-CalDAV-Part-I.html
516 // Called by the_room_itself() when the HTTP method is PROPFIND
517 void get_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
518 JsonValue *j = NewJsonObject(HKEY("gotoroom"));
520 JsonObjectAppend(j, NewJsonPlainString(HKEY("name"), c->room, -1));
521 JsonObjectAppend(j, NewJsonNumber(HKEY("current_view"), c->room_current_view));
522 JsonObjectAppend(j, NewJsonNumber(HKEY("default_view"), c->room_default_view));
523 JsonObjectAppend(j, NewJsonNumber(HKEY("is_room_aide"), c->is_room_aide));
524 JsonObjectAppend(j, NewJsonNumber(HKEY("is_trash_folder"), c->is_trash_folder));
525 JsonObjectAppend(j, NewJsonNumber(HKEY("can_delete_messages"), c->can_delete_messages));
526 JsonObjectAppend(j, NewJsonNumber(HKEY("new_messages"), c->new_messages));
527 JsonObjectAppend(j, NewJsonNumber(HKEY("total_messages"), c->total_messages));
528 JsonObjectAppend(j, NewJsonNumber(HKEY("last_seen"), c->last_seen));
529 JsonObjectAppend(j, NewJsonNumber(HKEY("room_mtime"), c->room_mtime));
531 StrBuf *sj = NewStrBuf();
532 SerializeJson(sj, j, 1); // '1' == free the source array
534 add_response_header(h, strdup("Content-type"), strdup("application/json"));
535 h->response_code = 200;
536 h->response_string = strdup("OK");
537 h->response_body_length = StrLength(sj);
538 h->response_body = SmashStrBuf(&sj);
543 // Handle REST/DAV requests for the room itself (such as /ctdl/r/roomname
544 // or /ctdl/r/roomname/ but *not* specific objects within the room)
545 void the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
547 // OPTIONS method on the room itself usually is a DAV client assessing what's here.
548 if (!strcasecmp(h->method, "OPTIONS")) {
549 options_the_room_itself(h, c);
553 // PROPFIND method on the room itself could be looking for a directory
554 if (!strcasecmp(h->method, "PROPFIND")) {
555 propfind_the_room_itself(h, c);
559 // REPORT method on the room itself is probably the dreaded CalDAV tower-of-crapola
560 if (!strcasecmp(h->method, "REPORT")) {
561 report_the_room_itself(h, c);
565 // GET method on the room itself is an API call, possibly from our JavaScript front end
566 if (!strcasecmp(h->method, "get")) {
567 get_the_room_itself(h, c);
571 // we probably want a "go to this room" for interactive access
576 // Dispatcher for "/ctdl/r" and "/ctdl/r/" for the room list
577 void room_list(struct http_transaction *h, struct ctdlsession *c) {
581 ctdl_printf(c, "LKRA");
582 ctdl_readline(c, buf, sizeof(buf));
588 JsonValue *j = NewJsonArray(HKEY("lkra"));
589 while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
591 // 0 |1 |2 |3 |4 |5 |6 |7 |8
592 // name|QRflags|QRfloor|QRorder|QRflags2|ra|current_view|default_view|mtime
593 JsonValue *jr = NewJsonObject(HKEY("room"));
595 extract_token(roomname, buf, 0, '|', sizeof roomname);
596 JsonObjectAppend(jr, NewJsonPlainString(HKEY("name"), roomname, -1));
598 JsonObjectAppend(jr, NewJsonNumber(HKEY("floor"), extract_int(buf, 2)));
599 JsonObjectAppend(jr, NewJsonNumber(HKEY("rorder"), extract_int(buf, 3)));
601 int ra = extract_int(buf, 5);
602 JsonObjectAppend(jr, NewJsonBool(HKEY("known"), (ra & UA_KNOWN)));
603 JsonObjectAppend(jr, NewJsonBool(HKEY("hasnewmsgs"), (ra & UA_HASNEWMSGS)));
605 JsonObjectAppend(jr, NewJsonNumber(HKEY("current_view"), extract_int(buf, 6)));
606 JsonObjectAppend(jr, NewJsonNumber(HKEY("default_view"), extract_int(buf, 7)));
607 JsonObjectAppend(jr, NewJsonNumber(HKEY("mtime"), extract_int(buf, 8)));
609 JsonArrayAppend(j, jr); // add the room to the array
612 StrBuf *sj = NewStrBuf();
613 SerializeJson(sj, j, 1); // '1' == free the source array
615 add_response_header(h, strdup("Content-type"), strdup("application/json"));
616 h->response_code = 200;
617 h->response_string = strdup("OK");
618 h->response_body_length = StrLength(sj);
619 h->response_body = SmashStrBuf(&sj);
623 // Dispatcher for paths starting with /ctdl/r/
624 void ctdl_r(struct http_transaction *h, struct ctdlsession *c) {
625 char requested_roomname[128];
628 long room_flags2 = 0;
630 // All room-related functions require being "in" the room specified. Are we in that room already?
631 extract_token(requested_roomname, h->url, 3, '/', sizeof requested_roomname);
632 unescape_input(requested_roomname);
634 if (IsEmptyStr(requested_roomname)) { // /ctdl/r/
638 // If not, try to go there.
639 if (strcasecmp(requested_roomname, c->room)) {
640 ctdl_printf(c, "GOTO %s", requested_roomname);
641 ctdl_readline(c, buf, sizeof(buf));
643 // buf[3] will indicate whether any instant messages are waiting
644 extract_token(c->room, &buf[4], 0, '|', sizeof c->room);
645 c->new_messages = extract_int(&buf[4], 1);
646 c->total_messages = extract_int(&buf[4], 2);
647 // 3 (int)info Info flag: set to nonzero if the user needs to read this room's info file
648 room_flags = extract_long(&buf[4], 3); // Various flags associated with this room.
649 // 5 (long)CC->room.QRhighest The highest message number present in this room
650 c->last_seen = extract_long(&buf[4], 6); // The highest message number the user has read in this room
651 // 7 (int)rmailflag Boolean flag: 1 if this is a Mail> room, 0 otherwise.
652 c->is_room_aide = extract_int(&buf[4], 8);
653 // 9 This position is no longer used
654 // 10 (int)CC->room.QRfloor The floor number this room resides on
655 c->room_current_view = extract_int(&buf[4], 11);
656 c->room_default_view = extract_int(&buf[4], 12);
657 c->is_trash_folder = extract_int(&buf[4], 13); // Boolean flag: 1 if this is the user's Trash folder, 0 otherwise.
658 room_flags2 = extract_long(&buf[4], 14); // More flags associated with this room.
659 c->room_mtime = extract_long(&buf[4], 15); // Timestamp of the last write activity in this room
661 // If any of these three conditions are met, let the client know it has permission to delete messages.
662 if ((c->is_room_aide) || (room_flags & QR_MAILBOX) || (room_flags2 & QR2_COLLABDEL)) {
663 c->can_delete_messages = 1;
666 c->can_delete_messages = 0;
674 // At this point our Citadel client session is "in" the specified room.
676 if (num_tokens(h->url, '/') == 4) { // /ctdl/r/roomname
677 the_room_itself(h, c);
681 extract_token(buf, h->url, 4, '/', sizeof buf);
682 if (num_tokens(h->url, '/') == 5) {
683 if (IsEmptyStr(buf)) {
684 the_room_itself(h, c); // /ctdl/r/roomname/ ( same as /ctdl/r/roomname )
687 object_in_room(h, c); // /ctdl/r/roomname/object
691 if (num_tokens(h->url, '/') >= 6) {
692 object_in_room(h, c); // /ctdl/r/roomname/object/ or possibly /ctdl/r/roomname/object/component
695 // If we get to this point, the client specified a valid room but requested an action we don't know how to perform.