Remove $Id$ tags from most of webcit
[citadel.git] / webcit / groupdav_delete.c
index 8aa9f3b57cd0a85f2162299ba7782cf34cc788b7..fee94eab094406a5b9e5777b278c232e0e314280 100644 (file)
@@ -1,8 +1,21 @@
 /*
- * $Id$
- *
  * Handles GroupDAV DELETE requests.
  *
+ * Copyright (c) 2005-2010 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "webcit.h"
 /*
  * The pathname is always going to be /groupdav/room_name/euid
  */
-void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
-       char dav_roomname[SIZ];
+void groupdav_delete(void) 
+{
+       wcsession *WCC = WC;
        char dav_uid[SIZ];
        long dav_msgnum = (-1);
        char buf[SIZ];
        int n = 0;
-       int len;
-
-       /* First, break off the "/groupdav/" prefix */
-       remove_token(dav_pathname, 0, '/');
-       remove_token(dav_pathname, 0, '/');
-
+       StrBuf *dav_roomname = NewStrBuf();
+       
        /* Now extract the message euid */
-       n = num_tokens(dav_pathname, '/');
-       extract_token(dav_uid, dav_pathname, n-1, '/', sizeof dav_uid);
-       remove_token(dav_pathname, n-1, '/');
+       n = StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/');
+       extract_token(dav_uid, ChrPtr(WCC->Hdr->HR.ReqLine), n-1, '/', sizeof dav_uid);
+       StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
 
-       /* What's left is the room name.  Remove trailing slashes. */
-       len = strlen(dav_pathname);
-       if (dav_pathname[len-1] == '/') {
-               dav_pathname[len-1] = 0;
-       }
-       strcpy(dav_roomname, dav_pathname);
+       ///* What's left is the room name.  Remove trailing slashes. */
+       //len = StrLength(WCC->Hdr->HR.ReqLine);
+       //if ((len > 0) && (ChrPtr(WCC->Hdr->HR.ReqLinee)[len-1] == '/')) {
+       //      StrBufCutRight(WCC->Hdr->HR.ReqLine, 1);
+       //}
+       //StrBufCutLeft(WCC->Hdr->HR.ReqLine, 1);
 
        /* Go to the correct room. */
-       if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+       if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
                gotoroom(dav_roomname);
        }
-       if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+       if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
                hprintf("HTTP/1.1 404 not found\r\n");
                groupdav_common_headers();
                hprintf("Content-Length: 0\r\n\r\n");
+               begin_burst();
+               end_burst();
+               FreeStrBuf(&dav_roomname);
                return;
        }
 
@@ -57,6 +70,9 @@ void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
                hprintf("HTTP/1.1 404 Not Found\r\n");
                groupdav_common_headers();
                hprintf("Content-Length: 0\r\n\r\n");
+               begin_burst();
+               end_burst();
+               FreeStrBuf(&dav_roomname);
                return;
        }
 
@@ -64,11 +80,14 @@ void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
         * It's there ... check the ETag and make sure it matches
         * the message number.
         */
-       if (!IsEmptyStr(dav_ifmatch)) {
-               if (atol(dav_ifmatch) != dav_msgnum) {
+       if (StrLength(WCC->Hdr->HR.dav_ifmatch) > 0) {
+               if (StrTol(WCC->Hdr->HR.dav_ifmatch) != dav_msgnum) {
                        hprintf("HTTP/1.1 412 Precondition Failed\r\n");
                        groupdav_common_headers();
                        hprintf("Content-Length: 0\r\n\r\n");
+                       begin_burst();
+                       end_burst();
+                       FreeStrBuf(&dav_roomname);
                        return;
                }
        }
@@ -82,11 +101,16 @@ void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
                hprintf("HTTP/1.1 204 No Content\r\n"); /* success */
                groupdav_common_headers();
                hprintf("Content-Length: 0\r\n\r\n");
+               begin_burst();
+               end_burst();
        }
        else {
                hprintf("HTTP/1.1 403 Forbidden\r\n");  /* access denied */
                groupdav_common_headers();
                hprintf("Content-Length: 0\r\n\r\n");
+               begin_burst();
+               end_burst();
        }
+       FreeStrBuf(&dav_roomname);
        return;
 }