]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/imap/imap_acl.c
More removal of $Id$ tags
[citadel.git] / citadel / modules / imap / imap_acl.c
index 1632532db3675e21f73983dc17a03295fad1b946..76fc7e4f7ffb7a244c84b8d74a981485847c0fdd 100644 (file)
@@ -1,11 +1,24 @@
 /*
- * $Id$
- *
  * Functions which implement RFC2086 (and maybe RFC4314) (IMAP ACL 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
  */
 
-
 #include "sysdep.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <ctype.h>
 #include <string.h>
 #include <limits.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
-#include "room_ops.h"
 #include "user_ops.h"
-#include "policy.h"
 #include "database.h"
 #include "msgbase.h"
-#include "tools.h"
 #include "internet_addressing.h"
-#include "serv_imap.h"
 #include "imap_tools.h"
+#include "serv_imap.h"
 #include "imap_fetch.h"
 #include "imap_misc.h"
 #include "genstamp.h"
-
+#include "ctdl_module.h"
 
 
 /*
  * Implements the SETACL command.
  */
-void imap_setacl(int num_parms, char *parms[]) {
+void imap_setacl(int num_parms, ConstStr *Params) {
 
-       cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
+       cprintf("%s BAD not yet implemented FIXME\r\n", Params[0].Key);
        return;
 }
 
@@ -65,9 +76,9 @@ void imap_setacl(int num_parms, char *parms[]) {
 /*
  * Implements the DELETEACL command.
  */
-void imap_deleteacl(int num_parms, char *parms[]) {
+void imap_deleteacl(int num_parms, ConstStr *Params) {
 
-       cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
+       cprintf("%s BAD not yet implemented FIXME\r\n", Params[0].Key);
        return;
 }
 
@@ -86,7 +97,7 @@ void imap_acl_flags(char *rights, int ra)
         */
        if (    (ra & UA_KNOWN)                                 /* known rooms */
           ||   ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED))     /* zapped rooms */
-          ) {
+       ) {
                strcat(rights, "l");
                strcat(rights, "r");
                strcat(rights, "s");
@@ -118,8 +129,9 @@ void imap_acl_flags(char *rights, int ra)
                         * commands are not yet implemented, omitting the flag should
                         * theoretically prevent compliant clients from attempting to
                         * perform them.
+                        *
+                        * strcat(rights, "a");
                         */
-                       /* strcat(rights, "a"); * commented out */
                }
        }
 }
@@ -128,7 +140,7 @@ void imap_acl_flags(char *rights, int ra)
 /*
  * Implements the GETACL command.
  */
