3 // Copyright (c) 1996-2024 by the citadel.org team
5 // This program is open source software. Use, duplication, or disclosure is subject to the GNU General Public License v3.
10 // Return an array of message numbers in the current room.
11 // Caller owns the memory and must free it. Returns NULL if any problems.
12 Array *get_msglist(struct ctdlsession *c, char *which_msgs) {
14 Array *msglist = NULL;
16 msglist = array_new(sizeof(long));
17 if (msglist == NULL) {
21 ctdl_printf(c, "MSGS %s", which_msgs);
22 ctdl_readline(c, buf, sizeof(buf));
24 while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
26 array_append(msglist, &m);
34 // Supplied with a list of potential matches from an If-Match: or If-None-Match: header, and
35 // a message number (which we always use as the entity tag in Citadel), return nonzero if the
36 // message number matches any of the supplied tags in the string.
37 int match_etags(char *taglist, long msgnum) {
38 int num_tags = num_tokens(taglist, ',');
42 if (msgnum <= 0) { // no msgnum? no match.
46 for (i = 0; i < num_tags; ++i) {
47 extract_token(tag, taglist, i, ',', sizeof tag);
49 char *lq = (strchr(tag, '"'));
50 char *rq = (strrchr(tag, '"'));
51 if (lq < rq) { // has two double quotes
56 if (!strcmp(tag, "*")) { // wildcard match
59 long tagmsgnum = atol(tag);
60 if ((tagmsgnum > 0) && (tagmsgnum == msgnum)) { // match
65 return (0); // no match
69 // Client is requesting a STAT (name and modification time) of the current room
70 void json_stat(struct http_transaction *h, struct ctdlsession *c) {
74 ctdl_printf(c, "STAT");
75 ctdl_readline(c, buf, sizeof(buf));
77 JsonValue *j = NewJsonObject(HKEY("stat"));
78 extract_token(field, &buf[4], 0, '|', sizeof field);
79 JsonObjectAppend(j, NewJsonPlainString(HKEY("name"), field, -1));
80 JsonObjectAppend(j, NewJsonNumber(HKEY("room_mtime"), extract_long(&buf[4], 1)));
82 StrBuf *sj = NewStrBuf();
83 SerializeJson(sj, j, 1); // '1' == free the source array
84 add_response_header(h, strdup("Content-type"), strdup("application/json"));
85 h->response_code = 200;
86 h->response_string = strdup("OK");
87 h->response_body_length = StrLength(sj);
88 h->response_body = SmashStrBuf(&sj);
97 // Client is requesting a mailbox summary of the current room
98 void json_mailbox(struct http_transaction *h, struct ctdlsession *c) {
101 JsonValue *j = NewJsonArray(HKEY("msgs"));
103 ctdl_printf(c, "MSGS ALL|||9"); // "9" as the fourth parameter delivers a mailbox summary
104 ctdl_readline(c, buf, sizeof(buf));
106 while (ctdl_readline(c, buf, sizeof(buf)), (strcmp(buf, "000"))) {
107 JsonValue *jmsg = NewJsonObject(HKEY("message"));
108 JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgnum"), extract_long(buf, 0)));
109 JsonObjectAppend(jmsg, NewJsonNumber(HKEY("time"), extract_long(buf, 1)));
110 extract_token(field, buf, 2, '|', sizeof field);
111 utf8ify_rfc822_string(field);
112 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("author"), field, -1));
113 extract_token(field, buf, 4, '|', sizeof field);
114 utf8ify_rfc822_string(field);
115 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("addr"), field, -1));
116 extract_token(field, buf, 5, '|', sizeof field);
117 utf8ify_rfc822_string(field);
118 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("subject"), field, -1));
119 JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgidhash"), extract_long(buf, 6)));
120 extract_token(field, buf, 7, '|', sizeof field);
121 utf8ify_rfc822_string(field);
122 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("references"), field, -1));
123 JsonArrayAppend(j, jmsg); // add the message to the array
127 StrBuf *sj = NewStrBuf();
128 SerializeJson(sj, j, 1); // '1' == free the source array
130 add_response_header(h, strdup("Content-type"), strdup("application/json"));
131 h->response_code = 200;
132 h->response_string = strdup("OK");
133 h->response_body_length = StrLength(sj);
134 h->response_body = SmashStrBuf(&sj);
139 // Client is requesting a message list
140 void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which) {
142 Array *msglist = get_msglist(c, which);
143 JsonValue *j = NewJsonArray(HKEY("msgs"));
145 if (msglist != NULL) {
146 for (i = 0; i < array_len(msglist); ++i) {
148 memcpy(&m, array_get_element_at(msglist, i), sizeof(long));
149 JsonArrayAppend(j, NewJsonNumber(HKEY("m"), m));
154 StrBuf *sj = NewStrBuf();
155 SerializeJson(sj, j, 1); // '1' == free the source array
157 add_response_header(h, strdup("Content-type"), strdup("application/json"));
158 h->response_code = 200;
159 h->response_string = strdup("OK");
160 h->response_body_length = StrLength(sj);
161 h->response_body = SmashStrBuf(&sj);
166 // Client is requesting the room info banner
167 void read_room_info_banner(struct http_transaction *h, struct ctdlsession *c) {
170 ctdl_printf(c, "RINF");
171 ctdl_readline(c, buf, sizeof(buf));
173 StrBuf *info = NewStrBuf();
174 while (ctdl_readline(c, buf, sizeof(buf)), (strcmp(buf, "000"))){
175 StrBufAppendPrintf(info, "%s\n", buf);
177 add_response_header(h, strdup("Content-type"), strdup("text/plain"));
178 h->response_code = 200;
179 h->response_string = strdup("OK");
180 h->response_body_length = StrLength(info);
181 h->response_body = SmashStrBuf(&info);
190 // Client is setting the "Last Read Pointer" (marking all messages as "seen" up to this message)
191 void set_last_read_pointer(struct http_transaction *h, struct ctdlsession *c) {
193 ctdl_printf(c, "SLRP %d", atoi(get_url_param(h, "last")));
194 ctdl_readline(c, cbuf, sizeof(cbuf));
195 if (cbuf[0] == '2') {
204 // Client requested an object in a room.
205 void object_in_room(struct http_transaction *h, struct ctdlsession *c) {
208 char unescaped_euid[1024];
210 extract_token(buf, h->url, 4, '/', sizeof buf);
212 if (!strcasecmp(buf, "mailbox")) { // Client is requesting a mailbox summary
217 if (!strcasecmp(buf, "stat")) { // Client is requesting a stat command (name and modification time)
222 if (!strncasecmp(buf, "msgs.", 5)) { // Client is requesting a list of message numbers
223 unescape_input(&buf[5]);
224 json_msglist(h, c, &buf[5]);
228 if (!strcasecmp(buf, "info.txt")) { // Client is requesting the room info banner
229 read_room_info_banner(h, c);
233 if (!strcasecmp(buf, "slrp")) { // Set the Last Read Pointer
234 set_last_read_pointer(h, c);
238 // If we get to this point, the client is requesting a specific object *in* the room.
240 if ((c->room_default_view == VIEW_CALENDAR) // room types where objects are referenced by EUID
241 || (c->room_default_view == VIEW_TASKS)
242 || (c->room_default_view == VIEW_ADDRESSBOOK)
244 safestrncpy(unescaped_euid, buf, sizeof unescaped_euid);
245 unescape_input(unescaped_euid);
246 msgnum = locate_message_by_uid(c, unescaped_euid);
248 else { // otherwise the object is being referenced by message number
252 // All methods except PUT require the message to already exist
253 if ((msgnum <= 0) && (strcasecmp(h->method, "PUT"))) {
257 // If we get to this point we have a valid message number in an accessible room.
258 syslog(LOG_DEBUG, "msgnum is %ld, method is %s", msgnum, h->method);
260 // A sixth component in the URL can be one of two things:
261 // (1) a MIME part specifier, in which case the client wants to download that component within the message
262 // (2) a content-type, in which ase the client wants us to try to render it a certain way
263 if (num_tokens(h->url, '/') >= 6) {
264 extract_token(buf, h->url, 5, '/', sizeof buf);
265 if (!IsEmptyStr(buf)) {
266 if (!strcasecmp(buf, "json")) {
267 json_render_one_message(h, c, msgnum);
270 download_mime_component(h, c, msgnum, buf);
276 // Ok, we want a full message, but first let's check for the if[-none]-match headers.
277 char *if_match = header_val(h, "If-Match");
278 if ((if_match != NULL) && (!match_etags(if_match, msgnum))) {
283 char *if_none_match = header_val(h, "If-None-Match");
284 if ((if_none_match != NULL) && (match_etags(if_none_match, msgnum))) {
289 // Now perform the requested operation.
290 if (!strcasecmp(h->method, "DELETE")) {
291 dav_delete_message(h, c, msgnum);
293 else if (!strcasecmp(h->method, "GET")) {
294 dav_get_message(h, c, msgnum);
296 else if (!strcasecmp(h->method, "PUT")) {
297 dav_put_message(h, c, unescaped_euid, msgnum);
299 else if (!strcasecmp(h->method, "MOVE")) {
300 dav_move_or_copy_message(h, c, msgnum, DAV_MOVE);
302 else if (!strcasecmp(h->method, "COPY")) {
303 dav_move_or_copy_message(h, c, msgnum, DAV_COPY);
306 do_404(h); // We should never get here, but if we do, a 404 error is clean.
311 // Called by the_room_itself() when the HTTP method is REPORT
312 void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
313 if (c->room_default_view == VIEW_CALENDAR) {
314 caldav_report(h, c); // CalDAV REPORTs ... fmgwac
318 do_404(h); // future implementations like CardDAV will require code paths here
322 // Called by the_room_itself() when the HTTP method is OPTIONS
323 void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
324 h->response_code = 200;
325 h->response_string = strdup("OK");
326 if (c->room_default_view == VIEW_CALENDAR) {
327 add_response_header(h, strdup("DAV"), strdup("1, calendar-access")); // offer CalDAV
329 else if (c->room_default_view == VIEW_ADDRESSBOOK) {
330 add_response_header(h, strdup("DAV"), strdup("1, addressbook")); // offer CardDAV
333 add_response_header(h, strdup("DAV"), strdup("1")); // ordinary WebDAV for all other room types
335 add_response_header(h, strdup("Allow"), strdup("OPTIONS, PROPFIND, GET, PUT, REPORT, DELETE, MOVE, COPY"));
339 // Called by the_room_itself() when the HTTP method is PROPFIND
340 void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
343 int dav_depth = (header_val(h, "Depth") ? atoi(header_val(h, "Depth")) : INT_MAX);
344 syslog(LOG_DEBUG, "Client PROPFIND requested depth: %d", dav_depth);
345 StrBuf *Buf = NewStrBuf();
347 StrBufAppendPrintf(Buf,
348 "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
351 "xmlns:C=\"urn:ietf:params:xml:ns:caldav\""
355 // Transmit the collection resource
356 StrBufAppendPrintf(Buf, "<D:response>");
357 StrBufAppendPrintf(Buf, "<D:href>");
358 StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0);
359 StrBufAppendPrintf(Buf, "/ctdl/r/");
360 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
361 StrBufAppendPrintf(Buf, "</D:href>");
363 StrBufAppendPrintf(Buf, "<D:propstat>");
364 StrBufAppendPrintf(Buf, "<D:status>HTTP/1.1 200 OK</D:status>");
365 StrBufAppendPrintf(Buf, "<D:prop>");
366 StrBufAppendPrintf(Buf, "<D:displayname>");
367 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
368 StrBufAppendPrintf(Buf, "</D:displayname>");
370 StrBufAppendPrintf(Buf, "<D:owner />"); // empty owner ought to be legal; see rfc3744 section 5.1
372 StrBufAppendPrintf(Buf, "<D:resourcetype><D:collection />");
373 switch (c->room_default_view) {
375 StrBufAppendPrintf(Buf, "<C:calendar />"); // RFC4791 section 4.2
378 StrBufAppendPrintf(Buf, "</D:resourcetype>");
380 int enumerate_by_euid = 0; // nonzero if messages will be retrieved by euid instead of msgnum
381 switch (c->room_default_view) {
382 case VIEW_CALENDAR: // RFC4791 section 5.2
383 StrBufAppendPrintf(Buf, "<C:supported-calendar-component-set><C:comp name=\"VEVENT\"/></C:supported-calendar-component-set>");
384 StrBufAppendPrintf(Buf, "<C:supported-calendar-data>");
385 StrBufAppendPrintf(Buf, "<C:calendar-data content-type=\"text/calendar\" version=\"2.0\"/>");
386 StrBufAppendPrintf(Buf, "</C:supported-calendar-data>");
387 enumerate_by_euid = 1;
389 case VIEW_TASKS: // RFC4791 section 5.2
390 StrBufAppendPrintf(Buf, "<C:supported-calendar-component-set><C:comp name=\"VTODO\"/></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_ADDRESSBOOK: // FIXME put some sort of CardDAV crapola here when we implement it
397 enumerate_by_euid = 1;
399 case VIEW_WIKI: // FIXME invent "WikiDAV" ? The versioning stuff in DAV could be useful.
400 enumerate_by_euid = 1;
404 // FIXME get the mtime
405 // StrBufAppendPrintf(Buf, "<D:getlastmodified>");
406 // escputs(datestring);
407 // StrBufAppendPrintf(Buf, "</D:getlastmodified>");
409 StrBufAppendPrintf(Buf, "</D:prop>");
410 StrBufAppendPrintf(Buf, "</D:propstat>");
411 StrBufAppendPrintf(Buf, "</D:response>\n");
413 // If a depth greater than zero was specified, transmit the collection listing
416 Array *msglist = get_msglist(c, "ALL");
419 for (i = 0; i < array_len(msglist); ++i) {
421 syslog(LOG_DEBUG, "PROPFIND enumerated %d messages", i);
423 e = NULL; // EUID gets stored here
427 memcpy(&m, array_get_element_at(msglist, i), sizeof(long));
430 ctdl_printf(c, "MSG0 %ld|3", m);
431 ctdl_readline(c, cbuf, sizeof(cbuf));
433 while (ctdl_readline(c, cbuf, sizeof(cbuf)), strcmp(cbuf, "000")) {
434 if ((enumerate_by_euid) && (!strncasecmp(cbuf, "exti=", 5))) {
435 // e = strdup(&cbuf[5]);
436 int elen = (2 * strlen(&cbuf[5]));
438 urlesc(e, elen, &cbuf[5]);
440 if (!strncasecmp(cbuf, "time=", 5)) {
441 timestamp = atol(&cbuf[5]);
446 sprintf(e, "%ld", m);
448 StrBufAppendPrintf(Buf, "<D:response>");
450 // Generate the 'href' tag for this message
451 StrBufAppendPrintf(Buf, "<D:href>");
452 StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0);
453 StrBufAppendPrintf(Buf, "/ctdl/r/");
454 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
455 StrBufAppendPrintf(Buf, "/");
456 StrBufXMLEscAppend(Buf, NULL, e, strlen(e), 0);
457 StrBufAppendPrintf(Buf, "</D:href>");
458 StrBufAppendPrintf(Buf, "<D:propstat>");
459 StrBufAppendPrintf(Buf, "<D:status>HTTP/1.1 200 OK</D:status>");
460 StrBufAppendPrintf(Buf, "<D:prop>");
462 switch (c->room_default_view) {
464 StrBufAppendPrintf(Buf,
465 "<D:getcontenttype>text/calendar; component=vevent</D:getcontenttype>");
468 StrBufAppendPrintf(Buf,
469 "<D:getcontenttype>text/calendar; component=vtodo</D:getcontenttype>");
471 case VIEW_ADDRESSBOOK:
472 StrBufAppendPrintf(Buf, "<D:getcontenttype>text/x-vcard</D:getcontenttype>");
477 char *datestring = http_datestring(timestamp);
479 StrBufAppendPrintf(Buf, "<D:getlastmodified>");
480 StrBufXMLEscAppend(Buf, NULL, datestring, strlen(datestring), 0);
481 StrBufAppendPrintf(Buf, "</D:getlastmodified>");
484 if (enumerate_by_euid) { // FIXME ajc 2017oct30 should this be inside the timestamp conditional?
485 StrBufAppendPrintf(Buf, "<D:getetag>\"%ld\"</D:getetag>", m);
488 StrBufAppendPrintf(Buf, "</D:prop></D:propstat></D:response>\n");
496 StrBufAppendPrintf(Buf, "</D:multistatus>\n");
498 add_response_header(h, strdup("Content-type"), strdup("text/xml"));
499 h->response_code = 207;
500 h->response_string = strdup("Multi-Status");
501 h->response_body_length = StrLength(Buf);
502 h->response_body = SmashStrBuf(&Buf);
505 // some good examples here
506 // http://blogs.nologin.es/rickyepoderi/index.php?/archives/14-Introducing-CalDAV-Part-I.html
509 // Called by the_room_itself() when the HTTP method is PROPFIND
510 void get_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
511 JsonValue *j = NewJsonObject(HKEY("gotoroom"));
513 JsonObjectAppend(j, NewJsonPlainString(HKEY("name"), c->room, -1));
514 JsonObjectAppend(j, NewJsonNumber(HKEY("current_view"), c->room_current_view));
515 JsonObjectAppend(j, NewJsonNumber(HKEY("default_view"), c->room_default_view));
516 JsonObjectAppend(j, NewJsonNumber(HKEY("is_room_aide"), c->is_room_aide));
517 JsonObjectAppend(j, NewJsonNumber(HKEY("is_trash_folder"), c->is_trash_folder));
518 JsonObjectAppend(j, NewJsonNumber(HKEY("can_delete_messages"), c->can_delete_messages));
519 JsonObjectAppend(j, NewJsonNumber(HKEY("new_messages"), c->new_messages));
520 JsonObjectAppend(j, NewJsonNumber(HKEY("total_messages"), c->total_messages));
521 JsonObjectAppend(j, NewJsonNumber(HKEY("last_seen"), c->last_seen));
522 JsonObjectAppend(j, NewJsonNumber(HKEY("room_mtime"), c->room_mtime));
524 StrBuf *sj = NewStrBuf();
525 SerializeJson(sj, j, 1); // '1' == free the source array
527 add_response_header(h, strdup("Content-type"), strdup("application/json"));
528 h->response_code = 200;
529 h->response_string = strdup("OK");
530 h->response_body_length = StrLength(sj);
531 h->response_body = SmashStrBuf(&sj);
536 // Handle REST/DAV requests for the room itself (such as /ctdl/r/roomname
537 // or /ctdl/r/roomname/ but *not* specific objects within the room)
538 void the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
540 // OPTIONS method on the room itself usually is a DAV client assessing what's here.
541 if (!strcasecmp(h->method, "OPTIONS")) {
542 options_the_room_itself(h, c);
546 // PROPFIND method on the room itself could be looking for a directory
547 if (!strcasecmp(h->method, "PROPFIND")) {
548 propfind_the_room_itself(h, c);
552 // REPORT method on the room itself is probably the dreaded CalDAV tower-of-crapola
553 if (!strcasecmp(h->method, "REPORT")) {
554 report_the_room_itself(h, c);
558 // GET method on the room itself is an API call, possibly from our JavaScript front end
559 if (!strcasecmp(h->method, "get")) {
560 get_the_room_itself(h, c);
564 // we probably want a "go to this room" for interactive access
569 // Dispatcher for "/ctdl/r" and "/ctdl/r/" for the room list
570 void room_list(struct http_transaction *h, struct ctdlsession *c) {
574 ctdl_printf(c, "LKRA");
575 ctdl_readline(c, buf, sizeof(buf));
581 JsonValue *j = NewJsonArray(HKEY("lkra"));
582 while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
584 // 0 |1 |2 |3 |4 |5 |6 |7 |8
585 // name|QRflags|QRfloor|QRorder|QRflags2|ra|current_view|default_view|mtime
586 JsonValue *jr = NewJsonObject(HKEY("room"));
588 extract_token(roomname, buf, 0, '|', sizeof roomname);
589 JsonObjectAppend(jr, NewJsonPlainString(HKEY("name"), roomname, -1));
591 JsonObjectAppend(jr, NewJsonNumber(HKEY("floor"), extract_int(buf, 2)));
592 JsonObjectAppend(jr, NewJsonNumber(HKEY("rorder"), extract_int(buf, 3)));
594 int ra = extract_int(buf, 5);
595 JsonObjectAppend(jr, NewJsonBool(HKEY("known"), (ra & UA_KNOWN)));
596 JsonObjectAppend(jr, NewJsonBool(HKEY("hasnewmsgs"), (ra & UA_HASNEWMSGS)));
598 JsonObjectAppend(jr, NewJsonNumber(HKEY("current_view"), extract_int(buf, 6)));
599 JsonObjectAppend(jr, NewJsonNumber(HKEY("default_view"), extract_int(buf, 7)));
600 JsonObjectAppend(jr, NewJsonNumber(HKEY("mtime"), extract_int(buf, 8)));
602 JsonArrayAppend(j, jr); // add the room to the array
605 StrBuf *sj = NewStrBuf();
606 SerializeJson(sj, j, 1); // '1' == free the source array
608 add_response_header(h, strdup("Content-type"), strdup("application/json"));
609 h->response_code = 200;
610 h->response_string = strdup("OK");
611 h->response_body_length = StrLength(sj);
612 h->response_body = SmashStrBuf(&sj);
616 // Dispatcher for paths starting with /ctdl/r/
617 void ctdl_r(struct http_transaction *h, struct ctdlsession *c) {
618 char requested_roomname[128];
621 long room_flags2 = 0;
623 // All room-related functions require being "in" the room specified. Are we in that room already?
624 extract_token(requested_roomname, h->url, 3, '/', sizeof requested_roomname);
625 unescape_input(requested_roomname);
627 if (IsEmptyStr(requested_roomname)) { // /ctdl/r/
631 // If not, try to go there.
632 if (strcasecmp(requested_roomname, c->room)) {
633 ctdl_printf(c, "GOTO %s", requested_roomname);
634 ctdl_readline(c, buf, sizeof(buf));
636 // buf[3] will indicate whether any instant messages are waiting
637 extract_token(c->room, &buf[4], 0, '|', sizeof c->room);
638 c->new_messages = extract_int(&buf[4], 1);
639 c->total_messages = extract_int(&buf[4], 2);
640 // 3 (int)info Info flag: set to nonzero if the user needs to read this room's info file
641 room_flags = extract_long(&buf[4], 3); // Various flags associated with this room.
642 // 5 (long)CC->room.QRhighest The highest message number present in this room
643 c->last_seen = extract_long(&buf[4], 6); // The highest message number the user has read in this room
644 // 7 (int)rmailflag Boolean flag: 1 if this is a Mail> room, 0 otherwise.
645 c->is_room_aide = extract_int(&buf[4], 8);
646 // 9 This position is no longer used
647 // 10 (int)CC->room.QRfloor The floor number this room resides on
648 c->room_current_view = extract_int(&buf[4], 11);
649 c->room_default_view = extract_int(&buf[4], 12);
650 c->is_trash_folder = extract_int(&buf[4], 13); // Boolean flag: 1 if this is the user's Trash folder, 0 otherwise.
651 room_flags2 = extract_long(&buf[4], 14); // More flags associated with this room.
652 c->room_mtime = extract_long(&buf[4], 15); // Timestamp of the last write activity in this room
654 // If any of these three conditions are met, let the client know it has permission to delete messages.
655 if ((c->is_room_aide) || (room_flags & QR_MAILBOX) || (room_flags2 & QR2_COLLABDEL)) {
656 c->can_delete_messages = 1;
659 c->can_delete_messages = 0;
667 // At this point our Citadel client session is "in" the specified room.
669 if (num_tokens(h->url, '/') == 4) { // /ctdl/r/roomname
670 the_room_itself(h, c);
674 extract_token(buf, h->url, 4, '/', sizeof buf);
675 if (num_tokens(h->url, '/') == 5) {
676 if (IsEmptyStr(buf)) {
677 the_room_itself(h, c); // /ctdl/r/roomname/ ( same as /ctdl/r/roomname )
680 object_in_room(h, c); // /ctdl/r/roomname/object
684 if (num_tokens(h->url, '/') >= 6) {
685 object_in_room(h, c); // /ctdl/r/roomname/object/ or possibly /ctdl/r/roomname/object/component
688 // If we get to this point, the client specified a valid room but requested an action we don't know how to perform.