X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=webcit-ng%2Froom_functions.c;h=5e432db8ec3dd44b8cf4994ba34b8ff84f8d3a54;hp=dbb6321bde35cfbb1e45e497f78b8ada62a3fb4a;hb=d337527fdb58a5496428babc0d68736ada0d4c0e;hpb=a112ae0472a232be5484c7a9aafc5a880a361c34 diff --git a/webcit-ng/room_functions.c b/webcit-ng/room_functions.c index dbb6321bd..5e432db8e 100644 --- a/webcit-ng/room_functions.c +++ b/webcit-ng/room_functions.c @@ -1,7 +1,7 @@ // // Room functions // -// Copyright (c) 1996-2019 by the citadel.org team +// Copyright (c) 1996-2021 by the citadel.org team // // This program is open source software. It runs great on the // Linux operating system (and probably elsewhere). You can use, @@ -20,8 +20,7 @@ * Return a "zero-terminated" array of message numbers in the current room. * Caller owns the memory and must free it. Returns NULL if any problems. */ -long *get_msglist(struct ctdlsession *c, char *which_msgs) -{ +long *get_msglist(struct ctdlsession *c, char *which_msgs) { char buf[1024]; long *msglist = NULL; int num_msgs = 0; @@ -53,8 +52,7 @@ long *get_msglist(struct ctdlsession *c, char *which_msgs) * a message number (which we always use as the entity tag in Citadel), return nonzero if the * message number matches any of the supplied tags in the string. */ -int match_etags(char *taglist, long msgnum) -{ +int match_etags(char *taglist, long msgnum) { int num_tags = num_tokens(taglist, ','); int i = 0; char tag[1024]; @@ -89,8 +87,7 @@ int match_etags(char *taglist, long msgnum) /* * Client is requesting a message list */ -void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which) -{ +void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which) { int i = 0; long *msglist = get_msglist(c, which); JsonValue *j = NewJsonArray(HKEY("msgs")); @@ -117,8 +114,7 @@ void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which /* * Client requested an object in a room. */ -void object_in_room(struct http_transaction *h, struct ctdlsession *c) -{ +void object_in_room(struct http_transaction *h, struct ctdlsession *c) { char buf[1024]; long msgnum = (-1); char unescaped_euid[1024]; @@ -205,11 +201,14 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) if (!strcasecmp(h->method, "DELETE")) { dav_delete_message(h, c, msgnum); - } else if (!strcasecmp(h->method, "GET")) { + } + else if (!strcasecmp(h->method, "GET")) { dav_get_message(h, c, msgnum); - } else if (!strcasecmp(h->method, "PUT")) { + } + else if (!strcasecmp(h->method, "PUT")) { dav_put_message(h, c, unescaped_euid, msgnum); - } else { + } + else { do_404(h); // Got this far but the method made no sense? Bummer. } @@ -219,8 +218,7 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) /* * Called by the_room_itself() when the HTTP method is REPORT */ -void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c) -{ +void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c) { if (c->room_default_view == VIEW_CALENDAR) { caldav_report(h, c); // CalDAV REPORTs ... fmgwac return; @@ -233,15 +231,16 @@ void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c) /* * Called by the_room_itself() when the HTTP method is OPTIONS */ -void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c) -{ +void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c) { h->response_code = 200; h->response_string = strdup("OK"); if (c->room_default_view == VIEW_CALENDAR) { add_response_header(h, strdup("DAV"), strdup("1, calendar-access")); // offer CalDAV - } else if (c->room_default_view == VIEW_ADDRESSBOOK) { + } + else if (c->room_default_view == VIEW_ADDRESSBOOK) { add_response_header(h, strdup("DAV"), strdup("1, addressbook")); // offer CardDAV - } else { + } + else { add_response_header(h, strdup("DAV"), strdup("1")); // ordinary WebDAV for all other room types } add_response_header(h, strdup("Allow"), strdup("OPTIONS, PROPFIND, GET, PUT, REPORT, DELETE")); @@ -251,8 +250,7 @@ void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c) /* * Called by the_room_itself() when the HTTP method is PROPFIND */ -void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) -{ +void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) { char *e; long timestamp; int dav_depth = (header_val(h, "Depth") ? atoi(header_val(h, "Depth")) : INT_MAX); @@ -289,31 +287,28 @@ void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) int enumerate_by_euid = 0; // nonzero if messages will be retrieved by euid instead of msgnum switch (c->room_default_view) { - case VIEW_CALENDAR: // RFC4791 section 5.2 - StrBufAppendPrintf(Buf, - ""); + case VIEW_CALENDAR: // RFC4791 section 5.2 + StrBufAppendPrintf(Buf, ""); StrBufAppendPrintf(Buf, ""); StrBufAppendPrintf(Buf, ""); StrBufAppendPrintf(Buf, ""); enumerate_by_euid = 1; break; - case VIEW_TASKS: // RFC4791 section 5.2 - StrBufAppendPrintf(Buf, - ""); + case VIEW_TASKS: // RFC4791 section 5.2 + StrBufAppendPrintf(Buf, ""); StrBufAppendPrintf(Buf, ""); StrBufAppendPrintf(Buf, ""); StrBufAppendPrintf(Buf, ""); enumerate_by_euid = 1; break; - case VIEW_ADDRESSBOOK: // FIXME put some sort of CardDAV crapola here when we implement it + case VIEW_ADDRESSBOOK: // FIXME put some sort of CardDAV crapola here when we implement it enumerate_by_euid = 1; break; - case VIEW_WIKI: // FIXME invent "WikiDAV" ? + case VIEW_WIKI: // FIXME invent "WikiDAV" ? enumerate_by_euid = 1; break; } - /* FIXME get the mtime StrBufAppendPrintf(Buf, ""); escputs(datestring); @@ -447,32 +442,32 @@ void get_the_room_itself(struct http_transaction *h, struct ctdlsession *c) * Handle REST/DAV requests for the room itself (such as /ctdl/r/roomname * or /ctdl/r/roomname/ but *not* specific objects within the room) */ -void the_room_itself(struct http_transaction *h, struct ctdlsession *c) -{ - // OPTIONS method on the room itself usually is a DAV client assessing what's here. +void the_room_itself(struct http_transaction *h, struct ctdlsession *c) { + // OPTIONS method on the room itself usually is a DAV client assessing what's here. if (!strcasecmp(h->method, "OPTIONS")) { options_the_room_itself(h, c); return; } - // PROPFIND method on the room itself could be looking for a directory + // PROPFIND method on the room itself could be looking for a directory if (!strcasecmp(h->method, "PROPFIND")) { propfind_the_room_itself(h, c); return; } - // REPORT method on the room itself is probably the dreaded CalDAV tower-of-crapola + // REPORT method on the room itself is probably the dreaded CalDAV tower-of-crapola if (!strcasecmp(h->method, "REPORT")) { report_the_room_itself(h, c); return; } - // GET method on the room itself is an API call, possibly from our JavaScript front end + // GET method on the room itself is an API call, possibly from our JavaScript front end if (!strcasecmp(h->method, "get")) { get_the_room_itself(h, c); return; } + // we probably want a "go to this room" for interactive access do_404(h); } @@ -481,8 +476,7 @@ void the_room_itself(struct http_transaction *h, struct ctdlsession *c) /* * Dispatcher for "/ctdl/r" and "/ctdl/r/" for the room list */ -void room_list(struct http_transaction *h, struct ctdlsession *c) -{ +void room_list(struct http_transaction *h, struct ctdlsession *c) { char buf[1024]; char roomname[1024]; @@ -529,8 +523,7 @@ void room_list(struct http_transaction *h, struct ctdlsession *c) /* * Dispatcher for paths starting with /ctdl/r/ */ -void ctdl_r(struct http_transaction *h, struct ctdlsession *c) -{ +void ctdl_r(struct http_transaction *h, struct ctdlsession *c) { char requested_roomname[128]; char buf[1024];