Citadel API clean up.
[citadel.git] / citadel / modules / imap / imap_metadata.c
index fef885071bb7e2a73afbc64048b17ef1695703d0..8e173a0f396a64ec3d08b24fc9e2f9e96cbd0470 100644 (file)
@@ -5,6 +5,21 @@
  *
  * This is an implementation of the Bynari variant of the METADATA extension.
  *
+ * Copyright (c) 2007-2009 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
  */
 
 
@@ -40,7 +55,6 @@
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
-#include "room_ops.h"
 #include "user_ops.h"
 #include "policy.h"
 #include "database.h"
@@ -52,7 +66,7 @@
 #include "imap_misc.h"
 #include "genstamp.h"
 
-
+#include "ctdl_module.h"
 
 /*
  * Implements the SETMETADATA command.
@@ -123,7 +137,7 @@ void imap_setmetadata(int num_parms, char *parms[]) {
                set_view = VIEW_MAILBOX;
        }
 
-       ret = imap_grabroom(roomname, parms[2], 0);
+       ret = imap_grabroom(roomname, parms[2], 1);
        if (ret != 0) {
                cprintf("%s NO Invalid mailbox name or access denied\r\n",
                        parms[0]);
@@ -131,13 +145,13 @@ void imap_setmetadata(int num_parms, char *parms[]) {
        }
 
        /*
-        * usergoto() formally takes us to the desired room.  (If another
+        * CtdlUserGoto() formally takes us to the desired room.  (If another
         * folder is selected, save its name so we can return there!!!!!)
         */
        if (IMAP->selected) {
                strcpy(savedroom, CC->room.QRname);
        }
-       usergoto(roomname, 0, 0, &msgs, &new);
+       CtdlUserGoto(roomname, 0, 0, &msgs, &new);
 
        /*
         * Always set the per-user view to the requested one.
@@ -162,9 +176,9 @@ void imap_setmetadata(int num_parms, char *parms[]) {
                        )
                ||      (msgs == 0)             /* hack: if room is empty, assume we just created it */
        ) {
-               lgetroom(&CC->room, CC->room.QRname);
+               CtdlGetRoomLock(&CC->room, CC->room.QRname);
                CC->room.QRdefaultview = set_view;
-               lputroom(&CC->room);
+               CtdlPutRoomLock(&CC->room);
                cprintf("%s OK SETANNOTATION complete\r\n", parms[0]);
        }
 
@@ -177,7 +191,7 @@ void imap_setmetadata(int num_parms, char *parms[]) {
         * If a different folder was previously selected, return there now.
         */
        if ( (IMAP->selected) && (strcasecmp(roomname, savedroom)) ) {
-               usergoto(savedroom, 0, 0, &msgs, &new);
+               CtdlUserGoto(savedroom, 0, 0, &msgs, &new);
        }
        return;
 }
@@ -200,7 +214,7 @@ void imap_getmetadata(int num_parms, char *parms[]) {
                return;
        }
 
-       ret = imap_grabroom(roomname, parms[2], 0);
+       ret = imap_grabroom(roomname, parms[2], 1);
        if (ret != 0) {
                cprintf("%s NO Invalid mailbox name or access denied\r\n",
                        parms[0]);
@@ -208,13 +222,13 @@ void imap_getmetadata(int num_parms, char *parms[]) {
        }
 
        /*
-        * usergoto() formally takes us to the desired room.  (If another
+        * CtdlUserGoto() formally takes us to the desired room.  (If another
         * folder is selected, save its name so we can return there!!!!!)
         */
        if (IMAP->selected) {
                strcpy(savedroom, CC->room.QRname);
        }
-       usergoto(roomname, 0, 0, &msgs, &new);
+       CtdlUserGoto(roomname, 0, 0, &msgs, &new);
 
        cprintf("* METADATA ");
        imap_strout(parms[2]);
@@ -228,6 +242,9 @@ void imap_getmetadata(int num_parms, char *parms[]) {
        else if (!strcasecmp(&CC->room.QRname[11], SENTITEMS)) {
                cprintf("mail.sentitems");
        }
+       else if (!strcasecmp(&CC->room.QRname[11], USERDRAFTROOM)) {
+               cprintf("mail.drafts");
+       }
        else if (!strcasecmp(&CC->room.QRname[11], USERCALENDARROOM)) {
                cprintf("event.default");
        }
@@ -277,7 +294,7 @@ void imap_getmetadata(int num_parms, char *parms[]) {
         * If a different folder was previously selected, return there now.
         */
        if ( (IMAP->selected) && (strcasecmp(roomname, savedroom)) ) {
-               usergoto(savedroom, 0, 0, &msgs, &new);
+               CtdlUserGoto(savedroom, 0, 0, &msgs, &new);
        }
 
        cprintf("%s OK GETMETADATA complete\r\n", parms[0]);