From d06bcd41e24dc33a726bd0965950c32a3746476f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 26 Jan 2005 18:02:23 +0000 Subject: [PATCH] * Initial implementation of GroupDAV PROPFIND --- webcit/ChangeLog | 4 +- webcit/Makefile.in | 4 +- webcit/context_loop.c | 4 +- webcit/groupdav.h | 1 + webcit/groupdav_main.c | 24 +++++------ webcit/groupdav_propfind.c | 88 ++++++++++++++++++++++++++++++++++++++ webcit/webcit.c | 16 ++++--- 7 files changed, 117 insertions(+), 24 deletions(-) create mode 100644 webcit/groupdav_propfind.c diff --git a/webcit/ChangeLog b/webcit/ChangeLog index ee48e47d9..ee8dcf4e3 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 528.22 2005/01/26 18:02:22 ajc +* Initial implementation of GroupDAV PROPFIND + Revision 528.21 2005/01/26 16:28:23 ajc * Output ETags in double quotes to conform with the new GroupDAV draft. * Output HTTP Server: header in GroupDAV transactions @@ -2233,4 +2236,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/Makefile.in b/webcit/Makefile.in index 1a0de31e5..212ae266d 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -37,7 +37,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \ mime_parser.o graphics.o netconf.o siteconfig.o subst.o \ calendar.o calendar_tools.o calendar_view.o event.o \ availability.o iconbar.o crypto.o inetconf.o notes.o \ - groupdav_main.o groupdav_get.o \ + groupdav_main.o groupdav_get.o groupdav_propfind.o \ $(LIBOBJS) $(CC) webserver.o context_loop.o tools.o cookie_conversion.o \ webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \ @@ -46,7 +46,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \ mime_parser.o graphics.o netconf.o preferences.o html2html.o \ summary.o calendar.o calendar_tools.o calendar_view.o event.o \ availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \ - groupdav_main.o groupdav_get.o \ + groupdav_main.o groupdav_get.o groupdav_propfind.o \ $(LIBOBJS) $(LIBS) $(LDFLAGS) -o webserver .c.o: diff --git a/webcit/context_loop.c b/webcit/context_loop.c index f0c8e553b..f4bd27372 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -323,9 +323,7 @@ void context_loop(int sock) * set. If there isn't, the client browser has cookies turned off * (or doesn't support them) and we have to barf & bail. */ - if (!strncasecmp(buf, "GET ", 4)) strcpy(buf, &buf[4]); - else if (!strncasecmp(buf, "HEAD ", 5)) strcpy(buf, &buf[5]); - else if (!strncasecmp(buf, "POST ", 5)) strcpy(buf, &buf[5]); + remove_token(buf, 0, ' '); if (buf[1]==' ') buf[1]=0; /* diff --git a/webcit/groupdav.h b/webcit/groupdav.h index 6fcc96ffa..4a71cd306 100644 --- a/webcit/groupdav.h +++ b/webcit/groupdav.h @@ -3,3 +3,4 @@ void groupdav_common_headers(void); void groupdav_main(struct httprequest *); void groupdav_get(char *); +void groupdav_propfind(char *); diff --git a/webcit/groupdav_main.c b/webcit/groupdav_main.c index 44701d0ad..6dca61e58 100644 --- a/webcit/groupdav_main.c +++ b/webcit/groupdav_main.c @@ -47,6 +47,10 @@ void groupdav_main(struct httprequest *req) { char dav_method[SIZ]; char dav_pathname[SIZ]; + for (rptr=req; rptr!=NULL; rptr=rptr->next) { + lprintf(9, "> %s\n", rptr->line); + } + if (!WC->logged_in) { wprintf("HTTP/1.1 401 Unauthorized\n"); groupdav_common_headers(); @@ -69,6 +73,14 @@ void groupdav_main(struct httprequest *req) { return; } + /* + * The PROPFIND method is basically used to list all objects in a room. + */ + if (!strcasecmp(dav_method, "PROPFIND")) { + groupdav_propfind(dav_pathname); + return; + } + /* * Couldn't find what we were looking for. Die in a car fire. */ @@ -79,16 +91,4 @@ void groupdav_main(struct httprequest *req) { "GroupDAV method \"%s\" is not implemented.\n", dav_method ); - - /* - * FIXME ... after development is finished, get rid of all this - */ - wprintf("\n\n\n ** DEBUGGING INFO FOLLOWS ** \n\n"); - wprintf("WC->httpauth_user = %s\n", WC->httpauth_user); - wprintf("WC->httpauth_pass = (%d characters)\n", strlen(WC->httpauth_pass)); - wprintf("WC->wc_session = %d\n", WC->wc_session); - - for (rptr=req; rptr!=NULL; rptr=rptr->next) { - wprintf("> %s\n", rptr->line); - } } diff --git a/webcit/groupdav_propfind.c b/webcit/groupdav_propfind.c new file mode 100644 index 000000000..171de4170 --- /dev/null +++ b/webcit/groupdav_propfind.c @@ -0,0 +1,88 @@ +/* + * $Id$ + * + * Handles GroupDAV PROPFIND requests. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "webcit.h" +#include "webserver.h" +#include "groupdav.h" + + +/* + * The pathname is always going to be /groupdav/room_name/msg_num + */ +void groupdav_propfind(char *dav_pathname) { + char dav_roomname[SIZ]; + char buf[SIZ]; + + /* First, break off the "/groupdav/" prefix */ + remove_token(dav_pathname, 0, '/'); + remove_token(dav_pathname, 0, '/'); + + /* What's left is the room name. Remove trailing slashes. */ + if (dav_pathname[strlen(dav_pathname)-1] == '/') { + dav_pathname[strlen(dav_pathname)-1] = 0; + } + strcpy(dav_roomname, dav_pathname); + + /* Go to the correct room. */ + if (strcasecmp(WC->wc_roomname, dav_roomname)) { + gotoroom(dav_roomname); + } + if (strcasecmp(WC->wc_roomname, dav_roomname)) { + wprintf("HTTP/1.1 404 not found\n"); + groupdav_common_headers(); + wprintf( + "Content-Type: text/plain\n" + "\n" + "There is no folder called \"%s\" on this server.\n", + dav_roomname + ); + return; + } + + /* + * Be rude. Completely ignore the XML request and simply send them + * everything we know about (which is going to simply be the ETag and + * nothing else). Let the client-side parser sort it out. + */ + wprintf("HTTP/1.0 207 Multi-Status\n"); + groupdav_common_headers(); + wprintf("Content-type: text/xml\n" + "\n" + "\n" + "\n" + ); + + serv_puts("MSGS ALL"); + serv_gets(buf); + if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) { + wprintf(" \n"); + wprintf(" %s/groupdav/Calendar/%s\n", WC->http_host, buf); + wprintf(" \n"); + wprintf(" HTTP/1.1 200 OK\n"); + wprintf(" \"%s\"\n", buf); + wprintf(" \n"); + wprintf(" \n"); + } + + wprintf("\n"); +} diff --git a/webcit/webcit.c b/webcit/webcit.c index e34d0d405..b873635d1 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -745,13 +745,17 @@ void extract_action(char *actbuf, char *cmdbuf) int i; strcpy(actbuf, cmdbuf); - if (!strncasecmp(actbuf, "GET /", 5)) - strcpy(actbuf, &actbuf[5]); - if (!strncasecmp(actbuf, "PUT /", 5)) - strcpy(actbuf, &actbuf[5]); - if (!strncasecmp(actbuf, "POST /", 6)) - strcpy(actbuf, &actbuf[6]); + /* + * First strip out the http method + */ + remove_token(actbuf, 0, ' '); + if (actbuf[0] == ' ') strcpy(actbuf, &actbuf[1]); + if (actbuf[0] == '/') strcpy(actbuf, &actbuf[1]); + + /* + * Now kill invalid (for webcit) characters + */ for (i = 0; i < strlen(actbuf); ++i) { if (actbuf[i] == ' ') { actbuf[i] = 0; -- 2.39.2