]> code.citadel.org Git - citadel.git/blobdiff - webcit/groupdav_get.c
cosmetic stuff
[citadel.git] / webcit / groupdav_get.c
index 2a4d4cb543e78de07f1d68968bcea056ee839f20..267f4bd6f001d929add1e4546c2d0320f1268a18 100644 (file)
@@ -1,8 +1,21 @@
 /*
- * $Id$
- *
  * Handles GroupDAV GET requests.
  *
+ * Copyright (c) 2005-2010 by the citadel.org team
+ *
+ * This program is open source 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"
@@ -23,9 +36,11 @@ void groupdav_get_big_ics(void) {
                hprintf("HTTP/1.1 404 not found\r\n");
                groupdav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
-               wprintf("%s\r\n",
+               begin_burst();
+               wc_printf("%s\r\n",
                        &buf[4]
-                       );/* TODO: do we need to end-burst here? */
+                       );
+               end_burst();
                return;
        }
 
@@ -34,7 +49,7 @@ void groupdav_get_big_ics(void) {
        hprintf("Content-type: text/calendar; charset=UTF-8\r\n");
        begin_burst();
        while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-               wprintf("%s\r\n", buf);
+               wc_printf("%s\r\n", buf);
        }
        end_burst();
 }
@@ -86,7 +101,9 @@ void extract_preferred(char *name, char *filename, char *partnum, char *disp,
  * /groupdav/room_name/euid    (GroupDAV)
  * /groupdav/room_name         (webcal)
  */
-void groupdav_get(StrBuf *dav_pathname) {
+void groupdav_get(void)
+{
+       wcsession *WCC = WC;
        StrBuf *dav_roomname;
        StrBuf *dav_uid;
        long dav_msgnum = (-1);
@@ -104,33 +121,33 @@ void groupdav_get(StrBuf *dav_pathname) {
        char date[128];
        struct epdata epdata;
 
-       if (StrBufNum_tokens(dav_pathname, '/') < 3) {
+       if (StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/') < 2) {
                hprintf("HTTP/1.1 404 not found\r\n");
                groupdav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
-               wprintf("The object you requested was not found.\r\n");
+               wc_printf("The object you requested was not found.\r\n");
                end_burst();
                return;
        }
 
        dav_roomname = NewStrBuf();;
        dav_uid = NewStrBuf();;
-       StrBufExtract_token(dav_roomname, dav_pathname, 2, '/');
-       StrBufExtract_token(dav_uid, dav_pathname, 3, '/');
+       StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
+       StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
        if ((!strcasecmp(ChrPtr(dav_uid), "ics")) || 
            (!strcasecmp(ChrPtr(dav_uid), "calendar.ics"))) {
                FlushStrBuf(dav_uid);
        }
 
        /* Go to the correct room. */
-       if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
+       if (strcasecmp(ChrPtr(WCC->CurRoom.name), ChrPtr(dav_roomname))) {
                gotoroom(dav_roomname);
        }
-       if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
+       if (strcasecmp(ChrPtr(WCC->CurRoom.name), ChrPtr(dav_roomname))) {
                hprintf("HTTP/1.1 404 not found\r\n");
                groupdav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
-               wprintf("There is no folder called \"%s\" on this server.\r\n",
+               wc_printf("There is no folder called \"%s\" on this server.\r\n",
                        ChrPtr(dav_roomname));
                end_burst();
                FreeStrBuf(&dav_roomname);
@@ -154,7 +171,7 @@ void groupdav_get(StrBuf *dav_pathname) {
                hprintf("HTTP/1.1 404 not found\r\n");
                groupdav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
-               wprintf("Object \"%s\" was not found in the \"%s\" folder.\r\n",
+               wc_printf("Object \"%s\" was not found in the \"%s\" folder.\r\n",
                        ChrPtr(dav_uid),
                        ChrPtr(dav_roomname));
                end_burst();
@@ -226,11 +243,11 @@ void groupdav_get(StrBuf *dav_pathname) {
         */
        if (!strncasecmp(content_type, "multipart/", 10)) {
 
-               if ( (WC->wc_default_view == VIEW_CALENDAR) || (WC->wc_default_view == VIEW_TASKS) ) {
+               if ( (WCC->CurRoom.defview == VIEW_CALENDAR) || (WCC->CurRoom.defview == VIEW_TASKS) ) {
                        strcpy(epdata.desired_content_type_1, "text/calendar");
                }
 
-               else if (WC->wc_default_view == VIEW_ADDRESSBOOK) {
+               else if (WCC->CurRoom.defview == VIEW_ADDRESSBOOK) {
                        strcpy(epdata.desired_content_type_1, "text/vcard");
                        strcpy(epdata.desired_content_type_2, "text/x-vcard");
                }
@@ -251,7 +268,7 @@ void groupdav_get(StrBuf *dav_pathname) {
                        ptr = memreadline(ptr, buf, sizeof buf);
        
                        if (in_body) {
-                               wprintf("%s\r\n", buf);
+                               wc_printf("%s\r\n", buf);
                        }
                        else if ((buf[0] == 0) && (in_body == 0)) {
                                in_body = 1;