$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
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
-
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 \
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:
* 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;
/*
void groupdav_common_headers(void);
void groupdav_main(struct httprequest *);
void groupdav_get(char *);
+void groupdav_propfind(char *);
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();
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.
*/
"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);
- }
}
--- /dev/null
+/*
+ * $Id$
+ *
+ * Handles GroupDAV PROPFIND requests.
+ *
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <limits.h>
+#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <time.h>
+#include <pthread.h>
+#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"
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+ "<D:multistatus xmlns:D=\"DAV:\">\n"
+ );
+
+ serv_puts("MSGS ALL");
+ serv_gets(buf);
+ if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
+ wprintf(" <D:response>\n");
+ wprintf(" <D:href>%s/groupdav/Calendar/%s</D:href>\n", WC->http_host, buf);
+ wprintf(" <D:propstat>\n");
+ wprintf(" <D:status>HTTP/1.1 200 OK</D:status>\n");
+ wprintf(" <D:prop><D:getetag>\"%s\"</D:getetag></D:prop>\n", buf);
+ wprintf(" </D:propstat>\n");
+ wprintf(" </D:response>\n");
+ }
+
+ wprintf("</D:multistatus>\n");
+}
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;