-void imap_getacl(int num_parms, char *parms[]) {
+void imap_getacl(int num_parms, ConstStr *Params) {
        char roomname[ROOMNAMELEN];
        char savedroom[ROOMNAMELEN];
        int msgs, new;
@@ -139,32 +151,31 @@ void imap_getacl(int num_parms, char *parms[]) {
        char rights[32];
 
        if (num_parms != 3) {
-               cprintf("%s BAD usage error\r\n", parms[0]);
+               cprintf("%s BAD usage error\r\n", Params[0].Key);
                return;
        }
 
        /*
         * Search for the specified room or folder
         */
-       ret = imap_grabroom(roomname, parms[2], 0);
+       ret = imap_grabroom(roomname, Params[2].Key, 1);
        if (ret != 0) {
-               cprintf("%s NO Invalid mailbox name or access denied\r\n",
-                       parms[0]);
+               cprintf("%s NO Invalid mailbox name or access denied\r\n", Params[0].Key);
                return;
        }
 
        /*
-        * 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("* ACL");
        cprintf(" ");
-       imap_strout(parms[2]);
+       imap_strout(&Params[2]);
 
        /*
         * Traverse the userlist
@@ -176,11 +187,11 @@ void imap_getacl(int num_parms, char *parms[]) {
                cdb_free(cdbus);
 
                CtdlRoomAccess(&CC->room, &temp, &ra, NULL);
-               if (strlen(temp.fullname) > 0) {
+               if (!IsEmptyStr(temp.fullname)) {
                        imap_acl_flags(rights, ra);
-                       if (strlen(rights) > 0) {
+                       if (!IsEmptyStr(rights)) {
                                cprintf(" ");
-                               imap_strout(temp.fullname);
+                               plain_imap_strout(temp.fullname);
                                cprintf(" %s", rights);
                        }
                }
@@ -193,17 +204,17 @@ void imap_getacl(int num_parms, char *parms[]) {
         * our happy day without violent explosions.
         */
        if (IMAP->selected) {
-               usergoto(savedroom, 0, 0, &msgs, &new);
+               CtdlUserGoto(savedroom, 0, 0, &msgs, &new);
        }
 
-       cprintf("%s OK GETACL completed\r\n", parms[0]);
+       cprintf("%s OK GETACL completed\r\n", Params[0].Key);
 }
 
 
 /*
  * Implements the LISTRIGHTS command.
  */
-void imap_listrights(int num_parms, char *parms[]) {
+void imap_listrights(int num_parms, ConstStr *Params) {
        char roomname[ROOMNAMELEN];
        char savedroom[ROOMNAMELEN];
        int msgs, new;
@@ -212,17 +223,16 @@ void imap_listrights(int num_parms, char *parms[]) {
        struct ctdluser temp;
 
        if (num_parms != 4) {
-               cprintf("%s BAD usage error\r\n", parms[0]);
+               cprintf("%s BAD usage error\r\n", Params[0].Key);
                return;
        }
 
        /*
         * Search for the specified room/folder
         */
-       ret = imap_grabroom(roomname, parms[2], 0);
+       ret = imap_grabroom(roomname, Params[2].Key, 1);
        if (ret != 0) {
-               cprintf("%s NO Invalid mailbox name or access denied\r\n",
-                       parms[0]);
+               cprintf("%s NO Invalid mailbox name or access denied\r\n", Params[0].Key);
                return;
        }
 
@@ -230,50 +240,47 @@ void imap_listrights(int num_parms, char *parms[]) {
         * Search for the specified user
         */
        ret = (-1);
-       valid = validate_recipients(parms[3]);
+       valid = validate_recipients(Params[3].Key, NULL, 0);
        if (valid != NULL) {
                if (valid->num_local == 1) {
-                       ret = getuser(&temp, valid->recp_local);
+                       ret = CtdlGetUser(&temp, valid->recp_local);
                }
                free_recipients(valid);
        }
        if (ret != 0) {
-               cprintf("%s NO Invalid user name or access denied\r\n",
-                       parms[0]);
+               cprintf("%s NO Invalid user name or access denied\r\n", Params[0].Key);
                return;
        }
 
        /*
-        * 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);
 
        /*
         * Now output the list of rights
         */
        cprintf("* LISTRIGHTS ");
-       imap_strout(parms[2]);
+       imap_strout(&Params[2]);
        cprintf(" ");
-       imap_strout(parms[3]);
+       imap_strout(&Params[3]);
        cprintf(" ");
-       imap_strout("");                /* FIXME ... do something here */
+       plain_imap_strout("");          /* FIXME ... do something here */
        cprintf("\r\n");
 
-
        /*
         * If another folder is selected, go back to that room so we can resume
         * our happy day without violent explosions.
         */
        if (IMAP->selected) {
-               usergoto(savedroom, 0, 0, &msgs, &new);
+               CtdlUserGoto(savedroom, 0, 0, &msgs, &new);
        }
 
-       cprintf("%s OK LISTRIGHTS completed\r\n", parms[0]);
+       cprintf("%s OK LISTRIGHTS completed\r\n", Params[0].Key);
        return;
 }
 
@@ -281,7 +288,7 @@ void imap_listrights(int num_parms, char *parms[]) {
 /*
  * Implements the MYRIGHTS command.
  */
-void imap_myrights(int num_parms, char *parms[]) {
+void imap_myrights(int num_parms, ConstStr *Params) {
        char roomname[ROOMNAMELEN];
        char savedroom[ROOMNAMELEN];
        int msgs, new;
@@ -290,42 +297,39 @@ void imap_myrights(int num_parms, char *parms[]) {
        char rights[32];
 
        if (num_parms != 3) {
-               cprintf("%s BAD usage error\r\n", parms[0]);
+               cprintf("%s BAD usage error\r\n", Params[0].Key);
                return;
        }
 
-       ret = imap_grabroom(roomname, parms[2], 0);
+       ret = imap_grabroom(roomname, Params[2].Key, 1);
        if (ret != 0) {
-               cprintf("%s NO Invalid mailbox name or access denied\r\n",
-                       parms[0]);
+               cprintf("%s NO Invalid mailbox name or access denied\r\n", Params[0].Key);
                return;
        }
 
        /*
-        * 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);
 
        CtdlRoomAccess(&CC->room, &CC->user, &ra, NULL);
        imap_acl_flags(rights, ra);
 
        cprintf("* MYRIGHTS ");
-       imap_strout(parms[2]);
+       imap_strout(&Params[2]);
        cprintf(" %s\r\n", rights);
 
        /*
         * 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 MYRIGHTS completed\r\n", parms[0]);
+       cprintf("%s OK MYRIGHTS completed\r\n", Params[0].Key);
        return;
 }
-
-